Skip to content

Commit 8f2e780

Browse files
authored
Merge pull request #354 from OpenHub-Store/desktop-scrollbar-impl
2 parents 62103c4 + 725ffd8 commit 8f2e780

File tree

34 files changed

+487
-89
lines changed

34 files changed

+487
-89
lines changed

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/Main.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ fun App(deepLinkUri: String? = null) {
103103
AppNavigation(
104104
navController = navController,
105105
isLiquidGlassEnabled = state.isLiquidGlassEnabled,
106+
isScrollbarEnabled = state.isScrollbarEnabled,
106107
)
107108
}
108109
}

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/MainState.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ data class MainState(
1414
val isDarkTheme: Boolean? = null,
1515
val currentFontTheme: FontTheme = FontTheme.CUSTOM,
1616
val isLiquidGlassEnabled: Boolean = true,
17+
val isScrollbarEnabled: Boolean = false,
1718
)

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/MainViewModel.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ class MainViewModel(
8080
}
8181
}
8282

83+
viewModelScope.launch {
84+
tweaksRepository.getScrollbarEnabled().collect { enabled ->
85+
_state.update { it.copy(isScrollbarEnabled = enabled) }
86+
}
87+
}
88+
8389
viewModelScope.launch {
8490
rateLimitRepository.rateLimitState.collect { rateLimitInfo ->
8591
_state.update { currentState ->

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import zed.rainxch.apps.presentation.AppsViewModel
3131
import zed.rainxch.auth.presentation.AuthenticationRoot
3232
import zed.rainxch.core.presentation.locals.LocalBottomNavigationHeight
3333
import zed.rainxch.core.presentation.locals.LocalBottomNavigationLiquid
34+
import zed.rainxch.core.presentation.locals.LocalScrollbarEnabled
3435
import zed.rainxch.details.presentation.DetailsRoot
3536
import zed.rainxch.devprofile.presentation.DeveloperProfileRoot
3637
import zed.rainxch.favourites.presentation.FavouritesRoot
@@ -43,6 +44,7 @@ import zed.rainxch.starred.presentation.StarredReposRoot
4344
fun AppNavigation(
4445
navController: NavHostController,
4546
isLiquidGlassEnabled: Boolean = true,
47+
isScrollbarEnabled: Boolean = false,
4648
) {
4749
val liquidState = rememberLiquidState()
4850
var bottomNavigationHeight by remember { mutableStateOf(0.dp) }
@@ -54,6 +56,7 @@ fun AppNavigation(
5456
CompositionLocalProvider(
5557
LocalBottomNavigationLiquid provides liquidState,
5658
LocalBottomNavigationHeight provides bottomNavigationHeight,
59+
LocalScrollbarEnabled provides isScrollbarEnabled,
5760
) {
5861
Box(
5962
modifier = Modifier.fillMaxSize(),

core/data/src/commonMain/kotlin/zed/rainxch/core/data/repository/TweaksRepositoryImpl.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,17 @@ class TweaksRepositoryImpl(
157157
}
158158
}
159159

160+
override fun getScrollbarEnabled(): Flow<Boolean> =
161+
preferences.data.map { prefs ->
162+
prefs[SCROLLBAR_ENABLED_KEY] ?: false
163+
}
164+
165+
override suspend fun setScrollbarEnabled(enabled: Boolean) {
166+
preferences.edit { prefs ->
167+
prefs[SCROLLBAR_ENABLED_KEY] = enabled
168+
}
169+
}
170+
160171
companion object {
161172
private const val DEFAULT_UPDATE_CHECK_INTERVAL_HOURS = 6L
162173

@@ -172,5 +183,6 @@ class TweaksRepositoryImpl(
172183
private val INCLUDE_PRE_RELEASES_KEY = booleanPreferencesKey("include_pre_releases")
173184
private val LIQUID_GLASS_ENABLED_KEY = booleanPreferencesKey("liquid_glass_enabled")
174185
private val HIDE_SEEN_ENABLED_KEY = booleanPreferencesKey("hide_seen_enabled")
186+
private val SCROLLBAR_ENABLED_KEY = booleanPreferencesKey("scrollbar_enabled")
175187
}
176188
}

core/domain/src/commonMain/kotlin/zed/rainxch/core/domain/repository/TweaksRepository.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,8 @@ interface TweaksRepository {
5454
fun getDiscoveryPlatform(): Flow<DiscoveryPlatform>
5555

5656
suspend fun setDiscoveryPlatform(platform: DiscoveryPlatform)
57+
58+
fun getScrollbarEnabled(): Flow<Boolean>
59+
60+
suspend fun setScrollbarEnabled(enabled: Boolean)
5761
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package zed.rainxch.core.presentation.components
2+
3+
import androidx.compose.foundation.lazy.LazyListState
4+
import androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridState
5+
import androidx.compose.runtime.Composable
6+
import androidx.compose.ui.Modifier
7+
8+
@Composable
9+
actual fun ScrollbarContainer(
10+
listState: LazyListState,
11+
enabled: Boolean,
12+
modifier: Modifier,
13+
content: `@Composable` () -> Unit,
14+
) {
15+
Box(modifier = modifier) {
16+
content()
17+
}
18+
}
19+
20+
`@Composable`
21+
actual fun ScrollbarContainer(
22+
gridState: LazyStaggeredGridState,
23+
enabled: Boolean,
24+
modifier: Modifier,
25+
content: `@Composable` () -> Unit,
26+
) {
27+
Box(modifier = modifier) {
28+
content()
29+
}
30+
}
31+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@
440440
<string name="auth_hint_denied">لقد رفضت طلب التفويض. حاول مرة أخرى إذا كان ذلك غير مقصود.</string>
441441
<string name="auth_check_status">لقد قمت بالتفويض بالفعل</string>
442442
<string name="auth_polling_status">جارٍ التحقق…</string>
443+
<string name="auth_rate_limited">تم تقييد المعدل — إعادة المحاولة خلال %1$d ثانية</string>
443444

444445
<!-- Read More / Show Less -->
445446
<string name="read_more">اقرأ المزيد</string>
@@ -594,6 +595,9 @@
594595
<string name="liquid_glass_option_title">تأثير الزجاج السائل</string>
595596
<string name="liquid_glass_option_description">تحسين الواجهة بمظهر زجاجي ناعم</string>
596597

598+
<string name="scrollbar_option_title">شريط التمرير</string>
599+
<string name="scrollbar_option_description">إظهار شريط التمرير في القوائم القابلة للتمرير (سطح المكتب)</string>
600+
597601
<string name="hide_seen_title">إخفاء المستودعات المشاهَدة</string>
598602
<string name="hide_seen_description">إخفاء المستودعات التي شاهدتها بالفعل من خلاصات الاكتشاف</string>
599603
<string name="clear_seen_history">مسح سجل المشاهدة</string>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@
440440
<string name="auth_hint_denied">আপনি অনুমোদনের অনুরোধ প্রত্যাখ্যান করেছেন। এটি অনিচ্ছাকৃত হলে আবার চেষ্টা করুন।</string>
441441
<string name="auth_check_status">আমি ইতিমধ্যেই অনুমোদন করেছি</string>
442442
<string name="auth_polling_status">যাচাই করা হচ্ছে…</string>
443+
<string name="auth_rate_limited">অনুরোধ সীমাবদ্ধ — %1$d সেকেন্ডে পুনরায় চেষ্টা করা হবে</string>
443444

444445
<!-- Read More / Show Less -->
445446
<string name="read_more">আরও পড়ুন</string>
@@ -593,6 +594,9 @@
593594
<string name="liquid_glass_option_title">লিকুইড গ্লাস ইফেক্ট</string>
594595
<string name="liquid_glass_option_description">একটি মসৃণ কাচের মতো চেহারা দিয়ে ইন্টারফেস উন্নত করুন</string>
595596

597+
<string name="scrollbar_option_title">স্ক্রলবার</string>
598+
<string name="scrollbar_option_description">স্ক্রলযোগ্য তালিকায় স্ক্রলবার দেখান (ডেস্কটপ)</string>
599+
596600
<string name="hide_seen_title">দেখা রিপোজিটরি লুকান</string>
597601
<string name="hide_seen_description">আপনি ইতিমধ্যে দেখেছেন এমন রিপোজিটরি আবিষ্কার ফিড থেকে লুকান</string>
598602
<string name="clear_seen_history">দেখার ইতিহাস মুছুন</string>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@
405405
<string name="auth_hint_denied">Rechazaste la solicitud de autorización. Intenta de nuevo si fue involuntario.</string>
406406
<string name="auth_check_status">Ya he autorizado</string>
407407
<string name="auth_polling_status">Comprobando…</string>
408+
<string name="auth_rate_limited">Límite alcanzado — reintentando en %1$d s</string>
408409

409410
<!-- Read More / Show Less -->
410411
<string name="read_more">Leer más</string>
@@ -554,6 +555,9 @@
554555
<string name="liquid_glass_option_title">Efecto de cristal líquido</string>
555556
<string name="liquid_glass_option_description">Mejora la interfaz con una apariencia suave tipo cristal</string>
556557

558+
<string name="scrollbar_option_title">Barra de desplazamiento</string>
559+
<string name="scrollbar_option_description">Mostrar barra de desplazamiento en listas desplazables (escritorio)</string>
560+
557561
<string name="hide_seen_title">Ocultar repositorios vistos</string>
558562
<string name="hide_seen_description">Ocultar repositorios que ya has visto de las fuentes de descubrimiento</string>
559563
<string name="clear_seen_history">Borrar historial de vistos</string>

0 commit comments

Comments
 (0)