mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 08:15:24 +00:00
Let TitleAndIcon take an attributed subtitle
Add an AttributedString subtitle initialiser to Compound's TitleAndIcon, with the existing String initialiser forwarding to it so current call sites are unchanged. Add a preview state with a bold run and re-record the titleAndIcon snapshots. This lets screens with partially bold copy, such as the multi-account announcement, use TitleAndIcon instead of rebuilding its layout.
This commit is contained in:
@@ -16,7 +16,7 @@ import SwiftUI
|
||||
/// than it is to add/subtract additional padding to some arbitrary defaults.
|
||||
public struct TitleAndIcon: View {
|
||||
private let title: String
|
||||
private let subtitle: String?
|
||||
private let subtitle: AttributedString?
|
||||
private let icon: KeyPath<CompoundIcons, Image>
|
||||
private let iconStyle: BigIcon.Style
|
||||
private let button: ButtonDetails?
|
||||
@@ -26,6 +26,18 @@ public struct TitleAndIcon: View {
|
||||
icon: KeyPath<CompoundIcons, Image>,
|
||||
iconStyle: BigIcon.Style,
|
||||
button: ButtonDetails? = nil) {
|
||||
self.init(title: title,
|
||||
subtitle: subtitle.map { AttributedString($0) },
|
||||
icon: icon,
|
||||
iconStyle: iconStyle,
|
||||
button: button)
|
||||
}
|
||||
|
||||
public init(title: String,
|
||||
subtitle: AttributedString?,
|
||||
icon: KeyPath<CompoundIcons, Image>,
|
||||
iconStyle: BigIcon.Style,
|
||||
button: ButtonDetails? = nil) {
|
||||
self.title = title
|
||||
self.subtitle = subtitle
|
||||
self.icon = icon
|
||||
@@ -95,8 +107,21 @@ public struct TitleAndIcon_Previews: PreviewProvider, TestablePreview {
|
||||
icon: \.circle,
|
||||
iconStyle: .defaultSolid,
|
||||
button: .init(title: "Learn more") { })
|
||||
|
||||
TitleAndIcon(title: "Headline",
|
||||
subtitle: attributedSubtitle,
|
||||
icon: \.circle,
|
||||
iconStyle: .defaultSolid)
|
||||
}
|
||||
.padding(24)
|
||||
.padding(.bottom, 16)
|
||||
}
|
||||
|
||||
private static var attributedSubtitle: AttributedString {
|
||||
var subtitle = AttributedString("Description with ")
|
||||
var boldText = AttributedString("bold text")
|
||||
boldText.inlinePresentationIntent = .stronglyEmphasized
|
||||
subtitle.append(boldText)
|
||||
return subtitle
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a462bcf49cb01edc5dd987b35fbeed8f22afb1beb821c066aa8b048da5a78285
|
||||
size 98742
|
||||
oid sha256:3b3d90b0039c941cee3aa00bb89612a1be3582c5de5bee214387e0b6eef744a1
|
||||
size 111386
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:77ef2e1f94fa765e37b2a51127fe641a60c0049561a32c64ac228665195c0764
|
||||
size 56729
|
||||
oid sha256:1a8e5eff7ee490a58fc775d54542c26fd3e01a0ba0fddb7f986537243c963818
|
||||
size 68065
|
||||
|
||||
Reference in New Issue
Block a user