mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-24 23:45:18 +00:00
Notes icon: turn blue immediately when sheet shows notes by passing count up from sheet (closure) and OR-ing with counter; reset on sheet close
This commit is contained in:
@@ -52,6 +52,7 @@ struct ContentView: View {
|
|||||||
@State private var expandedMessageIDs: Set<String> = []
|
@State private var expandedMessageIDs: Set<String> = []
|
||||||
@State private var showLocationNotes = false
|
@State private var showLocationNotes = false
|
||||||
@State private var notesGeohash: String? = nil
|
@State private var notesGeohash: String? = nil
|
||||||
|
@State private var sheetNotesCount: Int = 0
|
||||||
// Timer-based refresh removed; use LocationChannelManager live updates instead
|
// Timer-based refresh removed; use LocationChannelManager live updates instead
|
||||||
// Window sizes for rendering (infinite scroll up)
|
// Window sizes for rendering (infinite scroll up)
|
||||||
@State private var windowCountPublic: Int = 300
|
@State private var windowCountPublic: Int = 300
|
||||||
@@ -1185,7 +1186,7 @@ struct ContentView: View {
|
|||||||
showLocationNotes = true
|
showLocationNotes = true
|
||||||
}) {
|
}) {
|
||||||
HStack(alignment: .center, spacing: 4) {
|
HStack(alignment: .center, spacing: 4) {
|
||||||
let hasNotes = (notesCounter.count ?? 0) > 0
|
let hasNotes = ((notesCounter.count ?? 0) > 0) || (sheetNotesCount > 0)
|
||||||
Image(systemName: "long.text.page.and.pencil")
|
Image(systemName: "long.text.page.and.pencil")
|
||||||
.font(.system(size: 12))
|
.font(.system(size: 12))
|
||||||
.foregroundColor(hasNotes ? Color(hue: 0.60, saturation: 0.85, brightness: 0.82) : Color.gray)
|
.foregroundColor(hasNotes ? Color(hue: 0.60, saturation: 0.85, brightness: 0.82) : Color.gray)
|
||||||
@@ -1234,7 +1235,7 @@ struct ContentView: View {
|
|||||||
.sheet(isPresented: $showLocationNotes) {
|
.sheet(isPresented: $showLocationNotes) {
|
||||||
Group {
|
Group {
|
||||||
if let gh = notesGeohash ?? LocationChannelManager.shared.availableChannels.first(where: { $0.level == .building })?.geohash {
|
if let gh = notesGeohash ?? LocationChannelManager.shared.availableChannels.first(where: { $0.level == .building })?.geohash {
|
||||||
LocationNotesView(geohash: gh)
|
LocationNotesView(geohash: gh, onNotesCountChanged: { cnt in sheetNotesCount = cnt })
|
||||||
.environmentObject(viewModel)
|
.environmentObject(viewModel)
|
||||||
} else {
|
} else {
|
||||||
VStack(spacing: 12) {
|
VStack(spacing: 12) {
|
||||||
@@ -1276,6 +1277,7 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
.onDisappear {
|
.onDisappear {
|
||||||
LocationChannelManager.shared.endLiveRefresh()
|
LocationChannelManager.shared.endLiveRefresh()
|
||||||
|
sheetNotesCount = 0
|
||||||
}
|
}
|
||||||
.onChange(of: locationManager.availableChannels) { channels in
|
.onChange(of: locationManager.availableChannels) { channels in
|
||||||
if let current = channels.first(where: { $0.level == .building })?.geohash,
|
if let current = channels.first(where: { $0.level == .building })?.geohash,
|
||||||
|
|||||||
@@ -4,15 +4,17 @@ struct LocationNotesView: View {
|
|||||||
@EnvironmentObject var viewModel: ChatViewModel
|
@EnvironmentObject var viewModel: ChatViewModel
|
||||||
@StateObject private var manager: LocationNotesManager
|
@StateObject private var manager: LocationNotesManager
|
||||||
let geohash: String
|
let geohash: String
|
||||||
|
let onNotesCountChanged: ((Int) -> Void)?
|
||||||
|
|
||||||
@Environment(\.colorScheme) var colorScheme
|
@Environment(\.colorScheme) var colorScheme
|
||||||
@ObservedObject private var locationManager = LocationChannelManager.shared
|
@ObservedObject private var locationManager = LocationChannelManager.shared
|
||||||
@Environment(\.dismiss) private var dismiss
|
@Environment(\.dismiss) private var dismiss
|
||||||
@State private var draft: String = ""
|
@State private var draft: String = ""
|
||||||
|
|
||||||
init(geohash: String) {
|
init(geohash: String, onNotesCountChanged: ((Int) -> Void)? = nil) {
|
||||||
let gh = geohash.lowercased()
|
let gh = geohash.lowercased()
|
||||||
self.geohash = gh
|
self.geohash = gh
|
||||||
|
self.onNotesCountChanged = onNotesCountChanged
|
||||||
_manager = StateObject(wrappedValue: LocationNotesManager(geohash: gh))
|
_manager = StateObject(wrappedValue: LocationNotesManager(geohash: gh))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,6 +42,10 @@ struct LocationNotesView: View {
|
|||||||
.onChange(of: geohash) { newValue in
|
.onChange(of: geohash) { newValue in
|
||||||
manager.setGeohash(newValue)
|
manager.setGeohash(newValue)
|
||||||
}
|
}
|
||||||
|
.onAppear { onNotesCountChanged?(manager.notes.count) }
|
||||||
|
.onChange(of: manager.notes.count) { newValue in
|
||||||
|
onNotesCountChanged?(newValue)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var header: some View {
|
private var header: some View {
|
||||||
|
|||||||
Reference in New Issue
Block a user