Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
Improve history top bar
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkitSuda committed Nov 22, 2022
1 parent 8cbb7d0 commit 009b9d1
Showing 1 changed file with 14 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,65 +83,6 @@ fun HistoryScreen(
val argMonth = viewModel.argMonth
val argYear = viewModel.argYear

// LaunchedEffect(key1 = argumentsDate?.value) {
// if (argumentsDate?.value == null) return@LaunchedEffect;
//
// try {
// val mDate = argumentsDate.value?.toLocalDate()
// var index = -1
//
//// var loopIndex = 0;
//// for (map in workoutsMap) {
//// if (map.key?.month == mDate?.month && map.key?.year == mDate?.year) {
//// index = loopIndex;
//// break;
//// } else {
//// loopIndex += 1 + map.value.size
//// }
//// }
//// workoutsPage?.forEachIndexed { i, item ->
//// if (item is WorkoutWithExtraInfo && item.workout?.completedAt.toString() == mDate.toString()) {
//// index = i
//// }
//// }
//
// val allWorkouts = viewModel.workouts2.firstOrNull()
//
// if (allWorkouts != null) {
// for (i in allWorkouts.indices) {
// val item = allWorkouts[i]
// if (item is WorkoutWithExtraInfo) {
// val a = item.workout?.completedAt?.toLocalDate().toString()
// val b = mDate.toString()
// if (a == b) {
// index = i
// break
// }
// }
// }
// }
//
// if (index > -1) {
// try {
// workoutsPage[index]
// } catch (e: Exception) {
// e.printStackTrace()
// }
// delay(100)
// scrollState.animateScrollToItem(
// index
// )
// }
//
// Timber.d("items count ${workoutsPage.itemCount}")
//
// navController.currentBackStackEntry
// ?.savedStateHandle?.remove(DATE_KEY)
// } catch (e: Exception) {
// e.printStackTrace()
// }
// }

CollapsingToolbarScaffold(
scrollStrategy = ScrollStrategy.EnterAlwaysCollapsed,
state = collapsingState,
Expand All @@ -162,16 +103,9 @@ fun HistoryScreen(
.toString()
},
toolbarState = collapsingState.toolbarState,
navigationIcon = {
if (dateRangeType == WorkoutsDateRangeType.ALL) {
TopBarIconButton(
icon = Icons.Outlined.DateRange,
title = stringResource(id = R.string.show_calendar),
onClick = {
navigator.navigate(LeafScreen.Calendar.createRoute(selectedDate = LocalDate.now()))
}
)
} else {
navigationIcon =
if (dateRangeType != WorkoutsDateRangeType.ALL) {
{
TopBarIconButton(
icon = Icons.Outlined.ArrowBack,
title = stringResource(id = R.string.back),
Expand All @@ -180,15 +114,19 @@ fun HistoryScreen(
}
)
}
} else {
null
},
actions = {
TopBarIconButton(
icon = Icons.Outlined.MoreVert,
title = stringResource(id = R.string.open_menu),
onClick = {

}
)
if (dateRangeType == WorkoutsDateRangeType.ALL) {
TopBarIconButton(
icon = Icons.Outlined.DateRange,
title = stringResource(id = R.string.show_calendar),
onClick = {
navigator.navigate(LeafScreen.Calendar.createRoute(selectedDate = LocalDate.now()))
}
)
}
}
)
},
Expand Down

0 comments on commit 009b9d1

Please sign in to comment.