mirror of
https://github.com/mihonapp/mihon.git
synced 2025-08-25 15:41:32 +02:00
Compare commits
3 Commits
d4a8c2328a
...
248eeb8e5a
Author | SHA1 | Date | |
---|---|---|---|
|
248eeb8e5a | ||
|
6003b9ca06 | ||
|
202e156546 |
@@ -40,7 +40,6 @@ fun UpcomingItem(
|
||||
modifier = Modifier.fillMaxHeight(),
|
||||
data = upcoming.asMangaCover(),
|
||||
)
|
||||
|
||||
Text(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
|
@@ -48,18 +48,23 @@ fun UpdateUpcomingScreen(
|
||||
state: UpdateUpcomingScreenModel.State,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
if (isTabletUi()) {
|
||||
UpdateUpcomingScreenLargeImpl(
|
||||
state = state,
|
||||
modifier = modifier,
|
||||
onClickUpcoming = onClickUpcoming,
|
||||
)
|
||||
} else {
|
||||
UpdateUpcomingScreenSmallImpl(
|
||||
state = state,
|
||||
modifier = modifier,
|
||||
onClickUpcoming = onClickUpcoming,
|
||||
)
|
||||
Scaffold(
|
||||
topBar = { UpdateUpcomingToolbar() },
|
||||
modifier = modifier,
|
||||
) { paddingValues ->
|
||||
if (isTabletUi()) {
|
||||
UpdateUpcomingScreenLargeImpl(
|
||||
onClickUpcoming = onClickUpcoming,
|
||||
paddingValues = paddingValues,
|
||||
state = state,
|
||||
)
|
||||
} else {
|
||||
UpdateUpcomingScreenSmallImpl(
|
||||
onClickUpcoming = onClickUpcoming,
|
||||
paddingValues = paddingValues,
|
||||
state = state,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,19 +72,14 @@ fun UpdateUpcomingScreen(
|
||||
internal fun UpdateUpcomingScreenSmallImpl(
|
||||
onClickUpcoming: (manga: Manga) -> Unit,
|
||||
state: UpdateUpcomingScreenModel.State,
|
||||
modifier: Modifier = Modifier,
|
||||
paddingValues: PaddingValues,
|
||||
) {
|
||||
Scaffold(
|
||||
modifier = modifier,
|
||||
topBar = { UpdateUpcomingToolbar() },
|
||||
) { paddingValues ->
|
||||
UpdateUpcomingSmallContent(
|
||||
upcoming = state.items,
|
||||
events = state.events,
|
||||
contentPadding = paddingValues,
|
||||
onClickUpcoming = onClickUpcoming,
|
||||
)
|
||||
}
|
||||
UpdateUpcomingSmallContent(
|
||||
upcoming = state.items,
|
||||
events = state.events,
|
||||
contentPadding = paddingValues,
|
||||
onClickUpcoming = onClickUpcoming,
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -177,40 +177,35 @@ internal fun UpdateUpcomingSmallContent(
|
||||
|
||||
@Composable
|
||||
internal fun UpdateUpcomingScreenLargeImpl(
|
||||
onClickUpcoming: (manga: Manga) -> Unit,
|
||||
paddingValues: PaddingValues,
|
||||
state: UpdateUpcomingScreenModel.State,
|
||||
modifier: Modifier = Modifier,
|
||||
onClickUpcoming: (manga: Manga) -> Unit = {},
|
||||
) {
|
||||
val layoutDirection = LocalLayoutDirection.current
|
||||
val listState = rememberLazyListState()
|
||||
|
||||
Scaffold(
|
||||
modifier = modifier,
|
||||
topBar = { UpdateUpcomingToolbar() },
|
||||
) { contentPadding ->
|
||||
TwoPanelBox(
|
||||
modifier = Modifier.padding(
|
||||
start = contentPadding.calculateStartPadding(layoutDirection),
|
||||
end = contentPadding.calculateEndPadding(layoutDirection),
|
||||
),
|
||||
startContent = {
|
||||
UpdateUpcomingLargeCalendar(
|
||||
upcoming = state.items,
|
||||
listState = listState,
|
||||
events = state.events,
|
||||
modifier = Modifier.padding(contentPadding),
|
||||
)
|
||||
},
|
||||
endContent = {
|
||||
UpdateUpcomingLargeContent(
|
||||
upcoming = state.items,
|
||||
listState = listState,
|
||||
contentPadding = contentPadding,
|
||||
onClickUpcoming = onClickUpcoming,
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
TwoPanelBox(
|
||||
modifier = Modifier.padding(
|
||||
start = paddingValues.calculateStartPadding(layoutDirection),
|
||||
end = paddingValues.calculateEndPadding(layoutDirection),
|
||||
),
|
||||
startContent = {
|
||||
UpdateUpcomingLargeCalendar(
|
||||
upcoming = state.items,
|
||||
listState = listState,
|
||||
events = state.events,
|
||||
modifier = Modifier.padding(paddingValues),
|
||||
)
|
||||
},
|
||||
endContent = {
|
||||
UpdateUpcomingLargeContent(
|
||||
upcoming = state.items,
|
||||
listState = listState,
|
||||
contentPadding = paddingValues,
|
||||
onClickUpcoming = onClickUpcoming,
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
@@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.wrapContentHeight
|
||||
import androidx.compose.foundation.lazy.grid.GridCells
|
||||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||
import androidx.compose.foundation.lazy.grid.items
|
||||
@@ -75,7 +74,6 @@ fun Calendar(
|
||||
|
||||
Column(
|
||||
modifier = modifier
|
||||
.wrapContentHeight()
|
||||
.fillMaxWidth()
|
||||
.padding(MaterialTheme.padding.small),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
@@ -114,7 +112,7 @@ private fun CalendarGrid(
|
||||
onClickDay: (day: LocalDate) -> Unit = {},
|
||||
widthModifier: Float = 1.0F,
|
||||
) {
|
||||
val daysInMonth = currentYearMonth.month.length(currentYearMonth.isLeapYear)
|
||||
val daysInMonth = currentYearMonth.lengthOfMonth()
|
||||
val startDayOfMonth = currentYearMonth.atDay(1)
|
||||
val firstDayOfMonth = startDayOfMonth.dayOfWeek
|
||||
|
||||
@@ -125,7 +123,6 @@ private fun CalendarGrid(
|
||||
val modeModifier = if (isTabletUi) {
|
||||
modifier
|
||||
.fillMaxWidth(widthModifier)
|
||||
.wrapContentHeight()
|
||||
} else {
|
||||
modifier
|
||||
.fillMaxWidth(widthModifier)
|
||||
|
@@ -4,11 +4,10 @@ import androidx.compose.foundation.BorderStroke
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.defaultMinSize
|
||||
import androidx.compose.foundation.layout.wrapContentSize
|
||||
import androidx.compose.foundation.layout.offset
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
@@ -36,68 +35,50 @@ fun CalendarDay(
|
||||
) {
|
||||
val today = remember { LocalDate.now() }
|
||||
|
||||
val inThePast = date.isBefore(today)
|
||||
|
||||
val currentDay = today == date
|
||||
|
||||
Column(
|
||||
Box(
|
||||
modifier = modifier
|
||||
.border(
|
||||
border = getBorder(currentDay, MaterialTheme.colorScheme.onBackground),
|
||||
shape = CircleShape,
|
||||
.then(
|
||||
if (today == date) {
|
||||
Modifier.border(
|
||||
border = BorderStroke(1.dp, MaterialTheme.colorScheme.onBackground),
|
||||
shape = CircleShape,
|
||||
)
|
||||
} else {
|
||||
Modifier
|
||||
},
|
||||
)
|
||||
.background(Color.Transparent)
|
||||
.clip(shape = CircleShape)
|
||||
.background(color = Color.Transparent)
|
||||
.clickable(onClick = onDayClick)
|
||||
.circleLayout()
|
||||
.wrapContentSize()
|
||||
.defaultMinSize(56.dp),
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Text(
|
||||
text = date.dayOfMonth.toString(),
|
||||
modifier = Modifier.wrapContentSize(),
|
||||
textAlign = TextAlign.Center,
|
||||
fontSize = 16.sp,
|
||||
color = when {
|
||||
inThePast -> MaterialTheme.colorScheme.onBackground.copy(alpha = 0.38f)
|
||||
date.isBefore(today) -> MaterialTheme.colorScheme.onBackground.copy(alpha = 0.38f)
|
||||
else -> MaterialTheme.colorScheme.onBackground
|
||||
},
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
)
|
||||
Row {
|
||||
Row(
|
||||
modifier = Modifier.offset(y = 12.dp),
|
||||
) {
|
||||
val size = events.coerceAtMost(MaxEvents)
|
||||
for (index in 0 until size) {
|
||||
Row {
|
||||
CalendarIndicator(
|
||||
index = index,
|
||||
size = 56.dp,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
}
|
||||
CalendarIndicator(
|
||||
index = index,
|
||||
size = 56.dp,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the border stroke based on the current day, color, and selected state.
|
||||
*
|
||||
* @param currentDay Whether the day is the current day.
|
||||
* @param color The color of the border.
|
||||
*
|
||||
* @return The border stroke to be applied.
|
||||
*/
|
||||
private fun getBorder(currentDay: Boolean, color: Color): BorderStroke {
|
||||
val emptyBorder = BorderStroke(0.dp, Color.Transparent)
|
||||
return if (currentDay) {
|
||||
BorderStroke(1.dp, color)
|
||||
} else {
|
||||
emptyBorder
|
||||
}
|
||||
}
|
||||
|
||||
private fun Modifier.circleLayout() = layout { measurable, constraints ->
|
||||
// Measure the composable
|
||||
val placeable = measurable.measure(constraints)
|
||||
|
@@ -43,7 +43,7 @@ fun CalenderHeader(
|
||||
Row(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.padding(MaterialTheme.padding.medium, MaterialTheme.padding.small),
|
||||
.padding(horizontal = MaterialTheme.padding.medium, vertical = MaterialTheme.padding.small),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
@@ -58,15 +58,10 @@ fun CalenderHeader(
|
||||
)
|
||||
}
|
||||
Row {
|
||||
IconButton(
|
||||
onClick = onPreviousClick,
|
||||
) {
|
||||
IconButton(onClick = onPreviousClick) {
|
||||
Icon(Icons.Default.KeyboardArrowLeft, stringResource(MR.strings.upcoming_calendar_prev))
|
||||
}
|
||||
|
||||
IconButton(
|
||||
onClick = onNextClick,
|
||||
) {
|
||||
IconButton(onClick = onNextClick) {
|
||||
Icon(Icons.Default.KeyboardArrowRight, stringResource(MR.strings.upcoming_calendar_next))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user