more swift files

This commit is contained in:
Scott Pfeil 2023-04-18 09:07:11 -04:00
parent a08a2c678b
commit 657e69b798
8 changed files with 31 additions and 117 deletions

View File

@ -291,6 +291,7 @@
AFA4932029E5CA73001A9663 /* AlertOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFA4931F29E5CA73001A9663 /* AlertOperation.swift */; };
AFA4932229E5EF2E001A9663 /* TopNotificationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFA4932129E5EF2E001A9663 /* TopNotificationHandler.swift */; };
AFA4933F29E874F0001A9663 /* MVMCoreUILoggingDelegateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFA4933E29E874F0001A9663 /* MVMCoreUILoggingDelegateProtocol.swift */; };
AFA4935729EE3DCC001A9663 /* AlertDelegateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFA4935629EE3DCC001A9663 /* AlertDelegateProtocol.swift */; };
AFE4A1D127DFB5EE00C458D0 /* VDSColorTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */; };
AFE4A1D627DFBB6F00C458D0 /* UINavigationController+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */; };
BB105859248DEFF70069D008 /* UICollectionViewLeftAlignedLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */; };
@ -562,7 +563,6 @@
D2ED27EC254B0CE700A1C293 /* UIAlertControllerStyle+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2ED27E7254B0CE600A1C293 /* UIAlertControllerStyle+Extension.swift */; };
D2ED27EE254B0CE700A1C293 /* ActionAlertModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2ED27E9254B0CE600A1C293 /* ActionAlertModel.swift */; };
D2ED27EF254B0CE700A1C293 /* AlertModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2ED27EA254B0CE700A1C293 /* AlertModel.swift */; };
D2ED27FB254B0E0300A1C293 /* MVMCoreAlertDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED27F2254B0E0200A1C293 /* MVMCoreAlertDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
D2ED27FC254B0E0300A1C293 /* AlertObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2ED27F3254B0E0200A1C293 /* AlertObject.swift */; };
D2ED280C254B0EB800A1C293 /* MVMCoreTopAlertAnimationDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED2805254B0EB700A1C293 /* MVMCoreTopAlertAnimationDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
D2ED280D254B0EB800A1C293 /* MVMCoreTopAlertOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED2806254B0EB700A1C293 /* MVMCoreTopAlertOperation.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -896,6 +896,7 @@
AFA4931F29E5CA73001A9663 /* AlertOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertOperation.swift; sourceTree = "<group>"; };
AFA4932129E5EF2E001A9663 /* TopNotificationHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopNotificationHandler.swift; sourceTree = "<group>"; };
AFA4933E29E874F0001A9663 /* MVMCoreUILoggingDelegateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUILoggingDelegateProtocol.swift; sourceTree = "<group>"; };
AFA4935629EE3DCC001A9663 /* AlertDelegateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertDelegateProtocol.swift; sourceTree = "<group>"; };
AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSColorTokens.xcframework; path = ../SharedFrameworks/VDSColorTokens.xcframework; sourceTree = "<group>"; };
AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Extension.swift"; sourceTree = "<group>"; };
BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICollectionViewLeftAlignedLayout.swift; sourceTree = "<group>"; };
@ -1168,9 +1169,7 @@
D2ED27E7254B0CE600A1C293 /* UIAlertControllerStyle+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIAlertControllerStyle+Extension.swift"; sourceTree = "<group>"; };
D2ED27E9254B0CE600A1C293 /* ActionAlertModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionAlertModel.swift; sourceTree = "<group>"; };
D2ED27EA254B0CE700A1C293 /* AlertModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlertModel.swift; sourceTree = "<group>"; };
D2ED27F2254B0E0200A1C293 /* MVMCoreAlertDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreAlertDelegateProtocol.h; sourceTree = "<group>"; };
D2ED27F3254B0E0200A1C293 /* AlertObject.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlertObject.swift; sourceTree = "<group>"; };
D2ED27F7254B0E0200A1C293 /* MVMCoreAlertHandler+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "MVMCoreAlertHandler+Extension.swift"; sourceTree = "<group>"; };
D2ED2805254B0EB700A1C293 /* MVMCoreTopAlertAnimationDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreTopAlertAnimationDelegateProtocol.h; sourceTree = "<group>"; };
D2ED2806254B0EB700A1C293 /* MVMCoreTopAlertOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreTopAlertOperation.h; sourceTree = "<group>"; };
D2ED2807254B0EB700A1C293 /* MVMCoreTopAlertOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreTopAlertOperation.m; sourceTree = "<group>"; };
@ -2521,8 +2520,7 @@
D2ED27D8254B0C1F00A1C293 /* Alerts */ = {
isa = PBXGroup;
children = (
D2ED27F2254B0E0200A1C293 /* MVMCoreAlertDelegateProtocol.h */,
D2ED27F7254B0E0200A1C293 /* MVMCoreAlertHandler+Extension.swift */,
AFA4935629EE3DCC001A9663 /* AlertDelegateProtocol.swift */,
D2ED27F3254B0E0200A1C293 /* AlertObject.swift */,
AF7E509729E477C0009DC2AD /* AlertController.swift */,
AF7E509629E477C0009DC2AD /* AlertHandler.swift */,
@ -2582,7 +2580,6 @@
D2ED280F254B0EB800A1C293 /* MVMCoreTopAlertViewProtocol.h in Headers */,
D2ED280C254B0EB800A1C293 /* MVMCoreTopAlertAnimationDelegateProtocol.h in Headers */,
D2ED280D254B0EB800A1C293 /* MVMCoreTopAlertOperation.h in Headers */,
D2ED27FB254B0E0300A1C293 /* MVMCoreAlertDelegateProtocol.h in Headers */,
D2ED2810254B0EB800A1C293 /* MVMCoreTopAlertDelegateProtocol.h in Headers */,
D2ED2815254B0EE400A1C293 /* MVMCoreGlobalTopAlertDelegateProtocol.h in Headers */,
D29DF26F21E6AA0B003B2FB9 /* FLAnimatedImageView.h in Headers */,
@ -2987,6 +2984,7 @@
D23118B325124E18001C8440 /* Notification.swift in Sources */,
AA9972502475309F00FC7472 /* ListLeftVariableIconAllTextLinksModel.swift in Sources */,
AA69AAF62445BF5700AF3D3B /* ListLeftVariableCheckboxBodyText.swift in Sources */,
AFA4935729EE3DCC001A9663 /* AlertDelegateProtocol.swift in Sources */,
D264FAA3243E632F00D98315 /* ProgrammaticCollectionViewController.swift in Sources */,
D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */,
27F9736A246750BE00CAB5C5 /* ScreenBrightnessModifierBehavior.swift in Sources */,

View File

@ -0,0 +1,19 @@
//
// AlertDelegateProtocol.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 4/17/23.
// Copyright © 2023 Verizon Wireless. All rights reserved.
//
import Foundation
@objc
public protocol AlertDelegateProtocol {
// All are performed on the main thread.
@MainActor func alertShown(_ alertController: UIAlertController)
@MainActor func alertCancelled(_ alertController: UIAlertController)
@MainActor func alertDismissed(_ alertController: UIAlertController)
@MainActor func alertPaused(_ alertController: UIAlertController)
@MainActor func alertUnpaused(_ alertController: UIAlertController)
}

View File

@ -17,9 +17,9 @@ public struct AlertObject {
/// The alert model for the alert to show.
public var alertModel: AlertModel
public weak var alertDelegate: MVMCoreAlertDelegateProtocol?
public weak var alertDelegate: AlertDelegateProtocol?
public init(alertModel: AlertModel, isGreedy: Bool = false, alertDelegate: MVMCoreAlertDelegateProtocol? = nil) {
public init(alertModel: AlertModel, isGreedy: Bool = false, alertDelegate: AlertDelegateProtocol? = nil) {
self.alertModel = alertModel
self.isGreedy = isGreedy
self.alertDelegate = alertDelegate

View File

@ -67,7 +67,7 @@ public class AlertOperation: MVMCoreOperation {
public override func cancel() {
super.cancel()
Task { @MainActor in
self.alertObject.alertDelegate?.alertCancelled?(self.alertController)
self.alertObject.alertDelegate?.alertCancelled(self.alertController)
await self.dismissAlertView()
}
}
@ -92,9 +92,9 @@ public class AlertOperation: MVMCoreOperation {
Task { @MainActor in
await self.properties.set(displayed: visible)
if visible {
self.alertObject.alertDelegate?.alertShown?(self.alertController)
self.alertObject.alertDelegate?.alertShown(self.alertController)
} else {
self.alertObject.alertDelegate?.alertDismissed?(self.alertController)
self.alertObject.alertDelegate?.alertDismissed(self.alertController)
// Is visible was set to NO, meaning that the alertview is no longer visible.
self.stopObservingAlertView()

View File

@ -1,31 +0,0 @@
//
// MVMCoreAlertDelegateProtocol.h
// mobilefirst
//
// Created by Pfeil, Scott Robert on 8/8/17.
// Copyright © 2017 Verizon Wireless. All rights reserved.
//
// Called for popup style alerts.
#import <Foundation/Foundation.h>
@class MVMCoreLoadObject;
@class MVMCoreErrorObject;
@protocol MVMCoreAlertDelegateProtocol
@optional
// All are performed on the main thread.
- (void)alertShown:(nonnull UIAlertController *)alertController;
- (void)alertCancelled:(nonnull UIAlertController *)alertController;
- (void)alertDismissed:(nonnull UIAlertController *)alertController;
- (void)alertPaused:(nonnull UIAlertController *)alertController;
- (void)alertUnpaused:(nonnull UIAlertController *)alertController;
/** Overwrite this to alter how you want the alert to show.
* @param loadObject The load object.
* @param errorObject An error object if there was an error.
* Details: Easier to subclass here to avoid subclassing the displaying logic. */
- (void)handleAlertFor:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)errorObject;
@end

View File

@ -1,69 +0,0 @@
//
// MVMCoreAlertHandler+Extension.swift
// MVMCore
//
// Created by Scott Pfeil on 9/15/20.
// Copyright © 2020 myverizon. All rights reserved.
//
import Foundation
public extension MVMCoreAlertHandler {
/// Re-evaluates the queue operations
@objc func reevaluteQueue() {
var highestReadyOperation: MVMCoreTopAlertOperation?
var executingOperation: MVMCoreTopAlertOperation?
for case let operation as MVMCoreTopAlertOperation in topAlertQueue.operations {
guard !operation.isCancelled,
!operation.isFinished else { continue }
if operation.isReady,
highestReadyOperation == nil || operation.queuePriority.rawValue > highestReadyOperation!.queuePriority.rawValue {
highestReadyOperation = operation
}
if operation.isExecuting {
executingOperation = operation
}
}
guard let currentOperation = executingOperation else { return }
// Cancel the executing operation if it is no longer ready to run. Re-add for later if it is persistent.
guard currentOperation.isReady else {
currentOperation.reAddAfterCancel = currentOperation.topAlertObject.persistent
currentOperation.cancel()
return
}
// If the highest priority operation is not executing, and the executing operation is persistent, cancel it.
if let newOperation = highestReadyOperation,
currentOperation != newOperation,
currentOperation.topAlertObject.persistent {
currentOperation.reAddAfterCancel = true
currentOperation.cancel()
}
}
/// Registers to know when pages change.
@objc func registerForPageChanges() {
MVMCoreNavigationHandler.shared()?.addDelegate(self)
}
}
extension MVMCoreAlertHandler: MVMCorePresentationDelegateProtocol {
// Update displayable for each top alert operation when page type changes, in top queue priority order.
public func navigationController(_ navigationController: UINavigationController, displayedViewController viewController: UIViewController) {
guard topAlertQueue.operations.count > 0 else { return }
let viewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController)
guard viewController == MVMCoreUISplitViewController.main()?.getCurrentViewController() else { return }
let pageType = (viewController as? MVMCoreViewControllerProtocol)?.pageType
topAlertQueue.operations.compactMap {
$0 as? MVMCoreTopAlertOperation
}.sorted {
$0.queuePriority.rawValue > $1.queuePriority.rawValue
}.forEach {
$0.updateDisplayable(byPageType: pageType)
}
reevaluteQueue()
}
}

View File

@ -21,9 +21,6 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[];
#import <MVMCoreUI/MVMCoreUIViewControllerMappingObject.h>
#import <MVMCoreUI/MVMCoreUIViewConstrainingProtocol.h>
// Alert Handling
#import <MVMCoreUI/MVMCoreAlertDelegateProtocol.h>
#pragma mark - TopAlert
#import <MVMCoreUI/MVMCoreGlobalTopAlertDelegateProtocol.h>
#import <MVMCoreUI/MVMCoreTopAlertObject.h>

View File

@ -7,7 +7,7 @@
//
import UIKit
import MVMCore
open class MVMCoreUIDelegateObject: DelegateObject {
@ -17,7 +17,7 @@ open class MVMCoreUIDelegateObject: DelegateObject {
public weak var uiTextViewDelegate: UITextViewDelegate?
public weak var observingTextFieldDelegate: ObservingTextFieldDelegate?
public weak var moleculeDelegate: MoleculeDelegateProtocol?
public weak var alertDelegate: (MVMCoreAlertDelegateProtocol & NSObjectProtocol)?
public weak var alertDelegate: (AlertDelegateProtocol & NSObjectProtocol)?
public weak var topAlertDelegate: (MVMCoreTopAlertDelegateProtocol & NSObjectProtocol)?
open override func setAll(withDelegate delegate: Any) {
@ -28,7 +28,7 @@ open class MVMCoreUIDelegateObject: DelegateObject {
uiTextViewDelegate = delegate as? UITextViewDelegate
observingTextFieldDelegate = delegate as? ObservingTextFieldDelegate
moleculeDelegate = delegate as? MoleculeDelegateProtocol
alertDelegate = delegate as? (MVMCoreAlertDelegateProtocol & NSObjectProtocol)
alertDelegate = delegate as? (AlertDelegateProtocol & NSObjectProtocol)
topAlertDelegate = delegate as? (MVMCoreTopAlertDelegateProtocol & NSObjectProtocol)
}