Bug 1872885 - Move debug drawer store management from `DebugOverlay` to `FenixOverlay`
parent
3ddf06c968
commit
ece51eebdc
@ -0,0 +1,20 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.debugsettings.store
|
||||
|
||||
/**
|
||||
* Possible values of the debug drawer's physical state.
|
||||
*/
|
||||
enum class DrawerStatus {
|
||||
/**
|
||||
* The state of the drawer when it is closed.
|
||||
*/
|
||||
Closed,
|
||||
|
||||
/**
|
||||
* The state of the drawer when it is open.
|
||||
*/
|
||||
Open,
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.debugsettings.ui
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import mozilla.components.lib.state.ext.observeAsState
|
||||
import org.mozilla.fenix.compose.annotation.LightDarkPreview
|
||||
import org.mozilla.fenix.debugsettings.store.DebugDrawerAction
|
||||
import org.mozilla.fenix.debugsettings.store.DebugDrawerStore
|
||||
import org.mozilla.fenix.debugsettings.store.DrawerStatus
|
||||
import org.mozilla.fenix.theme.FirefoxTheme
|
||||
import org.mozilla.fenix.theme.Theme
|
||||
|
||||
/**
|
||||
* Overlay for presenting Fenix-wide debugging content.
|
||||
*/
|
||||
@Composable
|
||||
fun FenixOverlay() {
|
||||
val debugDrawerStore = remember { DebugDrawerStore() }
|
||||
val drawerStatus by debugDrawerStore.observeAsState(initialValue = DrawerStatus.Closed) { state ->
|
||||
state.drawerStatus
|
||||
}
|
||||
|
||||
FirefoxTheme(theme = Theme.getTheme(allowPrivateTheme = false)) {
|
||||
DebugOverlay(
|
||||
drawerStatus = drawerStatus,
|
||||
onDrawerOpen = {
|
||||
debugDrawerStore.dispatch(DebugDrawerAction.DrawerOpened)
|
||||
},
|
||||
onDrawerClose = {
|
||||
debugDrawerStore.dispatch(DebugDrawerAction.DrawerClosed)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@LightDarkPreview
|
||||
@Composable
|
||||
private fun FenixOverlayPreview() {
|
||||
FenixOverlay()
|
||||
}
|
Loading…
Reference in New Issue