Skip to content

Commit

Permalink
support edge-to-edge
Browse files Browse the repository at this point in the history
  • Loading branch information
soupslurpr authored and thestinger committed Oct 27, 2024
1 parent 4b2d8ad commit 8b464d1
Show file tree
Hide file tree
Showing 15 changed files with 182 additions and 63 deletions.
68 changes: 55 additions & 13 deletions app/src/main/kotlin/app/grapheneos/info/InfoApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideIn
import androidx.compose.animation.slideOut
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.calculateEndPadding
import androidx.compose.foundation.layout.calculateStartPadding
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.icons.Icons
Expand Down Expand Up @@ -42,11 +46,13 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NamedNavArgument
import androidx.navigation.NavBackStackEntry
Expand Down Expand Up @@ -149,6 +155,8 @@ fun InfoApp() {
currentWindowAdaptiveInfo()
)

val layoutDirection = LocalLayoutDirection.current

NavigationSuiteScaffold(
navigationSuiteItems = {
navSuiteItemScreens.forEach { navSuiteItemScreen ->
Expand Down Expand Up @@ -267,15 +275,18 @@ fun InfoApp() {
NavHost(
navController = navController,
startDestination = startDestination,
modifier = Modifier.padding(innerPadding),
) {
composableWithDefaultSlideTransitions(
route = InfoAppScreens.ReleaseNotes,
navigationSuiteType = navigationSuiteType,
) {
ReleaseNotesScreen(
releaseNotesUiState.value.entries.toSortedMap().toList().asReversed(),
{ useCaches, onFinishedUpdating ->
modifier = Modifier
.padding(top = innerPadding.calculateTopPadding())
.consumeWindowInsets(innerPadding),
entries =
releaseNotesUiState.value.entries.toSortedMap().toList().asReversed(),
updateReleaseNotes = { useCaches, onFinishedUpdating ->
releaseNotesViewModel.updateReleaseNotes(
useCaches = useCaches,
showSnackbarError = {
Expand All @@ -291,19 +302,27 @@ fun InfoApp() {
onFinishedUpdating = onFinishedUpdating,
)
},
releaseNotesLazyListState,
lazyListState = releaseNotesLazyListState,
additionalContentPadding = PaddingValues(
start = innerPadding.calculateStartPadding(layoutDirection),
top = 0.dp,
end = innerPadding.calculateEndPadding(layoutDirection),
bottom = innerPadding.calculateBottomPadding()
)
)
}
composableWithDefaultSlideTransitions(
route = InfoAppScreens.Community,
navigationSuiteType = navigationSuiteType,
) {
CommunityScreen(
modifier = Modifier.consumeWindowInsets(innerPadding),
showSnackbarError = {
snackbarCoroutine.launch {
snackbarHostState.showSnackbar(it)
}
},
additionalContentPadding = innerPadding
)
}
navigationWithDefaultSlideTransitions(
Expand All @@ -316,6 +335,7 @@ fun InfoApp() {
navigationSuiteType = navigationSuiteType,
) {
DonateStartScreen(
modifier = Modifier.consumeWindowInsets(innerPadding),
onNavigateToGithubSponsorsScreen = {
navController.navigate(InfoAppScreens.DonateGithubSponsors.name)
},
Expand All @@ -327,19 +347,22 @@ fun InfoApp() {
},
onNavigateToBankTransfersScreen = {
navController.navigate(InfoAppScreens.DonateBankTransfers.name)
}
},
additionalContentPadding = innerPadding
)
}
composableWithDefaultSlideTransitions(
route = InfoAppScreens.DonateGithubSponsors,
navigationSuiteType = navigationSuiteType,
) {
GithubSponsorsScreen(
modifier = Modifier.consumeWindowInsets(innerPadding),
showSnackbarError = {
snackbarCoroutine.launch {
snackbarHostState.showSnackbar(it)
}
},
additionalContentPadding = innerPadding
)
}
navigationWithDefaultSlideTransitions(
Expand All @@ -352,6 +375,7 @@ fun InfoApp() {
navigationSuiteType = navigationSuiteType,
) {
DonateCryptoCurrencyStartScreen(
modifier = Modifier.consumeWindowInsets(innerPadding),
onNavigateToBitcoinScreen = {
navController.navigate(InfoAppScreens.DonateCryptocurrenciesBitcoin.name)
},
Expand All @@ -369,79 +393,92 @@ fun InfoApp() {
},
onNavigateToLitecoinScreen = {
navController.navigate(InfoAppScreens.DonateCryptocurrenciesLitecoin.name)
}
},
additionalContentPadding = innerPadding
)
}
composableWithDefaultSlideTransitions(
route = InfoAppScreens.DonateCryptocurrenciesBitcoin,
navigationSuiteType = navigationSuiteType,
) {
BitcoinScreen(
modifier = Modifier.consumeWindowInsets(innerPadding),
showSnackbarError = {
snackbarCoroutine.launch {
snackbarHostState.showSnackbar(it)
}
},
additionalContentPadding = innerPadding
)
}
composableWithDefaultSlideTransitions(
route = InfoAppScreens.DonateCryptocurrenciesMonero,
navigationSuiteType = navigationSuiteType,
) {
MoneroScreen(
modifier = Modifier.consumeWindowInsets(innerPadding),
showSnackbarError = {
snackbarCoroutine.launch {
snackbarHostState.showSnackbar(it)
}
}
},
additionalContentPadding = innerPadding
)
}
composableWithDefaultSlideTransitions(
route = InfoAppScreens.DonateCryptocurrenciesZcash,
navigationSuiteType = navigationSuiteType,
) {
ZcashScreen(
modifier = Modifier.consumeWindowInsets(innerPadding),
showSnackbarError = {
snackbarCoroutine.launch {
snackbarHostState.showSnackbar(it)
}
}
},
additionalContentPadding = innerPadding
)
}
composableWithDefaultSlideTransitions(
route = InfoAppScreens.DonateCryptocurrenciesEthereum,
navigationSuiteType = navigationSuiteType,
) {
EthereumScreen(
modifier = Modifier.consumeWindowInsets(innerPadding),
showSnackbarError = {
snackbarCoroutine.launch {
snackbarHostState.showSnackbar(it)
}
}
},
additionalContentPadding = innerPadding
)
}
composableWithDefaultSlideTransitions(
route = InfoAppScreens.DonateCryptocurrenciesCardano,
navigationSuiteType = navigationSuiteType,
) {
CardanoScreen(
modifier = Modifier.consumeWindowInsets(innerPadding),
showSnackbarError = {
snackbarCoroutine.launch {
snackbarHostState.showSnackbar(it)
}
}
},
additionalContentPadding = innerPadding
)
}
composableWithDefaultSlideTransitions(
route = InfoAppScreens.DonateCryptocurrenciesLitecoin,
navigationSuiteType = navigationSuiteType,
) {
LitecoinScreen(
modifier = Modifier.consumeWindowInsets(innerPadding),
showSnackbarError = {
snackbarCoroutine.launch {
snackbarHostState.showSnackbar(it)
}
}
},
additionalContentPadding = innerPadding
)
}
}
Expand All @@ -450,18 +487,23 @@ fun InfoApp() {
navigationSuiteType = navigationSuiteType,
) {
PaypalScreen(
modifier = Modifier.consumeWindowInsets(innerPadding),
showSnackbarError = {
snackbarCoroutine.launch {
snackbarHostState.showSnackbar(it)
}
}
},
additionalContentPadding = innerPadding
)
}
composableWithDefaultSlideTransitions(
route = InfoAppScreens.DonateBankTransfers,
navigationSuiteType = navigationSuiteType,
) {
BankTransfersScreen()
BankTransfersScreen(
modifier = Modifier.consumeWindowInsets(innerPadding),
additionalContentPadding = innerPadding
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app.grapheneos.info.ui.community

import android.content.res.Configuration.UI_MODE_NIGHT_UNDEFINED
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
Expand All @@ -20,10 +21,15 @@ import app.grapheneos.info.ui.reusablecomposables.LinkCardItem
import app.grapheneos.info.ui.reusablecomposables.ScreenLazyColumn

@Composable
fun CommunityScreen(showSnackbarError: (String) -> Unit) {
fun CommunityScreen(
modifier: Modifier = Modifier,
showSnackbarError: (String) -> Unit = {},
additionalContentPadding: PaddingValues = PaddingValues(0.dp)
) {
ScreenLazyColumn(
modifier = Modifier
modifier = modifier
.fillMaxSize(),
additionalContentPadding = additionalContentPadding
) {
item {
Text(
Expand Down Expand Up @@ -128,6 +134,6 @@ fun CommunityScreen(showSnackbarError: (String) -> Unit) {
@Composable
private fun CommunityScreenPreview() {
MaterialTheme {
CommunityScreen({})
CommunityScreen()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package app.grapheneos.info.ui.donate

import android.content.res.Configuration
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
Expand Down Expand Up @@ -29,14 +30,17 @@ import app.grapheneos.info.ui.reusablecomposables.ScreenNavCardItem

@Composable
fun DonateStartScreen(
onNavigateToGithubSponsorsScreen: () -> Unit,
onNavigateToCryptocurrenciesScreen: () -> Unit,
onNavigateToPayPalScreen: () -> Unit,
onNavigateToBankTransfersScreen: () -> Unit,
modifier: Modifier = Modifier,
onNavigateToGithubSponsorsScreen: () -> Unit = {},
onNavigateToCryptocurrenciesScreen: () -> Unit = {},
onNavigateToPayPalScreen: () -> Unit = {},
onNavigateToBankTransfersScreen: () -> Unit = {},
additionalContentPadding: PaddingValues = PaddingValues(0.dp)
) {
ScreenLazyColumn(
modifier = Modifier
modifier = modifier
.fillMaxSize(),
additionalContentPadding = additionalContentPadding
) {
item {
Text(stringResource(R.string.donate_start_info_part_1))
Expand Down Expand Up @@ -135,6 +139,6 @@ fun DonateStartScreen(
@Composable
private fun DonateScreenPreview() {
MaterialTheme {
DonateStartScreen({}, {}, {}, {})
DonateStartScreen()
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app.grapheneos.info.ui.donate

import android.content.res.Configuration
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
Expand All @@ -14,18 +15,24 @@ import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.Wallpapers
import androidx.compose.ui.unit.dp
import app.grapheneos.info.R
import app.grapheneos.info.ui.reusablecomposables.ClickableText
import app.grapheneos.info.ui.reusablecomposables.LinkCardItem
import app.grapheneos.info.ui.reusablecomposables.ScreenLazyColumn

@Composable
fun GithubSponsorsScreen(showSnackbarError: (String) -> Unit) {
fun GithubSponsorsScreen(
modifier: Modifier = Modifier,
showSnackbarError: (String) -> Unit = {},
additionalContentPadding: PaddingValues = PaddingValues(0.dp)
) {
val githubSponsorsUrl = "https://github.com/sponsors/thestinger"

ScreenLazyColumn(
modifier = Modifier
modifier = modifier
.fillMaxSize(),
additionalContentPadding = additionalContentPadding
) {
item {
val localUriHandler = LocalUriHandler.current
Expand Down Expand Up @@ -78,6 +85,6 @@ fun GithubSponsorsScreen(showSnackbarError: (String) -> Unit) {
@Composable
private fun GithubSponsorsScreenPreview() {
MaterialTheme {
GithubSponsorsScreen({})
GithubSponsorsScreen()
}
}
Loading

0 comments on commit 8b464d1

Please sign in to comment.