mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-26 11:25:20 +00:00
cooler
This commit is contained in:
@@ -22,7 +22,7 @@ import com.bitchat.android.nostr.LocationNotesManager
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Location Notes button component for MainHeader
|
* Location Notes button component for MainHeader
|
||||||
* Displays when in mesh mode and location permission is granted
|
* Shows in mesh mode when location permission granted AND services enabled
|
||||||
* Icon turns primary color when notes exist, gray otherwise
|
* Icon turns primary color when notes exist, gray otherwise
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
@@ -38,7 +38,11 @@ fun LocationNotesButton(
|
|||||||
val selectedLocationChannel by viewModel.selectedLocationChannel.observeAsState()
|
val selectedLocationChannel by viewModel.selectedLocationChannel.observeAsState()
|
||||||
val locationManager = remember { LocationChannelManager.getInstance(context) }
|
val locationManager = remember { LocationChannelManager.getInstance(context) }
|
||||||
val permissionState by locationManager.permissionState.observeAsState()
|
val permissionState by locationManager.permissionState.observeAsState()
|
||||||
|
val locationServicesEnabled by locationManager.locationServicesEnabled.observeAsState(false)
|
||||||
|
|
||||||
|
// Check both permission AND location services enabled
|
||||||
val locationPermissionGranted = permissionState == LocationChannelManager.PermissionState.AUTHORIZED
|
val locationPermissionGranted = permissionState == LocationChannelManager.PermissionState.AUTHORIZED
|
||||||
|
val locationEnabled = locationPermissionGranted && locationServicesEnabled
|
||||||
|
|
||||||
// Get notes count from LocationNotesManager
|
// Get notes count from LocationNotesManager
|
||||||
val notesManager = remember { LocationNotesManager.getInstance() }
|
val notesManager = remember { LocationNotesManager.getInstance() }
|
||||||
@@ -46,7 +50,7 @@ fun LocationNotesButton(
|
|||||||
val notesCount = notes.size
|
val notesCount = notes.size
|
||||||
|
|
||||||
// Only show in mesh mode when location is authorized (iOS pattern)
|
// Only show in mesh mode when location is authorized (iOS pattern)
|
||||||
if (selectedLocationChannel is ChannelID.Mesh && locationPermissionGranted) {
|
if (selectedLocationChannel is ChannelID.Mesh && locationEnabled) {
|
||||||
val hasNotes = (notesCount ?: 0) > 0
|
val hasNotes = (notesCount ?: 0) > 0
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
|
|||||||
Reference in New Issue
Block a user