From 679bf7e001246a8598110e51c901396e934e2529 Mon Sep 17 00:00:00 2001 From: DatLag Date: Fri, 10 May 2024 19:06:39 +0200 Subject: [PATCH] move settings to bottom sheet --- .../component/DomainSection.android.kt | 2 +- .../aniflow/ui/navigation/RootComponent.kt | 15 ++--- .../aniflow/ui/navigation/RootConfig.kt | 3 - .../ui/navigation/screen/home/DialogConfig.kt | 10 +++ .../navigation/screen/home/HomeComponent.kt | 5 ++ .../ui/navigation/screen/home/HomeScreen.kt | 5 ++ .../screen/home/HomeScreenComponent.kt | 25 ++++++- .../dialog}/settings/SettingsComponent.kt | 5 +- .../dialog/settings/SettingsDialog.kt} | 43 ++++++++---- .../settings/SettingsDialogComponent.kt} | 12 ++-- .../settings/component/AdultSection.kt | 2 +- .../settings/component/CharacterSection.kt | 2 +- .../settings/component/ColorSection.kt | 2 +- .../settings/component/DomainSection.kt | 2 +- .../settings/component/TitleSection.kt | 2 +- .../dialog}/settings/component/UserSection.kt | 65 +++++++++++++------ .../dialog/character/CharacterDialog.kt | 3 +- .../settings/component/DomainSection.ios.kt | 2 +- 18 files changed, 143 insertions(+), 62 deletions(-) rename composeApp/src/androidMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/{ => home/dialog}/settings/component/DomainSection.android.kt (96%) create mode 100644 composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/DialogConfig.kt rename composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/{ => home/dialog}/settings/SettingsComponent.kt (82%) rename composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/{settings/SettingsScreen.kt => home/dialog/settings/SettingsDialog.kt} (85%) rename composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/{settings/SettingsScreenComponent.kt => home/dialog/settings/SettingsDialogComponent.kt} (91%) rename composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/{ => home/dialog}/settings/component/AdultSection.kt (96%) rename composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/{ => home/dialog}/settings/component/CharacterSection.kt (97%) rename composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/{ => home/dialog}/settings/component/ColorSection.kt (97%) rename composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/{ => home/dialog}/settings/component/DomainSection.kt (66%) rename composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/{ => home/dialog}/settings/component/TitleSection.kt (97%) rename composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/{ => home/dialog}/settings/component/UserSection.kt (51%) rename composeApp/src/iosMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/{ => home/dialog}/settings/component/DomainSection.ios.kt (64%) diff --git a/composeApp/src/androidMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/DomainSection.android.kt b/composeApp/src/androidMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/DomainSection.android.kt similarity index 96% rename from composeApp/src/androidMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/DomainSection.android.kt rename to composeApp/src/androidMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/DomainSection.android.kt index 2add183..891b37c 100644 --- a/composeApp/src/androidMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/DomainSection.android.kt +++ b/composeApp/src/androidMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/DomainSection.android.kt @@ -1,4 +1,4 @@ -package dev.datlag.aniflow.ui.navigation.screen.settings.component +package dev.datlag.aniflow.ui.navigation.screen.home.dialog.settings.component import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/RootComponent.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/RootComponent.kt index 157b761..f9ba5e9 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/RootComponent.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/RootComponent.kt @@ -13,7 +13,7 @@ import dev.datlag.aniflow.other.UserHelper import dev.datlag.aniflow.ui.navigation.screen.favorites.FavoritesScreenComponent import dev.datlag.aniflow.ui.navigation.screen.home.HomeScreenComponent import dev.datlag.aniflow.ui.navigation.screen.medium.MediumScreenComponent -import dev.datlag.aniflow.ui.navigation.screen.settings.SettingsScreenComponent +import dev.datlag.aniflow.ui.navigation.screen.home.dialog.settings.SettingsDialogComponent import dev.datlag.aniflow.ui.navigation.screen.nekos.NekosScreenComponent import org.kodein.di.DI import org.kodein.di.instance @@ -43,14 +43,14 @@ class RootComponent( onMediumDetails = { navigation.push(RootConfig.Details(it)) }, - onProfile = { - navigation.push(RootConfig.Settings) - }, onDiscover = { // navigation.replaceCurrent(RootConfig.Wallpaper) }, onFavorites = { navigation.replaceCurrent(RootConfig.Favorites) + }, + onNekos = { + navigation.bringToFront(RootConfig.Nekos) } ) is RootConfig.Details -> MediumScreenComponent( @@ -59,13 +59,6 @@ class RootComponent( initialMedium = rootConfig.medium, onBack = navigation::pop ) - is RootConfig.Settings -> SettingsScreenComponent( - componentContext = componentContext, - di = di, - onNekos = { - navigation.bringToFront(RootConfig.Nekos) - } - ) is RootConfig.Favorites -> FavoritesScreenComponent( componentContext = componentContext, di = di, diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/RootConfig.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/RootConfig.kt index 6ab07c1..dd55b08 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/RootConfig.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/RootConfig.kt @@ -14,9 +14,6 @@ sealed class RootConfig { constructor(id: Int) : this(Medium(id)) } - @Serializable - data object Settings : RootConfig() - @Serializable data object Favorites : RootConfig() diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/DialogConfig.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/DialogConfig.kt new file mode 100644 index 0000000..d75fdd5 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/DialogConfig.kt @@ -0,0 +1,10 @@ +package dev.datlag.aniflow.ui.navigation.screen.home + +import kotlinx.serialization.Serializable + +@Serializable +sealed class DialogConfig { + + @Serializable + data object Settings : DialogConfig() +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/HomeComponent.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/HomeComponent.kt index c44f942..1fed965 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/HomeComponent.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/HomeComponent.kt @@ -1,5 +1,7 @@ package dev.datlag.aniflow.ui.navigation.screen.home +import com.arkivanov.decompose.router.slot.ChildSlot +import com.arkivanov.decompose.value.Value import dev.datlag.aniflow.anilist.AiringTodayRepository import dev.datlag.aniflow.anilist.TrendingRepository import dev.datlag.aniflow.anilist.model.Medium @@ -8,6 +10,7 @@ import dev.datlag.aniflow.anilist.state.CollectionState import dev.datlag.aniflow.anilist.type.MediaType import dev.datlag.aniflow.trace.TraceRepository import dev.datlag.aniflow.ui.navigation.Component +import dev.datlag.aniflow.ui.navigation.DialogComponent import kotlinx.coroutines.flow.Flow interface HomeComponent : Component { @@ -21,6 +24,8 @@ interface HomeComponent : Component { val traceState: Flow + val dialog: Value> + fun viewProfile() fun viewAnime() fun viewManga() diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/HomeScreen.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/HomeScreen.kt index 2a4ba5b..53243c8 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/HomeScreen.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/HomeScreen.kt @@ -21,6 +21,7 @@ import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp +import com.arkivanov.decompose.extensions.compose.subscribeAsState import com.maxkeppeker.sheets.core.models.base.Header import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState import com.maxkeppeler.sheets.option.OptionDialog @@ -60,6 +61,10 @@ fun HomeScreen(component: HomeComponent) { it?.let(component::trace) } + val dialogState by component.dialog.subscribeAsState() + + dialogState.child?.instance?.render() + Scaffold( modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection), topBar = { diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/HomeScreenComponent.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/HomeScreenComponent.kt index f903ce6..9a15745 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/HomeScreenComponent.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/HomeScreenComponent.kt @@ -4,6 +4,8 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.remember import com.arkivanov.decompose.ComponentContext +import com.arkivanov.decompose.router.slot.* +import com.arkivanov.decompose.value.Value import dev.chrisbanes.haze.HazeState import dev.datlag.aniflow.LocalHaze import dev.datlag.aniflow.anilist.AiringTodayRepository @@ -20,6 +22,8 @@ import dev.datlag.aniflow.other.StateSaver import dev.datlag.aniflow.other.UserHelper import dev.datlag.aniflow.settings.Settings import dev.datlag.aniflow.trace.TraceRepository +import dev.datlag.aniflow.ui.navigation.DialogComponent +import dev.datlag.aniflow.ui.navigation.screen.home.dialog.settings.SettingsDialogComponent import dev.datlag.tooling.decompose.ioScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.SharingStarted @@ -32,9 +36,9 @@ class HomeScreenComponent( componentContext: ComponentContext, override val di: DI, private val onMediumDetails: (Medium) -> Unit, - private val onProfile: () -> Unit, private val onDiscover: () -> Unit, - private val onFavorites: () -> Unit + private val onFavorites: () -> Unit, + private val onNekos: () -> Unit ) : HomeComponent, ComponentContext by componentContext { private val appSettings by instance() @@ -90,6 +94,21 @@ class HomeScreenComponent( private val traceRepository by instance() override val traceState: Flow = traceRepository.response + private val dialogNavigation = SlotNavigation() + override val dialog: Value> = childSlot( + source = dialogNavigation, + serializer = DialogConfig.serializer() + ) { config, context -> + when (config) { + is DialogConfig.Settings -> SettingsDialogComponent( + componentContext = context, + di = di, + onNekos = onNekos, + onDismiss = dialogNavigation::dismiss + ) + } + } + init { traceRepository.clear() } @@ -108,7 +127,7 @@ class HomeScreenComponent( } override fun viewProfile() { - onProfile() + dialogNavigation.activate(DialogConfig.Settings) } override fun viewAnime() { diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/SettingsComponent.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/SettingsComponent.kt similarity index 82% rename from composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/SettingsComponent.kt rename to composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/SettingsComponent.kt index d0a93e7..c748239 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/SettingsComponent.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/SettingsComponent.kt @@ -1,13 +1,14 @@ -package dev.datlag.aniflow.ui.navigation.screen.settings +package dev.datlag.aniflow.ui.navigation.screen.home.dialog.settings import dev.datlag.aniflow.anilist.model.User import dev.datlag.aniflow.ui.navigation.Component +import dev.datlag.aniflow.ui.navigation.DialogComponent import kotlinx.coroutines.flow.Flow import dev.datlag.aniflow.settings.model.Color as SettingsColor import dev.datlag.aniflow.settings.model.TitleLanguage as SettingsTitle import dev.datlag.aniflow.settings.model.CharLanguage as SettingsChar -interface SettingsComponent : Component { +interface SettingsComponent : DialogComponent { val user: Flow val isLoggedIn: Flow val loginUri: String diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/SettingsScreen.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/SettingsDialog.kt similarity index 85% rename from composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/SettingsScreen.kt rename to composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/SettingsDialog.kt index 7417e41..8dab1a0 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/SettingsScreen.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/SettingsDialog.kt @@ -1,6 +1,8 @@ -package dev.datlag.aniflow.ui.navigation.screen.settings +package dev.datlag.aniflow.ui.navigation.screen.home.dialog.settings import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.fadeIn +import androidx.compose.animation.fadeOut import androidx.compose.foundation.Image import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn @@ -8,8 +10,9 @@ import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.* +import androidx.compose.material.icons.rounded.ArrowBackIosNew +import androidx.compose.material.icons.rounded.Code import androidx.compose.material3.* -import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -17,24 +20,38 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.unit.dp -import dev.chrisbanes.haze.haze -import dev.datlag.aniflow.LocalHaze -import dev.datlag.aniflow.LocalPaddingValues +import dev.datlag.aniflow.LocalEdgeToEdge import dev.datlag.aniflow.SharedRes +import dev.datlag.aniflow.common.isFullyExpandedOrTargeted import dev.datlag.aniflow.common.merge -import dev.datlag.aniflow.common.plus import dev.datlag.aniflow.other.Constants import dev.datlag.aniflow.other.StateSaver -import dev.datlag.aniflow.ui.navigation.screen.settings.component.* +import dev.datlag.aniflow.ui.navigation.screen.home.dialog.settings.component.* import dev.datlag.tooling.compose.onClick import dev.datlag.tooling.decompose.lifecycle.collectAsStateWithLifecycle import dev.icerock.moko.resources.compose.painterResource import dev.icerock.moko.resources.compose.stringResource +@OptIn(ExperimentalMaterial3Api::class) @Composable fun SettingsScreen(component: SettingsComponent) { - Scaffold { - val padding = it.merge(PaddingValues(16.dp)) + val sheetState = rememberModalBottomSheetState() + val (insets, bottomPadding) = if (LocalEdgeToEdge.current) { + WindowInsets( + left = 0, + top = 0, + right = 0, + bottom = 0 + ) to BottomSheetDefaults.windowInsets.only(WindowInsetsSides.Bottom).asPaddingValues() + } else { + BottomSheetDefaults.windowInsets to PaddingValues() + } + + ModalBottomSheet( + onDismissRequest = component::dismiss, + windowInsets = insets, + sheetState = sheetState + ) { val listState = rememberLazyListState( initialFirstVisibleItemIndex = StateSaver.List.settingsOverview, initialFirstVisibleItemScrollOffset = StateSaver.List.settingsOverviewOffset @@ -43,14 +60,16 @@ fun SettingsScreen(component: SettingsComponent) { LazyColumn( state = listState, modifier = Modifier.fillMaxWidth(), - contentPadding = padding, + contentPadding = bottomPadding.merge(PaddingValues(16.dp)), verticalArrangement = Arrangement.spacedBy(8.dp) ) { item { UserSection( userFlow = component.user, loginUri = component.loginUri, - modifier = Modifier.fillParentMaxWidth() + dismissVisible = sheetState.isFullyExpandedOrTargeted(forceFullExpand = true), + modifier = Modifier.fillParentMaxWidth(), + onDismiss = component::dismiss ) } item { @@ -159,7 +178,7 @@ fun SettingsScreen(component: SettingsComponent) { horizontalArrangement = Arrangement.spacedBy(8.dp) ) { Icon( - imageVector = Icons.Default.Code, + imageVector = Icons.Rounded.Code, contentDescription = null, ) Text(text = "Developed by DatLag") diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/SettingsScreenComponent.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/SettingsDialogComponent.kt similarity index 91% rename from composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/SettingsScreenComponent.kt rename to composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/SettingsDialogComponent.kt index 748f01e..a441d22 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/SettingsScreenComponent.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/SettingsDialogComponent.kt @@ -1,4 +1,4 @@ -package dev.datlag.aniflow.ui.navigation.screen.settings +package dev.datlag.aniflow.ui.navigation.screen.home.dialog.settings import androidx.compose.runtime.Composable import com.arkivanov.decompose.ComponentContext @@ -7,7 +7,6 @@ import dev.datlag.aniflow.common.onRender import dev.datlag.aniflow.other.UserHelper import dev.datlag.aniflow.settings.Settings import dev.datlag.tooling.compose.ioDispatcher -import dev.datlag.tooling.decompose.ioScope import kotlinx.coroutines.flow.* import org.kodein.di.DI import org.kodein.di.instance @@ -15,10 +14,11 @@ import dev.datlag.aniflow.settings.model.Color as SettingsColor import dev.datlag.aniflow.settings.model.TitleLanguage as SettingsTitle import dev.datlag.aniflow.settings.model.CharLanguage as SettingsChar -class SettingsScreenComponent( +class SettingsDialogComponent( componentContext: ComponentContext, override val di: DI, - private val onNekos: () -> Unit + private val onNekos: () -> Unit, + private val onDismiss: () -> Unit ) : SettingsComponent, ComponentContext by componentContext { private val appSettings by di.instance() @@ -73,4 +73,8 @@ class SettingsScreenComponent( override fun nekos() { onNekos() } + + override fun dismiss() { + onDismiss() + } } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/AdultSection.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/AdultSection.kt similarity index 96% rename from composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/AdultSection.kt rename to composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/AdultSection.kt index 90c7c2f..b78002a 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/AdultSection.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/AdultSection.kt @@ -1,4 +1,4 @@ -package dev.datlag.aniflow.ui.navigation.screen.settings.component +package dev.datlag.aniflow.ui.navigation.screen.home.dialog.settings.component import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/CharacterSection.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/CharacterSection.kt similarity index 97% rename from composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/CharacterSection.kt rename to composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/CharacterSection.kt index bfc81f0..3c89c14 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/CharacterSection.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/CharacterSection.kt @@ -1,4 +1,4 @@ -package dev.datlag.aniflow.ui.navigation.screen.settings.component +package dev.datlag.aniflow.ui.navigation.screen.home.dialog.settings.component import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/ColorSection.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/ColorSection.kt similarity index 97% rename from composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/ColorSection.kt rename to composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/ColorSection.kt index 7eb3a2b..c14a620 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/ColorSection.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/ColorSection.kt @@ -1,4 +1,4 @@ -package dev.datlag.aniflow.ui.navigation.screen.settings.component +package dev.datlag.aniflow.ui.navigation.screen.home.dialog.settings.component import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/DomainSection.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/DomainSection.kt similarity index 66% rename from composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/DomainSection.kt rename to composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/DomainSection.kt index 965d9c3..7e6a960 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/DomainSection.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/DomainSection.kt @@ -1,4 +1,4 @@ -package dev.datlag.aniflow.ui.navigation.screen.settings.component +package dev.datlag.aniflow.ui.navigation.screen.home.dialog.settings.component import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/TitleSection.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/TitleSection.kt similarity index 97% rename from composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/TitleSection.kt rename to composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/TitleSection.kt index 017f437..7607813 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/TitleSection.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/TitleSection.kt @@ -1,4 +1,4 @@ -package dev.datlag.aniflow.ui.navigation.screen.settings.component +package dev.datlag.aniflow.ui.navigation.screen.home.dialog.settings.component import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/UserSection.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/UserSection.kt similarity index 51% rename from composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/UserSection.kt rename to composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/UserSection.kt index 5bc3a1c..3a4efe1 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/UserSection.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/UserSection.kt @@ -1,10 +1,14 @@ -package dev.datlag.aniflow.ui.navigation.screen.settings.component +package dev.datlag.aniflow.ui.navigation.screen.home.dialog.settings.component -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.fadeIn +import androidx.compose.animation.fadeOut +import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.rounded.ArrowBackIosNew +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -34,7 +38,9 @@ import org.kodein.di.instance fun UserSection( userFlow: Flow, loginUri: String, + dismissVisible: Boolean, modifier: Modifier = Modifier, + onDismiss: () -> Unit, ) { val user by userFlow.collectAsStateWithLifecycle(null) @@ -45,22 +51,43 @@ fun UserSection( ) { val uriHandler = LocalUriHandler.current - AsyncImage( - modifier = Modifier.size(96.dp).clip(CircleShape).onClick( - enabled = user == null, + Box( + modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp), + contentAlignment = Alignment.Center + ) { + this@Column.AnimatedVisibility( + modifier = Modifier.align(Alignment.CenterStart), + visible = dismissVisible, + enter = fadeIn(), + exit = fadeOut() ) { - uriHandler.openUri(loginUri) - }, - model = user?.avatar?.large, - contentDescription = null, - error = rememberAsyncImagePainter( - model = user?.avatar?.medium, + IconButton( + onClick = onDismiss + ) { + Icon( + imageVector = Icons.Rounded.ArrowBackIosNew, + contentDescription = stringResource(SharedRes.strings.close) + ) + } + } + + AsyncImage( + modifier = Modifier.size(96.dp).clip(CircleShape).onClick( + enabled = user == null, + ) { + uriHandler.openUri(loginUri) + }, + model = user?.avatar?.large, + contentDescription = null, + error = rememberAsyncImagePainter( + model = user?.avatar?.medium, + contentScale = ContentScale.Crop, + error = painterResource(SharedRes.images.anilist) + ), contentScale = ContentScale.Crop, - error = painterResource(SharedRes.images.anilist) - ), - contentScale = ContentScale.Crop, - alignment = Alignment.Center - ) + alignment = Alignment.Center + ) + } Text( text = user?.name ?: stringResource(SharedRes.strings.settings), style = MaterialTheme.typography.headlineMedium, diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/dialog/character/CharacterDialog.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/dialog/character/CharacterDialog.kt index 4fcc449..d5160ee 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/dialog/character/CharacterDialog.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/dialog/character/CharacterDialog.kt @@ -10,6 +10,7 @@ import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.* +import androidx.compose.material.icons.rounded.ArrowBackIosNew import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.Alignment @@ -72,7 +73,7 @@ fun CharacterDialog(component: CharacterComponent) { onClick = component::dismiss ) { Icon( - imageVector = Icons.Default.ArrowBackIosNew, + imageVector = Icons.Rounded.ArrowBackIosNew, contentDescription = stringResource(SharedRes.strings.close) ) } diff --git a/composeApp/src/iosMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/DomainSection.ios.kt b/composeApp/src/iosMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/DomainSection.ios.kt similarity index 64% rename from composeApp/src/iosMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/DomainSection.ios.kt rename to composeApp/src/iosMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/DomainSection.ios.kt index 8fe2b8e..1cb2e89 100644 --- a/composeApp/src/iosMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/settings/component/DomainSection.ios.kt +++ b/composeApp/src/iosMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/DomainSection.ios.kt @@ -1,4 +1,4 @@ -package dev.datlag.aniflow.ui.navigation.screen.settings.component +package dev.datlag.aniflow.ui.navigation.screen.home.dialog.settings.component import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier