From 45f54bdd2cd19d93f42b5c48000a42fcb5dc7a84 Mon Sep 17 00:00:00 2001 From: jxhug Date: Tue, 23 Jan 2024 20:03:35 -0800 Subject: [PATCH 01/18] add macos support, unexpand when text changes Signed-off-by: jxhug plain button Signed-off-by: jxhug est Signed-off-by: jxhug bro Signed-off-by: jxhug @stackotter suggestion onchange Signed-off-by: jxhug --- Package.swift | 3 ++- Sources/ExpandableText/ExpandableText.swift | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index 4e0d394..ce0deac 100644 --- a/Package.swift +++ b/Package.swift @@ -6,7 +6,8 @@ import PackageDescription let package = Package( name: "ExpandableText", platforms: [ - .iOS(.v13) + .iOS(.v13), + .macOS(.v12) ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. diff --git a/Sources/ExpandableText/ExpandableText.swift b/Sources/ExpandableText/ExpandableText.swift index 43cdff0..a00b397 100644 --- a/Sources/ExpandableText/ExpandableText.swift +++ b/Sources/ExpandableText/ExpandableText.swift @@ -27,7 +27,7 @@ ExpandableText("Lorem ipsum dolor sit amet, consectetur adipiscing elit...") */ public struct ExpandableText: View { - @State private var isExpanded: Bool = false + @State internal var isExpanded: Bool = false @State private var isTruncated: Bool = false @State private var intrinsicSize: CGSize = .zero @@ -56,6 +56,11 @@ public struct ExpandableText: View { public var body: some View { content + .onChange(of: text) { _ in + if isExpanded { + isExpanded = false + } + } .lineLimit(isExpanded ? nil : lineLimit) .applyingTruncationMask(size: moreTextSize, enabled: shouldShowMoreButton) .readSize { size in @@ -94,6 +99,7 @@ public struct ExpandableText: View { .font(moreButtonFont ?? font) .foregroundColor(moreButtonColor) } + .buttonStyle(.plain) } })) } @@ -117,3 +123,7 @@ public struct ExpandableText: View { text.replacingOccurrences(of: #"\n\s*\n"#, with: "\n", options: .regularExpression) } } + +#Preview { + ExpandableText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.") +} From b925ead23acc4c94d0e6578d63af09b22117d6d9 Mon Sep 17 00:00:00 2001 From: James Hughes Date: Fri, 26 Jan 2024 21:37:32 -0800 Subject: [PATCH 02/18] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7bace8d..f2b4f65 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![build](https://github.com/n3d1117/ExpandableText/actions/workflows/build.yml/badge.svg)](https://github.com/n3d1117/ExpandableText/actions/workflows/build.yml) [![swift-version](https://img.shields.io/badge/swift-5.7-orange.svg)](https://github.com/apple/swift/) [![ios-version](https://img.shields.io/badge/ios-13.0+-brightgreen.svg)](https://github.com/apple/ios/) +[![macos-version](https://img.shields.io/badge/macos-12.0+-brightgreen.svg)](https://github.com/apple/macos/) [![xcode-version](https://img.shields.io/badge/xcode-14.2-blue)](https://developer.apple.com/xcode/) [![license](https://img.shields.io/badge/license-The%20Unlicense-yellow.svg)](LICENSE) From 71920e2d8f9064684643f6dab2a0c565140560a7 Mon Sep 17 00:00:00 2001 From: jxhug Date: Sun, 25 Feb 2024 11:41:22 -0800 Subject: [PATCH 03/18] less?? --- .../ExpandableText+Modifiers.swift | 25 +++++++++++++----- Sources/ExpandableText/ExpandableText.swift | 26 +++++++++++++++---- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/Sources/ExpandableText/ExpandableText+Modifiers.swift b/Sources/ExpandableText/ExpandableText+Modifiers.swift index d7cb4ee..00ef413 100644 --- a/Sources/ExpandableText/ExpandableText+Modifiers.swift +++ b/Sources/ExpandableText/ExpandableText+Modifiers.swift @@ -54,25 +54,36 @@ public extension ExpandableText { return copy } + /** + Sets the text to use for the "show less" button in the `ExpandableText` instance. + - Parameter moreText: The text to use for the "show less" button. Defaults to `less` + - Returns: A new `ExpandableText` instance with the specified "show more" button text applied. + */ + func lessButtonText(_ lessText: String) -> Self { + var copy = self + copy.lessButtonText = lessText + return copy + } + /** Sets the font to use for the "show more" button in the `ExpandableText` instance. - Parameter font: The font to use for the "show more" button. Defaults to the same font as the text - Returns: A new `ExpandableText` instance with the specified "show more" button font applied. */ - func moreButtonFont(_ font: Font) -> Self { + func buttonFont(_ font: Font) -> Self { var copy = self - copy.moreButtonFont = font + copy.buttonFont = font return copy } /** - Sets the color to use for the "show more" button in the `ExpandableText` instance. - - Parameter color: The color to use for the "show more" button. Defaults to `accentColor` - - Returns: A new `ExpandableText` instance with the specified "show more" button color applied. + Sets the color to use for the "show less/more" buttons in the `ExpandableText` instance. + - Parameter color: The color to use for the "show less/more" buttons. Defaults to `accentColor` + - Returns: A new `ExpandableText` instance with the specified "show less/more" buttons color applied. */ - func moreButtonColor(_ color: Color) -> Self { + func buttonColor(_ color: Color) -> Self { var copy = self - copy.moreButtonColor = color + copy.buttonColor = color return copy } diff --git a/Sources/ExpandableText/ExpandableText.swift b/Sources/ExpandableText/ExpandableText.swift index a00b397..206add6 100644 --- a/Sources/ExpandableText/ExpandableText.swift +++ b/Sources/ExpandableText/ExpandableText.swift @@ -39,8 +39,9 @@ public struct ExpandableText: View { internal var color: Color = .primary internal var lineLimit: Int = 3 internal var moreButtonText: String = "more" - internal var moreButtonFont: Font? - internal var moreButtonColor: Color = .accentColor + internal var lessButtonText: String = "less" + internal var buttonFont: Font? + internal var buttonColor: Color = .accentColor internal var expandAnimation: Animation = .default internal var collapseEnabled: Bool = false internal var trimMultipleNewlinesWhenTruncated: Bool = true @@ -79,7 +80,13 @@ public struct ExpandableText: View { ) .background( Text(moreButtonText) - .font(moreButtonFont ?? font) + .font(buttonFont ?? font) + .hidden() + .readSize { moreTextSize = $0 } + ) + .background( + Text(lessButtonText) + .font(buttonFont ?? font) .hidden() .readSize { moreTextSize = $0 } ) @@ -96,8 +103,17 @@ public struct ExpandableText: View { withAnimation(expandAnimation) { isExpanded.toggle() } } label: { Text(moreButtonText) - .font(moreButtonFont ?? font) - .foregroundColor(moreButtonColor) + .font(buttonFont ?? font) + .foregroundColor(buttonColor) + } + .buttonStyle(.plain) + } else { + Button { + withAnimation(expandAnimation) { isExpanded.toggle() } + } label: { + Text(lessButtonText) + .font(buttonFont ?? font) + .foregroundColor(buttonColor) } .buttonStyle(.plain) } From 714fdedebc1e9c2a24eb44f0545c2a42d213fb29 Mon Sep 17 00:00:00 2001 From: jxhug Date: Sun, 25 Feb 2024 11:51:28 -0800 Subject: [PATCH 04/18] test truncation shit Signed-off-by: jxhug --- Package.swift | 2 +- Sources/ExpandableText/ExpandableText.swift | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Package.swift b/Package.swift index ce0deac..f9173f9 100644 --- a/Package.swift +++ b/Package.swift @@ -6,7 +6,7 @@ import PackageDescription let package = Package( name: "ExpandableText", platforms: [ - .iOS(.v13), + .iOS(.v14), .macOS(.v12) ], products: [ diff --git a/Sources/ExpandableText/ExpandableText.swift b/Sources/ExpandableText/ExpandableText.swift index 206add6..8037b66 100644 --- a/Sources/ExpandableText/ExpandableText.swift +++ b/Sources/ExpandableText/ExpandableText.swift @@ -107,11 +107,20 @@ public struct ExpandableText: View { .foregroundColor(buttonColor) } .buttonStyle(.plain) - } else { + } else if isTruncated { Button { withAnimation(expandAnimation) { isExpanded.toggle() } } label: { - Text(lessButtonText) + Text("TRUNCATED") + .font(buttonFont ?? font) + .foregroundColor(buttonColor) + } + .buttonStyle(.plain) + } else if !isTruncated { + Button { + withAnimation(expandAnimation) { isExpanded.toggle() } + } label: { + Text("NOT TRUNCATED") .font(buttonFont ?? font) .foregroundColor(buttonColor) } From d6f61cb82872fc82d81781ce6c44010e6858e76e Mon Sep 17 00:00:00 2001 From: jxhug Date: Sun, 25 Feb 2024 11:52:34 -0800 Subject: [PATCH 05/18] boom Signed-off-by: jxhug --- Sources/ExpandableText/ExpandableText.swift | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Sources/ExpandableText/ExpandableText.swift b/Sources/ExpandableText/ExpandableText.swift index 8037b66..036860e 100644 --- a/Sources/ExpandableText/ExpandableText.swift +++ b/Sources/ExpandableText/ExpandableText.swift @@ -111,16 +111,7 @@ public struct ExpandableText: View { Button { withAnimation(expandAnimation) { isExpanded.toggle() } } label: { - Text("TRUNCATED") - .font(buttonFont ?? font) - .foregroundColor(buttonColor) - } - .buttonStyle(.plain) - } else if !isTruncated { - Button { - withAnimation(expandAnimation) { isExpanded.toggle() } - } label: { - Text("NOT TRUNCATED") + Text(lessButtonText) .font(buttonFont ?? font) .foregroundColor(buttonColor) } From f4ed1a90e40c10c44e50ac74484ef5f817675e78 Mon Sep 17 00:00:00 2001 From: jxhug Date: Sun, 25 Feb 2024 11:57:15 -0800 Subject: [PATCH 06/18] maybe maybe maybe maybe maybe maybe Signed-off-by: jxhug --- Sources/ExpandableText/ExpandableText.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/ExpandableText/ExpandableText.swift b/Sources/ExpandableText/ExpandableText.swift index 036860e..8193d29 100644 --- a/Sources/ExpandableText/ExpandableText.swift +++ b/Sources/ExpandableText/ExpandableText.swift @@ -107,7 +107,7 @@ public struct ExpandableText: View { .foregroundColor(buttonColor) } .buttonStyle(.plain) - } else if isTruncated { + } else if isExpanded && isTruncated { Button { withAnimation(expandAnimation) { isExpanded.toggle() } } label: { From 5b9c55c1485c4df101bf55e47244ef1b3d4292f2 Mon Sep 17 00:00:00 2001 From: jxhug Date: Sun, 25 Feb 2024 12:01:36 -0800 Subject: [PATCH 07/18] PELSAE Signed-off-by: jxhug --- Sources/ExpandableText/ExpandableText.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/ExpandableText/ExpandableText.swift b/Sources/ExpandableText/ExpandableText.swift index 8193d29..f0c2111 100644 --- a/Sources/ExpandableText/ExpandableText.swift +++ b/Sources/ExpandableText/ExpandableText.swift @@ -107,7 +107,7 @@ public struct ExpandableText: View { .foregroundColor(buttonColor) } .buttonStyle(.plain) - } else if isExpanded && isTruncated { + } else if collapseEnabled { Button { withAnimation(expandAnimation) { isExpanded.toggle() } } label: { From fc1d2602ef32d5b1680c76e284a565e0442ebb7f Mon Sep 17 00:00:00 2001 From: jxhug Date: Sun, 25 Feb 2024 12:14:11 -0800 Subject: [PATCH 08/18] uhhh Signed-off-by: jxhug --- Sources/ExpandableText/ExpandableText.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Sources/ExpandableText/ExpandableText.swift b/Sources/ExpandableText/ExpandableText.swift index f0c2111..b504c2c 100644 --- a/Sources/ExpandableText/ExpandableText.swift +++ b/Sources/ExpandableText/ExpandableText.swift @@ -92,8 +92,7 @@ public struct ExpandableText: View { ) .contentShape(Rectangle()) .onTapGesture { - if (isExpanded && collapseEnabled) || - shouldShowMoreButton { + if (isExpanded && collapseEnabled) || shouldShowMoreButton { withAnimation(expandAnimation) { isExpanded.toggle() } } } @@ -107,7 +106,7 @@ public struct ExpandableText: View { .foregroundColor(buttonColor) } .buttonStyle(.plain) - } else if collapseEnabled { + } else if (isExpanded && collapseEnabled) { Button { withAnimation(expandAnimation) { isExpanded.toggle() } } label: { From b5280296517fb00da6f78382e68f203949de4f81 Mon Sep 17 00:00:00 2001 From: jxhug Date: Sun, 25 Feb 2024 12:29:32 -0800 Subject: [PATCH 09/18] mahbdw Signed-off-by: jxhug --- Sources/ExpandableText/ExpandableText.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/ExpandableText/ExpandableText.swift b/Sources/ExpandableText/ExpandableText.swift index b504c2c..51cd031 100644 --- a/Sources/ExpandableText/ExpandableText.swift +++ b/Sources/ExpandableText/ExpandableText.swift @@ -106,7 +106,7 @@ public struct ExpandableText: View { .foregroundColor(buttonColor) } .buttonStyle(.plain) - } else if (isExpanded && collapseEnabled) { + } else if (isExpanded && !isTruncated) { Button { withAnimation(expandAnimation) { isExpanded.toggle() } } label: { From b0a14e0518f78ad8321ff25612603baabd20aa27 Mon Sep 17 00:00:00 2001 From: jxhug Date: Sun, 25 Feb 2024 12:42:15 -0800 Subject: [PATCH 10/18] pls Signed-off-by: jxhug --- Sources/ExpandableText/ExpandableText.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Sources/ExpandableText/ExpandableText.swift b/Sources/ExpandableText/ExpandableText.swift index 51cd031..1312833 100644 --- a/Sources/ExpandableText/ExpandableText.swift +++ b/Sources/ExpandableText/ExpandableText.swift @@ -107,6 +107,10 @@ public struct ExpandableText: View { } .buttonStyle(.plain) } else if (isExpanded && !isTruncated) { + // Initially hide the button + @State var showLessButton = false + + // Use onAppear to trigger the delayed display of the button Button { withAnimation(expandAnimation) { isExpanded.toggle() } } label: { @@ -115,7 +119,16 @@ public struct ExpandableText: View { .foregroundColor(buttonColor) } .buttonStyle(.plain) + .opacity(showLessButton ? 1 : 0) // Use opacity to show/hide the button + + .onAppear { + DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { + // Show the button after a delay of 0.25 seconds + showLessButton = true + } + } } + })) } From b2587a63a32ce9b1db62c7f3ec5bdd6edd449f7a Mon Sep 17 00:00:00 2001 From: jxhug Date: Sun, 25 Feb 2024 12:44:20 -0800 Subject: [PATCH 11/18] mayb Signed-off-by: jxhug --- Sources/ExpandableText/ExpandableText.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/ExpandableText/ExpandableText.swift b/Sources/ExpandableText/ExpandableText.swift index 1312833..10ce407 100644 --- a/Sources/ExpandableText/ExpandableText.swift +++ b/Sources/ExpandableText/ExpandableText.swift @@ -109,7 +109,6 @@ public struct ExpandableText: View { } else if (isExpanded && !isTruncated) { // Initially hide the button @State var showLessButton = false - // Use onAppear to trigger the delayed display of the button Button { withAnimation(expandAnimation) { isExpanded.toggle() } @@ -120,9 +119,9 @@ public struct ExpandableText: View { } .buttonStyle(.plain) .opacity(showLessButton ? 1 : 0) // Use opacity to show/hide the button - .onAppear { DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { + print("show button") // Show the button after a delay of 0.25 seconds showLessButton = true } From e87e638a94a653f38ccce3bf3ad053d27c1ccc5d Mon Sep 17 00:00:00 2001 From: jxhug Date: Sun, 25 Feb 2024 13:26:53 -0800 Subject: [PATCH 12/18] uhh Signed-off-by: jxhug --- Sources/ExpandableText/ExpandableText.swift | 29 +++++++++++---------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Sources/ExpandableText/ExpandableText.swift b/Sources/ExpandableText/ExpandableText.swift index 10ce407..3947ddb 100644 --- a/Sources/ExpandableText/ExpandableText.swift +++ b/Sources/ExpandableText/ExpandableText.swift @@ -29,7 +29,7 @@ public struct ExpandableText: View { @State internal var isExpanded: Bool = false @State private var isTruncated: Bool = false - + @State private var showLessButton: Bool = false @State private var intrinsicSize: CGSize = .zero @State private var truncatedSize: CGSize = .zero @State private var moreTextSize: CGSize = .zero @@ -107,27 +107,28 @@ public struct ExpandableText: View { } .buttonStyle(.plain) } else if (isExpanded && !isTruncated) { - // Initially hide the button - @State var showLessButton = false - // Use onAppear to trigger the delayed display of the button - Button { - withAnimation(expandAnimation) { isExpanded.toggle() } - } label: { - Text(lessButtonText) - .font(buttonFont ?? font) - .foregroundColor(buttonColor) + VStack { + if showLessButton { + Button { + withAnimation(expandAnimation) { + showLessButton = false + isExpanded.toggle() + } + } label: { + Text(lessButtonText) + .font(buttonFont ?? font) + .foregroundColor(buttonColor) + } + .buttonStyle(.plain) + } } - .buttonStyle(.plain) - .opacity(showLessButton ? 1 : 0) // Use opacity to show/hide the button .onAppear { DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { - print("show button") // Show the button after a delay of 0.25 seconds showLessButton = true } } } - })) } From 63662484c75d320ba0c22566fd16e1f0c788c13d Mon Sep 17 00:00:00 2001 From: jxhug Date: Sun, 25 Feb 2024 13:30:51 -0800 Subject: [PATCH 13/18] idk man Signed-off-by: jxhug --- Sources/ExpandableText/ExpandableText.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sources/ExpandableText/ExpandableText.swift b/Sources/ExpandableText/ExpandableText.swift index 3947ddb..4347cb3 100644 --- a/Sources/ExpandableText/ExpandableText.swift +++ b/Sources/ExpandableText/ExpandableText.swift @@ -93,13 +93,19 @@ public struct ExpandableText: View { .contentShape(Rectangle()) .onTapGesture { if (isExpanded && collapseEnabled) || shouldShowMoreButton { - withAnimation(expandAnimation) { isExpanded.toggle() } + withAnimation(expandAnimation) { + isExpanded.toggle() + showLessButton = false + } } } .modifier(OverlayAdapter(alignment: .trailingLastTextBaseline, view: { if shouldShowMoreButton { Button { - withAnimation(expandAnimation) { isExpanded.toggle() } + withAnimation(expandAnimation) { + isExpanded.toggle() + showLessButton = false + } } label: { Text(moreButtonText) .font(buttonFont ?? font) From 8b73a8e09550a3ee1103e3efc98c69898157f9fb Mon Sep 17 00:00:00 2001 From: jxhug Date: Sun, 25 Feb 2024 13:32:59 -0800 Subject: [PATCH 14/18] anim Signed-off-by: jxhug --- Sources/ExpandableText/ExpandableText.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/ExpandableText/ExpandableText.swift b/Sources/ExpandableText/ExpandableText.swift index 4347cb3..82750d8 100644 --- a/Sources/ExpandableText/ExpandableText.swift +++ b/Sources/ExpandableText/ExpandableText.swift @@ -126,6 +126,7 @@ public struct ExpandableText: View { .foregroundColor(buttonColor) } .buttonStyle(.plain) + .animation(.easeIn) } } .onAppear { From 81242070a391518cdb6785ef439aae7c3fe98bd9 Mon Sep 17 00:00:00 2001 From: jxhug Date: Sun, 25 Feb 2024 13:34:49 -0800 Subject: [PATCH 15/18] br Signed-off-by: jxhug --- Sources/ExpandableText/ExpandableText.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/ExpandableText/ExpandableText.swift b/Sources/ExpandableText/ExpandableText.swift index 82750d8..7448601 100644 --- a/Sources/ExpandableText/ExpandableText.swift +++ b/Sources/ExpandableText/ExpandableText.swift @@ -126,9 +126,10 @@ public struct ExpandableText: View { .foregroundColor(buttonColor) } .buttonStyle(.plain) - .animation(.easeIn) + .animation(.smooth) } } + .animation(.smooth) .onAppear { DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { // Show the button after a delay of 0.25 seconds From 041180c9156feb71c1c070c4c6bdf148bfee2f58 Mon Sep 17 00:00:00 2001 From: jxhug Date: Sun, 25 Feb 2024 13:36:39 -0800 Subject: [PATCH 16/18] stuff Signed-off-by: jxhug --- Sources/ExpandableText/ExpandableText.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/ExpandableText/ExpandableText.swift b/Sources/ExpandableText/ExpandableText.swift index 7448601..d1adbf5 100644 --- a/Sources/ExpandableText/ExpandableText.swift +++ b/Sources/ExpandableText/ExpandableText.swift @@ -112,6 +112,7 @@ public struct ExpandableText: View { .foregroundColor(buttonColor) } .buttonStyle(.plain) + .animation(.smooth, value: shouldShowMoreButton) } else if (isExpanded && !isTruncated) { VStack { if showLessButton { @@ -126,10 +127,9 @@ public struct ExpandableText: View { .foregroundColor(buttonColor) } .buttonStyle(.plain) - .animation(.smooth) } } - .animation(.smooth) + .animation(.smooth, value: showLessButton) .onAppear { DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { // Show the button after a delay of 0.25 seconds From 0ad6abfc96d0c0fe522fbbd58bd4576f3efb4620 Mon Sep 17 00:00:00 2001 From: jxhug Date: Sun, 25 Feb 2024 18:20:21 -0800 Subject: [PATCH 17/18] uhhh Signed-off-by: jxhug --- Sources/ExpandableText/ExpandableText.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/ExpandableText/ExpandableText.swift b/Sources/ExpandableText/ExpandableText.swift index d1adbf5..96b2408 100644 --- a/Sources/ExpandableText/ExpandableText.swift +++ b/Sources/ExpandableText/ExpandableText.swift @@ -130,6 +130,7 @@ public struct ExpandableText: View { } } .animation(.smooth, value: showLessButton) + .animation(.smooth, value: shouldShowMoreButton) .onAppear { DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { // Show the button after a delay of 0.25 seconds From 4ca1db1b46995af1ea694e0e1eced86c80c71f0f Mon Sep 17 00:00:00 2001 From: jxhug Date: Sun, 25 Feb 2024 18:21:55 -0800 Subject: [PATCH 18/18] 2 Signed-off-by: jxhug --- Sources/ExpandableText/ExpandableText.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/ExpandableText/ExpandableText.swift b/Sources/ExpandableText/ExpandableText.swift index 96b2408..439533c 100644 --- a/Sources/ExpandableText/ExpandableText.swift +++ b/Sources/ExpandableText/ExpandableText.swift @@ -139,6 +139,7 @@ public struct ExpandableText: View { } } })) + .animation(.smooth, value: shouldShowMoreButton) } private var content: some View {