Skip to content

Commit

Permalink
Merge b410ba6 into b0e7a57
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamMc331 committed May 24, 2023
2 parents b0e7a57 + b410ba6 commit e641bed
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 66 deletions.
3 changes: 1 addition & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions StreamHistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ The following is a record of all TOA streams in chronological order.
* [Stream Thirty Five - Bottom Bar For Settings](#stream-thirty-five---user-settings)
* [Stream Thirty Six - Settings Implementation](#stream-thirty-six---user-settings-continued)
* [Stream Thirty Seven - Adaptive Navigation Types](#stream-thirty-seven---adaptive-navigation-types)
* [Stream Thirty Eight - Gradle Version Catalogs](#stream-thirty-eight---migrating-to-gradle-version-catalogs)
* [Stream Thirty Nine - Material3 DatePickerDialog](#stream-thirty-nine---refactoring-material3-datepickerdialog)
</details>

<details>
Expand Down Expand Up @@ -609,3 +611,14 @@ PRs:

YouTube:
* Coming Soon

## Stream Thirty Nine - Refactoring Material3 DatePickerDialog

In this stream we replaced our custom date picker dialog implementation with the one provided
by the material 3 library which is now stable.

PRs:
* https://github.com/AdamMc331/TOA/pull/187

YouTube:
* Coming Soon
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
package com.adammcneilly.toa.core.ui.components

import android.content.res.Configuration
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.width
import androidx.compose.material.TextButton
import androidx.compose.material3.DatePicker
import androidx.compose.material3.DatePickerDialog
import androidx.compose.material3.DatePickerState
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.rememberDatePickerState
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import com.adammcneilly.toa.ExcludeFromJacocoGeneratedReport
import com.adammcneilly.toa.core.ui.theme.TOATheme
Expand All @@ -35,54 +27,28 @@ fun TOADatePickerDialog(
onDismiss: () -> Unit,
onComplete: (Long?) -> Unit,
) {
Dialog(
DatePickerDialog(
onDismissRequest = onDismiss,
) {
Surface {
Column {
DatePicker(
datePickerState,
dateValidator = { dateMillis ->
val todayStartMillis = LocalDate.now().toEpochMillisUTC()

dateMillis >= todayStartMillis
},
)

DatePickerButtonRow(
onCancelClicked = onDismiss,
onDoneClicked = {
onComplete(datePickerState.selectedDateMillis)
},
confirmButton = {
TextButton(
onClick = {
onComplete.invoke(datePickerState.selectedDateMillis)
},
) {
Text(
text = "DONE",
)
}
}
}
}

@Composable
private fun DatePickerButtonRow(
onCancelClicked: () -> Unit,
onDoneClicked: () -> Unit,
) {
Row(
modifier = Modifier
.fillMaxWidth(),
horizontalArrangement = Arrangement.End,
},
) {
TextButton(
onClick = onCancelClicked,
) {
Text("CANCEL")
}
DatePicker(
datePickerState,
dateValidator = { dateMillis ->
val todayStartMillis = LocalDate.now().toEpochMillisUTC()

Spacer(modifier = Modifier.width(8.dp))

TextButton(
onClick = onDoneClicked,
) {
Text("DONE")
}
dateMillis >= todayStartMillis
},
)
}
}

Expand Down
24 changes: 12 additions & 12 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
[versions]
accompanist = "0.28.0"
activityCompose = "1.6.1"
accompanist = "0.30.1"
activityCompose = "1.7.1"
androidxTestJunit = "1.1.5"
appCompat = "1.6.1"
compileSdk = "33"
compose = "1.4.0-alpha04"
compose = "1.4.3"
composeDestinations = "1.8.32-beta"
# For the known issue: https://developer.android.com/jetpack/androidx/releases/compose-material3#1.1.0-alpha04
composeFoundation = "1.4.0-alpha03"
composeMaterial3 = "1.1.0-alpha04"
composeNavigation = "2.4.2"
coreKtx = "1.9.0"
coroutines = "1.6.0"
composeFoundation = "1.4.3"
composeMaterial3 = "1.1.0"
composeNavigation = "2.5.3"
coreKtx = "1.10.1"
coroutines = "1.6.4"
dataStore = "1.0.0"
espresso = "3.5.1"
hilt = "2.45"
hilt = "2.46"
hiltNavigationCompose = "1.0.0"
junit = "4.13.2"
lifecycle = "2.5.1"
lifecycle = "2.6.1"
lint = "27.1.2"
material = "1.8.0"
material = "1.9.0"
minSdk = "21"
mockk = "1.13.4"
protobuf = "3.20.0"
room = "2.5.0"
room = "2.5.1"
truth = "1.1.3"
turbine = "0.12.1"
windowManager = "1.0.0"
Expand Down

0 comments on commit e641bed

Please sign in to comment.