mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Update and enable the new bloom style on the home screen. (#4291)
* Update Compound * Adopt the new accent colour (and gradient) tokens.
This commit is contained in:
@@ -9,46 +9,64 @@ import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct BadgeLabel: View {
|
||||
enum Style {
|
||||
case accent
|
||||
case info
|
||||
case `default`
|
||||
}
|
||||
|
||||
let title: String
|
||||
let icon: KeyPath<CompoundIcons, Image>
|
||||
let isHighlighted: Bool
|
||||
let style: Style
|
||||
|
||||
var body: some View {
|
||||
Label(title,
|
||||
icon: icon,
|
||||
iconSize: .xSmall,
|
||||
relativeTo: .compound.bodySM)
|
||||
.labelStyle(BadgeLabelStyle(isHighlighted: isHighlighted))
|
||||
}
|
||||
}
|
||||
|
||||
private struct BadgeLabelStyle: LabelStyle {
|
||||
let isHighlighted: Bool
|
||||
|
||||
var titleColor: Color {
|
||||
isHighlighted ? .compound.textBadgeAccent : .compound.textBadgeInfo
|
||||
.labelStyle(LabelStyle(style: style))
|
||||
}
|
||||
|
||||
var iconColor: Color {
|
||||
isHighlighted ? .compound.iconSuccessPrimary : .compound.iconInfoPrimary
|
||||
}
|
||||
|
||||
var backgroundColor: Color {
|
||||
isHighlighted ? .compound.bgBadgeAccent : .compound.bgBadgeInfo
|
||||
}
|
||||
|
||||
func makeBody(configuration: Configuration) -> some View {
|
||||
HStack(spacing: 4) {
|
||||
configuration.icon
|
||||
.foregroundStyle(iconColor)
|
||||
configuration.title
|
||||
.foregroundStyle(titleColor)
|
||||
private struct LabelStyle: SwiftUI.LabelStyle {
|
||||
let style: Style
|
||||
|
||||
var titleColor: Color {
|
||||
switch style {
|
||||
case .accent: .compound.textBadgeAccent
|
||||
case .info: .compound.textBadgeInfo
|
||||
case .default: .compound.textPrimary
|
||||
}
|
||||
}
|
||||
|
||||
var iconColor: Color {
|
||||
switch style {
|
||||
case .accent: .compound.iconAccentPrimary
|
||||
case .info: .compound.iconInfoPrimary
|
||||
case .default: .compound.iconPrimary
|
||||
}
|
||||
}
|
||||
|
||||
var backgroundColor: Color {
|
||||
switch style {
|
||||
case .accent: .compound.bgBadgeAccent
|
||||
case .info: .compound.bgBadgeInfo
|
||||
case .default: .compound.bgBadgeDefault
|
||||
}
|
||||
}
|
||||
|
||||
func makeBody(configuration: Configuration) -> some View {
|
||||
HStack(spacing: 4) {
|
||||
configuration.icon
|
||||
.foregroundStyle(iconColor)
|
||||
configuration.title
|
||||
.foregroundStyle(titleColor)
|
||||
}
|
||||
.font(.compound.bodySM)
|
||||
.padding(.leading, 8)
|
||||
.padding(.trailing, 12)
|
||||
.padding(.vertical, 4)
|
||||
.background(Capsule().fill(backgroundColor))
|
||||
}
|
||||
.font(.compound.bodySM)
|
||||
.padding(.leading, 8)
|
||||
.padding(.trailing, 12)
|
||||
.padding(.vertical, 4)
|
||||
.background(Capsule().fill(backgroundColor))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,10 +75,13 @@ struct BadgeLabel_Previews: PreviewProvider, TestablePreview {
|
||||
VStack(spacing: 10) {
|
||||
BadgeLabel(title: "Encrypted",
|
||||
icon: \.lockSolid,
|
||||
isHighlighted: true)
|
||||
style: .accent)
|
||||
BadgeLabel(title: "Not encrypted",
|
||||
icon: \.lockSolid,
|
||||
isHighlighted: false)
|
||||
style: .info)
|
||||
BadgeLabel(title: "1234",
|
||||
icon: \.userProfile,
|
||||
style: .default)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user