-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixup missing colours and use resolved colours in UIKit.
Fix the confetti colour when using DesignKit. Pin swift packages.
- Loading branch information
Showing
29 changed files
with
194 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"pins" : [ | ||
{ | ||
"identity" : "element-design-tokens", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/vector-im/element-design-tokens.git", | ||
"state" : { | ||
"revision" : "4aafdc25ca0e322c0de930d4ec86121f5503023e", | ||
"version" : "0.0.1" | ||
} | ||
}, | ||
{ | ||
"identity" : "element-x-ios", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/vector-im/element-x-ios", | ||
"state" : { | ||
"branch" : "develop", | ||
"revision" : "272fc5000bfe6e15a0f0ea669ef3088c7d163ce7" | ||
} | ||
}, | ||
{ | ||
"identity" : "maplibre-gl-native-distribution", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/maplibre/maplibre-gl-native-distribution", | ||
"state" : { | ||
"revision" : "d761956e81e74d8bdbfba31e0ec3a75616190658", | ||
"version" : "5.12.2" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-collections", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-collections", | ||
"state" : { | ||
"revision" : "48254824bb4248676bf7ce56014ff57b142b77eb", | ||
"version" : "1.0.2" | ||
} | ||
}, | ||
{ | ||
"identity" : "swiftui-introspect", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/siteline/SwiftUI-Introspect.git", | ||
"state" : { | ||
"revision" : "f2616860a41f9d9932da412a8978fec79c06fe24", | ||
"version" : "0.1.4" | ||
} | ||
} | ||
], | ||
"version" : 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// | ||
// Copyright 2022 New Vector Ltd | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import UIKit | ||
import DesignTokens | ||
|
||
extension UIColor { | ||
/// The colors from DesignKit, resolved for light mode only. | ||
static let elementLight = ElementUIColorsResolved(dynamicColors: element, userInterfaceStyle: .light) | ||
/// The colors from DesignKit, resolved for dark mode only. | ||
static let elementDark = ElementUIColorsResolved(dynamicColors: element, userInterfaceStyle: .dark) | ||
} | ||
|
||
/// The dynamic colors from DesignKit, resolved to light or dark mode for use in the UIKit themes. | ||
/// | ||
/// As Element doesn't (currently) update the app's `UIUserInterfaceStyle` when selecting | ||
/// a custom theme, the dynamic colors provided by DesignKit need resolving for each theme to | ||
/// prevent them from respecting the interface style and rendering in the wrong style. | ||
@objcMembers public class ElementUIColorsResolved: NSObject { | ||
// MARK: Compound | ||
public let accent: UIColor | ||
public let alert: UIColor | ||
public let primaryContent: UIColor | ||
public let secondaryContent: UIColor | ||
public let tertiaryContent: UIColor | ||
public let quaternaryContent: UIColor | ||
public let quinaryContent: UIColor | ||
public let system: UIColor | ||
public let background: UIColor | ||
|
||
public let namesAndAvatars: [UIColor] | ||
|
||
// MARK: Legacy | ||
public let quarterlyContent: UIColor | ||
public let navigation: UIColor | ||
public let tile: UIColor | ||
public let separator: UIColor | ||
|
||
// MARK: Setup | ||
public init(dynamicColors: ElementUIColors, userInterfaceStyle: UIUserInterfaceStyle) { | ||
let traitCollection = UITraitCollection(userInterfaceStyle: userInterfaceStyle) | ||
|
||
self.accent = dynamicColors.accent.resolvedColor(with: traitCollection) | ||
self.alert = dynamicColors.alert.resolvedColor(with: traitCollection) | ||
self.primaryContent = dynamicColors.primaryContent.resolvedColor(with: traitCollection) | ||
self.secondaryContent = dynamicColors.secondaryContent.resolvedColor(with: traitCollection) | ||
self.tertiaryContent = dynamicColors.tertiaryContent.resolvedColor(with: traitCollection) | ||
self.quaternaryContent = dynamicColors.quaternaryContent.resolvedColor(with: traitCollection) | ||
self.quinaryContent = dynamicColors.quinaryContent.resolvedColor(with: traitCollection) | ||
self.system = dynamicColors.system.resolvedColor(with: traitCollection) | ||
self.background = dynamicColors.background.resolvedColor(with: traitCollection) | ||
|
||
self.namesAndAvatars = [ | ||
dynamicColors.globalAzure.resolvedColor(with: traitCollection), | ||
dynamicColors.globalGrape.resolvedColor(with: traitCollection), | ||
dynamicColors.globalVerde.resolvedColor(with: traitCollection), | ||
dynamicColors.globalPolly.resolvedColor(with: traitCollection), | ||
dynamicColors.globalMelon.resolvedColor(with: traitCollection), | ||
dynamicColors.globalAqua.resolvedColor(with: traitCollection), | ||
dynamicColors.globalPrune.resolvedColor(with: traitCollection), | ||
dynamicColors.globalKiwi.resolvedColor(with: traitCollection) | ||
] | ||
|
||
// Legacy colours | ||
self.quarterlyContent = dynamicColors.quaternaryContent.resolvedColor(with: traitCollection) | ||
self.navigation = dynamicColors.system.resolvedColor(with: traitCollection) | ||
|
||
if userInterfaceStyle == .light { | ||
self.tile = UIColor(rgb: 0xF3F8FD) | ||
self.separator = dynamicColors.quinaryContent.resolvedColor(with: traitCollection) | ||
} else { | ||
self.tile = dynamicColors.quinaryContent.resolvedColor(with: traitCollection) | ||
self.separator = dynamicColors.system.resolvedColor(with: traitCollection) | ||
} | ||
|
||
super.init() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.