Skip to content

Commit

Permalink
- CLRichText default font is now .subheadline
Browse files Browse the repository at this point in the history
- CLExpandableText default font is now .subheadline + expand button font is now the same as Text and less spacing to Text
  • Loading branch information
juliangerhards committed Jun 8, 2022
1 parent 85cd7dc commit 45d3ac3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "1.000",
"green" : "0.482",
"red" : "0.000"
"blue" : "0xFF",
"green" : "0x7A",
"red" : "0x00"
}
},
"idiom" : "universal"
Expand Down
16 changes: 11 additions & 5 deletions Sources/CleanUI/Views/Texts/CLExpandableText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ public struct CLExpandableText: View {
/// - Parameters:
/// - string: The `String` to show
/// - characterLimit: The character limit; If the `string` is longer than the character limit, a show more / show less button gets shown
/// - font: The `Font
/// - font: The `Font, default is `.subheadline`
/// - richText: Should the Text be an ``CLRichText``?
/// - foregroundColor: The Text color
/// - alternativeExpandButtonAction: If you provide an action here, the default action for the show more button gets overwritten
/// - attributes: The attributes which should be highlighted for the ``CLRichText``, default is `[.links, .hashtags, .mentions]
/// - expandButtonColor: Set the foregroundColor for the expand button, default is `Color.grayText`
public init(_ string: String, characterLimit: Int = 150, font: Font = .callout, richText: Bool = true, foregroundColor: Color = Color.defaultText, alternativeExpandButtonAction: (() -> Void)? = nil, attributes: [Attribute] = [.links(), .hashtags(), .mentions()], expandButtonColor: Color = Color.grayText) {
public init(_ string: String, characterLimit: Int = 150, font: Font = .subheadline, richText: Bool = true, foregroundColor: Color = Color.defaultText, alternativeExpandButtonAction: (() -> Void)? = nil, attributes: [Attribute] = [.links(), .hashtags(), .mentions()], expandButtonColor: Color = Color.grayText) {
self.characterLimit = characterLimit
self.string = string
self.font = font
Expand All @@ -58,7 +58,7 @@ public struct CLExpandableText: View {
@State private var expanded: Bool = false

public var body: some View {
VStack(alignment: .leading) {
VStack(alignment: .leading, spacing: 6) {
if richText {
if expanded || string.count < characterLimit {
CLRichText(string, font: font, foregroundColor: foregroundColor, attributes: attributes)
Expand Down Expand Up @@ -92,11 +92,10 @@ public struct CLExpandableText: View {
}
}) {
Text(CULanguage.getStringCleanUI(expanded ? "showless" : "showmore"))
.font(.subheadline)
.font(font)
.foregroundColor(expandButtonColor)
}
.buttonStyle(.plain)
.padding(.vertical, 5)
}

}
Expand All @@ -105,3 +104,10 @@ public struct CLExpandableText: View {
}
}
}

struct CLExpandableText_Previews: PreviewProvider {
static var previews: some View {
CLExpandableText("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.")
.padding()
}
}
4 changes: 2 additions & 2 deletions Sources/CleanUI/Views/Texts/CLRichText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public struct CLRichText: View {

/// - Parameters:
/// - string: The String that should be shown
/// - font: The `Font`, default is `.callout`
/// - font: The `Font`, default is `.subheadline`
/// - foregroundColor: The text color, default is `Color.defaultText`
/// - attributes: The attributes which should be highlighted, default is `[.links, .hashtags, .mentions]
public init(_ string: String, font: Font = .callout, foregroundColor: Color = Color.defaultText, attributes: [Attribute] = [.links(), .hashtags(), .mentions()]){
public init(_ string: String, font: Font = .subheadline, foregroundColor: Color = Color.defaultText, attributes: [Attribute] = [.links(), .hashtags(), .mentions()]){
self.string = string
self.font = font
self.foregroundColor = foregroundColor
Expand Down

0 comments on commit 45d3ac3

Please sign in to comment.