fix: navigation bar scrollables and paddings
This commit is contained in:
parent
d393051b1d
commit
85a42b23c6
11 changed files with 101 additions and 36 deletions
|
@ -19,9 +19,7 @@ import androidx.core.view.WindowCompat
|
||||||
import com.simplemobiletools.commons.R
|
import com.simplemobiletools.commons.R
|
||||||
import com.simplemobiletools.commons.compose.extensions.AdjustNavigationBarColors
|
import com.simplemobiletools.commons.compose.extensions.AdjustNavigationBarColors
|
||||||
import com.simplemobiletools.commons.compose.extensions.TransparentSystemBars
|
import com.simplemobiletools.commons.compose.extensions.TransparentSystemBars
|
||||||
import com.simplemobiletools.commons.compose.screens.AboutScreen
|
import com.simplemobiletools.commons.compose.screens.*
|
||||||
import com.simplemobiletools.commons.compose.screens.AboutSection
|
|
||||||
import com.simplemobiletools.commons.compose.screens.HelpUsSection
|
|
||||||
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
|
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
|
||||||
import com.simplemobiletools.commons.dialogs.ConfirmationAdvancedDialog
|
import com.simplemobiletools.commons.dialogs.ConfirmationAdvancedDialog
|
||||||
import com.simplemobiletools.commons.dialogs.RateStarsDialog
|
import com.simplemobiletools.commons.dialogs.RateStarsDialog
|
||||||
|
@ -74,17 +72,17 @@ class AboutActivity : ComponentActivity() {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
socialSection = {
|
socialSection = {
|
||||||
/*if (showExternalLinks) {
|
if (showExternalLinks) {
|
||||||
SocialSection(
|
SocialSection(
|
||||||
onFacebookClick = ::onFacebookClick,
|
onFacebookClick = ::onFacebookClick,
|
||||||
onGithubClick = ::onGithubClick,
|
onGithubClick = ::onGithubClick,
|
||||||
onRedditClick = ::onRedditClick,
|
onRedditClick = ::onRedditClick,
|
||||||
onTelegramClick = ::onTelegramClick
|
onTelegramClick = ::onTelegramClick
|
||||||
)
|
)
|
||||||
}*/
|
}
|
||||||
},
|
},
|
||||||
otherSection = {
|
otherSection = {
|
||||||
/* val showWebsite = remember { resources.getBoolean(R.bool.show_donate_in_about) && !showExternalLinks }
|
val showWebsite = remember { resources.getBoolean(R.bool.show_donate_in_about) && !showExternalLinks }
|
||||||
var version = intent.getStringExtra(APP_VERSION_NAME) ?: ""
|
var version = intent.getStringExtra(APP_VERSION_NAME) ?: ""
|
||||||
if (baseConfig.appId.removeSuffix(".debug").endsWith(".pro")) {
|
if (baseConfig.appId.removeSuffix(".debug").endsWith(".pro")) {
|
||||||
version += " ${getString(R.string.pro)}"
|
version += " ${getString(R.string.pro)}"
|
||||||
|
@ -101,7 +99,7 @@ class AboutActivity : ComponentActivity() {
|
||||||
onLicenseClick = ::onLicenseClick,
|
onLicenseClick = ::onLicenseClick,
|
||||||
version = fullVersion,
|
version = fullVersion,
|
||||||
onVersionClick = ::onVersionClick
|
onVersionClick = ::onVersionClick
|
||||||
)*/
|
)
|
||||||
},
|
},
|
||||||
canScroll = { isContentScrollable ->
|
canScroll = { isContentScrollable ->
|
||||||
canScroll = isContentScrollable
|
canScroll = isContentScrollable
|
||||||
|
|
|
@ -3,9 +3,13 @@ package com.simplemobiletools.commons.activities
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
import com.simplemobiletools.commons.R
|
import com.simplemobiletools.commons.R
|
||||||
|
import com.simplemobiletools.commons.compose.extensions.AdjustNavigationBarColors
|
||||||
import com.simplemobiletools.commons.compose.extensions.TransparentSystemBars
|
import com.simplemobiletools.commons.compose.extensions.TransparentSystemBars
|
||||||
import com.simplemobiletools.commons.compose.screens.ContributorsScreen
|
import com.simplemobiletools.commons.compose.screens.ContributorsScreen
|
||||||
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
|
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
|
||||||
|
@ -19,6 +23,8 @@ class ContributorsActivity : AppCompatActivity() {
|
||||||
setContent {
|
setContent {
|
||||||
TransparentSystemBars()
|
TransparentSystemBars()
|
||||||
AppThemeSurface {
|
AppThemeSurface {
|
||||||
|
var canScroll by remember { mutableStateOf<Boolean?>(null) }
|
||||||
|
AdjustNavigationBarColors(canScroll)
|
||||||
val contributors = remember {
|
val contributors = remember {
|
||||||
languageContributors()
|
languageContributors()
|
||||||
}
|
}
|
||||||
|
@ -28,7 +34,8 @@ class ContributorsActivity : AppCompatActivity() {
|
||||||
ContributorsScreen(
|
ContributorsScreen(
|
||||||
goBack = ::finish,
|
goBack = ::finish,
|
||||||
showContributorsLabel = showContributorsLabel,
|
showContributorsLabel = showContributorsLabel,
|
||||||
contributors = contributors
|
contributors = contributors,
|
||||||
|
canScroll = { canPerformScroll -> canScroll = canPerformScroll }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,12 @@ package com.simplemobiletools.commons.activities
|
||||||
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.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
|
import com.simplemobiletools.commons.compose.extensions.AdjustNavigationBarColors
|
||||||
import com.simplemobiletools.commons.compose.extensions.TransparentSystemBars
|
import com.simplemobiletools.commons.compose.extensions.TransparentSystemBars
|
||||||
import com.simplemobiletools.commons.compose.screens.FAQScreen
|
import com.simplemobiletools.commons.compose.screens.FAQScreen
|
||||||
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
|
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
|
||||||
|
@ -19,8 +23,14 @@ class FAQActivity : ComponentActivity() {
|
||||||
setContent {
|
setContent {
|
||||||
TransparentSystemBars()
|
TransparentSystemBars()
|
||||||
AppThemeSurface {
|
AppThemeSurface {
|
||||||
|
var canScroll by remember { mutableStateOf<Boolean?>(null) }
|
||||||
|
AdjustNavigationBarColors(canScroll)
|
||||||
val faqItems = remember { intent.getSerializableExtra(APP_FAQ) as ArrayList<FAQItem> }
|
val faqItems = remember { intent.getSerializableExtra(APP_FAQ) as ArrayList<FAQItem> }
|
||||||
FAQScreen(goBack = ::finish, faqItems = faqItems.toImmutableList())
|
FAQScreen(
|
||||||
|
goBack = ::finish,
|
||||||
|
faqItems = faqItems.toImmutableList(),
|
||||||
|
canScroll = { canPerformScroll -> canScroll = canPerformScroll }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,13 @@ package com.simplemobiletools.commons.activities
|
||||||
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.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
import com.simplemobiletools.commons.R
|
import com.simplemobiletools.commons.R
|
||||||
|
import com.simplemobiletools.commons.compose.extensions.AdjustNavigationBarColors
|
||||||
import com.simplemobiletools.commons.compose.extensions.TransparentSystemBars
|
import com.simplemobiletools.commons.compose.extensions.TransparentSystemBars
|
||||||
import com.simplemobiletools.commons.compose.screens.LicenseScreen
|
import com.simplemobiletools.commons.compose.screens.LicenseScreen
|
||||||
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
|
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
|
||||||
|
@ -23,7 +27,14 @@ class LicenseActivity : ComponentActivity() {
|
||||||
val thirdPartyLicenses = remember { initLicenses().filter { licenseMask and it.id != 0L }.toImmutableList() }
|
val thirdPartyLicenses = remember { initLicenses().filter { licenseMask and it.id != 0L }.toImmutableList() }
|
||||||
TransparentSystemBars()
|
TransparentSystemBars()
|
||||||
AppThemeSurface {
|
AppThemeSurface {
|
||||||
LicenseScreen(goBack = ::finish, thirdPartyLicenses = thirdPartyLicenses, onLicenseClick = ::launchViewIntent)
|
var canScroll by remember { mutableStateOf<Boolean?>(null) }
|
||||||
|
AdjustNavigationBarColors(canScroll)
|
||||||
|
LicenseScreen(
|
||||||
|
goBack = ::finish,
|
||||||
|
thirdPartyLicenses = thirdPartyLicenses,
|
||||||
|
onLicenseClick = ::launchViewIntent,
|
||||||
|
canScroll = { canPerformScroll -> canScroll = canPerformScroll }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ fun AdjustNavigationBarColors(canScroll: Boolean?) {
|
||||||
val isSystemInDarkTheme = isSystemInDarkTheme()
|
val isSystemInDarkTheme = isSystemInDarkTheme()
|
||||||
val isSurfaceLitWell = MaterialTheme.colorScheme.surface.isLitWell()
|
val isSurfaceLitWell = MaterialTheme.colorScheme.surface.isLitWell()
|
||||||
val navigationBarColor = when (canScroll) {
|
val navigationBarColor = when (canScroll) {
|
||||||
true -> Color(MaterialTheme.colorScheme.surface.toArgb().darkenColor(factor = 1)).copy(alpha = 0.5f)
|
true -> Color(MaterialTheme.colorScheme.surface.toArgb().darkenColor()).copy(alpha = 0.5f)
|
||||||
else -> Color.Transparent
|
else -> Color.Transparent
|
||||||
}
|
}
|
||||||
DisposableEffect(systemUiController, !isSystemInDarkTheme, navigationBarColor) {
|
DisposableEffect(systemUiController, !isSystemInDarkTheme, navigationBarColor) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ import com.simplemobiletools.commons.compose.settings.SettingsTitleTextComponent
|
||||||
import com.simplemobiletools.commons.compose.settings.scaffold.SettingsScaffold
|
import com.simplemobiletools.commons.compose.settings.scaffold.SettingsScaffold
|
||||||
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
|
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
|
||||||
|
|
||||||
private val startingTitlePadding = Modifier.padding(start = 64.dp)
|
private val startingTitlePadding = Modifier.padding(start = 58.dp)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
internal fun AboutScreen(
|
internal fun AboutScreen(
|
||||||
|
|
|
@ -27,15 +27,17 @@ import com.simplemobiletools.commons.models.LanguageContributor
|
||||||
import kotlinx.collections.immutable.ImmutableList
|
import kotlinx.collections.immutable.ImmutableList
|
||||||
import kotlinx.collections.immutable.toImmutableList
|
import kotlinx.collections.immutable.toImmutableList
|
||||||
|
|
||||||
private val startingPadding = Modifier.padding(start = 62.dp)
|
private val startingPadding = Modifier.padding(start = 58.dp)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
internal fun ContributorsScreen(
|
internal fun ContributorsScreen(
|
||||||
goBack: () -> Unit,
|
goBack: () -> Unit,
|
||||||
showContributorsLabel: Boolean,
|
showContributorsLabel: Boolean,
|
||||||
contributors: ImmutableList<LanguageContributor>
|
contributors: ImmutableList<LanguageContributor>,
|
||||||
|
canScroll: (canPerformScroll: Boolean) -> Unit,
|
||||||
) {
|
) {
|
||||||
SettingsLazyScaffold(
|
SettingsLazyScaffold(
|
||||||
|
canScroll = canScroll,
|
||||||
title = { scrolledColor ->
|
title = { scrolledColor ->
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(id = R.string.contributors),
|
text = stringResource(id = R.string.contributors),
|
||||||
|
@ -148,7 +150,8 @@ private fun ContributorsScreenPreview() {
|
||||||
LanguageContributor(R.drawable.ic_flag_bengali_vector, R.string.translation_bengali, R.string.translators_bengali),
|
LanguageContributor(R.drawable.ic_flag_bengali_vector, R.string.translation_bengali, R.string.translators_bengali),
|
||||||
LanguageContributor(R.drawable.ic_flag_catalan_vector, R.string.translation_catalan, R.string.translators_catalan),
|
LanguageContributor(R.drawable.ic_flag_catalan_vector, R.string.translation_catalan, R.string.translators_catalan),
|
||||||
).toImmutableList(),
|
).toImmutableList(),
|
||||||
showContributorsLabel = true
|
showContributorsLabel = true,
|
||||||
|
canScroll = {}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,12 +34,14 @@ import kotlinx.collections.immutable.toImmutableList
|
||||||
@Composable
|
@Composable
|
||||||
internal fun FAQScreen(
|
internal fun FAQScreen(
|
||||||
goBack: () -> Unit,
|
goBack: () -> Unit,
|
||||||
faqItems: ImmutableList<FAQItem>
|
faqItems: ImmutableList<FAQItem>,
|
||||||
|
canScroll: (canPerformScroll: Boolean) -> Unit,
|
||||||
) {
|
) {
|
||||||
SettingsLazyScaffold(
|
SettingsLazyScaffold(
|
||||||
title = stringResource(id = R.string.frequently_asked_questions),
|
title = stringResource(id = R.string.frequently_asked_questions),
|
||||||
goBack = goBack,
|
goBack = goBack,
|
||||||
contentPadding = PaddingValues(bottom = 8.dp),
|
contentPadding = PaddingValues(bottom = 8.dp),
|
||||||
|
canScroll = canScroll
|
||||||
) { paddingValues ->
|
) { paddingValues ->
|
||||||
itemsIndexed(faqItems) { index, faqItem ->
|
itemsIndexed(faqItems) { index, faqItem ->
|
||||||
Column(modifier = Modifier.fillMaxWidth()) {
|
Column(modifier = Modifier.fillMaxWidth()) {
|
||||||
|
@ -74,9 +76,11 @@ internal fun FAQScreen(
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.padding(bottom = 8.dp))
|
Spacer(modifier = Modifier.padding(bottom = 8.dp))
|
||||||
if (index != faqItems.lastIndex) {
|
if (index != faqItems.lastIndex) {
|
||||||
SettingsHorizontalDivider(modifier = Modifier
|
SettingsHorizontalDivider(
|
||||||
.fillMaxWidth()
|
modifier = Modifier
|
||||||
.padding(bottom = 4.dp))
|
.fillMaxWidth()
|
||||||
|
.padding(bottom = 4.dp)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,7 +129,8 @@ private fun FAQScreenPreview() {
|
||||||
FAQItem(R.string.faq_4_title_commons, R.string.faq_4_text_commons),
|
FAQItem(R.string.faq_4_title_commons, R.string.faq_4_text_commons),
|
||||||
FAQItem(R.string.faq_2_title_commons, R.string.faq_2_text_commons),
|
FAQItem(R.string.faq_2_title_commons, R.string.faq_2_text_commons),
|
||||||
FAQItem(R.string.faq_6_title_commons, R.string.faq_6_text_commons)
|
FAQItem(R.string.faq_6_title_commons, R.string.faq_6_text_commons)
|
||||||
).toImmutableList()
|
).toImmutableList(),
|
||||||
|
canScroll = {}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,14 @@ import kotlinx.collections.immutable.toImmutableList
|
||||||
internal fun LicenseScreen(
|
internal fun LicenseScreen(
|
||||||
goBack: () -> Unit,
|
goBack: () -> Unit,
|
||||||
thirdPartyLicenses: ImmutableList<License>,
|
thirdPartyLicenses: ImmutableList<License>,
|
||||||
onLicenseClick: (urlId: Int) -> Unit
|
onLicenseClick: (urlId: Int) -> Unit,
|
||||||
|
canScroll: (canPerformScroll: Boolean) -> Unit,
|
||||||
) {
|
) {
|
||||||
SettingsLazyScaffold(title = stringResource(id = R.string.third_party_licences), goBack = goBack) { paddingValues ->
|
SettingsLazyScaffold(
|
||||||
|
title = stringResource(id = R.string.third_party_licences),
|
||||||
|
goBack = goBack,
|
||||||
|
canScroll = canScroll
|
||||||
|
) { paddingValues ->
|
||||||
itemsIndexed(thirdPartyLicenses) { index, license ->
|
itemsIndexed(thirdPartyLicenses) { index, license ->
|
||||||
Column {
|
Column {
|
||||||
LicenseItem(license, onLicenseClick)
|
LicenseItem(license, onLicenseClick)
|
||||||
|
@ -114,7 +119,8 @@ private fun LicenseScreenPreview() {
|
||||||
).toImmutableList(),
|
).toImmutableList(),
|
||||||
onLicenseClick = {
|
onLicenseClick = {
|
||||||
|
|
||||||
}
|
},
|
||||||
|
canScroll = {}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.AccessTime
|
import androidx.compose.material.icons.filled.AccessTime
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.remember
|
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
|
||||||
|
@ -30,7 +31,6 @@ fun SettingsLazyScaffold(
|
||||||
title: String,
|
title: String,
|
||||||
goBack: () -> Unit,
|
goBack: () -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
state: LazyListState = rememberLazyListState(),
|
|
||||||
contentPadding: PaddingValues = PaddingValues(0.dp),
|
contentPadding: PaddingValues = PaddingValues(0.dp),
|
||||||
reverseLayout: Boolean = false,
|
reverseLayout: Boolean = false,
|
||||||
verticalArrangement: Arrangement.Vertical =
|
verticalArrangement: Arrangement.Vertical =
|
||||||
|
@ -38,6 +38,8 @@ fun SettingsLazyScaffold(
|
||||||
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
|
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
|
||||||
flingBehavior: FlingBehavior = ScrollableDefaults.flingBehavior(),
|
flingBehavior: FlingBehavior = ScrollableDefaults.flingBehavior(),
|
||||||
userScrollEnabled: Boolean = true,
|
userScrollEnabled: Boolean = true,
|
||||||
|
canScroll: ((canPerformScroll: Boolean) -> Unit)? = null,
|
||||||
|
state: LazyListState = verticalScrollState(canScroll),
|
||||||
lazyContent: LazyListScope.(PaddingValues) -> Unit
|
lazyContent: LazyListScope.(PaddingValues) -> Unit
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
@ -89,7 +91,6 @@ fun SettingsLazyScaffold(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
title: @Composable (scrolledColor: Color) -> Unit,
|
title: @Composable (scrolledColor: Color) -> Unit,
|
||||||
goBack: () -> Unit,
|
goBack: () -> Unit,
|
||||||
state: LazyListState = rememberLazyListState(),
|
|
||||||
contentPadding: PaddingValues = PaddingValues(0.dp),
|
contentPadding: PaddingValues = PaddingValues(0.dp),
|
||||||
reverseLayout: Boolean = false,
|
reverseLayout: Boolean = false,
|
||||||
verticalArrangement: Arrangement.Vertical =
|
verticalArrangement: Arrangement.Vertical =
|
||||||
|
@ -97,6 +98,8 @@ fun SettingsLazyScaffold(
|
||||||
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
|
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
|
||||||
flingBehavior: FlingBehavior = ScrollableDefaults.flingBehavior(),
|
flingBehavior: FlingBehavior = ScrollableDefaults.flingBehavior(),
|
||||||
userScrollEnabled: Boolean = true,
|
userScrollEnabled: Boolean = true,
|
||||||
|
canScroll: ((canPerformScroll: Boolean) -> Unit)? = null,
|
||||||
|
state: LazyListState = verticalScrollState(canScroll),
|
||||||
lazyContent: LazyListScope.(PaddingValues) -> Unit
|
lazyContent: LazyListScope.(PaddingValues) -> Unit
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
@ -148,7 +151,6 @@ fun SettingsLazyScaffold(
|
||||||
title: @Composable (scrolledColor: Color) -> Unit,
|
title: @Composable (scrolledColor: Color) -> Unit,
|
||||||
actions: @Composable RowScope.() -> Unit,
|
actions: @Composable RowScope.() -> Unit,
|
||||||
goBack: () -> Unit,
|
goBack: () -> Unit,
|
||||||
state: LazyListState = rememberLazyListState(),
|
|
||||||
contentPadding: PaddingValues = PaddingValues(0.dp),
|
contentPadding: PaddingValues = PaddingValues(0.dp),
|
||||||
reverseLayout: Boolean = false,
|
reverseLayout: Boolean = false,
|
||||||
verticalArrangement: Arrangement.Vertical =
|
verticalArrangement: Arrangement.Vertical =
|
||||||
|
@ -156,6 +158,8 @@ fun SettingsLazyScaffold(
|
||||||
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
|
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
|
||||||
flingBehavior: FlingBehavior = ScrollableDefaults.flingBehavior(),
|
flingBehavior: FlingBehavior = ScrollableDefaults.flingBehavior(),
|
||||||
userScrollEnabled: Boolean = true,
|
userScrollEnabled: Boolean = true,
|
||||||
|
canScroll: ((canPerformScroll: Boolean) -> Unit)? = null,
|
||||||
|
state: LazyListState = verticalScrollState(canScroll),
|
||||||
lazyContent: LazyListScope.(PaddingValues) -> Unit
|
lazyContent: LazyListScope.(PaddingValues) -> Unit
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
@ -213,7 +217,6 @@ fun SettingsLazyScaffold(
|
||||||
colorTransitionFraction: Float,
|
colorTransitionFraction: Float,
|
||||||
contrastColor: Color,
|
contrastColor: Color,
|
||||||
) -> Unit,
|
) -> Unit,
|
||||||
state: LazyListState = rememberLazyListState(),
|
|
||||||
contentPadding: PaddingValues = PaddingValues(0.dp),
|
contentPadding: PaddingValues = PaddingValues(0.dp),
|
||||||
reverseLayout: Boolean = false,
|
reverseLayout: Boolean = false,
|
||||||
verticalArrangement: Arrangement.Vertical =
|
verticalArrangement: Arrangement.Vertical =
|
||||||
|
@ -221,6 +224,8 @@ fun SettingsLazyScaffold(
|
||||||
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
|
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
|
||||||
flingBehavior: FlingBehavior = ScrollableDefaults.flingBehavior(),
|
flingBehavior: FlingBehavior = ScrollableDefaults.flingBehavior(),
|
||||||
userScrollEnabled: Boolean = true,
|
userScrollEnabled: Boolean = true,
|
||||||
|
canScroll: ((canPerformScroll: Boolean) -> Unit)? = null,
|
||||||
|
state: LazyListState = verticalScrollState(canScroll),
|
||||||
lazyContent: LazyListScope.(PaddingValues) -> Unit
|
lazyContent: LazyListScope.(PaddingValues) -> Unit
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
@ -257,6 +262,15 @@ fun SettingsLazyScaffold(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun verticalScrollState(canScroll: ((canPerformScroll: Boolean) -> Unit)?): LazyListState {
|
||||||
|
val scrollState = rememberLazyListState()
|
||||||
|
LaunchedEffect(Unit) {
|
||||||
|
canScroll?.invoke(scrollState.canScrollForward || scrollState.canScrollBackward)
|
||||||
|
}
|
||||||
|
return scrollState
|
||||||
|
}
|
||||||
|
|
||||||
@MyDevices
|
@MyDevices
|
||||||
@Composable
|
@Composable
|
||||||
private fun SettingsLazyScaffoldPreview() {
|
private fun SettingsLazyScaffoldPreview() {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.simplemobiletools.commons.compose.settings.scaffold
|
package com.simplemobiletools.commons.compose.settings.scaffold
|
||||||
|
|
||||||
|
import androidx.compose.foundation.ScrollState
|
||||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
|
@ -27,7 +28,8 @@ fun SettingsScaffold(
|
||||||
verticalArrangement: Arrangement.Vertical =
|
verticalArrangement: Arrangement.Vertical =
|
||||||
if (!reverseLayout) Arrangement.Top else Arrangement.Bottom,
|
if (!reverseLayout) Arrangement.Top else Arrangement.Bottom,
|
||||||
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
|
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
|
||||||
canScroll: (canPerformScroll: Boolean) -> Unit = {},
|
canScroll: ((canPerformScroll: Boolean) -> Unit)? = null,
|
||||||
|
scrollState: ScrollState = verticalScrollState(canScroll),
|
||||||
content: @Composable ColumnScope.(PaddingValues) -> Unit
|
content: @Composable ColumnScope.(PaddingValues) -> Unit
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
@ -55,10 +57,6 @@ fun SettingsScaffold(
|
||||||
},
|
},
|
||||||
) { paddingValues ->
|
) { paddingValues ->
|
||||||
ScreenBoxSettingsScaffold(paddingValues) {
|
ScreenBoxSettingsScaffold(paddingValues) {
|
||||||
val scrollState = rememberScrollState()
|
|
||||||
LaunchedEffect(Unit) {
|
|
||||||
canScroll(scrollState.canScrollForward || scrollState.canScrollBackward)
|
|
||||||
}
|
|
||||||
Column(
|
Column(
|
||||||
Modifier
|
Modifier
|
||||||
.matchParentSize()
|
.matchParentSize()
|
||||||
|
@ -81,6 +79,8 @@ fun SettingsScaffold(
|
||||||
verticalArrangement: Arrangement.Vertical =
|
verticalArrangement: Arrangement.Vertical =
|
||||||
if (!reverseLayout) Arrangement.Top else Arrangement.Bottom,
|
if (!reverseLayout) Arrangement.Top else Arrangement.Bottom,
|
||||||
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
|
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
|
||||||
|
canScroll: ((canPerformScroll: Boolean) -> Unit)? = null,
|
||||||
|
scrollState: ScrollState = verticalScrollState(canScroll),
|
||||||
content: @Composable ColumnScope.(PaddingValues) -> Unit
|
content: @Composable ColumnScope.(PaddingValues) -> Unit
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
@ -112,7 +112,7 @@ fun SettingsScaffold(
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.matchParentSize()
|
.matchParentSize()
|
||||||
.verticalScroll(rememberScrollState()),
|
.verticalScroll(scrollState),
|
||||||
verticalArrangement = verticalArrangement,
|
verticalArrangement = verticalArrangement,
|
||||||
horizontalAlignment = horizontalAlignment,
|
horizontalAlignment = horizontalAlignment,
|
||||||
) {
|
) {
|
||||||
|
@ -132,6 +132,8 @@ fun SettingsScaffold(
|
||||||
verticalArrangement: Arrangement.Vertical =
|
verticalArrangement: Arrangement.Vertical =
|
||||||
if (!reverseLayout) Arrangement.Top else Arrangement.Bottom,
|
if (!reverseLayout) Arrangement.Top else Arrangement.Bottom,
|
||||||
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
|
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
|
||||||
|
canScroll: ((canPerformScroll: Boolean) -> Unit)? = null,
|
||||||
|
scrollState: ScrollState = verticalScrollState(canScroll),
|
||||||
content: @Composable ColumnScope.(PaddingValues) -> Unit
|
content: @Composable ColumnScope.(PaddingValues) -> Unit
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
@ -164,7 +166,7 @@ fun SettingsScaffold(
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.matchParentSize()
|
.matchParentSize()
|
||||||
.verticalScroll(rememberScrollState()),
|
.verticalScroll(scrollState),
|
||||||
verticalArrangement = verticalArrangement,
|
verticalArrangement = verticalArrangement,
|
||||||
horizontalAlignment = horizontalAlignment,
|
horizontalAlignment = horizontalAlignment,
|
||||||
) {
|
) {
|
||||||
|
@ -174,15 +176,24 @@ fun SettingsScaffold(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun verticalScrollState(canScroll: ((canPerformScroll: Boolean) -> Unit)?): ScrollState {
|
||||||
|
val scrollState = rememberScrollState()
|
||||||
|
LaunchedEffect(Unit) {
|
||||||
|
canScroll?.invoke(scrollState.canScrollForward || scrollState.canScrollBackward)
|
||||||
|
}
|
||||||
|
return scrollState
|
||||||
|
}
|
||||||
|
|
||||||
@MyDevices
|
@MyDevices
|
||||||
@Composable
|
@Composable
|
||||||
private fun SettingsScaffoldPreview() {
|
private fun SettingsScaffoldPreview() {
|
||||||
AppThemeSurface {
|
AppThemeSurface {
|
||||||
SettingsScaffold(title = "About", goBack = {}, content = {
|
SettingsScaffold(title = "About", goBack = {}) {
|
||||||
ListItem(headlineContent = { Text(text = "Some text") },
|
ListItem(headlineContent = { Text(text = "Some text") },
|
||||||
leadingContent = {
|
leadingContent = {
|
||||||
Icon(imageVector = Icons.Filled.AccessTime, contentDescription = null)
|
Icon(imageVector = Icons.Filled.AccessTime, contentDescription = null)
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue