diff --git a/iphone/Maps/Bookmarks/Catalog/CatalogConnectionErrorView.swift b/iphone/Maps/Bookmarks/Catalog/CatalogConnectionErrorView.swift index 7c36f733d3..6ffae7ad99 100644 --- a/iphone/Maps/Bookmarks/Catalog/CatalogConnectionErrorView.swift +++ b/iphone/Maps/Bookmarks/Catalog/CatalogConnectionErrorView.swift @@ -1,5 +1,3 @@ -import UIKit - class CatalogConnectionErrorView: UIView { @IBOutlet var imageView: UIImageView! diff --git a/iphone/Maps/Bookmarks/Catalog/Subscription/AllPassSubscriptionViewController.swift b/iphone/Maps/Bookmarks/Catalog/Subscription/AllPassSubscriptionViewController.swift index 8846fb2821..cab4220278 100644 --- a/iphone/Maps/Bookmarks/Catalog/Subscription/AllPassSubscriptionViewController.swift +++ b/iphone/Maps/Bookmarks/Catalog/Subscription/AllPassSubscriptionViewController.swift @@ -1,5 +1,3 @@ -import UIKit - class AllPassSubscriptionViewController: BaseSubscriptionViewController { //MARK:outlets @IBOutlet private var backgroundImageView: ImageViewCrossDisolve! diff --git a/iphone/Maps/Bookmarks/Catalog/Subscription/BookmarksSubscriptionButton.swift b/iphone/Maps/Bookmarks/Catalog/Subscription/BookmarksSubscriptionButton.swift index 098db17e64..696712cee1 100644 --- a/iphone/Maps/Bookmarks/Catalog/Subscription/BookmarksSubscriptionButton.swift +++ b/iphone/Maps/Bookmarks/Catalog/Subscription/BookmarksSubscriptionButton.swift @@ -1,5 +1,3 @@ -import UIKit - class BookmarksSubscriptionButton: UIButton { private let descriptionLabel = UILabel() private let priceLabel = UILabel() diff --git a/iphone/Maps/Categories/String+BoundingRect.swift b/iphone/Maps/Categories/String+BoundingRect.swift index 9bfa1f87c9..dea0d5b8da 100644 --- a/iphone/Maps/Categories/String+BoundingRect.swift +++ b/iphone/Maps/Categories/String+BoundingRect.swift @@ -1,4 +1,3 @@ -import UIKit extension String { func size(width: CGFloat, font: UIFont, maxNumberOfLines: Int = 0) -> CGSize { diff --git a/iphone/Maps/Categories/UIButton+RuntimeAttributes.h b/iphone/Maps/Categories/UIButton+RuntimeAttributes.h index beb5a67f4c..d9b5bab39e 100644 --- a/iphone/Maps/Categories/UIButton+RuntimeAttributes.h +++ b/iphone/Maps/Categories/UIButton+RuntimeAttributes.h @@ -1,6 +1,6 @@ #import -@interface UIButton (RuntimeAttributes_dep) +@interface UIButton (RuntimeAttributes) @property(copy, nonatomic) NSString * localizedText; diff --git a/iphone/Maps/Categories/UIColor+MapsMeColor.m b/iphone/Maps/Categories/UIColor+MapsMeColor.m index 768d2fe359..3891ba1e11 100644 --- a/iphone/Maps/Categories/UIColor+MapsMeColor.m +++ b/iphone/Maps/Categories/UIColor+MapsMeColor.m @@ -153,7 +153,7 @@ static UIColor * color(SEL cmd) { // Green color + (UIColor *)primary { - return [StyleManager instance].theme.colors.primary; + return StyleManager.shared.theme.colors.primary; } // Use for opaque fullscreen @@ -165,56 +165,56 @@ static UIColor * color(SEL cmd) { // Background color && press color + (UIColor *)pressBackground { - return [StyleManager instance].theme.colors.pressBackground; + return StyleManager.shared.theme.colors.pressBackground; } // Red color (use for status closed in place page) + (UIColor *)red { - return [StyleManager instance].theme.colors.red; + return StyleManager.shared.theme.colors.red; } // Blue color (use for links and phone numbers) + (UIColor *)linkBlue { - return [StyleManager instance].theme.colors.linkBlue; + return StyleManager.shared.theme.colors.linkBlue; } + (UIColor *)linkBlueHighlighted { - return [StyleManager instance].theme.colors.linkBlueHighlighted; + return StyleManager.shared.theme.colors.linkBlueHighlighted; } + (UIColor *)linkBlueDark { - return [StyleManager instance].theme.colors.linkBlueDark; + return StyleManager.shared.theme.colors.linkBlueDark; } + (UIColor *)buttonRed { - return [StyleManager instance].theme.colors.buttonRed; + return StyleManager.shared.theme.colors.buttonRed; } + (UIColor *)blackPrimaryText { - return [StyleManager instance].theme.colors.blackPrimaryText; + return StyleManager.shared.theme.colors.blackPrimaryText; } + (UIColor *)blackSecondaryText { - return [StyleManager instance].theme.colors.blackSecondaryText; + return StyleManager.shared.theme.colors.blackSecondaryText; } + (UIColor *)blackHintText { - return [StyleManager instance].theme.colors.blackHintText; + return StyleManager.shared.theme.colors.blackHintText; } + (UIColor *)blackDividers { - return [StyleManager instance].theme.colors.blackDividers; + return StyleManager.shared.theme.colors.blackDividers; } + (UIColor *)white { - return [StyleManager instance].theme.colors.white; + return StyleManager.shared.theme.colors.white; } + (UIColor *)whitePrimaryText @@ -230,12 +230,12 @@ static UIColor * color(SEL cmd) { + (UIColor *)whiteHintText { - return [StyleManager instance].theme.colors.whiteHintText; + return StyleManager.shared.theme.colors.whiteHintText; } + (UIColor *)buttonDisabledBlueText { - return [StyleManager instance].theme.colors.buttonDisabledBlueText; + return StyleManager.shared.theme.colors.buttonDisabledBlueText; } + (UIColor *)buttonHighlightedBlueText @@ -245,7 +245,7 @@ static UIColor * color(SEL cmd) { + (UIColor *)blackOpaque { - return [StyleManager instance].theme.colors.blackOpaque; + return StyleManager.shared.theme.colors.blackOpaque; } + (UIColor *)bookingBackground @@ -265,7 +265,7 @@ static UIColor * color(SEL cmd) { + (UIColor *)bannerBackground { - return [StyleManager instance].theme.colors.bannerBackground; + return StyleManager.shared.theme.colors.bannerBackground; } + (UIColor *)colorWithName:(NSString *)colorName diff --git a/iphone/Maps/Categories/UIView+Animation.swift b/iphone/Maps/Categories/UIView+Animation.swift index 82fb719701..8dd2d137ea 100644 --- a/iphone/Maps/Categories/UIView+Animation.swift +++ b/iphone/Maps/Categories/UIView+Animation.swift @@ -1,4 +1,3 @@ -import UIKit extension UIView { @objc func animateConstraints(duration: TimeInterval, diff --git a/iphone/Maps/Categories/UIView+Coordinates.swift b/iphone/Maps/Categories/UIView+Coordinates.swift index ec7f187afe..2fb88607d5 100644 --- a/iphone/Maps/Categories/UIView+Coordinates.swift +++ b/iphone/Maps/Categories/UIView+Coordinates.swift @@ -1,4 +1,3 @@ -import UIKit extension UIView { func center(inContainerView containerView: UIView) -> CGPoint { diff --git a/iphone/Maps/Categories/UIView+Snapshot.swift b/iphone/Maps/Categories/UIView+Snapshot.swift index 1207d92632..c5d5590e37 100644 --- a/iphone/Maps/Categories/UIView+Snapshot.swift +++ b/iphone/Maps/Categories/UIView+Snapshot.swift @@ -1,4 +1,3 @@ -import UIKit extension UIView { @objc var snapshot: UIView { diff --git a/iphone/Maps/Classes/Components/ExpandableReviewView/ExpandableReviewSettings.swift b/iphone/Maps/Classes/Components/ExpandableReviewView/ExpandableReviewSettings.swift index 691ec61c6e..655333dbcd 100644 --- a/iphone/Maps/Classes/Components/ExpandableReviewView/ExpandableReviewSettings.swift +++ b/iphone/Maps/Classes/Components/ExpandableReviewView/ExpandableReviewSettings.swift @@ -1,4 +1,3 @@ -import UIKit struct ExpandableReviewSettings { var expandText: String diff --git a/iphone/Maps/Classes/Components/ExpandableReviewView/ExpandableReviewView.swift b/iphone/Maps/Classes/Components/ExpandableReviewView/ExpandableReviewView.swift index fadb0e9ba0..6c75be3271 100644 --- a/iphone/Maps/Classes/Components/ExpandableReviewView/ExpandableReviewView.swift +++ b/iphone/Maps/Classes/Components/ExpandableReviewView/ExpandableReviewView.swift @@ -1,4 +1,3 @@ -import UIKit final class ExpandableReviewView: UIView { var contentLabel: UILabel = { diff --git a/iphone/Maps/Classes/Components/MWMAddPlaceNavigationBar.xib b/iphone/Maps/Classes/Components/MWMAddPlaceNavigationBar.xib index cc0ec936a4..e681ce0773 100644 --- a/iphone/Maps/Classes/Components/MWMAddPlaceNavigationBar.xib +++ b/iphone/Maps/Classes/Components/MWMAddPlaceNavigationBar.xib @@ -1,9 +1,9 @@ - + - + @@ -32,7 +32,7 @@ - + @@ -49,7 +49,7 @@ - + @@ -61,7 +61,7 @@ - + diff --git a/iphone/Maps/Classes/Components/RatingSummaryView/RatingSummaryView.swift b/iphone/Maps/Classes/Components/RatingSummaryView/RatingSummaryView.swift index 6a4c2572be..2b9b18e21c 100644 --- a/iphone/Maps/Classes/Components/RatingSummaryView/RatingSummaryView.swift +++ b/iphone/Maps/Classes/Components/RatingSummaryView/RatingSummaryView.swift @@ -1,4 +1,3 @@ -import UIKit final class RatingSummaryView: UIView { @IBInspectable var value: String = RatingSummaryViewSettings.Default.value { diff --git a/iphone/Maps/Classes/Components/RatingSummaryView/RatingSummaryViewSettings.swift b/iphone/Maps/Classes/Components/RatingSummaryView/RatingSummaryViewSettings.swift index 74f0c617a0..b7665c1eb9 100644 --- a/iphone/Maps/Classes/Components/RatingSummaryView/RatingSummaryViewSettings.swift +++ b/iphone/Maps/Classes/Components/RatingSummaryView/RatingSummaryViewSettings.swift @@ -1,4 +1,3 @@ -import UIKit struct RatingSummaryViewSettings { enum Default { diff --git a/iphone/Maps/Classes/Components/RatingView/RatingView.swift b/iphone/Maps/Classes/Components/RatingView/RatingView.swift index ab3fc4ffaa..0c7d56996b 100644 --- a/iphone/Maps/Classes/Components/RatingView/RatingView.swift +++ b/iphone/Maps/Classes/Components/RatingView/RatingView.swift @@ -1,4 +1,3 @@ -import UIKit @IBDesignable final class RatingView: UIView { @IBInspectable var value: CGFloat = RatingViewSettings.Default.value { diff --git a/iphone/Maps/Classes/Components/RatingView/RatingViewSettings.swift b/iphone/Maps/Classes/Components/RatingView/RatingViewSettings.swift index edf843ef18..0ea1cac6e8 100644 --- a/iphone/Maps/Classes/Components/RatingView/RatingViewSettings.swift +++ b/iphone/Maps/Classes/Components/RatingView/RatingViewSettings.swift @@ -1,4 +1,3 @@ -import UIKit struct RatingViewSettings { enum FillMode: Int { diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/PromoButton/PromoButton.swift b/iphone/Maps/Classes/CustomViews/MapViewControls/PromoButton/PromoButton.swift index 893ea2daba..b1c0500133 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/PromoButton/PromoButton.swift +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/PromoButton/PromoButton.swift @@ -1,4 +1,3 @@ -import UIKit @objc class PromoButton: MWMButton { diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/PromoButton/PromoCoordinator.swift b/iphone/Maps/Classes/CustomViews/MapViewControls/PromoButton/PromoCoordinator.swift index c0b10259ae..39cb42450e 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/PromoButton/PromoCoordinator.swift +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/PromoButton/PromoCoordinator.swift @@ -1,4 +1,3 @@ -import UIKit @objc class PromoCoordinator: NSObject { @objc enum PromoType: Int{ diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/TrafficButton/MWMTrafficButtonViewController.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/TrafficButton/MWMTrafficButtonViewController.mm index ee1b206dff..f4edc89991 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/TrafficButton/MWMTrafficButtonViewController.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/TrafficButton/MWMTrafficButtonViewController.mm @@ -57,7 +57,7 @@ NSArray * imagesWithName(NSString * name) [ovc addChildViewController:self]; [ovc.controlsView addSubview:self.view]; [self configLayout]; - [[StyleManager instance] addListener: self]; + [StyleManager.shared addListener: self]; [MWMMapOverlayManager addObserver:self]; } return self; @@ -65,7 +65,7 @@ NSArray * imagesWithName(NSString * name) - (void)dealloc { - [[StyleManager instance] removeListener: self]; + [StyleManager.shared removeListener: self]; } - (void)configLayout @@ -190,6 +190,6 @@ NSArray * imagesWithName(NSString * name) - (void)onTrafficStateUpdated { [self applyTheme]; } - (void)onTransitStateUpdated { [self applyTheme]; } -- (void)onIsoLinesStateUpdated { [self refreshAppearance]; } +- (void)onIsoLinesStateUpdated { [self applyTheme]; } @end diff --git a/iphone/Maps/Classes/MapsAppDelegate.mm b/iphone/Maps/Classes/MapsAppDelegate.mm index 15ad206a48..fb0400bcb3 100644 --- a/iphone/Maps/Classes/MapsAppDelegate.mm +++ b/iphone/Maps/Classes/MapsAppDelegate.mm @@ -559,14 +559,6 @@ continueUserActivity:(NSUserActivity *)userActivity }); } -+ (NSDictionary *)navigationBarTextAttributes -{ - return @{ - NSForegroundColorAttributeName : [UIColor whitePrimaryText], - NSFontAttributeName : [UIFont regular18] - }; -} - + (void)customizeAppearanceForNavigationBar:(UINavigationBar *)navigationBar { auto backImage = [[UIImage imageNamed:@"ic_nav_bar_back_sys"] @@ -580,15 +572,6 @@ continueUserActivity:(NSUserActivity *)userActivity [UIButton appearance].exclusiveTouch = YES; [self customizeAppearanceForNavigationBar:[UINavigationBar appearance]]; - - UIBarButtonItem *barButtonApperance = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UINavigationBar class]]]; - [barButtonApperance setTitleTextAttributes:[self navigationBarTextAttributes] - forState:UIControlStateNormal]; - [barButtonApperance setTitleTextAttributes:@{ - NSForegroundColorAttributeName : [UIColor lightGrayColor], - } - forState:UIControlStateDisabled]; - [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UINavigationBar class]]].tintColor = [UIColor whitePrimaryText]; UITextField * textField = [UITextField appearance]; textField.keyboardAppearance = diff --git a/iphone/Maps/Classes/Pages/ImageViewCrossDisolve.swift b/iphone/Maps/Classes/Pages/ImageViewCrossDisolve.swift index 8dc787e0d7..5b1e0e9257 100644 --- a/iphone/Maps/Classes/Pages/ImageViewCrossDisolve.swift +++ b/iphone/Maps/Classes/Pages/ImageViewCrossDisolve.swift @@ -1,4 +1,3 @@ -import UIKit class ImageViewCrossDisolve: UIView { private var imageViews: [UIImageView] = [] diff --git a/iphone/Maps/Classes/Pages/PageIndicator.swift b/iphone/Maps/Classes/Pages/PageIndicator.swift index 64ac460c32..e47c185800 100644 --- a/iphone/Maps/Classes/Pages/PageIndicator.swift +++ b/iphone/Maps/Classes/Pages/PageIndicator.swift @@ -1,4 +1,3 @@ -import UIKit fileprivate let kDotWidth: CGFloat = 6.0 fileprivate let kExtraDotWidth: CGFloat = kDotWidth * 4 diff --git a/iphone/Maps/Common/Common.swift b/iphone/Maps/Common/Common.swift index eeac32549a..7739d8d3ba 100644 --- a/iphone/Maps/Common/Common.swift +++ b/iphone/Maps/Common/Common.swift @@ -38,3 +38,7 @@ func LOG(_ level: LogLevel, Logger.log(level, message: formattedMessage) } } + +struct Weak where T: AnyObject { + weak var value: T? +} diff --git a/iphone/Maps/Core/Ads/BannerType.swift b/iphone/Maps/Core/Ads/BannerType.swift index e08776a173..ec5e749025 100644 --- a/iphone/Maps/Core/Ads/BannerType.swift +++ b/iphone/Maps/Core/Ads/BannerType.swift @@ -48,7 +48,7 @@ extension BannerType: Equatable { } extension BannerType: Hashable { - func hash(into hasher: inout Hasher){ + func hash(into hasher: inout Hasher) { switch self { case .none: hasher.combine(mwmType.hashValue) case let .facebook(id): hasher.combine(mwmType.hashValue ^ id.hashValue) diff --git a/iphone/Maps/Core/Routing/MWMRouter.mm b/iphone/Maps/Core/Routing/MWMRouter.mm index d633b6f9b0..a758e63d5a 100644 --- a/iphone/Maps/Core/Routing/MWMRouter.mm +++ b/iphone/Maps/Core/Routing/MWMRouter.mm @@ -463,7 +463,9 @@ void logPointEvent(MWMRoutePoint * point, NSString * eventType) { rm.FollowRoute(); [[MWMMapViewControlsManager manager] onRouteStart]; - [MWMThemeManager setAutoUpdates:YES]; + if (@available(iOS 13.0, *)) {} else { + [MWMThemeManager setAutoUpdates:YES]; + } } else { @@ -522,7 +524,9 @@ void logPointEvent(MWMRoutePoint * point, NSString * eventType) GetFramework().GetRoutingManager().CloseRouting(removeRoutePoints); if (removeRoutePoints) GetFramework().GetRoutingManager().DeleteSavedRoutePoints(); - [MWMThemeManager setAutoUpdates:NO]; + if (@available(iOS 13.0, *)) {} else { + [MWMThemeManager setAutoUpdates:NO]; + } [[MapsAppDelegate theApp] showAlertIfRequired]; } diff --git a/iphone/Maps/Core/Subscriptions/SubscriptionManager.swift b/iphone/Maps/Core/Subscriptions/SubscriptionManager.swift index bd092f1ba6..eef53cc491 100644 --- a/iphone/Maps/Core/Subscriptions/SubscriptionManager.swift +++ b/iphone/Maps/Core/Subscriptions/SubscriptionManager.swift @@ -55,7 +55,7 @@ class SubscriptionManager: NSObject, ISubscriptionManager { return SKPaymentQueue.canMakePayments() } - @objc func getAvailableSubscriptions(_ completion: @escaping SuscriptionsCompletion){ + @objc func getAvailableSubscriptions(_ completion: @escaping SuscriptionsCompletion) { subscriptionsComplection = completion productsRequest = SKProductsRequest(productIdentifiers: Set(productIds)) productsRequest!.delegate = self diff --git a/iphone/Maps/Core/Theme/Core/Style.swift b/iphone/Maps/Core/Theme/Core/Style.swift index bb761ed6ae..ba2751b6b4 100644 --- a/iphone/Maps/Core/Theme/Core/Style.swift +++ b/iphone/Maps/Core/Theme/Core/Style.swift @@ -58,223 +58,222 @@ class Style: ExpressibleByDictionaryLiteral { } subscript(keyname: Key) -> Value { - get { return self.params[keyname] != nil ? self.params[keyname]! : nil } + get { return params[keyname] ?? nil } } - func append(_ style: Style){ - self.params.merge(style.params) { (a, b) -> Style.Value in + func append(_ style: Style) { + params.merge(style.params) { (a, b) -> Style.Value in return b } } - func append(_ styles: [Style]){ + func append(_ styles: [Style]) { styles.forEach { (style) in - self.params.merge(style.params) { (a, b) -> Style.Value in + params.merge(style.params) { (a, b) -> Style.Value in return b } } } } - extension Style { var backgroundColor: UIColor? { get { return self[.backgroundColor] as? UIColor } - set { self.params[.backgroundColor] = newValue } + set { params[.backgroundColor] = newValue } } var borderColor: UIColor? { get { return self[.borderColor] as? UIColor } - set { self.params[.borderColor] = newValue } + set { params[.borderColor] = newValue } } var borderWidth: CGFloat? { get { return self[.borderWidth] as? CGFloat } - set { self.params[.borderWidth] = newValue } + set { params[.borderWidth] = newValue } } var cornerRadius: CGFloat? { get { return self[.cornerRadius] as? CGFloat } - set { self.params[.cornerRadius] = newValue } + set { params[.cornerRadius] = newValue } } var shadowColor: UIColor? { get { return self[.shadowColor] as? UIColor } - set { self.params[.shadowColor] = newValue } + set { params[.shadowColor] = newValue } } var shadowOpacity: Float? { get { return self[.shadowOpacity] as? Float } - set { self.params[.shadowOpacity] = newValue } + set { params[.shadowOpacity] = newValue } } var shadowOffset: CGSize? { get { return self[.shadowOffset] as? CGSize } - set { self.params[.shadowOffset] = newValue } + set { params[.shadowOffset] = newValue } } var shadowRadius: CGFloat? { get { return self[.shadowRadius] as? CGFloat } - set { self.params[.shadowRadius] = newValue } + set { params[.shadowRadius] = newValue } } var clip: Bool? { get { return self[.clip] as? Bool } - set { self.params[.clip] = newValue } + set { params[.clip] = newValue } } var round: Bool? { get { return self[.round] as? Bool } - set { self.params[.round] = newValue } + set { params[.round] = newValue } } var font: UIFont? { get { return self[.font] as? UIFont } - set { self.params[.font] = newValue } + set { params[.font] = newValue } } var fontColor: UIColor? { get { return self[.fontColor] as? UIColor } - set { self.params[.fontColor] = newValue } + set { params[.fontColor] = newValue } } var fontDetailed: UIFont? { get { return self[.fontDetailed] as? UIFont } - set { self.params[.fontDetailed] = newValue } + set { params[.fontDetailed] = newValue } } var fontColorDetailed: UIColor? { get { return self[.fontColorDetailed] as? UIColor } - set { self.params[.fontColorDetailed] = newValue } + set { params[.fontColorDetailed] = newValue } } var tintColor: UIColor? { get { return self[.tintColor] as? UIColor } - set { self.params[.tintColor] = newValue } + set { params[.tintColor] = newValue } } var tintColorDisabled: UIColor? { get { return self[.tintColorDisabled] as? UIColor } - set { self.params[.tintColorDisabled] = newValue } + set { params[.tintColorDisabled] = newValue } } var onTintColor: UIColor? { get { return self[.onTintColor] as? UIColor } - set { self.params[.onTintColor] = newValue } + set { params[.onTintColor] = newValue } } var offTintColor: UIColor? { get { return self[.offTintColor] as? UIColor } - set { self.params[.offTintColor] = newValue } + set { params[.offTintColor] = newValue } } var image: String? { get { return self[.image] as? String } - set { self.params[.image] = newValue } + set { params[.image] = newValue } } var mwmImage: String? { get { return self[.mwmImage] as? String } - set { self.params[.mwmImage] = newValue } + set { params[.mwmImage] = newValue } } var color: UIColor? { get { return self[.color] as? UIColor } - set { self.params[.color] = newValue } + set { params[.color] = newValue } } var attributes: [NSAttributedString.Key : Any]? { get { return self[.attributes] as? [NSAttributedString.Key : Any] } - set { self.params[.attributes] = newValue } + set { params[.attributes] = newValue } } var linkAttributes: [NSAttributedString.Key : Any]? { get { return self[.linkAttributes] as? [NSAttributedString.Key : Any] } - set { self.params[.linkAttributes] = newValue } + set { params[.linkAttributes] = newValue } } var backgroundImage: UIImage? { get { return self[.backgroundImage] as? UIImage } - set { self.params[.backgroundImage] = newValue } + set { params[.backgroundImage] = newValue } } var barTintColor: UIColor? { get { return self[.barTintColor] as? UIColor } - set { self.params[.barTintColor] = newValue } + set { params[.barTintColor] = newValue } } var backgroundColorSelected: UIColor? { get { return self[.backgroundColorSelected] as? UIColor } - set { self.params[.backgroundColorSelected] = newValue } + set { params[.backgroundColorSelected] = newValue } } var backgroundColorHighlighted: UIColor? { get { return self[.backgroundColorHighlighted] as? UIColor } - set { self.params[.backgroundColorHighlighted] = newValue } + set { params[.backgroundColorHighlighted] = newValue } } var backgroundColorDisabled: UIColor? { get { return self[.backgroundColorDisabled] as? UIColor } - set { self.params[.backgroundColorDisabled] = newValue } + set { params[.backgroundColorDisabled] = newValue } } var fontColorSelected: UIColor? { get { return self[.fontColorSelected] as? UIColor } - set { self.params[.fontColorSelected] = newValue } + set { params[.fontColorSelected] = newValue } } var fontColorHighlighted: UIColor? { get { return self[.fontColorHighlighted] as? UIColor } - set { self.params[.fontColorHighlighted] = newValue } + set { params[.fontColorHighlighted] = newValue } } var fontColorDisabled: UIColor? { get { return self[.fontColorDisabled] as? UIColor } - set { self.params[.fontColorDisabled] = newValue } + set { params[.fontColorDisabled] = newValue } } var shadowImage: UIImage? { get { return self[.shadowImage] as? UIImage } - set { self.params[.shadowImage] = newValue } + set { params[.shadowImage] = newValue } } var textAlignment: NSTextAlignment? { get { return self[.textAlignment] as? NSTextAlignment } - set { self.params[.textAlignment] = newValue } + set { params[.textAlignment] = newValue } } var textContainerInset: UIEdgeInsets? { get { return self[.textContainerInset] as? UIEdgeInsets } - set { self.params[.textContainerInset] = newValue } + set { params[.textContainerInset] = newValue } } var separatorColor: UIColor? { get { return self[.separatorColor] as? UIColor } - set { self.params[.separatorColor] = newValue } + set { params[.separatorColor] = newValue } } var pageIndicatorTintColor: UIColor? { get { return self[.pageIndicatorTintColor] as? UIColor } - set { self.params[.pageIndicatorTintColor] = newValue } + set { params[.pageIndicatorTintColor] = newValue } } var currentPageIndicatorTintColor: UIColor? { get { return self[.currentPageIndicatorTintColor] as? UIColor } - set { self.params[.currentPageIndicatorTintColor] = newValue } + set { params[.currentPageIndicatorTintColor] = newValue } } var colors: [UIColor]? { get { return self[.colors] as? [UIColor] } - set { self.params[.colors] = newValue } + set { params[.colors] = newValue } } var images: [String]? { get { return self[.images] as? [String] } - set { self.params[.images] = newValue } + set { params[.images] = newValue } } var coloring: MWMButtonColoring? { get { return self[.coloring] as? MWMButtonColoring } - set { self.params[.coloring] = newValue } + set { params[.coloring] = newValue } } } diff --git a/iphone/Maps/Core/Theme/Core/StyleManager.swift b/iphone/Maps/Core/Theme/Core/StyleManager.swift index 2b91739180..1511f9d61a 100644 --- a/iphone/Maps/Core/Theme/Core/StyleManager.swift +++ b/iphone/Maps/Core/Theme/Core/StyleManager.swift @@ -3,12 +3,9 @@ } @objc class StyleManager: NSObject { - private struct Weak { - weak var listener: ThemeListener? - } - private static var _instance: StyleManager? + @objc static var shared = StyleManager() @objc private(set) var theme: Theme? - private var listeners: [Weak] = [] + private var listeners: [Weak] = [] func setTheme (_ theme: Theme) { self.theme = theme; @@ -19,15 +16,7 @@ return theme != nil } - @objc class func instance() -> StyleManager{ - if StyleManager._instance == nil { - SwizzleStyle.addSwizzle(); - StyleManager._instance = StyleManager() - } - return StyleManager._instance! - } - - func update (){ + func update () { for window in UIApplication.shared.windows { updateView(window.rootViewController?.view) } @@ -43,7 +32,7 @@ } for container in listeners { - if let listener = container.listener { + if let listener = container.value { listener.applyTheme() } } @@ -69,16 +58,14 @@ if theme != nil { themeListener.applyTheme() } - if listeners.contains(where: { (container) -> Bool in - return themeListener === container.listener - }) == false { - listeners.append(Weak(listener: themeListener)) + if !listeners.contains(where: { themeListener === $0.value }) { + listeners.append(Weak(value: themeListener)) } } @objc func removeListener(_ themeListener: ThemeListener) { listeners.removeAll { (container) -> Bool in - return container.listener === themeListener + return container.value === themeListener } } } diff --git a/iphone/Maps/Core/Theme/Core/Theme.swift b/iphone/Maps/Core/Theme/Core/Theme.swift index dc77c4cd3a..87186d47e7 100644 --- a/iphone/Maps/Core/Theme/Core/Theme.swift +++ b/iphone/Maps/Core/Theme/Core/Theme.swift @@ -25,32 +25,23 @@ U.register(theme: self, colors: colors, fonts: fonts) } - - func add(styleName: StyleName, - _ resolver:@escaping Resolver) { + func add(styleName: StyleName, _ resolver:@escaping Resolver) { resolvers[styleName] = resolver } - func add(styleName: StyleName, - from: StyleName, - _ resolver:@escaping Resolver) { + func add(styleName: StyleName, from: StyleName, _ resolver:@escaping Resolver) { resolvers[styleName] = resolver dependencies[styleName] = from } - func add(styleName: StyleName, - forType: ThemeType, - _ resolver:@escaping Resolver) { + func add(styleName: StyleName, forType: ThemeType, _ resolver:@escaping Resolver) { guard themeType == forType else { return } resolvers[styleName] = resolver } - func add(styleName: StyleName, - from: StyleName, - forType: ThemeType, - _ resolver:@escaping Resolver) { + func add(styleName: StyleName, from: StyleName, forType: ThemeType, _ resolver:@escaping Resolver) { guard themeType == forType else { return } diff --git a/iphone/Maps/Core/Theme/Core/ThemeManager.swift b/iphone/Maps/Core/Theme/Core/ThemeManager.swift index 2ae36bda13..c678839b3a 100644 --- a/iphone/Maps/Core/Theme/Core/ThemeManager.swift +++ b/iphone/Maps/Core/Theme/Core/ThemeManager.swift @@ -50,12 +50,12 @@ final class ThemeManager: NSObject { FrameworkHelper.setTheme(actualTheme) - if nightMode != newNightMode || StyleManager.instance().hasTheme() == false{ + if nightMode != newNightMode || StyleManager.shared.hasTheme() == false{ UIColor.setNightMode(newNightMode) if newNightMode { - StyleManager.instance().setTheme(MainTheme(type: .dark, colors: NightColors(), fonts: Fonts())) + StyleManager.shared.setTheme(MainTheme(type: .dark, colors: NightColors(), fonts: Fonts())) } else { - StyleManager.instance().setTheme(MainTheme(type: .light, colors: DayColors(), fonts: Fonts())) + StyleManager.shared.setTheme(MainTheme(type: .light, colors: DayColors(), fonts: Fonts())) } } } @@ -64,6 +64,7 @@ final class ThemeManager: NSObject { instance.update(theme: MWMSettings.theme()) } + @available(iOS, deprecated:13.0) @objc static var autoUpdates: Bool { get { return instance.timer != nil diff --git a/iphone/Maps/Core/Theme/Extensions/SwizzleStyle.m b/iphone/Maps/Core/Theme/Extensions/SwizzleStyle.m deleted file mode 100644 index 7e674b9537..0000000000 --- a/iphone/Maps/Core/Theme/Extensions/SwizzleStyle.m +++ /dev/null @@ -1,34 +0,0 @@ -#import "SwizzleStyle.h" -#import -#import "objc/runtime.h" -#import "objc/message.h" - -@implementation SwizzleStyle -+ (void)addSwizzle { - [SwizzleStyle swizzle:[UIView class] methodName:@"didMoveToWindow"]; - - [self swizzle:[UITextField class] methodName:@"textRectForBounds:"]; - [self swizzle:[UITextField class] methodName:@"editingRectForBounds:"]; - - [SwizzleStyle swizzle:[UIWindow class] methodName:@"becomeKeyWindow"]; -} - -+ (void)swizzle:(Class)class methodName:(NSString*)methodName -{ - SEL originalMethod = NSSelectorFromString(methodName); - SEL newMethod = NSSelectorFromString([NSString stringWithFormat:@"%@%@", @"sw_", methodName]); - [SwizzleStyle swizzle:class from:originalMethod to:newMethod]; -} - -+ (void)swizzle:(Class)class from:(SEL)original to:(SEL)new -{ - Method originalMethod = class_getInstanceMethod(class, original); - Method newMethod = class_getInstanceMethod(class, new); - if (class_addMethod(class, original, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))) { - class_replaceMethod(class, new, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod)); - } else { - method_exchangeImplementations(originalMethod, newMethod); - } -} - -@end diff --git a/iphone/Maps/Core/Theme/Extensions/UINavigationItem+styleName.swift b/iphone/Maps/Core/Theme/Extensions/UINavigationItem+styleName.swift new file mode 100644 index 0000000000..4a203984ed --- /dev/null +++ b/iphone/Maps/Core/Theme/Extensions/UINavigationItem+styleName.swift @@ -0,0 +1,42 @@ +fileprivate struct AssociatedKeys { + static var styleName: UInt8 = 0 + static var isStyleApplied: UInt8 = 1 +} + +@objc extension UINavigationItem { + @objc func sw_didMoveToWindow() { + applyTheme() + isStyleApplied = true + sw_didMoveToWindow(); + } + + @objc var styleName: String { + get { + isStyleApplied = false + guard let value = objc_getAssociatedObject(self, &AssociatedKeys.styleName) as? String else { + return "" + } + return value + } + set(newValue) { + objc_setAssociatedObject(self, &AssociatedKeys.styleName, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + } + + @objc var isStyleApplied: Bool { + get { + guard let value = objc_getAssociatedObject(self, &AssociatedKeys.isStyleApplied) as? Bool else { + return false + } + return value + } + set(newValue) { + objc_setAssociatedObject(self, &AssociatedKeys.isStyleApplied, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + } + + @objc func setStyleAndApply(_ styleName: String) { + self.styleName = styleName + self.applyTheme() + } +} diff --git a/iphone/Maps/Core/Theme/Extensions/UIView+styleName.swift b/iphone/Maps/Core/Theme/Extensions/UIView+styleName.swift index 8d60d934aa..2025da8d6c 100644 --- a/iphone/Maps/Core/Theme/Extensions/UIView+styleName.swift +++ b/iphone/Maps/Core/Theme/Extensions/UIView+styleName.swift @@ -1,13 +1,13 @@ -struct AssociatedKeys { +fileprivate struct AssociatedKeys { static var styleName: UInt8 = 0 static var isStyleApplied: UInt8 = 1 } @objc extension UIView { @objc func sw_didMoveToWindow() { - self.applyTheme() - self.isStyleApplied = true - self.sw_didMoveToWindow(); + applyTheme() + isStyleApplied = true + sw_didMoveToWindow(); } @objc var styleName: String { @@ -37,6 +37,6 @@ struct AssociatedKeys { @objc func setStyleAndApply(_ styleName: String) { self.styleName = styleName - self.applyTheme() + applyTheme() } } diff --git a/iphone/Maps/Core/Theme/GlobalStyleSheet.swift b/iphone/Maps/Core/Theme/GlobalStyleSheet.swift index 53965d468c..ad77f53161 100644 --- a/iphone/Maps/Core/Theme/GlobalStyleSheet.swift +++ b/iphone/Maps/Core/Theme/GlobalStyleSheet.swift @@ -44,10 +44,12 @@ class GlobalStyleSheet: IStyleSheet { s.fontColor = colors.whitePrimaryText } - theme.add(styleName: "NavigationButton") { (s) -> (Void) in + theme.add(styleName: "NavigationBarItem") { (s) -> (Void) in s.font = fonts.regular18 s.fontColor = colors.whitePrimaryText + s.fontColorDisabled = UIColor.lightGray s.fontColorHighlighted = colors.whitePrimaryTextHighlighted + s.tintColor = colors.whitePrimaryText } theme.add(styleName: "Checkmark") { (s) -> (Void) in diff --git a/iphone/Maps/Core/Theme/Renderers/CheckmarkRenderer.swift b/iphone/Maps/Core/Theme/Renderers/CheckmarkRenderer.swift index edd71651da..3546f893ba 100644 --- a/iphone/Maps/Core/Theme/Renderers/CheckmarkRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/CheckmarkRenderer.swift @@ -4,7 +4,7 @@ extension Checkmark { if styleName.isEmpty { styleName = "Checkmark" } - for style in StyleManager.instance().getStyle(styleName) { + for style in StyleManager.shared.getStyle(styleName) { CheckmarkRenderer.render(self, style: style) } } diff --git a/iphone/Maps/Core/Theme/Renderers/MWMButtonRenderer.swift b/iphone/Maps/Core/Theme/Renderers/MWMButtonRenderer.swift index 09177b5644..e3aca61e90 100644 --- a/iphone/Maps/Core/Theme/Renderers/MWMButtonRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/MWMButtonRenderer.swift @@ -1,6 +1,6 @@ extension MWMButton { @objc override func applyTheme() { - for style in StyleManager.instance().getStyle(styleName) { + for style in StyleManager.shared.getStyle(styleName) { MWMButtonRenderer.render(self, style: style) } } diff --git a/iphone/Maps/Core/Theme/Renderers/MWMTableViewCellRenderer.swift b/iphone/Maps/Core/Theme/Renderers/MWMTableViewCellRenderer.swift index 150dee6d40..0f31a5a315 100644 --- a/iphone/Maps/Core/Theme/Renderers/MWMTableViewCellRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/MWMTableViewCellRenderer.swift @@ -4,7 +4,7 @@ extension MWMTableViewCell { if styleName.isEmpty { styleName = "MWMTableViewCell" } - for style in StyleManager.instance().getStyle(styleName) { + for style in StyleManager.shared.getStyle(styleName) { MWMTableViewCellRenderer.render(self, style: style) } } diff --git a/iphone/Maps/Core/Theme/Renderers/RatingSummaryViewRenderer.swift b/iphone/Maps/Core/Theme/Renderers/RatingSummaryViewRenderer.swift index f65f7b042b..196971b3e4 100644 --- a/iphone/Maps/Core/Theme/Renderers/RatingSummaryViewRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/RatingSummaryViewRenderer.swift @@ -1,7 +1,7 @@ import Foundation extension RatingSummaryView { @objc override func applyTheme() { - for style in StyleManager.instance().getStyle(styleName) { + for style in StyleManager.shared.getStyle(styleName) { RatingSummaryViewRenderer.render(self, style: style) } } diff --git a/iphone/Maps/Core/Theme/Renderers/TabViewRenderer.swift b/iphone/Maps/Core/Theme/Renderers/TabViewRenderer.swift index 53fc70ea99..02bae530cd 100644 --- a/iphone/Maps/Core/Theme/Renderers/TabViewRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/TabViewRenderer.swift @@ -1,10 +1,9 @@ -import UIKit extension TabView { @objc override func applyTheme() { if styleName.isEmpty { styleName = "TabView" } - for style in StyleManager.instance().getStyle(styleName) { + for style in StyleManager.shared.getStyle(styleName) { TabViewRenderer.render(self, style: style) } } diff --git a/iphone/Maps/Core/Theme/Renderers/UIActivityIndicatorRenderer.swift b/iphone/Maps/Core/Theme/Renderers/UIActivityIndicatorRenderer.swift index 1cc3d24745..e1375990a9 100644 --- a/iphone/Maps/Core/Theme/Renderers/UIActivityIndicatorRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/UIActivityIndicatorRenderer.swift @@ -1,6 +1,6 @@ extension UIActivityIndicatorView { @objc override func applyTheme() { - for style in StyleManager.instance().getStyle(styleName) { + for style in StyleManager.shared.getStyle(styleName) { UIActivityIndicatorRenderer.render(self, style: style) } } diff --git a/iphone/Maps/Core/Theme/Renderers/UIBarButtonItemRenderer.swift b/iphone/Maps/Core/Theme/Renderers/UIBarButtonItemRenderer.swift index 14db92b6a2..612ddf8039 100644 --- a/iphone/Maps/Core/Theme/Renderers/UIBarButtonItemRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/UIBarButtonItemRenderer.swift @@ -1,18 +1,34 @@ import UIKit + class UIBarButtonItemRenderer { class func render(_ control: UIBarButtonItem, style: Style) { + var normalAttributes = [NSAttributedString.Key: Any]() + var disableAttributes = [NSAttributedString.Key: Any]() + var highlightedAttributes = [NSAttributedString.Key: Any]() + if let backgroundImage = style.backgroundImage { control.setBackgroundImage(backgroundImage, for: .normal, barMetrics: .default) } if let tintColor = style.tintColor { control.tintColor = tintColor } - if let backgroundColor = style.backgroundColor { - let layer: CALayer = CALayer() - layer.frame = CGRect(x: 0, y: 0, width: 30, height: 26) - layer.masksToBounds = true - layer.backgroundColor = backgroundColor.cgColor + if let font = style.font { + normalAttributes[NSAttributedString.Key.font] = font + disableAttributes[NSAttributedString.Key.font] = font + highlightedAttributes[NSAttributedString.Key.font] = font } + if let fontColor = style.fontColor { + normalAttributes[NSAttributedString.Key.foregroundColor] = fontColor + } + if let fontColorDisabled = style.fontColorDisabled { + disableAttributes[NSAttributedString.Key.foregroundColor] = fontColorDisabled + } + if let fontColorHighlighted = style.fontColorHighlighted { + highlightedAttributes[NSAttributedString.Key.foregroundColor] = fontColorHighlighted + } + + control.setTitleTextAttributes(normalAttributes, for: .normal) + control.setTitleTextAttributes(disableAttributes, for: .disabled) + control.setTitleTextAttributes(highlightedAttributes, for: .highlighted) } } - diff --git a/iphone/Maps/Core/Theme/Renderers/UIButtonRenderer.swift b/iphone/Maps/Core/Theme/Renderers/UIButtonRenderer.swift index 1838690cb7..4b85389a4e 100644 --- a/iphone/Maps/Core/Theme/Renderers/UIButtonRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/UIButtonRenderer.swift @@ -1,6 +1,6 @@ extension UIButton { @objc override func applyTheme() { - for style in StyleManager.instance().getStyle(styleName) { + for style in StyleManager.shared.getStyle(styleName) { UIButtonRenderer.render(self, style: style) } } diff --git a/iphone/Maps/Core/Theme/Renderers/UIImageRenderer.swift b/iphone/Maps/Core/Theme/Renderers/UIImageRenderer.swift index d9755b02fa..97c1166cf6 100644 --- a/iphone/Maps/Core/Theme/Renderers/UIImageRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/UIImageRenderer.swift @@ -1,14 +1,14 @@ extension UIImageView { @objc override func applyTheme() { - for style in StyleManager.instance().getStyle(styleName) { - UIViewRenderer.render(self, style: style) + for style in StyleManager.shared.getStyle(styleName) { UIImageViewRenderer.render(self, style: style) } } } -class UIImageViewRenderer { +class UIImageViewRenderer: UIViewRenderer { class func render(_ control: UIImageView, style: Style) { + super.render(control, style: style) if let image = style.image { control.image = UIImage(named: image) } diff --git a/iphone/Maps/Core/Theme/Renderers/UILabelRenderer.swift b/iphone/Maps/Core/Theme/Renderers/UILabelRenderer.swift index 8587c887a5..fd8bbcf323 100644 --- a/iphone/Maps/Core/Theme/Renderers/UILabelRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/UILabelRenderer.swift @@ -12,9 +12,8 @@ extension UILabel { } @objc override func applyTheme() { - let styles = StyleManager.instance().getStyle(styleName) + let styles = StyleManager.shared.getStyle(styleName) for style in styles { - UIViewRenderer.render(self, style: style) UILabelRenderer.render(self, style: style) } } @@ -22,7 +21,7 @@ extension UILabel { @objc func sw_setAttributedText(text: NSAttributedString) -> CGRect { var attributedString = text if styleName.isEmpty == false { - let styles = StyleManager.instance().getStyle(styleName) + let styles = StyleManager.shared.getStyle(styleName) for style in styles where style.attributes != nil { attributedString = UILabelRenderer.transformText(style: style, text: attributedString) @@ -32,8 +31,9 @@ extension UILabel { } } -class UILabelRenderer { +class UILabelRenderer: UIViewRenderer { class func render(_ control: UILabel, style: Style) { + super.render(control, style: style) if let font = style.font { control.font = font } diff --git a/iphone/Maps/Core/Theme/Renderers/UINavigationBarRenderer.swift b/iphone/Maps/Core/Theme/Renderers/UINavigationBarRenderer.swift index 4631e9ae9f..a99312fe33 100644 --- a/iphone/Maps/Core/Theme/Renderers/UINavigationBarRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/UINavigationBarRenderer.swift @@ -1,19 +1,18 @@ -import UIKit extension UINavigationBar { @objc override func applyTheme() { if styleName.isEmpty { styleName = "NavigationBar" } - for style in StyleManager.instance().getStyle(styleName) { - UIViewRenderer.render(self, style: style) + for style in StyleManager.shared.getStyle(styleName) { UINavigationBarRenderer.render(self, style: style) } } } -class UINavigationBarRenderer { +class UINavigationBarRenderer: UIViewRenderer { class func render(_ control: UINavigationBar, style: Style) { + super.render(control, style: style) if let barTintColor = style.barTintColor { control.barTintColor = barTintColor } diff --git a/iphone/Maps/Core/Theme/Renderers/UINavigationItemRenderer.swift b/iphone/Maps/Core/Theme/Renderers/UINavigationItemRenderer.swift index 779d6cd1cf..de95841ef5 100644 --- a/iphone/Maps/Core/Theme/Renderers/UINavigationItemRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/UINavigationItemRenderer.swift @@ -1,10 +1,13 @@ -import UIKit extension UINavigationItem { @objc func applyTheme() { - assertionFailure("Can't apply on non UIView") + if styleName.isEmpty { + styleName = "NavigationBarItem" + } + for style in StyleManager.shared.getStyle(styleName) { + UINavigationItemRenderer.render(self, style: style) + } } } - class UINavigationItemRenderer { class func render(_ control: UINavigationItem, style: Style) { if let item = control.backBarButtonItem { diff --git a/iphone/Maps/Core/Theme/Renderers/UIPageControlRenderer.swift b/iphone/Maps/Core/Theme/Renderers/UIPageControlRenderer.swift index 309b23a652..cff95908cf 100644 --- a/iphone/Maps/Core/Theme/Renderers/UIPageControlRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/UIPageControlRenderer.swift @@ -1,10 +1,9 @@ -import UIKit extension UIPageControl { @objc override func applyTheme() { if styleName.isEmpty { styleName = "PageControl" } - for style in StyleManager.instance().getStyle(styleName) { + for style in StyleManager.shared.getStyle(styleName) { UIPageControlenderer.render(self, style: style) } } diff --git a/iphone/Maps/Core/Theme/Renderers/UISearchBarRenderer.swift b/iphone/Maps/Core/Theme/Renderers/UISearchBarRenderer.swift index 24d34f3e54..97fb7d5ac8 100644 --- a/iphone/Maps/Core/Theme/Renderers/UISearchBarRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/UISearchBarRenderer.swift @@ -4,15 +4,15 @@ extension UISearchBar { if styleName.isEmpty { styleName = "SearchBar" } - for style in StyleManager.instance().getStyle(styleName) { - UIViewRenderer.render(self, style: style) + for style in StyleManager.shared.getStyle(styleName) { UISearchBarRenderer.render(self, style: style) } } } -class UISearchBarRenderer { +class UISearchBarRenderer: UIViewRenderer { class func render(_ control: UISearchBar, style: Style) { + super.render(control, style: style) if let backgroundColor = style.backgroundColor { control.searchTextField.backgroundColor = backgroundColor } diff --git a/iphone/Maps/Core/Theme/Renderers/UISwitchRenderer.swift b/iphone/Maps/Core/Theme/Renderers/UISwitchRenderer.swift index 2506e33add..b4c3899bb4 100644 --- a/iphone/Maps/Core/Theme/Renderers/UISwitchRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/UISwitchRenderer.swift @@ -3,15 +3,15 @@ extension UISwitch { if styleName.isEmpty { styleName = "Switch" } - for style in StyleManager.instance().getStyle(styleName) { - UIViewRenderer.render(self, style: style) + for style in StyleManager.shared.getStyle(styleName) { UISwitchRenderer.render(self, style: style) } } } -class UISwitchRenderer { +class UISwitchRenderer: UIViewRenderer { class func render(_ control: UISwitch, style: Style) { + super.render(control, style: style) if let onTintColor = style.onTintColor { control.onTintColor = onTintColor } diff --git a/iphone/Maps/Core/Theme/Renderers/UITableViewCellRenderer.swift b/iphone/Maps/Core/Theme/Renderers/UITableViewCellRenderer.swift index 1b38fd7b71..774b6c5580 100644 --- a/iphone/Maps/Core/Theme/Renderers/UITableViewCellRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/UITableViewCellRenderer.swift @@ -3,7 +3,7 @@ extension UITableViewCell { if styleName.isEmpty { styleName = "TableCell" } - for style in StyleManager.instance().getStyle(styleName) { + for style in StyleManager.shared.getStyle(styleName) { UITableViewCellRenderer.render(self, style: style) } } diff --git a/iphone/Maps/Core/Theme/Renderers/UITableViewHeaderFooterViewRenderer.swift b/iphone/Maps/Core/Theme/Renderers/UITableViewHeaderFooterViewRenderer.swift index 1a2b9cc40f..f83f00bb98 100644 --- a/iphone/Maps/Core/Theme/Renderers/UITableViewHeaderFooterViewRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/UITableViewHeaderFooterViewRenderer.swift @@ -3,7 +3,7 @@ extension UITableViewHeaderFooterView { if styleName.isEmpty { styleName = "TableViewHeaderFooterView" } - for style in StyleManager.instance().getStyle(styleName) { + for style in StyleManager.shared.getStyle(styleName) { UITableViewHeaderFooterViewRenderer.render(self, style: style) } } diff --git a/iphone/Maps/Core/Theme/Renderers/UITableViewRenderer.swift b/iphone/Maps/Core/Theme/Renderers/UITableViewRenderer.swift index e3a1c89acc..9f7174e42d 100644 --- a/iphone/Maps/Core/Theme/Renderers/UITableViewRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/UITableViewRenderer.swift @@ -3,15 +3,15 @@ extension UITableView { if styleName.isEmpty { styleName = "TableView" } - for style in StyleManager.instance().getStyle(styleName) { - UIViewRenderer.render(self, style: style) + for style in StyleManager.shared.getStyle(styleName) { UITableViewRenderer.render(self, style: style) } } } -class UITableViewRenderer { +class UITableViewRenderer: UIViewRenderer { class func render(_ control: UITableView, style: Style) { + super.render(control, style: style) if let backgroundColor = style.backgroundColor { control.backgroundView = UIImageView(image: backgroundColor.getImage()) } diff --git a/iphone/Maps/Core/Theme/Renderers/UITextFieldRenderer.swift b/iphone/Maps/Core/Theme/Renderers/UITextFieldRenderer.swift index 72f97d4b9a..8b3168f47f 100644 --- a/iphone/Maps/Core/Theme/Renderers/UITextFieldRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/UITextFieldRenderer.swift @@ -1,20 +1,14 @@ extension UITextField { @objc override func applyTheme() { - for style in StyleManager.instance().getStyle(styleName) { + for style in StyleManager.shared.getStyle(styleName) { UITextFieldRenderer.render(self, style: style) } } - @objc func sw_textRect(forBounds bounds: CGRect) -> CGRect { - if !isStyleApplied { - applyTheme() - } + @objc override func sw_didMoveToWindow() { + applyTheme() isStyleApplied = true - return self.sw_textRect(forBounds: bounds) - } - - @objc func sw_editingRect(bounds: CGRect) -> CGRect { - return self.textRect(forBounds: bounds) + sw_didMoveToWindow(); } } diff --git a/iphone/Maps/Core/Theme/Renderers/UITextViewRenderer.swift b/iphone/Maps/Core/Theme/Renderers/UITextViewRenderer.swift index 69c571afbc..a4b73187c7 100644 --- a/iphone/Maps/Core/Theme/Renderers/UITextViewRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/UITextViewRenderer.swift @@ -1,6 +1,6 @@ extension UITextView { @objc override func applyTheme() { - for style in StyleManager.instance().getStyle(styleName) { + for style in StyleManager.shared.getStyle(styleName) { UITextViewRenderer.render(self, style: style) } } diff --git a/iphone/Maps/Core/Theme/Renderers/UIToolbarRenderer.swift b/iphone/Maps/Core/Theme/Renderers/UIToolbarRenderer.swift index 3d7354a09b..c41709209b 100644 --- a/iphone/Maps/Core/Theme/Renderers/UIToolbarRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/UIToolbarRenderer.swift @@ -1,6 +1,6 @@ extension UIToolbar { @objc override func applyTheme() { - for style in StyleManager.instance().getStyle(styleName) { + for style in StyleManager.shared.getStyle(styleName) { UIToolbarRenderer.render(self, style: style) } } diff --git a/iphone/Maps/Core/Theme/Renderers/UIViewRenderer.swift b/iphone/Maps/Core/Theme/Renderers/UIViewRenderer.swift index 5673a75dda..1077d7baba 100644 --- a/iphone/Maps/Core/Theme/Renderers/UIViewRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/UIViewRenderer.swift @@ -3,7 +3,7 @@ extension UIView { if type(of: self.superview) == UINavigationBar.self { return; } - for style in StyleManager.instance().getStyle(styleName) { + for style in StyleManager.shared.getStyle(styleName) { UIViewRenderer.render(self, style: style) } } diff --git a/iphone/Maps/Core/Theme/Renderers/UIWindowRenderer.swift b/iphone/Maps/Core/Theme/Renderers/UIWindowRenderer.swift index 319b9b7a42..73e7a09931 100644 --- a/iphone/Maps/Core/Theme/Renderers/UIWindowRenderer.swift +++ b/iphone/Maps/Core/Theme/Renderers/UIWindowRenderer.swift @@ -1,7 +1,6 @@ extension UIWindow { @objc override func applyTheme() { - for style in StyleManager.instance().getStyle(styleName) { - UIViewRenderer.render(self, style: style) + for style in StyleManager.shared.getStyle(styleName) { UIWindowRenderer.render(self, style: style) } } diff --git a/iphone/Maps/Core/Theme/Extensions/SwizzleStyle.h b/iphone/Maps/Core/Theme/Swizzle/SwizzleStyle.h similarity index 65% rename from iphone/Maps/Core/Theme/Extensions/SwizzleStyle.h rename to iphone/Maps/Core/Theme/Swizzle/SwizzleStyle.h index 304ea483c0..6d9f2aeadf 100644 --- a/iphone/Maps/Core/Theme/Extensions/SwizzleStyle.h +++ b/iphone/Maps/Core/Theme/Swizzle/SwizzleStyle.h @@ -4,7 +4,7 @@ NS_ASSUME_NONNULL_BEGIN @interface SwizzleStyle : NSObject -+ (void)addSwizzle; ++ (void)swizzle:(Class)forClass methodName:(NSString*)methodName; @end diff --git a/iphone/Maps/Core/Theme/Swizzle/SwizzleStyle.m b/iphone/Maps/Core/Theme/Swizzle/SwizzleStyle.m new file mode 100644 index 0000000000..23ddf78850 --- /dev/null +++ b/iphone/Maps/Core/Theme/Swizzle/SwizzleStyle.m @@ -0,0 +1,25 @@ +#import "SwizzleStyle.h" +#import +#import "objc/runtime.h" +#import "objc/message.h" + +@implementation SwizzleStyle ++ (void)swizzle:(Class)forClass methodName:(NSString*)methodName +{ + SEL originalMethod = NSSelectorFromString(methodName); + SEL newMethod = NSSelectorFromString([NSString stringWithFormat:@"%@%@", @"sw_", methodName]); + [SwizzleStyle swizzle:forClass from:originalMethod to:newMethod]; +} + ++ (void)swizzle:(Class)forClass from:(SEL)original to:(SEL)new +{ + Method originalMethod = class_getInstanceMethod(forClass, original); + Method newMethod = class_getInstanceMethod(forClass, new); + if (class_addMethod(forClass, original, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))) { + class_replaceMethod(forClass, new, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod)); + } else { + method_exchangeImplementations(originalMethod, newMethod); + } +} + +@end diff --git a/iphone/Maps/Core/Theme/Swizzle/UINavigationItem+swizzle.h b/iphone/Maps/Core/Theme/Swizzle/UINavigationItem+swizzle.h new file mode 100644 index 0000000000..be159f2529 --- /dev/null +++ b/iphone/Maps/Core/Theme/Swizzle/UINavigationItem+swizzle.h @@ -0,0 +1,9 @@ +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface UINavigationItem (swizzle) + +@end + +NS_ASSUME_NONNULL_END diff --git a/iphone/Maps/Core/Theme/Swizzle/UINavigationItem+swizzle.m b/iphone/Maps/Core/Theme/Swizzle/UINavigationItem+swizzle.m new file mode 100644 index 0000000000..4d741396aa --- /dev/null +++ b/iphone/Maps/Core/Theme/Swizzle/UINavigationItem+swizzle.m @@ -0,0 +1,8 @@ +#import "UINavigationItem+swizzle.h" +#import "SwizzleStyle.h" + +@implementation UINavigationItem (swizzle) ++(void)load { + [SwizzleStyle swizzle:[self class] methodName:@"didMoveToWindow"]; +} +@end diff --git a/iphone/Maps/Core/Theme/Swizzle/UITextField+swizzle.h b/iphone/Maps/Core/Theme/Swizzle/UITextField+swizzle.h new file mode 100644 index 0000000000..896afdf352 --- /dev/null +++ b/iphone/Maps/Core/Theme/Swizzle/UITextField+swizzle.h @@ -0,0 +1,9 @@ +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface UITextField (swizzle) + +@end + +NS_ASSUME_NONNULL_END diff --git a/iphone/Maps/Core/Theme/Swizzle/UITextField+swizzle.m b/iphone/Maps/Core/Theme/Swizzle/UITextField+swizzle.m new file mode 100644 index 0000000000..1fdca6e4b6 --- /dev/null +++ b/iphone/Maps/Core/Theme/Swizzle/UITextField+swizzle.m @@ -0,0 +1,10 @@ +#import "UITextField+swizzle.h" +#import "SwizzleStyle.h" + +@implementation UITextField (swizzle) ++(void)load { + if (@available(iOS 12, *)) { + [SwizzleStyle swizzle:[self class] methodName:@"didMoveToWindow"]; + } +} +@end diff --git a/iphone/Maps/Core/Theme/Swizzle/UIView+swizzle.h b/iphone/Maps/Core/Theme/Swizzle/UIView+swizzle.h new file mode 100644 index 0000000000..d93966f629 --- /dev/null +++ b/iphone/Maps/Core/Theme/Swizzle/UIView+swizzle.h @@ -0,0 +1,9 @@ +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface UIView (swizzle) + +@end + +NS_ASSUME_NONNULL_END diff --git a/iphone/Maps/Core/Theme/Swizzle/UIView+swizzle.m b/iphone/Maps/Core/Theme/Swizzle/UIView+swizzle.m new file mode 100644 index 0000000000..c500e88b39 --- /dev/null +++ b/iphone/Maps/Core/Theme/Swizzle/UIView+swizzle.m @@ -0,0 +1,8 @@ +#import "SwizzleStyle.h" +#import "UIView+swizzle.h" + +@implementation UIView (swizzle) ++(void)load { + [SwizzleStyle swizzle:[self class] methodName:@"didMoveToWindow"]; +} +@end diff --git a/iphone/Maps/Core/Theme/Swizzle/UIWindow+swizzle.h b/iphone/Maps/Core/Theme/Swizzle/UIWindow+swizzle.h new file mode 100644 index 0000000000..28fbc68d23 --- /dev/null +++ b/iphone/Maps/Core/Theme/Swizzle/UIWindow+swizzle.h @@ -0,0 +1,9 @@ +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface UIWindow (swizzle) + +@end + +NS_ASSUME_NONNULL_END diff --git a/iphone/Maps/Core/Theme/Swizzle/UIWindow+swizzle.m b/iphone/Maps/Core/Theme/Swizzle/UIWindow+swizzle.m new file mode 100644 index 0000000000..a7d8e95d3b --- /dev/null +++ b/iphone/Maps/Core/Theme/Swizzle/UIWindow+swizzle.m @@ -0,0 +1,8 @@ +#import "UIWindow+swizzle.h" +#import "SwizzleStyle.h" + +@implementation UIWindow (swizzle) ++(void)load { + [SwizzleStyle swizzle:[self class] methodName:@"becomeKeyWindow"]; +} +@end diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index 3a9b215a5a..a04d48ecb4 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -570,6 +570,11 @@ 991FCA2423B11E61009AD684 /* BookmarksStyleSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 991FCA2323B11E61009AD684 /* BookmarksStyleSheet.swift */; }; 991FCA2623B11EDE009AD684 /* UITextViewRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 991FCA2523B11EDE009AD684 /* UITextViewRenderer.swift */; }; 991FCA2823B12201009AD684 /* CheckmarkRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 991FCA2723B12201009AD684 /* CheckmarkRenderer.swift */; }; + 9929693B23D89B7100B0D5D9 /* UIView+swizzle.m in Sources */ = {isa = PBXBuildFile; fileRef = 9929693A23D89B7100B0D5D9 /* UIView+swizzle.m */; }; + 9929693E23D89C1400B0D5D9 /* UITextField+swizzle.m in Sources */ = {isa = PBXBuildFile; fileRef = 9929693D23D89C1400B0D5D9 /* UITextField+swizzle.m */; }; + 9929694323D89D8A00B0D5D9 /* UIWindow+swizzle.m in Sources */ = {isa = PBXBuildFile; fileRef = 9929694223D89D8A00B0D5D9 /* UIWindow+swizzle.m */; }; + 9929694623D8A32200B0D5D9 /* UINavigationItem+swizzle.m in Sources */ = {isa = PBXBuildFile; fileRef = 9929694523D8A32200B0D5D9 /* UINavigationItem+swizzle.m */; }; + 9929694823D8A3CB00B0D5D9 /* UINavigationItem+styleName.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9929694723D8A3CB00B0D5D9 /* UINavigationItem+styleName.swift */; }; 993F5507237C622700545511 /* DeepLinkSearchStrategy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 993F54F8237C622700545511 /* DeepLinkSearchStrategy.swift */; }; 993F5508237C622700545511 /* DeepLinkRouteStrategyAdapter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 993F54F9237C622700545511 /* DeepLinkRouteStrategyAdapter.mm */; }; 993F5509237C622700545511 /* DeepLinkHandlerStrategy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 993F54FA237C622700545511 /* DeepLinkHandlerStrategy.swift */; }; @@ -1614,6 +1619,15 @@ 991FCA2323B11E61009AD684 /* BookmarksStyleSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarksStyleSheet.swift; sourceTree = ""; }; 991FCA2523B11EDE009AD684 /* UITextViewRenderer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITextViewRenderer.swift; sourceTree = ""; }; 991FCA2723B12201009AD684 /* CheckmarkRenderer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckmarkRenderer.swift; sourceTree = ""; }; + 9929693923D89B7000B0D5D9 /* UIView+swizzle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIView+swizzle.h"; sourceTree = ""; }; + 9929693A23D89B7100B0D5D9 /* UIView+swizzle.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIView+swizzle.m"; sourceTree = ""; }; + 9929693C23D89C1400B0D5D9 /* UITextField+swizzle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UITextField+swizzle.h"; sourceTree = ""; }; + 9929693D23D89C1400B0D5D9 /* UITextField+swizzle.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UITextField+swizzle.m"; sourceTree = ""; }; + 9929694123D89D8A00B0D5D9 /* UIWindow+swizzle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIWindow+swizzle.h"; sourceTree = ""; }; + 9929694223D89D8A00B0D5D9 /* UIWindow+swizzle.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIWindow+swizzle.m"; sourceTree = ""; }; + 9929694423D8A32200B0D5D9 /* UINavigationItem+swizzle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UINavigationItem+swizzle.h"; sourceTree = ""; }; + 9929694523D8A32200B0D5D9 /* UINavigationItem+swizzle.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UINavigationItem+swizzle.m"; sourceTree = ""; }; + 9929694723D8A3CB00B0D5D9 /* UINavigationItem+styleName.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UINavigationItem+styleName.swift"; sourceTree = ""; }; 993F54F8237C622700545511 /* DeepLinkSearchStrategy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeepLinkSearchStrategy.swift; sourceTree = ""; }; 993F54F9237C622700545511 /* DeepLinkRouteStrategyAdapter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DeepLinkRouteStrategyAdapter.mm; sourceTree = ""; }; 993F54FA237C622700545511 /* DeepLinkHandlerStrategy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeepLinkHandlerStrategy.swift; sourceTree = ""; }; @@ -3587,6 +3601,23 @@ path = PromoAfterBookingCampaign; sourceTree = ""; }; + 9929694923D8A3D600B0D5D9 /* Swizzle */ = { + isa = PBXGroup; + children = ( + 994AEC0223AB763C0079B81F /* SwizzleStyle.h */, + 994AEC0523AB763C0079B81F /* SwizzleStyle.m */, + 9929693923D89B7000B0D5D9 /* UIView+swizzle.h */, + 9929693A23D89B7100B0D5D9 /* UIView+swizzle.m */, + 9929693C23D89C1400B0D5D9 /* UITextField+swizzle.h */, + 9929693D23D89C1400B0D5D9 /* UITextField+swizzle.m */, + 9929694123D89D8A00B0D5D9 /* UIWindow+swizzle.h */, + 9929694223D89D8A00B0D5D9 /* UIWindow+swizzle.m */, + 9929694423D8A32200B0D5D9 /* UINavigationItem+swizzle.h */, + 9929694523D8A32200B0D5D9 /* UINavigationItem+swizzle.m */, + ); + path = Swizzle; + sourceTree = ""; + }; 993F54EB237C5CD800545511 /* Recovered References */ = { isa = PBXGroup; children = ( @@ -3644,6 +3675,7 @@ 999FC12523ABAF5200B0E6F9 /* Core */, 994AEBE523AB763C0079B81F /* Renderers */, 994AEBFF23AB763C0079B81F /* Extensions */, + 9929694923D8A3D600B0D5D9 /* Swizzle */, 994AEC0623AB763C0079B81F /* Components */, 994AEBE423AB763C0079B81F /* Colors.swift */, 999FC12323ABACED00B0E6F9 /* Fonts.swift */, @@ -3696,8 +3728,7 @@ isa = PBXGroup; children = ( 994AEC0023AB763C0079B81F /* UIView+styleName.swift */, - 994AEC0223AB763C0079B81F /* SwizzleStyle.h */, - 994AEC0523AB763C0079B81F /* SwizzleStyle.m */, + 9929694723D8A3CB00B0D5D9 /* UINavigationItem+styleName.swift */, 994AEC0323AB763C0079B81F /* UIColor+rgba.swift */, 994AEC0423AB763C0079B81F /* UIColor+image.swift */, ); @@ -5229,6 +5260,7 @@ BB8123D62130427E00ADE512 /* MetalContextFactory.mm in Sources */, 3467CEB2202C6EEE00D3C670 /* BMCNotificationsHeader.swift in Sources */, 34F4072F1E9E1AFF00E57AC0 /* BannersCache.swift in Sources */, + 9929693E23D89C1400B0D5D9 /* UITextField+swizzle.m in Sources */, 34D3B0211E389D05004100F9 /* MWMEditorAddAdditionalNameTableViewCell.m in Sources */, 999FC12923ABAFFE00B0E6F9 /* GlobalStyleSheet.swift in Sources */, 99D363192358685300941BF4 /* SubscriptionGroupItem.swift in Sources */, @@ -5249,6 +5281,7 @@ 34D3B0421E389D05004100F9 /* MWMEditorTextTableViewCell.m in Sources */, 47FA14D1230D52FC003DA979 /* PhoneNumberAuthorizationViewController.swift in Sources */, 340708651F2905A500029ECC /* NavigationInfoArea.swift in Sources */, + 9929694823D8A3CB00B0D5D9 /* UINavigationItem+styleName.swift in Sources */, 34AB666B1FC5AA330078E451 /* TransportTransitCell.swift in Sources */, 3404163C1E7BDFE000E2B6D6 /* PhotosViewController.swift in Sources */, 47E8163323B17734008FD836 /* MWMStorage+UI.m in Sources */, @@ -5301,6 +5334,7 @@ 47E3C7292111E614008B3B27 /* FadeInAnimatedTransitioning.swift in Sources */, 34AB667D1FC5AA330078E451 /* MWMRoutePreview.mm in Sources */, 99F50FCA23B3852F00E95228 /* UIToolbarRenderer.swift in Sources */, + 9929693B23D89B7100B0D5D9 /* UIView+swizzle.m in Sources */, B33D21AC20DA515800BAD749 /* MWMCategoryInfoCell.mm in Sources */, 473CBF9B2164DD470059BD54 /* SettingsTableViewSelectableProgressCell.swift in Sources */, 47E3C72D2111E6A2008B3B27 /* FadeTransitioning.swift in Sources */, @@ -5310,6 +5344,7 @@ 47A04171238DE8AE00D84E95 /* HotelFacilitiesViewController.swift in Sources */, 479D306522C664CE00D18278 /* MWMDownloadBannerViewController.m in Sources */, F6E2FEDF1E097BA00083EBEC /* MWMSearchManager+Layout.m in Sources */, + 9929694623D8A32200B0D5D9 /* UINavigationItem+swizzle.m in Sources */, F64D9CA01C899C350063FA30 /* MWMEditorViralAlert.mm in Sources */, 34AC8FD11EFC02C000E7F910 /* MWMRoutePoint.mm in Sources */, CDB4D5012231412900104869 /* ListTemplateBuilder.swift in Sources */, @@ -5352,6 +5387,7 @@ 47B9065421C7FA400079C85E /* UIImageView+WebImage.m in Sources */, F6E2FF481E097BA00083EBEC /* SettingsTableViewSelectableCell.swift in Sources */, 994AEC2D23AB763C0079B81F /* StyleManager.swift in Sources */, + 9929694323D89D8A00B0D5D9 /* UIWindow+swizzle.m in Sources */, 34BBD6581F826F810070CA50 /* AuthorizationTransitioningManager.swift in Sources */, 33F7668F21A57CDF00A88B16 /* EditOnWebViewController.swift in Sources */, 34AB664A1FC5AA330078E451 /* RouteManageriPadPresentationController.swift in Sources */, diff --git a/iphone/Maps/UI/Downloader/NoMaps/DownloaderNoResultsEmbedViewController.swift b/iphone/Maps/UI/Downloader/NoMaps/DownloaderNoResultsEmbedViewController.swift index 87b9cb6071..6585af1f81 100644 --- a/iphone/Maps/UI/Downloader/NoMaps/DownloaderNoResultsEmbedViewController.swift +++ b/iphone/Maps/UI/Downloader/NoMaps/DownloaderNoResultsEmbedViewController.swift @@ -1,4 +1,3 @@ -import UIKit @objc(MWMDownloaderNoResultsEmbedViewController) final class DownloaderNoResultsEmbed: UINavigationController { diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotosTransitionAnimator.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotosTransitionAnimator.swift index 9c64fdb031..57c77f06ca 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotosTransitionAnimator.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotosTransitionAnimator.swift @@ -1,4 +1,3 @@ -import UIKit final class PhotosTransitionAnimator: NSObject, UIViewControllerAnimatedTransitioning { private enum Settings { diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSummaryRatingStarsCell.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSummaryRatingStarsCell.swift index f5c23ebe1e..cba49b3701 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSummaryRatingStarsCell.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSummaryRatingStarsCell.swift @@ -1,4 +1,3 @@ -import UIKit final class UGCSummaryRatingStarsCell: UICollectionViewCell { @IBOutlet private weak var ratingView: RatingView! { diff --git a/iphone/Maps/UI/Search/SearchNoResultsViewController.swift b/iphone/Maps/UI/Search/SearchNoResultsViewController.swift index 24e1926888..06aaa5e7a8 100644 --- a/iphone/Maps/UI/Search/SearchNoResultsViewController.swift +++ b/iphone/Maps/UI/Search/SearchNoResultsViewController.swift @@ -1,4 +1,3 @@ -import UIKit final class SearchNoResultsViewController: MWMViewController { diff --git a/iphone/Maps/UI/Settings/DrivingOptionsViewController.swift b/iphone/Maps/UI/Settings/DrivingOptionsViewController.swift index 35312db284..86e29be9e7 100644 --- a/iphone/Maps/UI/Settings/DrivingOptionsViewController.swift +++ b/iphone/Maps/UI/Settings/DrivingOptionsViewController.swift @@ -1,4 +1,3 @@ -import UIKit class DrivingOptionsViewController: MWMTableViewController { let options = RoutingOptions() diff --git a/iphone/Maps/UI/Storyboard/Storyboard.swift b/iphone/Maps/UI/Storyboard/Storyboard.swift index 17e455653d..07b3a5daaa 100644 --- a/iphone/Maps/UI/Storyboard/Storyboard.swift +++ b/iphone/Maps/UI/Storyboard/Storyboard.swift @@ -1,5 +1,3 @@ -import UIKit - @objc(MWMStoryboard) enum Storyboard: Int { case authorization diff --git a/iphone/Maps/UI/Welcome/PromoDiscovery/PromoDiscoveryPresenter.swift b/iphone/Maps/UI/Welcome/PromoDiscovery/PromoDiscoveryPresenter.swift index 9ed47f956b..f7b2f50a9a 100644 --- a/iphone/Maps/UI/Welcome/PromoDiscovery/PromoDiscoveryPresenter.swift +++ b/iphone/Maps/UI/Welcome/PromoDiscovery/PromoDiscoveryPresenter.swift @@ -18,7 +18,7 @@ class PromoDiscoveryPresenter { } extension PromoDiscoveryPresenter: IPromoRouterPresenter { - func configure(){ + func configure() { switch campaign.group { case .discoverCatalog: viewController?.setTitleImage(UIImage(named: "img_onboarding_subscribeguides")) diff --git a/iphone/Maps/UI/Welcome/TermsOfUse/TermsOfUseViewController.swift b/iphone/Maps/UI/Welcome/TermsOfUse/TermsOfUseViewController.swift index 4b08141afe..d9c2291f27 100644 --- a/iphone/Maps/UI/Welcome/TermsOfUse/TermsOfUseViewController.swift +++ b/iphone/Maps/UI/Welcome/TermsOfUse/TermsOfUseViewController.swift @@ -43,7 +43,7 @@ class TermsOfUseViewController: MWMViewController { } @IBAction func onCheck(_ sender: Checkmark) { - if (privacyPolicyCheck.isChecked && termsOfUseCheck.isChecked){ + if (privacyPolicyCheck.isChecked && termsOfUseCheck.isChecked) { presenter?.onNext() } } diff --git a/iphone/Maps/UI/Welcome/WelcomePageController.swift b/iphone/Maps/UI/Welcome/WelcomePageController.swift index 8d15033f35..64484c59d6 100644 --- a/iphone/Maps/UI/Welcome/WelcomePageController.swift +++ b/iphone/Maps/UI/Welcome/WelcomePageController.swift @@ -1,5 +1,3 @@ -import UIKit - @objc(MWMWelcomePageControllerProtocol) protocol WelcomePageControllerProtocol { var view: UIView! { get set }