Skip to content

Commit

Permalink
v.0.12.2
Browse files Browse the repository at this point in the history
- animates start/stop buttons
- improves calendar for tablets
  • Loading branch information
pabloscloud committed Nov 25, 2023
1 parent 80aa05e commit bb4109e
Show file tree
Hide file tree
Showing 11 changed files with 179 additions and 61 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId = "cloud.pablos.overload"
minSdk = 26
targetSdk = 34
versionCode = 121
versionName = "0.12.1"
versionCode = 122
versionName = "0.12.2"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 121,
"versionName": "0.12.1",
"versionCode": 122,
"versionName": "0.12.2",
"outputFile": "app-release.apk"
}
],
Expand Down
33 changes: 31 additions & 2 deletions app/src/main/java/cloud/pablos/overload/ui/OverloadApp.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cloud.pablos.overload.ui

import android.os.Build
import android.util.Log
import androidx.annotation.RequiresApi
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.background
Expand Down Expand Up @@ -48,6 +49,7 @@ import cloud.pablos.overload.ui.tabs.calendar.CalendarTab
import cloud.pablos.overload.ui.tabs.configurations.ConfigurationsTab
import cloud.pablos.overload.ui.tabs.home.HomeTab
import cloud.pablos.overload.ui.utils.DevicePosture
import cloud.pablos.overload.ui.utils.OverloadContentType
import cloud.pablos.overload.ui.utils.OverloadNavigationContentPosition
import cloud.pablos.overload.ui.utils.OverloadNavigationType
import cloud.pablos.overload.ui.utils.isBookPosture
Expand All @@ -66,6 +68,7 @@ fun OverloadApp(
onEvent: (ItemEvent) -> Unit,
) {
val navigationType: OverloadNavigationType
val contentType: OverloadContentType

val foldingFeature = displayFeatures.filterIsInstance<FoldingFeature>().firstOrNull()

Expand All @@ -82,19 +85,29 @@ fun OverloadApp(
when (windowSize.widthSizeClass) {
WindowWidthSizeClass.Compact -> {
navigationType = OverloadNavigationType.BOTTOM_NAVIGATION
contentType = OverloadContentType.SINGLE_PANE
}
WindowWidthSizeClass.Medium -> {
navigationType = OverloadNavigationType.NAVIGATION_RAIL
contentType = if (foldingDevicePosture != DevicePosture.NormalPosture) {
OverloadContentType.DUAL_PANE
} else {
OverloadContentType.SINGLE_PANE
}

Log.d("ol_df", displayFeatures.toString())
}
WindowWidthSizeClass.Expanded -> {
navigationType = if (foldingDevicePosture is DevicePosture.BookPosture) {
OverloadNavigationType.NAVIGATION_RAIL
} else {
OverloadNavigationType.PERMANENT_NAVIGATION_DRAWER
}
contentType = OverloadContentType.DUAL_PANE
}
else -> {
navigationType = OverloadNavigationType.BOTTOM_NAVIGATION
contentType = OverloadContentType.SINGLE_PANE
}
}

Expand All @@ -114,6 +127,7 @@ fun OverloadApp(

OverloadNavigationWrapper(
navigationType = navigationType,
contentType = contentType,
navigationContentPosition = navigationContentPosition,
state = state,
onEvent = onEvent,
Expand All @@ -124,6 +138,7 @@ fun OverloadApp(
@Composable
private fun OverloadNavigationWrapper(
navigationType: OverloadNavigationType,
contentType: OverloadContentType,
navigationContentPosition: OverloadNavigationContentPosition,
state: ItemState,
onEvent: (ItemEvent) -> Unit,
Expand Down Expand Up @@ -152,6 +167,7 @@ private fun OverloadNavigationWrapper(
}) {
OverloadAppContent(
navigationType = navigationType,
contentType = contentType,
navigationContentPosition = navigationContentPosition,
navController = navController,
selectedDestination = selectedDestination,
Expand All @@ -165,6 +181,7 @@ private fun OverloadNavigationWrapper(
OverloadNavigationType.BOTTOM_NAVIGATION -> {
OverloadAppContent(
navigationType = navigationType,
contentType = contentType,
navigationContentPosition = navigationContentPosition,
navController = navController,
selectedDestination = selectedDestination,
Expand Down Expand Up @@ -198,6 +215,7 @@ private fun OverloadNavigationWrapper(
) {
OverloadAppContent(
navigationType = navigationType,
contentType = contentType,
navigationContentPosition = navigationContentPosition,
navController = navController,
selectedDestination = selectedDestination,
Expand All @@ -220,6 +238,7 @@ private fun OverloadNavigationWrapper(
fun OverloadAppContent(
modifier: Modifier = Modifier,
navigationType: OverloadNavigationType,
contentType: OverloadContentType,
navigationContentPosition: OverloadNavigationContentPosition,
navController: NavHostController,
selectedDestination: String,
Expand Down Expand Up @@ -261,6 +280,7 @@ fun OverloadAppContent(
) {
OverloadNavHost(
navigationType = navigationType,
contentType = contentType,
navController = navController,
state = state,
onEvent = onEvent,
Expand Down Expand Up @@ -315,6 +335,7 @@ fun OverloadAppContent(
@Composable
private fun OverloadNavHost(
navigationType: OverloadNavigationType,
contentType: OverloadContentType,
navController: NavHostController,
modifier: Modifier = Modifier,
state: ItemState,
Expand All @@ -326,10 +347,18 @@ private fun OverloadNavHost(
startDestination = OverloadRoute.HOME,
) {
composable(OverloadRoute.HOME) {
HomeTab(navigationType = navigationType, state = state, onEvent = onEvent)
HomeTab(
navigationType = navigationType,
state = state,
onEvent = onEvent,
)
}
composable(OverloadRoute.CALENDAR) {
CalendarTab(state = state, onEvent = onEvent)
CalendarTab(
contentType = contentType,
state = state,
onEvent = onEvent,
)
}
composable(OverloadRoute.CONFIGURATIONS) {
ConfigurationsTab(state = state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cloud.pablos.overload.ui.navigation

import android.os.Build
import androidx.annotation.RequiresApi
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -189,7 +190,7 @@ fun PermanentNavigationDrawerContent(
modifier = Modifier.padding(16.dp),
)

if (state.selectedDayCalendar == LocalDate.now().toString()) {
AnimatedVisibility(visible = state.selectedDayCalendar == LocalDate.now().toString()) {
OverloadNavigationFab(state = state, onEvent = onEvent)
}
}
Expand Down Expand Up @@ -276,7 +277,7 @@ fun ModalNavigationDrawerContent(
}
}

if (state.selectedDayCalendar == LocalDate.now().toString()) {
AnimatedVisibility(visible = state.selectedDayCalendar == LocalDate.now().toString()) {
OverloadNavigationFab(state = state, onEvent = onEvent)
}
}
Expand Down
129 changes: 101 additions & 28 deletions app/src/main/java/cloud/pablos/overload/ui/tabs/calendar/CalendarTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cloud.pablos.overload.ui.tabs.calendar

import android.os.Build
import androidx.annotation.RequiresApi
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.gestures.detectVerticalDragGestures
import androidx.compose.foundation.layout.Arrangement
Expand Down Expand Up @@ -38,9 +39,11 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import cloud.pablos.overload.data.item.ItemEvent
import cloud.pablos.overload.data.item.ItemState
import cloud.pablos.overload.ui.utils.OverloadContentType
import cloud.pablos.overload.ui.views.DayView
import cloud.pablos.overload.ui.views.TextView
import cloud.pablos.overload.ui.views.YearView
import cloud.pablos.overload.ui.views.getFormattedDate
import cloud.pablos.overload.ui.views.getLocalDate
import cloud.pablos.overload.ui.views.parseToLocalDateTime
import kotlinx.coroutines.launch
Expand All @@ -52,6 +55,7 @@ import java.time.temporal.ChronoUnit
@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
@Composable
fun CalendarTab(
contentType: OverloadContentType,
state: ItemState,
onEvent: (ItemEvent) -> Unit,
) {
Expand Down Expand Up @@ -118,39 +122,91 @@ fun CalendarTab(
) { paddingValues ->
Box(modifier = Modifier.fillMaxSize()) {
Column(modifier = Modifier.padding(paddingValues)) {
Surface(
tonalElevation = NavigationBarDefaults.Elevation,
color = MaterialTheme.colorScheme.background,
) {
WeekDaysHeader()
AnimatedVisibility(visible = contentType == OverloadContentType.DUAL_PANE) {
Row(modifier = Modifier.fillMaxSize()) {
Box(
modifier = Modifier.weight(1f),
) {
Column {
Surface(
tonalElevation = NavigationBarDefaults.Elevation,
color = MaterialTheme.colorScheme.background,
) {
WeekDaysHeader()
}

YearView(
state = state,
onEvent = onEvent,
year = state.selectedYearCalendar,
bottomPadding = 0.dp,
)
}
}

Box(
modifier = Modifier.weight(1f),
) {
HorizontalPager(
state = pagerState,
) {
Column {
Surface(
tonalElevation = NavigationBarDefaults.Elevation,
color = MaterialTheme.colorScheme.background,
) {
DateHeader(selectedDay)
}

DayView(
state = state,
onEvent = onEvent,
date = selectedDay,
isEditable = false,
)
}
}
}
}
}
BottomSheetScaffold(
scaffoldState = sheetState,
sheetContent = {
HorizontalPager(
state = pagerState,
AnimatedVisibility(visible = contentType == OverloadContentType.SINGLE_PANE) {
Column {
Surface(
tonalElevation = NavigationBarDefaults.Elevation,
color = MaterialTheme.colorScheme.background,
) {
DayView(
WeekDaysHeader()
}

BottomSheetScaffold(
scaffoldState = sheetState,
sheetContent = {
HorizontalPager(
state = pagerState,
) {
DayView(
state = state,
onEvent = onEvent,
date = selectedDay,
isEditable = false,
)
}
},
) { innerPadding ->
YearView(
state = state,
onEvent = onEvent,
date = selectedDay,
isEditable = false,
year = state.selectedYearCalendar,
bottomPadding = innerPadding.calculateBottomPadding(),
)
}
},
) { innerPadding ->
YearView(
state = state,
onEvent = onEvent,
year = state.selectedYearCalendar,
bottomPadding = innerPadding.calculateBottomPadding(),
)

Modifier.pointerInput(Unit) {
detectVerticalDragGestures { _, dragAmount ->
val maxOffset = 64.dp.toPx()

sheetOffset = (sheetOffset + dragAmount).coerceIn(0f, maxOffset)

Modifier.pointerInput(Unit) {
detectVerticalDragGestures { _, dragAmount ->
val maxOffset = 64.dp.toPx()

sheetOffset = (sheetOffset + dragAmount).coerceIn(0f, maxOffset)
}
}
}
}
}
Expand Down Expand Up @@ -192,3 +248,20 @@ fun DayOfWeekHeaderCell(text: String) {
)
}
}

@Composable
fun DateHeader(date: LocalDate) {
val text = getFormattedDate(date, true)
Box(
modifier = Modifier
.padding(4.dp)
.height(36.dp)
.fillMaxWidth(),
) {
TextView(
text = text,
fontSize = 14.sp,
modifier = Modifier.padding(6.dp),
)
}
}
Loading

0 comments on commit bb4109e

Please sign in to comment.