diff --git a/MVMCoreUI.xcodeproj/xcshareddata/xcschemes/MVMCoreUI.xcscheme b/MVMCoreUI.xcodeproj/xcshareddata/xcschemes/MVMCoreUI.xcscheme new file mode 100644 index 00000000..9e236f99 --- /dev/null +++ b/MVMCoreUI.xcodeproj/xcshareddata/xcschemes/MVMCoreUI.xcscheme @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MVMCoreUI/Alerts/AlertOperation.swift b/MVMCoreUI/Alerts/AlertOperation.swift index 088a6ff5..50b71e46 100644 --- a/MVMCoreUI/Alerts/AlertOperation.swift +++ b/MVMCoreUI/Alerts/AlertOperation.swift @@ -73,7 +73,7 @@ public class AlertOperation: MVMCoreOperation { if await !self.properties.getIsDisplayed() { self.markAsFinished() } else { - (CoreUIObject.sharedInstance()?.loggingDelegate as? MVMCoreUILoggingDelegateProtocol)?.logAlert(with: self.alertObject) + (MVMCoreObject.sharedInstance()?.loggingDelegate as? MVMCoreUILoggingDelegateProtocol)?.logAlert(with: self.alertObject) if self.isCancelled { await self.dismissAlertView() } diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift index 4f4a8b34..c6a14872 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift @@ -21,7 +21,7 @@ import VDSColorTokens else { return } // Set line to the same color as the text - if let color = titleLabel?.textColor?.cgColor { + if let color = titleColor(for: state)?.cgColor { context.setStrokeColor(color) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift index 7a17dd1b..f9cfcc95 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift @@ -55,11 +55,11 @@ import Foundation isAccessibilityElement = true var message = "" - if let headlineLabel = headlineBody.headlineLabel.text { + if let headlineLabel = headlineBody.headlineLabel.accessibilityLabel ?? headlineBody.headlineLabel.text { message += headlineLabel + ", " } - if let messageLabel = headlineBody.messageLabel.text { + if let messageLabel = headlineBody.messageLabel.accessibilityLabel ?? headlineBody.messageLabel.text { message += messageLabel } diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index ea7d89b8..6b360120 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -384,7 +384,7 @@ open class Carousel: View { extension Carousel: UICollectionViewDelegateFlowLayout { open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - let itemWidth = collectionView.bounds.width * itemWidthPercent + let itemWidth = (collectionView.bounds.width - collectionView.contentInset.left - collectionView.contentInset.right) * itemWidthPercent return CGSize(width: itemWidth, height: collectionView.bounds.height) } diff --git a/MVMCoreUI/Categories/UIColor+MFConvenience.h b/MVMCoreUI/Categories/UIColor+MFConvenience.h index 97280ba1..10e9433d 100644 --- a/MVMCoreUI/Categories/UIColor+MFConvenience.h +++ b/MVMCoreUI/Categories/UIColor+MFConvenience.h @@ -183,8 +183,12 @@ // Returns a gradient lighter color; + (nonnull UIColor *)mfGradientColor:(nullable UIColor *)color; +// Returns if the color is dark or not +- (BOOL)isDark; + #pragma mark - Hex String + (nullable NSString *)hexStringForColor:(nonnull UIColor*)color; + (nonnull UIColor *)mfGetColorForHexWithTransparency:(nonnull NSString *)hexString; + @end diff --git a/MVMCoreUI/Categories/UIColor+MFConvenience.m b/MVMCoreUI/Categories/UIColor+MFConvenience.m index 8786df01..cd809509 100644 --- a/MVMCoreUI/Categories/UIColor+MFConvenience.m +++ b/MVMCoreUI/Categories/UIColor+MFConvenience.m @@ -389,6 +389,12 @@ return [UIColor whiteColor]; } +- (BOOL)isDark { + CGFloat greyScale = 0; + [self getWhite:&greyScale alpha:nil]; + return greyScale < 0.5; +} + #pragma mark - Hex String + (nullable NSString *)hexStringForColor:(nonnull UIColor*)color { diff --git a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift index 625f0a25..3372c1ab 100644 --- a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift +++ b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift @@ -12,6 +12,7 @@ import MVMCore public extension UINavigationController { /// Convenience function for setting the navigation item. + @MainActor func setNavigationItem(with model: NavigationItemModelProtocol, for viewController: UIViewController, coordinatingWith pageBehaviorController: PageBehaviorHandlerProtocol? = nil) { let behaviorHandler = pageBehaviorController ?? viewController as? PageBehaviorHandlerProtocol; @@ -33,6 +34,7 @@ public extension UINavigationController { } /// Convenience function for setting the navigation buttons. + @MainActor func setNavigationButtons(with model: NavigationItemModelProtocol, for viewController: UIViewController) { let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject var leftItems: [UIBarButtonItem] = [] @@ -60,6 +62,7 @@ public extension UINavigationController { } /// Convenience function for setting the navigation titleView. + @MainActor func setNavigationTitleView(with model: NavigationItemModelProtocol, for viewController: UIViewController, coordinatingWith pageBehaviorController: PageBehaviorHandlerProtocol? = nil) { guard let titleViewModel = model.titleView else { return } @@ -87,6 +90,7 @@ public extension UINavigationController { } /// Convenience function for setting the navigation bar ui + @MainActor func setNavigationBarUI(with model: NavigationItemModelProtocol) { let navigationBar = navigationBar let font = Styler.Font.BoldTitleSmall.getFont(false) diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index 7bdee349..458c0169 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -273,7 +273,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, // Load controller from the cache needToTrackTabSelect = true Task(priority: .userInitiated) { - await NavigationHandler.shared().replace(viewController: controller, navigationController: subNavigationController, tryToReplace: false, animated: true) + await NavigationHandler.shared().replace(viewController: controller, navigationController:subNavigationController, delegateObject:delegateObject(), tryToReplace: false, animated: true) } } else if let tabsModel = tabs.tabsModel, let action = tabsModel.tabs[indexPath.row].action { diff --git a/MVMCoreUI/OtherHandlers/CoreUIObject.swift b/MVMCoreUI/OtherHandlers/CoreUIObject.swift index b96e9b93..d1fd18f9 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIObject.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIObject.swift @@ -9,19 +9,22 @@ import UIKit import MVMCore -@objcMembers open class CoreUIObject: MVMCoreObject { +@objcMembers +public class CoreUIObject: NSObject { + private static var singleton = CoreUIObject() + public static func sharedInstance() -> CoreUIObject? { singleton } + private override init() {} + public var alertHandler: AlertHandler? public var topNotificationHandler: NotificationHandler? - open override func defaultInitialSetup() { + public func defaultInitialSetup() { + MVMCoreObject.sharedInstance()?.defaultInitialSetup() CoreUIModelMapping.registerObjects() - loadHandler = MVMCoreLoadHandler() - cache = MVMCoreCache() - session = MVMCoreUISession() - sessionHandler = MVMCoreSessionTimeHandler() - actionHandler = MVMCoreUIActionHandler() - viewControllerMapping = MVMCoreUIViewControllerMappingObject() - loggingDelegate = MVMCoreUILoggingHandler() + MVMCoreObject.sharedInstance()?.session = MVMCoreUISession() + MVMCoreObject.sharedInstance()?.actionHandler = MVMCoreUIActionHandler() + MVMCoreObject.sharedInstance()?.viewControllerMapping = MVMCoreUIViewControllerMappingObject() + MVMCoreObject.sharedInstance()?.loggingDelegate = MVMCoreUILoggingHandler() alertHandler = AlertHandler() } } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUISession.m b/MVMCoreUI/OtherHandlers/MVMCoreUISession.m index 42a3e769..3b1d5913 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUISession.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUISession.m @@ -9,7 +9,8 @@ #import "MVMCoreUISession.h" #import "MFLoadingViewController.h" #import "NSLayoutConstraint+MFConvenience.h" -@import MVMCore.MVMCoreObject; +@import MVMCore.MVMCoreLoadingOverlayDelegateProtocol; +@import MVMCore.Swift; @interface MVMCoreUISession ()