Skip to content

Commit 78d8d9f

Browse files
committed
feat(core-setting): add setting ui impl-dialog module
1 parent 353c1a6 commit 78d8d9f

File tree

24 files changed

+233
-134
lines changed

24 files changed

+233
-134
lines changed

app-common/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ dependencies {
3131
implementation(projects.core.configstore.implBackend)
3232

3333
implementation(projects.core.featureflag)
34+
35+
implementation(projects.core.ui.setting.api)
36+
implementation(projects.core.ui.setting.implDialog)
3437
implementation(projects.core.ui.legacy.theme2.common)
3538

3639
implementation(projects.feature.account.avatar.api)

app-common/src/main/kotlin/net/thunderbird/app/common/core/AppCommonCoreModule.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ package net.thunderbird.app.common.core
22

33
import net.thunderbird.app.common.core.configstore.appCommonCoreConfigStoreModule
44
import net.thunderbird.app.common.core.logging.appCommonCoreLogger
5+
import net.thunderbird.app.common.core.ui.appCommonCoreUiModule
56
import org.koin.core.module.Module
67
import org.koin.dsl.module
78

89
val appCommonCoreModule: Module = module {
910
includes(
1011
appCommonCoreConfigStoreModule,
1112
appCommonCoreLogger,
13+
appCommonCoreUiModule,
1214
)
1315
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package net.thunderbird.app.common.core.ui
2+
3+
import net.thunderbird.core.ui.setting.SettingViewProvider
4+
import net.thunderbird.core.ui.setting.dialog.DialogSettingViewProvider
5+
import org.koin.dsl.module
6+
7+
val appCommonCoreUiModule = module {
8+
single<SettingViewProvider> { DialogSettingViewProvider() }
9+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package net.thunderbird.core.ui.setting
2+
3+
import androidx.compose.runtime.Composable
4+
import androidx.compose.ui.Modifier
5+
6+
/**
7+
* A provider of a settings view.
8+
*/
9+
interface SettingViewProvider {
10+
11+
/**
12+
* A view that displays a list of settings.
13+
*
14+
* @param title The title of the view.
15+
* @param subtitle The subtitle of the view (optional).
16+
* @param settings The list of settings to display.
17+
* @param onSettingValueChange The callback to be invoked when a setting value is changed.
18+
* @param onBack The callback to be invoked when the back button is clicked.
19+
* @param modifier The modifier to be applied to the view.
20+
*/
21+
@Composable
22+
fun SettingView(
23+
title: String,
24+
settings: Settings,
25+
onSettingValueChange: (SettingValue<*>) -> Unit,
26+
onBack: () -> Unit,
27+
modifier: Modifier = Modifier,
28+
subtitle: String? = null,
29+
)
30+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
package net.thunderbird.core.ui.setting
22

33
import kotlinx.collections.immutable.ImmutableList
4+
import kotlinx.collections.immutable.persistentListOf
45

56
/**
67
* A immutable list of settings.
78
*/
89
typealias Settings = ImmutableList<Setting>
10+
11+
/**
12+
* Returns an empty list of settings.
13+
*/
14+
fun emptySettings(): Settings = persistentListOf()
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
plugins {
2+
id(ThunderbirdPlugins.Library.androidCompose)
3+
alias(libs.plugins.kotlin.parcelize)
4+
}
5+
6+
android {
7+
namespace = "net.thunderbird.core.ui.setting.dialog"
8+
resourcePrefix = "core_ui_setting_dialog_"
9+
}
10+
11+
dependencies {
12+
implementation(projects.core.ui.setting.api)
13+
14+
implementation(projects.core.ui.compose.designsystem)
15+
16+
testImplementation(projects.core.ui.compose.testing)
17+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package net.thunderbird.core.ui.setting.dialog
2+
3+
import androidx.compose.runtime.Composable
4+
import androidx.compose.ui.Modifier
5+
import app.k9mail.core.ui.compose.designsystem.atom.text.TextTitleMedium
6+
import net.thunderbird.core.ui.setting.SettingValue
7+
import net.thunderbird.core.ui.setting.SettingViewProvider
8+
import net.thunderbird.core.ui.setting.Settings
9+
10+
class DialogSettingViewProvider : SettingViewProvider {
11+
12+
@Composable
13+
override fun SettingView(
14+
title: String,
15+
settings: Settings,
16+
onSettingValueChange: (SettingValue<*>) -> Unit,
17+
onBack: () -> Unit,
18+
modifier: Modifier,
19+
subtitle: String?,
20+
) {
21+
TextTitleMedium("This is going to be implemented soon.")
22+
}
23+
}

feature/account/settings/impl/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@ dependencies {
1414

1515
implementation(projects.core.outcome)
1616

17+
implementation(projects.core.ui.setting.api)
18+
1719
implementation(projects.core.logging.implLegacy)
1820
implementation(projects.core.ui.compose.designsystem)
1921
implementation(projects.core.ui.compose.navigation)
2022
implementation(projects.core.ui.compose.preference)
2123
implementation(projects.core.ui.legacy.theme2.common)
2224

25+
debugImplementation(projects.core.ui.setting.implDialog)
26+
2327
testImplementation(projects.core.logging.testing)
2428
testImplementation(projects.core.ui.compose.testing)
2529
}

feature/account/settings/impl/src/debug/kotlin/net/thunderbird/feature/account/settings/impl/ui/fake/FakePreferenceData.kt renamed to feature/account/settings/impl/src/debug/kotlin/net/thunderbird/feature/account/settings/impl/ui/fake/FakeSettingData.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ import app.k9mail.core.ui.compose.designsystem.atom.icon.Icons
99
import app.k9mail.core.ui.compose.designsystem.atom.text.TextBodyLarge
1010
import app.k9mail.core.ui.compose.theme2.MainTheme
1111
import kotlinx.collections.immutable.persistentListOf
12-
import net.thunderbird.core.ui.compose.preference.api.PreferenceDisplay
13-
import net.thunderbird.core.ui.compose.preference.api.PreferenceSetting
12+
import net.thunderbird.core.ui.setting.SettingDecoration
13+
import net.thunderbird.core.ui.setting.SettingValue
1414

15-
object FakePreferenceData {
15+
object FakeSettingData {
1616

17-
val textPreference = PreferenceSetting.Text(
17+
val text = SettingValue.Text(
1818
id = "text",
1919
icon = { Icons.Outlined.Info },
2020
title = { "Title" },
2121
description = { "Description" },
2222
value = "Value",
2323
)
2424

25-
val colorPreference = PreferenceSetting.Color(
25+
val color = SettingValue.Color(
2626
id = "color",
2727
icon = { Icons.Outlined.Info },
2828
title = { "Title" },
@@ -35,7 +35,7 @@ object FakePreferenceData {
3535
),
3636
)
3737

38-
val customPreference = PreferenceDisplay.Custom(
38+
val custom = SettingDecoration.Custom(
3939
id = "custom",
4040
customUi = { modifier ->
4141
CardElevated(
@@ -53,20 +53,20 @@ object FakePreferenceData {
5353
},
5454
)
5555

56-
val sectionDivider = PreferenceDisplay.SectionDivider(
56+
val sectionDivider = SettingDecoration.SectionDivider(
5757
id = "section_divider",
5858
)
5959

60-
val sectionHeader = PreferenceDisplay.SectionHeader(
60+
val sectionHeader = SettingDecoration.SectionHeader(
6161
id = "section_header",
6262
title = { "Section Title" },
6363
color = { Color.Black },
6464
)
6565

66-
val preferences = persistentListOf(
67-
textPreference,
68-
colorPreference,
69-
customPreference,
66+
val settings = persistentListOf(
67+
text,
68+
color,
69+
custom,
7070
sectionHeader,
7171
sectionDivider,
7272
)

feature/account/settings/impl/src/debug/kotlin/net/thunderbird/feature/account/settings/impl/ui/general/GeneralSettingsContentPreview.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ package net.thunderbird.feature.account.settings.impl.ui.general
33
import androidx.compose.runtime.Composable
44
import androidx.compose.ui.tooling.preview.Preview
55
import app.k9mail.core.ui.compose.designsystem.PreviewWithTheme
6-
import net.thunderbird.feature.account.settings.impl.ui.fake.FakePreferenceData
6+
import net.thunderbird.core.ui.setting.dialog.DialogSettingViewProvider
7+
import net.thunderbird.feature.account.settings.impl.ui.fake.FakeSettingData
78

89
@Composable
910
@Preview(showBackground = true)
@@ -12,9 +13,10 @@ internal fun GeneralSettingsContentPreview() {
1213
GeneralSettingsContent(
1314
state = GeneralSettingsContract.State(
1415
subtitle = "Subtitle",
15-
preferences = FakePreferenceData.preferences,
16+
settings = FakeSettingData.settings,
1617
),
1718
onEvent = {},
19+
provider = DialogSettingViewProvider(),
1820
)
1921
}
2022
}

0 commit comments

Comments
 (0)