Skip to content

Commit 0d880bb

Browse files
committed
add option to swap order of notifications and explore tabs
1 parent 5df7241 commit 0d880bb

3 files changed

Lines changed: 73 additions & 28 deletions

File tree

shared/src/commonMain/composeResources/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
<string name="hide_interaction_counters">Hide interaction counters on posts</string>
6868
<string name="hide_follow_counters">Hide follow counters</string>
6969
<string name="amoled_dark_theme">AMOLED dark theme</string>
70+
<string name="swap_notifications_and_explore_order">Swap order of Notifications and Explore tabs</string>
7071

7172
<string name="account">Account</string>
7273
<string name="switch_account">Switch account</string>

shared/src/commonMain/kotlin/site/remlit/snowdrop/App.kt

Lines changed: 55 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import androidx.compose.foundation.clickable
1313
import androidx.compose.foundation.interaction.MutableInteractionSource
1414
import androidx.compose.foundation.interaction.PressInteraction
1515
import androidx.compose.foundation.layout.Arrangement
16-
import androidx.compose.foundation.layout.Box
1716
import androidx.compose.foundation.layout.Column
1817
import androidx.compose.foundation.layout.Row
1918
import androidx.compose.foundation.layout.fillMaxWidth
@@ -42,9 +41,7 @@ import androidx.compose.runtime.CompositionLocalProvider
4241
import androidx.compose.runtime.DisposableEffect
4342
import androidx.compose.runtime.LaunchedEffect
4443
import androidx.compose.runtime.getValue
45-
import androidx.compose.runtime.mutableStateOf
4644
import androidx.compose.runtime.remember
47-
import androidx.compose.runtime.setValue
4845
import androidx.compose.ui.Alignment
4946
import androidx.compose.ui.Modifier
5047
import androidx.compose.ui.draw.clip
@@ -56,7 +53,6 @@ import androidx.compose.ui.text.font.FontWeight
5653
import androidx.compose.ui.tooling.preview.Preview
5754
import androidx.compose.ui.unit.dp
5855
import androidx.lifecycle.compose.collectAsStateWithLifecycle
59-
import androidx.navigation.NavBackStackEntry
6056
import androidx.navigation.NavDestination.Companion.hasRoute
6157
import androidx.navigation.compose.NavHost
6258
import androidx.navigation.compose.composable
@@ -220,6 +216,9 @@ fun App() = safe {
220216
val account by getCurrentAccountObjectFlow()
221217
.collectAsStateWithLifecycle(null)
222218

219+
val swappedMiddleNavs by settings.getBooleanFlow("swapped_middle_navs", false)
220+
.collectAsStateWithLifecycle(false)
221+
223222

224223
DisposableEffect(Unit) {
225224
ExternalUriHandler.listener = { uri ->
@@ -301,31 +300,59 @@ fun App() = safe {
301300
label = { Text(stringResource(Res.string.timeline)) }
302301
)
303302

304-
NavigationBarItem(
305-
selected = atRoute<NotificationsRoute>(currentDest),
306-
onClick = { navController.navigate(NotificationsRoute) },
307-
icon = {
308-
if (atRoute<NotificationsRoute>(currentDest)) Icon(
309-
painterResource(Res.drawable.icon_notifications_filled_24px),
310-
null
311-
)
312-
else Icon(painterResource(Res.drawable.icon_notifications_24px), null)
313-
},
314-
label = { Text(stringResource(Res.string.notifications)) }
315-
)
303+
if (swappedMiddleNavs) {
304+
NavigationBarItem(
305+
selected = atRoute<ExploreRoute>(currentDest),
306+
onClick = { navController.navigate(ExploreRoute) },
307+
icon = {
308+
if (atRoute<ExploreRoute>(currentDest)) Icon(
309+
painterResource(Res.drawable.icon_explore_filled_24px),
310+
null
311+
)
312+
else Icon(painterResource(Res.drawable.icon_explore_24px), null)
313+
},
314+
label = { Text(stringResource(Res.string.explore)) }
315+
)
316316

317-
NavigationBarItem(
318-
selected = atRoute<ExploreRoute>(currentDest),
319-
onClick = { navController.navigate(ExploreRoute) },
320-
icon = {
321-
if (atRoute<ExploreRoute>(currentDest)) Icon(
322-
painterResource(Res.drawable.icon_explore_filled_24px),
323-
null
324-
)
325-
else Icon(painterResource(Res.drawable.icon_explore_24px), null)
326-
},
327-
label = { Text(stringResource(Res.string.explore)) }
328-
)
317+
NavigationBarItem(
318+
selected = atRoute<NotificationsRoute>(currentDest),
319+
onClick = { navController.navigate(NotificationsRoute) },
320+
icon = {
321+
if (atRoute<NotificationsRoute>(currentDest)) Icon(
322+
painterResource(Res.drawable.icon_notifications_filled_24px),
323+
null
324+
)
325+
else Icon(painterResource(Res.drawable.icon_notifications_24px), null)
326+
},
327+
label = { Text(stringResource(Res.string.notifications)) }
328+
)
329+
} else {
330+
NavigationBarItem(
331+
selected = atRoute<NotificationsRoute>(currentDest),
332+
onClick = { navController.navigate(NotificationsRoute) },
333+
icon = {
334+
if (atRoute<NotificationsRoute>(currentDest)) Icon(
335+
painterResource(Res.drawable.icon_notifications_filled_24px),
336+
null
337+
)
338+
else Icon(painterResource(Res.drawable.icon_notifications_24px), null)
339+
},
340+
label = { Text(stringResource(Res.string.notifications)) }
341+
)
342+
343+
NavigationBarItem(
344+
selected = atRoute<ExploreRoute>(currentDest),
345+
onClick = { navController.navigate(ExploreRoute) },
346+
icon = {
347+
if (atRoute<ExploreRoute>(currentDest)) Icon(
348+
painterResource(Res.drawable.icon_explore_filled_24px),
349+
null
350+
)
351+
else Icon(painterResource(Res.drawable.icon_explore_24px), null)
352+
},
353+
label = { Text(stringResource(Res.string.explore)) }
354+
)
355+
}
329356

330357
NavigationBarItem(
331358
selected = atRoute<MyProfileRoute>(currentDest),

shared/src/commonMain/kotlin/site/remlit/snowdrop/view/settings/SettingsView.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import snowdrop.shared.generated.resources.icon_logout_24px
6969
import snowdrop.shared.generated.resources.icon_switch_account_24px
7070
import snowdrop.shared.generated.resources.logout
7171
import snowdrop.shared.generated.resources.settings
72+
import snowdrop.shared.generated.resources.swap_notifications_and_explore_order
7273
import snowdrop.shared.generated.resources.switch_account
7374
import snowdrop.shared.generated.resources.visibility_direct
7475
import snowdrop.shared.generated.resources.visibility_followers
@@ -261,6 +262,22 @@ fun SettingsView() = ViewSurface {
261262
)
262263
}
263264
}
265+
item {
266+
val swapExploreAndNotifs by settings.getBooleanFlow("swapped_middle_navs", false)
267+
.collectAsStateWithLifecycle(false)
268+
269+
Card {
270+
ListItem(
271+
headlineContent = { Text(stringResource(Res.string.swap_notifications_and_explore_order)) },
272+
trailingContent = {
273+
Switch(
274+
swapExploreAndNotifs,
275+
onCheckedChange = { blockingSettings.putBoolean("swapped_middle_navs", it) }
276+
)
277+
}
278+
)
279+
}
280+
}
264281
/* item { Divider() } */
265282

266283
item {

0 commit comments

Comments
 (0)