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
parent
9550790a17
commit
fb7dd47a96
|
@ -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..<segSplit.count, id: \.self) { segIndex in
|
||||
|
||||
|
||||
let verse = try! decoder.decode(Verse.self, from: segSplit[segIndex].data(using: .utf8)!)
|
||||
let arrayOfText = verse.body.components(separatedBy: " ")
|
||||
|
||||
|
||||
|
||||
var wordSelected = ""
|
||||
var newView = WrappingHStack(alignment: .leading, horizontalSpacing: 3.5) {
|
||||
ForEach(0..<arrayOfText.count, id: \.self) { index in
|
||||
Text(arrayOfText[index])
|
||||
|
||||
.foregroundColor(Color(UIColor(red: 0.76, green: 0.76, blue: 0.76, alpha: 1.00)))
|
||||
.font(Font.custom("AveriaSerifLibre-Regular", size: 20))
|
||||
ForEach(0..<arrayOfText.count, id: \.self) { index in
|
||||
HStack (spacing: 2) {
|
||||
if index == 0 {
|
||||
Text(String(verse.verse))
|
||||
.contentShape(Rectangle())
|
||||
.font(Font.custom("AveriaSerifLibre-Regular", size: 10))
|
||||
.baselineOffset(6.0)
|
||||
|
||||
.foregroundColor(Color.white)
|
||||
// .background(Color.black)
|
||||
.padding(.horizontal, 0)
|
||||
.foregroundColor(Color(UIColor(red: 0.76, green: 0.76, blue: 0.76, alpha: 1.00)))
|
||||
}
|
||||
|
||||
.onTapGesture {
|
||||
Print(arrayOfText[index])
|
||||
Print(index)
|
||||
Text(arrayOfText[index])
|
||||
.foregroundColor(Color(UIColor(red: 0.76, green: 0.76, blue: 0.76, alpha: 1.00)))
|
||||
.font(Font.custom("AveriaSerifLibre-Regular", size: 20))
|
||||
|
||||
|
||||
.foregroundColor(Color.white)
|
||||
.padding(.horizontal, 0)
|
||||
|
||||
.onTapGesture {
|
||||
Print(arrayOfText[index])
|
||||
Print(index)
|
||||
}
|
||||
}
|
||||
// .if( index == 0 ) { $0.offset(x: -6) }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// return retView
|
||||
return newView } }
|
||||
return retView
|
||||
}
|
||||
}
|
||||
|
||||
struct ContentView: View {
|
||||
@State var viewState = CGSize.zero
|
||||
|
@ -372,10 +379,10 @@ struct ContentView: View {
|
|||
refresh: $refresh,
|
||||
draggedRibbon: draggedRibbon,
|
||||
isDragging: isDragging)
|
||||
.onDrag {
|
||||
.onDrag {
|
||||
self.draggedRibbon = ribbon
|
||||
return NSItemProvider()
|
||||
}
|
||||
}
|
||||
.onDrop(of: [.item],
|
||||
delegate: DropViewDelegate(destinationItem: ribbon,
|
||||
draggedItem: $draggedRibbon,
|
||||
|
|
Loading…
Reference in New Issue