-
Notifications
You must be signed in to change notification settings - Fork 174
Adding tablet UI for home #1723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
09b507c
fbecf47
78b4915
7492570
e6546cc
fe47f61
7c846c2
17828a0
9f2f300
fd24493
22968dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,7 +50,7 @@ import it.vercruysse.lemmyapi.dto.ListingType | |
| import kotlinx.coroutines.launch | ||
|
|
||
| class PostViewModel( | ||
| val id: Either<PostId, CommentId>, | ||
| var id: Either<PostId, CommentId>, | ||
| ) : ViewModel() { | ||
| var postRes: ApiState<GetPostResponse> by mutableStateOf(ApiState.Empty) | ||
| private set | ||
|
|
@@ -81,6 +81,11 @@ class PostViewModel( | |
| this.getData() | ||
| } | ||
|
|
||
| fun reInitializeWithNewId(id: Either<PostId, CommentId>) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't fully checked it out But I think the idea was rather that you would recreate a new postViewModel each time. I haven't this out yet but this might not play well with the state that won't be remembered. Like sorts. |
||
| this.id = id | ||
| this.getData() | ||
| } | ||
|
|
||
| fun updateSortType(sortType: CommentSortType) { | ||
| this.sortType = sortType | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| package com.jerboa.ui.components.common | ||
|
|
||
| import android.annotation.SuppressLint | ||
| import android.app.Activity | ||
| import androidx.annotation.StringRes | ||
| import androidx.compose.animation.AnimatedVisibility | ||
| import androidx.compose.animation.core.animateFloatAsState | ||
|
|
@@ -26,8 +25,9 @@ import androidx.compose.material.icons.filled.KeyboardArrowDown | |
| import androidx.compose.material.icons.filled.KeyboardArrowUp | ||
| import androidx.compose.material.icons.outlined.* | ||
| import androidx.compose.material3.* | ||
| import androidx.compose.material3.adaptive.navigationsuite.NavigationSuiteScaffold | ||
| import androidx.compose.material3.adaptive.navigationsuite.NavigationSuiteScope | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.DisposableEffect | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.runtime.remember | ||
| import androidx.compose.ui.Alignment | ||
|
|
@@ -38,7 +38,6 @@ import androidx.compose.ui.draw.scale | |
| import androidx.compose.ui.geometry.Offset | ||
| import androidx.compose.ui.geometry.Size | ||
| import androidx.compose.ui.graphics.Color | ||
| import androidx.compose.ui.graphics.toArgb | ||
| import androidx.compose.ui.graphics.vector.ImageVector | ||
| import androidx.compose.ui.platform.LocalContext | ||
| import androidx.compose.ui.platform.LocalResources | ||
|
|
@@ -113,99 +112,87 @@ fun SimpleTopAppBarPreview() { | |
| } | ||
| } | ||
|
|
||
| @Composable | ||
| fun BottomAppBarAll( | ||
| fun NavigationSuiteScope.adaptiveNavigationBar( | ||
| selectedTab: NavTab, | ||
| onSelect: (NavTab) -> Unit, | ||
| onSelectTab: (NavTab) -> Unit, | ||
| userViewType: UserViewType, | ||
| unreadCounts: Long, | ||
| unreadAppCount: Long?, | ||
| unreadReportCount: Long?, | ||
| showTextDescriptionsInNavbar: Boolean, | ||
| ) { | ||
| // Check for preview mode | ||
| if (LocalContext.current is Activity) { | ||
| val window = (LocalContext.current as Activity).window | ||
| val colorScheme = MaterialTheme.colorScheme | ||
|
|
||
| DisposableEffect(Unit) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see this is also gone but this was really necessary for the navigation bar to look the same as system navigation bar. It looked quite odd. I'll check it out later to see how this looks now.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see any need for these now in the jetpack compose code, maybe they were necessary once, but now with
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not on older API levels
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| window.navigationBarColor = colorScheme.surfaceContainer.toArgb() | ||
|
|
||
| onDispose { | ||
| window.navigationBarColor = colorScheme.background.toArgb() | ||
| } | ||
| for (tab in NavTab.getEntries(userViewType)) { | ||
| val selected = tab == selectedTab | ||
| val iconBadgeCount = when (tab) { | ||
| NavTab.Inbox -> unreadCounts | ||
| NavTab.RegistrationApplications -> unreadAppCount | ||
| NavTab.Reports -> unreadReportCount | ||
| else -> null | ||
| } | ||
| } | ||
| // If descriptions are hidden, make the bar shorter | ||
| val modifier = if (showTextDescriptionsInNavbar) Modifier else Modifier.navigationBarsPadding().height(56.dp) | ||
|
MV-GH marked this conversation as resolved.
|
||
| NavigationBar( | ||
| modifier = modifier, | ||
| ) { | ||
| for (tab in NavTab.getEntries(userViewType)) { | ||
| val selected = tab == selectedTab | ||
| val iconBadgeCount = when (tab) { | ||
| NavTab.Inbox -> unreadCounts | ||
| NavTab.RegistrationApplications -> unreadAppCount | ||
| NavTab.Reports -> unreadReportCount | ||
| else -> null | ||
| } | ||
|
|
||
| NavigationBarItem( | ||
| icon = { | ||
| NavbarIconAndBadge( | ||
| iconBadgeCount = iconBadgeCount, | ||
| icon = | ||
| if (selected) { | ||
| tab.iconFilled | ||
| } else { | ||
| tab.iconOutlined | ||
| }, | ||
| contentDescription = stringResource(tab.contentDescriptionId), | ||
| item( | ||
| icon = { | ||
| NavbarIconAndBadge( | ||
| iconBadgeCount = iconBadgeCount, | ||
| icon = | ||
| if (selected) { | ||
| tab.iconFilled | ||
| } else { | ||
| tab.iconOutlined | ||
| }, | ||
| contentDescription = stringResource(tab.contentDescriptionId), | ||
| ) | ||
| }, | ||
| label = { | ||
| if (showTextDescriptionsInNavbar) { | ||
| Text( | ||
| textAlign = TextAlign.Center, | ||
| fontSize = TextUnit(10f, TextUnitType.Sp), | ||
| text = stringResource(tab.textId), | ||
| ) | ||
| }, | ||
| label = { | ||
| if (showTextDescriptionsInNavbar) { | ||
| Text( | ||
| textAlign = TextAlign.Center, | ||
| fontSize = TextUnit(10f, TextUnitType.Sp), | ||
| text = stringResource(tab.textId), | ||
| ) | ||
| } | ||
| }, | ||
| selected = selected, | ||
| onClick = { | ||
| onSelect(tab) | ||
| }, | ||
| ) | ||
| } | ||
| } | ||
| }, | ||
| selected = selected, | ||
| onClick = { | ||
| onSelectTab(tab) | ||
| }, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| @Preview | ||
| @Composable | ||
| fun BottomAppBarAllPreview() { | ||
| BottomAppBarAll( | ||
| selectedTab = NavTab.Home, | ||
| onSelect = {}, | ||
| unreadCounts = 30, | ||
| unreadAppCount = 2, | ||
| unreadReportCount = 8, | ||
| userViewType = UserViewType.AdminOnly, | ||
| showTextDescriptionsInNavbar = true, | ||
| fun AdaptiveNavigationBarPreview() { | ||
| NavigationSuiteScaffold( | ||
| navigationSuiteItems = { | ||
| adaptiveNavigationBar( | ||
| selectedTab = NavTab.Home, | ||
| onSelectTab = {}, | ||
| unreadCounts = 30, | ||
| unreadAppCount = 2, | ||
| unreadReportCount = 8, | ||
| userViewType = UserViewType.AdminOnly, | ||
| showTextDescriptionsInNavbar = true, | ||
| ) | ||
| }, | ||
| ) | ||
| } | ||
|
|
||
| @Preview | ||
| @Composable | ||
| fun BottomAppBarAllNoDescriptionsPreview() { | ||
| BottomAppBarAll( | ||
| selectedTab = NavTab.Home, | ||
| onSelect = {}, | ||
| unreadCounts = 30, | ||
| unreadAppCount = null, | ||
| unreadReportCount = null, | ||
| userViewType = UserViewType.Normal, | ||
| showTextDescriptionsInNavbar = false, | ||
| fun AdaptiveNavigationBarNoDescriptionsPreview() { | ||
| NavigationSuiteScaffold( | ||
| navigationSuiteItems = { | ||
| adaptiveNavigationBar( | ||
| selectedTab = NavTab.Home, | ||
| onSelectTab = {}, | ||
| unreadCounts = 30, | ||
| unreadAppCount = 2, | ||
| unreadReportCount = 8, | ||
| userViewType = UserViewType.AdminOnly, | ||
| showTextDescriptionsInNavbar = false, | ||
| ) | ||
| }, | ||
| ) | ||
| } | ||
|
|
||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.