Skip to content
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

Add bottom bar to community list #497

Merged
merged 6 commits into from
Jun 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/src/main/java/com/jerboa/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ class MainActivity : ComponentActivity() {
CommunityListActivity(
navController = navController,
accountViewModel = accountViewModel,
homeViewModel = homeViewModel,
appSettingsViewModel = appSettingsViewModel,
communityListViewModel = communityListViewModel,
selectMode = it.arguments?.getBoolean("select")!!,
)
Expand Down
19 changes: 14 additions & 5 deletions app/src/main/java/com/jerboa/ui/components/common/AppBars.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Bookmarks
import androidx.compose.material.icons.filled.Email
import androidx.compose.material.icons.filled.Home
import androidx.compose.material.icons.filled.List
import androidx.compose.material.icons.filled.Person
import androidx.compose.material.icons.outlined.*
import androidx.compose.material3.*
Expand Down Expand Up @@ -127,15 +128,23 @@ fun BottomAppBarAll(

NavigationBarItem(
icon = {
Icon(
imageVector = Icons.Outlined.List,
contentDescription = "TODO",
)
if (screen == "communityList") {
Icon(
imageVector = Icons.Filled.List,
tint = MaterialTheme.colorScheme.primary,
contentDescription = "TODO",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contentDescriptions are in another PR, but don't worry about them, as this will probably get merged before anyway.

)
} else {
Icon(
imageVector = Icons.Outlined.List,
contentDescription = "TODO",
)
}
},
onClick = {
navController.navigate("communityList")
},
selected = screen == "communityList",
selected = false,
)
NavigationBarItem(
icon = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ import androidx.compose.ui.platform.LocalContext
import androidx.navigation.NavController
import com.jerboa.DEBOUNCE_DELAY
import com.jerboa.db.AccountViewModel
import com.jerboa.db.AppSettingsViewModel
import com.jerboa.loginFirstToast
import com.jerboa.ui.components.common.BottomAppBarAll
import com.jerboa.ui.components.common.getCurrentAccount
import com.jerboa.ui.components.home.HomeViewModel
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
Expand All @@ -34,6 +38,8 @@ fun CommunityListActivity(
navController: NavController,
communityListViewModel: CommunityListViewModel,
accountViewModel: AccountViewModel,
homeViewModel: HomeViewModel,
appSettingsViewModel: AppSettingsViewModel,
selectMode: Boolean = false,
) {
Log.d("jerboa", "got to community list activity")
Expand Down Expand Up @@ -85,6 +91,35 @@ fun CommunityListActivity(
)
}
},
bottomBar = {
BottomAppBarAll(
showBottomNav = appSettingsViewModel.appSettings.value?.showBottomNav,
screen = "communityList",
unreadCounts = homeViewModel.unreadCountResponse,
onClickProfile = {
account?.id?.also {
navController.navigate(route = "profile/$it")
} ?: run {
loginFirstToast(ctx)
}
},
onClickInbox = {
account?.also {
navController.navigate(route = "inbox")
} ?: run {
loginFirstToast(ctx)
}
},
onClickSaved = {
account?.id?.also {
navController.navigate(route = "profile/$it?saved=${true}")
} ?: run {
loginFirstToast(ctx)
}
},
navController = navController,
)
},
)
}
}