feat: about screen

This commit is contained in:
robin committed 2026-10-30 14:24:03 +01:00
1 parent 3aedc51b97
commit 31a1f5158f
7 files changed
+281 -104

No files matched your search

@@ -8,6 +8,7 @@ import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.Home
import androidx.compose.material.icons.filled.List
import androidx.compose.material.icons.filled.Settings
@@ -20,15 +21,25 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.res.stringResource
import de.schanbro.weekfocus.ui.theme.WeekFocusTheme
import androidx.navigation.NavGraph.Companion.findStartDestination
import androidx.navigation.compose.*
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import de.schanbro.weekfocus.screens.AboutScreen
import de.schanbro.weekfocus.screens.SettingsScreen
import de.schanbro.weekfocus.screens.WordListScreen
import de.schanbro.weekfocus.settings.SettingsRepository
import de.schanbro.weekfocus.settings.ThemeMode
import de.schanbro.weekfocus.ui.theme.WeekFocusTheme
import de.schanbro.weekfocus.update.NetworkPermissionGate
import de.schanbro.weekfocus.update.UpdateHandler
private object Routes {
const val HOME = "home"
const val WORDS = "words"
const val SETTINGS = "settings"
const val ABOUT = "about"
}
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
@@ -53,8 +64,6 @@ class MainActivity : ComponentActivity() {
override fun onResume() {
super.onResume()
// Falls das Widget (z.B. durch Energiesparmodus) nicht rechtzeitig aktualisiert
// wurde, wird es beim Öffnen der App nachgezogen.
updateWidget(this)
}
}
@@ -62,7 +71,9 @@ class MainActivity : ComponentActivity() {
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun MainScreen() {
var selectedTab by remember { mutableIntStateOf(0) }
val navController = rememberNavController()
val backStackEntry by navController.currentBackStackEntryAsState()
val currentRoute = backStackEntry?.destination?.route
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior()
Scaffold(
@@ -73,14 +84,25 @@ fun MainScreen() {
LargeTopAppBar(
title = {
Text(
when (selectedTab) {
0 -> stringResource(R.string.title_home)
1 -> stringResource(R.string.title_words)
2 -> stringResource(R.string.title_settings)
when (currentRoute) {
Routes.HOME -> stringResource(R.string.title_weekly_focus)
Routes.WORDS -> stringResource(R.string.title_words)
Routes.SETTINGS -> stringResource(R.string.title_settings)
Routes.ABOUT -> stringResource(R.string.title_about)
else -> stringResource(R.string.app_name)
}
)
},
navigationIcon = {
if (currentRoute == Routes.ABOUT) {
IconButton(onClick = { navController.popBackStack() }) {
Icon(
Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = stringResource(R.string.action_back)
)
}
}
},
scrollBehavior = scrollBehavior,
colors = TopAppBarDefaults.largeTopAppBarColors(
containerColor = MaterialTheme.colorScheme.surface,
@@ -89,40 +111,66 @@ fun MainScreen() {
)
},
bottomBar = {
NavigationBar {
NavigationBarItem(
selected = selectedTab == 0,
onClick = { selectedTab = 0 },
icon = {
Icon(
imageVector = if (selectedTab == 0) Icons.Filled.Home else Icons.Outlined.Home,
contentDescription = stringResource(R.string.title_home)
)
},
label = { Text(stringResource(R.string.title_home)) }
)
NavigationBarItem(
selected = selectedTab == 1,
onClick = { selectedTab = 1 },
icon = {
Icon(
imageVector = if (selectedTab == 1) Icons.Filled.List else Icons.Outlined.List,
contentDescription = stringResource(R.string.title_words)
)
},
label = { Text(stringResource(R.string.title_words)) }
)
NavigationBarItem(
selected = selectedTab == 2,
onClick = { selectedTab = 2 },
icon = {
Icon(
imageVector = if (selectedTab == 2) Icons.Filled.Settings else Icons.Outlined.Settings,
contentDescription = stringResource(R.string.title_settings)
)
},
label = { Text(stringResource(R.string.title_settings)) }
)
if (currentRoute != Routes.ABOUT) {
NavigationBar {
NavigationBarItem(
selected = currentRoute == Routes.HOME,
onClick = {
navController.navigate(Routes.HOME) {
popUpTo(navController.graph.findStartDestination().id) {
saveState = true
}
launchSingleTop = true
restoreState = true
}
},
icon = {
Icon(
imageVector = if (currentRoute == Routes.HOME) Icons.Filled.Home else Icons.Outlined.Home,
contentDescription = stringResource(R.string.title_home)
)
},
label = { Text(stringResource(R.string.title_home)) }
)
NavigationBarItem(
selected = currentRoute == Routes.WORDS,
onClick = {
navController.navigate(Routes.WORDS) {
popUpTo(navController.graph.findStartDestination().id) {
saveState = true
}
launchSingleTop = true
restoreState = true
}
},
icon = {
Icon(
imageVector = if (currentRoute == Routes.WORDS) Icons.Filled.List else Icons.Outlined.List,
contentDescription = stringResource(R.string.title_words)
)
},
label = { Text(stringResource(R.string.title_words)) }
)
NavigationBarItem(
selected = currentRoute == Routes.SETTINGS,
onClick = {
navController.navigate(Routes.SETTINGS) {
popUpTo(navController.graph.findStartDestination().id) {
saveState = true
}
launchSingleTop = true
restoreState = true
}
},
icon = {
Icon(
imageVector = if (currentRoute == Routes.SETTINGS) Icons.Filled.Settings else Icons.Outlined.Settings,
contentDescription = stringResource(R.string.title_settings)
)
},
label = { Text(stringResource(R.string.title_settings)) }
)
}
}
}
) { innerPadding ->
@@ -132,10 +180,17 @@ fun MainScreen() {
.padding(innerPadding),
color = MaterialTheme.colorScheme.background
) {
when (selectedTab) {
0 -> PlaceholderScreen(title = stringResource(R.string.title_weekly_focus))
1 -> WordListScreen()
2 -> SettingsScreen()
NavHost(
navController = navController,
startDestination = Routes.HOME,
modifier = Modifier.fillMaxSize()
) {
composable(Routes.HOME) { PlaceholderScreen(title = stringResource(R.string.title_weekly_focus)) }
composable(Routes.WORDS) { WordListScreen() }
composable(Routes.SETTINGS) {
SettingsScreen(onOpenAbout = { navController.navigate(Routes.ABOUT) })
}
composable(Routes.ABOUT) { AboutScreen() }
}
}
}
@@ -155,9 +210,6 @@ fun PlaceholderScreen(title: String) {
}
}
/**
* Bleibt als Top-Level-Funktion erhalten, damit WordListScreen unverändert weiter funktioniert.
*/
fun updateWidget(context: Context) {
SimpleWidget.updateAllWidgets(context)
}
}