Skip to content

Commit 1a14f47

Browse files
authored
Merge pull request #363 from OpenHub-Store/feat-tweaks
2 parents 69e5e57 + 7f9da88 commit 1a14f47

30 files changed

Lines changed: 1185 additions & 697 deletions

File tree

composeApp/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ kotlin {
6565
implementation(projects.feature.starred.presentation)
6666

6767
implementation(projects.feature.recentlyViewed.presentation)
68+
implementation(projects.feature.tweaks.presentation)
6869

6970
implementation(libs.jetbrains.compose.navigation)
7071
implementation(libs.bundles.koin.common)

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/di/ViewModelsModule.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import zed.rainxch.profile.presentation.ProfileViewModel
1212
import zed.rainxch.recentlyviewed.presentation.RecentlyViewedViewModel
1313
import zed.rainxch.search.presentation.SearchViewModel
1414
import zed.rainxch.starred.presentation.StarredReposViewModel
15+
import zed.rainxch.tweaks.presentation.TweaksViewModel
1516

1617
val viewModelsModule =
1718
module {
@@ -24,5 +25,6 @@ val viewModelsModule =
2425
viewModelOf(::RecentlyViewedViewModel)
2526
viewModelOf(::SearchViewModel)
2627
viewModelOf(::ProfileViewModel)
28+
viewModelOf(::TweaksViewModel)
2729
viewModelOf(::StarredReposViewModel)
2830
}

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/AppNavigation.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ import zed.rainxch.devprofile.presentation.DeveloperProfileRoot
3737
import zed.rainxch.favourites.presentation.FavouritesRoot
3838
import zed.rainxch.home.presentation.HomeRoot
3939
import zed.rainxch.profile.presentation.ProfileRoot
40+
import zed.rainxch.profile.presentation.SponsorScreen
4041
import zed.rainxch.recentlyviewed.presentation.RecentlyViewedRoot
4142
import zed.rainxch.search.presentation.SearchRoot
4243
import zed.rainxch.starred.presentation.StarredReposRoot
44+
import zed.rainxch.tweaks.presentation.TweaksRoot
4345

4446
@Composable
4547
fun AppNavigation(
@@ -283,13 +285,17 @@ fun AppNavigation(
283285
}
284286

285287
composable<GithubStoreGraph.SponsorScreen> {
286-
zed.rainxch.profile.presentation.SponsorScreen(
288+
SponsorScreen(
287289
onNavigateBack = {
288290
navController.navigateUp()
289291
},
290292
)
291293
}
292294

295+
composable<GithubStoreGraph.TweaksScreen> {
296+
TweaksRoot()
297+
}
298+
293299
composable<GithubStoreGraph.AppsScreen> {
294300
AppsRoot(
295301
onNavigateBack = {

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/BottomNavigation.kt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,9 @@ fun BottomNavigation(
7171
) {
7272
val liquidState = LocalBottomNavigationLiquid.current
7373

74-
if (currentScreen !in BottomNavigationUtils.allowedScreens()) return
74+
if (currentScreen !in BottomNavigationUtils.allowedScreens().map { it.screen }) return
7575

76-
val visibleItems =
77-
remember {
78-
BottomNavigationUtils.items().filterNot {
79-
getPlatform() != Platform.ANDROID &&
80-
it.screen == GithubStoreGraph.AppsScreen
81-
}
82-
}
83-
84-
val selectedIndex = visibleItems.indexOfFirst { it.screen == currentScreen }
76+
val selectedIndex = BottomNavigationUtils.allowedScreens().indexOfFirst { it.screen == currentScreen }
8577

8678
val itemPositions = remember { mutableMapOf<Int, Pair<Float, Float>>() }
8779

@@ -272,7 +264,7 @@ fun BottomNavigation(
272264
horizontalArrangement = Arrangement.spacedBy(4.dp),
273265
verticalAlignment = Alignment.CenterVertically,
274266
) {
275-
visibleItems.forEachIndexed { index, item ->
267+
BottomNavigationUtils.allowedScreens().forEachIndexed { index, item ->
276268
LiquidGlassTabItem(
277269
item = item,
278270
hasBadge = item.screen == GithubStoreGraph.AppsScreen && isUpdateAvailable,

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/BottomNavigationUtils.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
package zed.rainxch.githubstore.app.navigation
22

33
import androidx.compose.material.icons.Icons
4-
import androidx.compose.material.icons.filled.Apps
5-
import androidx.compose.material.icons.filled.Home
6-
import androidx.compose.material.icons.filled.Person2
7-
import androidx.compose.material.icons.filled.Search
8-
import androidx.compose.material.icons.outlined.Apps
9-
import androidx.compose.material.icons.outlined.Home
10-
import androidx.compose.material.icons.outlined.Person2
11-
import androidx.compose.material.icons.outlined.Search
4+
import androidx.compose.material.icons.filled.*
5+
import androidx.compose.material.icons.outlined.*
126
import androidx.compose.ui.graphics.vector.ImageVector
137
import org.jetbrains.compose.resources.StringResource
148
import zed.rainxch.core.domain.getPlatform
@@ -49,12 +43,18 @@ object BottomNavigationUtils {
4943
iconFilled = Icons.Filled.Person2,
5044
screen = GithubStoreGraph.ProfileScreen,
5145
),
46+
BottomNavigationItem(
47+
titleRes = Res.string.bottom_nav_profile_tweaks,
48+
iconOutlined = Icons.Outlined.Settings,
49+
iconFilled = Icons.Filled.Settings,
50+
screen = GithubStoreGraph.TweaksScreen,
51+
),
5252
)
5353

54-
fun allowedScreens(): List<GithubStoreGraph> =
54+
fun allowedScreens(): List<BottomNavigationItem> =
5555
items()
5656
.filterNot {
5757
getPlatform() != Platform.ANDROID &&
5858
it.screen == GithubStoreGraph.AppsScreen
59-
}.map { it.screen }
59+
}
6060
}

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/GithubStoreGraph.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ sealed interface GithubStoreGraph {
2929
@Serializable
3030
data object ProfileScreen : GithubStoreGraph
3131

32+
@Serializable
33+
data object TweaksScreen : GithubStoreGraph
34+
3235
@Serializable
3336
data object FavouritesScreen : GithubStoreGraph
3437

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/NavigationUtils.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ fun NavBackStackEntry?.getCurrentScreen(): GithubStoreGraph? {
1414
route.contains("DetailsScreen") -> toRoute<GithubStoreGraph.DetailsScreen>()
1515
route.contains("DeveloperProfileScreen") -> toRoute<GithubStoreGraph.DeveloperProfileScreen>()
1616
route.contains("ProfileScreen") -> GithubStoreGraph.ProfileScreen
17+
route.contains("TweaksScreen") -> GithubStoreGraph.TweaksScreen
18+
route.contains("RecentlyViewedScreen") -> GithubStoreGraph.RecentlyViewedScreen
1719
route.contains("FavouritesScreen") -> GithubStoreGraph.FavouritesScreen
1820
route.contains("StarredReposScreen") -> GithubStoreGraph.StarredReposScreen
1921
route.contains("AppsScreen") -> GithubStoreGraph.AppsScreen

core/presentation/src/commonMain/composeResources/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@
394394
<string name="bottom_nav_search_title">Search</string>
395395
<string name="bottom_nav_apps_title">Apps</string>
396396
<string name="bottom_nav_profile_title">Profile</string>
397+
<string name="bottom_nav_profile_tweaks">Tweaks</string>
397398

398399
<string name="forked_repository">Fork</string>
399400

@@ -620,4 +621,6 @@
620621
<string name="recent_searches">Recent searches</string>
621622
<string name="clear_all_history">Clear all</string>
622623
<string name="remove_search_history_item">Remove</string>
624+
625+
<string name="tweaks_title">Tweaks</string>
623626
</resources>
Lines changed: 1 addition & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,20 @@
11
package zed.rainxch.profile.presentation
22

3-
import zed.rainxch.core.domain.model.AppTheme
4-
import zed.rainxch.core.domain.model.FontTheme
5-
import zed.rainxch.core.domain.model.InstallerType
6-
import zed.rainxch.profile.presentation.model.ProxyType
7-
83
sealed interface ProfileAction {
9-
data object OnNavigateBackClick : ProfileAction
10-
11-
data class OnThemeColorSelected(
12-
val themeColor: AppTheme,
13-
) : ProfileAction
14-
15-
data class OnAmoledThemeToggled(
16-
val enabled: Boolean,
17-
) : ProfileAction
18-
19-
data class OnDarkThemeChange(
20-
val isDarkTheme: Boolean?,
21-
) : ProfileAction
22-
234
data object OnLogoutClick : ProfileAction
245

256
data object OnLogoutConfirmClick : ProfileAction
267

278
data object OnStarredReposClick : ProfileAction
289

2910
data object OnFavouriteReposClick : ProfileAction
11+
data class OnRepositoriesClick(val username: String) : ProfileAction
3012

3113
data object OnLogoutDismiss : ProfileAction
3214

33-
data object OnHelpClick : ProfileAction
34-
3515
data object OnLoginClick : ProfileAction
3616

37-
data object OnRefreshCacheSize : ProfileAction
38-
39-
data object OnClearCacheClick : ProfileAction
40-
41-
data object OnClearDownloadsConfirm : ProfileAction
42-
43-
data object OnClearDownloadsDismiss : ProfileAction
44-
45-
data class OnFontThemeSelected(
46-
val fontTheme: FontTheme,
47-
) : ProfileAction
48-
49-
data class OnProxyTypeSelected(
50-
val type: ProxyType,
51-
) : ProfileAction
52-
53-
data class OnProxyHostChanged(
54-
val host: String,
55-
) : ProfileAction
56-
57-
data class OnProxyPortChanged(
58-
val port: String,
59-
) : ProfileAction
60-
61-
data class OnRepositoriesClick(
62-
val username: String,
63-
) : ProfileAction
64-
65-
data class OnProxyUsernameChanged(
66-
val username: String,
67-
) : ProfileAction
68-
69-
data class OnProxyPasswordChanged(
70-
val password: String,
71-
) : ProfileAction
72-
73-
data object OnProxyPasswordVisibilityToggle : ProfileAction
74-
75-
data class OnLiquidGlassEnabledChange(
76-
val enabled: Boolean,
77-
) : ProfileAction
78-
79-
data object OnProxySave : ProfileAction
80-
81-
data class OnInstallerTypeSelected(
82-
val type: InstallerType,
83-
) : ProfileAction
84-
85-
data object OnRequestShizukuPermission : ProfileAction
86-
87-
data class OnAutoUpdateToggled(
88-
val enabled: Boolean,
89-
) : ProfileAction
90-
91-
data class OnUpdateCheckIntervalChanged(
92-
val hours: Long,
93-
) : ProfileAction
94-
95-
data class OnIncludePreReleasesToggled(
96-
val enabled: Boolean,
97-
) : ProfileAction
98-
99-
data class OnAutoDetectClipboardToggled(
100-
val enabled: Boolean,
101-
) : ProfileAction
102-
103-
data class OnHideSeenToggled(
104-
val enabled: Boolean,
105-
) : ProfileAction
106-
107-
data object OnClearSeenRepos : ProfileAction
108-
10917
data object OnRecentlyViewedClick : ProfileAction
11018

11119
data object OnSponsorClick : ProfileAction
112-
113-
data class OnScrollbarToggled(
114-
val enabled: Boolean,
115-
) : ProfileAction
11620
}

feature/profile/presentation/src/commonMain/kotlin/zed/rainxch/profile/presentation/ProfileRoot.kt

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,8 @@ import zed.rainxch.core.presentation.utils.ObserveAsEvents
3636
import zed.rainxch.githubstore.core.presentation.res.*
3737
import zed.rainxch.profile.presentation.components.ClearDownloadsDialog
3838
import zed.rainxch.profile.presentation.components.LogoutDialog
39-
import zed.rainxch.profile.presentation.components.sections.about
4039
import zed.rainxch.profile.presentation.components.sections.logout
41-
import zed.rainxch.profile.presentation.components.sections.othersSection
4240
import zed.rainxch.profile.presentation.components.sections.profile
43-
import zed.rainxch.profile.presentation.components.sections.settings
4441

4542
@Composable
4643
fun ProfileRoot(
@@ -57,20 +54,6 @@ fun ProfileRoot(
5754
val snackbarState = remember { SnackbarHostState() }
5855
val coroutineScope = rememberCoroutineScope()
5956

60-
val lifecycleOwner = LocalLifecycleOwner.current
61-
DisposableEffect(lifecycleOwner) {
62-
val observer =
63-
androidx.lifecycle.LifecycleEventObserver { _, event ->
64-
if (event == androidx.lifecycle.Lifecycle.Event.ON_RESUME) {
65-
viewModel.onAction(ProfileAction.OnRefreshCacheSize)
66-
}
67-
}
68-
lifecycleOwner.lifecycle.addObserver(observer)
69-
onDispose {
70-
lifecycleOwner.lifecycle.removeObserver(observer)
71-
}
72-
}
73-
7457
ObserveAsEvents(viewModel.events) { event ->
7558
when (event) {
7659
ProfileEvent.OnLogoutSuccessful -> {
@@ -123,10 +106,6 @@ fun ProfileRoot(
123106
state = state,
124107
onAction = { action ->
125108
when (action) {
126-
ProfileAction.OnNavigateBackClick -> {
127-
onNavigateBack()
128-
}
129-
130109
ProfileAction.OnLoginClick -> {
131110
onNavigateToAuthentication()
132111
}
@@ -169,18 +148,6 @@ fun ProfileRoot(
169148
},
170149
)
171150
}
172-
173-
if (state.isClearDownloadsDialogVisible) {
174-
ClearDownloadsDialog(
175-
cacheSize = state.cacheSize,
176-
onDismissRequest = {
177-
viewModel.onAction(ProfileAction.OnClearDownloadsDismiss)
178-
},
179-
onConfirm = {
180-
viewModel.onAction(ProfileAction.OnClearDownloadsConfirm)
181-
},
182-
)
183-
}
184151
}
185152

186153
@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class)
@@ -228,33 +195,6 @@ fun ProfileScreen(
228195
Spacer(Modifier.height(32.dp))
229196
}
230197

231-
settings(
232-
state = state,
233-
onAction = onAction,
234-
)
235-
236-
item {
237-
Spacer(Modifier.height(16.dp))
238-
}
239-
240-
othersSection(
241-
state = state,
242-
onAction = onAction,
243-
)
244-
245-
item {
246-
Spacer(Modifier.height(32.dp))
247-
}
248-
249-
about(
250-
versionName = state.versionName,
251-
onAction = onAction,
252-
)
253-
254-
item {
255-
Spacer(Modifier.height(32.dp))
256-
}
257-
258198
if (state.isUserLoggedIn) {
259199
logout(
260200
onAction = onAction,

0 commit comments

Comments
 (0)