mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +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.
|
/// than it is to add/subtract additional padding to some arbitrary defaults.
|
||||||
public struct TitleAndIcon: View {
|
public struct TitleAndIcon: View {
|
||||||
private let title: String
|
private let title: String
|
||||||
private let subtitle: String?
|
private let subtitle: AttributedString?
|
||||||
private let icon: KeyPath<CompoundIcons, Image>
|
private let icon: KeyPath<CompoundIcons, Image>
|
||||||
private let iconStyle: BigIcon.Style
|
private let iconStyle: BigIcon.Style
|
||||||
private let button: ButtonDetails?
|
private let button: ButtonDetails?
|
||||||
@@ -26,6 +26,18 @@ public struct TitleAndIcon: View {
|
|||||||
icon: KeyPath<CompoundIcons, Image>,
|
icon: KeyPath<CompoundIcons, Image>,
|
||||||
iconStyle: BigIcon.Style,
|
iconStyle: BigIcon.Style,
|
||||||
button: ButtonDetails? = nil) {
|
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.title = title
|
||||||
self.subtitle = subtitle
|
self.subtitle = subtitle
|
||||||
self.icon = icon
|
self.icon = icon
|
||||||
@@ -95,8 +107,21 @@ public struct TitleAndIcon_Previews: PreviewProvider, TestablePreview {
|
|||||||
icon: \.circle,
|
icon: \.circle,
|
||||||
iconStyle: .defaultSolid,
|
iconStyle: .defaultSolid,
|
||||||
button: .init(title: "Learn more") { })
|
button: .init(title: "Learn more") { })
|
||||||
|
|
||||||
|
TitleAndIcon(title: "Headline",
|
||||||
|
subtitle: attributedSubtitle,
|
||||||
|
icon: \.circle,
|
||||||
|
iconStyle: .defaultSolid)
|
||||||
}
|
}
|
||||||
.padding(24)
|
.padding(24)
|
||||||
.padding(.bottom, 16)
|
.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
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:a462bcf49cb01edc5dd987b35fbeed8f22afb1beb821c066aa8b048da5a78285
|
oid sha256:3b3d90b0039c941cee3aa00bb89612a1be3582c5de5bee214387e0b6eef744a1
|
||||||
size 98742
|
size 111386
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:77ef2e1f94fa765e37b2a51127fe641a60c0049561a32c64ac228665195c0764
|
oid sha256:1a8e5eff7ee490a58fc775d54542c26fd3e01a0ba0fddb7f986537243c963818
|
||||||
size 56729
|
size 68065
|
||||||
|
|||||||
Reference in New Issue
Block a user