Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
nahwneeth committed Jun 15, 2023
1 parent d4ecbc8 commit 6da8447
Show file tree
Hide file tree
Showing 21 changed files with 56 additions and 56 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/com/jerboa/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class MainActivity : ComponentActivity() {
MarkdownHelper.init(
this,
appSettingsViewModel.appSettings.value?.useCustomTabs ?: true,
appSettingsViewModel.appSettings.value?.usePrivateTabs ?: false
appSettingsViewModel.appSettings.value?.usePrivateTabs ?: false,
)
window.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))

Expand All @@ -131,7 +131,7 @@ class MainActivity : ComponentActivity() {
enterTransition = { defaultEnterTransition },
exitTransition = { defaultExitTransition },
popEnterTransition = { defaultPopEnterTransition },
popExitTransition = { defaultPopExitTransition }
popExitTransition = { defaultPopExitTransition },
) {
loginScreen(
navController = navController,
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/jerboa/nav/AboutNavigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ private const val aboutRoutePattern = "about"
@OptIn(ExperimentalAnimationApi::class)
fun NavGraphBuilder.aboutScreen(
navController: NavController,
appSettings: AppSettings?
appSettings: AppSettings?,
) {
composable(
route = aboutRoutePattern,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fun NavGraphBuilder.accountSettingsScreen(
composable(
route = accountSettingsRoutePattern,
deepLinks = DEFAULT_LEMMY_INSTANCES.map { instance ->
navDeepLink { uriPattern = "${instance}/settings" }
navDeepLink { uriPattern = "$instance/settings" }
},
) {
AccountSettingsActivity(
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/jerboa/nav/CommentNavigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fun NavGraphBuilder.commentScreen(
composable(
route = commentRoutePattern,
deepLinks = DEFAULT_LEMMY_INSTANCES.map { instance ->
navDeepLink { uriPattern = "${instance}/${commentRoutePattern}" }
navDeepLink { uriPattern = "$instance/$commentRoutePattern" }
},
arguments = listOf(
navArgument(CommentArgs.ID) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/jerboa/nav/CommentReplyNavigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.jerboa.ui.components.home.SiteViewModel
import com.jerboa.ui.components.person.PersonProfileViewModel
import com.jerboa.ui.components.post.PostViewModel

private const val commentReplyRoutePattern = "commentReply";
private const val commentReplyRoutePattern = "commentReply"

@OptIn(ExperimentalAnimationApi::class)
fun NavGraphBuilder.commentReplyScreen(
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/jerboa/nav/CommunityListNavigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private class CommunityListArgs(val select: Boolean) {

private const val communityListRoutePattern = "communityList?select={${CommunityListArgs.SELECT}}"

fun NavBackStackEntry.bottomNavIsSearch() = destination.route == communityListRoutePattern;
fun NavBackStackEntry.bottomNavIsSearch() = destination.route == communityListRoutePattern

@OptIn(ExperimentalAnimationApi::class)
fun NavGraphBuilder.communityListScreen(
Expand Down Expand Up @@ -61,4 +61,3 @@ fun NavController.bottomNavSelectSearch() {
popUpTo(0)
}
}

2 changes: 1 addition & 1 deletion app/src/main/java/com/jerboa/nav/CreatePostNavigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import com.jerboa.ui.components.community.list.CommunityListViewModel
import com.jerboa.ui.components.post.create.CreatePostActivity
import com.jerboa.ui.components.post.create.CreatePostViewModel

private const val createPostRoutePattern = "createPost";
private const val createPostRoutePattern = "createPost"

@OptIn(ExperimentalAnimationApi::class)
fun NavGraphBuilder.createPostScreen(
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/jerboa/nav/FeedNavigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import com.jerboa.ui.components.post.edit.PostEditViewModel

private const val feedRoutePattern = "feed"

fun bottomNavDefaultRoute() = feedRoutePattern;
fun bottomNavDefaultRoute() = feedRoutePattern

fun NavBackStackEntry.bottomNavIsHome(): Boolean = destination.route == feedRoutePattern

Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/jerboa/nav/HomeNavigation.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.jerboa.nav

import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.material3.DrawerState
import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import com.google.accompanist.navigation.animation.composable
Expand All @@ -11,8 +10,8 @@ import com.jerboa.db.AppSettingsViewModel
import com.jerboa.ui.components.comment.edit.CommentEditViewModel
import com.jerboa.ui.components.comment.reply.CommentReplyViewModel
import com.jerboa.ui.components.community.list.CommunityListViewModel
import com.jerboa.ui.components.home.HomeViewModel
import com.jerboa.ui.components.home.HomeActivity
import com.jerboa.ui.components.home.HomeViewModel
import com.jerboa.ui.components.home.SiteViewModel
import com.jerboa.ui.components.inbox.InboxViewModel
import com.jerboa.ui.components.person.PersonProfileViewModel
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/jerboa/nav/InboxNavigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import com.jerboa.ui.components.inbox.InboxViewModel

private const val inboxRoutePattern = "inbox"

fun NavBackStackEntry.bottomNavIsInbox() = destination.route == inboxRoutePattern;
fun NavBackStackEntry.bottomNavIsInbox() = destination.route == inboxRoutePattern

@OptIn(ExperimentalAnimationApi::class)
fun NavGraphBuilder.inboxScreen(
Expand All @@ -35,7 +35,7 @@ fun NavGraphBuilder.inboxScreen(
composable(
route = inboxRoutePattern,
deepLinks = DEFAULT_LEMMY_INSTANCES.map { instance ->
navDeepLink { uriPattern = "${instance}/${inboxRoutePattern}" }
navDeepLink { uriPattern = "$instance/$inboxRoutePattern" }
},
) {
if (account != null) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/jerboa/nav/LoginNavigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fun NavGraphBuilder.loginScreen(
composable(
route = loginRoutePattern,
deepLinks = DEFAULT_LEMMY_INSTANCES.map { instance ->
navDeepLink { uriPattern = "${instance}/${loginRoutePattern}" }
navDeepLink { uriPattern = "$instance/$loginRoutePattern" }
},
) {
LoginActivity(
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/jerboa/nav/PostNavigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ fun NavGraphBuilder.postScreen(
account: Account?,
appSettings: AppSettings?,
ctx: Context,
) {
) {
composable(
route = postRoutePattern,
deepLinks = DEFAULT_LEMMY_INSTANCES.map { instance ->
navDeepLink { uriPattern = "$instance/${postRoutePattern}" }
navDeepLink { uriPattern = "$instance/$postRoutePattern" }
},
arguments = listOf(
navArgument(PostArgs.ID) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/jerboa/nav/PostReportNavigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private class PostReportArgs(val id: Int) {
}
}

private const val postReportRoutePattern ="postReport/{${PostReportArgs.ID}}"
private const val postReportRoutePattern = "postReport/{${PostReportArgs.ID}}"

@OptIn(ExperimentalAnimationApi::class)
fun NavGraphBuilder.postReportScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.jerboa.ui.components.home.SiteViewModel
import com.jerboa.ui.components.inbox.InboxViewModel
import com.jerboa.ui.components.privatemessage.PrivateMessageReplyActivity

private const val privateMessageReplyRoutePattern ="privateMessageReply"
private const val privateMessageReplyRoutePattern = "privateMessageReply"

@OptIn(ExperimentalAnimationApi::class)
fun NavGraphBuilder.privateMessageReplyScreen(
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/jerboa/nav/ProfileNavigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import com.jerboa.ui.components.post.edit.PostEditViewModel
private class ProfileArgs(val id: Int, val saved: Boolean) {
constructor(navBackStackEntry: NavBackStackEntry) : this(
id = navBackStackEntry.arguments?.getInt(ID)!!,
saved = navBackStackEntry.arguments?.getBoolean(SAVED)!!
saved = navBackStackEntry.arguments?.getBoolean(SAVED)!!,
)

companion object {
Expand All @@ -36,21 +36,21 @@ private class ProfileArgs(val id: Int, val saved: Boolean) {
private const val profileRoutePattern = "profile/{${ProfileArgs.ID}}?saved={${ProfileArgs.SAVED}}"

fun NavBackStackEntry.bottomNavIsProfile() =
destination.route == profileRoutePattern && !ProfileArgs(this).saved;
destination.route == profileRoutePattern && !ProfileArgs(this).saved

fun NavBackStackEntry.bottomNavIsSaved() =
destination.route == profileRoutePattern && ProfileArgs(this).saved;
destination.route == profileRoutePattern && ProfileArgs(this).saved

fun NavController.bottomNavSelectSaved(profileId: Int) {
val route = "profile/${profileId}?saved=${true}"
val route = "profile/$profileId?saved=${true}"
navigate(route) {
launchSingleTop = true
popUpTo(0)
}
}

fun NavController.bottomNavSelectProfile(profileId: Int) {
val route = "profile/${profileId}"
val route = "profile/$profileId"
navigate(route) {
launchSingleTop = true
popUpTo(0)
Expand Down
6 changes: 2 additions & 4 deletions app/src/main/java/com/jerboa/nav/ProfileNavigationByUrl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ import com.jerboa.db.AppSettings
import com.jerboa.db.AppSettingsViewModel
import com.jerboa.ui.components.comment.edit.CommentEditViewModel
import com.jerboa.ui.components.comment.reply.CommentReplyViewModel
import com.jerboa.ui.components.community.CommunityActivity
import com.jerboa.ui.components.community.CommunityViewModel
import com.jerboa.ui.components.community.list.CommunityListViewModel
import com.jerboa.ui.components.home.SiteViewModel
import com.jerboa.ui.components.person.PersonProfileActivity
import com.jerboa.ui.components.person.PersonProfileViewModel
Expand All @@ -37,7 +34,8 @@ private class ProfileByUrlArgs(val instance: String, val name: String) {
}
}

private const val profileByUrlRoutePattern = "{${ProfileByUrlArgs.INSTANCE}}/u/{${ProfileByUrlArgs.NAME}}"
private const val profileByUrlRoutePattern =
"{${ProfileByUrlArgs.INSTANCE}}/u/{${ProfileByUrlArgs.NAME}}"

@OptIn(ExperimentalAnimationApi::class)
fun NavGraphBuilder.profileScreenFromUrl(
Expand Down
7 changes: 0 additions & 7 deletions app/src/main/java/com/jerboa/nav/Transitions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@ import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutHorizontally
import androidx.compose.animation.slideOutVertically
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.runtime.Composable
import androidx.navigation.NavController

val noEnterTransition = fadeIn(tween(0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fun DefaultBackButton(navController: NavController) {
pressedBackButton = true
Icon(
imageVector = Icons.Outlined.ArrowBack,
contentDescription = stringResource(R.string.topAppBar_back)
contentDescription = stringResource(R.string.topAppBar_back),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fun CommunityListHeader(
)
}
},
navigationIcon = { DefaultBackButton(navController) }
navigationIcon = { DefaultBackButton(navController) },
)
}

Expand Down
32 changes: 18 additions & 14 deletions app/src/main/java/com/jerboa/ui/components/home/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -289,24 +289,28 @@ fun BottomNavBar(
BottomNavBarType.Profile -> Icons.Outlined.Person
}
},
contentDescription = stringResource(when (type) {
BottomNavBarType.Home -> R.string.bottomBar_home
BottomNavBarType.Search -> R.string.bottomBar_search
BottomNavBarType.Inbox -> R.string.bottomBar_inbox
BottomNavBarType.Saved -> R.string.bottomBar_bookmarks
BottomNavBarType.Profile -> R.string.bottomBar_profile
}),
contentDescription = stringResource(
when (type) {
BottomNavBarType.Home -> R.string.bottomBar_home
BottomNavBarType.Search -> R.string.bottomBar_search
BottomNavBarType.Inbox -> R.string.bottomBar_inbox
BottomNavBarType.Saved -> R.string.bottomBar_bookmarks
BottomNavBarType.Profile -> R.string.bottomBar_profile
},
),
)
},
label = {
Text(
text = stringResource(when (type) {
BottomNavBarType.Home -> R.string.bottomBar_label_home
BottomNavBarType.Search -> R.string.bottomBar_label_search
BottomNavBarType.Inbox -> R.string.bottomBar_label_inbox
BottomNavBarType.Saved -> R.string.bottomBar_label_bookmarks
BottomNavBarType.Profile -> R.string.bottomBar_label_profile
}),
text = stringResource(
when (type) {
BottomNavBarType.Home -> R.string.bottomBar_label_home
BottomNavBarType.Search -> R.string.bottomBar_label_search
BottomNavBarType.Inbox -> R.string.bottomBar_label_inbox
BottomNavBarType.Saved -> R.string.bottomBar_label_bookmarks
BottomNavBarType.Profile -> R.string.bottomBar_label_profile
},
),
color = MaterialTheme.colorScheme.onSurface,
)
},
Expand Down
17 changes: 12 additions & 5 deletions app/src/main/java/com/jerboa/ui/components/post/PostActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.ArrowBack
import androidx.compose.material.icons.outlined.Sort
import androidx.compose.material.pullrefresh.PullRefreshIndicator
import androidx.compose.material.pullrefresh.pullRefresh
Expand Down Expand Up @@ -176,7 +175,11 @@ fun PostActivity(
},
content = { padding ->
Box(modifier = Modifier.pullRefresh(pullRefreshState)) {
PullRefreshIndicator(postViewModel.loading, pullRefreshState, Modifier.align(Alignment.TopCenter))
PullRefreshIndicator(
postViewModel.loading,
pullRefreshState,
Modifier.align(Alignment.TopCenter),
)
postViewModel.postView.value?.also { postView ->
LazyColumn(
state = listState,
Expand Down Expand Up @@ -266,7 +269,8 @@ fun PostActivity(
postViewMode = PostViewMode.Card,
showVotingArrowsInListView = showVotingArrowsInListView,
enableDownVotes = enableDownVotes,
showAvatar = siteViewModel.siteRes?.my_user?.local_user_view?.local_user?.show_avatars ?: true,
showAvatar = siteViewModel.siteRes?.my_user?.local_user_view?.local_user?.show_avatars
?: true,
)
}
item(key = "${postView.post.id}_is_comment_view") {
Expand Down Expand Up @@ -387,10 +391,13 @@ fun PostActivity(
showCollapsedCommentContent = showCollapsedCommentContent,
isCollapsedByParent = false,
showActionBar = { commentId ->
showActionBarByDefault xor commentsWithToggledActionBar.contains(commentId)
showActionBarByDefault xor commentsWithToggledActionBar.contains(
commentId,
)
},
enableDownVotes = enableDownVotes,
showAvatar = siteViewModel.siteRes?.my_user?.local_user_view?.local_user?.show_avatars ?: true,
showAvatar = siteViewModel.siteRes?.my_user?.local_user_view?.local_user?.show_avatars
?: true,
)
}
}
Expand Down

0 comments on commit 6da8447

Please sign in to comment.