good progress on highlighting verses

undo
saint 2024-05-16 11:39:38 -04:00
parent fb7dd47a96
commit f107e746b8
1 changed files with 47 additions and 9 deletions

View File

@ -201,6 +201,7 @@ func makeVerseView(seg: SegDenorm) -> some View {
private struct SegRow: View { private struct SegRow: View {
var seg: SegDenorm var seg: SegDenorm
var ribbonId: Int64 var ribbonId: Int64
@State var highlights = 0
var body: some View { var body: some View {
@ -247,7 +248,8 @@ private struct SegRow: View {
var segSplit = seg.body.components(separatedBy: ";;") var segSplit = seg.body.components(separatedBy: ";;")
let decoder = JSONDecoder() let decoder = JSONDecoder()
var retView = WrappingHStack(alignment: .leading, horizontalSpacing: 3.5) { // var retView = WrappingHStack(alignment: .leading, horizontalSpacing: 3.5) {
var retView = WrappingHStack(alignment: .leading, horizontalSpacing: 0) {
// segSplit.enumerated().forEach { _, item in // segSplit.enumerated().forEach { _, item in
ForEach(0..<segSplit.count, id: \.self) { segIndex in ForEach(0..<segSplit.count, id: \.self) { segIndex in
@ -259,30 +261,66 @@ private struct SegRow: View {
let lineHeight = CGFloat(30)
let fontSize = CGFloat(20)
ForEach(0..<arrayOfText.count, id: \.self) { index in ForEach(0..<arrayOfText.count, id: \.self) { index in
HStack (spacing: 2) { HStack (spacing: 0) {
if index == 0 { if index == 0 {
Text("")
.foregroundColor(Color(UIColor(red: 0.76, green: 0.76, blue: 0.76, alpha: 1.00)))
.font(Font.custom("AveriaSerifLibre-Regular", size: fontSize))
.if( self.highlights == verse.verse ) { $0.background(Color.blue) }
// Rectangle()
// .if( self.highlights == verse.verse ) { $0.fill(.blue) }
// .frame(width: 2)
// .frame(height:lineHeight)
// .if( self.highlights != verse.verse ) { $0.opacity(0) }
VStack (spacing: 0) {
// Rectangle()
// .fill(.blue)
// .frame(width: 6, height: 1)
// // .if( self.highlights == verse.verse ) { $0.opacity(1.0) }
// // .if( self.highlights != verse.verse ) { $0.opacity(0.0) }
ZStack {
Text(" ")
.foregroundColor(Color(UIColor(red: 0.76, green: 0.76, blue: 0.76, alpha: 1.00)))
.font(Font.custom("AveriaSerifLibre-Regular", size: fontSize))
.if( self.highlights == verse.verse ) { $0.background(Color.blue) }
Text(String(verse.verse)) Text(String(verse.verse))
.contentShape(Rectangle()) .contentShape(Rectangle())
.font(Font.custom("AveriaSerifLibre-Regular", size: 10)) .font(Font.custom("AveriaSerifLibre-Regular", size: 10))
.baselineOffset(6.0) .padding(.horizontal, 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)))
.if( self.highlights == verse.verse ) { $0.background(Color.blue) }
}
.if( self.highlights == verse.verse ) { $0.background(Color.blue) }
}
} }
Text(arrayOfText[index]) Text(arrayOfText[index])
.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)))
.font(Font.custom("AveriaSerifLibre-Regular", size: 20)) .font(Font.custom("AveriaSerifLibre-Regular", size: fontSize))
.padding(.horizontal, 1.5) // intra word spacing
.if( self.highlights == verse.verse ) { $0.background(Color.blue) }
.foregroundColor(Color.white) .foregroundColor(Color.white)
.padding(.horizontal, 0)
.onTapGesture { .onTapGesture {
Print(arrayOfText[index]) Print(arrayOfText[index])
Print(index) Print(verse.verse)
self.highlights = verse.verse
} }
} }
.frame(height:16) // intra line spacing
.padding(.vertical, 0)
// .if( index == 0 ) { $0.offset(x: -6) } // .if( index == 0 ) { $0.offset(x: -6) }
} }