Make the text selectable (for copying and lookup), after description is shown

This commit is contained in:
2024-02-25 11:42:45 +01:00
parent c81eb49364
commit 2bebe1e167

View File

@@ -14,20 +14,26 @@ struct WordView: View {
@EnvironmentObject var model: WordAXModelView @EnvironmentObject var model: WordAXModelView
@Environment(\.colorScheme) var colorScheme @Environment(\.colorScheme) var colorScheme
var body: some View { var body: some View {
let wordText = Text(word.name)
.font(.title)
.bold()
VStack { VStack {
Text(word.name)
.font(.title)
.bold()
if word.shown && word.lastSeenOn != nil { if word.shown && word.lastSeenOn != nil {
Text(model.getDateFormatter().string(from: word.lastSeenOn!)) Text(model.getDateFormatter().string(from: word.lastSeenOn!))
} }
if showDescription { if showDescription {
wordText
.textSelection(.enabled)
Divider() Divider()
.background(colorScheme == .light ? Color.black : Color.white) .background(colorScheme == .light ? Color.black : Color.white)
.padding(.horizontal) .padding(.horizontal)
Text(word.description) Text(word.description)
.multilineTextAlignment(.center) .multilineTextAlignment(.center)
} else {
wordText
} }
} }
.padding([.horizontal, .top]) .padding([.horizontal, .top])