Added SettingsButton.kt

This commit is contained in:
Sad Ellie 2023-05-18 23:33:10 +03:00
parent 7aa0d3e431
commit 1b61b4bd85
4 changed files with 40 additions and 27 deletions

View File

@ -0,0 +1,34 @@
/*
* Unitto is a unit converter for Android
* Copyright (c) 2023 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.core.ui.common
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import com.sadellie.unitto.core.base.R
@Composable
fun SettingsButton(onClick: () -> Unit) {
IconButton(onClick) {
Icon(Icons.Outlined.Settings, stringResource(R.string.open_settings_description))
}
}

View File

@ -37,7 +37,6 @@ import androidx.compose.foundation.layout.sizeIn
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Delete import androidx.compose.material.icons.filled.Delete
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material3.AlertDialog import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
@ -66,6 +65,7 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.sadellie.unitto.core.base.R import com.sadellie.unitto.core.base.R
import com.sadellie.unitto.core.ui.common.MenuButton import com.sadellie.unitto.core.ui.common.MenuButton
import com.sadellie.unitto.core.ui.common.SettingsButton
import com.sadellie.unitto.core.ui.common.UnittoScreenWithTopBar import com.sadellie.unitto.core.ui.common.UnittoScreenWithTopBar
import com.sadellie.unitto.core.ui.common.textfield.ExpressionTextField import com.sadellie.unitto.core.ui.common.textfield.ExpressionTextField
import com.sadellie.unitto.core.ui.common.textfield.UnformattedTextField import com.sadellie.unitto.core.ui.common.textfield.UnformattedTextField
@ -143,12 +143,7 @@ private fun CalculatorScreen(
} }
) )
} else { } else {
IconButton(onClick = navigateToSettings) { SettingsButton(navigateToSettings)
Icon(
Icons.Outlined.Settings,
contentDescription = stringResource(R.string.open_settings_description)
)
}
} }
} }
} }

View File

@ -20,10 +20,6 @@ package com.sadellie.unitto.feature.converter
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -38,6 +34,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.sadellie.unitto.core.base.R import com.sadellie.unitto.core.base.R
import com.sadellie.unitto.core.ui.common.MenuButton import com.sadellie.unitto.core.ui.common.MenuButton
import com.sadellie.unitto.core.ui.common.PortraitLandscape import com.sadellie.unitto.core.ui.common.PortraitLandscape
import com.sadellie.unitto.core.ui.common.SettingsButton
import com.sadellie.unitto.core.ui.common.UnittoScreenWithTopBar import com.sadellie.unitto.core.ui.common.UnittoScreenWithTopBar
import com.sadellie.unitto.feature.converter.components.Keyboard import com.sadellie.unitto.feature.converter.components.Keyboard
import com.sadellie.unitto.feature.converter.components.TopScreenPart import com.sadellie.unitto.feature.converter.components.TopScreenPart
@ -85,12 +82,7 @@ private fun ConverterScreen(
title = { Text(stringResource(R.string.unit_converter)) }, title = { Text(stringResource(R.string.unit_converter)) },
navigationIcon = { MenuButton { navigateToMenu() } }, navigationIcon = { MenuButton { navigateToMenu() } },
actions = { actions = {
IconButton(onClick = navigateToSettings) { SettingsButton(navigateToSettings)
Icon(
Icons.Outlined.Settings,
contentDescription = stringResource(R.string.open_settings_description)
)
}
}, },
colors = TopAppBarDefaults colors = TopAppBarDefaults
.centerAlignedTopAppBarColors(containerColor = Color.Transparent), .centerAlignedTopAppBarColors(containerColor = Color.Transparent),

View File

@ -26,10 +26,6 @@ import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
@ -45,6 +41,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.sadellie.unitto.core.base.R import com.sadellie.unitto.core.base.R
import com.sadellie.unitto.core.ui.common.DatePickerDialog import com.sadellie.unitto.core.ui.common.DatePickerDialog
import com.sadellie.unitto.core.ui.common.MenuButton import com.sadellie.unitto.core.ui.common.MenuButton
import com.sadellie.unitto.core.ui.common.SettingsButton
import com.sadellie.unitto.core.ui.common.TimePickerDialog import com.sadellie.unitto.core.ui.common.TimePickerDialog
import com.sadellie.unitto.core.ui.common.UnittoScreenWithTopBar import com.sadellie.unitto.core.ui.common.UnittoScreenWithTopBar
import com.sadellie.unitto.feature.datedifference.components.DateTimeResultBlock import com.sadellie.unitto.feature.datedifference.components.DateTimeResultBlock
@ -83,12 +80,7 @@ internal fun DateDifferenceScreen(
title = { Text(stringResource(R.string.date_difference)) }, title = { Text(stringResource(R.string.date_difference)) },
navigationIcon = { MenuButton(navigateToMenu) }, navigationIcon = { MenuButton(navigateToMenu) },
actions = { actions = {
IconButton(onClick = navigateToSettings) { SettingsButton(navigateToSettings)
Icon(
Icons.Outlined.Settings,
contentDescription = stringResource(R.string.open_settings_description)
)
}
} }
) { paddingValues -> ) { paddingValues ->
FlowRow( FlowRow(