some formatting stuff i guess

undo
saint 2024-05-16 16:08:52 -04:00
parent 4c484ccd90
commit 605c165523
1 changed files with 19 additions and 23 deletions

View File

@ -7,10 +7,11 @@
import GRDB import GRDB
import GRDBQuery import GRDBQuery
import SwiftUIIntrospect
import os import os
import SwiftUI import SwiftUI
import SwiftUIIntrospect
import WrappingHStack import WrappingHStack
let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "network") let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "network")
var currentId: String? var currentId: String?
@ -141,7 +142,6 @@ struct RibbonCrown: View {
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)) .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)
@ -203,40 +203,39 @@ private struct SegRow: View {
var ribbonId: Int64 var ribbonId: Int64
@State var highlights = Set<Int>() @State var highlights = Set<Int>()
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 = WrappingHStack(alignment: .leading, horizontalSpacing: 0) {
ForEach(0..<segSplit.count, id: \.self) { segIndex in ForEach(0 ..< segSplit.count, id: \.self) { segIndex in
let verse = try! decoder.decode(Verse.self, from: segSplit[segIndex].data(using: .utf8)!) let verse = try! decoder.decode(Verse.self, from: segSplit[segIndex].data(using: .utf8)!)
let arrayOfText = verse.body.components(separatedBy: " ") let arrayOfText = verse.body.components(separatedBy: " ")
let lineHeight = CGFloat(30) let lineHeight = CGFloat(30)
let fontSize = CGFloat(20) let fontSize = CGFloat(20)
let highlightColor = "470000" let highlightColor = "470000"
ForEach(0 ..< arrayOfText.count, id: \.self) { index in
ForEach(0..<arrayOfText.count, id: \.self) { index in HStack(spacing: 0) {
HStack (spacing: 0) {
if index == 0 { if index == 0 {
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.init(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.init(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.init(hex: highlightColor)) } .if(self.highlights.contains(verse.verse)) { $0.background(Color(hex: highlightColor)) }
} }
.if( self.highlights.contains(verse.verse) ) { $0.background(Color.init(hex: highlightColor)) } .if(self.highlights.contains(verse.verse)) { $0.background(Color(hex: highlightColor)) }
} }
} }
@ -244,12 +243,8 @@ private struct SegRow: View {
.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))
.padding(.horizontal, 1.5) // intra word spacing .padding(.horizontal, 1.5) // intra word spacing
.if(self.highlights.contains(verse.verse)) { $0.background(Color(hex: highlightColor)) }
.if( self.highlights.contains(verse.verse) ) { $0.background(Color.init(hex: highlightColor)) }
.foregroundColor(Color.white) .foregroundColor(Color.white)
.onTapGesture { .onTapGesture {
Print(arrayOfText[index]) Print(arrayOfText[index])
Print(verse.verse) Print(verse.verse)
@ -260,8 +255,9 @@ private struct SegRow: View {
} }
} }
} }
.frame(height:16) // intra line spacing .frame(height: 16) // intra line spacing
.padding(.vertical, 0) .padding(.vertical, 0)
// .if( index == 0 ) { $0.offset(x: -6) }
} }
} }
} }
@ -355,10 +351,10 @@ struct ContentView: View {
refresh: $refresh, refresh: $refresh,
draggedRibbon: draggedRibbon, draggedRibbon: draggedRibbon,
isDragging: isDragging) isDragging: isDragging)
.onDrag { .onDrag {
self.draggedRibbon = ribbon self.draggedRibbon = ribbon
return NSItemProvider() return NSItemProvider()
} }
.onDrop(of: [.item], .onDrop(of: [.item],
delegate: DropViewDelegate(destinationItem: ribbon, delegate: DropViewDelegate(destinationItem: ribbon,
draggedItem: $draggedRibbon, draggedItem: $draggedRibbon,
@ -493,7 +489,7 @@ struct ContentView: View {
} }
} }
} }
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { scrollView in Print("introspect") .introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { scrollView in Print("introspect")
// Print("Scroll delegate offset", scrollDelegate.scrollOffset) // Print("Scroll delegate offset", scrollDelegate.scrollOffset)
if setScrollOffset != nil { if setScrollOffset != nil {