diff --git a/Pane.swift b/Pane.swift index 013616d..030a239 100644 --- a/Pane.swift +++ b/Pane.swift @@ -16,7 +16,7 @@ struct SegRow: View { var ribbonId: Int64 var width: CGFloat @State var highlights = Set() - @State var chapVisible = false + @ObservedObject var showTitle: ShowTitle let intraWordSpacing = CGFloat(1.6) @@ -28,14 +28,14 @@ struct SegRow: View { .frame(width: width) .padding(.vertical, 10) - .if(chapVisible) { $0.foregroundColor(mainTextColor) } - .if(!chapVisible) { $0.foregroundColor(secondBackgroundColor) } + .if(showTitle.chapVisible) { $0.foregroundColor(mainTextColor) } + .if(!showTitle.chapVisible) { $0.foregroundColor(secondBackgroundColor) } .font(Font.custom("AveriaSerifLibre-Regular", size: fontSize)) .background(secondBackgroundColor) // .background(mainBackgroundColor) .onTapGesture { - chapVisible.toggle() + showTitle.chapVisible.toggle() } WrappingHStack(alignment: .leading, horizontalSpacing: 0) { 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 { @ObservedObject var paneConnector: PaneConnector + @StateObject var showTitle = ShowTitle() + + // @State var chapVisible = false @State var selectedRibbon: [Ribbon] @State var width: CGFloat @State var height: CGFloat + var dragOffset = CGFloat() @State var refresh: Bool = false @Query(SegDenormRequest(book: "bible.mark")) private var segs: [SegDenorm] + @Environment(\.appDatabase) private var appDatabase var body: some View { @@ -123,7 +131,9 @@ struct Pane: View { ForEach(segs) { seg in SegRow(seg: seg, ribbonId: selectedRibbon[0].id!, - width: width) + width: width, + showTitle: showTitle + ) .id("\(seg.id)") .offset(x: -dragOffset) .padding(EdgeInsets(top: 10, leading: 20, bottom: 20, trailing: 20))