Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ import com.infomaniak.auth.R
import com.infomaniak.auth.ui.theme.AuthenticatorTheme
import com.infomaniak.core.ui.compose.margin.Margin
import com.infomaniak.core.ui.compose.preview.PreviewSmallWindow
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf

@Composable
fun OptionsSection(
vararg sections: List<OptionItemType>,
sections: ImmutableList<ImmutableList<OptionItemType>>,
modifier: Modifier = Modifier,
) {
OptionsSectionContainer(modifier, *sections) { optionItems ->
OptionsSectionContainer(modifier, sections) { optionItems ->
optionItems.forEachIndexed { index, optionItemType ->
OptionItem(optionItemType = optionItemType)

Expand All @@ -73,7 +75,7 @@ fun OptionsSection(
@Composable
private fun OptionsSectionContainer(
modifier: Modifier = Modifier,
vararg sections: List<OptionItemType>,
sections: ImmutableList<ImmutableList<OptionItemType>>,
content: @Composable (optionItem: List<OptionItemType>) -> Unit,
) {
Column(
Expand Down Expand Up @@ -193,7 +195,7 @@ sealed interface OptionItemType {
@PreviewSmallWindow
@Composable
fun OptionsSectionPreview() {
val firstSectionItems = listOf(
val firstSectionItems = persistentListOf(
OptionItemType.WithCheckBox(
stringResId = R.string.appCompleteName,
isChecked = false,
Expand All @@ -213,12 +215,17 @@ fun OptionsSectionPreview() {
)

val secondSectionItems =
listOf(OptionItemType.WithCheckBox(stringResId = R.string.appCompleteName, isChecked = false, onCheckedChange = {}))
persistentListOf(
OptionItemType.WithCheckBox(
stringResId = R.string.appCompleteName,
isChecked = false,
onCheckedChange = {})
)

AuthenticatorTheme {
Column(modifier = Modifier.background(AuthenticatorTheme.materialColors.inverseOnSurface)) {
OptionsSection(
firstSectionItems, secondSectionItems,
sections = persistentListOf(firstSectionItems, secondSectionItems),
modifier = Modifier.padding(PaddingValues(Margin.Small)),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import com.infomaniak.core.ui.compose.basics.Typography
import com.infomaniak.core.ui.compose.bottomstickybuttonscaffolds.SinglePaneScaffold
import com.infomaniak.core.ui.compose.margin.Margin
import com.infomaniak.core.ui.compose.preview.PreviewSmallWindow
import kotlinx.collections.immutable.persistentListOf

@Composable
fun AccountDetails(account: FakeAccount, onBackPressed: () -> Unit) {
Expand Down Expand Up @@ -232,16 +233,16 @@ private fun LogInAgainButton(hasLoggedInWithError: Boolean, logIn: () -> Unit) {
@Composable
private fun SettingsSections(modifier: Modifier = Modifier, securityLevel: AccountSecurityLevel) {
val firstSectionItem = if (securityLevel == AccountSecurityLevel.Secured) {
listOf(
persistentListOf(
OptionItemType.WithRightIcon(
stringResId = R.string.refreshPendingLoginsButton,
rightIconResId = R.drawable.right_indicator,
onClick = {},
),
)
} else listOf()
} else persistentListOf()

val secondSectionItems = listOf(
val secondSectionItems = persistentListOf(
OptionItemType.WithRightIcon(
stringResId = R.string.activityHistoryButton,
rightIconResId = R.drawable.square_arrow_up,
Expand All @@ -258,7 +259,7 @@ private fun SettingsSections(modifier: Modifier = Modifier, securityLevel: Accou
),
)

OptionsSection(firstSectionItem, secondSectionItems)
OptionsSection(sections = persistentListOf(firstSectionItem, secondSectionItems))
}

private enum class AccountStatus(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.infomaniak.auth.ui.theme.AuthenticatorTheme
import com.infomaniak.auth.utils.GetSetCallbacks
import com.infomaniak.core.ui.compose.bottomstickybuttonscaffolds.SinglePaneScaffold
import com.infomaniak.core.ui.compose.preview.PreviewSmallWindow
import kotlinx.collections.immutable.persistentListOf

@Composable
fun SettingsScreen(onThemeClicked: () -> Unit) {
Expand All @@ -57,7 +58,7 @@ private fun SettingsScreen(
appLocked: GetSetCallbacks<Boolean>,
onThemeClicked: () -> Unit,
) {
val firstSectionItems = listOf(
val firstSectionItems = persistentListOf(
OptionItemType.WithCheckBox(
stringResId = R.string.notificationsTitle,
isChecked = notificationEnabled.get(),
Expand All @@ -75,7 +76,7 @@ private fun SettingsScreen(
),
)

val secondSectionItems = listOf(
val secondSectionItems = persistentListOf(
OptionItemType.WithRightIcon(
stringResId = R.string.dataManagementTitle,
rightIconResId = R.drawable.right_indicator,
Expand All @@ -99,7 +100,7 @@ private fun SettingsScreen(
},
) { paddingValues ->
OptionsSection(
firstSectionItems, secondSectionItems,
sections = persistentListOf(firstSectionItems, secondSectionItems),
modifier = Modifier.padding(paddingValues),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import com.infomaniak.auth.ui.theme.AuthenticatorTheme
import com.infomaniak.auth.utils.GetSetCallbacks
import com.infomaniak.core.ui.compose.bottomstickybuttonscaffolds.SinglePaneScaffold
import com.infomaniak.core.ui.compose.preview.PreviewSmallWindow
import kotlinx.collections.immutable.persistentListOf

@Composable
fun ThemeSettingsScreen(onBackPressed: () -> Unit) {
Expand All @@ -59,7 +60,7 @@ private fun ThemeSettingsScreen(
)
},
) { paddingValues ->
val section = listOf(
val section = persistentListOf(
OptionItemType.WithSelection(
leftIconResId = R.drawable.ic_theme_light,
stringResId = R.string.themeLight,
Expand All @@ -81,7 +82,7 @@ private fun ThemeSettingsScreen(
)

OptionsSection(
section,
sections = persistentListOf(section),
modifier = Modifier
.padding(paddingValues),
)
Expand Down