Добавлен раздел «Ссылки»

Этот коммит содержится в:
Глеб Иваницкий 2024-12-25 17:38:10 +03:00
родитель 04b05587bf
Коммит c915b2ea21
8 изменённых файлов: 200 добавлений и 27 удалений

Просмотреть файл

@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
<path android:fillColor="#ffffff" android:pathData="M18,13h-5v5c0,0.55 -0.45,1 -1,1s-1,-0.45 -1,-1v-5H6c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1h5V6c0,-0.55 0.45,-1 1,-1s1,0.45 1,1v5h5c0.55,0 1,0.45 1,1s-0.45,1 -1,1z"/>
</vector>

Просмотреть файл

@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
<path android:fillColor="@android:color/white" android:pathData="M13.35,20.13c-0.76,0.69 -1.93,0.69 -2.69,-0.01l-0.11,-0.1C5.3,15.27 1.87,12.16 2,8.28c0.06,-1.7 0.93,-3.33 2.34,-4.29 2.64,-1.8 5.9,-0.96 7.66,1.1 1.76,-2.06 5.02,-2.91 7.66,-1.1 1.41,0.96 2.28,2.59 2.34,4.29 0.14,3.88 -3.3,6.99 -8.55,11.76l-0.1,0.09z"/>
</vector>

Просмотреть файл

@ -11,11 +11,15 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationRail import androidx.compose.material3.NavigationRail
import androidx.compose.material3.NavigationRailItem import androidx.compose.material3.NavigationRailItem
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
@ -26,6 +30,7 @@ import androidx.navigation.compose.composable
import androidx.navigation.compose.currentBackStackEntryAsState import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController import androidx.navigation.compose.rememberNavController
import corp_tularegion_extension.composeapp.generated.resources.Res 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.tularegion_48
import corp_tularegion_extension.composeapp.generated.resources.round_info_24 import corp_tularegion_extension.composeapp.generated.resources.round_info_24
import corp_tularegion_extension.composeapp.generated.resources.round_open_in_new_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.DrawableResource
import org.jetbrains.compose.resources.painterResource import org.jetbrains.compose.resources.painterResource
import ru.tularegion.corp.backend.openCorpPortal import ru.tularegion.corp.backend.openCorpPortal
import ru.tularegion.corp.screens.AboutScreen import ru.tularegion.corp.ui.screens.AboutScreen
import ru.tularegion.corp.screens.SettingsScreen import ru.tularegion.corp.ui.screens.LinksScreen
import ru.tularegion.corp.ui.screens.SettingsScreen
import ru.tularegion.corp.ui.theme.darkScheme import ru.tularegion.corp.ui.theme.darkScheme
enum class Screen( enum class Screen(
val route: String, val route: String,
val label: String, val title: String,
val icon: DrawableResource, val icon: DrawableResource,
) { ) {
Links(
route = "links",
title = "Быстрые ссылки",
icon = Res.drawable.round_favorite_24,
),
Settings( Settings(
route = "settings", route = "settings",
label = "Открыть вкладку «Настройки»", title = "Настройки",
icon = Res.drawable.round_settings_24, icon = Res.drawable.round_settings_24,
), ),
About( About(
route = "about", route = "about",
label = "Открыть вкладку «О расширении»", title = "О приложении",
icon = Res.drawable.round_info_24, icon = Res.drawable.round_info_24,
), ),
} }
@OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
fun App() { fun App() {
val navController = rememberNavController() val navController = rememberNavController()
val navBackStackEntry = navController.currentBackStackEntryAsState() val navBackStackEntry = navController.currentBackStackEntryAsState()
val floatingActionButtonState = remember {
mutableStateOf<(@Composable () -> Unit)?>(null)
}
MaterialTheme( MaterialTheme(
colorScheme = darkScheme, colorScheme = darkScheme,
@ -102,7 +117,7 @@ fun App() {
icon = { icon = {
Icon( Icon(
painter = painterResource(screen.icon), painter = painterResource(screen.icon),
contentDescription = screen.label, contentDescription = "Открыть вкладку «${screen.title}»",
) )
}, },
) )
@ -123,23 +138,48 @@ fun App() {
} }
} }
NavHost( Scaffold(
navController = navController, topBar = {
startDestination = Screen.Settings.route, TopAppBar(
modifier = Modifier title = {
.verticalScroll( Text(
state = rememberScrollState(), text = Screen.entries.find {
it.route == navBackStackEntry.value?.destination?.route
}?.title ?: "",
)
},
) )
.padding( },
bottom = 16.dp, floatingActionButton = {
) floatingActionButtonState.value?.let {
.fillMaxSize(), it()
) { }
composable(Screen.Settings.route) { },
SettingsScreen() ) { paddingValues ->
} NavHost(
composable(Screen.About.route) { navController = navController,
AboutScreen() 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()
}
} }
} }
} }

Просмотреть файл

@ -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»",
)
}
}

Просмотреть файл

@ -75,7 +75,9 @@ fun SwitchSpoiler(
.fillMaxWidth() .fillMaxWidth()
.clickable( .clickable(
onClick = { onClick = {
enabledState.value = !enabledState.value val value = !enabledState.value
onValueChange(value)
enabledState.value = value
}, },
) )
.padding(16.dp), .padding(16.dp),

Просмотреть файл

@ -1,4 +1,4 @@
package ru.tularegion.corp.screens package ru.tularegion.corp.ui.screens
import androidx.compose.foundation.Image import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
@ -17,7 +17,9 @@ fun AboutScreen() {
painter = painterResource(Res.drawable.citto_48), painter = painterResource(Res.drawable.citto_48),
contentDescription = "Логотип ГАУ ТО «ЦИТ»", contentDescription = "Логотип ГАУ ТО «ЦИТ»",
modifier = Modifier modifier = Modifier
.padding(16.dp), .padding(
horizontal = 16.dp,
),
) )
} }
} }

Просмотреть файл

@ -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/",
)
}
}

Просмотреть файл

@ -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.Arrangement
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
@ -67,7 +67,9 @@ fun SettingsScreen() {
Column { Column {
Column( Column(
modifier = Modifier modifier = Modifier
.padding(16.dp), .padding(
horizontal = 16.dp,
),
verticalArrangement = Arrangement.spacedBy(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp),
) { ) {
DropdownSelect( DropdownSelect(