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),
|
height: CGFloat(100 * scale),
|
||||||
alignment: .center
|
alignment: .center
|
||||||
).foregroundColor(Color(UIColor(red: 0.30, green: 0.30, blue: 0.30, alpha: 0.4)))
|
).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)) }
|
.if(draggedRibbon != nil && draggedRibbon!.id == ribbon.id && isDragging) { $0.overlay(Color(red: 0.1, green: 0.1, blue: 0.1)) }
|
||||||
|
|
||||||
// .offset(x: 10)
|
// .offset(x: 10)
|
||||||
|
@ -201,44 +203,29 @@ private struct SegRow: View {
|
||||||
var ribbonId: Int64
|
var ribbonId: Int64
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
var retView = Text("")
|
|
||||||
// .onTapGesture {
|
// var attributedString: AttributedString {
|
||||||
// // selectedLine = seg.id
|
// // var result = AttributedString("Hello World!")
|
||||||
// // Print(selectedLine)
|
// var result = AttributedString(verse.verse)
|
||||||
// Print("meow")
|
// // result.underlineStyle = Text.LineStyle(
|
||||||
// // Print(verse.body)
|
// // pattern: .dot, color: .white)
|
||||||
|
// return result
|
||||||
// }
|
// }
|
||||||
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 attributedString: AttributedString {
|
// retView = retView + Text(String(ribbonId))
|
||||||
// var result = AttributedString("Hello World!")
|
// // retView = retView + Text(attributedString)
|
||||||
var result = AttributedString(verse.body)
|
// // Text(seg.body)
|
||||||
// result.underlineStyle = Text.LineStyle(
|
// // .contentShape(Rectangle())
|
||||||
// pattern: .dot, color: .white)
|
// .font(Font.custom("AveriaSerifLibre-Regular", size: 10))
|
||||||
return result
|
// .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 +
|
||||||
// retView = retView + Text(attributedString)
|
// Text(attributedString)
|
||||||
// Text(seg.body)
|
// .foregroundColor(Color(UIColor(red: 0.76, green: 0.76, blue: 0.76, alpha: 1.00)))
|
||||||
// .contentShape(Rectangle())
|
// .font(Font.custom("AveriaSerifLibre-Regular", size: 20))
|
||||||
.font(Font.custom("AveriaSerifLibre-Regular", size: 10))
|
// // .frame(maxWidth: .infinity, alignment: .leading)
|
||||||
.baselineOffset(6.0)
|
// // .contentShape(Rectangle())
|
||||||
.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())
|
|
||||||
|
|
||||||
// .listRowBackground(Color(red: 0.2, green: 0.8, blue: 0.2))
|
// .listRowBackground(Color(red: 0.2, green: 0.8, blue: 0.2))
|
||||||
// .listRowInsets(EdgeInsets())
|
// .listRowInsets(EdgeInsets())
|
||||||
|
@ -257,24 +244,38 @@ private struct SegRow: View {
|
||||||
// selectedLine = seg.id
|
// selectedLine = seg.id
|
||||||
// Print(selectedLine)
|
// 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."
|
var segSplit = seg.body.components(separatedBy: ";;")
|
||||||
let arrayOfText = myText.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
|
ForEach(0..<arrayOfText.count, id: \.self) { index in
|
||||||
Text(arrayOfText[index])
|
HStack (spacing: 2) {
|
||||||
|
if index == 0 {
|
||||||
|
Text(String(verse.verse))
|
||||||
|
.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)))
|
.foregroundColor(Color(UIColor(red: 0.76, green: 0.76, blue: 0.76, alpha: 1.00)))
|
||||||
|
}
|
||||||
|
|
||||||
|
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))
|
.font(Font.custom("AveriaSerifLibre-Regular", size: 20))
|
||||||
|
|
||||||
|
|
||||||
.foregroundColor(Color.white)
|
.foregroundColor(Color.white)
|
||||||
// .background(Color.black)
|
|
||||||
.padding(.horizontal, 0)
|
.padding(.horizontal, 0)
|
||||||
|
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
|
@ -282,9 +283,15 @@ private struct SegRow: View {
|
||||||
Print(index)
|
Print(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// .if( index == 0 ) { $0.offset(x: -6) }
|
||||||
}
|
}
|
||||||
// return retView
|
|
||||||
return newView } }
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return retView
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
@State var viewState = CGSize.zero
|
@State var viewState = CGSize.zero
|
||||||
|
|
Loading…
Reference in New Issue