Add option to re-hide spoiler content after expanding (#20)

* Add option to re-hide spoiler content after expanding

Uses the same logic as the "Show more" button, but in reverse. This allows a user to hide the content that they expanded.

* Use .toggle() method instead of multiple if statements
This commit is contained in:
Tyler Baker 2023-01-03 10:44:11 -06:00 committed by GitHub
parent 5fe72e36d2
commit e9991020ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -139,17 +139,16 @@ public struct StatusRowView: View {
if !viewModel.status.spoilerText.isEmpty {
Text(status.spoilerText)
.font(.body)
}
if viewModel.displaySpoiler {
Button {
withAnimation {
viewModel.displaySpoiler = false
viewModel.displaySpoiler.toggle()
}
} label: {
Text("Show more")
Text(viewModel.displaySpoiler ? "Show more" : "Show less")
}
.buttonStyle(.bordered)
} else {
}
if !viewModel.displaySpoiler {
Text(status.content.asSafeAttributedString)
.font(.body)
.environment(\.openURL, OpenURLAction { url in