Skip to content

Commit

Permalink
add constants for icon sizes etc., bigger top toolbar buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
hg42 committed Nov 7, 2022
1 parent 4c6b3b3 commit 658e65f
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 22 deletions.
6 changes: 6 additions & 0 deletions app/src/main/java/com/machiav3lli/backup/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.machiav3lli.backup

import android.Manifest
import android.content.Intent
import androidx.compose.ui.unit.dp
import com.machiav3lli.backup.ui.item.ChipItem
import com.machiav3lli.backup.ui.item.Legend
import com.machiav3lli.backup.ui.item.Link
Expand Down Expand Up @@ -62,6 +63,11 @@ val themeItems = mutableMapOf(
if (OABX.minSDK(31)) set(THEME_DYNAMIC, R.string.prefs_theme_dynamic)
}

val BASIC_BUTTON_SIZE = 48.dp
val BUTTON_ICON_SIZE = 24.dp
val STANDALONE_ICON_SIZE = 48.dp
val SMALL_ICON_SIZE = 32.dp

val accentColorItems = mapOf(
0 to R.string.prefs_accent_0,
1 to R.string.prefs_accent_1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import androidx.work.OneTimeWorkRequest
import androidx.work.WorkInfo
import androidx.work.WorkManager
import com.google.accompanist.navigation.animation.rememberAnimatedNavController
import com.machiav3lli.backup.BASIC_BUTTON_SIZE
import com.machiav3lli.backup.MAIN_FILTER_DEFAULT
import com.machiav3lli.backup.NAV_MAIN
import com.machiav3lli.backup.OABX
Expand Down Expand Up @@ -188,11 +189,14 @@ class MainActivityX : BaseActivity() {
topBar = {

if (navController.currentDestination?.route == NavItem.Scheduler.destination)
TopBar(title = stringResource(id = pageTitle)) {
TopBar(
title = stringResource(id = pageTitle)
) {

RoundButton(
modifier = Modifier
.padding(horizontal = 4.dp)
.size(32.dp),
.size(BASIC_BUTTON_SIZE),
icon = Phosphor.Prohibit,
description = stringResource(id = R.string.sched_blocklist)
) {
Expand All @@ -218,7 +222,7 @@ class MainActivityX : BaseActivity() {
RoundButton(
modifier = Modifier
.padding(horizontal = 4.dp)
.size(32.dp),
.size(BASIC_BUTTON_SIZE),
description = stringResource(id = R.string.prefs_title),
icon = Phosphor.GearSix
) { navController.navigate(NavItem.Settings.destination) }
Expand All @@ -238,14 +242,14 @@ class MainActivityX : BaseActivity() {
RoundButton(
modifier = Modifier
.padding(horizontal = 4.dp)
.size(32.dp),
.size(BASIC_BUTTON_SIZE),
description = stringResource(id = R.string.refresh),
icon = Phosphor.ArrowsClockwise
) { OABX.main?.needRefresh = true }
RoundButton(
modifier = Modifier
.padding(horizontal = 4.dp)
.size(32.dp),
.size(BASIC_BUTTON_SIZE),
description = stringResource(id = R.string.prefs_title),
icon = Phosphor.GearSix
) { navController.navigate(NavItem.Settings.destination) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.google.accompanist.navigation.animation.rememberAnimatedNavController
import com.machiav3lli.backup.BASIC_BUTTON_SIZE
import com.machiav3lli.backup.NAV_PREFS
import com.machiav3lli.backup.OABX
import com.machiav3lli.backup.R
Expand Down Expand Up @@ -91,7 +92,7 @@ class PrefsActivityX : BaseActivity() {
RoundButton(
modifier = Modifier
.padding(horizontal = 4.dp)
.size(32.dp),
.size(BASIC_BUTTON_SIZE),
icon = Phosphor.Info,
description = stringResource(id = R.string.help),
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.machiav3lli.backup.BUTTON_ICON_SIZE
import com.machiav3lli.backup.R
import com.machiav3lli.backup.activities.MainActivityX
import com.machiav3lli.backup.dbs.entity.Schedule
Expand All @@ -57,7 +57,7 @@ fun SchedulerPage(viewModel: SchedulerViewModel) {
text = { Text(stringResource(id = R.string.sched_add)) },
icon = {
Icon(
modifier = Modifier.size(24.dp),
modifier = Modifier.size(BUTTON_ICON_SIZE),
imageVector = Phosphor.CalendarPlus,
contentDescription = stringResource(id = R.string.sched_add)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.machiav3lli.backup.BASIC_BUTTON_SIZE
import com.machiav3lli.backup.ui.compose.item.PrefIcon
import com.machiav3lli.backup.ui.item.Pref

Expand Down Expand Up @@ -82,7 +83,7 @@ fun PrefsGroupHeading(
Column(
verticalArrangement = Arrangement.Center,
modifier = Modifier
.height(48.dp)
.height(BASIC_BUTTON_SIZE)
.padding(horizontal = 32.dp)
.fillMaxWidth(),
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
Expand Down Expand Up @@ -74,6 +75,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Popup
import coil.compose.AsyncImage
import coil.request.ImageRequest
import com.machiav3lli.backup.BUTTON_ICON_SIZE
import com.machiav3lli.backup.MAIN_FILTER_SPECIAL
import com.machiav3lli.backup.MAIN_FILTER_SYSTEM
import com.machiav3lli.backup.MAIN_FILTER_USER
Expand All @@ -84,10 +86,12 @@ import com.machiav3lli.backup.MODE_DATA_EXT
import com.machiav3lli.backup.MODE_DATA_MEDIA
import com.machiav3lli.backup.MODE_DATA_OBB
import com.machiav3lli.backup.R
import com.machiav3lli.backup.SMALL_ICON_SIZE
import com.machiav3lli.backup.SPECIAL_FILTER_ALL
import com.machiav3lli.backup.SPECIAL_FILTER_DISABLED
import com.machiav3lli.backup.SPECIAL_FILTER_LAUNCHABLE
import com.machiav3lli.backup.SPECIAL_FILTER_OLD
import com.machiav3lli.backup.STANDALONE_ICON_SIZE
import com.machiav3lli.backup.dbs.entity.Backup
import com.machiav3lli.backup.dbs.entity.Schedule
import com.machiav3lli.backup.items.Package
Expand Down Expand Up @@ -132,7 +136,7 @@ fun ButtonIcon(
Icon(
imageVector = icon,
contentDescription = stringResource(id = textId),
modifier = Modifier.size(24.dp),
modifier = Modifier.size(BUTTON_ICON_SIZE),
tint = tint ?: LocalContentColor.current
)
}
Expand All @@ -146,7 +150,7 @@ fun PrefIcon(
Icon(
imageVector = icon,
contentDescription = text,
modifier = Modifier.size(32.dp),
modifier = Modifier.size(SMALL_ICON_SIZE), //TODO BUTTON_ICON_SIZE?
tint = tint ?: MaterialTheme.colorScheme.onBackground
)
}
Expand All @@ -159,7 +163,7 @@ fun PackageIcon(
) {
AsyncImage(
modifier = modifier
.size(48.dp)
.size(STANDALONE_ICON_SIZE)
.clip(RoundedCornerShape(LocalShapes.current.medium)),
model = ImageRequest.Builder(LocalContext.current)
.crossfade(true)
Expand Down Expand Up @@ -208,7 +212,7 @@ fun ActionButton(
if (icon != null) {
if (iconOnSide) Spacer(modifier = Modifier.weight(1f))
Icon(
modifier = Modifier.size(24.dp),
modifier = Modifier.size(BUTTON_ICON_SIZE),
imageVector = icon,
contentDescription = text
)
Expand Down Expand Up @@ -247,7 +251,7 @@ fun ElevatedActionButton(
) {
if (icon != null) {
Icon(
modifier = Modifier.size(24.dp),
modifier = Modifier.size(BUTTON_ICON_SIZE),
imageVector = icon,
contentDescription = text
)
Expand Down Expand Up @@ -385,7 +389,7 @@ fun RoundButton(
onClick = onClick
) {
Icon(
modifier = Modifier.size(24.dp),
modifier = Modifier.padding(8.dp).fillMaxSize(),
imageVector = icon,
contentDescription = description
)
Expand Down Expand Up @@ -413,7 +417,7 @@ fun StateChip(
onClick = onClick,
) {
Icon(
modifier = Modifier.size(24.dp),
modifier = Modifier.size(BUTTON_ICON_SIZE),
imageVector = icon,
contentDescription = text
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.machiav3lli.backup.BUTTON_ICON_SIZE
import com.machiav3lli.backup.ui.compose.ifThen
import com.machiav3lli.backup.ui.item.BooleanPref
import com.machiav3lli.backup.ui.item.EnumPref
Expand Down Expand Up @@ -250,7 +251,7 @@ fun SwitchPreference(
endWidget = { isEnabled ->
Switch(
modifier = Modifier
.height(24.dp),
.height(BUTTON_ICON_SIZE),
checked = checked,
onCheckedChange = {
onCheckedChange(it)
Expand Down Expand Up @@ -298,7 +299,7 @@ fun CheckboxPreference(
endWidget = { isEnabled ->
Checkbox(
modifier = Modifier
.height(24.dp),
.height(BUTTON_ICON_SIZE),
checked = checked,
onCheckedChange = {
onCheckedChange(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.dp
import com.google.accompanist.flowlayout.FlowRow
import com.machiav3lli.backup.BUTTON_ICON_SIZE
import com.machiav3lli.backup.R
import com.machiav3lli.backup.ui.compose.icons.Phosphor
import com.machiav3lli.backup.ui.compose.icons.phosphor.PlusCircle
Expand Down Expand Up @@ -100,7 +101,7 @@ fun TagItem(
Icon(
imageVector = icon,
contentDescription = stringResource(id = R.string.dialogCancel),
modifier = Modifier.size(24.dp)
modifier = Modifier.size(BUTTON_ICON_SIZE)
)
},
onClick = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.machiav3lli.backup.BASIC_BUTTON_SIZE
import com.machiav3lli.backup.OABX
import com.machiav3lli.backup.R
import com.machiav3lli.backup.preferences.pref_showInfoLogBar
Expand Down Expand Up @@ -256,7 +257,7 @@ fun ExpandableSearchAction(
RoundButton(
modifier = modifier
.padding(horizontal = 4.dp)
.size(32.dp),
.size(BASIC_BUTTON_SIZE),
icon = Phosphor.MagnifyingGlass,
description = stringResource(id = R.string.search),
onClick = { onExpanded(true) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.google.accompanist.flowlayout.FlowMainAxisAlignment
import com.google.accompanist.flowlayout.FlowRow
import com.machiav3lli.backup.BUTTON_ICON_SIZE
import com.machiav3lli.backup.dbs.entity.Backup
import com.machiav3lli.backup.dbs.entity.Schedule
import com.machiav3lli.backup.items.Log
Expand Down Expand Up @@ -158,7 +159,7 @@ fun InfoChipsBlock(
if (chip.icon != null) Icon(
imageVector = chip.icon,
contentDescription = chip.text,
modifier = Modifier.size(24.dp)
modifier = Modifier.size(BUTTON_ICON_SIZE)
)
},
border = SuggestionChipDefaults.suggestionChipBorder(
Expand Down Expand Up @@ -190,7 +191,7 @@ fun InfoChipsBlock(
if (chip.icon != null) Icon(
imageVector = chip.icon,
contentDescription = chip.text,
modifier = Modifier.size(24.dp)
modifier = Modifier.size(BUTTON_ICON_SIZE)
)
},
border = SuggestionChipDefaults.suggestionChipBorder(
Expand Down

0 comments on commit 658e65f

Please sign in to comment.