Skip to content

Commit

Permalink
Adding a ListDetailPaneScaffold to the List screens. I want to play a…
Browse files Browse the repository at this point in the history
…round with it and see if it's worth continuing with them
  • Loading branch information
jakepurple13 committed Nov 17, 2023
1 parent 9797670 commit ab8265b
Show file tree
Hide file tree
Showing 8 changed files with 1,117 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.ExperimentalComposeUiApi
Expand Down Expand Up @@ -104,6 +105,7 @@ import com.programmersbox.uiviews.history.HistoryUi
import com.programmersbox.uiviews.lists.ImportListScreen
import com.programmersbox.uiviews.lists.OtakuCustomListScreen
import com.programmersbox.uiviews.lists.OtakuListScreen
import com.programmersbox.uiviews.lists.OtakuListStuff
import com.programmersbox.uiviews.notifications.NotificationsScreen
import com.programmersbox.uiviews.notifications.cancelNotification
import com.programmersbox.uiviews.recent.RecentView
Expand Down Expand Up @@ -158,6 +160,8 @@ abstract class BaseMainActivity : AppCompatActivity() {

private var notificationCount by mutableIntStateOf(0)

private var showListDetail by mutableStateOf(true)

@OptIn(
ExperimentalMaterial3Api::class,
ExperimentalMaterial3WindowSizeClassApi::class
Expand Down Expand Up @@ -362,7 +366,7 @@ abstract class BaseMainActivity : AppCompatActivity() {
NavigationRailItem(
imageVector = Icons.AutoMirrored.Default.List,
label = stringResource(R.string.custom_lists_title),
screen = Screen.CustomListScreen,
screen = if (showListDetail) Screen.CustomListStuffScreen else Screen.CustomListScreen,
currentDestination = currentDestination,
navController = navController,
customRoute = "_home"
Expand Down Expand Up @@ -499,7 +503,11 @@ abstract class BaseMainActivity : AppCompatActivity() {
favoritesClick = { navController.navigate(Screen.FavoriteScreen.route) { launchSingleTop = true } },
historyClick = { navController.navigate(Screen.HistoryScreen.route) { launchSingleTop = true } },
globalSearchClick = { navController.navigate(Screen.GlobalSearchScreen.route) { launchSingleTop = true } },
listClick = { navController.navigate(Screen.CustomListScreen.route) { launchSingleTop = true } },
listClick = {
navController.navigate(
if (showListDetail) Screen.CustomListStuffScreen.route else Screen.CustomListScreen.route
) { launchSingleTop = true }
},
debugMenuClick = { navController.navigate(Screen.DebugScreen.route) { launchSingleTop = true } }
)
}
Expand Down Expand Up @@ -566,6 +574,11 @@ abstract class BaseMainActivity : AppCompatActivity() {
)
}

composable(
Screen.CustomListStuffScreen.route,
enterTransition = { slideIntoContainer(AnimatedContentTransitionScope.SlideDirection.Start) },
exitTransition = { slideOutOfContainer(AnimatedContentTransitionScope.SlideDirection.End) }
) { OtakuListStuff() }
composable(Screen.CustomListScreen.route) { OtakuListScreen() }
composable(
Screen.CustomListItemScreen.route + "/{uuid}"
Expand Down Expand Up @@ -622,6 +635,11 @@ abstract class BaseMainActivity : AppCompatActivity() {
}

composable(Screen.CustomListScreen.route + "_home") { OtakuListScreen() }
composable(
Screen.CustomListStuffScreen.route + "_home",
enterTransition = { slideIntoContainer(AnimatedContentTransitionScope.SlideDirection.Start) },
exitTransition = { slideOutOfContainer(AnimatedContentTransitionScope.SlideDirection.End) }
) { OtakuListStuff() }

composable(
Screen.NotificationScreen.route + "_home",
Expand Down Expand Up @@ -701,6 +719,10 @@ abstract class BaseMainActivity : AppCompatActivity() {
.getAllNotificationCount()
.onEach { notificationCount = it }
.launchIn(lifecycleScope)

settingsHandling.showListDetail
.onEach { showListDetail = it }
.launchIn(lifecycleScope)
}

private fun NavDestination?.isTopLevelDestinationInHierarchy(destination: Screen) = this?.hierarchy?.any {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ fun OtakuCustomListScreen(
verticalArrangement = Arrangement.spacedBy(4.dp),
modifier = Modifier
.padding(16.dp)
.padding(bottom = 80.dp)
.fillMaxWidth(),
) {
itemsIndexed(items = vm.searchItems) { index, item ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ fun OtakuListScreen(
listDao: ListDao = LocalCustomListDao.current,
vm: OtakuListViewModel = viewModel { OtakuListViewModel(listDao) }
) {
//TODO: MAYBE do a ListDetailScaffold here?
val navController = LocalNavController.current
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())

Expand Down
Loading

0 comments on commit ab8265b

Please sign in to comment.