HighlightDraftContentView.swift (1249B)
1 // 2 // HighlightDraftContentView.swift 3 // damus 4 // 5 // Created by eric on 5/26/24. 6 // 7 8 import SwiftUI 9 10 struct HighlightDraftContentView: View { 11 let draft: HighlightContentDraft 12 13 var body: some View { 14 VStack(alignment: .leading, spacing: 10) { 15 HStack { 16 var attributedString: AttributedString { 17 var attributedString = AttributedString(draft.selected_text) 18 19 if let range = attributedString.range(of: draft.selected_text) { 20 attributedString[range].backgroundColor = DamusColors.highlight 21 } 22 23 return attributedString 24 } 25 26 Text(attributedString) 27 .lineSpacing(5) 28 .padding(10) 29 } 30 .overlay( 31 RoundedRectangle(cornerRadius: 25).fill(DamusColors.highlight).frame(width: 4), 32 alignment: .leading 33 ) 34 35 if case .external_url(let url) = draft.source { 36 LinkViewRepresentable(meta: .url(url)) 37 .frame(height: 50) 38 39 } 40 } 41 } 42 }