findfamily: drop the map top bar for an overlay menu (#680)
- Commit
5a0881f8996f1109129763472cce6be1a607e3ee- Author
- vayun-mathur <[email protected]>
- When
- 2026-09-11 17:13 UTC (2 months ago)
- Parents
3c38e28
Diff
findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPage.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPage.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPage.ktindex 784f7642fd..f5a5c9231c 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPage.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPage.kt@@ -61,7 +61,9 @@ import com.vayunmathur.library.ui.SheetValue import com.vayunmathur.library.ui.Switch import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.ToggleFloatingActionButton-import com.vayunmathur.library.ui.TopAppBar+import com.vayunmathur.library.ui.OverlayAction+import com.vayunmathur.library.ui.Spacing+import com.vayunmathur.library.ui.TopAppBarOverlay import com.vayunmathur.library.ui.dynamicLightColorScheme import com.vayunmathur.library.ui.rememberBottomSheetScaffoldState import com.vayunmathur.library.ui.rememberMessenger@@ -129,7 +131,7 @@ import com.vayunmathur.library.ui.IconClose import com.vayunmathur.library.ui.IconCopy import com.vayunmathur.library.ui.IconDelete import com.vayunmathur.library.ui.IconEdit-import com.vayunmathur.library.ui.IconNavigation+import com.vayunmathur.library.ui.IconMoreVert import com.vayunmathur.library.ui.IconNavigationArrow import com.vayunmathur.library.ui.IconRestore import com.vayunmathur.library.ui.IconVerify@@ -406,9 +408,9 @@ fun MainPage( } /**- * The stateless map-page layout: the [BottomSheetScaffold] (top bar + sheet) with a- * full-bleed [map] slot and the floating action button on top. It reads only [state] and- * calls back through [actions]/[familyActions]/[personActions], so both the real app (via+ * The stateless map-page layout: the [BottomSheetScaffold] sheet with a full-bleed [map] slot+ * and the floating chrome (overlay bar, floating action button) on top. It reads only [state]+ * and calls back through [actions]/[familyActions]/[personActions], so both the real app (via * the [MainPage] wrapper) and the store-listing previews render the *same* page — the app * injects the live [MapView] into [map], the previews inject a static backdrop. *@@ -498,68 +500,8 @@ fun MainPageContent( sheetSwipeEnabled = !state.historyMode, sheetDragHandle = if (state.historyMode) null else { { BottomSheetDefaults.DragHandle() } }, sheetContainerColor = MaterialTheme.colorScheme.surfaceContainerLow,- // Default (solid) app bar so the map stays cut off beneath it while panning.- topBar = {- TopAppBar(- title = {- if (state.historyMode) {- Text(stringResource(R.string.history_title, state.selectedUser?.name ?: ""))- } else if (state.nothingSelected) {- Text(stringResource(R.string.app_name))- }- },- navigationIcon = {- if (state.selectedUserId != null || state.selectedWaypointId != null) {- IconNavigation {- if (state.historyMode) {- actions.setShowingPresent(true)- } else {- actions.clearSelection()- }- }- }- },- actions = {- if (state.selectedUserId == null &&- (state.selectedWaypointId == null || state.selectedWaypointId == 0L)) {- if (state.usingGpsFallback) {- IconButton({ actions.onGpsWarningClick() }) {- // Use Image (not the tinting IconWarning) so the- // custom yellow-and-red drawable keeps both colors.- Image(- painter = painterResource(R.drawable.ic_warning_gps),- contentDescription = stringResource(- R.string.gps_fallback_warning_content_description- )- )- }- }- backupButtons()- } else if (state.selectedUserId != null && !state.historyMode) {- if (!state.isSelfSelected) {- // Find Nearby (UWB) needs both the public- // android.ranging API (Android 16+) and an actual- // UWB radio. Hide the entry point otherwise.- if (state.uwbAvailable) {- IconButton({ actions.openUwbRanging(state.selectedUserId) }) {- IconNavigationArrow()- }- }- IconButton({ actions.onShowSecurityCode() }) {- IconVerify()- }- IconButton({ actions.deleteSelectedUser() }) {- IconDelete()- }- }- } else if (state.selectedWaypointId != null && state.selectedWaypointId != 0L) {- IconButton({ actions.deleteSelectedWaypoint() }) {- IconDelete()- }- }- }- )- },+ // No top bar: the chrome floats over the map as a TopAppBarOverlay in the content+ // slot below, so the map gets the whole window (GitHub #680). sheetContent = { // The sheet's own content MUST be taller than the peek, or Material3 emits a single // anchor and the scaffold crashes.@@ -577,7 +519,7 @@ fun MainPageContent( if (state.nothingSelected) { FamilyListSheet(state.familyList, familyActions) } else if (state.historyMode) {- // History mode has no sheet; the name is shown in the app bar.+ // History mode has no sheet; the name is shown in the map overlay. } else if (state.selectedUserId != null) { state.person?.let { PersonDetailSheet(it, personActions) } } else if (state.selectedWaypointId != null) {@@ -624,6 +566,15 @@ fun MainPageContent( map() + // The chrome that used to be the top bar, floating over the map instead. Colored+ // from the light scheme for the same reason the FAB below is: the map is always+ // light, whatever the app's theme.+ Box(Modifier.align(Alignment.TopCenter).fillMaxWidth()) {+ MaterialTheme(colorScheme = lightScheme) {+ MapOverlayBar(state, actions, backupButtons)+ }+ }+ historyScrubber() // FAB floats just above the sheet peek, lifting as the sheet expands.@@ -700,6 +651,110 @@ fun MainPageContent( } } +/**+ * The map page's chrome, floating over the map rather than sitting in a bar above it.+ *+ * The bar this replaces was a solid [com.vayunmathur.library.ui.TopAppBar] carrying the app+ * name and the two backup actions, and it cost the map a full bar's height on every screen+ * (GitHub #680). Backup and restore are rare enough to live behind the overflow menu; the+ * contextual actions for a selected person or place keep their own buttons, because they are+ * the reason that selection is on screen.+ *+ * [backupButtons] is emitted inside the menu and owns the file-picker launchers and the+ * passphrase dialog for whatever it started, so nothing here closes the menu on a tap.+ */+@Composable+private fun MapOverlayBar(+ state: MainPageUiState,+ actions: MainPageActions,+ backupButtons: @Composable () -> Unit,+) {+ var menuExpanded by remember { mutableStateOf(false) }++ val gpsWarningDescription = stringResource(R.string.gps_fallback_warning_content_description)+ val menuDescription = stringResource(R.string.map_menu_content_description)+ val findNearbyDescription = stringResource(R.string.find_nearby_content_description)+ val verifyDescription = stringResource(R.string.verify_security_code_content_description)+ val deletePersonDescription = stringResource(R.string.delete_person_content_description)+ val deletePlaceDescription = stringResource(R.string.delete_place_content_description)++ val selectedUserId = state.selectedUserId+ val selectedWaypointId = state.selectedWaypointId++ val overlayActions: List<OverlayAction> =+ if (selectedUserId == null && (selectedWaypointId == null || selectedWaypointId == 0L)) {+ listOfNotNull(+ if (state.usingGpsFallback) {+ OverlayAction(+ icon = {+ // Use Image (not the tinting IconWarning) so the+ // custom yellow-and-red drawable keeps both colors.+ Image(+ painter = painterResource(R.drawable.ic_warning_gps),+ contentDescription = gpsWarningDescription+ )+ },+ contentDescription = gpsWarningDescription,+ onClick = { actions.onGpsWarningClick() }+ )+ } else null,+ OverlayAction(+ icon = {+ IconMoreVert()+ // Anchored to the button's own content so the menu drops from it.+ DropdownMenu(menuExpanded, { menuExpanded = false }) {+ Row(Modifier.padding(horizontal = Spacing.xs)) { backupButtons() }+ }+ },+ contentDescription = menuDescription,+ onClick = { menuExpanded = !menuExpanded }+ )+ )+ } else if (selectedUserId != null && !state.historyMode) {+ if (state.isSelfSelected) emptyList() else listOfNotNull(+ // Find Nearby (UWB) needs both the public android.ranging API+ // (Android 16+) and an actual UWB radio. Hide the entry point otherwise.+ if (state.uwbAvailable) {+ OverlayAction({ IconNavigationArrow() }, findNearbyDescription) {+ actions.openUwbRanging(selectedUserId)+ }+ } else null,+ OverlayAction({ IconVerify() }, verifyDescription) { actions.onShowSecurityCode() },+ OverlayAction({ IconDelete() }, deletePersonDescription) { actions.deleteSelectedUser() }+ )+ } else if (selectedWaypointId != null && selectedWaypointId != 0L) {+ listOf(+ OverlayAction({ IconDelete() }, deletePlaceDescription) { actions.deleteSelectedWaypoint() }+ )+ } else {+ emptyList()+ }++ TopAppBarOverlay(+ onNavigateBack = if (selectedUserId != null || selectedWaypointId != null) {+ {+ if (state.historyMode) actions.setShowingPresent(true) else actions.clearSelection()+ }+ } else null,+ actions = overlayActions,+ // The overlay draws no container of its own, so the history title carries its own+ // surface to stay legible over the map.+ title = if (state.historyMode) {+ {+ Card(Modifier.padding(start = Spacing.sm)) {+ Text(+ stringResource(R.string.history_title, state.selectedUser?.name ?: ""),+ Modifier.padding(horizontal = Spacing.md, vertical = Spacing.sm),+ style = MaterialTheme.typography.titleMedium,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis+ )+ }+ }+ } else null+ )+}+ /** * The sheet shown when nobody is selected: everyone sharing with you, then inbound * requests, temporary links and saved places.
findfamily/src/main/java/com/vayunmathur/findfamily/util/FindFamilyUiContract.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/util/FindFamilyUiContract.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/util/FindFamilyUiContract.ktindex 59af755b82..58d87e5723 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/util/FindFamilyUiContract.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/util/FindFamilyUiContract.kt@@ -104,7 +104,7 @@ data class MainPageUiState( /** False while viewing a contact's past track (history mode). */ val isShowingPresent: Boolean = true, val usingGpsFallback: Boolean = false,- /** Whether UWB "Find Nearby" is available on this device (controls the top-bar entry). */+ /** Whether UWB "Find Nearby" is available on this device (controls the overlay entry). */ val uwbAvailable: Boolean = false, /** This device's own user id, so the layout can hide self-only controls. */ val selfUserId: Long = -1L,@@ -123,7 +123,7 @@ data class MainPageUiState( } /**- * Top-bar and FAB callbacks for the map page. Same no-op-default arrangement as the sheet+ * Map-overlay and FAB callbacks for the map page. Same no-op-default arrangement as the sheet * action interfaces so [Noop] is all a preview needs. The stateful `MainPage` wires these to * the ViewModel and nav back stack. */
findfamily/src/main/res/values/strings.xml
diff --git a/findfamily/src/main/res/values/strings.xml b/findfamily/src/main/res/values/strings.xmlindex 6e7e14fd2c..837901f5dc 100644--- a/findfamily/src/main/res/values/strings.xml+++ b/findfamily/src/main/res/values/strings.xml@@ -148,7 +148,7 @@ <string name="auto_toggle_never">Never</string> <!-- UserPage: Auto-toggle dropdown option that flips sharing when you arrive at a saved place. %1$s = place name, e.g. Home --> <string name="arrival_at">Arrival at %1$s</string>- <!-- MainPage TopAppBar: Title when in history mode. %1$s = selected user name, e.g. Alice -->+ <!-- MainPage map overlay: Title when in history mode. %1$s = selected user name, e.g. Alice --> <string name="history_title">History: <xliff:g id="person_name" example="Alice">%1$s</xliff:g></string> <!-- HistoryScrubber: Button label to step back 5 minutes. Verb with duration --> <string name="history_step_minus_5m">-5m</string>@@ -279,8 +279,18 @@ <!-- UwbRangingScreen: Hint when azimuth null. Instruction sentence --> <string name="point_the_back_of_your_phone_toward_your">Point the back of your phone toward your contact</string> - <!-- MainPage: Content description for the GPS-only fallback warning icon in the top bar. Noun phrase -->+ <!-- MainPage: Content description for the GPS-only fallback warning icon in the map overlay. Noun phrase --> <string name="gps_fallback_warning_content_description">Network location unavailable</string>+ <!-- MainPage: Content description for the overflow button on the map that opens the backup and restore actions. Noun phrase -->+ <string name="map_menu_content_description">More options</string>+ <!-- MainPage: Content description for the map overlay button that starts Find Nearby (UWB) for the selected person. Verb phrase -->+ <string name="find_nearby_content_description">Find nearby</string>+ <!-- MainPage: Content description for the map overlay button that shows the end-to-end encryption security code for the selected person. Verb phrase -->+ <string name="verify_security_code_content_description">Verify security code</string>+ <!-- MainPage: Content description for the map overlay button that removes the selected person. Verb phrase -->+ <string name="delete_person_content_description">Remove person</string>+ <!-- MainPage: Content description for the map overlay button that deletes the selected saved place. Verb phrase -->+ <string name="delete_place_content_description">Delete saved place</string> <!-- GpsFallbackWarningDialog: Title of the GPS-only fallback warning dialog. Noun phrase --> <string name="gps_fallback_warning_title">Using GPS only</string> <!-- GpsFallbackWarningDialog: Body explaining network location is off and GPS drains battery. Sentence -->