-
Notifications
You must be signed in to change notification settings - Fork 6
feat: about page #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: about page #74
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bffbe42
feat: add about page
aanorbel 523ce36
chore: update lint
aanorbel 2177440
Merge branch 'main' of github.com:ooni/probe-multiplatform into setti…
aanorbel dd75fc0
chore: add support for sending emails
aanorbel 05bfd42
feat: add markdown viewer (#81)
aanorbel a715de7
Merge branch 'main' of github.com:ooni/probe-multiplatform into setti…
aanorbel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
|
||
logo.xml | ||
|
||
logo_probe.xml | ||
logo_probe.xml |
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
4 changes: 4 additions & 0 deletions
4
composeApp/src/commonMain/composeResources/values/untraslatable.xml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<resources> | ||
<string name="shareEmailTo" translatable="false">mailto:bugs@openobservatory.org</string> | ||
<string name="shareSubject" translatable="false">[bug-report] OONI Probe %1$s</string> | ||
</resources> |
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
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
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
57 changes: 57 additions & 0 deletions
57
composeApp/src/commonMain/kotlin/org/ooni/probe/ui/settings/about/AboutScreen.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.ooni.probe.ui.settings.about | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.automirrored.filled.ArrowBack | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.material3.LargeTopAppBar | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import ooniprobe.composeapp.generated.resources.Res | ||
import ooniprobe.composeapp.generated.resources.Settings_About_Content_Paragraph | ||
import ooniprobe.composeapp.generated.resources.Settings_About_Label | ||
import ooniprobe.composeapp.generated.resources.back | ||
import org.jetbrains.compose.resources.stringResource | ||
import org.ooni.probe.ui.shared.MarkdownViewer | ||
|
||
@Composable | ||
fun AboutScreen(onEvent: (AboutViewModel.Event) -> Unit) { | ||
LazyColumn { | ||
item { | ||
LargeTopAppBar( | ||
title = { | ||
Text(stringResource(Res.string.Settings_About_Label)) | ||
}, | ||
navigationIcon = { | ||
IconButton(onClick = { onEvent(AboutViewModel.Event.BackClicked) }) { | ||
Icon( | ||
Icons.AutoMirrored.Filled.ArrowBack, | ||
contentDescription = stringResource(Res.string.back), | ||
) | ||
} | ||
}, | ||
) | ||
} | ||
item { | ||
Column( | ||
verticalArrangement = Arrangement.Center, | ||
) { | ||
MarkdownViewer( | ||
markdown = stringResource(Res.string.Settings_About_Content_Paragraph), | ||
) { url -> onEvent(AboutViewModel.Event.LaunchUrlClicked(url)) } | ||
|
||
Spacer(modifier = Modifier.height(16.dp)) | ||
InfoLinks( | ||
launchUrl = { url -> onEvent(AboutViewModel.Event.LaunchUrlClicked(url)) }, | ||
) | ||
} | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
composeApp/src/commonMain/kotlin/org/ooni/probe/ui/settings/about/AboutViewModel.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.ooni.probe.ui.settings.about | ||
|
||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import kotlinx.coroutines.flow.MutableSharedFlow | ||
import kotlinx.coroutines.flow.filterIsInstance | ||
import kotlinx.coroutines.flow.launchIn | ||
import kotlinx.coroutines.flow.onEach | ||
|
||
class AboutViewModel( | ||
onBack: () -> Unit, | ||
launchUrl: (String) -> Unit, | ||
) : ViewModel() { | ||
private val events = MutableSharedFlow<Event>(extraBufferCapacity = 1) | ||
|
||
init { | ||
events.filterIsInstance<Event.BackClicked>().onEach { onBack() }.launchIn(viewModelScope) | ||
events.filterIsInstance<Event.LaunchUrlClicked>().onEach { url -> launchUrl(url.url) } | ||
.launchIn(viewModelScope) | ||
} | ||
|
||
fun onEvent(event: Event) { | ||
events.tryEmit(event) | ||
} | ||
|
||
sealed interface Event { | ||
data object BackClicked : Event | ||
|
||
data class LaunchUrlClicked(val url: String) : Event | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
composeApp/src/commonMain/kotlin/org/ooni/probe/ui/shared/MarkdownViewer.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.ooni.probe.ui.shared | ||
|
||
import androidx.compose.runtime.Composable | ||
import com.multiplatform.webview.request.RequestInterceptor | ||
import com.multiplatform.webview.request.WebRequest | ||
import com.multiplatform.webview.request.WebRequestInterceptResult | ||
import com.multiplatform.webview.web.WebView | ||
import com.multiplatform.webview.web.WebViewNavigator | ||
import com.multiplatform.webview.web.rememberWebViewNavigator | ||
import com.multiplatform.webview.web.rememberWebViewStateWithHTMLData | ||
import org.intellij.markdown.flavours.commonmark.CommonMarkFlavourDescriptor | ||
import org.intellij.markdown.html.HtmlGenerator | ||
import org.intellij.markdown.parser.MarkdownParser | ||
|
||
@Composable | ||
fun MarkdownViewer( | ||
markdown: String, | ||
onUrlClicked: (String) -> Unit, | ||
) { | ||
val flavour = CommonMarkFlavourDescriptor() | ||
val html = HtmlGenerator( | ||
markdown, | ||
MarkdownParser(flavour).buildMarkdownTreeFromString(markdown), | ||
flavour, | ||
).generateHtml() | ||
val webViewState = rememberWebViewStateWithHTMLData( | ||
data = html, | ||
) | ||
val navigator = | ||
rememberWebViewNavigator( | ||
requestInterceptor = | ||
object : RequestInterceptor { | ||
override fun onInterceptUrlRequest( | ||
request: WebRequest, | ||
navigator: WebViewNavigator, | ||
): WebRequestInterceptResult { | ||
onUrlClicked(request.url) | ||
return WebRequestInterceptResult.Reject | ||
} | ||
}, | ||
) | ||
WebView(state = webViewState, navigator = navigator) | ||
} |
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
7 changes: 7 additions & 0 deletions
7
composeApp/src/dwMain/kotlin/org/ooni/probe/ui/about/InfoLinks.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.ooni.probe.ui.settings.about | ||
|
||
import androidx.compose.runtime.Composable | ||
|
||
@Composable | ||
fun InfoLinks(launchUrl: (String) -> Unit) { | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.