Skip to content

Commit

Permalink
feat(Brand): New moves brand and remove prominent
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Renamed some tokens from the color palettes and removed prominent variant theme and all the code related with ThemeVariant

* IOS-7865 Update movistar mistica color palette for digital hub. Removed/renamed some tokens from MisticaColors protocol. Removed GradientView cause now is not used anymore.

* Run swiftformat

* IOS-7865 Removed O2Classic snapshots.

* IOS-7865 Added new snapshots for the new Movistar color palette.

* IOS-7865 Update ColorToolkit+UIColor with some tokens renamed.

* IOS-8052 Removed all code related with theme variants and prominent.

* Run swiftformat

---------

Co-authored-by: idenjoe <idenjoe@users.noreply.github.com>
  • Loading branch information
idenjoe and idenjoe committed Mar 16, 2023
1 parent a74e575 commit 016ad74
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 113 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ When implementing the component, try to have in mind the following guidelines:
* Make sure the component reiszes correctly (we support iPad multitasking, so any screen can resize at any given time).
* Don't forget accessibility (VoiceOver, Dynamic Type...).
* Pay attention to user interaction (Gestures, Haptics, 3D Touch...)
* Although this should be transparent to you, take into account themes and multiple brands.
* Although this should be transparent to you, take into account multiple brands.
* To help other developers, add documentation about the new component.

## Testing
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,10 @@ pod install

## Configuration

By default the framework components are created with the Movistar's brand style and the `standard` theme variant, to select a different one, configure the brand style and/or variant:
By default the framework components are created with the Movistar's brand style, to select a different one, configure the brand style:

```swift
MisticaConfig.brandStyle = .o2
MisticaConfig.themeVariant = .prominent
```

Remember to initialize Mistica with you desired brand style before the initialize the UI of your app.
Expand Down
17 changes: 3 additions & 14 deletions Sources/Mistica/Components/Filter/Filter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ public class Filter: UIView {
setUpSegmentsContentMode(for: traitCollection)
setUpLayout(for: segmentsContentMode)
setUpCollectionView()

// Listen to theme variant changes
NotificationCenter.default.addObserver(self, selector: #selector(themeDidChange), name: .themeVariantDidChange, object: nil)
}

override public func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
Expand All @@ -115,7 +112,9 @@ public class Filter: UIView {
}

if traitCollection.userInterfaceStyle != previousTraitCollection?.userInterfaceStyle {
themeDidChange()
collectionView.backgroundColor = .navigationBarBackground
bottomSeparator.image = UIImage(color: .navigationBarDivider)
reloadContent()
}
}

Expand Down Expand Up @@ -357,13 +356,3 @@ private extension Filter {
return segments[index]
}
}

// MARK: Theme Variant did change notification

@objc extension Filter {
func themeDidChange() {
collectionView.backgroundColor = .navigationBarBackground
bottomSeparator.image = UIImage(color: .navigationBarDivider)
reloadContent()
}
}
11 changes: 0 additions & 11 deletions Sources/Mistica/Components/Tabs/TabsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ private extension TabsView {
setUpDivider()
setUpCollectionView()
updateEstimatedItemSize()

// Listen to theme variant changes
NotificationCenter.default.addObserver(self, selector: #selector(themeDidChange), name: .themeVariantDidChange, object: nil)
}

func setUpView() {
Expand Down Expand Up @@ -229,14 +226,6 @@ extension TabsView: UICollectionViewDelegate {
}
}

// MARK: Theme Variant did change notification

@objc extension TabsView {
func themeDidChange() {
reloadContent()
}
}

// MARK: UILargeContentViewerInteractionDelegate

extension TabsView: UILargeContentViewerInteractionDelegate {
Expand Down
7 changes: 0 additions & 7 deletions Sources/MisticaCommon/MisticaConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ public enum MisticaConfig {
}
}

public static var themeVariant: ThemeVariant = .standard {
didSet {
MisticaAppearance.setUp(controls: currentStyledControls)
NotificationCenter.default.post(name: .themeVariantDidChange, object: nil)
}
}

public static func styleControls(_ controls: [MisticaControlStyle]) {
currentStyledControls = controls
MisticaAppearance.setUp(controls: controls)
Expand Down

This file was deleted.

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// AssetCatalog+Themed.swift
// AssetCatalog.swift
//
// Made with ❤️ by Novum
//
Expand All @@ -17,7 +17,7 @@ extension UIImage {
///
/// - Parameters:
/// - brandedImageNamed: asset name
/// - type: if the asset can change per brand, theme or is common
/// - type: if the asset can change per brand or is common
convenience init?(named: String, type: AssetType) {
let name = type.assetPath(named)
self.init(named: name, in: .mistica, compatibleWith: nil)
Expand All @@ -30,7 +30,7 @@ extension NSDataAsset {
///
/// - Parameters:
/// - brandedImageNamed: asset name
/// - type: if the asset can change per brand, theme or is common
/// - type: if the asset can change per brand or is common
convenience init?(named: String, type: AssetType) {
let name = type.assetPath(named)
self.init(name: name, bundle: .mistica)
Expand All @@ -43,48 +43,27 @@ extension Image {
///
/// - Parameters:
/// - brandedImageNamed: asset name
/// - type: if the asset can change per brand, theme or is common
/// - type: if the asset can change per brand or is common
init?(named: String, type: AssetType) {
let name = type.assetPath(named)
self.init(name, bundle: .mistica)
}
}

extension UIColor {
/// Creates a color using the current theme variant.
///
/// - Parameters:
/// - defaultColor: color used when the color for the current variant has not been provided
/// - variants: colors for different theme variants
convenience init(_ defaultColor: UIColor, variants: [ThemeVariant: UIColor]) {
if let current = variants[MisticaConfig.themeVariant] {
self.init(cgColor: current.cgColor)
} else {
self.init(cgColor: defaultColor.cgColor)
}
}
}

private extension BrandStyle {
/// Build an asset path based on the brand style (movistar, vivo..) and the theme variant (standard, prominent..)
/// Build an asset path based on the brand style (movistar, vivo..)
/// The image name with a 'path' format will be used to locate the asset in the asset catalog.
///
/// - Parameters:
/// - name: asset name
/// - variant: brand style variant
/// - Returns: path to asset inside the asset catalog
func assetPath(_ name: String, variant: ThemeVariant) -> String {
switch variant {
case .standard:
return "\(id)/\(name)"
default:
return "\(id)/\(variant.rawValue)/\(name)"
}
func assetPath(_ name: String) -> String {
"\(id)/\(name)"
}
}

private extension AssetType {
/// Build an asset path based on the asset type in case the asset can change per brand, theme or is common
/// Build an asset path based on the asset type in case the asset can change per brand or is common
/// The image name with a 'path' format will be used to locate the asset in the asset catalog.
///
/// - Parameter name: asset name
Expand All @@ -94,9 +73,7 @@ private extension AssetType {
case .common:
return name
case .branded:
return MisticaConfig.brandStyle.assetPath(name, variant: .standard)
case .brandedAndThemed:
return MisticaConfig.brandStyle.assetPath(name, variant: MisticaConfig.themeVariant)
return MisticaConfig.brandStyle.assetPath(name)
}
}
}
3 changes: 0 additions & 3 deletions Sources/MisticaCommon/Styles/AssetType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@ enum AssetType {

// The asset changes per brand style
case branded

// The asset changes per brand style and per theme variant
case brandedAndThemed
}
19 changes: 0 additions & 19 deletions Sources/MisticaCommon/Styles/ThemeVariant.swift

This file was deleted.

0 comments on commit 016ad74

Please sign in to comment.