chap number view prelim
							parent
							
								
									c04469ef19
								
							
						
					
					
						commit
						ac45ae5b20
					
				
							
								
								
									
										63
									
								
								Pane.swift
								
								
								
								
							
							
						
						
									
										63
									
								
								Pane.swift
								
								
								
								
							|  | @ -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)") | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|  | @ -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 { | ||||||
|  |  | ||||||
|  | @ -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 | ||||||
|  |  | ||||||
|  | @ -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 { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue