-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
170 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...c/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/discover/DiscoverComponent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package dev.datlag.aniflow.ui.navigation.screen.discover | ||
|
||
import dev.datlag.aniflow.ui.navigation.Component | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface DiscoverComponent : Component { | ||
val loggedIn: Flow<Boolean> | ||
|
||
fun viewHome() | ||
fun viewList() | ||
} |
98 changes: 98 additions & 0 deletions
98
.../src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/discover/DiscoverScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package dev.datlag.aniflow.ui.navigation.screen.discover | ||
|
||
import androidx.compose.animation.core.animateDpAsState | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.foundation.lazy.rememberLazyListState | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.rounded.Search | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.SearchBar | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import dev.chrisbanes.haze.haze | ||
import dev.datlag.aniflow.LocalHaze | ||
import dev.datlag.aniflow.SharedRes | ||
import dev.datlag.aniflow.common.merge | ||
import dev.datlag.aniflow.common.scrollUpVisible | ||
import dev.datlag.aniflow.ui.navigation.screen.component.HidingNavigationBar | ||
import dev.datlag.aniflow.ui.navigation.screen.component.NavigationBarState | ||
import dev.icerock.moko.resources.compose.stringResource | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun DiscoverScreen(component: DiscoverComponent) { | ||
val listState = rememberLazyListState() | ||
|
||
Scaffold( | ||
topBar = { | ||
var query by remember { mutableStateOf("") } | ||
var active by remember { mutableStateOf(false) } | ||
|
||
val activePadding by animateDpAsState( | ||
targetValue = if (active) 0.dp else 16.dp | ||
) | ||
|
||
SearchBar( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = activePadding) | ||
.padding(bottom = activePadding), | ||
query = query, | ||
onQueryChange = { | ||
query = it | ||
}, | ||
active = active, | ||
onActiveChange = { | ||
active = it | ||
}, | ||
onSearch = { | ||
query = it | ||
}, | ||
leadingIcon = { | ||
Icon( | ||
imageVector = Icons.Rounded.Search, | ||
contentDescription = null | ||
) | ||
}, | ||
placeholder = { | ||
Text(text = stringResource(SharedRes.strings.search)) | ||
}, | ||
content = { } | ||
) | ||
}, | ||
bottomBar = { | ||
HidingNavigationBar( | ||
visible = listState.scrollUpVisible(), | ||
selected = NavigationBarState.Discover, | ||
loggedIn = component.loggedIn, | ||
onDiscover = { }, | ||
onHome = component::viewHome, | ||
onFavorites = component::viewList | ||
) | ||
} | ||
) { padding -> | ||
LazyColumn( | ||
state = listState, | ||
modifier = Modifier.fillMaxSize().haze(state = LocalHaze.current), | ||
contentPadding = padding.merge(PaddingValues(16.dp)), | ||
verticalArrangement = Arrangement.spacedBy(16.dp), | ||
) { | ||
item { | ||
Text("Discover Screen") | ||
} | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...onMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/discover/DiscoverScreenComponent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package dev.datlag.aniflow.ui.navigation.screen.discover | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.CompositionLocalProvider | ||
import androidx.compose.runtime.remember | ||
import com.arkivanov.decompose.ComponentContext | ||
import dev.chrisbanes.haze.HazeState | ||
import dev.datlag.aniflow.LocalHaze | ||
import dev.datlag.aniflow.common.onRender | ||
import dev.datlag.aniflow.other.UserHelper | ||
import kotlinx.coroutines.flow.Flow | ||
import org.kodein.di.DI | ||
import org.kodein.di.instance | ||
|
||
class DiscoverScreenComponent( | ||
componentContext: ComponentContext, | ||
override val di: DI, | ||
private val onHome: () -> Unit, | ||
private val onList: () -> Unit, | ||
) : DiscoverComponent, ComponentContext by componentContext { | ||
|
||
private val userHelper by instance<UserHelper>() | ||
override val loggedIn: Flow<Boolean> = userHelper.isLoggedIn | ||
|
||
@Composable | ||
override fun render() { | ||
val haze = remember { HazeState() } | ||
|
||
CompositionLocalProvider( | ||
LocalHaze provides haze | ||
) { | ||
onRender { | ||
DiscoverScreen(this) | ||
} | ||
} | ||
} | ||
|
||
override fun viewHome() { | ||
onHome() | ||
} | ||
|
||
override fun viewList() { | ||
onList() | ||
} | ||
} |