-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add option to open links in internal web view (#482)
* refactor: cleanup ImageDetailScreen * update build scripts * implement WebViewScreen * add method to DetailOpener * add new UrlOpeningMode * add management in CustomUriHandler * add option in settings * update l10n
- Loading branch information
Showing
20 changed files
with
246 additions
and
99 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
86 changes: 86 additions & 0 deletions
86
...n/kotlin/com/livefast/eattrash/raccoonforfriendica/core/commonui/content/WebViewScreen.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package com.livefast.eattrash.raccoonforfriendica.core.commonui.content | ||
|
||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.automirrored.filled.ArrowBack | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TopAppBar | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.DisposableEffect | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.text.style.TextOverflow | ||
import cafe.adriel.voyager.core.screen.Screen | ||
import com.livefast.eattrash.raccoonforfriendica.core.navigation.di.getDrawerCoordinator | ||
import com.livefast.eattrash.raccoonforfriendica.core.navigation.di.getNavigationCoordinator | ||
import com.mohamedrejeb.calf.ui.web.WebView | ||
import com.mohamedrejeb.calf.ui.web.rememberWebViewState | ||
|
||
class WebViewScreen( | ||
private val url: String, | ||
) : Screen { | ||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
override fun Content() { | ||
val navigationCoordinator = remember { getNavigationCoordinator() } | ||
val drawerCoordinator = remember { getDrawerCoordinator() } | ||
val state = | ||
rememberWebViewState( | ||
url = url, | ||
) | ||
|
||
LaunchedEffect(Unit) { | ||
state.settings.javaScriptEnabled = true | ||
state.settings.androidSettings.supportZoom = true | ||
} | ||
LaunchedEffect(drawerCoordinator) { | ||
drawerCoordinator.setGesturesEnabled(false) | ||
} | ||
DisposableEffect(drawerCoordinator) { | ||
onDispose { | ||
drawerCoordinator.setGesturesEnabled(true) | ||
} | ||
} | ||
|
||
Scaffold( | ||
topBar = { | ||
TopAppBar( | ||
title = { | ||
Text( | ||
text = url, | ||
style = MaterialTheme.typography.titleMedium, | ||
maxLines = 1, | ||
overflow = TextOverflow.Ellipsis, | ||
) | ||
}, | ||
navigationIcon = { | ||
if (navigationCoordinator.canPop.value) { | ||
IconButton( | ||
onClick = { | ||
navigationCoordinator.pop() | ||
}, | ||
) { | ||
Icon( | ||
imageVector = Icons.AutoMirrored.Default.ArrowBack, | ||
contentDescription = null, | ||
) | ||
} | ||
} | ||
}, | ||
) | ||
}, | ||
) { padding -> | ||
WebView( | ||
modifier = Modifier.padding(top = padding.calculateTopPadding()).fillMaxSize(), | ||
state = state, | ||
) | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.