This, but better v
This commit is contained in:
parent
dd09487729
commit
7ee5bd5c61
@ -4,6 +4,7 @@ import android.content.Context
|
|||||||
import android.text.format.DateUtils
|
import android.text.format.DateUtils
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.compose.animation.AnimatedContent
|
import androidx.compose.animation.AnimatedContent
|
||||||
|
import androidx.compose.animation.animateContentSize
|
||||||
import androidx.compose.animation.fadeIn
|
import androidx.compose.animation.fadeIn
|
||||||
import androidx.compose.animation.fadeOut
|
import androidx.compose.animation.fadeOut
|
||||||
import androidx.compose.animation.slideIn
|
import androidx.compose.animation.slideIn
|
||||||
@ -129,14 +130,14 @@ fun CalendarWidget(
|
|||||||
val hasPermission by viewModel.hasPermission.collectAsState()
|
val hasPermission by viewModel.hasPermission.collectAsState()
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(horizontal = 12.dp)
|
.animateContentSize()
|
||||||
.padding(bottom = 12.dp)
|
|
||||||
) {
|
) {
|
||||||
if (hasPermission == false) {
|
if (hasPermission == false) {
|
||||||
MissingPermissionBanner(
|
MissingPermissionBanner(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(4.dp),
|
.padding(4.dp)
|
||||||
|
.padding(horizontal = 12.dp),
|
||||||
text = stringResource(R.string.missing_permission_calendar_widget),
|
text = stringResource(R.string.missing_permission_calendar_widget),
|
||||||
onClick = { viewModel.requestCalendarPermission(context as AppCompatActivity) }
|
onClick = { viewModel.requestCalendarPermission(context as AppCompatActivity) }
|
||||||
)
|
)
|
||||||
@ -151,17 +152,42 @@ fun CalendarWidget(
|
|||||||
when {
|
when {
|
||||||
initialState.first == targetState.first -> fadeIn() togetherWith fadeOut()
|
initialState.first == targetState.first -> fadeIn() togetherWith fadeOut()
|
||||||
initialState.first < targetState.first -> {
|
initialState.first < targetState.first -> {
|
||||||
fadeIn() + slideIn { IntOffset((it.width * 0.25f).toInt(), 0) } togetherWith
|
fadeIn() + slideIn {
|
||||||
fadeOut() + slideOut { IntOffset((it.width * -0.25f).toInt(), 0) }
|
IntOffset(
|
||||||
|
(it.width * 0.25f).toInt(),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
} togetherWith
|
||||||
|
fadeOut() + slideOut {
|
||||||
|
IntOffset(
|
||||||
|
(it.width * -0.25f).toInt(),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
fadeIn() + slideIn { IntOffset((it.width * -0.25f).toInt(), 0) } togetherWith
|
fadeIn() + slideIn {
|
||||||
fadeOut() + slideOut { IntOffset((it.width * 0.25f).toInt(), 0) }
|
IntOffset(
|
||||||
|
(it.width * -0.25f).toInt(),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
} togetherWith
|
||||||
|
fadeOut() + slideOut {
|
||||||
|
IntOffset(
|
||||||
|
(it.width * 0.25f).toInt(),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
) { (_, events, runningEvents) ->
|
) { (_, events, runningEvents) ->
|
||||||
Column {
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(horizontal = 12.dp)
|
||||||
|
.padding(bottom = 12.dp)
|
||||||
|
) {
|
||||||
if (events.isEmpty() && hasPermission == true) {
|
if (events.isEmpty() && hasPermission == true) {
|
||||||
Info(text = stringResource(R.string.calendar_widget_no_events))
|
Info(text = stringResource(R.string.calendar_widget_no_events))
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user