Show title pane working with showing chapter
switched to observedobj from binding as it works betterfix_swipe
parent
ac45ae5b20
commit
495b052db0
20
Pane.swift
20
Pane.swift
|
@ -16,7 +16,7 @@ struct SegRow: View {
|
||||||
var ribbonId: Int64
|
var ribbonId: Int64
|
||||||
var width: CGFloat
|
var width: CGFloat
|
||||||
@State var highlights = Set<Int>()
|
@State var highlights = Set<Int>()
|
||||||
@State var chapVisible = false
|
@ObservedObject var showTitle: ShowTitle
|
||||||
|
|
||||||
|
|
||||||
let intraWordSpacing = CGFloat(1.6)
|
let intraWordSpacing = CGFloat(1.6)
|
||||||
|
@ -28,14 +28,14 @@ struct SegRow: View {
|
||||||
.frame(width: width)
|
.frame(width: width)
|
||||||
.padding(.vertical, 10)
|
.padding(.vertical, 10)
|
||||||
|
|
||||||
.if(chapVisible) { $0.foregroundColor(mainTextColor) }
|
.if(showTitle.chapVisible) { $0.foregroundColor(mainTextColor) }
|
||||||
.if(!chapVisible) { $0.foregroundColor(secondBackgroundColor) }
|
.if(!showTitle.chapVisible) { $0.foregroundColor(secondBackgroundColor) }
|
||||||
|
|
||||||
.font(Font.custom("AveriaSerifLibre-Regular", size: fontSize))
|
.font(Font.custom("AveriaSerifLibre-Regular", size: fontSize))
|
||||||
.background(secondBackgroundColor)
|
.background(secondBackgroundColor)
|
||||||
// .background(mainBackgroundColor)
|
// .background(mainBackgroundColor)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
chapVisible.toggle()
|
showTitle.chapVisible.toggle()
|
||||||
}
|
}
|
||||||
WrappingHStack(alignment: .leading, horizontalSpacing: 0) {
|
WrappingHStack(alignment: .leading, horizontalSpacing: 0) {
|
||||||
ForEach(0 ..< segSplit.count, id: \.self) { segIndex in
|
ForEach(0 ..< segSplit.count, id: \.self) { segIndex in
|
||||||
|
@ -97,21 +97,29 @@ struct SegRow: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ShowTitle: NSObject, ObservableObject {
|
||||||
|
@Published var chapVisible = false
|
||||||
|
}
|
||||||
|
|
||||||
struct Pane: View {
|
struct Pane: View {
|
||||||
@ObservedObject var paneConnector: PaneConnector
|
@ObservedObject var paneConnector: PaneConnector
|
||||||
|
@StateObject var showTitle = ShowTitle()
|
||||||
|
|
||||||
|
// @State var chapVisible = false
|
||||||
|
|
||||||
@State var selectedRibbon: [Ribbon]
|
@State var selectedRibbon: [Ribbon]
|
||||||
|
|
||||||
@State var width: CGFloat
|
@State var width: CGFloat
|
||||||
@State var height: CGFloat
|
@State var height: CGFloat
|
||||||
|
|
||||||
|
|
||||||
var dragOffset = CGFloat()
|
var dragOffset = CGFloat()
|
||||||
|
|
||||||
@State var refresh: Bool = false
|
@State var refresh: Bool = false
|
||||||
|
|
||||||
@Query(SegDenormRequest(book: "bible.mark")) private var segs: [SegDenorm]
|
@Query(SegDenormRequest(book: "bible.mark")) private var segs: [SegDenorm]
|
||||||
|
|
||||||
|
|
||||||
@Environment(\.appDatabase) private var appDatabase
|
@Environment(\.appDatabase) private var appDatabase
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
@ -123,7 +131,9 @@ struct Pane: View {
|
||||||
ForEach(segs) { seg in
|
ForEach(segs) { seg in
|
||||||
SegRow(seg: seg,
|
SegRow(seg: seg,
|
||||||
ribbonId: selectedRibbon[0].id!,
|
ribbonId: selectedRibbon[0].id!,
|
||||||
width: width)
|
width: width,
|
||||||
|
showTitle: showTitle
|
||||||
|
)
|
||||||
.id("\(seg.id)")
|
.id("\(seg.id)")
|
||||||
.offset(x: -dragOffset)
|
.offset(x: -dragOffset)
|
||||||
.padding(EdgeInsets(top: 10, leading: 20, bottom: 20, trailing: 20))
|
.padding(EdgeInsets(top: 10, leading: 20, bottom: 20, trailing: 20))
|
||||||
|
|
Loading…
Reference in New Issue