diff --git a/composeApp/src/commonMain/composeResources/drawable/round_add_24.xml b/composeApp/src/commonMain/composeResources/drawable/round_add_24.xml new file mode 100644 index 0000000..4f18112 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/round_add_24.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/composeApp/src/commonMain/composeResources/drawable/round_favorite_24.xml b/composeApp/src/commonMain/composeResources/drawable/round_favorite_24.xml new file mode 100644 index 0000000..36f7780 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/round_favorite_24.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/composeApp/src/commonMain/kotlin/ru/tularegion/corp/App.kt b/composeApp/src/commonMain/kotlin/ru/tularegion/corp/App.kt index 110326f..773e348 100644 --- a/composeApp/src/commonMain/kotlin/ru/tularegion/corp/App.kt +++ b/composeApp/src/commonMain/kotlin/ru/tularegion/corp/App.kt @@ -11,11 +11,15 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.NavigationRail import androidx.compose.material3.NavigationRailItem +import androidx.compose.material3.Scaffold import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -26,6 +30,7 @@ import androidx.navigation.compose.composable import androidx.navigation.compose.currentBackStackEntryAsState import androidx.navigation.compose.rememberNavController import corp_tularegion_extension.composeapp.generated.resources.Res +import corp_tularegion_extension.composeapp.generated.resources.round_favorite_24 import corp_tularegion_extension.composeapp.generated.resources.tularegion_48 import corp_tularegion_extension.composeapp.generated.resources.round_info_24 import corp_tularegion_extension.composeapp.generated.resources.round_open_in_new_24 @@ -33,31 +38,41 @@ import corp_tularegion_extension.composeapp.generated.resources.round_settings_2 import org.jetbrains.compose.resources.DrawableResource import org.jetbrains.compose.resources.painterResource import ru.tularegion.corp.backend.openCorpPortal -import ru.tularegion.corp.screens.AboutScreen -import ru.tularegion.corp.screens.SettingsScreen +import ru.tularegion.corp.ui.screens.AboutScreen +import ru.tularegion.corp.ui.screens.LinksScreen +import ru.tularegion.corp.ui.screens.SettingsScreen import ru.tularegion.corp.ui.theme.darkScheme enum class Screen( val route: String, - val label: String, + val title: String, val icon: DrawableResource, ) { + Links( + route = "links", + title = "Быстрые ссылки", + icon = Res.drawable.round_favorite_24, + ), Settings( route = "settings", - label = "Открыть вкладку «Настройки»", + title = "Настройки", icon = Res.drawable.round_settings_24, ), About( route = "about", - label = "Открыть вкладку «О расширении»", + title = "О приложении", icon = Res.drawable.round_info_24, ), } +@OptIn(ExperimentalMaterial3Api::class) @Composable fun App() { val navController = rememberNavController() val navBackStackEntry = navController.currentBackStackEntryAsState() + val floatingActionButtonState = remember { + mutableStateOf<(@Composable () -> Unit)?>(null) + } MaterialTheme( colorScheme = darkScheme, @@ -102,7 +117,7 @@ fun App() { icon = { Icon( painter = painterResource(screen.icon), - contentDescription = screen.label, + contentDescription = "Открыть вкладку «${screen.title}»", ) }, ) @@ -123,23 +138,48 @@ fun App() { } } - NavHost( - navController = navController, - startDestination = Screen.Settings.route, - modifier = Modifier - .verticalScroll( - state = rememberScrollState(), + Scaffold( + topBar = { + TopAppBar( + title = { + Text( + text = Screen.entries.find { + it.route == navBackStackEntry.value?.destination?.route + }?.title ?: "", + ) + }, ) - .padding( - bottom = 16.dp, - ) - .fillMaxSize(), - ) { - composable(Screen.Settings.route) { - SettingsScreen() - } - composable(Screen.About.route) { - AboutScreen() + }, + floatingActionButton = { + floatingActionButtonState.value?.let { + it() + } + }, + ) { paddingValues -> + NavHost( + navController = navController, + startDestination = Screen.Links.route, + modifier = Modifier + .verticalScroll( + state = rememberScrollState(), + ) + .padding(paddingValues) + .padding( + bottom = 16.dp, + ) + .fillMaxSize(), + ) { + composable(Screen.Links.route) { + LinksScreen( + floatingActionButtonState = floatingActionButtonState, + ) + } + composable(Screen.Settings.route) { + SettingsScreen() + } + composable(Screen.About.route) { + AboutScreen() + } } } } diff --git a/composeApp/src/commonMain/kotlin/ru/tularegion/corp/ui/components/LinkButton.kt b/composeApp/src/commonMain/kotlin/ru/tularegion/corp/ui/components/LinkButton.kt new file mode 100644 index 0000000..b465c1a --- /dev/null +++ b/composeApp/src/commonMain/kotlin/ru/tularegion/corp/ui/components/LinkButton.kt @@ -0,0 +1,70 @@ +package ru.tularegion.corp.ui.components + +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp +import corp_tularegion_extension.composeapp.generated.resources.Res +import corp_tularegion_extension.composeapp.generated.resources.round_open_in_new_24 +import org.jetbrains.compose.resources.painterResource + +@Composable +fun LinkButton( + title: String, + url: String, +) { + Row( + modifier = Modifier + .fillMaxWidth() + .clickable( + onClick = {}, + ) + .padding( + horizontal = 16.dp, + vertical = 16.dp, + ), + horizontalArrangement = Arrangement.SpaceBetween, + verticalAlignment = Alignment.CenterVertically, + ) { + Column( + modifier = Modifier + .weight( + weight = 1f, + ), + ) { + Text( + text = title, + style = MaterialTheme.typography.titleLarge, + ) + Spacer( + modifier = Modifier + .height(4.dp), + ) + Text( + text = url, + color = MaterialTheme.colorScheme.onSurfaceVariant, + style = MaterialTheme.typography.bodyMedium, + ) + } + Spacer( + modifier = Modifier + .width(16.dp), + ) + Icon( + painter = painterResource(Res.drawable.round_open_in_new_24), + contentDescription = "Открыть «$title»", + ) + } +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ru/tularegion/corp/ui/components/SwitchSpoiler.kt b/composeApp/src/commonMain/kotlin/ru/tularegion/corp/ui/components/SwitchSpoiler.kt index 335f11e..a4b0934 100644 --- a/composeApp/src/commonMain/kotlin/ru/tularegion/corp/ui/components/SwitchSpoiler.kt +++ b/composeApp/src/commonMain/kotlin/ru/tularegion/corp/ui/components/SwitchSpoiler.kt @@ -75,7 +75,9 @@ fun SwitchSpoiler( .fillMaxWidth() .clickable( onClick = { - enabledState.value = !enabledState.value + val value = !enabledState.value + onValueChange(value) + enabledState.value = value }, ) .padding(16.dp), diff --git a/composeApp/src/commonMain/kotlin/ru/tularegion/corp/screens/AboutScreen.kt b/composeApp/src/commonMain/kotlin/ru/tularegion/corp/ui/screens/AboutScreen.kt similarity index 85% rename from composeApp/src/commonMain/kotlin/ru/tularegion/corp/screens/AboutScreen.kt rename to composeApp/src/commonMain/kotlin/ru/tularegion/corp/ui/screens/AboutScreen.kt index 1dafaa3..aa31193 100644 --- a/composeApp/src/commonMain/kotlin/ru/tularegion/corp/screens/AboutScreen.kt +++ b/composeApp/src/commonMain/kotlin/ru/tularegion/corp/ui/screens/AboutScreen.kt @@ -1,4 +1,4 @@ -package ru.tularegion.corp.screens +package ru.tularegion.corp.ui.screens import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Column @@ -17,7 +17,9 @@ fun AboutScreen() { painter = painterResource(Res.drawable.citto_48), contentDescription = "Логотип ГАУ ТО «ЦИТ»", modifier = Modifier - .padding(16.dp), + .padding( + horizontal = 16.dp, + ), ) } } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ru/tularegion/corp/ui/screens/LinksScreen.kt b/composeApp/src/commonMain/kotlin/ru/tularegion/corp/ui/screens/LinksScreen.kt new file mode 100644 index 0000000..345fb6f --- /dev/null +++ b/composeApp/src/commonMain/kotlin/ru/tularegion/corp/ui/screens/LinksScreen.kt @@ -0,0 +1,47 @@ +package ru.tularegion.corp.ui.screens + +import androidx.compose.foundation.layout.Column +import androidx.compose.material3.ExtendedFloatingActionButton +import androidx.compose.material3.Icon +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.MutableState +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import corp_tularegion_extension.composeapp.generated.resources.Res +import corp_tularegion_extension.composeapp.generated.resources.round_add_24 +import org.jetbrains.compose.resources.painterResource +import ru.tularegion.corp.ui.components.LinkButton + +@Composable +fun LinksScreen( + floatingActionButtonState: MutableState<(@Composable () -> Unit)?>, +) { + val floatingActionButtonExpandedState = remember { + mutableStateOf(true) + } + floatingActionButtonState.value = @Composable { + ExtendedFloatingActionButton( + text = { + Text( + text = "Добавить ссылку", + ) + }, + icon = { + Icon( + painter = painterResource(Res.drawable.round_add_24), + contentDescription = null, + ) + }, + onClick = {}, + expanded = floatingActionButtonExpandedState.value, + ) + } + + Column { + LinkButton( + title = "Задачи", + url = "https://corp.tularegion.local/company/personal/user/9761/tasks/", + ) + } +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ru/tularegion/corp/screens/SettingsScreen.kt b/composeApp/src/commonMain/kotlin/ru/tularegion/corp/ui/screens/SettingsScreen.kt similarity index 97% rename from composeApp/src/commonMain/kotlin/ru/tularegion/corp/screens/SettingsScreen.kt rename to composeApp/src/commonMain/kotlin/ru/tularegion/corp/ui/screens/SettingsScreen.kt index 9b1dff1..49fa63c 100644 --- a/composeApp/src/commonMain/kotlin/ru/tularegion/corp/screens/SettingsScreen.kt +++ b/composeApp/src/commonMain/kotlin/ru/tularegion/corp/ui/screens/SettingsScreen.kt @@ -1,4 +1,4 @@ -package ru.tularegion.corp.screens +package ru.tularegion.corp.ui.screens import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -67,7 +67,9 @@ fun SettingsScreen() { Column { Column( modifier = Modifier - .padding(16.dp), + .padding( + horizontal = 16.dp, + ), verticalArrangement = Arrangement.spacedBy(16.dp), ) { DropdownSelect(