Skip to content

Commit e70b160

Browse files
committed
app/ui: fix absolute cards
1 parent 1dbf90f commit e70b160

File tree

12 files changed

+311
-228
lines changed

12 files changed

+311
-228
lines changed

app/src/main/kotlin/com/dergoogler/mmrl/ui/activity/SetupScreen.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ fun SetupScreen(setWorkingMode: (WorkingMode) -> Unit) {
9292
remember(currentSelection) { currentSelection == manager }
9393

9494
Card {
95-
List {
95+
List(
96+
modifier = Modifier.relative()
97+
) {
9698
RadioItem(
9799
selected = selected,
98100
interactionSource = interactionSource,

app/src/main/kotlin/com/dergoogler/mmrl/ui/screens/home/HomeScreen.kt

Lines changed: 79 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import com.dergoogler.mmrl.ui.component.SELinuxStatus
7171
import com.dergoogler.mmrl.ui.component.TopAppBar
7272
import com.dergoogler.mmrl.ui.component.TopAppBarEventIcon
7373
import com.dergoogler.mmrl.ui.component.card.Card
74+
import com.dergoogler.mmrl.ui.component.card.Relative
7475
import com.dergoogler.mmrl.ui.component.listItem.ListItem
7576
import com.dergoogler.mmrl.ui.component.listItem.ListItemDefaults
7677
import com.dergoogler.mmrl.ui.component.listItem.ListProgressBarItem
@@ -211,8 +212,9 @@ fun HomeScreen(
211212
modifier = Modifier.padding(vertical = 16.dp)
212213
) {
213214
val uname = Os.uname()
214-
Column {
215-
215+
Column(
216+
modifier = Modifier.relative()
217+
) {
216218
scope.Item {
217219
Icon(painter = painterResource(R.drawable.cookie_man))
218220
Title(R.string.kernel)
@@ -259,14 +261,18 @@ fun HomeScreen(
259261
Card(
260262
modifier = Modifier.padding(vertical = 16.dp)
261263
) {
262-
scope.Item {
263-
Title(R.string.home_root_provider_version_name)
264-
Description(viewModel.versionName)
265-
}
264+
Column(
265+
modifier = Modifier.relative()
266+
) {
267+
scope.Item {
268+
Title(R.string.home_root_provider_version_name)
269+
Description(viewModel.versionName)
270+
}
266271

267-
scope.Item {
268-
Title(R.string.home_root_provider_se_linux_context)
269-
Description(viewModel.seLinuxContext)
272+
scope.Item {
273+
Title(R.string.home_root_provider_se_linux_context)
274+
Description(viewModel.seLinuxContext)
275+
}
270276
}
271277
}
272278
}
@@ -282,9 +288,11 @@ fun HomeScreen(
282288
.padding(vertical = 16.dp)
283289
.weight(1f)
284290
) {
285-
scope.Item {
286-
Title(R.string.home_installed_modules)
287-
Description(it.totalModules.toString())
291+
Relative {
292+
scope.Item {
293+
Title(R.string.home_installed_modules)
294+
Description(it.totalModules.toString())
295+
}
288296
}
289297
}
290298

@@ -293,9 +301,11 @@ fun HomeScreen(
293301
.padding(vertical = 16.dp)
294302
.weight(1f)
295303
) {
296-
scope.Item {
297-
Title(R.string.home_updated_modules)
298-
Description(it.totalUpdated.toString())
304+
Relative {
305+
scope.Item {
306+
Title(R.string.home_updated_modules)
307+
Description(it.totalUpdated.toString())
308+
}
299309
}
300310
}
301311
}
@@ -304,31 +314,33 @@ fun HomeScreen(
304314
modifier = Modifier
305315
.padding(vertical = 16.dp)
306316
) {
307-
scope.Item {
308-
Title(R.string.home_storage_usage)
309-
310-
Description {
311-
Row(
312-
verticalAlignment = Alignment.CenterVertically,
313-
horizontalArrangement = Arrangement.spacedBy(8.dp)
314-
) {
315-
Text(
316-
text = it.totalModulesUsageBytes.toFormattedFileSize(),
317-
)
318-
319-
LinearProgressIndicator(
320-
progress = {
321-
it.totalStorageUsage
322-
},
323-
modifier = Modifier
324-
.height(10.dp)
325-
.weight(1f),
326-
drawStopIndicator = {}
327-
)
328-
329-
Text(
330-
text = it.totalDeviceStorageBytes.toFormattedFileSize(),
331-
)
317+
Relative {
318+
scope.Item {
319+
Title(R.string.home_storage_usage)
320+
321+
Description {
322+
Row(
323+
verticalAlignment = Alignment.CenterVertically,
324+
horizontalArrangement = Arrangement.spacedBy(8.dp)
325+
) {
326+
Text(
327+
text = it.totalModulesUsageBytes.toFormattedFileSize(),
328+
)
329+
330+
LinearProgressIndicator(
331+
progress = {
332+
it.totalStorageUsage
333+
},
334+
modifier = Modifier
335+
.height(10.dp)
336+
.weight(1f),
337+
drawStopIndicator = {}
338+
)
339+
340+
Text(
341+
text = it.totalDeviceStorageBytes.toFormattedFileSize(),
342+
)
343+
}
332344
}
333345
}
334346
}
@@ -342,9 +354,11 @@ fun HomeScreen(
342354
.padding(vertical = 16.dp)
343355
.weight(1f)
344356
) {
345-
scope.Item {
346-
Title(R.string.home_enabled_modules)
347-
Description(it.totalEnabled.toString())
357+
Relative {
358+
scope.Item {
359+
Title(R.string.home_enabled_modules)
360+
Description(it.totalEnabled.toString())
361+
}
348362
}
349363
}
350364

@@ -353,9 +367,11 @@ fun HomeScreen(
353367
.padding(vertical = 16.dp)
354368
.weight(1f)
355369
) {
356-
scope.Item {
357-
Title(R.string.home_disabled_modules)
358-
Description(it.totalDisabled.toString())
370+
Relative {
371+
scope.Item {
372+
Title(R.string.home_disabled_modules)
373+
Description(it.totalDisabled.toString())
374+
}
359375
}
360376
}
361377
}
@@ -370,22 +386,24 @@ fun HomeScreen(
370386
browser.openUri("https://github.com/sponsors/DerGoogler")
371387
}
372388
) {
373-
scope.Item {
374-
Title(
375-
id = R.string.home_support_title,
376-
styleTransform = {
377-
val newStyle = it.copy(color = Color.Unspecified)
378-
it.merge(newStyle)
379-
}
380-
)
389+
Relative {
390+
scope.Item {
391+
Title(
392+
id = R.string.home_support_title,
393+
styleTransform = {
394+
val newStyle = it.copy(color = Color.Unspecified)
395+
it.merge(newStyle)
396+
}
397+
)
381398

382-
Description(
383-
id = R.string.home_support_content,
384-
styleTransform = {
385-
val newStyle = it.copy(color = Color.Unspecified)
386-
it.merge(newStyle)
387-
}
388-
)
399+
Description(
400+
id = R.string.home_support_content,
401+
styleTransform = {
402+
val newStyle = it.copy(color = Color.Unspecified)
403+
it.merge(newStyle)
404+
}
405+
)
406+
}
389407
}
390408
}
391409
}

app/src/main/kotlin/com/dergoogler/mmrl/ui/screens/home/items/NonRootItem.kt

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,31 @@ import com.dergoogler.mmrl.ui.component.card.Card
2727
internal fun NonRootItem(
2828
developerMode: Boolean = false,
2929
) = Card(
30-
modifier = Modifier.padding(20.dp),
3130
color = MaterialTheme.colorScheme.secondaryContainer,
32-
absolute = {
33-
developerMode.takeTrue {
34-
Surface(
35-
shape = RoundedCornerShape(
36-
topEnd = 20.dp,
37-
bottomStart = 15.dp,
38-
bottomEnd = 0.dp
39-
),
40-
color = MaterialTheme.colorScheme.primary,
31+
) {
32+
developerMode.takeTrue {
33+
Surface(
34+
shape = RoundedCornerShape(
35+
topEnd = 20.dp,
36+
bottomStart = 15.dp,
37+
bottomEnd = 0.dp
38+
),
39+
color = MaterialTheme.colorScheme.primary,
40+
modifier = Modifier
41+
.absolute(Alignment.TopEnd)
42+
) {
43+
Text(
44+
text = "USER!DEV",
45+
style = MaterialTheme.typography.bodySmall,
46+
color = MaterialTheme.colorScheme.onPrimary,
4147
modifier = Modifier
42-
.align(Alignment.TopEnd)
43-
) {
44-
Text(
45-
text = "USER!DEV",
46-
style = MaterialTheme.typography.bodySmall,
47-
color = MaterialTheme.colorScheme.onPrimary,
48-
modifier = Modifier
49-
.padding(horizontal = 16.dp, vertical = 8.dp)
50-
)
51-
}
48+
.padding(horizontal = 16.dp, vertical = 8.dp)
49+
)
5250
}
5351
}
54-
) {
52+
5553
Row(
54+
modifier = Modifier.relative().padding(20.dp),
5655
verticalAlignment = Alignment.CenterVertically
5756
) {
5857
Icon(

app/src/main/kotlin/com/dergoogler/mmrl/ui/screens/home/items/RootItem.kt

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,32 +44,31 @@ internal fun RootItem(
4444
FeaturedManager.managers.find { userPreferences.workingMode == it.workingMode }
4545

4646
Card(
47-
modifier = Modifier.padding(20.dp),
4847
color = MaterialTheme.colorScheme.secondaryContainer,
49-
absolute = {
50-
developerMode.takeTrue {
51-
Surface(
52-
shape = RoundedCornerShape(
53-
topEnd = 20.dp,
54-
bottomStart = 15.dp,
55-
bottomEnd = 0.dp
56-
),
57-
color = MaterialTheme.colorScheme.primary,
48+
) {
49+
developerMode.takeTrue {
50+
Surface(
51+
shape = RoundedCornerShape(
52+
topEnd = 20.dp,
53+
bottomStart = 15.dp,
54+
bottomEnd = 0.dp
55+
),
56+
color = MaterialTheme.colorScheme.primary,
57+
modifier = Modifier
58+
.absolute(Alignment.TopEnd)
59+
) {
60+
Text(
61+
text = "USER!DEV",
62+
style = MaterialTheme.typography.bodySmall,
63+
color = MaterialTheme.colorScheme.onPrimary,
5864
modifier = Modifier
59-
.align(Alignment.TopEnd)
60-
) {
61-
Text(
62-
text = "USER!DEV",
63-
style = MaterialTheme.typography.bodySmall,
64-
color = MaterialTheme.colorScheme.onPrimary,
65-
modifier = Modifier
66-
.padding(horizontal = 16.dp, vertical = 8.dp)
67-
)
68-
}
65+
.padding(horizontal = 16.dp, vertical = 8.dp)
66+
)
6967
}
7068
}
71-
) {
69+
7270
Row(
71+
modifier = Modifier.relative().padding(20.dp),
7372
verticalAlignment = Alignment.CenterVertically
7473
) {
7574
Icon(

app/src/main/kotlin/com/dergoogler/mmrl/ui/screens/modules/ModuleItem.kt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ import com.dergoogler.mmrl.platform.model.ModId.Companion.moduleDir
6767
import com.dergoogler.mmrl.ui.component.BottomSheet
6868
import com.dergoogler.mmrl.ui.component.LabelItemDefaults
6969
import com.dergoogler.mmrl.ui.component.LocalCover
70+
import com.dergoogler.mmrl.ui.component.card.Absolute
71+
import com.dergoogler.mmrl.ui.component.card.CardScope
7072
import com.dergoogler.mmrl.ui.component.text.TextWithIconDefaults
7173
import com.dergoogler.mmrl.utils.WebUIXPackageName
7274
import com.dergoogler.mmrl.utils.launchWebUI
@@ -82,7 +84,7 @@ fun ModuleItem(
8284
alpha: Float = 1f,
8385
decoration: TextDecoration = TextDecoration.None,
8486
switch: @Composable() (() -> Unit?)? = null,
85-
indicator: @Composable() (BoxScope.() -> Unit?)? = null,
87+
indicator: @Composable() (CardScope.() -> Unit?)? = null,
8688
startTrailingButton: @Composable() (RowScope.() -> Unit)? = null,
8789
trailingButton: @Composable() (RowScope.() -> Unit),
8890
isBlacklisted: Boolean = false,
@@ -117,13 +119,19 @@ fun ModuleItem(
117119
width = 1.dp,
118120
color = MaterialTheme.colorScheme.errorContainer
119121
),
120-
absoluteAlignment = Alignment.Center,
121-
absolute = {
122-
indicator?.invoke(this)
123-
},
124122
onClick = clicker
125123
) {
126-
Column {
124+
indicator.nullable {
125+
Absolute(
126+
alignment = Alignment.Center,
127+
) {
128+
it()
129+
}
130+
}
131+
132+
Column(
133+
modifier = Modifier.relative(),
134+
) {
127135
module.config.cover.nullable(menu.showCover) {
128136
val file = SuFile(module.id.moduleDir, it)
129137

0 commit comments

Comments
 (0)