One style for group headers

This commit is contained in:
Sad Ellie 2022-08-13 21:23:31 +03:00
parent 3c28016836
commit 5e82e3f9c5
5 changed files with 14 additions and 50 deletions

View File

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.sadellie.unitto.screens.second.components
package com.sadellie.unitto.screens.common
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.fillMaxWidth
@ -28,20 +28,23 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
/**
* Unit group header.
* Basic list header.
*
* @param text Unit group name.
* @param text Group label.
* @param modifier Modifier that will be applied to Text composable.
*/
@Composable
fun Header(text: String, modifier: Modifier = Modifier) {
fun Header(
text: String,
modifier: Modifier = Modifier
) {
Text(
modifier = modifier
.background(MaterialTheme.colorScheme.background)
.fillMaxWidth()
.padding(vertical = 12.dp, horizontal = 8.dp),
.padding(start = 16.dp, end = 16.dp, top = 24.dp, bottom = 12.dp),
text = text,
style = MaterialTheme.typography.titleMedium,
style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.primary
)
}

View File

@ -33,12 +33,11 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.stringResource
import com.sadellie.unitto.R
import com.sadellie.unitto.data.units.ALL_UNIT_GROUPS
import com.sadellie.unitto.data.units.AbstractUnit
import com.sadellie.unitto.data.units.UnitGroup
import com.sadellie.unitto.screens.Formatter
import com.sadellie.unitto.screens.second.components.ChipsRow
import com.sadellie.unitto.screens.second.components.Header
import com.sadellie.unitto.screens.common.Header
import com.sadellie.unitto.screens.second.components.SearchBar
import com.sadellie.unitto.screens.second.components.SearchPlaceholder
import com.sadellie.unitto.screens.second.components.UnitListItem

View File

@ -34,10 +34,10 @@ import com.sadellie.unitto.data.NavRoutes.UNIT_GROUPS_SCREEN
import com.sadellie.unitto.data.preferences.OUTPUT_FORMAT
import com.sadellie.unitto.data.preferences.PRECISIONS
import com.sadellie.unitto.data.preferences.SEPARATORS
import com.sadellie.unitto.screens.common.Header
import com.sadellie.unitto.screens.common.UnittoLargeTopAppBar
import com.sadellie.unitto.screens.openLink
import com.sadellie.unitto.screens.setttings.components.AlertDialogWithList
import com.sadellie.unitto.screens.setttings.components.SettingsHeader
import com.sadellie.unitto.screens.setttings.components.SettingsListItem
@Composable
@ -58,7 +58,7 @@ fun SettingsScreen(
LazyColumn(contentPadding = padding) {
// GENERAL GROUP
item { SettingsHeader(stringResource(R.string.general_settings_group)) }
item { Header(stringResource(R.string.general_settings_group)) }
// THEME
item {
@ -109,7 +109,7 @@ fun SettingsScreen(
}
// ADDITIONAL GROUP
item { SettingsHeader(stringResource(R.string.additional_settings_group)) }
item { Header(stringResource(R.string.additional_settings_group)) }
// TERMS AND CONDITIONS
item {

View File

@ -43,7 +43,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.sadellie.unitto.R
import com.sadellie.unitto.screens.common.UnittoLargeTopAppBar
import com.sadellie.unitto.screens.second.components.Header
import com.sadellie.unitto.screens.common.Header
import com.sadellie.unitto.screens.setttings.components.SettingsListItem
import org.burnoutcrew.reorderable.ReorderableItem
import org.burnoutcrew.reorderable.detectReorder

View File

@ -1,38 +0,0 @@
/*
* Unitto is a unit converter for Android
* Copyright (c) 2022 Elshan Agaev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.sadellie.unitto.screens.setttings.components
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
@Composable
fun SettingsHeader(text: String) =
Text(
modifier = Modifier
.fillMaxWidth()
.padding(start = 16.dp, end = 16.dp, top = 24.dp, bottom = 12.dp),
text = text,
style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.primary
)