Skip to content

Commit fd95f09

Browse files
committed
fix: drawer menu positioning
1 parent 46d7e73 commit fd95f09

File tree

2 files changed

+74
-70
lines changed

2 files changed

+74
-70
lines changed

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ suspend fun getData(): Result<Data> = withContext(Dispatchers.IO) {
192192
- ALWAYS be mindful of thread safety when working with mutable lists & state
193193
- ALWAYS split screen composables into parent accepting viewmodel + inner private child accepting state and callbacks `Content()`
194194
- ALWAYS name lambda parameters in a composable function using present tense, NEVER use past tense
195+
- ALWAYS use a single root layout node in composables that emit UI
195196
- ALWAYS list 3 suggested commit messages after implementation work for the entire set of uncommitted changes
196197
- NEVER use `wheneverBlocking` in unit test expression body functions wrapped in a `= test {}` lambda
197198
- ALWAYS wrap unit tests `setUp` methods mocking suspending calls with `runBlocking`, e.g `setUp() = runBlocking { }`

app/src/main/java/to/bitkit/ui/components/DrawerMenu.kt

Lines changed: 73 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -63,69 +63,70 @@ fun DrawerMenu(
6363
) {
6464
val scope = rememberCoroutineScope()
6565

66-
Scrim(
67-
visible = drawerState.currentValue == DrawerValue.Open,
68-
onClick = {
69-
scope.launch {
70-
drawerState.close()
71-
}
72-
},
73-
modifier = Modifier
74-
.fillMaxSize()
75-
.zIndex(zIndexScrim)
76-
)
66+
Box(modifier = modifier.fillMaxSize()) {
67+
Scrim(
68+
visible = drawerState.currentValue == DrawerValue.Open,
69+
onClick = {
70+
scope.launch {
71+
drawerState.close()
72+
}
73+
},
74+
modifier = Modifier
75+
.fillMaxSize()
76+
.zIndex(zIndexScrim)
77+
)
7778

78-
AnimatedVisibility(
79-
visible = drawerState.currentValue == DrawerValue.Open,
80-
enter = slideInHorizontally(
81-
initialOffsetX = { it }
82-
),
83-
exit = slideOutHorizontally(
84-
targetOffsetX = { it }
85-
),
86-
modifier = modifier.then(
87-
Modifier
79+
AnimatedVisibility(
80+
visible = drawerState.currentValue == DrawerValue.Open,
81+
enter = slideInHorizontally(
82+
initialOffsetX = { it }
83+
),
84+
exit = slideOutHorizontally(
85+
targetOffsetX = { it }
86+
),
87+
modifier = Modifier
88+
.align(Alignment.TopEnd)
8889
.fillMaxHeight()
8990
.zIndex(zIndexMenu)
9091
.blockPointerInputPassthrough()
91-
)
92-
) {
93-
MenuContent(
94-
onWalletClick = {
95-
if (!navigator.isAtHome()) navigator.navigateToHome()
96-
scope.launch { drawerState.close() }
97-
},
98-
onActivityClick = {
99-
navigator.navigate(Routes.Activity.All)
100-
scope.launch { drawerState.close() }
101-
},
102-
onContactsClick = null, // TODO IMPLEMENT CONTACTS
103-
onProfileClick = null, // TODO IMPLEMENT PROFILE
104-
onWidgetsClick = {
105-
if (!hasSeenWidgetsIntro) {
106-
navigator.navigate(Routes.Widgets.Intro)
107-
} else {
108-
navigator.navigate(Routes.Widgets.Add)
109-
}
110-
scope.launch { drawerState.close() }
111-
},
112-
onShopClick = {
113-
if (!hasSeenShopIntro) {
114-
navigator.navigate(Routes.Shop.Intro)
115-
} else {
116-
navigator.navigate(Routes.Shop.Discover)
117-
}
118-
scope.launch { drawerState.close() }
119-
},
120-
onSettingsClick = {
121-
navigator.navigate(Routes.Settings.Main)
122-
scope.launch { drawerState.close() }
123-
},
124-
onAppStatusClick = {
125-
navigator.navigate(Routes.AppStatus)
126-
scope.launch { drawerState.close() }
127-
},
128-
)
92+
) {
93+
MenuContent(
94+
onWalletClick = {
95+
if (!navigator.isAtHome()) navigator.navigateToHome()
96+
scope.launch { drawerState.close() }
97+
},
98+
onActivityClick = {
99+
navigator.navigate(Routes.Activity.All)
100+
scope.launch { drawerState.close() }
101+
},
102+
onContactsClick = null, // TODO IMPLEMENT CONTACTS
103+
onProfileClick = null, // TODO IMPLEMENT PROFILE
104+
onWidgetsClick = {
105+
if (!hasSeenWidgetsIntro) {
106+
navigator.navigate(Routes.Widgets.Intro)
107+
} else {
108+
navigator.navigate(Routes.Widgets.Add)
109+
}
110+
scope.launch { drawerState.close() }
111+
},
112+
onShopClick = {
113+
if (!hasSeenShopIntro) {
114+
navigator.navigate(Routes.Shop.Intro)
115+
} else {
116+
navigator.navigate(Routes.Shop.Discover)
117+
}
118+
scope.launch { drawerState.close() }
119+
},
120+
onSettingsClick = {
121+
navigator.navigate(Routes.Settings.Main)
122+
scope.launch { drawerState.close() }
123+
},
124+
onAppStatusClick = {
125+
navigator.navigate(Routes.AppStatus)
126+
scope.launch { drawerState.close() }
127+
},
128+
)
129+
}
129130
}
130131
}
131132

@@ -294,17 +295,19 @@ private fun DrawerItem(
294295
@Composable
295296
private fun Preview() {
296297
AppThemeSurface {
297-
Box {
298-
MenuContent(
299-
onWalletClick = {},
300-
onActivityClick = {},
301-
onContactsClick = null,
302-
onProfileClick = null,
303-
onWidgetsClick = {},
304-
onShopClick = {},
305-
onSettingsClick = {},
306-
onAppStatusClick = {},
307-
)
298+
Box(modifier = Modifier.fillMaxSize()) {
299+
Box(modifier = Modifier.align(Alignment.TopEnd)) {
300+
MenuContent(
301+
onWalletClick = {},
302+
onActivityClick = {},
303+
onContactsClick = null,
304+
onProfileClick = null,
305+
onWidgetsClick = {},
306+
onShopClick = {},
307+
onSettingsClick = {},
308+
onAppStatusClick = {},
309+
)
310+
}
308311
}
309312
}
310313
}

0 commit comments

Comments
 (0)