Change the Scaffold hierarchy
This commit is contained in:
parent
1bbd523e88
commit
d91dda3013
10 changed files with 225 additions and 1451 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.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.NavigationBarDefaults
|
||||
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.State
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
|
|
@ -64,6 +66,9 @@ private fun CalendarContent(
|
|||
modifier = modifier,
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = NavigationBarDefaults.containerColor,
|
||||
),
|
||||
navigationIcon = {
|
||||
IconButton(
|
||||
onClick = onBack,
|
||||
|
|
|
|||
|
|
@ -16,15 +16,18 @@ import androidx.compose.foundation.shape.CircleShape
|
|||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material.icons.outlined.Info
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.FloatingActionButton
|
||||
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.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Stable
|
||||
import androidx.compose.runtime.State
|
||||
|
|
@ -105,6 +108,9 @@ private fun EventContent(
|
|||
modifier = modifier,
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = NavigationBarDefaults.containerColor,
|
||||
),
|
||||
navigationIcon = {
|
||||
IconButton(
|
||||
onClick = onBack,
|
||||
|
|
@ -147,7 +153,7 @@ private fun EventContent(
|
|||
}
|
||||
)
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_error_24px),
|
||||
imageVector = Icons.Outlined.Info,
|
||||
tint = color.value,
|
||||
contentDescription = null,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,38 +1,46 @@
|
|||
package com.pixelized.headache.ui.page.home
|
||||
|
||||
import androidx.compose.animation.AnimatedContent
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.togetherWith
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.background
|
||||
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.WindowInsets
|
||||
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.size
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
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.Info
|
||||
import androidx.compose.material.icons.outlined.Info
|
||||
import androidx.compose.material3.DropdownMenu
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.FloatingActionButton
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.NavigationBar
|
||||
import androidx.compose.material3.NavigationBarDefaults
|
||||
import androidx.compose.material3.NavigationBarItem
|
||||
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.Stable
|
||||
import androidx.compose.runtime.State
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
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.hilt.navigation.compose.hiltViewModel
|
||||
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.page.event.edit.EventEditBottomSheet
|
||||
import com.pixelized.headache.ui.page.event.edit.EventEditBottomSheetViewModel
|
||||
|
||||
import com.pixelized.headache.ui.theme.color.HeadacheColorPalette
|
||||
|
||||
@Stable
|
||||
data class BottomBarItemUio(
|
||||
|
|
@ -61,17 +69,7 @@ fun HomePage(
|
|||
navigator: HomeNavigator,
|
||||
editViewModel: EventEditBottomSheetViewModel = hiltViewModel(),
|
||||
) {
|
||||
val selectedItem = remember {
|
||||
derivedStateOf {
|
||||
when (navigator.backStack.last()) {
|
||||
is YearSummaryDestination -> 0
|
||||
is ReportDestination -> 1
|
||||
is MonthSummaryDestination -> 2
|
||||
else -> -1
|
||||
}
|
||||
}
|
||||
}
|
||||
val items = rememberBottomBarItems(
|
||||
val bottomBarItems = rememberBottomBarItems(
|
||||
onYearlyFollowUp = {
|
||||
navigator.navigateToYearSummary()
|
||||
},
|
||||
|
|
@ -82,12 +80,41 @@ fun HomePage(
|
|||
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(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
navigator = navigator,
|
||||
items = items,
|
||||
displayLegendAction = displayLegendAction,
|
||||
displayLegendPopup = displayLegendPopup,
|
||||
items = bottomBarItems,
|
||||
selectedItem = selectedItem,
|
||||
onDisplayLegend = {
|
||||
displayLegendPopup.value = true
|
||||
},
|
||||
onDismissLegend = {
|
||||
displayLegendPopup.value = false
|
||||
},
|
||||
onFabClick = {
|
||||
editViewModel.show()
|
||||
},
|
||||
|
|
@ -129,13 +156,58 @@ private fun rememberBottomBarItems(
|
|||
private fun HomePageContent(
|
||||
modifier: Modifier = Modifier,
|
||||
navigator: HomeNavigator,
|
||||
displayLegendAction: State<Boolean>,
|
||||
displayLegendPopup: State<Boolean>,
|
||||
items: List<BottomBarItemUio>,
|
||||
selectedItem: State<Int>,
|
||||
onDisplayLegend: () -> Unit,
|
||||
onDismissLegend: () -> Unit,
|
||||
onFabClick: () -> Unit,
|
||||
) {
|
||||
Scaffold(
|
||||
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,
|
||||
) {
|
||||
AnimatedContent(
|
||||
targetState = displayLegendPopup.value,
|
||||
transitionSpec = { fadeIn() togetherWith fadeOut() },
|
||||
) { display ->
|
||||
IconButton(
|
||||
onClick = onDisplayLegend,
|
||||
) {
|
||||
Icon(
|
||||
imageVector = when (display) {
|
||||
true -> Icons.Filled.Info
|
||||
else -> Icons.Outlined.Info
|
||||
},
|
||||
contentDescription = null,
|
||||
)
|
||||
}
|
||||
}
|
||||
DropdownMenu(
|
||||
expanded = displayLegendPopup.value,
|
||||
onDismissRequest = onDismissLegend,
|
||||
) {
|
||||
LegendPopupContent(
|
||||
modifier = Modifier.padding(horizontal = 12.dp, vertical = 4.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
},
|
||||
bottomBar = {
|
||||
NavigationBar {
|
||||
items.forEachIndexed { index, item ->
|
||||
|
|
@ -183,40 +255,44 @@ private fun HomePageContent(
|
|||
)
|
||||
}
|
||||
|
||||
@Stable
|
||||
data object NavigationItemDefault {
|
||||
@Stable
|
||||
val minHeight: Dp = 56.dp
|
||||
|
||||
@Stable
|
||||
val padding = PaddingValues(horizontal = 16.dp)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun NavigationItem(
|
||||
private fun LegendPopupContent(
|
||||
modifier: Modifier = Modifier,
|
||||
padding: PaddingValues = NavigationItemDefault.padding,
|
||||
minHeight: Dp = NavigationItemDefault.minHeight,
|
||||
label: String,
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.clickable(onClick = onClick)
|
||||
.fillMaxWidth()
|
||||
.heightIn(min = minHeight)
|
||||
.padding(paddingValues = padding)
|
||||
.then(other = modifier),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
Column(
|
||||
modifier = modifier,
|
||||
) {
|
||||
Text(
|
||||
modifier = Modifier.weight(1f),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
text = label,
|
||||
)
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Filled.KeyboardArrowRight,
|
||||
contentDescription = null,
|
||||
)
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(space = 4.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(8.dp)
|
||||
.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.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
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.rememberLazyListState
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.NavigationBarDefaults
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Stable
|
||||
import androidx.compose.runtime.State
|
||||
|
|
@ -26,7 +21,6 @@ import androidx.compose.runtime.mutableStateOf
|
|||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.keepScreenOn
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
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.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.pixelized.headache.R
|
||||
import com.pixelized.headache.ui.navigation.destination.navigateToEventPage
|
||||
import com.pixelized.headache.ui.navigation.main.LocalMainNavigator
|
||||
import com.pixelized.headache.ui.page.summary.monthly.item.MonthSummaryItem
|
||||
|
|
@ -89,50 +82,32 @@ private fun MonthSummaryContent(
|
|||
events: State<Map<MonthSummaryTitleUio, List<MonthSummaryItemUio>>>,
|
||||
onItem: (MonthSummaryItemUio) -> 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.month_summary_title))
|
||||
},
|
||||
)
|
||||
},
|
||||
content = { paddingValues ->
|
||||
LazyColumn(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(paddingValues = paddingValues),
|
||||
state = state,
|
||||
flingBehavior = flingBehavior,
|
||||
contentPadding = listPadding,
|
||||
verticalArrangement = Arrangement.spacedBy(space = spacing),
|
||||
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,
|
||||
)
|
||||
}
|
||||
}
|
||||
state = state,
|
||||
flingBehavior = flingBehavior,
|
||||
contentPadding = listPadding,
|
||||
verticalArrangement = Arrangement.spacedBy(space = spacing),
|
||||
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
|
||||
|
|
@ -141,11 +116,14 @@ private fun MonthSummaryPreview(
|
|||
@PreviewParameter(MonthSummaryPreviewProvider::class) preview: Map<MonthSummaryTitleUio, List<MonthSummaryItemUio>>,
|
||||
) {
|
||||
HeadacheTheme {
|
||||
val events = remember { mutableStateOf(preview) }
|
||||
MonthSummaryContent(
|
||||
events = events,
|
||||
onItem = { },
|
||||
)
|
||||
Surface {
|
||||
val events = remember { mutableStateOf(preview) }
|
||||
MonthSummaryContent(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
events = events,
|
||||
onItem = { },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,47 +2,27 @@ package com.pixelized.headache.ui.page.summary.report
|
|||
|
||||
|
||||
import android.icu.util.Calendar
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.gestures.FlingBehavior
|
||||
import androidx.compose.foundation.gestures.snapping.SnapPosition
|
||||
import androidx.compose.foundation.gestures.snapping.rememberSnapFlingBehavior
|
||||
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.Row
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
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.LazyListState
|
||||
import androidx.compose.foundation.lazy.items
|
||||
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.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.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Stable
|
||||
import androidx.compose.runtime.State
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.keepScreenOn
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
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.PreviewParameter
|
||||
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.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.pixelized.headache.R
|
||||
import com.pixelized.headache.ui.navigation.destination.navigateToEventPage
|
||||
import com.pixelized.headache.ui.navigation.main.LocalMainNavigator
|
||||
import com.pixelized.headache.ui.theme.HeadacheTheme
|
||||
import com.pixelized.headache.ui.theme.color.HeadacheColorPalette
|
||||
import com.pixelized.headache.utils.extention.calculate
|
||||
|
||||
@Stable
|
||||
|
|
@ -108,102 +86,21 @@ private fun ReportContent(
|
|||
events: State<List<ReportBoxUio>>,
|
||||
onMonth: (ReportBoxUio.Month) -> Unit,
|
||||
) {
|
||||
Scaffold(
|
||||
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(
|
||||
LazyColumn(
|
||||
modifier = modifier,
|
||||
state = state,
|
||||
flingBehavior = flingBehavior,
|
||||
contentPadding = paddingValues,
|
||||
verticalArrangement = Arrangement.spacedBy(space = contentSpace),
|
||||
) {
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(space = 4.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(8.dp)
|
||||
.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",
|
||||
items(
|
||||
items = events.value
|
||||
) { item ->
|
||||
ReportBox(
|
||||
barSize = barSize,
|
||||
barSpace = barSpace,
|
||||
item = item,
|
||||
onMonth = onMonth,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import androidx.compose.foundation.gestures.snapping.SnapPosition
|
|||
import androidx.compose.foundation.gestures.snapping.rememberSnapFlingBehavior
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
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.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.NavigationBarDefaults
|
||||
import androidx.compose.material3.Scaffold
|
||||
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.Stable
|
||||
import androidx.compose.runtime.State
|
||||
|
|
@ -31,7 +26,6 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.keepScreenOn
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
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.PreviewParameter
|
||||
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.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.pixelized.headache.R
|
||||
import com.pixelized.headache.ui.navigation.destination.navigateToEventPage
|
||||
import com.pixelized.headache.ui.navigation.main.LocalMainNavigator
|
||||
import com.pixelized.headache.ui.theme.HeadacheTheme
|
||||
|
|
@ -103,65 +96,49 @@ fun YearSummaryContent(
|
|||
uio: State<List<YearUio>>,
|
||||
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,
|
||||
contentWindowInsets = remember { WindowInsets(0, 0, 0, 0) },
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = NavigationBarDefaults.containerColor,
|
||||
),
|
||||
title = {
|
||||
Text(text = stringResource(R.string.year_summary_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,
|
||||
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) ->
|
||||
item(
|
||||
span = { GridItemSpan(maxLineSpan) },
|
||||
contentType = { "Title" },
|
||||
) {
|
||||
uio.value.forEachIndexed { index, (year, months) ->
|
||||
item(
|
||||
span = { GridItemSpan(maxLineSpan) },
|
||||
contentType = { "Title" },
|
||||
) {
|
||||
Text(
|
||||
modifier = Modifier.padding(top = 16.dp),
|
||||
style = MaterialTheme.typography.displaySmall,
|
||||
text = "$year",
|
||||
)
|
||||
}
|
||||
items(
|
||||
items = months,
|
||||
key = { it.date.time },
|
||||
contentType = { "Month" },
|
||||
) {
|
||||
YearSummaryMonth(
|
||||
uio = it,
|
||||
defaultTextStyle = defaultTextStyle,
|
||||
headacheTextStyle = headacheTextStyle,
|
||||
daySize = daySize,
|
||||
onMonth = onMonth,
|
||||
)
|
||||
}
|
||||
}
|
||||
Text(
|
||||
modifier = Modifier.padding(top = 16.dp),
|
||||
style = MaterialTheme.typography.displaySmall,
|
||||
text = "$year",
|
||||
)
|
||||
}
|
||||
items(
|
||||
items = months,
|
||||
key = { it.date.time },
|
||||
contentType = { "Month" },
|
||||
) {
|
||||
YearSummaryMonth(
|
||||
uio = it,
|
||||
defaultTextStyle = defaultTextStyle,
|
||||
headacheTextStyle = headacheTextStyle,
|
||||
daySize = daySize,
|
||||
onMonth = onMonth,
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M480,680Q497,680 508.5,668.5Q520,657 520,640Q520,623 508.5,611.5Q497,600 480,600Q463,600 451.5,611.5Q440,623 440,640Q440,657 451.5,668.5Q463,680 480,680ZM440,520L520,520L520,280L440,280L440,520ZM480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480Q80,397 111.5,324Q143,251 197,197Q251,143 324,111.5Q397,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,563 848.5,636Q817,709 763,763Q709,817 636,848.5Q563,880 480,880ZM480,800Q614,800 707,707Q800,614 800,480Q800,346 707,253Q614,160 480,160Q346,160 253,253Q160,346 160,480Q160,614 253,707Q346,800 480,800ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Z" />
|
||||
</vector>
|
||||
Loading…
Add table
Add a link
Reference in a new issue