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,46 +14,63 @@ import WrappingHStack
struct SegRow: View { struct SegRow: View {
var seg: SegDenorm var seg: SegDenorm
var ribbonId: Int64 var ribbonId: Int64
var width: CGFloat
@State var highlights = Set<Int>() @State var highlights = Set<Int>()
@State var chapVisible = false
let intraWordSpacing = CGFloat(1.6) let intraWordSpacing = CGFloat(1.6)
var body: some View { var body: some 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: 0) { var retView = VStack {
ForEach(0 ..< segSplit.count, id: \.self) { segIndex in Text("\(seg.chap)")
.frame(width: width)
.padding(.vertical, 10)
let verse = try! decoder.decode(Verse.self, from: segSplit[segIndex].data(using: .utf8)!) .if(chapVisible) { $0.foregroundColor(mainTextColor) }
let arrayOfText = verse.body.components(separatedBy: " ") .if(!chapVisible) { $0.foregroundColor(secondBackgroundColor) }
let lineHeight = CGFloat(30) .font(Font.custom("AveriaSerifLibre-Regular", size: fontSize))
let fontSize = CGFloat(18) .background(secondBackgroundColor)
let highlightColor = "470000" // .background(mainBackgroundColor)
ForEach(0 ..< arrayOfText.count, id: \.self) { index in .onTapGesture {
HStack(spacing: 0) { chapVisible.toggle()
if index == 0 { }
Text("") 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)!)
let arrayOfText = verse.body.components(separatedBy: " ")
let lineHeight = CGFloat(30)
let fontSize = CGFloat(18)
let highlightColor = "470000"
ForEach(0 ..< arrayOfText.count, id: \.self) { index in
HStack(spacing: 0) {
if index == 0 {
Text("")
.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: fontSize)) .font(Font.custom("AveriaSerifLibre-Regular", size: fontSize))
.if(self.highlights.contains(verse.verse)) { $0.background(Color(hex: highlightColor)) } .if(self.highlights.contains(verse.verse)) { $0.background(Color(hex: highlightColor)) }
VStack(spacing: 0) { VStack(spacing: 0) {
ZStack { ZStack {
Text(" ") Text(" ")
.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: fontSize)) .font(Font.custom("AveriaSerifLibre-Regular", size: fontSize))
.if(self.highlights.contains(verse.verse)) { $0.background(Color(hex: highlightColor)) } .if(self.highlights.contains(verse.verse)) { $0.background(Color(hex: highlightColor)) }
Text(String(verse.verse)) Text(String(verse.verse))
.font(Font.custom("AveriaSerifLibre-Regular", size: 10)) .font(Font.custom("AveriaSerifLibre-Regular", size: 10))
.padding(.horizontal, 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.contains(verse.verse)) { $0.background(Color(hex: highlightColor)) } .if(self.highlights.contains(verse.verse)) { $0.background(Color(hex: highlightColor)) }
}
.if(self.highlights.contains(verse.verse)) { $0.background(Color(hex: highlightColor)) }
} }
.if(self.highlights.contains(verse.verse)) { $0.background(Color(hex: highlightColor)) }
} }
}
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: fontSize)) .font(Font.custom("AveriaSerifLibre-Regular", size: fontSize))
@ -69,9 +86,10 @@ struct SegRow: View {
self.highlights.insert(verse.verse) self.highlights.insert(verse.verse)
} }
} }
}
.frame(height: 16) // intra line spacing
.padding(.vertical, 0)
} }
.frame(height: 16) // intra line spacing
.padding(.vertical, 0)
} }
} }
} }
@ -104,10 +122,11 @@ struct Pane: View {
LazyVStack { LazyVStack {
ForEach(segs) { seg in ForEach(segs) { seg in
SegRow(seg: seg, SegRow(seg: seg,
ribbonId: selectedRibbon[0].id!) ribbonId: selectedRibbon[0].id!,
width: width)
.id("\(seg.id)") .id("\(seg.id)")
.offset(x: -dragOffset) .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)") .trackVisibility(id: "\(seg.id)")
} }
} }

View File

@ -11,6 +11,7 @@ struct SegDenorm: Identifiable, Equatable {
var body: String var body: String
// var lineIds: [Int64] // var lineIds: [Int64]
var book: String var book: String
var chap: Int64
} }
extension SegDenorm { extension SegDenorm {
@ -27,7 +28,7 @@ extension SegDenorm: Codable, FetchableRecord, MutablePersistableRecord {
// static let id = Column(CodingKeys.id) // static let id = Column(CodingKeys.id)
// static let book = Column(CodingKeys.book) // static let book = Column(CodingKeys.book)
// } // }
// /// Updates a player id after it has been inserted in the database. // /// Updates a player id after it has been inserted in the database.
// mutating func didInsert(_ inserted: InsertionSuccess) { // mutating func didInsert(_ inserted: InsertionSuccess) {
// id = inserted.rowID // id = inserted.rowID

View File

@ -43,7 +43,7 @@ struct SegDenormRequest: Queryable {
var book = ret[0].book var book = ret[0].book
var sql = """ 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 \ (select * from seg where seg.book = '\(book)') as seg \
join (select * from line where line.book = '\(book)') as line \ join (select * from line where line.book = '\(book)') as line \
on seg.line_id = line.line_id group by seg.seg_id on seg.line_id = line.line_id group by seg.seg_id

View File

@ -18,6 +18,11 @@ var currentOffset: CGFloat?
var disableDrop = false 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 { public extension UserDefaults {
func optionalInt(forKey defaultName: String) -> Int? { func optionalInt(forKey defaultName: String) -> Int? {
let defaults = self let defaults = self
@ -484,6 +489,8 @@ struct ContentView: View {
startSwipeState = nil startSwipeState = nil
startSwipeDir = nil startSwipeDir = nil
print("foo")
// if mainSwipe.width < 0 && pulledOut.width > 0 { // if mainSwipe.width < 0 && pulledOut.width > 0 {
// setPulledOutWith = CGFloat(0) // setPulledOutWith = CGFloat(0)
// } else if mainSwipe.width > 0 && pulledOut.width < 0 { // } else if mainSwipe.width > 0 && pulledOut.width < 0 {