Compare commits
12 Commits
ac433bc492
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| 075dac1fc7 | |||
| bc07ea421b | |||
|
|
59c869d539 | ||
|
|
082c4f7973 | ||
|
|
c2efbd1f75 | ||
|
|
0482f03e09 | ||
|
|
aff43c61a0 | ||
|
|
2987289581 | ||
|
|
aaed01bd12 | ||
|
|
39ff86c8a0 | ||
|
|
993ab0a0b1 | ||
|
|
1f6e7b8ac0 |
@@ -3,7 +3,12 @@ package ru.fincode.tsudesk
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.core.view.WindowCompat
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import ru.fincode.tsudesk.core.ui.components.ConfigureSystemBars
|
||||||
|
import ru.fincode.tsudesk.core.ui.theme.TSUDeskTheme
|
||||||
|
import ru.fincode.tsudesk.core.ui.theme.TSUDeskThemeExt
|
||||||
import ru.fincode.tsudesk.presentation.TSUDeskApp
|
import ru.fincode.tsudesk.presentation.TSUDeskApp
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
@@ -11,9 +16,16 @@ class MainActivity : ComponentActivity() {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||||
setContent {
|
setContent {
|
||||||
|
TSUDeskTheme {
|
||||||
|
ConfigureSystemBars(
|
||||||
|
statusBarColor = Color.Transparent,
|
||||||
|
navigationBarColor = TSUDeskThemeExt.colors.brand,
|
||||||
|
darkIcons = false
|
||||||
|
)
|
||||||
TSUDeskApp()
|
TSUDeskApp()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,7 @@ private const val BASE_TIMEOUT = 30L
|
|||||||
@InstallIn(SingletonComponent::class)
|
@InstallIn(SingletonComponent::class)
|
||||||
object AppConfigModule {
|
object AppConfigModule {
|
||||||
|
|
||||||
private const val BASE_URL_PROD = "https://tulsu.ru/schedule/queries/"
|
private const val BASE_URL_PROD = "https://tulsu.ru/"
|
||||||
private const val BASE_URL_DEVELOP = "https://scherbatykh.ru/app/tsudesk/"
|
private const val BASE_URL_DEVELOP = "https://scherbatykh.ru/app/tsudesk/"
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@@ -1,37 +1,32 @@
|
|||||||
package ru.fincode.tsudesk.app.presentation.main
|
package ru.fincode.tsudesk.presentation.main
|
||||||
|
|
||||||
import androidx.navigation.NavBackStackEntry
|
import androidx.navigation.NavBackStackEntry
|
||||||
|
import androidx.navigation.NavDestination
|
||||||
|
import androidx.navigation.NavDestination.Companion.hasRoute
|
||||||
import ru.fincode.tsudesk.core.navigation.AppRoute
|
import ru.fincode.tsudesk.core.navigation.AppRoute
|
||||||
import ru.fincode.tsudesk.core.navigation.TopLevelDestination
|
import ru.fincode.tsudesk.core.navigation.TopLevelDestination
|
||||||
import ru.fincode.tsudesk.core.navigation.route
|
|
||||||
|
|
||||||
fun selectedTopLevel(entry: NavBackStackEntry?): TopLevelDestination {
|
fun selectedTopLevel(entry: NavBackStackEntry?): TopLevelDestination {
|
||||||
if (entry == null) return TopLevelDestination.SCHEDULE
|
val dest: NavDestination = entry?.destination ?: return TopLevelDestination.SCHEDULE
|
||||||
|
|
||||||
return runCatching {
|
return when {
|
||||||
when (entry.route<AppRoute>()) {
|
dest.hasRoute<AppRoute.Schedule>() || dest.hasRoute<AppRoute.ScheduleDetails>() ->
|
||||||
AppRoute.Schedule,
|
TopLevelDestination.SCHEDULE
|
||||||
is AppRoute.ScheduleDetails -> TopLevelDestination.SCHEDULE
|
|
||||||
|
|
||||||
AppRoute.News,
|
dest.hasRoute<AppRoute.News>() || dest.hasRoute<AppRoute.NewsDetails>() ->
|
||||||
is AppRoute.NewsDetails -> TopLevelDestination.NEWS
|
TopLevelDestination.NEWS
|
||||||
|
|
||||||
AppRoute.Progress -> TopLevelDestination.PROGRESS
|
dest.hasRoute<AppRoute.Progress>() ->
|
||||||
|
TopLevelDestination.PROGRESS
|
||||||
|
|
||||||
AppRoute.Settings -> TopLevelDestination.SETTINGS
|
dest.hasRoute<AppRoute.Settings>() ->
|
||||||
|
TopLevelDestination.SETTINGS
|
||||||
|
|
||||||
else -> TopLevelDestination.SCHEDULE
|
else -> TopLevelDestination.SCHEDULE
|
||||||
}
|
}
|
||||||
}.getOrDefault(TopLevelDestination.SCHEDULE)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun shouldShowBottomBar(entry: NavBackStackEntry?): Boolean {
|
fun shouldShowBottomBar(entry: NavBackStackEntry?): Boolean {
|
||||||
if (entry == null) return false
|
val dest: NavDestination = entry?.destination ?: return false
|
||||||
|
return !dest.hasRoute<AppRoute.Splash>()
|
||||||
return runCatching {
|
|
||||||
when (entry.route<AppRoute>()) {
|
|
||||||
AppRoute.Splash -> false
|
|
||||||
else -> true
|
|
||||||
}
|
|
||||||
}.getOrDefault(true)
|
|
||||||
}
|
}
|
||||||
@@ -1,59 +1,50 @@
|
|||||||
package ru.fincode.tsudesk.presentation.main
|
package ru.fincode.tsudesk.presentation.main
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.painterResource
|
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.res.vectorResource
|
||||||
import androidx.navigation.NavHostController
|
import androidx.navigation.NavHostController
|
||||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||||
import ru.fincode.core.ui.components.BottomBarItem
|
|
||||||
import ru.fincode.core.ui.components.TsudeskBottomBar
|
|
||||||
import ru.fincode.tsudesk.R
|
import ru.fincode.tsudesk.R
|
||||||
import ru.fincode.tsudesk.app.presentation.main.selectedTopLevel
|
|
||||||
import ru.fincode.tsudesk.app.presentation.main.shouldShowBottomBar
|
|
||||||
import ru.fincode.tsudesk.core.navigation.TopLevelDestination
|
import ru.fincode.tsudesk.core.navigation.TopLevelDestination
|
||||||
import ru.fincode.tsudesk.core.navigation.navigateToTopLevel
|
import ru.fincode.tsudesk.core.navigation.navigateToTopLevel
|
||||||
|
import ru.fincode.tsudesk.core.ui.components.BottomBarItem
|
||||||
|
import ru.fincode.tsudesk.core.ui.components.TsudeskBottomBar
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun MainScaffold(
|
fun MainScaffold(
|
||||||
navController: NavHostController,
|
navController: NavHostController,
|
||||||
content: @Composable (Modifier) -> Unit,
|
content: @Composable (Modifier) -> Unit,
|
||||||
) {
|
) {
|
||||||
val scheduleIcon = painterResource(R.drawable.ic_progress)
|
val scheduleIcon =
|
||||||
val newsIcon = painterResource(R.drawable.ic_news)
|
androidx.compose.ui.graphics.vector.ImageVector.vectorResource(R.drawable.ic_progress)
|
||||||
val progressIcon = painterResource(R.drawable.ic_progress)
|
val newsIcon =
|
||||||
val settingsIcon = painterResource(R.drawable.ic_progress)
|
androidx.compose.ui.graphics.vector.ImageVector.vectorResource(R.drawable.ic_progress)
|
||||||
|
val progressIcon =
|
||||||
|
androidx.compose.ui.graphics.vector.ImageVector.vectorResource(R.drawable.ic_progress)
|
||||||
|
val settingsIcon =
|
||||||
|
androidx.compose.ui.graphics.vector.ImageVector.vectorResource(R.drawable.ic_progress)
|
||||||
|
|
||||||
val items = listOf(
|
val items = listOf(
|
||||||
TopLevelItem(
|
TopLevelItem(TopLevelDestination.SCHEDULE, R.string.tab_schedule, scheduleIcon),
|
||||||
destination = TopLevelDestination.SCHEDULE,
|
TopLevelItem(TopLevelDestination.NEWS, R.string.tab_news, newsIcon),
|
||||||
labelRes = R.string.tab_schedule,
|
TopLevelItem(TopLevelDestination.PROGRESS, R.string.tab_progress, progressIcon),
|
||||||
icon = scheduleIcon
|
TopLevelItem(TopLevelDestination.SETTINGS, R.string.tab_settings, settingsIcon),
|
||||||
),
|
|
||||||
TopLevelItem(
|
|
||||||
destination = TopLevelDestination.NEWS,
|
|
||||||
labelRes = R.string.tab_news,
|
|
||||||
icon = newsIcon
|
|
||||||
),
|
|
||||||
TopLevelItem(
|
|
||||||
destination = TopLevelDestination.PROGRESS,
|
|
||||||
labelRes = R.string.tab_progress,
|
|
||||||
icon = progressIcon
|
|
||||||
),
|
|
||||||
TopLevelItem(
|
|
||||||
destination = TopLevelDestination.SETTINGS,
|
|
||||||
labelRes = R.string.tab_settings,
|
|
||||||
icon = settingsIcon
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
val backStackEntry by navController.currentBackStackEntryAsState()
|
val backStackEntry by navController.currentBackStackEntryAsState()
|
||||||
val selected = selectedTopLevel(backStackEntry)
|
val selected = selectedTopLevel(backStackEntry)
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
|
// ВАЖНО: при edge-to-edge отключаем автоматические systemBars insets у Scaffold,
|
||||||
|
// иначе получаем двойные отступы (Scaffold + windowInsetsPadding в Header'е)
|
||||||
|
contentWindowInsets = WindowInsets(0),
|
||||||
|
|
||||||
bottomBar = {
|
bottomBar = {
|
||||||
if (shouldShowBottomBar(backStackEntry)) {
|
if (shouldShowBottomBar(backStackEntry)) {
|
||||||
val uiItems = items.map { item ->
|
val uiItems = items.map { item ->
|
||||||
@@ -77,6 +68,8 @@ fun MainScaffold(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
) { innerPadding ->
|
) { innerPadding ->
|
||||||
|
// innerPadding учитывает bottomBar и системные элементы Scaffold (если будут),
|
||||||
|
// но НЕ добавляет statusBars (мы делаем это вручную в нужных местах, например в Header)
|
||||||
content(Modifier.padding(innerPadding))
|
content(Modifier.padding(innerPadding))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
package ru.fincode.tsudesk.presentation.main
|
package ru.fincode.tsudesk.presentation.main
|
||||||
|
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.compose.ui.graphics.painter.Painter
|
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import ru.fincode.tsudesk.core.navigation.TopLevelDestination
|
import ru.fincode.tsudesk.core.navigation.TopLevelDestination
|
||||||
|
|
||||||
data class TopLevelItem(
|
data class TopLevelItem(
|
||||||
val destination: TopLevelDestination,
|
val destination: TopLevelDestination,
|
||||||
@StringRes val labelRes: Int,
|
@StringRes val labelRes: Int,
|
||||||
val icon: Painter,
|
val icon: ImageVector
|
||||||
)
|
)
|
||||||
@@ -1,19 +1,20 @@
|
|||||||
package ru.fincode.tsudesk.presentation.navigation
|
package ru.fincode.tsudesk.presentation.navigation
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.navigation.NavHostController
|
import androidx.navigation.NavHostController
|
||||||
import androidx.navigation.compose.NavHost
|
import androidx.navigation.compose.NavHost
|
||||||
import androidx.navigation.compose.composable
|
import androidx.navigation.compose.composable
|
||||||
import androidx.navigation.compose.navigation
|
import androidx.navigation.compose.rememberNavController
|
||||||
import ru.fincode.tsudesk.presentation.main.MainScaffold
|
|
||||||
import ru.fincode.tsudesk.core.navigation.AppRoute
|
import ru.fincode.tsudesk.core.navigation.AppRoute
|
||||||
import ru.fincode.tsudesk.core.navigation.navigateRoute
|
import ru.fincode.tsudesk.core.navigation.navigateRoute
|
||||||
|
import ru.fincode.tsudesk.feature.news.presentation.screen.NewsRoute
|
||||||
|
//import ru.fincode.tsudesk.feature.news.presentation.screen.NewsRoute
|
||||||
|
import ru.fincode.tsudesk.presentation.main.MainScaffold
|
||||||
import ru.fincode.tsudesk.feature.schedule.presentation.screen.ScheduleRoute
|
import ru.fincode.tsudesk.feature.schedule.presentation.screen.ScheduleRoute
|
||||||
|
|
||||||
import ru.fincode.tsudesk.feature.splash.presentation.screen.SplashRoute
|
import ru.fincode.tsudesk.feature.splash.presentation.screen.SplashRoute
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AppNavHost(
|
fun AppNavHost(
|
||||||
navController: NavHostController,
|
navController: NavHostController,
|
||||||
@@ -33,51 +34,45 @@ fun AppNavHost(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
navigation<AppRoute.Main>(startDestination = AppRoute.Schedule) {
|
composable<AppRoute.Main> {
|
||||||
|
val tabsNavController = rememberNavController()
|
||||||
|
|
||||||
composable<AppRoute.Schedule> {
|
MainScaffold(
|
||||||
MainScaffold(navController) { innerModifier ->
|
navController = tabsNavController
|
||||||
ScheduleRoute(
|
) { innerModifier ->
|
||||||
modifier = innerModifier,
|
MainTabsNavHost(
|
||||||
// onOpenDetails = { lessonId ->
|
navController = tabsNavController,
|
||||||
// navController.navigateRoute(AppRoute.ScheduleDetails(lessonId))
|
modifier = innerModifier
|
||||||
// }
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun MainTabsNavHost(
|
||||||
|
navController: NavHostController,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
) {
|
||||||
|
NavHost(
|
||||||
|
navController = navController,
|
||||||
|
startDestination = AppRoute.Schedule,
|
||||||
|
modifier = modifier
|
||||||
|
) {
|
||||||
|
composable<AppRoute.Schedule> {
|
||||||
|
ScheduleRoute(modifier = Modifier.fillMaxSize())
|
||||||
|
}
|
||||||
|
|
||||||
composable<AppRoute.News> {
|
composable<AppRoute.News> {
|
||||||
MainScaffold(navController) { innerModifier: Modifier ->
|
NewsRoute(modifier = Modifier.fillMaxSize())
|
||||||
// NewsScreen(
|
|
||||||
// modifier = innerModifier,
|
|
||||||
// onOpenDetails = { id ->
|
|
||||||
// navController.navigateRoute(AppRoute.NewsDetails(id))
|
|
||||||
// }
|
|
||||||
// )
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
composable<AppRoute.Progress> {
|
composable<AppRoute.Progress> {
|
||||||
MainScaffold(navController) { innerModifier: Modifier ->
|
// ProgressRoute(modifier = Modifier)
|
||||||
// ProgressScreen(modifier = innerModifier)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
composable<AppRoute.Settings> {
|
composable<AppRoute.Settings> {
|
||||||
MainScaffold(navController) { innerModifier ->
|
// SettingsRoute(modifier = Modifier)
|
||||||
// SettingsRoute(modifier = innerModifier)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// composable<AppRoute.ScheduleDetails> { entry ->
|
|
||||||
// val args = entry.route<AppRoute.ScheduleDetails>()
|
|
||||||
// ScheduleDetailsScreen(lessonId = args.lessonId)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// composable<AppRoute.NewsDetails> { entry ->
|
|
||||||
// val args = entry.route<AppRoute.NewsDetails>()
|
|
||||||
// NewsDetailsScreen(id = args.id)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,10 +3,12 @@
|
|||||||
android:height="24dp"
|
android:height="24dp"
|
||||||
android:viewportWidth="24"
|
android:viewportWidth="24"
|
||||||
android:viewportHeight="24">
|
android:viewportHeight="24">
|
||||||
|
|
||||||
<path
|
<path
|
||||||
android:pathData="M12,3L1,9l11,6 9,-4.91V17h2V9L12,3z"
|
android:pathData="M12,3L1,9l11,6 9,-4.91V17h2V9L12,3z"
|
||||||
android:fillColor="?attr/colorControlNormal"/>
|
android:fillColor="#FF000000"/>
|
||||||
|
|
||||||
<path
|
<path
|
||||||
android:pathData="M5,12.18V17c0,2.21 3.58,4 7,4s7,-1.79 7,-4v-4.82l-7,3.82 -7,-3.82z"
|
android:pathData="M5,12.18V17c0,2.21 3.58,4 7,4s7,-1.79 7,-4v-4.82l-7,3.82 -7,-3.82z"
|
||||||
android:fillColor="?attr/colorControlNormal"/>
|
android:fillColor="#FF000000"/>
|
||||||
</vector>
|
</vector>
|
||||||
@@ -13,7 +13,6 @@ import ru.fincode.tsudesk.core.database.api.schedule.ScheduleDao
|
|||||||
LessonCacheEntity::class
|
LessonCacheEntity::class
|
||||||
],
|
],
|
||||||
version = 2,
|
version = 2,
|
||||||
exportSchema = true
|
|
||||||
)
|
)
|
||||||
@TypeConverters(StringListConverter::class)
|
@TypeConverters(StringListConverter::class)
|
||||||
abstract class AppDatabase : RoomDatabase() {
|
abstract class AppDatabase : RoomDatabase() {
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package ru.fincode.tsudesk.core.ui.components
|
||||||
|
|
||||||
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
|
|
||||||
|
data class BottomBarItem(
|
||||||
|
val key: String,
|
||||||
|
val label: String,
|
||||||
|
val icon: ImageVector,
|
||||||
|
)
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package ru.fincode.tsudesk.core.ui.components
|
||||||
|
|
||||||
|
import androidx.activity.ComponentActivity
|
||||||
|
import androidx.activity.SystemBarStyle
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.SideEffect
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.graphics.toArgb
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ConfigureSystemBars(
|
||||||
|
statusBarColor: Color,
|
||||||
|
navigationBarColor: Color = statusBarColor,
|
||||||
|
darkIcons: Boolean = false, // false = светлые иконки
|
||||||
|
) {
|
||||||
|
val context = LocalContext.current
|
||||||
|
val status = statusBarColor.toArgb()
|
||||||
|
val nav = navigationBarColor.toArgb()
|
||||||
|
|
||||||
|
SideEffect {
|
||||||
|
val activity = context as? ComponentActivity ?: return@SideEffect
|
||||||
|
|
||||||
|
activity.enableEdgeToEdge(
|
||||||
|
statusBarStyle = if (darkIcons) {
|
||||||
|
SystemBarStyle.light(status, status)
|
||||||
|
} else {
|
||||||
|
SystemBarStyle.dark(status)
|
||||||
|
},
|
||||||
|
navigationBarStyle = SystemBarStyle.auto(
|
||||||
|
lightScrim = nav,
|
||||||
|
darkScrim = nav,
|
||||||
|
detectDarkMode = { darkIcons }
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,11 @@
|
|||||||
package ru.fincode.core.ui.components
|
package ru.fincode.tsudesk.core.ui.components
|
||||||
|
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.NavigationBar
|
import androidx.compose.material3.NavigationBar
|
||||||
import androidx.compose.material3.NavigationBarItem
|
import androidx.compose.material3.NavigationBarItem
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.graphics.painter.Painter
|
|
||||||
|
|
||||||
data class BottomBarItem(
|
|
||||||
val key: String,
|
|
||||||
val label: String,
|
|
||||||
val icon: Painter,
|
|
||||||
)
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun TsudeskBottomBar(
|
fun TsudeskBottomBar(
|
||||||
@@ -21,19 +15,22 @@ fun TsudeskBottomBar(
|
|||||||
) {
|
) {
|
||||||
NavigationBar {
|
NavigationBar {
|
||||||
items.forEach { item ->
|
items.forEach { item ->
|
||||||
|
val selected = item.key == selectedKey
|
||||||
|
|
||||||
NavigationBarItem(
|
NavigationBarItem(
|
||||||
selected = item.key == selectedKey,
|
selected = selected,
|
||||||
onClick = { onItemClick(item) },
|
onClick = { onItemClick(item) },
|
||||||
icon = {
|
icon = {
|
||||||
Icon(
|
Icon(
|
||||||
painter = item.icon,
|
imageVector = item.icon,
|
||||||
contentDescription = item.label
|
contentDescription = item.label,
|
||||||
|
tint = if (selected)
|
||||||
|
MaterialTheme.colorScheme.primary
|
||||||
|
else
|
||||||
|
MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
label = {
|
label = { Text(item.label) }
|
||||||
Text(text = item.label)
|
|
||||||
},
|
|
||||||
alwaysShowLabel = true
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package ru.fincode.tsudesk.core.ui.theme
|
||||||
|
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
|
||||||
|
// Brand (ТулГУ / TSUDesk)
|
||||||
|
val BrandRed = Color(0xFF7C1D1D) // замени на точный бордовый
|
||||||
|
val OnBrand = Color(0xFFFFFFFF)
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package ru.fincode.tsudesk.core.ui.theme
|
||||||
|
|
||||||
|
import androidx.compose.material3.darkColorScheme
|
||||||
|
import androidx.compose.material3.lightColorScheme
|
||||||
|
|
||||||
|
val LightColorScheme = lightColorScheme(
|
||||||
|
primary = androidx.compose.ui.graphics.Color(0xFF6750A4),
|
||||||
|
onPrimary = androidx.compose.ui.graphics.Color.White,
|
||||||
|
secondary = androidx.compose.ui.graphics.Color(0xFF625B71),
|
||||||
|
onSecondary = androidx.compose.ui.graphics.Color.White,
|
||||||
|
tertiary = androidx.compose.ui.graphics.Color(0xFF7D5260),
|
||||||
|
onTertiary = androidx.compose.ui.graphics.Color.White,
|
||||||
|
)
|
||||||
|
|
||||||
|
val DarkColorScheme = darkColorScheme(
|
||||||
|
primary = androidx.compose.ui.graphics.Color(0xFFD0BCFF),
|
||||||
|
onPrimary = androidx.compose.ui.graphics.Color(0xFF381E72),
|
||||||
|
secondary = androidx.compose.ui.graphics.Color(0xFFCCC2DC),
|
||||||
|
onSecondary = androidx.compose.ui.graphics.Color(0xFF332D41),
|
||||||
|
tertiary = androidx.compose.ui.graphics.Color(0xFFEFB8C8),
|
||||||
|
onTertiary = androidx.compose.ui.graphics.Color(0xFF492532),
|
||||||
|
)
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package ru.fincode.tsudesk.core.ui.theme
|
||||||
|
|
||||||
|
import androidx.compose.runtime.staticCompositionLocalOf
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
|
||||||
|
data class ExtendedColors(
|
||||||
|
val brand: Color,
|
||||||
|
val onBrand: Color,
|
||||||
|
val brandSoft: Color,
|
||||||
|
)
|
||||||
|
|
||||||
|
val LocalExtendedColors = staticCompositionLocalOf {
|
||||||
|
ExtendedColors(
|
||||||
|
brand = Color.Unspecified,
|
||||||
|
onBrand = Color.Unspecified,
|
||||||
|
brandSoft = Color.Unspecified,
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package ru.fincode.tsudesk.core.ui.theme
|
||||||
|
|
||||||
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun TSUDeskTheme(
|
||||||
|
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||||
|
content: @Composable () -> Unit
|
||||||
|
) {
|
||||||
|
val scheme = if (darkTheme) DarkColorScheme else LightColorScheme
|
||||||
|
|
||||||
|
val extended = ExtendedColors(
|
||||||
|
brand = BrandRed,
|
||||||
|
onBrand = OnBrand,
|
||||||
|
brandSoft = BrandRed.copy(alpha = 0.12f),
|
||||||
|
)
|
||||||
|
|
||||||
|
CompositionLocalProvider(LocalExtendedColors provides extended) {
|
||||||
|
MaterialTheme(
|
||||||
|
colorScheme = scheme,
|
||||||
|
typography = TSUDeskTypography,
|
||||||
|
content = content
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package ru.fincode.tsudesk.core.ui.theme
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
|
||||||
|
|
||||||
|
object TSUDeskThemeExt {
|
||||||
|
val colors: ExtendedColors
|
||||||
|
@Composable get() = LocalExtendedColors.current
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package ru.fincode.tsudesk.core.ui.theme
|
||||||
|
|
||||||
|
import androidx.compose.material3.Typography
|
||||||
|
|
||||||
|
val TSUDeskTypography = Typography()
|
||||||
@@ -9,7 +9,7 @@ import java.util.Locale
|
|||||||
class NewsHtmlParser {
|
class NewsHtmlParser {
|
||||||
|
|
||||||
private val dateFormatter =
|
private val dateFormatter =
|
||||||
DateTimeFormatter.ofPattern("dd.MM.yyyy", Locale("ru"))
|
DateTimeFormatter.ofPattern("dd.MM.yyyy", Locale.forLanguageTag("ru"))
|
||||||
|
|
||||||
fun parseArchivePage(html: String): List<NewsItem> {
|
fun parseArchivePage(html: String): List<NewsItem> {
|
||||||
val itemRegex = Regex(
|
val itemRegex = Regex(
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package ru.fincode.tsudesk.feature.schedule.data.remote
|
|||||||
object ScheduleApiContract {
|
object ScheduleApiContract {
|
||||||
|
|
||||||
object Path {
|
object Path {
|
||||||
const val GET_SCHEDULE_METHOD = "GetSchedule.php"
|
const val GET_SCHEDULE_METHOD = "schedule/queries/GetSchedule.php"
|
||||||
}
|
}
|
||||||
|
|
||||||
object Query {
|
object Query {
|
||||||
|
|||||||
@@ -1,18 +1,25 @@
|
|||||||
package ru.fincode.tsudesk.feature.schedule.presentation.navigation
|
package ru.fincode.tsudesk.feature.schedule.presentation.navigation
|
||||||
|
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.navigation.NavGraphBuilder
|
import androidx.navigation.NavGraphBuilder
|
||||||
import androidx.navigation.compose.composable
|
import androidx.navigation.compose.composable
|
||||||
import ru.fincode.tsudesk.core.navigation.AppRoute
|
import ru.fincode.tsudesk.core.navigation.AppRoute
|
||||||
import ru.fincode.tsudesk.feature.schedule.presentation.screen.ScheduleRoute
|
import ru.fincode.tsudesk.feature.schedule.presentation.screen.ScheduleRoute
|
||||||
|
|
||||||
fun NavGraphBuilder.scheduleGraph(
|
fun NavGraphBuilder.scheduleGraph(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
// на будущее:
|
||||||
|
// onOpenDetails: (lessonId: Long) -> Unit,
|
||||||
) {
|
) {
|
||||||
composable<AppRoute.Schedule> {
|
composable<AppRoute.Schedule> {
|
||||||
ScheduleRoute()
|
ScheduleRoute(
|
||||||
|
modifier = modifier,
|
||||||
|
// onOpenDetails = onOpenDetails
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// composable<AppRoute.ScheduleDetails> { backStackEntry ->
|
// composable<AppRoute.ScheduleDetails> { entry ->
|
||||||
// val args = backStackEntry.toRoute<AppRoute.ScheduleDetails>()
|
// val args = entry.toRoute<AppRoute.ScheduleDetails>()
|
||||||
// ScheduleDetailsRoute(lessonId = args.lessonId)
|
// ScheduleDetailsRoute(lessonId = args.lessonId)
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package ru.fincode.tsudesk.feature.schedule.presentation
|
package ru.fincode.tsudesk.feature.schedule.presentation.screen
|
||||||
|
|
||||||
sealed interface ScheduleAction {
|
sealed interface ScheduleAction {
|
||||||
|
|
||||||
@@ -3,7 +3,21 @@ package ru.fincode.tsudesk.feature.schedule.presentation.screen
|
|||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.border
|
import androidx.compose.foundation.border
|
||||||
import androidx.compose.foundation.horizontalScroll
|
import androidx.compose.foundation.horizontalScroll
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.layout.statusBars
|
||||||
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.foundation.layout.windowInsetsPadding
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
@@ -14,9 +28,23 @@ import androidx.compose.material.icons.Icons
|
|||||||
import androidx.compose.material.icons.filled.Close
|
import androidx.compose.material.icons.filled.Close
|
||||||
import androidx.compose.material.icons.filled.KeyboardArrowDown
|
import androidx.compose.material.icons.filled.KeyboardArrowDown
|
||||||
import androidx.compose.material.icons.filled.KeyboardArrowUp
|
import androidx.compose.material.icons.filled.KeyboardArrowUp
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.AssistChip
|
||||||
|
import androidx.compose.material3.AssistChipDefaults
|
||||||
|
import androidx.compose.material3.Button
|
||||||
|
import androidx.compose.material3.ButtonDefaults
|
||||||
|
import androidx.compose.material3.CircularProgressIndicator
|
||||||
|
import androidx.compose.material3.DropdownMenu
|
||||||
|
import androidx.compose.material3.DropdownMenuItem
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.IconButton
|
||||||
|
import androidx.compose.material3.LinearProgressIndicator
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.OutlinedTextField
|
||||||
|
import androidx.compose.material3.OutlinedTextFieldDefaults
|
||||||
|
import androidx.compose.material3.Surface
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TextButton
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
@@ -28,7 +56,7 @@ import androidx.compose.ui.text.style.TextOverflow
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import ru.fincode.tsudesk.core.common.model.DataResult
|
import ru.fincode.tsudesk.core.common.model.DataResult
|
||||||
import ru.fincode.tsudesk.feature.schedule.presentation.*
|
import ru.fincode.tsudesk.core.ui.theme.TSUDeskThemeExt
|
||||||
import ru.fincode.tsudesk.feature.schedule.presentation.util.dowRuShort
|
import ru.fincode.tsudesk.feature.schedule.presentation.util.dowRuShort
|
||||||
import ru.fincode.tsudesk.feature.schedule.presentation.util.todayString
|
import ru.fincode.tsudesk.feature.schedule.presentation.util.todayString
|
||||||
|
|
||||||
@@ -60,31 +88,38 @@ private fun ScheduleHeader(
|
|||||||
onIntent: (ScheduleIntent) -> Unit
|
onIntent: (ScheduleIntent) -> Unit
|
||||||
) {
|
) {
|
||||||
val shape = RoundedCornerShape(bottomStart = 20.dp, bottomEnd = 20.dp)
|
val shape = RoundedCornerShape(bottomStart = 20.dp, bottomEnd = 20.dp)
|
||||||
|
val brand = TSUDeskThemeExt.colors
|
||||||
|
|
||||||
val headerBrush = Brush.linearGradient(
|
val headerBrush = Brush.linearGradient(
|
||||||
listOf(
|
listOf(
|
||||||
MaterialTheme.colorScheme.error,
|
brand.brand,
|
||||||
MaterialTheme.colorScheme.error.copy(alpha = 0.75f)
|
brand.brand.copy(alpha = 0.75f)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
Column(
|
Box(
|
||||||
Modifier
|
Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.clip(shape)
|
.clip(shape)
|
||||||
.background(headerBrush)
|
.background(headerBrush)
|
||||||
.padding(top = 20.dp, start = 16.dp, end = 16.dp, bottom = 14.dp)
|
) {
|
||||||
|
Column(
|
||||||
|
Modifier
|
||||||
|
// inset только для содержимого, фон остаётся до верха
|
||||||
|
.windowInsetsPadding(WindowInsets.statusBars)
|
||||||
|
.padding(start = 16.dp, end = 16.dp, bottom = 14.dp)
|
||||||
) {
|
) {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
Column(Modifier.weight(1f)) {
|
Column(Modifier.weight(1f)) {
|
||||||
Text(
|
Text(
|
||||||
text = "Расписание",
|
text = "Расписание",
|
||||||
color = MaterialTheme.colorScheme.onError,
|
color = brand.onBrand,
|
||||||
fontSize = 20.sp,
|
fontSize = 20.sp,
|
||||||
fontWeight = FontWeight.Bold
|
fontWeight = FontWeight.Bold
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = "ТулГУ • Осенний семестр",
|
text = "ТулГУ • Осенний семестр",
|
||||||
color = MaterialTheme.colorScheme.onError.copy(alpha = 0.8f),
|
color = brand.onBrand.copy(alpha = 0.8f),
|
||||||
fontSize = 11.sp,
|
fontSize = 11.sp,
|
||||||
fontWeight = FontWeight.Medium
|
fontWeight = FontWeight.Medium
|
||||||
)
|
)
|
||||||
@@ -105,18 +140,16 @@ private fun ScheduleHeader(
|
|||||||
isLoading = state.isLoading,
|
isLoading = state.isLoading,
|
||||||
onExpanded = { onIntent(ScheduleIntent.SetGroupMenuExpanded(it)) },
|
onExpanded = { onIntent(ScheduleIntent.SetGroupMenuExpanded(it)) },
|
||||||
onValueChange = { onIntent(ScheduleIntent.ChangeGroupInput(it)) },
|
onValueChange = { onIntent(ScheduleIntent.ChangeGroupInput(it)) },
|
||||||
|
|
||||||
// выбор из списка -> сразу загрузка
|
|
||||||
onSelectRecent = { group ->
|
onSelectRecent = { group ->
|
||||||
onIntent(ScheduleIntent.SelectRecentGroup(group))
|
onIntent(ScheduleIntent.SelectRecentGroup(group))
|
||||||
onIntent(ScheduleIntent.ApplyGroup)
|
onIntent(ScheduleIntent.ApplyGroup)
|
||||||
},
|
},
|
||||||
|
|
||||||
onRemoveRecent = { onIntent(ScheduleIntent.RemoveRecentGroup(it)) },
|
onRemoveRecent = { onIntent(ScheduleIntent.RemoveRecentGroup(it)) },
|
||||||
onApply = { onIntent(ScheduleIntent.ApplyGroup) },
|
onApply = { onIntent(ScheduleIntent.ApplyGroup) },
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -566,9 +599,10 @@ private fun LessonCard(lesson: UiLesson) {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun LessonBadge(text: String, kind: BadgeKind) {
|
private fun LessonBadge(text: String, kind: BadgeKind) {
|
||||||
|
val brand = TSUDeskThemeExt.colors
|
||||||
val (bg, fg) = when (kind) {
|
val (bg, fg) = when (kind) {
|
||||||
BadgeKind.INFO -> MaterialTheme.colorScheme.primary.copy(alpha = 0.12f) to MaterialTheme.colorScheme.primary
|
BadgeKind.INFO -> MaterialTheme.colorScheme.primary.copy(alpha = 0.12f) to MaterialTheme.colorScheme.primary
|
||||||
BadgeKind.PRIMARY -> MaterialTheme.colorScheme.error.copy(alpha = 0.12f) to MaterialTheme.colorScheme.error
|
BadgeKind.PRIMARY -> brand.brandSoft to brand.brand
|
||||||
BadgeKind.LAB -> MaterialTheme.colorScheme.tertiary.copy(alpha = 0.12f) to MaterialTheme.colorScheme.tertiary
|
BadgeKind.LAB -> MaterialTheme.colorScheme.tertiary.copy(alpha = 0.12f) to MaterialTheme.colorScheme.tertiary
|
||||||
BadgeKind.MUTED -> MaterialTheme.colorScheme.surfaceVariant to MaterialTheme.colorScheme.onSurfaceVariant
|
BadgeKind.MUTED -> MaterialTheme.colorScheme.surfaceVariant to MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user