-
Notifications
You must be signed in to change notification settings - Fork 171
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 7 commits
09b507c
fbecf47
78b4915
7492570
e6546cc
fe47f61
7c846c2
17828a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <resources> | ||
| <string name="app_name">Jerboa (ОТЛАДКА)</string> | ||
| </resources> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,7 +60,7 @@ | |
| <data android:mimeType="image/*" /> | ||
| </intent-filter> | ||
|
|
||
| <intent-filter> | ||
| <intent-filter android:autoVerify="true"> | ||
|
||
| <action android:name="android.intent.action.VIEW" /> | ||
| <category android:name="android.intent.category.DEFAULT" /> | ||
| <category android:name="android.intent.category.BROWSABLE" /> | ||
|
|
||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,7 +46,7 @@ fun futureDaysToUnixTime(days: Long?): Long? = | |
| fun amMod( | ||
| moderators: List<PersonId>?, | ||
| myId: PersonId, | ||
| ): Boolean = moderators?.contains(myId) ?: false | ||
|
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. Imo the previous reads easier but you can leave as is. |
||
| ): Boolean = moderators?.contains(myId) == true | ||
|
|
||
| /** | ||
| * In screens with posts from different communities we don't have access to moderators of those communities | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,7 +49,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 | ||
|
|
@@ -79,6 +79,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.testTag | ||
|
|
@@ -112,99 +111,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.
Show resolved
Hide 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, | ||
| ) | ||
| }, | ||
| ) | ||
| } | ||
|
|
||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you remove this then you might as well remove the entire file
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do. There's a lot of other translation lints that android studio is telling us to fix, but that can be done in a separate PR.
Eventually we can switch to weblate, I've done that for a few other repos now.