From fb7dd47a96825bf86a51febdcc2bbe3ac77f283c Mon Sep 17 00:00:00 2001 From: saint Date: Wed, 15 May 2024 14:20:01 -0400 Subject: [PATCH] Got it to render with the verse properly so you can click on a word and it will select it. Doing this for highlighting and other stuff --- gloss/ContentView.swift | 119 +++++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 56 deletions(-) diff --git a/gloss/ContentView.swift b/gloss/ContentView.swift index 3a98580..e004f7f 100644 --- a/gloss/ContentView.swift +++ b/gloss/ContentView.swift @@ -140,6 +140,8 @@ struct RibbonCrown: View { height: CGFloat(100 * scale), alignment: .center ).foregroundColor(Color(UIColor(red: 0.30, green: 0.30, blue: 0.30, alpha: 0.4))) + .contentShape(.dragPreview, RoundedRectangle(cornerRadius: 32)) + .if(draggedRibbon != nil && draggedRibbon!.id == ribbon.id && isDragging) { $0.overlay(Color(red: 0.1, green: 0.1, blue: 0.1)) } // .offset(x: 10) @@ -200,45 +202,30 @@ private struct SegRow: View { var seg: SegDenorm var ribbonId: Int64 - var body: some View { - var retView = Text("") - // .onTapGesture { - // // selectedLine = seg.id - // // Print(selectedLine) - // Print("meow") - // // Print(verse.body) - // } - var segSplit = seg.body.components(separatedBy: ";;") - let decoder = JSONDecoder() - // Text(segSplit[0].body) - // .id(seg.id) - // VStack { - // ForEach(segSplit.indices) { i in - segSplit.enumerated().forEach { _, item in - let verse = try! decoder.decode(Verse.self, from: item.data(using: .utf8)!) + var body: some View { - var attributedString: AttributedString { - // var result = AttributedString("Hello World!") - var result = AttributedString(verse.body) - // result.underlineStyle = Text.LineStyle( - // pattern: .dot, color: .white) - return result - } + // var attributedString: AttributedString { + // // var result = AttributedString("Hello World!") + // var result = AttributedString(verse.verse) + // // result.underlineStyle = Text.LineStyle( + // // pattern: .dot, color: .white) + // return result + // } - retView = retView + Text(String(ribbonId)) - // retView = retView + Text(attributedString) - // Text(seg.body) - // .contentShape(Rectangle()) - .font(Font.custom("AveriaSerifLibre-Regular", size: 10)) - .baselineOffset(6.0) - .foregroundColor(Color(UIColor(red: 0.76, green: 0.76, blue: 0.76, alpha: 1.00))) + // retView = retView + Text(String(ribbonId)) + // // retView = retView + Text(attributedString) + // // Text(seg.body) + // // .contentShape(Rectangle()) + // .font(Font.custom("AveriaSerifLibre-Regular", size: 10)) + // .baselineOffset(6.0) + // .foregroundColor(Color(UIColor(red: 0.76, green: 0.76, blue: 0.76, alpha: 1.00))) - retView = retView + - Text(attributedString) - .foregroundColor(Color(UIColor(red: 0.76, green: 0.76, blue: 0.76, alpha: 1.00))) - .font(Font.custom("AveriaSerifLibre-Regular", size: 20)) - // .frame(maxWidth: .infinity, alignment: .leading) - // .contentShape(Rectangle()) + // retView = retView + + // Text(attributedString) + // .foregroundColor(Color(UIColor(red: 0.76, green: 0.76, blue: 0.76, alpha: 1.00))) + // .font(Font.custom("AveriaSerifLibre-Regular", size: 20)) + // // .frame(maxWidth: .infinity, alignment: .leading) + // // .contentShape(Rectangle()) // .listRowBackground(Color(red: 0.2, green: 0.8, blue: 0.2)) // .listRowInsets(EdgeInsets()) @@ -257,34 +244,54 @@ private struct SegRow: View { // selectedLine = seg.id // Print(selectedLine) // } - } - // } - let myText = "There was a man sent from God, whose name was John. This man came for a witness, to give testimony of the light, that all men might believe through him. He was not the light, but was to give testimony of the light. That was the true light, which enlighteneth every man that cometh into this world. He was in the world, and the world was made by him, and the world knew him not." - let arrayOfText = myText.components(separatedBy: " ") + var segSplit = seg.body.components(separatedBy: ";;") + let decoder = JSONDecoder() + var retView = WrappingHStack(alignment: .leading, horizontalSpacing: 3.5) { + + // segSplit.enumerated().forEach { _, item in + ForEach(0..