[ios] refactor styles to make them type-safe using enums instead of string lit

1. for now the structure is SheetStyle.Global/PlacePage/Font/TestColor...
2. the styles are used by assessing the property
before:
lineView.setStyleAndApply("Divider")
headerTitleLabel.setStyleAndApply("semibold18:blackPrimaryText")

after:
lineView.setStyleAndApply(.global(.divider))
headerTitleLabel.setFontStyle(.semibold18, color: .blackPrimary)

Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
This commit is contained in:
Kiryl Kaveryn 2025-01-10 18:29:16 +04:00 committed by Kiryl Kaveryn
parent 06bd35d931
commit a1c6d532b5
79 changed files with 1264 additions and 1146 deletions

View file

@ -34,7 +34,7 @@ final class BMCViewController: MWMViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.styleName = "PressBackground"
view.setStyle(.pressBackground)
viewModel = BMCDefaultViewModel()
}

View file

@ -85,7 +85,7 @@ final class RecentlyDeletedCategoriesViewController: MWMViewController {
}
private func setupTableView() {
tableView.styleName = "TableView:PressBackground";
tableView.setStyles([.tableView, .pressBackground])
tableView.allowsMultipleSelectionDuringEditing = true
tableView.register(cell: RecentlyDeletedTableViewCell.self)
tableView.setEditing(true, animated: false)

View file

@ -8,7 +8,7 @@ extension UIView {
thickness: CGFloat = 1.0,
insets: UIEdgeInsets = .zero) {
let lineView = UIView()
lineView.setStyleAndApply("Divider")
lineView.setStyleAndApply(.divider)
lineView.isUserInteractionEnabled = false
lineView.translatesAutoresizingMaskIntoConstraints = false
addSubview(lineView)

View file

@ -7,7 +7,7 @@ final class DimBackground: SolidTouchView {
self.mainView = mainView
self.tapAction = tapAction
super.init(frame: mainView.superview!.bounds)
styleName = "FadeBackground"
setStyle(.fadeBackground)
autoresizingMask = [.flexibleWidth, .flexibleHeight]
addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(onTap)))
}

View file

