This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var openDatePickerDialog = remember { mutableStateOf(false) } | |
if (openDatePickerDialog.value) { | |
val datePickerState = rememberDatePickerState() | |
DatePickerDialog( | |
onDismissRequest = { | |
openDatePickerDialog.value = false | |
}, | |
confirmButton = { | |
TextButton( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val datePickerState = | |
rememberDatePickerState(initialSelectedDateMillis = System.currentTimeMillis(), | |
selectableDates = object : SelectableDates { | |
override fun isSelectableDate(utcTimeMillis: Long): Boolean { | |
val date = Date().apply { | |
time = utcTimeMillis | |
} | |
val currentDate = Date() | |
return date.before(currentDate) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val datePickerState = | |
rememberDatePickerState(initialSelectedDateMillis = System.currentTimeMillis()) | |
DatePicker( | |
state = datePickerState, | |
modifier = Modifier.padding(16.dp), | |
title = { | |
Text(text = "Select start date") | |
}, | |
// colors = DatePickerDefaults.colors( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var openModalBottomSheet by rememberSaveable { mutableStateOf(false) } | |
// Modal Sheet content | |
if (openModalBottomSheet) { | |
ModalBottomSheet( | |
onDismissRequest = { openModalBottomSheet = false }, | |
sheetState = bottomSheetState, | |
scrimColor = Purple40Alpha30, | |
) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// to customize sheet drag handle | |
sheetDragHandle = { | |
BottomSheetDefaults.DragHandle( | |
color = Color.Red, | |
shape = RoundedCornerShape(2.dp), | |
width = 48.dp, | |
height = 8.dp | |
) | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val scope = rememberCoroutineScope() | |
val sheetState = SheetState(skipPartiallyExpanded = false, skipHiddenState = false) | |
val scaffoldState = rememberBottomSheetScaffoldState(bottomSheetState = sheetState) | |
BottomSheetScaffold(modifier = Modifier.fillMaxHeight(), | |
scaffoldState = scaffoldState, | |
sheetPeekHeight = 128.dp, | |
sheetShadowElevation = 32.dp, | |
topBar = { | |
CenterAlignedTopAppBar(title = { Text(text = "Material 3 Demo") }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val DarkColorScheme = darkColorScheme( | |
primary = Purple80, | |
secondary = PurpleGrey80, | |
tertiary = Pink80 | |
) | |
private val LightColorScheme = lightColorScheme( | |
primary = Purple40, | |
secondary = PurpleGrey40, | |
tertiary = Pink40 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Migrating queries to fetch all products (From skus to products) | |
// v4.0 - deprecated | |
val skuList = ArrayList<String>() | |
skuList.add("up_basic_sub") | |
val params = SkuDetailsParams.newBuilder() | |
params.setSkusList(skuList).setType(BillingClient.SkuType.SUBS) | |
billingClient.querySkuDetailsAsync(params.build()) { | |
billingResult, skuDetailsList -> | |
// Process the result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
val listOfMumbaiPeople = listOf<Person>( | |
Person("John", Address("Thane", "Mumbai")), | |
Person("Bob", Address("Bandra", "Mumbai")) | |
) | |
val listOfVadodaraPeople = listOf<Person>( | |
Person("Jane", Address("Manjalpur", "Vadodara")), | |
Person("Alice", Address("Akota", "Vadodara")) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class Address(var addressLine1: String, var city: String) | |
data class Person(var name: String, var address: Address) | |
fun main() { | |
// map | |
val listOfPeople = listOf<Person>( | |
Person("Jane", Address("Manjalpur", "Vadodara")), | |
Person("John", Address("Vastrapur", "Ahmedabad")), | |
Person("Bob", Address("Bandra", "Mumbai")) | |
) |
NewerOlder