chap number view prelim

fix_swipe
saint 2024-06-12 12:19:30 -04:00
parent c04469ef19
commit ac45ae5b20
4 changed files with 51 additions and 24 deletions

View File

@ -14,13 +14,30 @@ import WrappingHStack
struct SegRow: View {
var seg: SegDenorm
var ribbonId: Int64
var width: CGFloat
@State var highlights = Set<Int>()
@State var chapVisible = false
let intraWordSpacing = CGFloat(1.6)
var body: some View {
var segSplit = seg.body.components(separatedBy: ";;")
let decoder = JSONDecoder()
var retView = WrappingHStack(alignment: .leading, horizontalSpacing: 0) {
var retView = VStack {
Text("\(seg.chap)")
.frame(width: width)
.padding(.vertical, 10)
.if(chapVisible) { $0.foregroundColor(mainTextColor) }
.if(!chapVisible) { $0.foregroundColor(secondBackgroundColor) }
.font(Font.custom("AveriaSerifLibre-Regular", size: fontSize))
.background(secondBackgroundColor)
// .background(mainBackgroundColor)
.onTapGesture {
chapVisible.toggle()
}
WrappingHStack(alignment: .leading, horizontalSpacing: 0) {
ForEach(0 ..< segSplit.count, id: \.self) { segIndex in
let verse = try! decoder.decode(Verse.self, from: segSplit[segIndex].data(using: .utf8)!)
@ -75,6 +92,7 @@ struct SegRow: View {
}
}
}
}
return retView
}
}
@ -104,10 +122,11 @@ struct Pane: View {
LazyVStack {
ForEach(segs) { seg in
SegRow(seg: seg,
ribbonId: selectedRibbon[0].id!)
ribbonId: selectedRibbon[0].id!,
width: width)
.id("\(seg.id)")
.offset(x: -dragOffset)
.padding(EdgeInsets(top: 10, leading: 20, bottom: 40, trailing: 20))
.padding(EdgeInsets(top: 10, leading: 20, bottom: 20, trailing: 20))
.trackVisibility(id: "\(seg.id)")
}
}

View File

@ -11,6 +11,7 @@ struct SegDenorm: Identifiable, Equatable {
var body: String
// var lineIds: [Int64]
var book: String
var chap: Int64
}
extension SegDenorm {

View File

@ -43,7 +43,7 @@ struct SegDenormRequest: Queryable {
var book = ret[0].book
var sql = """
select seg_id as id, seg.book as book, group_concat(line.body, ';;') as body from \
select seg_id as id, line.chap as chap, seg.book as book, group_concat(line.body, ';;') as body from \
(select * from seg where seg.book = '\(book)') as seg \
join (select * from line where line.book = '\(book)') as line \
on seg.line_id = line.line_id group by seg.seg_id

View File

@ -18,6 +18,11 @@ var currentOffset: CGFloat?
var disableDrop = false
//TODO: move to globals file
let mainBackgroundColor = Color(red: 0.1, green: 0.1, blue: 0.1)
let mainTextColor = Color(UIColor(red: 0.76, green: 0.76, blue: 0.76, alpha: 1.00))
let secondBackgroundColor = Color(red: 0.18, green: 0.18, blue: 0.18)
public extension UserDefaults {
func optionalInt(forKey defaultName: String) -> Int? {
let defaults = self
@ -484,6 +489,8 @@ struct ContentView: View {
startSwipeState = nil
startSwipeDir = nil
print("foo")
// if mainSwipe.width < 0 && pulledOut.width > 0 {
// setPulledOutWith = CGFloat(0)
// } else if mainSwipe.width > 0 && pulledOut.width < 0 {