@ -5,7 +5,7 @@ class DimmedModalPresentationController: UIPresentationController {
private lazy var dimView: UIView = {
let view = UIView()
view.styleName = "BlackStatusBarBackground"
view.setStyle(.blackStatusBarBackground)
if isCancellable {
view.addGestureRecognizer(onTapGr)
}

View file

@ -81,29 +81,29 @@ final class BCCreateCategoryAlert: MWMAlert {
}
private func process(state: State) {
let styleName: String
let style: TextColorStyleSheet
switch state {
case .valid:
styleName = "blackHintText"
style = .blackHint
rightButton.isEnabled = true
errorLabel.isHidden = true
case .tooFewSymbols:
styleName = "blackHintText"
style = .blackHint
errorLabel.isHidden = true
rightButton.isEnabled = false
case .tooManySymbols:
styleName = "buttonRedText"
style = .buttonRed
errorLabel.isHidden = false
errorLabel.text = L("bookmarks_error_title_list_name_too_long")
rightButton.isEnabled = false
case .nameAlreadyExists:
styleName = "buttonRedText"
style = .buttonRed
errorLabel.isHidden = false
errorLabel.text = L("bookmarks_error_title_list_name_already_taken")
rightButton.isEnabled = false
}
charactersCountLabel.setStyleAndApply(styleName)
charactersCountLabel.setFontStyleAndApply(style)
textFieldContainer.layer.borderColor = charactersCountLabel.textColor.cgColor
}

View file

@ -83,14 +83,14 @@ NSString * const kUDDidShowLongTapToShowSideButtonsToast = @"kUDDidShowLongTapTo
{
case MWMMyPositionModePendingPosition:
{
[locBtn setStyleAndApply: @"ButtonPending"];
[locBtn setStyleNameAndApply: @"ButtonPending"];
[locBtn.imageView startRotation:1];
break;
}
case MWMMyPositionModeNotFollow:
case MWMMyPositionModeNotFollowNoPosition: [locBtn setStyleAndApply: @"ButtonGetPosition"]; break;
case MWMMyPositionModeFollow: [locBtn setStyleAndApply: @"ButtonFollow"]; break;
case MWMMyPositionModeFollowAndRotate: [locBtn setStyleAndApply: @"ButtonFollowAndRotate"]; break;
case MWMMyPositionModeNotFollowNoPosition: [locBtn setStyleNameAndApply: @"ButtonGetPosition"]; break;
case MWMMyPositionModeFollow: [locBtn setStyleNameAndApply: @"ButtonFollow"]; break;
case MWMMyPositionModeFollowAndRotate: [locBtn setStyleNameAndApply: @"ButtonFollowAndRotate"]; break;
}
}

View file

@ -71,7 +71,7 @@ final class TrackRecordingViewController: MWMViewController {
view.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(button)
button.setStyleAndApply("TrackRecordingWidgetButton")
button.setStyle(.trackRecordingWidgetButton)
button.tintColor = Constants.color.darker
button.translatesAutoresizingMaskIntoConstraints = false
button.setImage(UIImage(resource: .icMenuBookmarkTrackRecording), for: .normal)

View file

@ -23,9 +23,8 @@ final class RouteManagerCell: MWMTableViewCell {
override var snapshot: UIView {
let skipViews: [UIView] = [typeImage, separator1, separator2]
skipViews.forEach { $0.isHidden = true }
setStyleAndApply("BlackOpaqueBackground")
let snapshot = super.snapshot
setStyleAndApply("Background")
setStyle(.background)
skipViews.forEach { $0.isHidden = false }
return snapshot
}

View file

@ -36,7 +36,7 @@ final class RouteManagerDimView: UIView {
didSet {
guard isVisible != oldValue else { return }
let componentsAlpha: CGFloat = 0.5
setStyleAndApply("BlackStatusBarBackground")
setStyle(.blackStatusBarBackground)
alpha = isVisible ? 0 : 1
image.alpha = isVisible ? 0 : componentsAlpha
label.alpha = isVisible ? 0 : componentsAlpha

View file

@ -14,7 +14,7 @@ final class RouteManagerViewController: MWMViewController, UITableViewDataSource
lazy var chromeView: UIView = {
let view = UIView()
view.styleName = "BlackStatusBarBackground"
view.setStyle(.blackStatusBarBackground)
return view
}()

View file

@ -7,7 +7,7 @@ final class BaseRoutePreviewStatus: SolidTouchView {
@IBOutlet weak var manageRouteBoxBackground: UIView! {
didSet {
iPhoneSpecific {
manageRouteBoxBackground.styleName = "BlackOpaqueBackground"
manageRouteBoxBackground.setStyle(.blackOpaqueBackground)
}
}
}

View file

@ -11,7 +11,7 @@ final class TransportTransitSeparator: UICollectionReusableView {
private func setup() {
let image = UIImageView(image: #imageLiteral(resourceName: "ic_arrow"))
image.styleName = "MWMBlack"
image.setStyle(.black)
image.contentMode = .scaleAspectFit
addSubview(image)
}

View file

@ -1,28 +0,0 @@
class AuthStyleSheet: IStyleSheet {
static func register(theme: Theme, colors: IColors, fonts: IFonts) {
theme.add(styleName: "GoogleButton") { (s) -> (Void) in
s.cornerRadius = 8
s.borderWidth = 1
s.borderColor = colors.blackDividers
s.clip = true
s.fontColor = colors.blackPrimaryText
s.fontColorDisabled = colors.blackSecondaryText
s.font = fonts.bold14
}
theme.add(styleName: "FacebookButton") { (s) -> (Void) in
s.cornerRadius = 8
s.clip = true
s.font = fonts.bold14
s.backgroundColor = colors.facebookButtonBackground
s.backgroundColorDisabled = colors.facebookButtonBackgroundDisabled
}
theme.add(styleName: "OsmSocialLoginButton") { (s) -> (Void) in
s.font = fonts.regular17
s.cornerRadius = 8
s.borderWidth = 1
s.borderColor = colors.blackDividers
}
}
}

View file

@ -1,30 +1,34 @@
import Foundation
enum BookmarksStyleSheet: String, CaseIterable {
case bookmarksCategoryTextView = "BookmarksCategoryTextView"
case bookmarksCategoryDeleteButton = "BookmarksCategoryDeleteButton"
case bookmarksActionCreateIcon = "BookmarksActionCreateIcon"
case bookmarkSharingLicense = "BookmarkSharingLicense"
}
class BookmarksStyleSheet: IStyleSheet {
static func register(theme: Theme, colors: IColors, fonts: IFonts) {
theme.add(styleName: "BookmarksCategoryTextView") { (s) -> (Void) in
s.font = fonts.regular16
s.fontColor = colors.blackPrimaryText
s.textContainerInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
}
theme.add(styleName: "BookmarksCategoryDeleteButton") { (s) -> (Void) in
s.font = fonts.regular17
s.fontColor = colors.red
s.fontColorDisabled = colors.blackHintText
}
theme.add(styleName: "BookmarksActionCreateIcon") { (s) -> (Void) in
s.tintColor = colors.linkBlue
}
theme.add(styleName: "LonelyPlanetLogo") { (s) -> (Void) in
s.tintColor = colors.lonelyPlanetLogoColor
}
theme.add(styleName: "BookmarkSharingLicense", from: "TermsOfUseLinkText") { (s) -> (Void) in
s.fontColor = colors.blackSecondaryText
s.font = fonts.regular14
extension BookmarksStyleSheet: IStyleSheet {
func styleResolverFor(colors: IColors, fonts: IFonts) -> Theme.StyleResolver {
switch self {
case .bookmarksCategoryTextView:
return .add { s in
s.font = fonts.regular16
s.fontColor = colors.blackPrimaryText
s.textContainerInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
}
case .bookmarksCategoryDeleteButton:
return .add { s in
s.font = fonts.regular17
s.fontColor = colors.red
s.fontColorDisabled = colors.blackHintText
}
case .bookmarksActionCreateIcon:
return .add { s in
s.tintColor = colors.linkBlue
}
case .bookmarkSharingLicense:
return .addFrom(GlobalStyleSheet.termsOfUseLinkText) { s in
s.fontColor = colors.blackSecondaryText
s.font = fonts.regular14
}
}
}
}

View file

@ -46,8 +46,6 @@ class DayColors: IColors {
var ratingYellow = UIColor(245, 176, 39, alpha100)
var ratingLightGreen = UIColor(124, 179, 66, alpha100)
var ratingGreen = UIColor(67, 160, 71, alpha100)
var facebookButtonBackground = UIColor(59, 89, 152, alpha100);
var facebookButtonBackgroundDisabled = UIColor(59, 89, 152, alpha70);
var fadeBackground = UIColor(0, 0, 0, alpha80)
var blackStatusBarBackground = UIColor(0, 0, 0, alpha80)
var elevationPreviewTint = UIColor(193, 209, 224, alpha30)
@ -57,7 +55,6 @@ class DayColors: IColors {
var chartShadow = UIColor(red: 0.118, green: 0.588, blue: 0.941, alpha: 0.12)
var cityColor = UIColor(red: 0.4, green: 0.225, blue: 0.75, alpha: 1)
var outdoorColor = UIColor(red: 0.235, green: 0.549, blue: 0.235, alpha: 1)
var lonelyPlanetLogoColor = UIColor(red: 0, green: 0.286, blue: 0.565, alpha: 1)
var carplayPlaceholderBackground = UIColor(221, 221, 205, alpha100)
var iconOpaqueGrayTint = UIColor(117, 117, 117, alpha100)
var iconOpaqueGrayBackground = UIColor(231, 231, 231, alpha100)
@ -111,8 +108,6 @@ class NightColors: IColors {
var ratingYellow = UIColor(245, 176, 39, alpha100)
var ratingLightGreen = UIColor(124, 179, 66, alpha100)
var ratingGreen = UIColor(67, 160, 71, alpha100)
var facebookButtonBackground = UIColor(59, 89, 152, alpha100);
var facebookButtonBackgroundDisabled = UIColor(59, 89, 152, alpha70);
var fadeBackground = UIColor(0, 0, 0, alpha80)
var blackStatusBarBackground = UIColor(0, 0, 0, alpha80)
var elevationPreviewTint = UIColor(0, 0, 0, alpha54)
@ -122,7 +117,6 @@ class NightColors: IColors {
var chartShadow = UIColor(red: 0.294, green: 0.725, blue: 0.902, alpha: 0.12)
var cityColor = UIColor(152, 103, 252, alpha100)
var outdoorColor = UIColor(147, 191, 57, alpha100)
var lonelyPlanetLogoColor = UIColor(red: 1, green: 1, blue: 1, alpha: 0.7)
var carplayPlaceholderBackground = UIColor(50, 54, 58, alpha100)
var iconOpaqueGrayTint = UIColor(197, 197, 197, alpha100)
var iconOpaqueGrayBackground = UIColor(84, 86, 90, alpha100)

View file

@ -56,8 +56,6 @@ let alpha100: CGFloat = 1.0
var ratingYellow: UIColor { get }
var ratingLightGreen: UIColor { get }
var ratingGreen: UIColor { get }
var facebookButtonBackground: UIColor { get }
var facebookButtonBackgroundDisabled: UIColor { get }
var fadeBackground: UIColor { get }
var blackStatusBarBackground: UIColor { get }
var elevationPreviewSelector: UIColor { get }
@ -67,7 +65,6 @@ let alpha100: CGFloat = 1.0
var chartShadow: UIColor { get }
var cityColor: UIColor { get }
var outdoorColor: UIColor { get }
var lonelyPlanetLogoColor: UIColor { get }
var carplayPlaceholderBackground: UIColor { get }
var iconOpaqueGrayTint: UIColor { get }
var iconOpaqueGrayBackground: UIColor { get }

View file

@ -1,3 +1,9 @@
protocol IStyleSheet: AnyObject {
protocol IStyleSheet: CaseIterable, RawRepresentable, StyleStringRepresentable {
static func register(theme: Theme, colors: IColors, fonts: IFonts)
}
extension IStyleSheet {
static func register(theme: Theme, colors: IColors, fonts: IFonts) {
allCases.forEach { theme.add($0, $0.styleResolverFor(colors: colors, fonts: fonts)) }
}
}

View file

@ -0,0 +1,23 @@
extension UILabel {
func setFontStyle(_ font: FontStyleSheet, color: TextColorStyleSheet? = nil) {
var name = font.rawValue
if let color {
name += ":\(color.rawValue)"
}
styleName = name
}
func setFontStyle(_ color: TextColorStyleSheet) {
styleName = color.rawValue
}
func setFontStyleAndApply(_ font: FontStyleSheet, color: TextColorStyleSheet? = nil) {
setFontStyle(font, color: color)
applyTheme()
}
func setFontStyleAndApply(_ color: TextColorStyleSheet) {
setFontStyle(color)
applyTheme()
}
}

View file

@ -3,7 +3,7 @@ fileprivate struct AssociatedKeys {
static var isStyleApplied: UInt8 = 1
}
@objc extension UINavigationItem {
@objc extension UINavigationItem: StyleApplicable {
@objc var styleName: String {
get {
isStyleApplied = false
@ -28,9 +28,4 @@ fileprivate struct AssociatedKeys {
objc_setAssociatedObject(self, &AssociatedKeys.isStyleApplied, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
}
@objc func setStyleAndApply(_ styleName: String) {
self.styleName = styleName
self.applyTheme()
}
}

View file

@ -3,7 +3,7 @@ fileprivate struct AssociatedKeys {
static var isStyleApplied: UInt8 = 1
}
@objc extension UIView {
@objc extension UIView: StyleApplicable {
@objc func sw_didMoveToWindow() {
guard MapsAppDelegate.theApp().window === window else {
sw_didMoveToWindow();
@ -39,7 +39,7 @@ fileprivate struct AssociatedKeys {
}
}
@objc func setStyleAndApply(_ styleName: String) {
@objc func setStyleNameAndApply(_ styleName: String) {
self.styleName = styleName
applyTheme()
}

View file

@ -1,197 +1,132 @@
class FontStyleSheet: IStyleSheet {
static func register(theme: Theme, colors: IColors, fonts: IFonts) {
theme.add(styleName: "regular9") { (s) -> (Void) in
s.font = fonts.regular9
}
theme.add(styleName: "regular10") { (s) -> (Void) in
s.font = fonts.regular10
}
theme.add(styleName: "regular11") { (s) -> (Void) in
s.font = fonts.regular11
}
theme.add(styleName: "regular12") { (s) -> (Void) in
s.font = fonts.regular12
}
theme.add(styleName: "regular13") { (s) -> (Void) in
s.font = fonts.regular13
}
theme.add(styleName: "regular14") { (s) -> (Void) in
s.font = fonts.regular14
}
theme.add(styleName: "regular15") { (s) -> (Void) in
s.font = fonts.regular15
}
theme.add(styleName: "regular16") { (s) -> (Void) in
s.font = fonts.regular16
}
theme.add(styleName: "regular17") { (s) -> (Void) in
s.font = fonts.regular17
}
theme.add(styleName: "regular18") { (s) -> (Void) in
s.font = fonts.regular18
}
theme.add(styleName: "regular20") { (s) -> (Void) in
s.font = fonts.regular20
}
theme.add(styleName: "regular24") { (s) -> (Void) in
s.font = fonts.regular24
}
theme.add(styleName: "regular32") { (s) -> (Void) in
s.font = fonts.regular32
}
theme.add(styleName: "regular52") { (s) -> (Void) in
s.font = fonts.regular52
}
theme.add(styleName: "medium9") { (s) -> (Void) in
s.font = fonts.medium9
}
theme.add(styleName: "medium10") { (s) -> (Void) in
s.font = fonts.medium10
}
theme.add(styleName: "medium12") { (s) -> (Void) in
s.font = fonts.medium12
}
theme.add(styleName: "medium14") { (s) -> (Void) in
s.font = fonts.medium14
}
theme.add(styleName: "medium16") { (s) -> (Void) in
s.font = fonts.medium16
}
theme.add(styleName: "medium17") { (s) -> (Void) in
s.font = fonts.medium17
}
theme.add(styleName: "medium18") { (s) -> (Void) in
s.font = fonts.medium18
}
theme.add(styleName: "medium20") { (s) -> (Void) in
s.font = fonts.medium20
}
theme.add(styleName: "medium24") { (s) -> (Void) in
s.font = fonts.medium24
}
theme.add(styleName: "medium28") { (s) -> (Void) in
s.font = fonts.medium28
}
theme.add(styleName: "medium36") { (s) -> (Void) in
s.font = fonts.medium36
}
theme.add(styleName: "medium40") { (s) -> (Void) in
s.font = fonts.medium40
}
theme.add(styleName: "medium44") { (s) -> (Void) in
s.font = fonts.medium44
}
theme.add(styleName: "light10") { (s) -> (Void) in
s.font = fonts.light10
}
theme.add(styleName: "light12") { (s) -> (Void) in
s.font = fonts.light12
}
theme.add(styleName: "light16") { (s) -> (Void) in
s.font = fonts.light16
}
theme.add(styleName: "light17") { (s) -> (Void) in
s.font = fonts.light17
}
theme.add(styleName: "bold12") { (s) -> (Void) in
s.font = fonts.bold12
}
theme.add(styleName: "bold14") { (s) -> (Void) in
s.font = fonts.bold14
}
theme.add(styleName: "bold16") { (s) -> (Void) in
s.font = fonts.bold16
}
theme.add(styleName: "bold17") { (s) -> (Void) in
s.font = fonts.bold17
}
theme.add(styleName: "bold18") { (s) -> (Void) in
s.font = fonts.bold18
}
theme.add(styleName: "bold20") { (s) -> (Void) in
s.font = fonts.bold20
}
theme.add(styleName: "bold22") { (s) -> (Void) in
s.font = fonts.bold22
}
theme.add(styleName: "bold24") { (s) -> (Void) in
s.font = fonts.bold24
}
theme.add(styleName: "bold28") { (s) -> (Void) in
s.font = fonts.bold28
}
theme.add(styleName: "bold34") { (s) -> (Void) in
s.font = fonts.bold34
}
theme.add(styleName: "bold36") { (s) -> (Void) in
s.font = fonts.bold36
}
theme.add(styleName: "bold48") { (s) -> (Void) in
s.font = fonts.bold48
}
theme.add(styleName: "heavy17") { (s) -> (Void) in
s.font = fonts.heavy17
}
theme.add(styleName: "heavy20") { (s) -> (Void) in
s.font = fonts.heavy20
}
theme.add(styleName: "heavy32") { (s) -> (Void) in
s.font = fonts.heavy32
}
theme.add(styleName: "heavy38") { (s) -> (Void) in
s.font = fonts.heavy38
}
theme.add(styleName: "italic12") { (s) -> (Void) in
s.font = fonts.italic12
}
theme.add(styleName: "italic16") { (s) -> (Void) in
s.font = fonts.italic16
}
theme.add(styleName: "semibold12") { (s) -> (Void) in
s.font = fonts.semibold12
}
theme.add(styleName: "semibold14") { (s) -> (Void) in
s.font = fonts.semibold14
}
theme.add(styleName: "semibold15") { (s) -> (Void) in
s.font = fonts.semibold15
}
theme.add(styleName: "semibold16") { (s) -> (Void) in
s.font = fonts.semibold16
}
theme.add(styleName: "semibold18") { (s) -> (Void) in
s.font = fonts.semibold18
}
enum FontStyleSheet: String, CaseIterable {
case regular9
case regular10
case regular11
case regular12
case regular13
case regular14
case regular15
case regular16
case regular17
case regular18
case regular20
case regular24
case regular32
case regular52
theme.add(styleName: "whitePrimaryText") { (s) -> (Void) in
s.fontColor = colors.whitePrimaryText
}
theme.add(styleName: "blackSecondaryText") { (s) -> (Void) in
s.fontColor = colors.blackSecondaryText
}
theme.add(styleName: "blackPrimaryText") { (s) -> (Void) in
s.fontColor = colors.blackPrimaryText
}
theme.add(styleName: "linkBlueText") { (s) -> (Void) in
s.fontColor = colors.linkBlue
}
theme.add(styleName: "linkBlueHighlightedText") { (s) -> (Void) in
s.fontColor = colors.linkBlueHighlighted
}
theme.add(styleName: "whiteText") { (s) -> (Void) in
s.fontColor = colors.white
}
theme.add(styleName: "blackHintText") { (s) -> (Void) in
s.fontColor = colors.blackHintText
}
theme.add(styleName: "greenText") { (s) -> (Void) in
s.fontColor = colors.ratingGreen
}
theme.add(styleName: "redText") { (s) -> (Void) in
s.fontColor = colors.red
}
theme.add(styleName: "buttonRedText") { (s) -> (Void) in
s.fontColor = colors.buttonRed
}
case medium9
case medium10
case medium12
case medium14
case medium16
case medium17
case medium18
case medium20
case medium24
case medium28
case medium36
case medium40
case medium44
case light10
case light12
case light16
case light17
case bold12
case bold14
case bold16
case bold17
case bold18
case bold20
case bold22
case bold24
case bold28
case bold34
case bold36
case bold48
case heavy17
case heavy20
case heavy32
case heavy38
case italic12
case italic16
case semibold12
case semibold14
case semibold15
case semibold16
case semibold18
}
extension FontStyleSheet: IStyleSheet {
func styleResolverFor(colors: IColors, fonts: IFonts) -> Theme.StyleResolver {
let font: UIFont = {
switch self {
case .regular9: return fonts.regular9
case .regular10: return fonts.regular10
case .regular11: return fonts.regular11
case .regular12: return fonts.regular12
case .regular13: return fonts.regular13
case .regular14: return fonts.regular14
case .regular15: return fonts.regular15
case .regular16: return fonts.regular16
case .regular17: return fonts.regular17
case .regular18: return fonts.regular18
case .regular20: return fonts.regular20
case .regular24: return fonts.regular24
case .regular32: return fonts.regular32
case .regular52: return fonts.regular52
case .medium9: return fonts.medium9
case .medium10: return fonts.medium10
case .medium12: return fonts.medium12
case .medium14: return fonts.medium14
case .medium16: return fonts.medium16
case .medium17: return fonts.medium17
case .medium18: return fonts.medium18
case .medium20: return fonts.medium20
case .medium24: return fonts.medium24
case .medium28: return fonts.medium28
case .medium36: return fonts.medium36
case .medium40: return fonts.medium40
case .medium44: return fonts.medium44
case .light10: return fonts.light10
case .light12: return fonts.light12
case .light16: return fonts.light16
case .light17: return fonts.light17
case .bold12: return fonts.bold12
case .bold14: return fonts.bold14
case .bold16: return fonts.bold16
case .bold17: return fonts.bold17
case .bold18: return fonts.bold18
case .bold20: return fonts.bold20
case .bold22: return fonts.bold22
case .bold24: return fonts.bold24
case .bold28: return fonts.bold28
case .bold34: return fonts.bold34
case .bold36: return fonts.bold36
case .bold48: return fonts.bold48
case .heavy17: return fonts.heavy17
case .heavy20: return fonts.heavy20
case .heavy32: return fonts.heavy32
case .heavy38: return fonts.heavy38
case .italic12: return fonts.italic12
case .italic16: return fonts.italic16
case .semibold12: return fonts.semibold12
case .semibold14: return fonts.semibold14
case .semibold15: return fonts.semibold15
case .semibold16: return fonts.semibold16
case .semibold18: return fonts.semibold18
}
}()
return .add { s in s.font = font }
}
}

View file

@ -1,356 +1,429 @@
import Foundation
enum GlobalStyleSheet: String, CaseIterable {
case tableView = "TableView"
case tableCell = "TableCell"
case tableViewCell = "MWMTableViewCell"
case tableViewHeaderFooterView = "TableViewHeaderFooterView"
case searchBar = "SearchBar"
case navigationBar = "NavigationBar"
case navigationBarItem = "NavigationBarItem"
case checkmark = "Checkmark"
case `switch` = "Switch"
case pageControl = "PageControl"
case starRatingView = "StarRatingView"
case difficultyView = "DifficultyView"
case divider = "Divider"
case solidDivider = "SolidDivider"
case background = "Background"
case pressBackground = "PressBackground"
case primaryBackground = "PrimaryBackground"
case secondaryBackground = "SecondaryBackground"
case menuBackground = "MenuBackground"
case bottomTabBarButton = "BottomTabBarButton"
case trackRecordingWidgetButton = "TrackRecordingWidgetButton"
case blackOpaqueBackground = "BlackOpaqueBackground"
case blueBackground = "BlueBackground"
case toastBackground = "ToastBackground"
case fadeBackground = "FadeBackground"
case errorBackground = "ErrorBackground"
case blackStatusBarBackground = "BlackStatusBarBackground"
case presentationBackground = "PresentationBackground"
case clearBackground = "ClearBackground"
case border = "Border"
case tabView = "TabView"
case dialogView = "DialogView"
case alertView = "AlertView"
case alertViewTextFieldContainer = "AlertViewTextFieldContainer"
case alertViewTextField = "AlertViewTextField"
case searchStatusBarView = "SearchStatusBarView"
case flatNormalButton = "FlatNormalButton"
case flatNormalButtonBig = "FlatNormalButtonBig"
case flatNormalTransButton = "FlatNormalTransButton"
case flatNormalTransButtonBig = "FlatNormalTransButtonBig"
case flatGrayTransButton = "FlatGrayTransButton"
case flatPrimaryTransButton = "FlatPrimaryTransButton"
case flatRedTransButton = "FlatRedTransButton"
case flatRedTransButtonBig = "FlatRedTransButtonBig"
case flatRedButton = "FlatRedButton"
case moreButton = "MoreButton"
case editButton = "EditButton"
case rateAppButton = "RateAppButton"
case termsOfUseLinkText = "TermsOfUseLinkText"
case termsOfUseGrayButton = "TermsOfUseGrayButton"
case badge = "Badge"
case blue = "MWMBlue"
case black = "MWMBlack"
case other = "MWMOther"
case gray = "MWMGray"
case separator = "MWMSeparator"
case white = "MWMWhite"
case datePickerView = "DatePickerView"
case valueStepperView = "ValueStepperView"
}
class GlobalStyleSheet: IStyleSheet {
static func register(theme: Theme, colors: IColors, fonts: IFonts) {
//MARK: Defaults
theme.add(styleName: "TableView") { (s) -> (Void) in
s.backgroundColor = colors.white
s.separatorColor = colors.blackDividers
s.exclusions = [String(describing: UIDatePicker.self)]
}
extension GlobalStyleSheet: IStyleSheet {
func styleResolverFor(colors: IColors, fonts: IFonts) -> Theme.StyleResolver {
switch self {
case .tableView:
return .add { s in
s.backgroundColor = colors.white
s.separatorColor = colors.blackDividers
s.exclusions = [String(describing: UIDatePicker.self)]
}
case .tableCell:
return .add { s in
s.backgroundColor = colors.white
s.fontColor = colors.blackPrimaryText
s.tintColor = colors.linkBlue
s.fontColorDetailed = colors.blackSecondaryText
s.backgroundColorSelected = colors.pressBackground
s.exclusions = [String(describing: UIDatePicker.self), "_UIActivityUserDefaultsActivityCell"]
}
case .tableViewCell:
return .addFrom(Self.tableCell) { s in
}
case .tableViewHeaderFooterView:
return .add { s in
s.font = fonts.medium14
s.fontColor = colors.blackSecondaryText
}
case .searchBar:
return .add { s in
s.backgroundColor = colors.white
s.barTintColor = colors.primary
s.fontColor = colors.blackPrimaryText
s.fontColorDetailed = UIColor.white
s.tintColor = colors.blackSecondaryText
}
case .navigationBar:
return .add { s in
s.barTintColor = colors.primary
s.tintColor = colors.whitePrimaryText
s.backgroundImage = UIImage()
s.shadowImage = UIImage()
s.font = fonts.header
s.fontColor = colors.whitePrimaryText
}
case .navigationBarItem:
return .add { s in
s.font = fonts.regular18
s.fontColor = colors.whitePrimaryText
s.fontColorDisabled = UIColor.lightGray
s.fontColorHighlighted = colors.whitePrimaryTextHighlighted
s.tintColor = colors.whitePrimaryText
}
case .checkmark:
return .add { s in
s.onTintColor = colors.linkBlue
s.offTintColor = colors.blackHintText
}
case .switch:
return .add { s in
s.onTintColor = colors.linkBlue
}
case .pageControl:
return .add { s in
s.pageIndicatorTintColor = colors.blackHintText
s.currentPageIndicatorTintColor = colors.blackSecondaryText
s.backgroundColor = colors.white
}
case .starRatingView:
return .add { s in
s.onTintColor = colors.ratingYellow
s.offTintColor = colors.blackDividers
}
case .difficultyView:
return .add { s in
s.colors = [colors.blackSecondaryText, colors.ratingGreen, colors.ratingYellow, colors.ratingRed]
s.offTintColor = colors.blackSecondaryText
s.backgroundColor = colors.clear
}
case .divider:
return .add { s in
s.backgroundColor = colors.blackDividers
}
case .solidDivider:
return .add { s in
s.backgroundColor = colors.solidDividers
}
case .background:
return .add { s in
s.backgroundColor = colors.white
s.backgroundColorSelected = colors.pressBackground
}
case .pressBackground:
return .add { s in
s.backgroundColor = colors.pressBackground
}
case .primaryBackground:
return .add { s in
s.backgroundColor = colors.primary
}
case .secondaryBackground:
return .add { s in
s.backgroundColor = colors.secondary
}
case .menuBackground:
return .add { s in
s.backgroundColor = colors.menuBackground
}
case .bottomTabBarButton:
return .add { s in
s.backgroundColor = colors.tabBarButtonBackground
s.tintColor = colors.blackSecondaryText
s.coloring = MWMButtonColoring.black
s.cornerRadius = 8
s.shadowColor = UIColor(0,0,0,alpha20)
s.shadowOpacity = 1
s.shadowOffset = CGSize(width: 0, height: 1)
s.onTintColor = .red
}
case .trackRecordingWidgetButton:
return .addFrom(Self.bottomTabBarButton) { s in
s.cornerRadius = 23
}
case .blackOpaqueBackground:
return .add { s in
s.backgroundColor = colors.blackOpaque
}
case .blueBackground:
return .add { s in
s.backgroundColor = colors.linkBlue
}
case .toastBackground:
return .add { s in
s.backgroundColor = colors.toastBackground
}
case .fadeBackground:
return .add { s in
s.backgroundColor = colors.fadeBackground
}
case .errorBackground:
return .add { s in
s.backgroundColor = colors.errorPink
}
case .blackStatusBarBackground:
return .add { s in
s.backgroundColor = colors.blackStatusBarBackground
}
case .presentationBackground:
return .add { s in
s.backgroundColor = UIColor.black.withAlphaComponent(alpha40)
}
case .clearBackground:
return .add { s in
s.backgroundColor = colors.clear
}
case .border:
return .add { s in
s.backgroundColor = colors.border
}
case .tabView:
return .add { s in
s.backgroundColor = colors.pressBackground
s.barTintColor = colors.primary
s.tintColor = colors.white
s.fontColor = colors.whitePrimaryText
s.font = fonts.medium14
}
case .dialogView:
return .add { s in
s.cornerRadius = 8
s.shadowRadius = 2
s.shadowColor = UIColor(0,0,0,alpha26)
s.shadowOpacity = 1
s.shadowOffset = CGSize(width: 0, height: 1)
s.backgroundColor = colors.white
s.clip = true
}
case .alertView:
return .add { s in
s.cornerRadius = 12
s.shadowRadius = 6
s.shadowColor = UIColor(0,0,0,alpha20)
s.shadowOpacity = 1
s.shadowOffset = CGSize(width: 0, height: 3)
s.backgroundColor = colors.alertBackground
s.clip = true
}
case .alertViewTextFieldContainer:
return .add { s in
s.borderColor = colors.blackDividers
s.borderWidth = 0.5
s.backgroundColor = colors.white
}
case .alertViewTextField:
return .add { s in
s.font = fonts.regular14
s.fontColor = colors.blackPrimaryText
s.tintColor = colors.blackSecondaryText
}
case .searchStatusBarView:
return .add { s in
s.backgroundColor = colors.primary
s.shadowRadius = 2
s.shadowColor = colors.blackDividers
s.shadowOpacity = 1
s.shadowOffset = CGSize(width: 0, height: 0)
}
case .flatNormalButton:
return .add { s in
s.font = fonts.medium14
s.cornerRadius = 8
s.clip = true
s.fontColor = colors.whitePrimaryText
s.backgroundColor = colors.linkBlue
s.fontColorHighlighted = colors.whitePrimaryTextHighlighted
s.fontColorDisabled = colors.whitePrimaryTextHighlighted
s.backgroundColorHighlighted = colors.linkBlueHighlighted
}
case .flatNormalButtonBig:
return .addFrom(Self.flatNormalButton) { s in
s.font = fonts.regular17
}
case .flatNormalTransButton:
return .add { s in
s.font = fonts.medium14
s.cornerRadius = 8
s.clip = true
s.fontColor = colors.linkBlue
s.backgroundColor = colors.clear
s.fontColorHighlighted = colors.linkBlueHighlighted
s.fontColorDisabled = colors.blackHintText
s.backgroundColorHighlighted = colors.clear
}
case .flatNormalTransButtonBig:
return .addFrom(Self.flatNormalTransButton) { s in
s.font = fonts.regular17
}
case .flatGrayTransButton:
return .add { s in
s.font = fonts.medium14
s.fontColor = colors.blackSecondaryText
s.backgroundColor = colors.clear
s.fontColorHighlighted = colors.linkBlueHighlighted
}
case .flatPrimaryTransButton:
return .add { s in
s.fontColor = colors.blackPrimaryText
s.backgroundColor = colors.clear
s.fontColorHighlighted = colors.linkBlueHighlighted
}
case .flatRedTransButton:
return .add { s in
s.font = fonts.medium14
s.fontColor = colors.red
s.backgroundColor = colors.clear
s.fontColorHighlighted = colors.red
}
case .flatRedTransButtonBig:
return .add { s in
s.font = fonts.regular17
s.fontColor = colors.red
s.backgroundColor = colors.clear
s.fontColorHighlighted = colors.red
}
case .flatRedButton:
return .add { s in
s.font = fonts.medium14
s.cornerRadius = 8
s.fontColor = colors.whitePrimaryText
s.backgroundColor = colors.buttonRed
s.fontColorHighlighted = colors.buttonRedHighlighted
}
case .moreButton:
return .add { s in
s.fontColor = colors.linkBlue
s.fontColorHighlighted = colors.linkBlueHighlighted
s.backgroundColor = colors.clear
s.font = fonts.regular16
}
case .editButton:
return .add { s in
s.font = fonts.regular14
s.fontColor = colors.linkBlue
s.cornerRadius = 8
s.borderColor = colors.linkBlue
s.borderWidth = 1
s.fontColorHighlighted = colors.linkBlueHighlighted
s.backgroundColor = colors.clear
}
case .rateAppButton:
return .add { s in
s.font = fonts.medium17
s.fontColor = colors.linkBlue
s.fontColorHighlighted = colors.white
s.borderColor = colors.linkBlue
s.cornerRadius = 8
s.borderWidth = 1
s.backgroundColor = colors.clear
s.backgroundColorHighlighted = colors.linkBlue
}
case .termsOfUseLinkText:
return .add { s in
s.font = fonts.regular16
s.fontColor = colors.blackPrimaryText
theme.add(styleName: "TableCell") { (s) -> (Void) in
s.backgroundColor = colors.white
s.fontColor = colors.blackPrimaryText
s.tintColor = colors.linkBlue
s.fontColorDetailed = colors.blackSecondaryText
s.backgroundColorSelected = colors.pressBackground
s.exclusions = [String(describing: UIDatePicker.self),
"_UIActivityUserDefaultsActivityCell"]
}
theme.add(styleName: "MWMTableViewCell", from: "TableCell") { (s) -> (Void) in
}
theme.add(styleName: "TableViewHeaderFooterView") { (s) -> (Void) in
s.font = fonts.medium14
s.fontColor = colors.blackSecondaryText
}
theme.add(styleName: "SearchBar") { (s) -> (Void) in
s.backgroundColor = colors.white
s.barTintColor = colors.primary
s.fontColor = colors.blackPrimaryText
s.fontColorDetailed = UIColor.white
s.tintColor = colors.blackSecondaryText
}
theme.add(styleName: "NavigationBar") { (s) -> (Void) in
s.barTintColor = colors.primary
s.tintColor = colors.whitePrimaryText
s.backgroundImage = UIImage()
s.shadowImage = UIImage()
s.font = fonts.header
s.fontColor = colors.whitePrimaryText
}
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
s.onTintColor = colors.linkBlue
s.offTintColor = colors.blackHintText
}
theme.add(styleName: "Switch") { (s) -> (Void) in
s.onTintColor = colors.linkBlue
}
theme.add(styleName: "PageControl") { (s) -> (Void) in
s.pageIndicatorTintColor = colors.blackHintText
s.currentPageIndicatorTintColor = colors.blackSecondaryText
s.backgroundColor = colors.white
}
theme.add(styleName: "StarRatingView") { (s) -> (Void) in
s.onTintColor = colors.ratingYellow
s.offTintColor = colors.blackDividers
}
theme.add(styleName: "DifficultyView") { (s) -> (Void) in
s.colors = [colors.blackSecondaryText, colors.ratingGreen, colors.ratingYellow, colors.ratingRed]
s.offTintColor = colors.blackSecondaryText
s.backgroundColor = colors.clear
}
//MARK: Global styles
theme.add(styleName: "Divider") { (s) -> (Void) in
s.backgroundColor = colors.blackDividers
}
theme.add(styleName: "SolidDivider") { (s) -> (Void) in
s.backgroundColor = colors.solidDividers
}
theme.add(styleName: "Background") { (s) -> (Void) in
s.backgroundColor = colors.white
s.backgroundColorSelected = colors.pressBackground
}
theme.add(styleName: "PressBackground") { (s) -> (Void) in
s.backgroundColor = colors.pressBackground
}
theme.add(styleName: "PrimaryBackground") { (s) -> (Void) in
s.backgroundColor = colors.primary
}
theme.add(styleName: "SecondaryBackground") { (s) -> (Void) in
s.backgroundColor = colors.secondary
}
theme.add(styleName: "MenuBackground") { (s) -> (Void) in
s.backgroundColor = colors.menuBackground
}
theme.add(styleName: "BottomTabBarButton") { (s) -> (Void) in
s.backgroundColor = colors.tabBarButtonBackground
s.tintColor = colors.blackSecondaryText
s.coloring = MWMButtonColoring.black
s.cornerRadius = 8
s.shadowColor = UIColor(0,0,0,alpha20)
s.shadowOpacity = 1
s.shadowOffset = CGSize(width: 0, height: 1)
s.onTintColor = .red
}
theme.add(styleName: "TrackRecordingWidgetButton", from: "BottomTabBarButton") { (s) -> (Void) in
s.cornerRadius = 23
}
theme.add(styleName: "BlackOpaqueBackground") { (s) -> (Void) in
s.backgroundColor = colors.blackOpaque
}
theme.add(styleName: "BlueBackground") { (s) -> (Void) in
s.backgroundColor = colors.linkBlue
}
theme.add(styleName: "ToastBackground") { (s) -> (Void) in
s.backgroundColor = colors.toastBackground
}
theme.add(styleName: "FadeBackground") { (s) -> (Void) in
s.backgroundColor = colors.fadeBackground
}
theme.add(styleName: "ErrorBackground") { (s) -> (Void) in
s.backgroundColor = colors.errorPink
}
theme.add(styleName: "BlackStatusBarBackground") { (s) -> (Void) in
s.backgroundColor = colors.blackStatusBarBackground
}
theme.add(styleName: "PresentationBackground") { (s) -> (Void) in
s.backgroundColor = UIColor.black.withAlphaComponent(alpha40)
}
theme.add(styleName: "ClearBackground") { (s) -> (Void) in
s.backgroundColor = colors.clear
}
theme.add(styleName: "Border") { (s) -> (Void) in
s.backgroundColor = colors.border
}
theme.add(styleName: "TabView") { (s) -> (Void) in
s.backgroundColor = colors.pressBackground
s.barTintColor = colors.primary
s.tintColor = colors.white
s.fontColor = colors.whitePrimaryText
s.font = fonts.medium14
}
theme.add(styleName: "DialogView") { (s) -> (Void) in
s.cornerRadius = 8
s.shadowRadius = 2
s.shadowColor = UIColor(0,0,0,alpha26)
s.shadowOpacity = 1
s.shadowOffset = CGSize(width: 0, height: 1)
s.backgroundColor = colors.white
s.clip = true
}
theme.add(styleName: "AlertView") { (s) -> (Void) in
s.cornerRadius = 12
s.shadowRadius = 6
s.shadowColor = UIColor(0,0,0,alpha20)
s.shadowOpacity = 1
s.shadowOffset = CGSize(width: 0, height: 3)
s.backgroundColor = colors.alertBackground
s.clip = true
}
theme.add(styleName: "AlertViewTextFieldContainer") { (s) -> (Void) in
s.borderColor = colors.blackDividers
s.borderWidth = 0.5
s.backgroundColor = colors.white
}
theme.add(styleName: "AlertViewTextField") { (s) -> Void in
s.font = fonts.regular14
s.fontColor = colors.blackPrimaryText
s.tintColor = colors.blackSecondaryText
}
theme.add(styleName: "SearchStatusBarView") { (s) -> (Void) in
s.backgroundColor = colors.primary
s.shadowRadius = 2
s.shadowColor = colors.blackDividers
s.shadowOpacity = 1
s.shadowOffset = CGSize(width: 0, height: 0)
}
//MARK: Buttons
theme.add(styleName: "FlatNormalButton") { (s) -> (Void) in
s.font = fonts.medium14
s.cornerRadius = 8
s.clip = true
s.fontColor = colors.whitePrimaryText
s.backgroundColor = colors.linkBlue
s.fontColorHighlighted = colors.whitePrimaryTextHighlighted
s.fontColorDisabled = colors.whitePrimaryTextHighlighted
s.backgroundColorHighlighted = colors.linkBlueHighlighted
}
theme.add(styleName: "FlatNormalButtonBig", from: "FlatNormalButton") { (s) -> (Void) in
s.font = fonts.regular17
}
theme.add(styleName: "FlatNormalTransButton") { (s) -> (Void) in
s.font = fonts.medium14
s.cornerRadius = 8
s.clip = true
s.fontColor = colors.linkBlue
s.backgroundColor = colors.clear
s.fontColorHighlighted = colors.linkBlueHighlighted
s.fontColorDisabled = colors.blackHintText
s.backgroundColorHighlighted = colors.clear
}
theme.add(styleName: "FlatNormalTransButtonBig", from: "FlatNormalTransButton") { (s) -> (Void) in
s.font = fonts.regular17
}
theme.add(styleName: "FlatGrayTransButton") { (s) -> (Void) in
s.font = fonts.medium14
s.fontColor = colors.blackSecondaryText
s.backgroundColor = colors.clear
s.fontColorHighlighted = colors.linkBlueHighlighted
}
theme.add(styleName: "FlatPrimaryTransButton") { (s) -> (Void) in
s.fontColor = colors.blackPrimaryText
s.backgroundColor = colors.clear
s.fontColorHighlighted = colors.linkBlueHighlighted
}
theme.add(styleName: "FlatRedTransButton") { (s) -> (Void) in
s.font = fonts.medium14
s.fontColor = colors.red
s.backgroundColor = colors.clear
s.fontColorHighlighted = colors.red
}
theme.add(styleName: "FlatRedTransButtonBig") { (s) -> (Void) in
s.font = fonts.regular17
s.fontColor = colors.red
s.backgroundColor = colors.clear
s.fontColorHighlighted = colors.red
}
theme.add(styleName: "FlatRedButton") { (s) -> (Void) in
s.font = fonts.medium14
s.cornerRadius = 8
s.fontColor = colors.whitePrimaryText
s.backgroundColor = colors.buttonRed
s.fontColorHighlighted = colors.buttonRedHighlighted
}
theme.add(styleName: "MoreButton") { (s) -> (Void) in
s.fontColor = colors.linkBlue
s.fontColorHighlighted = colors.linkBlueHighlighted
s.backgroundColor = colors.clear
s.font = fonts.regular16
}
theme.add(styleName: "EditButton") { (s) -> (Void) in
s.font = fonts.regular14
s.fontColor = colors.linkBlue
s.cornerRadius = 8
s.borderColor = colors.linkBlue
s.borderWidth = 1
s.fontColorHighlighted = colors.linkBlueHighlighted
s.backgroundColor = colors.clear
}
theme.add(styleName: "RateAppButton") { (s) -> (Void) in
s.font = fonts.medium17
s.fontColor = colors.linkBlue
s.fontColorHighlighted = colors.white
s.borderColor = colors.linkBlue
s.cornerRadius = 8
s.borderWidth = 1
s.backgroundColor = colors.clear
s.backgroundColorHighlighted = colors.linkBlue
}
theme.add(styleName: "TermsOfUseLinkText") { (s) -> (Void) in
s.font = fonts.regular16
s.fontColor = colors.blackPrimaryText
s.linkAttributes = [NSAttributedString.Key.font: fonts.regular16,
NSAttributedString.Key.foregroundColor: colors.linkBlue,
NSAttributedString.Key.underlineColor: UIColor.clear]
s.textContainerInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
}
theme.add(styleName: "TermsOfUseGrayButton") { (s) -> (Void) in
s.font = fonts.medium10
s.fontColor = colors.blackSecondaryText
s.fontColorHighlighted = colors.blackHintText
}
theme.add(styleName: "Badge") { (s) -> (Void) in
s.round = true
s.backgroundColor = colors.downloadBadgeBackground
}
//MARK: coloring
theme.add(styleName: "MWMBlue") { (s) -> (Void) in
s.tintColor = colors.linkBlue
s.coloring = MWMButtonColoring.blue
}
theme.add(styleName: "MWMBlack") { (s) -> (Void) in
s.tintColor = colors.blackSecondaryText
s.coloring = MWMButtonColoring.black
}
theme.add(styleName: "MWMOther") { (s) -> (Void) in
s.tintColor = colors.white
s.coloring = MWMButtonColoring.other
}
theme.add(styleName: "MWMGray") { (s) -> (Void) in
s.tintColor = colors.blackHintText
s.coloring = MWMButtonColoring.gray
}
theme.add(styleName: "MWMSeparator") { (s) -> (Void) in
s.tintColor = colors.blackDividers
s.coloring = MWMButtonColoring.black
}
theme.add(styleName: "MWMWhite") { (s) -> (Void) in
s.tintColor = colors.white
s.coloring = MWMButtonColoring.white
s.linkAttributes = [NSAttributedString.Key.font: fonts.regular16,
NSAttributedString.Key.foregroundColor: colors.linkBlue,
NSAttributedString.Key.underlineColor: UIColor.clear]
s.textContainerInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
}
case .termsOfUseGrayButton:
return .add { s in
s.font = fonts.medium10
s.fontColor = colors.blackSecondaryText
s.fontColorHighlighted = colors.blackHintText
}
case .badge:
return .add { s in
s.round = true
s.backgroundColor = colors.downloadBadgeBackground
}
case .blue:
return .add { s in
s.tintColor = colors.linkBlue
s.coloring = MWMButtonColoring.blue
}
case .black:
return .add { s in
s.tintColor = colors.blackSecondaryText
s.coloring = MWMButtonColoring.black
}
case .other:
return .add { s in
s.tintColor = colors.white
s.coloring = MWMButtonColoring.other
}
case .gray:
return .add { s in
s.tintColor = colors.blackHintText
s.coloring = MWMButtonColoring.gray
}
case .separator:
return .add { s in
s.tintColor = colors.blackDividers
s.coloring = MWMButtonColoring.black
}
case .white:
return .add { s in
s.tintColor = colors.white
s.coloring = MWMButtonColoring.white
}
case .datePickerView:
return .add { s in
s.backgroundColor = colors.white
s.fontColor = colors.blackPrimaryText
s.fontColorSelected = colors.whitePrimaryText
s.backgroundColorSelected = colors.linkBlue
s.backgroundColorHighlighted = colors.linkBlueHighlighted
s.fontColorDisabled = colors.blackSecondaryText
}
case .valueStepperView:
return .add { s in
s.font = fonts.regular16
s.fontColor = colors.blackPrimaryText
s.coloring = MWMButtonColoring.blue
}
}
}
}

View file

@ -1,13 +1,12 @@
class MainTheme: Theme {
override func register() {
self.registerStyleSheet(GlobalStyleSheet.self)
self.registerStyleSheet(FontStyleSheet.self)
self.registerStyleSheet(SearchStyleSheet.self)
self.registerStyleSheet(BookmarksStyleSheet.self)
self.registerStyleSheet(MapStyleSheet.self)
self.registerStyleSheet(AuthStyleSheet.self)
self.registerStyleSheet(PlacePageStyleSheet.self)
self.registerStyleSheet(PartnersStyleSheet.self)
registerStyleSheet(GlobalStyleSheet.self)
registerStyleSheet(PlacePageStyleSheet.self)
registerStyleSheet(MapStyleSheet.self)
registerStyleSheet(BookmarksStyleSheet.self)
registerStyleSheet(SearchStyleSheet.self)
registerStyleSheet(FontStyleSheet.self)
registerStyleSheet(TextColorStyleSheet.self)
}
}

View file

@ -1,134 +1,122 @@
class MapStyleSheet: IStyleSheet {
static func register(theme: Theme, colors: IColors, fonts: IFonts) {
theme.add(styleName: "MenuButtonDisabled") { (s) -> (Void) in
s.fontColor = colors.blackSecondaryText
s.font = fonts.regular10
s.backgroundColor = colors.clear
s.borderColor = colors.clear
s.borderWidth = 0
s.cornerRadius = 6
}
enum MapStyleSheet: String, CaseIterable {
case mapMenuButtonDisabled = "MenuButtonDisabled"
case mapMenuButtonEnabled = "MenuButtonEnabled"
case mapStreetNameBackgroundView = "StreetNameBackgroundView"
case mapButtonZoomIn = "ButtonZoomIn"
case mapButtonZoomOut = "ButtonZoomOut"
case mapButtonPending = "ButtonPending"
case mapButtonGetPosition = "ButtonGetPosition"
case mapButtonFollow = "ButtonFollow"
case mapButtonFollowAndRotate = "ButtonFollowAndRotate"
case mapButtonMapBookmarks = "ButtonMapBookmarks"
case mapPromoDiscoveryButton = "PromoDiscroveryButton"
case mapButtonBookmarksBack = "ButtonBookmarksBack"
case mapButtonBookmarksBackOpaque = "ButtonBookmarksBackOpaque"
case mapFirstTurnView = "FirstTurnView"
case mapSecondTurnView = "SecondTurnView"
case mapAutoupdateView = "MapAutoupdateView"
case mapGuidesNavigationBar = "GuidesNavigationBar"
}
theme.add(styleName: "MenuButtonEnabled") { (s) -> (Void) in
s.fontColor = colors.linkBlue
s.font = fonts.regular10
s.backgroundColor = colors.linkBlue
s.borderColor = colors.linkBlue
s.borderWidth = 2
s.cornerRadius = 6
}
theme.add(styleName: "StreetNameBackgroundView") { (s) -> (Void) in
s.backgroundColor = colors.white
s.shadowRadius = 2
s.shadowColor = UIColor(0, 0, 0, alpha26)
s.shadowOpacity = 1
s.shadowOffset = CGSize(width: 0, height: 1)
}
theme.add(styleName: "PPRatingView") { (s) -> (Void) in
s.backgroundColor = colors.blackOpaque
s.round = true
}
theme.add(styleName: "PPRatingHorrible") { (s) -> (Void) in
s.image = "ic_24px_rating_horrible"
s.tintColor = colors.ratingRed
}
theme.add(styleName: "PPRatingBad") { (s) -> (Void) in
s.image = "ic_24px_rating_bad"
s.tintColor = colors.ratingOrange
}
theme.add(styleName: "PPRatingNormal") { (s) -> (Void) in
s.image = "ic_24px_rating_normal"
s.tintColor = colors.ratingYellow
}
theme.add(styleName: "PPRatingGood") { (s) -> (Void) in
s.image = "ic_24px_rating_good"
s.tintColor = colors.ratingLightGreen
}
theme.add(styleName: "PPRatingExellent") { (s) -> (Void) in
s.image = "ic_24px_rating_excellent"
s.tintColor = colors.ratingGreen
}
theme.add(styleName: "PPButton", from: "FlatNormalTransButtonBig") { (s) -> (Void) in
s.borderColor = colors.linkBlue
s.borderWidth = 1
}
theme.add(styleName: "ButtonZoomIn") { (s) -> (Void) in
s.mwmImage = "btn_zoom_in"
}
theme.add(styleName: "ButtonZoomOut") { (s) -> (Void) in
s.mwmImage = "btn_zoom_out"
}
theme.add(styleName: "ButtonPending") { (s) -> (Void) in
s.mwmImage = "btn_pending"
}
theme.add(styleName: "ButtonGetPosition") { (s) -> (Void) in
s.mwmImage = "btn_get_position"
}
theme.add(styleName: "ButtonFollow") { (s) -> (Void) in
s.mwmImage = "btn_follow"
}
theme.add(styleName: "ButtonFollowAndRotate") { (s) -> (Void) in
s.mwmImage = "btn_follow_and_rotate"
}
theme.add(styleName: "ButtonMapBookmarks") { (s) -> (Void) in
s.mwmImage = "ic_routing_bookmark"
}
theme.add(styleName: "PromoDiscroveryButton") { (s) -> (Void) in
s.mwmImage = "promo_discovery_button"
}
theme.add(styleName: "ButtonBookmarksBack") { (s) -> (Void) in
s.mwmImage = "btn_back"
}
theme.add(styleName: "ButtonBookmarksBackOpaque") { (s) -> (Void) in
s.mwmImage = "btn_back_opaque"
}
theme.add(styleName: "FirstTurnView") { (s) -> (Void) in
s.backgroundColor = colors.linkBlue
s.cornerRadius = 4
s.shadowRadius = 2
s.shadowColor = colors.blackHintText
s.shadowOpacity = 1
s.shadowOffset = CGSize(width: 0, height: 2)
}
theme.add(styleName: "SecondTurnView", from: "FirstTurnView") { (s) -> (Void) in
s.backgroundColor = colors.white
}
theme.add(styleName: "MapAutoupdateView") { (s) -> (Void) in
s.shadowOffset = CGSize(width: 0, height: 3)
s.shadowRadius = 6
s.cornerRadius = 4
s.shadowOpacity = 1
s.backgroundColor = colors.white
}
theme.add(styleName: "GuidesNavigationBar") { (s) -> (Void) in
s.barTintColor = colors.white
s.tintColor = colors.linkBlue
s.backgroundImage = UIImage()
s.shadowImage = UIImage()
s.font = fonts.regular18
s.fontColor = colors.blackPrimaryText
extension MapStyleSheet: IStyleSheet {
func styleResolverFor(colors: IColors, fonts: IFonts) -> Theme.StyleResolver {
switch self {
case .mapMenuButtonDisabled:
return .add { s in
s.fontColor = colors.blackSecondaryText
s.font = fonts.regular10
s.backgroundColor = colors.clear
s.borderColor = colors.clear
s.borderWidth = 0
s.cornerRadius = 6
}
case .mapMenuButtonEnabled:
return .add { s in
s.fontColor = colors.linkBlue
s.font = fonts.regular10
s.backgroundColor = colors.linkBlue
s.borderColor = colors.linkBlue
s.borderWidth = 2
s.cornerRadius = 6
}
case .mapStreetNameBackgroundView:
return .add { s in
s.backgroundColor = colors.white
s.shadowRadius = 2
s.shadowColor = UIColor(0, 0, 0, alpha26)
s.shadowOpacity = 1
s.shadowOffset = CGSize(width: 0, height: 1)
}
case .mapButtonZoomIn:
return .add { s in
s.mwmImage = "btn_zoom_in"
}
case .mapButtonZoomOut:
return .add { s in
s.mwmImage = "btn_zoom_out"
}
case .mapButtonPending:
return .add { s in
s.mwmImage = "btn_pending"
}
case .mapButtonGetPosition:
return .add { s in
s.mwmImage = "btn_get_position"
}
case .mapButtonFollow:
return .add { s in
s.mwmImage = "btn_follow"
}
case .mapButtonFollowAndRotate:
return .add { s in
s.mwmImage = "btn_follow_and_rotate"
}
case .mapButtonMapBookmarks:
return .add { s in
s.mwmImage = "ic_routing_bookmark"
}
case .mapPromoDiscoveryButton:
return .add { s in
s.mwmImage = "promo_discovery_button"
}
case .mapButtonBookmarksBack:
return .add { s in
s.mwmImage = "btn_back"
}
case .mapButtonBookmarksBackOpaque:
return .add { s in
s.mwmImage = "btn_back_opaque"
}
case .mapFirstTurnView:
return .add { s in
s.backgroundColor = colors.linkBlue
s.cornerRadius = 4
s.shadowRadius = 2
s.shadowColor = colors.blackHintText
s.shadowOpacity = 1
s.shadowOffset = CGSize(width: 0, height: 2)
}
case .mapSecondTurnView:
return .addFrom(Self.mapFirstTurnView) { s in
s.backgroundColor = colors.white
}
case .mapAutoupdateView:
return .add { s in
s.shadowOffset = CGSize(width: 0, height: 3)
s.shadowRadius = 6
s.cornerRadius = 4
s.shadowOpacity = 1
s.backgroundColor = colors.white
}
case .mapGuidesNavigationBar:
return .add { s in
s.barTintColor = colors.white
s.tintColor = colors.linkBlue
s.backgroundImage = UIImage()
s.shadowImage = UIImage()
s.font = fonts.regular18
s.fontColor = colors.blackPrimaryText
}
}
}
}

View file

@ -1,44 +0,0 @@
class PartnersStyleSheet: IStyleSheet {
static func register(theme: Theme, colors: IColors, fonts: IFonts) {
theme.add(styleName: "Tinkoff") { (s) -> (Void) in
s.backgroundColor = UIColor(fromHexString: "FFDD2D")
s.fontColor = .black
s.font = fonts.semibold14
s.cornerRadius = 14
s.clip = true
}
theme.add(styleName: "Mts") { (s) -> (Void) in
s.backgroundColor = UIColor(fromHexString: "E30611")
s.fontColor = .white
s.font = fonts.semibold14
s.cornerRadius = 14
s.clip = true
}
theme.add(styleName: "Skyeng") { (s) -> (Void) in
s.backgroundColor = UIColor(fromHexString: "4287DF")
s.fontColor = .white
s.font = fonts.semibold14
s.cornerRadius = 14
s.clip = true
}
theme.add(styleName: "Sberbank") { (s) -> (Void) in
s.backgroundColor = UIColor(fromHexString: "009A37")
s.fontColor = .white
s.font = fonts.semibold14
s.cornerRadius = 14
s.clip = true
}
theme.add(styleName: "Arsenal") { (s) -> (Void) in
s.backgroundColor = UIColor(fromHexString: "93C950")
s.fontColor = .white
s.font = fonts.semibold14
s.cornerRadius = 14
s.clip = true
}
}
}

View file

@ -1,131 +1,195 @@
class PlacePageStyleSheet: IStyleSheet {
static func register(theme: Theme, colors: IColors, fonts: IFonts) {
theme.add(styleName: "PPTitlePopularView") { (s) -> (Void) in
s.backgroundColor = colors.linkBlueHighlighted
s.cornerRadius = 10
}
enum PlacePageStyleSheet: String, CaseIterable {
case ppTitlePopularView = "PPTitlePopularView"
case ppActionBarTitle = "PPActionBarTitle"
case ppActionBarTitlePartner = "PPActionBarTitlePartner"
case ppElevationProfileDescriptionCell = "ElevationProfileDescriptionCell"
case ppElevationProfileExtendedDifficulty = "ElevationProfileExtendedDifficulty"
case ppRouteBasePreview = "RouteBasePreview"
case ppRoutePreview = "RoutePreview"
case ppRatingSummaryView24 = "RatingSummaryView24"
case ppRatingSummaryView12 = "RatingSummaryView12"
case ppRatingSummaryView12User = "RatingSummaryView12User"
case ppHeaderView = "PPHeaderView"
case ppNavigationShadowView = "PPNavigationShadowView"
case ppBackgroundView = "PPBackgroundView"
case ppView = "PPView"
case ppHeaderCircleIcon = "PPHeaderCircleIcon"
case ppChartView = "ChartView"
case ppRatingView = "PPRatingView"
case ppRatingHorrible = "PPRatingHorrible"
case ppRatingBad = "PPRatingBad"
case ppRatingNormal = "PPRatingNormal"
case ppRatingGood = "PPRatingGood"
case ppRatingExcellent = "PPRatingExellent"
case ppButton = "PPButton"
}
theme.add(styleName: "PPActionBarTitle") { (s) -> (Void) in
s.font = fonts.regular10
s.fontColor = colors.blackSecondaryText
}
theme.add(styleName: "PPActionBarTitlePartner") { (s) -> (Void) in
s.font = fonts.regular10
s.fontColor = UIColor.white
}
theme.add(styleName: "ElevationProfileDescriptionCell") { (s) -> (Void) in
s.backgroundColor = colors.blackOpaque
s.cornerRadius = 6
}
theme.add(styleName: "ElevationProfileExtendedDifficulty") { (s) -> (Void) in
s.backgroundColor = colors.blackSecondaryText
s.fontColor = colors.white
s.font = fonts.medium14
s.textContainerInset = UIEdgeInsets(top: 4, left: 6, bottom: 4, right: 6)
}
theme.add(styleName: "RouteBasePreview") { (s) -> (Void) in
s.borderColor = colors.blackDividers
s.borderWidth = 1
s.backgroundColor = colors.white
}
theme.add(styleName: "RoutePreview") { (s) -> (Void) in
s.shadowRadius = 2
s.shadowColor = colors.blackDividers
s.shadowOpacity = 1
s.shadowOffset = CGSize(width: 3, height: 0)
s.backgroundColor = colors.pressBackground
}
theme.add(styleName: "RatingSummaryView24") { (s) -> (Void) in
s.font = fonts.bold16
s.fontColorHighlighted = colors.ratingYellow //filled color
s.fontColorDisabled = colors.blackDividers //empty color
s.colors = [
colors.blackSecondaryText, //noValue
colors.ratingRed, //horrible
colors.ratingOrange, //bad
colors.ratingYellow, //normal
colors.ratingLightGreen, //good
colors.ratingGreen //exellent
]
s.images = [
"ic_24px_rating_normal", //noValue
"ic_24px_rating_horrible", //horrible
"ic_24px_rating_bad", //bad
"ic_24px_rating_normal", //normal
"ic_24px_rating_good", //good
"ic_24px_rating_excellent" //exellent
]
}
theme.add(styleName: "RatingSummaryView12", from: "RatingSummaryView24") { (s) -> (Void) in
s.font = fonts.bold12
s.images = [
"ic_12px_rating_normal",
"ic_12px_rating_horrible",
"ic_12px_rating_bad",
"ic_12px_rating_normal",
"ic_12px_rating_good",
"ic_12px_rating_excellent"
]
}
theme.add(styleName: "RatingSummaryView12User", from: "RatingSummaryView12") { (s) -> (Void) in
s.colors?[0] = colors.linkBlue
s.images?[0] = "ic_12px_radio_on"
}
theme.add(styleName: "PPHeaderView") { (s) -> (Void) in
s.backgroundColor = colors.white
s.cornerRadius = 10
s.clip = true
}
theme.add(styleName: "PPNavigationShadowView") { (s) -> (Void) in
s.backgroundColor = colors.white
s.shadowColor = UIColor.black
s.shadowOffset = CGSize(width: 0, height: 1)
s.shadowOpacity = 0.4
s.shadowRadius = 1
s.clip = false
}
theme.add(styleName: "PPBackgroundView") { (s) -> (Void) in
s.backgroundColor = colors.pressBackground
s.cornerRadius = 10
s.shadowColor = UIColor.black
s.shadowOffset = CGSize(width: 0, height: 1)
s.shadowOpacity = 0.6
s.shadowRadius = 2
s.clip = false
}
theme.add(styleName: "PPView") { (s) -> (Void) in
s.backgroundColor = colors.clear
s.cornerRadius = 10
s.clip = true
}
theme.add(styleName: "PPHeaderCircleIcon") { (s) -> (Void) in
s.tintColor = colors.iconOpaqueGrayTint
s.backgroundColor = colors.iconOpaqueGrayBackground
}
theme.add(styleName: "ChartView") { (s) -> (Void) in
s.backgroundColor = colors.white
s.fontColor = colors.blackSecondaryText
s.font = fonts.regular12
s.gridColor = colors.blackDividers
s.previewSelectorColor = colors.elevationPreviewSelector
s.previewTintColor = colors.elevationPreviewTint
s.shadowOpacity = 0.25
s.shadowColor = colors.shadow
s.infoBackground = colors.pressBackground
extension PlacePageStyleSheet: IStyleSheet {
func styleResolverFor(colors: IColors, fonts: IFonts) -> Theme.StyleResolver {
switch self {
case .ppTitlePopularView:
return .add { s in
s.backgroundColor = colors.linkBlueHighlighted
s.cornerRadius = 10
}
case .ppActionBarTitle:
return .add { s in
s.font = fonts.regular10
s.fontColor = colors.blackSecondaryText
}
case .ppActionBarTitlePartner:
return .add { s in
s.font = fonts.regular10
s.fontColor = UIColor.white
}
case .ppElevationProfileDescriptionCell:
return .add { s in
s.backgroundColor = colors.blackOpaque
s.cornerRadius = 6
}
case .ppElevationProfileExtendedDifficulty:
return .add { s in
s.backgroundColor = colors.blackSecondaryText
s.fontColor = colors.white
s.font = fonts.medium14
s.textContainerInset = UIEdgeInsets(top: 4, left: 6, bottom: 4, right: 6)
}
case .ppRouteBasePreview:
return .add { s in
s.borderColor = colors.blackDividers
s.borderWidth = 1
s.backgroundColor = colors.white
}
case .ppRoutePreview:
return .add { s in
s.shadowRadius = 2
s.shadowColor = colors.blackDividers
s.shadowOpacity = 1
s.shadowOffset = CGSize(width: 3, height: 0)
s.backgroundColor = colors.pressBackground
}
case .ppRatingSummaryView24:
return .add { s in
s.font = fonts.bold16
s.fontColorHighlighted = colors.ratingYellow
s.fontColorDisabled = colors.blackDividers
s.colors = [
colors.blackSecondaryText,
colors.ratingRed,
colors.ratingOrange,
colors.ratingYellow,
colors.ratingLightGreen,
colors.ratingGreen
]
s.images = [
"ic_24px_rating_normal",
"ic_24px_rating_horrible",
"ic_24px_rating_bad",
"ic_24px_rating_normal",
"ic_24px_rating_good",
"ic_24px_rating_excellent"
]
}
case .ppRatingSummaryView12:
return .addFrom(Self.ppRatingSummaryView24) { s in
s.font = fonts.bold12
s.images = [
"ic_12px_rating_normal",
"ic_12px_rating_horrible",
"ic_12px_rating_bad",
"ic_12px_rating_normal",
"ic_12px_rating_good",
"ic_12px_rating_excellent"
]
}
case .ppRatingSummaryView12User:
return .addFrom(Self.ppRatingSummaryView12) { s in
s.colors?[0] = colors.linkBlue
s.images?[0] = "ic_12px_radio_on"
}
case .ppHeaderView:
return .add { s in
s.backgroundColor = colors.white
s.cornerRadius = 10
s.clip = true
}
case .ppNavigationShadowView:
return .add { s in
s.backgroundColor = colors.white
s.shadowColor = UIColor.black
s.shadowOffset = CGSize(width: 0, height: 1)
s.shadowOpacity = 0.4
s.shadowRadius = 1
s.clip = false
}
case .ppBackgroundView:
return .add { s in
s.backgroundColor = colors.pressBackground
s.cornerRadius = 10
s.shadowColor = UIColor.black
s.shadowOffset = CGSize(width: 0, height: 1)
s.shadowOpacity = 0.6
s.shadowRadius = 2
s.clip = false
}
case .ppView:
return .add { s in
s.backgroundColor = colors.clear
s.cornerRadius = 10
s.clip = true
}
case .ppHeaderCircleIcon:
return .add { s in
s.tintColor = colors.iconOpaqueGrayTint
s.backgroundColor = colors.iconOpaqueGrayBackground
}
case .ppChartView:
return .add { s in
s.backgroundColor = colors.white
s.fontColor = colors.blackSecondaryText
s.font = fonts.regular12
s.gridColor = colors.blackDividers
s.previewSelectorColor = colors.elevationPreviewSelector
s.previewTintColor = colors.elevationPreviewTint
s.shadowOpacity = 0.25
s.shadowColor = colors.shadow
s.infoBackground = colors.pressBackground
}
case .ppRatingView:
return .add { s in
s.backgroundColor = colors.blackOpaque
s.round = true
}
case .ppRatingHorrible:
return .add { s in
s.image = "ic_24px_rating_horrible"
s.tintColor = colors.ratingRed
}
case .ppRatingBad:
return .add { s in
s.image = "ic_24px_rating_bad"
s.tintColor = colors.ratingOrange
}
case .ppRatingNormal:
return .add { s in
s.image = "ic_24px_rating_normal"
s.tintColor = colors.ratingYellow
}
case .ppRatingGood:
return .add { s in
s.image = "ic_24px_rating_good"
s.tintColor = colors.ratingLightGreen
}
case .ppRatingExcellent:
return .add { s in
s.image = "ic_24px_rating_excellent"
s.tintColor = colors.ratingGreen
}
case .ppButton:
return .addFrom(GlobalStyleSheet.flatNormalTransButtonBig) { s in
s.borderColor = colors.linkBlue
s.borderWidth = 1
}
}
}
}

View file

@ -3,7 +3,7 @@ import Chart
extension ChartView {
override func applyTheme() {
if styleName.isEmpty {
styleName = "ChartView"
setStyle(.ppChartView)
}
for style in StyleManager.shared.getStyle(styleName) where !style.isEmpty && !style.hasExclusion(view: self) {
ChartViewRenderer.render(self, style: style)

View file

@ -2,7 +2,7 @@ import Foundation
extension Checkmark {
@objc override func applyTheme() {
if styleName.isEmpty {
styleName = "Checkmark"
setStyle(.checkmark)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {

View file

@ -3,7 +3,7 @@ import DatePicker
extension DatePickerView {
override func applyTheme() {
if styleName.isEmpty {
styleName = "DatePickerView"
setStyle(.datePickerView)
}
for style in StyleManager.shared.getStyle(styleName) where !style.isEmpty && !style.hasExclusion(view: self) {
DatePickerViewRenderer.render(self, style: style)

View file

@ -2,7 +2,7 @@ import Foundation
extension DifficultyView {
@objc override func applyTheme() {
if styleName.isEmpty {
styleName = "DifficultyView"
setStyle(.difficultyView)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {

View file

@ -2,7 +2,7 @@ import Foundation
extension MWMTableViewCell {
@objc override func applyTheme() {
if styleName.isEmpty {
styleName = "MWMTableViewCell"
setStyle(.tableViewCell)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {

View file

@ -1,7 +1,7 @@
extension TabView {
@objc override func applyTheme() {
if styleName.isEmpty {
styleName = "TabView"
setStyle(.tabView)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {

View file

@ -2,7 +2,7 @@
extension UINavigationBar {
@objc override func applyTheme() {
if styleName.isEmpty {
styleName = "NavigationBar"
setStyle(.navigationBar)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {

View file

@ -1,7 +1,7 @@
extension UINavigationItem {
@objc func applyTheme() {
if styleName.isEmpty {
styleName = "NavigationBarItem"
setStyle(.navigationBarItem)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty {

View file

@ -1,7 +1,7 @@
extension UIPageControl {
@objc override func applyTheme() {
if styleName.isEmpty {
styleName = "PageControl"
setStyle(.pageControl)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {

View file

@ -2,7 +2,7 @@ import Foundation
extension UISearchBar {
@objc override func applyTheme() {
if styleName.isEmpty {
styleName = "SearchBar"
setStyle(.searchBar)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {

View file

@ -1,7 +1,7 @@
extension UISwitch {
@objc override func applyTheme() {
if styleName.isEmpty {
styleName = "Switch"
setStyle(.switch)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {

View file

@ -1,7 +1,7 @@
extension UITableViewCell {
@objc override func applyTheme() {
if styleName.isEmpty {
styleName = "TableCell"
setStyle(.tableCell)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {

View file

@ -1,7 +1,7 @@
extension UITableViewHeaderFooterView {
@objc override func applyTheme() {
if styleName.isEmpty {
styleName = "TableViewHeaderFooterView"
setStyle(.tableViewHeaderFooterView)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {

View file

@ -1,7 +1,7 @@
extension UITableView {
@objc override func applyTheme() {
if styleName.isEmpty {
styleName = "TableView"
setStyle(.tabView)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {

View file

@ -1,7 +1,7 @@
extension ValueStepperView {
override func applyTheme() {
if styleName.isEmpty {
styleName = "ValueStepperView"
setStyle(.valueStepperView)
}
for style in StyleManager.shared.getStyle(styleName) where !style.isEmpty && !style.hasExclusion(view: self) {
ValueStepperViewRenderer.render(self, style: style)

View file

@ -1,108 +1,96 @@
class SearchStyleSheet: IStyleSheet {
static func register(theme: Theme, colors: IColors, fonts: IFonts) {
theme.add(styleName: "SearchInstallButton") { (s) -> Void in
s.cornerRadius = 10
s.clip = true
s.font = fonts.medium12
s.fontColor = colors.blackSecondaryText
s.backgroundColor = colors.searchPromoBackground
}
enum SearchStyleSheet: String, CaseIterable {
case searchInstallButton = "SearchInstallButton"
case searchBanner = "SearchBanner"
case searchClosedBackground = "SearchClosedBackground"
case searchPopularView = "SearchPopularView"
case searchSideAvailableMarker = "SearchSideAvaliableMarker"
case searchBarView = "SearchBarView"
case searchActionBarView = "SearchActionBarView"
case searchActionBarButton = "SearchActionBarButton"
case searchSearchTextField = "SearchSearchTextField"
case searchSearchTextFieldIcon = "SearchSearchTextFieldIcon"
case searchDatePickerField = "SearchDatePickerField"
case searchCellAvailable = "SearchCellAvaliable"
}
theme.add(styleName: "SearchBanner") { (s) -> Void in
s.backgroundColor = colors.searchPromoBackground
}
theme.add(styleName: "SearchClosedBackground") { (s) -> Void in
s.cornerRadius = 4
s.backgroundColor = colors.blackHintText
}
theme.add(styleName: "SearchPopularView") { (s) -> Void in
s.cornerRadius = 10
s.backgroundColor = colors.linkBlueHighlighted
}
theme.add(styleName: "SearchSideAvaliableMarker") { (s) -> Void in
s.backgroundColor = colors.ratingGreen
}
theme.add(styleName: "SearchBarView") { (s) -> Void in
s.backgroundColor = colors.primary
s.shadowRadius = 2
s.shadowColor = UIColor(0, 0, 0, alpha26)
s.shadowOpacity = 1
s.shadowOffset = CGSize.zero
}
theme.add(styleName: "SearchActionBarView") { (s) -> (Void) in
s.backgroundColor = colors.linkBlue
s.cornerRadius = 20
s.shadowRadius = 1
s.shadowColor = UIColor(0, 0, 0, 0.24)
s.shadowOffset = CGSize(width: 0, height: 2)
s.shadowOpacity = 1
}
theme.add(styleName: "SearchActionBarButton") { (s) -> (Void) in
s.backgroundColor = colors.clear
s.fontColor = colors.whitePrimaryText
s.font = fonts.semibold14
s.coloring = .whiteText
}
theme.add(styleName: "SearchSearchTextField") { (s) -> Void in
s.fontColor = colors.blackPrimaryText
s.backgroundColor = colors.white
s.tintColor = colors.blackSecondaryText
s.cornerRadius = 8.0
s.barTintColor = colors.primary
}
theme.add(styleName: "SearchSearchTextFieldIcon") { (s) -> Void in
s.tintColor = colors.blackSecondaryText
s.coloring = MWMButtonColoring.black
s.color = colors.blackSecondaryText
}
theme.add(styleName: "SearchDatePickerField") { (s) -> Void in
s.backgroundColor = colors.white
s.cornerRadius = 4
s.borderColor = colors.solidDividers
s.borderWidth = 1
}
theme.add(styleName: "SearchCellAvaliable", from: "TableCell") { (s) -> Void in
s.backgroundColor = colors.transparentGreen
}
theme.add(styleName: "DatePickerView") { (s) -> (Void) in
s.backgroundColor = colors.white
s.fontColor = colors.blackPrimaryText
s.fontColorSelected = colors.whitePrimaryText
s.backgroundColorSelected = colors.linkBlue
s.backgroundColorHighlighted = colors.linkBlueHighlighted
s.fontColorDisabled = colors.blackSecondaryText
}
theme.add(styleName: "BookingDateField") { (s) -> (Void) in
s.backgroundColor = colors.white
s.cornerRadius = 4
s.borderColor = colors.blackDividers
s.borderWidth = 1
}
theme.add(styleName: "BookingDatePickerCancel", from: "FlatNormalTransButton") { (s) -> (Void) in
s.font = fonts.regular16
}
theme.add(styleName: "BookingDatePickerDone", from: "FlatNormalTransButton") { (s) -> (Void) in
s.font = fonts.semibold16
}
theme.add(styleName: "ValueStepperView") { (s) -> (Void) in
s.font = fonts.regular16
s.fontColor = colors.blackPrimaryText
s.coloring = MWMButtonColoring.blue
extension SearchStyleSheet: IStyleSheet {
func styleResolverFor(colors: IColors, fonts: IFonts) -> Theme.StyleResolver {
switch self {
case .searchInstallButton:
return .add { s in
s.cornerRadius = 10
s.clip = true
s.font = fonts.medium12
s.fontColor = colors.blackSecondaryText
s.backgroundColor = colors.searchPromoBackground
}
case .searchBanner:
return .add { s in
s.backgroundColor = colors.searchPromoBackground
}
case .searchClosedBackground:
return .add { s in
s.cornerRadius = 4
s.backgroundColor = colors.blackHintText
}
case .searchPopularView:
return .add { s in
s.cornerRadius = 10
s.backgroundColor = colors.linkBlueHighlighted
}
case .searchSideAvailableMarker:
return .add { s in
s.backgroundColor = colors.ratingGreen
}
case .searchBarView:
return .add { s in
s.backgroundColor = colors.primary
s.shadowRadius = 2
s.shadowColor = UIColor(0, 0, 0, alpha26)
s.shadowOpacity = 1
s.shadowOffset = CGSize.zero
}
case .searchActionBarView:
return .add { s in
s.backgroundColor = colors.linkBlue
s.cornerRadius = 20
s.shadowRadius = 1
s.shadowColor = UIColor(0, 0, 0, 0.24)
s.shadowOffset = CGSize(width: 0, height: 2)
s.shadowOpacity = 1
}
case .searchActionBarButton:
return .add { s in
s.backgroundColor = colors.clear
s.fontColor = colors.whitePrimaryText
s.font = fonts.semibold14
s.coloring = .whiteText
}
case .searchSearchTextField:
return .add { s in
s.fontColor = colors.blackPrimaryText
s.backgroundColor = colors.white
s.tintColor = colors.blackSecondaryText
s.cornerRadius = 8.0
s.barTintColor = colors.primary
}
case .searchSearchTextFieldIcon:
return .add { s in
s.tintColor = colors.blackSecondaryText
s.coloring = MWMButtonColoring.black
s.color = colors.blackSecondaryText
}
case .searchDatePickerField:
return .add { s in
s.backgroundColor = colors.white
s.cornerRadius = 4
s.borderColor = colors.solidDividers
s.borderWidth = 1
}
case .searchCellAvailable:
return .addFrom(GlobalStyleSheet.tableCell) { s in
s.backgroundColor = colors.transparentGreen
}
}
}
}

View file

@ -0,0 +1,54 @@
protocol StyleApplicable: AnyObject {
var styleName: String { get set }
var isStyleApplied: Bool { get set }
func setStyleName(_ styleName: String)
func setStyleNameAndApply(_ styleName: String)
func setStyle(_ style: StyleStringRepresentable)
func setStyleAndApply(_ style: StyleStringRepresentable)
func applyTheme()
}
extension StyleApplicable {
func setStyleName(_ styleName: String) {
self.styleName = styleName
}
func setStyleNameAndApply(_ styleName: String) {
self.styleName = styleName
applyTheme()
}
func setStyle(_ style: StyleStringRepresentable) {
styleName = style.rawValue
}
func setStyleAndApply(_ style: StyleStringRepresentable) {
styleName = style.rawValue
applyTheme()
}
}
// Overload for the direct usage of the nested StyleSheet enums
extension StyleApplicable {
func setStyle(_ style: GlobalStyleSheet) { setStyle(style) }
func setStyle(_ style: PlacePageStyleSheet) { setStyle(style) }
func setStyle(_ style: MapStyleSheet) { setStyle(style) }
func setStyle(_ style: BookmarksStyleSheet) { setStyle(style) }
func setStyle(_ style: SearchStyleSheet) { setStyle(style) }
func setStyleAndApply(_ style: GlobalStyleSheet) { setStyleAndApply(style) }
func setStyleAndApply(_ style: PlacePageStyleSheet) { setStyleAndApply(style) }
func setStyleAndApply(_ style: MapStyleSheet) { setStyleAndApply(style) }
func setStyleAndApply(_ style: BookmarksStyleSheet) { setStyleAndApply(style) }
func setStyleAndApply(_ style: SearchStyleSheet) { setStyleAndApply(style) }
func setStyles(_ styles: [GlobalStyleSheet]) { styleName = styles.joinedStyle }
}
private extension Collection where Element: RawRepresentable, Element.RawValue == String {
var joinedStyle: String {
map(\.rawValue).joined(separator: ":")
}
}

View file

@ -0,0 +1,27 @@
protocol StyleStringRepresentable {
var rawValue: String { get }
func styleResolverFor(colors: IColors, fonts: IFonts) -> Theme.StyleResolver
}
extension Theme {
enum StyleResolver {
case add(_ resolver: Theme.Resolver)
case addFrom(_ from: StyleStringRepresentable, _ resolver: Theme.Resolver)
case addFromType(_ forType: ThemeType, _ resolver: Theme.Resolver)
case addFromForType(_ from: StyleStringRepresentable, _ forType: ThemeType, _ resolver: Theme.Resolver)
}
func add(_ style: StyleStringRepresentable, _ resolvingType: StyleResolver) {
switch resolvingType {
case .add(let resolver):
add(styleName: style.rawValue, resolver)
case .addFrom(let from, let resolver):
add(styleName: style.rawValue, from: from.rawValue, resolver)
case .addFromType(let forType, let resolver):
add(styleName: style.rawValue, forType: forType, resolver)
case .addFromForType(let from, let forType, let resolver):
add(styleName: style.rawValue, from: from.rawValue, forType: forType, resolver)
}
}
}

View file

@ -0,0 +1,32 @@
enum TextColorStyleSheet: String, CaseIterable {
case whitePrimary = "whitePrimaryText"
case blackSecondary = "blackSecondaryText"
case blackPrimary = "blackPrimaryText"
case linkBlue = "linkBlueText"
case linkBlueHighlighted = "linkBlueHighlightedText"
case white = "whiteText"
case blackHint = "blackHintText"
case green = "greenText"
case red = "redText"
case buttonRed = "buttonRedText"
}
extension TextColorStyleSheet: IStyleSheet {
func styleResolverFor(colors: IColors, fonts: IFonts) -> Theme.StyleResolver {
let color: UIColor = {
switch self {
case .whitePrimary: return colors.whitePrimaryText
case .blackSecondary: return colors.blackSecondaryText
case .blackPrimary: return colors.blackPrimaryText
case .linkBlue: return colors.linkBlue
case .linkBlueHighlighted: return colors.linkBlueHighlighted
case .white: return colors.white
case .blackHint: return colors.blackHintText
case .green: return colors.ratingGreen
case .red: return colors.red
case .buttonRed: return colors.buttonRed
}
}()
return .add { $0.fontColor = color }
}
}

View file

@ -178,7 +178,6 @@
34F742321E0834F400AC1FD6 /* UIViewController+Navigation.m in Sources */ = {isa = PBXBuildFile; fileRef = 34F742301E0834F400AC1FD6 /* UIViewController+Navigation.m */; };
34FE5A6F1F18F30F00BCA729 /* TrafficButtonArea.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34FE5A6D1F18F30F00BCA729 /* TrafficButtonArea.swift */; };
3D15ACEE2155117000F725D5 /* MWMObjectsCategorySelectorDataSource.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3D15ACED2155117000F725D5 /* MWMObjectsCategorySelectorDataSource.mm */; };
3DBD7BE42425015C00ED9FE8 /* ParntersStyleSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DBD7BE32425015C00ED9FE8 /* ParntersStyleSheet.swift */; };
3DEE1AEB21F72CD300054A91 /* MWMPowerManagmentViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3DEE1AEA21F72CD300054A91 /* MWMPowerManagmentViewController.mm */; };
408645FC21495EB1000A4A1D /* categories_cuisines.txt in Resources */ = {isa = PBXBuildFile; fileRef = 408645FB21495EB1000A4A1D /* categories_cuisines.txt */; };
44360A0D2A7D34990016F412 /* TransportRuler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44360A0C2A7D34990016F412 /* TransportRuler.swift */; };
@ -347,8 +346,8 @@
993DF0CC23F6BD0600AC231A /* ElevationDetailsPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 993DF0C723F6BD0600AC231A /* ElevationDetailsPresenter.swift */; };
993DF10223F6BDB100AC231A /* Colors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 993DF0CD23F6BDB000AC231A /* Colors.swift */; };
993DF10323F6BDB100AC231A /* MainTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 993DF0CE23F6BDB000AC231A /* MainTheme.swift */; };
993DF10423F6BDB100AC231A /* UIView+styleName.swift in Sources */ = {isa = PBXBuildFile; fileRef = 993DF0D023F6BDB000AC231A /* UIView+styleName.swift */; };
993DF10523F6BDB100AC231A /* UINavigationItem+styleName.swift in Sources */ = {isa = PBXBuildFile; fileRef = 993DF0D123F6BDB000AC231A /* UINavigationItem+styleName.swift */; };
993DF10423F6BDB100AC231A /* UIView+SetStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 993DF0D023F6BDB000AC231A /* UIView+SetStyle.swift */; };
993DF10523F6BDB100AC231A /* UINavigationItem+StyleStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 993DF0D123F6BDB000AC231A /* UINavigationItem+StyleStyle.swift */; };
993DF10623F6BDB100AC231A /* UIColor+rgba.swift in Sources */ = {isa = PBXBuildFile; fileRef = 993DF0D223F6BDB000AC231A /* UIColor+rgba.swift */; };
993DF10723F6BDB100AC231A /* UIColor+image.swift in Sources */ = {isa = PBXBuildFile; fileRef = 993DF0D323F6BDB000AC231A /* UIColor+image.swift */; };
993DF10823F6BDB100AC231A /* IColors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 993DF0D523F6BDB000AC231A /* IColors.swift */; };
@ -410,7 +409,6 @@
998927402449ECC200260CE2 /* BottomMenuItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9989273F2449ECC200260CE2 /* BottomMenuItemCell.swift */; };
999FC12023ABA9AD00B0E6F9 /* SearchStyleSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 999FC11F23ABA9AD00B0E6F9 /* SearchStyleSheet.swift */; };
999FC12B23ABB4B800B0E6F9 /* FontStyleSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 999FC12A23ABB4B800B0E6F9 /* FontStyleSheet.swift */; };
99A614D523C8911A00D8D8D0 /* AuthStyleSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99A614D423C8911A00D8D8D0 /* AuthStyleSheet.swift */; };
99A614E423CDD1D900D8D8D0 /* UIButton+RuntimeAttributes.m in Sources */ = {isa = PBXBuildFile; fileRef = 99A614E323CDD1D900D8D8D0 /* UIButton+RuntimeAttributes.m */; };
99A906DE23F6F7030005872B /* PlacePageEditBookmarkOrTrackViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99A906CD23F6F7010005872B /* PlacePageEditBookmarkOrTrackViewController.swift */; };
99A906E123F6F7030005872B /* PlacePageButtonsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99A906D023F6F7020005872B /* PlacePageButtonsViewController.swift */; };
@ -509,6 +507,9 @@
ED7CCC4F2C1362E300E2A737 /* FileType.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED7CCC4E2C1362E300E2A737 /* FileType.swift */; };
ED808D0F2C38407800D52585 /* CircleImageButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED808D0E2C38407800D52585 /* CircleImageButton.swift */; };
ED8270F02C2071A3005966DA /* SettingsTableViewDetailedSwitchCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED8270EF2C2071A3005966DA /* SettingsTableViewDetailedSwitchCell.swift */; };
ED914AB22D35063A00973C45 /* TextColorStyleSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED914AB12D35063A00973C45 /* TextColorStyleSheet.swift */; };
ED914AB82D351DF000973C45 /* StyleApplicable.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED914AB72D351DF000973C45 /* StyleApplicable.swift */; };
ED914ABE2D351FF800973C45 /* UILabel+SetFontStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED914ABD2D351FF800973C45 /* UILabel+SetFontStyle.swift */; };
ED9857082C4ED02D00694F6C /* MailComposer.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED9857072C4ED02D00694F6C /* MailComposer.swift */; };
ED9966802B94FBC20083CE55 /* ColorPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED99667D2B94FBC20083CE55 /* ColorPicker.swift */; };
EDA1EAA42CC7ECAD00DBDCAA /* ElevationProfileFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDA1EAA32CC7ECAD00DBDCAA /* ElevationProfileFormatter.swift */; };
@ -520,6 +521,7 @@
EDC4E34D2C5D1BEF009286A2 /* RecentlyDeletedTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDC4E3492C5D1BEF009286A2 /* RecentlyDeletedTableViewCell.swift */; };
EDC4E3612C5E2576009286A2 /* RecentlyDeletedCategoriesViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDC4E3412C5D1BD3009286A2 /* RecentlyDeletedCategoriesViewModelTests.swift */; };
EDC4E3692C5E6F5B009286A2 /* MockRecentlyDeletedCategoriesManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDC4E3402C5D1BD3009286A2 /* MockRecentlyDeletedCategoriesManager.swift */; };
EDCA7CDF2D317DF9003366CE /* StyleSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDCA7CDE2D317DF9003366CE /* StyleSheet.swift */; };
EDE243DD2B6D2E640057369B /* AboutController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDE243D52B6CF3980057369B /* AboutController.swift */; };
EDE243E52B6D3F400057369B /* OSMView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDE243E42B6D3F400057369B /* OSMView.swift */; };
EDE243E72B6D55610057369B /* InfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDE243E02B6D3EA00057369B /* InfoView.swift */; };
@ -1120,7 +1122,6 @@
34FE5A6D1F18F30F00BCA729 /* TrafficButtonArea.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrafficButtonArea.swift; sourceTree = "<group>"; };
3D15ACED2155117000F725D5 /* MWMObjectsCategorySelectorDataSource.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMObjectsCategorySelectorDataSource.mm; sourceTree = "<group>"; };
3D15ACEF2155118800F725D5 /* MWMObjectsCategorySelectorDataSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMObjectsCategorySelectorDataSource.h; sourceTree = "<group>"; };
3DBD7BE32425015C00ED9FE8 /* ParntersStyleSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParntersStyleSheet.swift; sourceTree = "<group>"; };
3DEE1AE921F72CD300054A91 /* MWMPowerManagmentViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMPowerManagmentViewController.h; sourceTree = "<group>"; };
3DEE1AEA21F72CD300054A91 /* MWMPowerManagmentViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMPowerManagmentViewController.mm; sourceTree = "<group>"; };
408645FB21495EB1000A4A1D /* categories_cuisines.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = categories_cuisines.txt; path = ../../data/categories_cuisines.txt; sourceTree = "<group>"; };
@ -1265,8 +1266,8 @@
993DF0C723F6BD0600AC231A /* ElevationDetailsPresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ElevationDetailsPresenter.swift; sourceTree = "<group>"; };
993DF0CD23F6BDB000AC231A /* Colors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Colors.swift; sourceTree = "<group>"; };
993DF0CE23F6BDB000AC231A /* MainTheme.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainTheme.swift; sourceTree = "<group>"; };
993DF0D023F6BDB000AC231A /* UIView+styleName.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+styleName.swift"; sourceTree = "<group>"; };
993DF0D123F6BDB000AC231A /* UINavigationItem+styleName.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UINavigationItem+styleName.swift"; sourceTree = "<group>"; };
993DF0D023F6BDB000AC231A /* UIView+SetStyle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+SetStyle.swift"; sourceTree = "<group>"; };
993DF0D123F6BDB000AC231A /* UINavigationItem+StyleStyle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UINavigationItem+StyleStyle.swift"; sourceTree = "<group>"; };
993DF0D223F6BDB000AC231A /* UIColor+rgba.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIColor+rgba.swift"; sourceTree = "<group>"; };
993DF0D323F6BDB000AC231A /* UIColor+image.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIColor+image.swift"; sourceTree = "<group>"; };
993DF0D523F6BDB000AC231A /* IColors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IColors.swift; sourceTree = "<group>"; };
@ -1332,7 +1333,6 @@
9989273F2449ECC200260CE2 /* BottomMenuItemCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottomMenuItemCell.swift; sourceTree = "<group>"; };
999FC11F23ABA9AD00B0E6F9 /* SearchStyleSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchStyleSheet.swift; sourceTree = "<group>"; };
999FC12A23ABB4B800B0E6F9 /* FontStyleSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontStyleSheet.swift; sourceTree = "<group>"; };
99A614D423C8911A00D8D8D0 /* AuthStyleSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthStyleSheet.swift; sourceTree = "<group>"; };
99A614E223CDD1D900D8D8D0 /* UIButton+RuntimeAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIButton+RuntimeAttributes.h"; sourceTree = "<group>"; };
99A614E323CDD1D900D8D8D0 /* UIButton+RuntimeAttributes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIButton+RuntimeAttributes.m"; sourceTree = "<group>"; };
99A906CD23F6F7010005872B /* PlacePageEditBookmarkOrTrackViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlacePageEditBookmarkOrTrackViewController.swift; sourceTree = "<group>"; };
@ -1471,6 +1471,9 @@
ED7CCC4E2C1362E300E2A737 /* FileType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileType.swift; sourceTree = "<group>"; };
ED808D0E2C38407800D52585 /* CircleImageButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleImageButton.swift; sourceTree = "<group>"; };
ED8270EF2C2071A3005966DA /* SettingsTableViewDetailedSwitchCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsTableViewDetailedSwitchCell.swift; sourceTree = "<group>"; };
ED914AB12D35063A00973C45 /* TextColorStyleSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextColorStyleSheet.swift; sourceTree = "<group>"; };
ED914AB72D351DF000973C45 /* StyleApplicable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StyleApplicable.swift; sourceTree = "<group>"; };
ED914ABD2D351FF800973C45 /* UILabel+SetFontStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UILabel+SetFontStyle.swift"; sourceTree = "<group>"; };
ED9857072C4ED02D00694F6C /* MailComposer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MailComposer.swift; sourceTree = "<group>"; };
ED99667D2B94FBC20083CE55 /* ColorPicker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColorPicker.swift; sourceTree = "<group>"; };
EDA1EAA32CC7ECAD00DBDCAA /* ElevationProfileFormatter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ElevationProfileFormatter.swift; sourceTree = "<group>"; };
@ -1482,6 +1485,7 @@
EDC4E3472C5D1BEF009286A2 /* RecentlyDeletedCategoriesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecentlyDeletedCategoriesViewController.swift; sourceTree = "<group>"; };
EDC4E3482C5D1BEF009286A2 /* RecentlyDeletedCategoriesViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecentlyDeletedCategoriesViewModel.swift; sourceTree = "<group>"; };
EDC4E3492C5D1BEF009286A2 /* RecentlyDeletedTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecentlyDeletedTableViewCell.swift; sourceTree = "<group>"; };
EDCA7CDE2D317DF9003366CE /* StyleSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StyleSheet.swift; sourceTree = "<group>"; };
EDE243D52B6CF3980057369B /* AboutController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutController.swift; sourceTree = "<group>"; };
EDE243E02B6D3EA00057369B /* InfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoView.swift; sourceTree = "<group>"; };
EDE243E42B6D3F400057369B /* OSMView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSMView.swift; sourceTree = "<group>"; };
@ -2836,8 +2840,9 @@
993DF0CF23F6BDB000AC231A /* Extensions */ = {
isa = PBXGroup;
children = (
993DF0D023F6BDB000AC231A /* UIView+styleName.swift */,
993DF0D123F6BDB000AC231A /* UINavigationItem+styleName.swift */,
993DF0D023F6BDB000AC231A /* UIView+SetStyle.swift */,
ED914ABD2D351FF800973C45 /* UILabel+SetFontStyle.swift */,
993DF0D123F6BDB000AC231A /* UINavigationItem+StyleStyle.swift */,
993DF0D223F6BDB000AC231A /* UIColor+rgba.swift */,
AC79C8912A65AB9500594C24 /* UIColor+hexString.swift */,
993DF0D323F6BDB000AC231A /* UIColor+image.swift */,
@ -2941,14 +2946,15 @@
993DF0CD23F6BDB000AC231A /* Colors.swift */,
993DF0FA23F6BDB100AC231A /* Fonts.swift */,
993DF0CE23F6BDB000AC231A /* MainTheme.swift */,
ED914AB72D351DF000973C45 /* StyleApplicable.swift */,
EDCA7CDE2D317DF9003366CE /* StyleSheet.swift */,
993DF10123F6BDB100AC231A /* GlobalStyleSheet.swift */,
99A906F223FA95AB0005872B /* PlacePageStyleSheet.swift */,
99F8B4C523B644A6009FF0B4 /* MapStyleSheet.swift */,
991FCA2323B11E61009AD684 /* BookmarksStyleSheet.swift */,
999FC11F23ABA9AD00B0E6F9 /* SearchStyleSheet.swift */,
999FC12A23ABB4B800B0E6F9 /* FontStyleSheet.swift */,
99A614D423C8911A00D8D8D0 /* AuthStyleSheet.swift */,
3DBD7BE32425015C00ED9FE8 /* ParntersStyleSheet.swift */,
ED914AB12D35063A00973C45 /* TextColorStyleSheet.swift */,
);
path = Theme;
sourceTree = "<group>";
@ -4398,6 +4404,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
ED914ABE2D351FF800973C45 /* UILabel+SetFontStyle.swift in Sources */,
34845DB71E166084003D55B9 /* Common.swift in Sources */,
47F4F21323A6EC420022FD56 /* DownloadMapsViewController.swift in Sources */,
99A906F623FA9C010005872B /* InsetsLabelRenderer.swift in Sources */,
@ -4499,7 +4506,6 @@
F653CE191C71F62700A453F1 /* MWMAddPlaceNavigationBar.mm in Sources */,
340475621E081A4600C92850 /* MWMNetworkPolicy+UI.m in Sources */,
F6E2FEE51E097BA00083EBEC /* MWMSearchNoResults.m in Sources */,
3DBD7BE42425015C00ED9FE8 /* ParntersStyleSheet.swift in Sources */,
F6E2FF631E097BA00083EBEC /* MWMTTSLanguageViewController.mm in Sources */,
4715273524907F8200E91BBA /* BookmarkColorViewController.swift in Sources */,
47E3C7292111E614008B3B27 /* FadeInAnimatedTransitioning.swift in Sources */,
@ -4540,7 +4546,7 @@
993DF12A23F6BDB100AC231A /* Style.swift in Sources */,
34ABA6171C2D185C00FE1BEC /* MWMAuthorizationOSMLoginViewController.mm in Sources */,
ED9966802B94FBC20083CE55 /* ColorPicker.swift in Sources */,
993DF10423F6BDB100AC231A /* UIView+styleName.swift in Sources */,
993DF10423F6BDB100AC231A /* UIView+SetStyle.swift in Sources */,
998927302449DE1500260CE2 /* TabBarArea.swift in Sources */,
995739042355CAA30019AEE7 /* PageIndicator.swift in Sources */,
470F0B7D238842EA006AEC94 /* ExpandableLabel.swift in Sources */,
@ -4559,7 +4565,6 @@
F6FE3C391CC50FFD00A73196 /* MWMPlaceDoesntExistAlert.m in Sources */,
F6E2FDFE1E097BA00083EBEC /* MWMOpeningHoursClosedSpanTableViewCell.mm in Sources */,
34B846A12029DCC10081ECCD /* BMCCategoriesHeader.swift in Sources */,
99A614D523C8911A00D8D8D0 /* AuthStyleSheet.swift in Sources */,
99A906F123FA946E0005872B /* DifficultyViewRenderer.swift in Sources */,
F6E2FD5F1E097BA00083EBEC /* MWMMapDownloaderLargeCountryTableViewCell.m in Sources */,
49AB95982CB2FE5300468EA2 /* UIButton+ImagePadding.swift in Sources */,
@ -4691,6 +4696,7 @@
9917D17F2397B1D600A7E06E /* IPadModalPresentationController.swift in Sources */,
3444DFCD1F1760B900E73099 /* WidgetsArea.swift in Sources */,
34D3B03C1E389D05004100F9 /* MWMEditorSwitchTableViewCell.m in Sources */,
EDCA7CDF2D317DF9003366CE /* StyleSheet.swift in Sources */,
34AB66411FC5AA330078E451 /* RouteManagerTransitioningManager.swift in Sources */,
EDA1EAA42CC7ECAD00DBDCAA /* ElevationProfileFormatter.swift in Sources */,
996D108A24E3DBF2002DD0E2 /* BookmarksCoordinator.swift in Sources */,
@ -4723,6 +4729,7 @@
F626D52F1C3E83F800C17D15 /* MWMTableViewCell.m in Sources */,
34AB66591FC5AA330078E451 /* TransportTransitFlowLayout.swift in Sources */,
EDBD680B2B62572E005DD151 /* LocationServicesDisabledAlert.swift in Sources */,
ED914AB82D351DF000973C45 /* StyleApplicable.swift in Sources */,
3486B5191E27AD3B0069C126 /* MWMFrameworkListener.mm in Sources */,
3404756B1E081A4600C92850 /* MWMSearch+CoreSpotlight.mm in Sources */,
CD9AD96C2281B56900EC174A /* CPViewPortState.swift in Sources */,
@ -4774,6 +4781,7 @@
99012851244732DB00C72B10 /* BottomTabBarViewController.swift in Sources */,
993DF10623F6BDB100AC231A /* UIColor+rgba.swift in Sources */,
EDC3573B2B7B5029001AE9CA /* CALayer+SetCorner.swift in Sources */,
ED914AB22D35063A00973C45 /* TextColorStyleSheet.swift in Sources */,
47E3C7332111F4D8008B3B27 /* CoverVerticalDismissalAnimator.swift in Sources */,
471AB99423ABA3BD00F56D49 /* SearchMapsDataSource.swift in Sources */,
47CA68F1250B54AF00671019 /* BookmarksListCell.swift in Sources */,
@ -4785,7 +4793,7 @@
3454D7CB1E07F045004AF2AD /* UIColor+MapsMeColor.m in Sources */,
34B127EA1FBDD410008713D9 /* MWMRouterTransitStepInfo.mm in Sources */,
34D3B02A1E389D05004100F9 /* MWMEditorAdditionalNameTableViewCell.m in Sources */,
993DF10523F6BDB100AC231A /* UINavigationItem+styleName.swift in Sources */,
993DF10523F6BDB100AC231A /* UINavigationItem+StyleStyle.swift in Sources */,
9977E69C247BFB510073780C /* SearchTextField.swift in Sources */,
4726254921C27D4B00C7BAAD /* PlacePageDescriptionViewController.swift in Sources */,
039371B62C5B68CD00708377 /* UIFont+monospaced.swift in Sources */,

View file

@ -12,7 +12,7 @@ class BottomMenuViewController: MWMViewController {
lazy var chromeView: UIView = {
let view = UIView()
view.styleName = "PresentationBackground"
view.setStyle(.presentationBackground)
return view
}()

View file

@ -29,7 +29,7 @@ class BottomMenuItemCell: UITableViewCell {
badgeBackgroundWidthConstraint.constant = 32
}
isEnabled = enabled
icon.setStyleAndApply(isEnabled ? "MWMBlack" : "MWMGray")
label.setStyleAndApply(isEnabled ? "blackPrimaryText" : "blackHintText")
icon.setStyleAndApply(isEnabled ? .black : .gray)
label.setFontStyleAndApply(isEnabled ? .blackPrimary : .blackHint)
}
}

View file

@ -24,7 +24,7 @@ final class BottomMenuLayerButton: VerticallyAlignedButton {
} else {
if badgeView == nil {
badgeView = UIView()
badgeView?.styleName = "Badge"
badgeView?.setStyle(.badge)
addSubview(badgeView!)
}
let imageFrame = imageView.frame

View file

@ -37,17 +37,17 @@ class BottomMenuLayersCell: UITableViewCell {
private func updateSubwayButton() {
let enabled = MapOverlayManager.transitEnabled()
subwayButton.setStyleAndApply(enabled ? "MenuButtonEnabled" : "MenuButtonDisabled")
subwayButton.setStyleAndApply(styleFor(enabled))
}
private func updateIsoLinesButton() {
let enabled = MapOverlayManager.isoLinesEnabled()
isoLinesButton.setStyleAndApply(enabled ? "MenuButtonEnabled" : "MenuButtonDisabled")
isoLinesButton.setStyleAndApply(styleFor(enabled))
}
private func updateOutdoorButton() {
let enabled = MapOverlayManager.outdoorEnabled()
outdoorButton.setStyleAndApply(enabled ? "MenuButtonEnabled" : "MenuButtonDisabled")
outdoorButton.setStyleAndApply(styleFor(enabled))
}
@IBAction func onCloseButtonPressed(_ sender: Any) {
@ -83,3 +83,9 @@ extension BottomMenuLayersCell: MapOverlayManagerObserver {
updateOutdoorButton()
}
}
private extension BottomMenuLayersCell {
func styleFor(_ enabled: Bool) -> MapStyleSheet {
enabled ? .mapMenuButtonEnabled : .mapMenuButtonDisabled
}
}

View file

@ -3,7 +3,7 @@ import UIKit
class BottomTabBarButton: MWMButton {
@objc override func applyTheme() {
if styleName.isEmpty {
styleName = "BottomTabBarButton"
setStyle(.bottomTabBarButton)
}
for style in StyleManager.shared.getStyle(styleName) where !style.isEmpty && !style.hasExclusion(view: self) {

View file

@ -8,7 +8,7 @@
self = [super initWithFrame:frame];
if (self)
{
[self setStyleAndApply:@"regular12:blackSecondaryText"];
[self setStyleNameAndApply:@"regular12:blackSecondaryText"];
}
return self;
}

View file

@ -100,7 +100,7 @@ class DownloadAllView: UIView {
case .error:
iconImageView.image = UIImage(named: "ic_download_error")
title.text = errorTitle
title.setStyleAndApply("redText")
title.setFontStyleAndApply(.red)
downloadButton.setTitle(errorButtonTitle, for: .normal)
downloadButton.isHidden = false
stateWrapper.isHidden = true
@ -108,7 +108,7 @@ class DownloadAllView: UIView {
downloadSizeLabel.isHidden = false
case .ready:
title.text = readyTitle
title.setStyleAndApply("blackPrimaryText")
title.setFontStyleAndApply(.blackPrimary)
downloadButton.setTitle(readyButtonTitle, for: .normal)
downloadButton.isHidden = false
stateWrapper.isHidden = true
@ -116,7 +116,7 @@ class DownloadAllView: UIView {
downloadSizeLabel.isHidden = false
case .dowloading:
title.text = downloadingTitle
title.setStyleAndApply("blackPrimaryText")
title.setFontStyleAndApply(.blackPrimary)
downloadButton.isHidden = true
stateWrapper.isHidden = false
progress.state = .spinner

View file

@ -125,8 +125,8 @@ final class EditBookmarkViewController: MWMTableViewController {
let cell = tableView.dequeueDefaultCell(for: indexPath)
cell.textLabel?.text = bookmarkGroupTitle
cell.imageView?.image = UIImage(named: "ic_folder")
cell.imageView?.styleName = "MWMBlack";
cell.accessoryType = .disclosureIndicator;
cell.imageView?.setStyle(.black)
cell.accessoryType = .disclosureIndicator
return cell;
default:
fatalError()

View file

@ -104,8 +104,8 @@ final class EditTrackViewController: MWMTableViewController {
let cell = tableView.dequeueDefaultCell(for: indexPath)
cell.textLabel?.text = trackGroupTitle
cell.imageView?.image = UIImage(named: "ic_folder")
cell.imageView?.styleName = "MWMBlack";
cell.accessoryType = .disclosureIndicator;
cell.imageView?.setStyle(.black)
cell.accessoryType = .disclosureIndicator
return cell;
default:
fatalError()

View file

@ -45,12 +45,12 @@ static CGFloat const kErrorLabelHeight = 16;
if (self.isValid)
{
self.errorLabelHeight.constant = 0;
[self.contentView setStyleAndApply: @"Background"];
[self.contentView setStyleNameAndApply: @"Background"];
}
else
{
self.errorLabelHeight.constant = kErrorLabelHeight;
[self.contentView setStyleAndApply: @"ErrorBackground"];
[self.contentView setStyleNameAndApply: @"ErrorBackground"];
}
[self layoutIfNeeded];
}

View file

@ -28,12 +28,12 @@
if (text && text.length != 0)
{
self.label.text = text;
[self.label setStyleAndApply: @"blackPrimaryText"];
[self.label setStyleNameAndApply: @"blackPrimaryText"];
}
else
{
self.label.text = placeholder;
[self.label setStyleAndApply: @"blackHintText"];
[self.label setStyleNameAndApply: @"blackHintText"];
}
self.label.preferredMaxLayoutWidth =
self.width - self.labelLeadingOffset.constant - self.labelTrailingOffset.constant;

View file

@ -49,7 +49,7 @@ static CGFloat const kErrorLabelDefaultTopSpace = 4.;
{
self.delegate = delegate;
self.icon.image = icon;
[self.icon setStyleAndApply: @"MWMBlack"];
[self.icon setStyleNameAndApply: @"MWMBlack"];
self.icon.hidden = (icon == nil);
self.textField.text = text;
@ -70,13 +70,13 @@ static CGFloat const kErrorLabelDefaultTopSpace = 4.;
{
self.labelHeight.priority = UILayoutPriorityDefaultHigh;
self.errorLabelTopSpace.constant = 0.;
[self.contentView setStyleAndApply: @"Background"];
[self.contentView setStyleNameAndApply: @"Background"];
}
else
{
self.labelHeight.priority = UILayoutPriorityDefaultLow;
self.errorLabelTopSpace.constant = kErrorLabelDefaultTopSpace;
[self.contentView setStyleAndApply: @"ErrorBackground"];
[self.contentView setStyleNameAndApply: @"ErrorBackground"];
}
[self layoutIfNeeded];
}

View file

@ -73,7 +73,7 @@ using namespace osmoh;
if (image.tag == tag)
{
image.image = [UIImage imageNamed:selected ? @"radioBtnOn" : @"radioBtnOff"];
[image setStyleAndApply: selected ? @"MWMBlue" : @"MWMGray"];
[image setStyleNameAndApply: selected ? @"MWMBlue" : @"MWMGray"];
}
}
}

View file

@ -109,7 +109,7 @@ private extension AboutController {
}
func setupHeaderTitle() {
headerTitleLabel.setStyleAndApply("semibold18:blackPrimaryText")
headerTitleLabel.setFontStyle(.semibold18, color: .blackPrimary)
headerTitleLabel.text = L("about_headline")
headerTitleLabel.textAlignment = .center
headerTitleLabel.numberOfLines = 1
@ -140,7 +140,7 @@ private extension AboutController {
}
func setupInfoTable() {
infoTableView.setStyleAndApply("ClearBackground")
infoTableView.setStyle(.clearBackground)
infoTableView.delegate = self
infoTableView.dataSource = self
infoTableView.separatorStyle = .none
@ -151,7 +151,7 @@ private extension AboutController {
}
func setupSocialMediaCollection() {
socialMediaHeaderLabel.setStyleAndApply("regular16:blackPrimaryText")
socialMediaHeaderLabel.setFontStyle(.regular16, color: .blackPrimary)
socialMediaHeaderLabel.text = L("follow_us")
socialMediaHeaderLabel.numberOfLines = 1
socialMediaHeaderLabel.allowsDefaultTighteningForTruncation = true
@ -177,8 +177,8 @@ private extension AboutController {
})
}
view.setStyleAndApply("PressBackground")
view.setStyle(.pressBackground)
setupTitle()
setupScrollAndStack()
setupLogo()
@ -438,7 +438,7 @@ private extension UIStackView {
func addArrangedSubviewWithSeparator(_ view: UIView) {
if !arrangedSubviews.isEmpty {
let separator = UIView()
separator.setStyleAndApply("Divider")
separator.setStyleAndApply(.divider)
separator.isUserInteractionEnabled = false
separator.translatesAutoresizingMaskIntoConstraints = false
addArrangedSubview(separator)

View file

@ -46,7 +46,7 @@ final class ButtonsStackView: UIView {
// MARK: - Public
func addButton(title: String, font: UIFont = .regular14(), didTapHandler: @escaping () -> Void) {
let button = UIButton()
button.setStyleAndApply("FlatPrimaryTransButton")
button.setStyleAndApply(.flatPrimaryTransButton)
button.setTitle(title, for: .normal)
button.titleLabel?.font = font
button.addTarget(self, action: #selector(buttonTapped(_:)), for: .touchUpInside)

View file

@ -20,13 +20,13 @@ final class DonationView: UIView {
}
private func setupViews() {
donateTextLabel.styleName = "regular14:blackPrimaryText"
donateTextLabel.setFontStyle(.regular14, color: .blackPrimary)
donateTextLabel.text = L("donate_description")
donateTextLabel.textAlignment = .center
donateTextLabel.lineBreakMode = .byWordWrapping
donateTextLabel.numberOfLines = 0
donateButton.styleName = "FlatNormalButton"
donateButton.setStyle(.flatNormalButton)
donateButton.setTitle(L("donate").localizedUppercase, for: .normal)
donateButton.addTarget(self, action: #selector(donateButtonDidTap), for: .touchUpInside)
}

View file

@ -15,7 +15,7 @@ final class InfoTableViewCell: UITableViewCell {
private func setupView() {
backgroundView = UIView() // Set background color to clear
setStyleAndApply("ClearBackground")
setStyle(.clearBackground)
contentView.addSubview(infoView)
infoView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([

View file

@ -35,11 +35,11 @@ final class InfoView: UIView {
stackView.alignment = .center
stackView.spacing = 16
titleLabel.setStyleAndApply("regular16:blackPrimaryText")
titleLabel.setFontStyle(.regular16, color: .blackPrimary)
titleLabel.lineBreakMode = .byWordWrapping
titleLabel.numberOfLines = .zero
imageView.setStyleAndApply("MWMBlack")
imageView.setStyle(.black)
imageView.contentMode = .scaleAspectFit
}

View file

@ -36,7 +36,7 @@ final class OSMView: UIView {
private func setupViews() {
OSMImageView.image = UIImage(named: "osm_logo")
OSMTextLabel.styleName = "regular14:blackPrimaryText"
OSMTextLabel.setFontStyle(.regular14, color: .blackPrimary)
OSMTextLabel.lineBreakMode = .byWordWrapping
OSMTextLabel.numberOfLines = 0
OSMTextLabel.isUserInteractionEnabled = true

View file

@ -19,7 +19,7 @@ final class SocialMediaCollectionViewCell: UICollectionViewCell {
}
private func setupView() {
setStyleAndApply("ClearBackground")
setStyle(.clearBackground)
imageView.contentMode = .scaleAspectFit
imageView.translatesAutoresizingMaskIntoConstraints = false

View file

@ -16,7 +16,7 @@ final class SocialMediaCollectionViewHeader: UICollectionReusableView {
private func setupView() {
addSubview(titleLabel)
titleLabel.setStyleAndApply("regular16:blackPrimaryText")
titleLabel.setFontStyleAndApply(.regular16, color: .blackPrimary)
titleLabel.numberOfLines = 1
titleLabel.allowsDefaultTighteningForTruncation = true
titleLabel.adjustsFontSizeToFitWidth = true

View file

@ -22,7 +22,7 @@ final class CircleImageButton: UIButton {
private func setupView() {
backgroundColor = .clear
circleImageView.styleName = "PPHeaderCircleIcon"
circleImageView.setStyle(.ppHeaderCircleIcon)
circleImageView.contentMode = .scaleAspectFill
circleImageView.clipsToBounds = true
circleImageView.isUserInteractionEnabled = false

View file

@ -53,13 +53,13 @@ class InfoItemViewController: UIViewController {
func setStyle(_ style: Style) {
switch style {
case .regular:
imageView?.setStyleAndApply("MWMBlack")
infoLabel?.setStyleAndApply("blackPrimaryText")
imageView?.setStyleAndApply(.black)
infoLabel?.setFontStyleAndApply(.blackPrimary)
case .link:
imageView?.setStyleAndApply("MWMBlue")
infoLabel?.setStyleAndApply("linkBlueText")
imageView?.setStyleAndApply(.blue)
infoLabel?.setFontStyleAndApply(.linkBlue)
}
accessoryButton.setStyleAndApply("MWMBlack")
accessoryButton.setStyleAndApply(.black)
self.style = style
}

View file

@ -15,7 +15,7 @@ final class ProductButton: UIButton {
}
private func setup(title: String, action: @escaping () -> Void) {
setStyleAndApply("BlueBackground")
setStyleAndApply(.blueBackground)
setTitle(title, for: .normal)
setTitleColor(.white, for: .normal)
titleLabel?.font = UIFont.regular14()

View file

@ -38,7 +38,7 @@ final class ProductsViewController: UIViewController {
}
private func setupViews() {
view.setStyleAndApply("Background")
view.setStyleAndApply(.background)
setupTitleLabel()
setupDescriptionLabel()
setupCloseButton()
@ -61,7 +61,7 @@ final class ProductsViewController: UIViewController {
}
private func setupCloseButton() {
closeButton.setStyleAndApply("MWMGray")
closeButton.setStyleAndApply(.gray)
closeButton.setImage(UIImage(resource: .icSearchClear), for: .normal)
closeButton.translatesAutoresizingMaskIntoConstraints = false
closeButton.addTarget(self, action: #selector(closeButtonDidTap), for: .touchUpInside)

View file

@ -29,11 +29,11 @@
UILabel * label = self.label;
label.text = text;
if (isRed)
[label setStyleAndApply:@"redText"];
[label setStyleNameAndApply:@"redText"];
else if (self.currentDay)
[label setStyleAndApply:@"blackPrimaryText"];
[label setStyleNameAndApply:@"blackPrimaryText"];
else
[label setStyleAndApply:@"blackSecondaryText"];
[label setStyleNameAndApply:@"blackSecondaryText"];
}
- (void)setOpenTimeText:(NSString *)text

View file

@ -153,7 +153,7 @@ final class PlacePageScrollView: UIScrollView {
private func setupView() {
let bgView = UIView()
bgView.styleName = "PPBackgroundView"
bgView.setStyle(.ppBackgroundView)
stackView.insertSubview(bgView, at: 0)
bgView.alignToSuperview()

View file

@ -95,7 +95,7 @@
}
}
[self setStyleAndApply: @"Background"];
[self setStyleNameAndApply: @"Background"];
}
- (NSDictionary *)selectedTitleAttributes

View file

@ -12,8 +12,7 @@ class SettingsTableViewDetailedSwitchCell: SettingsTableViewSwitchCell {
}
private func styleDetail() {
let detailTextLabelStyle = "regular12:blackSecondaryText"
detailTextLabel?.setStyleAndApply(detailTextLabelStyle)
detailTextLabel?.setFontStyleAndApply(.regular12, color: .blackSecondary)
detailTextLabel?.numberOfLines = 0
detailTextLabel?.lineBreakMode = .byWordWrapping
}

View file

@ -7,11 +7,11 @@ final class SettingsTableViewLinkCell: MWMTableViewCell {
}
private func setupCell() {
styleName = "Background"
textLabel?.styleName = "regular17:blackPrimaryText"
setStyle(.background)
textLabel?.setFontStyle(.regular17, color: .blackPrimary)
textLabel?.numberOfLines = 0
textLabel?.lineBreakMode = .byWordWrapping
detailTextLabel?.styleName = "regular17:blackSecondaryText"
detailTextLabel?.setFontStyle(.regular17, color: .blackSecondary)
}
@objc func config(title: String, info: String?) {

View file

@ -12,8 +12,8 @@ final class SettingsTableViewSelectableCell: MWMTableViewCell {
}
private func setupCell() {
styleName = "Background"
textLabel?.styleName = "regular17:blackPrimaryText"
setStyle(.background)
textLabel?.setFontStyle(.regular17, color: .blackPrimary)
textLabel?.numberOfLines = 0
textLabel?.lineBreakMode = .byWordWrapping
}

View file

@ -47,7 +47,7 @@ class SettingsTableViewSwitchCell: MWMTableViewCell {
}
private func setupCell() {
styleName = "Background"
setStyle(.background)
styleTitle()
textLabel?.numberOfLines = 0
textLabel?.lineBreakMode = .byWordWrapping
@ -63,7 +63,6 @@ class SettingsTableViewSwitchCell: MWMTableViewCell {
}
private func styleTitle() {
let style = "regular17:" + (isEnabled ? "blackPrimaryText" : "blackSecondaryText")
textLabel?.setStyleAndApply(style)
textLabel?.setFontStyleAndApply(.regular17, color: isEnabled ? .blackPrimary : .blackSecondary)
}
}