Pin DesignKit version and use contantAndAvatars array.

This commit is contained in:
Doug
2022-07-01 14:36:04 +01:00
committed by Doug
parent 7d29bca319
commit 2d4e553cbd
12 changed files with 19 additions and 40 deletions

View File

@@ -49,7 +49,7 @@ struct AvatarImage: View {
mxContentUri: mxContentUri,
matrixItemId: matrixItemId,
displayName: displayName,
colorCount: theme.colors.namesAndAvatars.count,
colorCount: theme.colors.contentAndAvatars.count,
avatarSize: size
)
}

View File

@@ -36,7 +36,7 @@ struct PlaceholderAvatarImage: View {
var body: some View {
ZStack {
theme.colors.namesAndAvatars[colorIndex]
theme.colors.contentAndAvatars[colorIndex]
Text(String(firstCharacter))
.padding(4)

View File

@@ -38,7 +38,7 @@ struct SpaceAvatarImage: View {
.padding(10)
.frame(width: CGFloat(size.rawValue), height: CGFloat(size.rawValue))
.foregroundColor(.white)
.background(theme.colors.namesAndAvatars[colorIndex])
.background(theme.colors.contentAndAvatars[colorIndex])
.clipShape(RoundedRectangle(cornerRadius: 8))
// Make the text resizable (i.e. Make it large and then allow it to scale down)
.font(.system(size: 200))
@@ -55,7 +55,7 @@ struct SpaceAvatarImage: View {
mxContentUri: mxContentUri,
matrixItemId: matrixItemId,
displayName: value,
colorCount: theme.colors.namesAndAvatars.count,
colorCount: theme.colors.contentAndAvatars.count,
avatarSize: size
)
})
@@ -65,7 +65,7 @@ struct SpaceAvatarImage: View {
mxContentUri: mxContentUri,
matrixItemId: matrixItemId,
displayName: displayName,
colorCount: theme.colors.namesAndAvatars.count,
colorCount: theme.colors.contentAndAvatars.count,
avatarSize: size
)
}

View File

@@ -31,7 +31,7 @@ class EffectsScene: SCNScene {
static func confetti(with theme: ThemeSwiftUI) -> EffectsScene? {
guard let scene = EffectsScene(named: Constants.confettiSceneName) else { return nil }
let colors: [[Float]] = theme.colors.namesAndAvatars.compactMap { $0.floatComponents }
let colors: [[Float]] = theme.colors.contentAndAvatars.compactMap { $0.floatComponents }
if let particles = scene.rootNode.childNode(withName: Constants.particlesNodeName, recursively: false)?.particleSystems?.first {
// The particles need a non-zero color variation for the handler to affect the color

View File

@@ -36,24 +36,11 @@ public protocol ThemeSwiftUIType {
/// may contain more design components in future, like icons, audio files etc.
}
// MARK: - Legacy Colors
public extension ElementColors {
// MARK: - Legacy
var legacyTile: Color {
let dynamicColor = UIColor { $0.userInterfaceStyle == .light ? .elementLight.tile : .elementDark.tile }
return Color(dynamicColor)
}
// TODO: Generate in DesignTokens repo.
var namesAndAvatars: [Color] {
[
globalAzure,
globalGrape,
globalVerde,
globalPolly,
globalMelon,
globalAqua,
globalPrune,
globalKiwi
]
}
}

View File

@@ -23,7 +23,7 @@ extension ThemeSwiftUI {
/// - Parameter userId: The user id used to hash.
/// - Returns: The SwiftUI color for the associated userId.
func userColor(for userId: String) -> Color {
let senderNameColorIndex = Int(userId.vc_hashCode % Int32(colors.namesAndAvatars.count))
return colors.namesAndAvatars[senderNameColorIndex]
let senderNameColorIndex = Int(userId.vc_hashCode % Int32(colors.contentAndAvatars.count))
return colors.contentAndAvatars[senderNameColorIndex]
}
}