all: override LocalUriHandler with UrlLauncher

This commit is contained in:
Harsh Shandilya 2021-10-28 22:16:05 +05:30
parent 26a96d9116
commit 9d538b4600
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80
2 changed files with 10 additions and 2 deletions

View file

@ -19,6 +19,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
import androidx.compose.ui.input.nestedscroll.NestedScrollSource import androidx.compose.ui.input.nestedscroll.NestedScrollSource
import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalUriHandler
import androidx.lifecycle.viewmodel.compose.viewModel import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.compose.NavHost import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable import androidx.navigation.compose.composable
@ -89,7 +90,10 @@ fun LobstersApp(
navController.addOnDestinationChangedListener { _, destination, _ -> navController.addOnDestinationChangedListener { _, destination, _ ->
currentDestination = destination.route ?: Destinations.Hottest currentDestination = destination.route ?: Destinations.Hottest
} }
LobstersTheme(darkTheme = isSystemInDarkTheme()) { LobstersTheme(
darkTheme = isSystemInDarkTheme(),
providedValues = arrayOf(LocalUriHandler provides urlLauncher),
) {
ProvideWindowInsets { ProvideWindowInsets {
val useDarkIcons = MaterialTheme.colors.isLight val useDarkIcons = MaterialTheme.colors.isLight
val statusBarColor = MaterialTheme.colors.primarySurface val statusBarColor = MaterialTheme.colors.primarySurface

View file

@ -9,6 +9,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.WindowPlacement import androidx.compose.ui.window.WindowPlacement
import androidx.compose.ui.window.WindowPosition import androidx.compose.ui.window.WindowPosition
@ -58,7 +59,10 @@ fun main() = application {
undecorated = true, undecorated = true,
onCloseRequest = ::exitApplication, onCloseRequest = ::exitApplication,
) { ) {
LobstersTheme(darkTheme = false) { LobstersTheme(
darkTheme = false,
providedValues = arrayOf(LocalUriHandler provides urlLauncher),
) {
Box( Box(
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
) { ) {