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
NavDeepLinkBuilder(context) | |
.setGraph(R.navigation.nav_graph) | |
.setDestination(R.id.taskDetailFragment) | |
.setArguments(arguments) | |
.createPendingIntent() |
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 taskDetailIntent = Intent( | |
Intent.ACTION_VIEW, | |
"https://example.com/task_id=${task.id}".toUri(), | |
context, | |
MainActivity::class.java | |
) | |
val pending: PendingIntent = TaskStackBuilder.create(context).run { | |
addNextIntentWithParentStack(taskDetailIntent) | |
getPendingIntent(REQUEST_CODE, PendingIntent.FLAG_UPDATE_CURRENT) |
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
<intent-filter> | |
<action android:name="android.intent.action.VIEW" /> | |
<category android:name="android.intent.category.DEFAULT" /> | |
<category android:name="android.intent.category.BROWSABLE" /> | |
<data | |
android:host="example.com" | |
android:scheme="https" /> | |
</intent-filter> |
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 taskDetailIntent = Intent( | |
Intent.ACTION_VIEW, | |
"https://example.com/task_id=${task.id}".toUri() | |
) | |
val pending: PendingIntent = TaskStackBuilder.create(context).run { | |
addNextIntentWithParentStack(taskDetailIntent) | |
getPendingIntent(REQUEST_CODE, PendingIntent.FLAG_UPDATE_CURRENT) | |
} |
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
@Composable | |
fun SnackbarSample() { | |
val snackbarHostState = remember { SnackbarHostState() } | |
val coroutineScope = rememberCoroutineScope() | |
val modifier = Modifier | |
Box(modifier.fillMaxSize()) { | |
Button(onClick = { | |
coroutineScope.launch { | |
snackbarHostState.showSnackbar(message = "This is a Snackbar") |
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
@Composable | |
fun HomeList(taskViewModel: ListViewModel = viewModel()) { | |
Scaffold { | |
val list by remember(taskViewModel) { | |
taskViewModel.taskList | |
}.collectAsState() | |
LazyColumn { | |
items( | |
items = list, |
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
@Composable | |
fun HomeList(taskViewModel: ListViewModel = viewModel()) { | |
val coroutineScope = rememberCoroutineScope() | |
val scaffoldState = rememberScaffoldState() | |
val onShowSnackbar: (Task) -> Unit = { task -> | |
coroutineScope.launch { | |
val snackbarResult = scaffoldState.snackbarHostState.showSnackbar( | |
message = "${task.title} completed", | |
actionLabel = "Undo" |
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
Scaffold(scaffoldState = scaffoldState) { | |
... | |
ListItem( | |
task = task, | |
onCheckedChange = { task -> | |
taskViewModel.onCheckedChange(task) | |
onShowSnackbar(task) | |
} | |
) | |
} |