Skip to content

Commit

Permalink
[SHARED][#97] Add about section
Browse files Browse the repository at this point in the history
  • Loading branch information
kamgurgul committed Feb 10, 2025
1 parent ca74962 commit 303b721
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@

<!-- Settings -->
<string name="settings_others">Ostatní</string>
<string name="settings_about">O aplikaci</string>

<!-- Licenses -->
<string name="licenses">Licence</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@

<!-- Settings -->
<string name="settings_others">Andere</string>
<string name="settings_about">Über</string>

<!-- Licenses -->
<string name="licenses">Lizenzen</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@

<!-- Settings -->
<string name="settings_others">Inne</string>
<string name="settings_about">O aplikacji</string>

<!-- Licenses -->
<string name="licenses">Licencje</string>
Expand Down
1 change: 1 addition & 0 deletions shared/src/commonMain/composeResources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@

<!-- Settings -->
<string name="settings_others">Others</string>
<string name="settings_about">About</string>

<!-- Licenses -->
<string name="licenses">Licenses</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalUriHandler
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
Expand All @@ -55,6 +56,7 @@ import com.kgurgul.cpuinfo.shared.pref_theme_dark
import com.kgurgul.cpuinfo.shared.pref_theme_default
import com.kgurgul.cpuinfo.shared.pref_theme_light
import com.kgurgul.cpuinfo.shared.settings
import com.kgurgul.cpuinfo.shared.settings_about
import com.kgurgul.cpuinfo.shared.settings_others
import com.kgurgul.cpuinfo.shared.temperature_unit
import com.kgurgul.cpuinfo.ui.components.PrimaryTopAppBar
Expand Down Expand Up @@ -109,11 +111,13 @@ fun SettingsScreen(
viewModel: SettingsViewModel = koinViewModel(),
) {
val uiState by viewModel.uiStateFlow.collectAsStateWithLifecycle()
val uriHandler = LocalUriHandler.current
SettingsScreen(
uiState = uiState,
onTemperatureOptionClicked = viewModel::setTemperatureUnit,
onThemeOptionClicked = viewModel::setTheme,
onLicensesClicked = onLicensesClicked,
onAboutClicked = { uriHandler.openUri(NavigationConst.APP_WEBPAGE) },
)
}

Expand All @@ -123,6 +127,7 @@ fun SettingsScreen(
onTemperatureOptionClicked: (Int) -> Unit,
onThemeOptionClicked: (String) -> Unit,
onLicensesClicked: () -> Unit,
onAboutClicked: () -> Unit,
) {
Scaffold(
topBar = {
Expand All @@ -140,6 +145,7 @@ fun SettingsScreen(
onThemeItemClicked = { isThemeDialogVisible = true },
onTemperatureItemClicked = { isTemperatureDialogVisible = true },
onLicensesClicked = onLicensesClicked,
onAboutClicked = onAboutClicked,
)
TemperatureUnitDialog(
isDialogVisible = isTemperatureDialogVisible,
Expand All @@ -164,6 +170,7 @@ private fun SettingsList(
onThemeItemClicked: () -> Unit,
onTemperatureItemClicked: () -> Unit,
onLicensesClicked: () -> Unit,
onAboutClicked: () -> Unit,
modifier: Modifier = Modifier,
) {
Box(
Expand Down Expand Up @@ -212,6 +219,12 @@ private fun SettingsList(
onClick = onLicensesClicked,
)
}
item(key = "__aboutItem") {
SettingsItem(
title = stringResource(Res.string.settings_about),
onClick = onAboutClicked,
)
}
}
VerticalScrollbar(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.kgurgul.cpuinfo.utils.navigation
object NavigationConst {

const val BASE_URL = "https://kgurgul.com/assets/cpuinfo/"
const val APP_WEBPAGE = "https://github.com/kamgurgul/cpu-info"

const val INFORMATION = "information"
const val APPLICATIONS = "applications"
Expand Down

0 comments on commit 303b721

Please sign in to comment.