Change the Scaffold hierarchy
This commit is contained in:
parent
1bbd523e88
commit
c3f2dd1363
9 changed files with 214 additions and 1440 deletions
1158
.idea/misc.xml
generated
1158
.idea/misc.xml
generated
File diff suppressed because it is too large
Load diff
Binary file not shown.
Binary file not shown.
|
|
@ -10,9 +10,11 @@ import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.NavigationBarDefaults
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TopAppBar
|
import androidx.compose.material3.TopAppBar
|
||||||
|
import androidx.compose.material3.TopAppBarDefaults
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.State
|
import androidx.compose.runtime.State
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
|
|
@ -64,6 +66,9 @@ private fun CalendarContent(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
topBar = {
|
topBar = {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
|
colors = TopAppBarDefaults.topAppBarColors(
|
||||||
|
containerColor = NavigationBarDefaults.containerColor,
|
||||||
|
),
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = onBack,
|
onClick = onBack,
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,12 @@ import androidx.compose.material3.FloatingActionButton
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.NavigationBarDefaults
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TopAppBar
|
import androidx.compose.material3.TopAppBar
|
||||||
|
import androidx.compose.material3.TopAppBarDefaults
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import androidx.compose.runtime.State
|
import androidx.compose.runtime.State
|
||||||
|
|
@ -105,6 +107,9 @@ private fun EventContent(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
topBar = {
|
topBar = {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
|
colors = TopAppBarDefaults.topAppBarColors(
|
||||||
|
containerColor = NavigationBarDefaults.containerColor,
|
||||||
|
),
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = onBack,
|
onClick = onBack,
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,46 @@
|
||||||
package com.pixelized.headache.ui.page.home
|
package com.pixelized.headache.ui.page.home
|
||||||
|
|
||||||
import androidx.compose.animation.AnimatedContent
|
import androidx.compose.animation.AnimatedContent
|
||||||
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.animation.fadeIn
|
import androidx.compose.animation.fadeIn
|
||||||
import androidx.compose.animation.fadeOut
|
import androidx.compose.animation.fadeOut
|
||||||
import androidx.compose.animation.togetherWith
|
import androidx.compose.animation.togetherWith
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
|
||||||
import androidx.compose.foundation.layout.heightIn
|
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
|
|
||||||
import androidx.compose.material.icons.filled.Add
|
import androidx.compose.material.icons.filled.Add
|
||||||
|
import androidx.compose.material.icons.filled.Info
|
||||||
|
import androidx.compose.material3.DropdownMenu
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.FloatingActionButton
|
import androidx.compose.material3.FloatingActionButton
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.NavigationBar
|
import androidx.compose.material3.NavigationBar
|
||||||
|
import androidx.compose.material3.NavigationBarDefaults
|
||||||
import androidx.compose.material3.NavigationBarItem
|
import androidx.compose.material3.NavigationBarItem
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TopAppBar
|
||||||
|
import androidx.compose.material3.TopAppBarDefaults
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import androidx.compose.runtime.State
|
import androidx.compose.runtime.State
|
||||||
import androidx.compose.runtime.derivedStateOf
|
import androidx.compose.runtime.derivedStateOf
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
import androidx.hilt.navigation.compose.hiltViewModel
|
||||||
import com.pixelized.headache.R
|
import com.pixelized.headache.R
|
||||||
|
|
@ -46,7 +54,7 @@ import com.pixelized.headache.ui.navigation.home.HomeNavDisplay
|
||||||
import com.pixelized.headache.ui.navigation.home.HomeNavigator
|
import com.pixelized.headache.ui.navigation.home.HomeNavigator
|
||||||
import com.pixelized.headache.ui.page.event.edit.EventEditBottomSheet
|
import com.pixelized.headache.ui.page.event.edit.EventEditBottomSheet
|
||||||
import com.pixelized.headache.ui.page.event.edit.EventEditBottomSheetViewModel
|
import com.pixelized.headache.ui.page.event.edit.EventEditBottomSheetViewModel
|
||||||
|
import com.pixelized.headache.ui.theme.color.HeadacheColorPalette
|
||||||
|
|
||||||
@Stable
|
@Stable
|
||||||
data class BottomBarItemUio(
|
data class BottomBarItemUio(
|
||||||
|
|
@ -61,17 +69,7 @@ fun HomePage(
|
||||||
navigator: HomeNavigator,
|
navigator: HomeNavigator,
|
||||||
editViewModel: EventEditBottomSheetViewModel = hiltViewModel(),
|
editViewModel: EventEditBottomSheetViewModel = hiltViewModel(),
|
||||||
) {
|
) {
|
||||||
val selectedItem = remember {
|
val bottomBarItems = rememberBottomBarItems(
|
||||||
derivedStateOf {
|
|
||||||
when (navigator.backStack.last()) {
|
|
||||||
is YearSummaryDestination -> 0
|
|
||||||
is ReportDestination -> 1
|
|
||||||
is MonthSummaryDestination -> 2
|
|
||||||
else -> -1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val items = rememberBottomBarItems(
|
|
||||||
onYearlyFollowUp = {
|
onYearlyFollowUp = {
|
||||||
navigator.navigateToYearSummary()
|
navigator.navigateToYearSummary()
|
||||||
},
|
},
|
||||||
|
|
@ -82,12 +80,41 @@ fun HomePage(
|
||||||
navigator.navigateToMonthSummary()
|
navigator.navigateToMonthSummary()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
val selectedItem = remember {
|
||||||
|
derivedStateOf {
|
||||||
|
when (navigator.backStack.last()) {
|
||||||
|
is YearSummaryDestination -> 0
|
||||||
|
is ReportDestination -> 1
|
||||||
|
is MonthSummaryDestination -> 2
|
||||||
|
else -> -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val displayLegendAction = remember {
|
||||||
|
derivedStateOf {
|
||||||
|
when (navigator.backStack.lastOrNull()) {
|
||||||
|
is ReportDestination -> true
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val displayLegendPopup = remember {
|
||||||
|
mutableStateOf(false)
|
||||||
|
}
|
||||||
|
|
||||||
HomePageContent(
|
HomePageContent(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
navigator = navigator,
|
navigator = navigator,
|
||||||
items = items,
|
displayLegendAction = displayLegendAction,
|
||||||
|
displayLegendPopup = displayLegendPopup,
|
||||||
|
items = bottomBarItems,
|
||||||
selectedItem = selectedItem,
|
selectedItem = selectedItem,
|
||||||
|
onDisplayLegend = {
|
||||||
|
displayLegendPopup.value = true
|
||||||
|
},
|
||||||
|
onDismissLegend = {
|
||||||
|
displayLegendPopup.value = false
|
||||||
|
},
|
||||||
onFabClick = {
|
onFabClick = {
|
||||||
editViewModel.show()
|
editViewModel.show()
|
||||||
},
|
},
|
||||||
|
|
@ -129,13 +156,50 @@ private fun rememberBottomBarItems(
|
||||||
private fun HomePageContent(
|
private fun HomePageContent(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
navigator: HomeNavigator,
|
navigator: HomeNavigator,
|
||||||
|
displayLegendAction: State<Boolean>,
|
||||||
|
displayLegendPopup: State<Boolean>,
|
||||||
items: List<BottomBarItemUio>,
|
items: List<BottomBarItemUio>,
|
||||||
selectedItem: State<Int>,
|
selectedItem: State<Int>,
|
||||||
|
onDisplayLegend: () -> Unit,
|
||||||
|
onDismissLegend: () -> Unit,
|
||||||
onFabClick: () -> Unit,
|
onFabClick: () -> Unit,
|
||||||
) {
|
) {
|
||||||
Scaffold(
|
Scaffold(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
contentWindowInsets = remember { WindowInsets(0, 0, 0, 0) },
|
topBar = {
|
||||||
|
TopAppBar(
|
||||||
|
colors = TopAppBarDefaults.topAppBarColors(
|
||||||
|
containerColor = NavigationBarDefaults.containerColor,
|
||||||
|
),
|
||||||
|
title = {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.app_name),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
actions = {
|
||||||
|
AnimatedVisibility(
|
||||||
|
visible = displayLegendAction.value,
|
||||||
|
) {
|
||||||
|
IconButton(
|
||||||
|
onClick = onDisplayLegend,
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Default.Info,
|
||||||
|
contentDescription = null,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
DropdownMenu(
|
||||||
|
expanded = displayLegendPopup.value,
|
||||||
|
onDismissRequest = onDismissLegend,
|
||||||
|
) {
|
||||||
|
LegendPopupContent(
|
||||||
|
modifier = Modifier.padding(horizontal = 12.dp, vertical = 4.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
},
|
||||||
bottomBar = {
|
bottomBar = {
|
||||||
NavigationBar {
|
NavigationBar {
|
||||||
items.forEachIndexed { index, item ->
|
items.forEachIndexed { index, item ->
|
||||||
|
|
@ -183,40 +247,44 @@ private fun HomePageContent(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Stable
|
|
||||||
data object NavigationItemDefault {
|
|
||||||
@Stable
|
|
||||||
val minHeight: Dp = 56.dp
|
|
||||||
|
|
||||||
@Stable
|
|
||||||
val padding = PaddingValues(horizontal = 16.dp)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun NavigationItem(
|
private fun LegendPopupContent(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
padding: PaddingValues = NavigationItemDefault.padding,
|
|
||||||
minHeight: Dp = NavigationItemDefault.minHeight,
|
|
||||||
label: String,
|
|
||||||
onClick: () -> Unit,
|
|
||||||
) {
|
) {
|
||||||
Row(
|
Column(
|
||||||
modifier = Modifier
|
modifier = modifier,
|
||||||
.clickable(onClick = onClick)
|
|
||||||
.fillMaxWidth()
|
|
||||||
.heightIn(min = minHeight)
|
|
||||||
.padding(paddingValues = padding)
|
|
||||||
.then(other = modifier),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
) {
|
) {
|
||||||
Text(
|
Row(
|
||||||
modifier = Modifier.weight(1f),
|
horizontalArrangement = Arrangement.spacedBy(space = 4.dp),
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
text = label,
|
) {
|
||||||
)
|
Box(
|
||||||
Icon(
|
modifier = Modifier
|
||||||
imageVector = Icons.AutoMirrored.Filled.KeyboardArrowRight,
|
.size(8.dp)
|
||||||
contentDescription = null,
|
.background(
|
||||||
)
|
color = HeadacheColorPalette.Calendar.Headache,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
style = MaterialTheme.typography.labelSmall,
|
||||||
|
text = "Jours de migraine",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Row(
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(space = 4.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.size(8.dp)
|
||||||
|
.background(
|
||||||
|
color = HeadacheColorPalette.Calendar.Pill,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
style = MaterialTheme.typography.labelSmall,
|
||||||
|
text = "Prise de cachet",
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -6,7 +6,6 @@ import androidx.compose.foundation.gestures.snapping.SnapPosition
|
||||||
import androidx.compose.foundation.gestures.snapping.rememberSnapFlingBehavior
|
import androidx.compose.foundation.gestures.snapping.rememberSnapFlingBehavior
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
|
|
@ -14,11 +13,7 @@ import androidx.compose.foundation.lazy.LazyListState
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.NavigationBarDefaults
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Scaffold
|
|
||||||
import androidx.compose.material3.Text
|
|
||||||
import androidx.compose.material3.TopAppBar
|
|
||||||
import androidx.compose.material3.TopAppBarDefaults
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import androidx.compose.runtime.State
|
import androidx.compose.runtime.State
|
||||||
|
|
@ -26,7 +21,6 @@ import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.keepScreenOn
|
import androidx.compose.ui.keepScreenOn
|
||||||
import androidx.compose.ui.res.stringResource
|
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||||
|
|
@ -34,7 +28,6 @@ import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
import androidx.hilt.navigation.compose.hiltViewModel
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.pixelized.headache.R
|
|
||||||
import com.pixelized.headache.ui.navigation.destination.navigateToEventPage
|
import com.pixelized.headache.ui.navigation.destination.navigateToEventPage
|
||||||
import com.pixelized.headache.ui.navigation.main.LocalMainNavigator
|
import com.pixelized.headache.ui.navigation.main.LocalMainNavigator
|
||||||
import com.pixelized.headache.ui.page.summary.monthly.item.MonthSummaryItem
|
import com.pixelized.headache.ui.page.summary.monthly.item.MonthSummaryItem
|
||||||
|
|
@ -89,50 +82,32 @@ private fun MonthSummaryContent(
|
||||||
events: State<Map<MonthSummaryTitleUio, List<MonthSummaryItemUio>>>,
|
events: State<Map<MonthSummaryTitleUio, List<MonthSummaryItemUio>>>,
|
||||||
onItem: (MonthSummaryItemUio) -> Unit,
|
onItem: (MonthSummaryItemUio) -> Unit,
|
||||||
) {
|
) {
|
||||||
Scaffold(
|
LazyColumn(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
contentWindowInsets = remember { WindowInsets(0, 0, 0, 0) },
|
state = state,
|
||||||
topBar = {
|
flingBehavior = flingBehavior,
|
||||||
TopAppBar(
|
contentPadding = listPadding,
|
||||||
colors = TopAppBarDefaults.topAppBarColors(
|
verticalArrangement = Arrangement.spacedBy(space = spacing),
|
||||||
containerColor = NavigationBarDefaults.containerColor,
|
reverseLayout = false,
|
||||||
),
|
) {
|
||||||
title = {
|
events.value.forEach { entry ->
|
||||||
Text(text = stringResource(R.string.month_summary_title))
|
item {
|
||||||
},
|
MonthSummaryTitle(
|
||||||
)
|
modifier = Modifier.padding(top = 16.dp),
|
||||||
},
|
item = entry.key,
|
||||||
content = { paddingValues ->
|
)
|
||||||
LazyColumn(
|
}
|
||||||
modifier = Modifier
|
items(
|
||||||
.fillMaxSize()
|
items = entry.value,
|
||||||
.padding(paddingValues = paddingValues),
|
key = { item -> item.date },
|
||||||
state = state,
|
) { item ->
|
||||||
flingBehavior = flingBehavior,
|
MonthSummaryItem(
|
||||||
contentPadding = listPadding,
|
item = item,
|
||||||
verticalArrangement = Arrangement.spacedBy(space = spacing),
|
onItem = onItem,
|
||||||
reverseLayout = false,
|
)
|
||||||
) {
|
|
||||||
events.value.forEach { entry ->
|
|
||||||
item {
|
|
||||||
MonthSummaryTitle(
|
|
||||||
modifier = Modifier.padding(top = 16.dp),
|
|
||||||
item = entry.key,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
items(
|
|
||||||
items = entry.value,
|
|
||||||
key = { item -> item.date },
|
|
||||||
) { item ->
|
|
||||||
MonthSummaryItem(
|
|
||||||
item = item,
|
|
||||||
onItem = onItem,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
@ -141,11 +116,14 @@ private fun MonthSummaryPreview(
|
||||||
@PreviewParameter(MonthSummaryPreviewProvider::class) preview: Map<MonthSummaryTitleUio, List<MonthSummaryItemUio>>,
|
@PreviewParameter(MonthSummaryPreviewProvider::class) preview: Map<MonthSummaryTitleUio, List<MonthSummaryItemUio>>,
|
||||||
) {
|
) {
|
||||||
HeadacheTheme {
|
HeadacheTheme {
|
||||||
val events = remember { mutableStateOf(preview) }
|
Surface {
|
||||||
MonthSummaryContent(
|
val events = remember { mutableStateOf(preview) }
|
||||||
events = events,
|
MonthSummaryContent(
|
||||||
onItem = { },
|
modifier = Modifier.fillMaxSize(),
|
||||||
)
|
events = events,
|
||||||
|
onItem = { },
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,47 +2,27 @@ package com.pixelized.headache.ui.page.summary.report
|
||||||
|
|
||||||
|
|
||||||
import android.icu.util.Calendar
|
import android.icu.util.Calendar
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.gestures.FlingBehavior
|
import androidx.compose.foundation.gestures.FlingBehavior
|
||||||
import androidx.compose.foundation.gestures.snapping.SnapPosition
|
import androidx.compose.foundation.gestures.snapping.SnapPosition
|
||||||
import androidx.compose.foundation.gestures.snapping.rememberSnapFlingBehavior
|
import androidx.compose.foundation.gestures.snapping.rememberSnapFlingBehavior
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
|
||||||
import androidx.compose.foundation.layout.Column
|
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.Row
|
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.padding
|
|
||||||
import androidx.compose.foundation.layout.size
|
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.LazyListState
|
import androidx.compose.foundation.lazy.LazyListState
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.material.icons.Icons
|
|
||||||
import androidx.compose.material.icons.filled.Info
|
|
||||||
import androidx.compose.material3.DropdownMenu
|
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.Icon
|
|
||||||
import androidx.compose.material3.IconButton
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
import androidx.compose.material3.NavigationBarDefaults
|
|
||||||
import androidx.compose.material3.Scaffold
|
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Text
|
|
||||||
import androidx.compose.material3.TopAppBar
|
|
||||||
import androidx.compose.material3.TopAppBarDefaults
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import androidx.compose.runtime.State
|
import androidx.compose.runtime.State
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.keepScreenOn
|
import androidx.compose.ui.keepScreenOn
|
||||||
import androidx.compose.ui.platform.LocalDensity
|
import androidx.compose.ui.platform.LocalDensity
|
||||||
import androidx.compose.ui.platform.LocalWindowInfo
|
import androidx.compose.ui.platform.LocalWindowInfo
|
||||||
import androidx.compose.ui.res.stringResource
|
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||||
|
|
@ -51,11 +31,9 @@ import androidx.compose.ui.unit.DpSize
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
import androidx.hilt.navigation.compose.hiltViewModel
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.pixelized.headache.R
|
|
||||||
import com.pixelized.headache.ui.navigation.destination.navigateToEventPage
|
import com.pixelized.headache.ui.navigation.destination.navigateToEventPage
|
||||||
import com.pixelized.headache.ui.navigation.main.LocalMainNavigator
|
import com.pixelized.headache.ui.navigation.main.LocalMainNavigator
|
||||||
import com.pixelized.headache.ui.theme.HeadacheTheme
|
import com.pixelized.headache.ui.theme.HeadacheTheme
|
||||||
import com.pixelized.headache.ui.theme.color.HeadacheColorPalette
|
|
||||||
import com.pixelized.headache.utils.extention.calculate
|
import com.pixelized.headache.utils.extention.calculate
|
||||||
|
|
||||||
@Stable
|
@Stable
|
||||||
|
|
@ -108,102 +86,21 @@ private fun ReportContent(
|
||||||
events: State<List<ReportBoxUio>>,
|
events: State<List<ReportBoxUio>>,
|
||||||
onMonth: (ReportBoxUio.Month) -> Unit,
|
onMonth: (ReportBoxUio.Month) -> Unit,
|
||||||
) {
|
) {
|
||||||
Scaffold(
|
LazyColumn(
|
||||||
modifier = modifier,
|
|
||||||
contentWindowInsets = remember { WindowInsets(0, 0, 0, 0) },
|
|
||||||
topBar = {
|
|
||||||
TopAppBar(
|
|
||||||
colors = TopAppBarDefaults.topAppBarColors(
|
|
||||||
containerColor = NavigationBarDefaults.containerColor,
|
|
||||||
),
|
|
||||||
title = {
|
|
||||||
Text(
|
|
||||||
text = stringResource(R.string.year_summary_title),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
actions = {
|
|
||||||
Box {
|
|
||||||
val expanded = remember { mutableStateOf(false) }
|
|
||||||
IconButton(
|
|
||||||
onClick = { expanded.value = true },
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Default.Info,
|
|
||||||
contentDescription = null,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
DropdownMenu(
|
|
||||||
expanded = expanded.value,
|
|
||||||
onDismissRequest = { expanded.value = false }
|
|
||||||
) {
|
|
||||||
Legend(
|
|
||||||
modifier = Modifier.padding(horizontal = 12.dp, vertical = 4.dp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
content = { it ->
|
|
||||||
LazyColumn(
|
|
||||||
modifier = Modifier.padding(paddingValues = it),
|
|
||||||
state = state,
|
|
||||||
flingBehavior = flingBehavior,
|
|
||||||
contentPadding = paddingValues,
|
|
||||||
verticalArrangement = Arrangement.spacedBy(space = contentSpace),
|
|
||||||
) {
|
|
||||||
items(
|
|
||||||
items = events.value
|
|
||||||
) { item ->
|
|
||||||
ReportBox(
|
|
||||||
barSize = barSize,
|
|
||||||
barSpace = barSpace,
|
|
||||||
item = item,
|
|
||||||
onMonth = onMonth,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun Legend(
|
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
) {
|
|
||||||
Column(
|
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
|
state = state,
|
||||||
|
flingBehavior = flingBehavior,
|
||||||
|
contentPadding = paddingValues,
|
||||||
|
verticalArrangement = Arrangement.spacedBy(space = contentSpace),
|
||||||
) {
|
) {
|
||||||
Row(
|
items(
|
||||||
horizontalArrangement = Arrangement.spacedBy(space = 4.dp),
|
items = events.value
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
) { item ->
|
||||||
) {
|
ReportBox(
|
||||||
Box(
|
barSize = barSize,
|
||||||
modifier = Modifier
|
barSpace = barSpace,
|
||||||
.size(8.dp)
|
item = item,
|
||||||
.background(
|
onMonth = onMonth,
|
||||||
color = HeadacheColorPalette.Calendar.Headache,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
Text(
|
|
||||||
style = MaterialTheme.typography.labelSmall,
|
|
||||||
text = "Jours de migraine",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Row(
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(space = 4.dp),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
) {
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.size(8.dp)
|
|
||||||
.background(
|
|
||||||
color = HeadacheColorPalette.Calendar.Pill,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
Text(
|
|
||||||
style = MaterialTheme.typography.labelSmall,
|
|
||||||
text = "Prise de cachet",
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import androidx.compose.foundation.gestures.snapping.SnapPosition
|
||||||
import androidx.compose.foundation.gestures.snapping.rememberSnapFlingBehavior
|
import androidx.compose.foundation.gestures.snapping.rememberSnapFlingBehavior
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.lazy.grid.GridCells
|
import androidx.compose.foundation.lazy.grid.GridCells
|
||||||
|
|
@ -16,12 +15,8 @@ import androidx.compose.foundation.lazy.grid.items
|
||||||
import androidx.compose.foundation.lazy.grid.rememberLazyGridState
|
import androidx.compose.foundation.lazy.grid.rememberLazyGridState
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.NavigationBarDefaults
|
|
||||||
import androidx.compose.material3.Scaffold
|
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TopAppBar
|
|
||||||
import androidx.compose.material3.TopAppBarDefaults
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import androidx.compose.runtime.State
|
import androidx.compose.runtime.State
|
||||||
|
|
@ -31,7 +26,6 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.keepScreenOn
|
import androidx.compose.ui.keepScreenOn
|
||||||
import androidx.compose.ui.platform.LocalDensity
|
import androidx.compose.ui.platform.LocalDensity
|
||||||
import androidx.compose.ui.platform.LocalWindowInfo
|
import androidx.compose.ui.platform.LocalWindowInfo
|
||||||
import androidx.compose.ui.res.stringResource
|
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||||
|
|
@ -39,7 +33,6 @@ import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
import androidx.hilt.navigation.compose.hiltViewModel
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.pixelized.headache.R
|
|
||||||
import com.pixelized.headache.ui.navigation.destination.navigateToEventPage
|
import com.pixelized.headache.ui.navigation.destination.navigateToEventPage
|
||||||
import com.pixelized.headache.ui.navigation.main.LocalMainNavigator
|
import com.pixelized.headache.ui.navigation.main.LocalMainNavigator
|
||||||
import com.pixelized.headache.ui.theme.HeadacheTheme
|
import com.pixelized.headache.ui.theme.HeadacheTheme
|
||||||
|
|
@ -103,65 +96,49 @@ fun YearSummaryContent(
|
||||||
uio: State<List<YearUio>>,
|
uio: State<List<YearUio>>,
|
||||||
onMonth: (YearSummaryMonthUio) -> Unit,
|
onMonth: (YearSummaryMonthUio) -> Unit,
|
||||||
) {
|
) {
|
||||||
Scaffold(
|
val typography = MaterialTheme.typography
|
||||||
|
val colorScheme = MaterialTheme.headache.colorScheme
|
||||||
|
val defaultTextStyle = remember(typography, colorScheme) {
|
||||||
|
typography.labelSmall.copy(color = colorScheme.base.onSurface)
|
||||||
|
}
|
||||||
|
val headacheTextStyle = remember(typography, colorScheme) {
|
||||||
|
defaultTextStyle.copy(color = colorScheme.calendar.onHeadache)
|
||||||
|
}
|
||||||
|
LazyVerticalGrid(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
contentWindowInsets = remember { WindowInsets(0, 0, 0, 0) },
|
state = state,
|
||||||
topBar = {
|
flingBehavior = flingBehavior,
|
||||||
TopAppBar(
|
columns = GridCells.Adaptive(minSize = daySize * 7),
|
||||||
colors = TopAppBarDefaults.topAppBarColors(
|
horizontalArrangement = Arrangement.spacedBy(space = space),
|
||||||
containerColor = NavigationBarDefaults.containerColor,
|
verticalArrangement = Arrangement.spacedBy(space = space),
|
||||||
),
|
contentPadding = paddingValues,
|
||||||
title = {
|
) {
|
||||||
Text(text = stringResource(R.string.year_summary_title))
|
uio.value.forEachIndexed { index, (year, months) ->
|
||||||
},
|
item(
|
||||||
)
|
span = { GridItemSpan(maxLineSpan) },
|
||||||
},
|
contentType = { "Title" },
|
||||||
content = { it ->
|
|
||||||
val typography = MaterialTheme.typography
|
|
||||||
val colorScheme = MaterialTheme.headache.colorScheme
|
|
||||||
val defaultTextStyle = remember(typography, colorScheme) {
|
|
||||||
typography.labelSmall.copy(color = colorScheme.base.onSurface)
|
|
||||||
}
|
|
||||||
val headacheTextStyle = remember(typography, colorScheme) {
|
|
||||||
defaultTextStyle.copy(color = colorScheme.calendar.onHeadache)
|
|
||||||
}
|
|
||||||
LazyVerticalGrid(
|
|
||||||
modifier = Modifier.padding(paddingValues = it),
|
|
||||||
state = state,
|
|
||||||
flingBehavior = flingBehavior,
|
|
||||||
columns = GridCells.Adaptive(minSize = daySize * 7),
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(space = space),
|
|
||||||
verticalArrangement = Arrangement.spacedBy(space = space),
|
|
||||||
contentPadding = paddingValues,
|
|
||||||
) {
|
) {
|
||||||
uio.value.forEachIndexed { index, (year, months) ->
|
Text(
|
||||||
item(
|
modifier = Modifier.padding(top = 16.dp),
|
||||||
span = { GridItemSpan(maxLineSpan) },
|
style = MaterialTheme.typography.displaySmall,
|
||||||
contentType = { "Title" },
|
text = "$year",
|
||||||
) {
|
)
|
||||||
Text(
|
}
|
||||||
modifier = Modifier.padding(top = 16.dp),
|
items(
|
||||||
style = MaterialTheme.typography.displaySmall,
|
items = months,
|
||||||
text = "$year",
|
key = { it.date.time },
|
||||||
)
|
contentType = { "Month" },
|
||||||
}
|
) {
|
||||||
items(
|
YearSummaryMonth(
|
||||||
items = months,
|
uio = it,
|
||||||
key = { it.date.time },
|
defaultTextStyle = defaultTextStyle,
|
||||||
contentType = { "Month" },
|
headacheTextStyle = headacheTextStyle,
|
||||||
) {
|
daySize = daySize,
|
||||||
YearSummaryMonth(
|
onMonth = onMonth,
|
||||||
uio = it,
|
)
|
||||||
defaultTextStyle = defaultTextStyle,
|
|
||||||
headacheTextStyle = headacheTextStyle,
|
|
||||||
daySize = daySize,
|
|
||||||
onMonth = onMonth,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue