diff --git a/app/src/main/java/com/jerboa/JerboaAppState.kt b/app/src/main/java/com/jerboa/JerboaAppState.kt
index e8ac2c779..051517d80 100644
--- a/app/src/main/java/com/jerboa/JerboaAppState.kt
+++ b/app/src/main/java/com/jerboa/JerboaAppState.kt
@@ -127,6 +127,8 @@ class JerboaAppState(
fun toSiteSideBar() = navController.navigate(Route.SITE_SIDEBAR)
+ fun toSiteLegal() = navController.navigate(Route.SITE_LEGAL)
+
fun toCommentReply(replyItem: ReplyItem) {
sendReturnForwards(CommentReplyReturn.COMMENT_SEND, replyItem)
navController.navigate(Route.COMMENT_REPLY)
diff --git a/app/src/main/java/com/jerboa/MainActivity.kt b/app/src/main/java/com/jerboa/MainActivity.kt
index 5ad77431f..8e5ae556f 100644
--- a/app/src/main/java/com/jerboa/MainActivity.kt
+++ b/app/src/main/java/com/jerboa/MainActivity.kt
@@ -53,6 +53,7 @@ import com.jerboa.ui.components.community.CommunityActivity
import com.jerboa.ui.components.community.list.CommunityListActivity
import com.jerboa.ui.components.community.sidebar.CommunitySidebarActivity
import com.jerboa.ui.components.home.BottomNavActivity
+import com.jerboa.ui.components.home.legal.SiteLegalActivity
import com.jerboa.ui.components.home.sidebar.SiteSidebarActivity
import com.jerboa.ui.components.imageviewer.ImageViewer
import com.jerboa.ui.components.inbox.InboxActivity
@@ -559,6 +560,13 @@ class MainActivity : AppCompatActivity() {
composable(route = Route.SITE_SIDEBAR) {
SiteSidebarActivity(
+ appState = appState,
+ siteViewModel = siteViewModel,
+ )
+ }
+
+ composable(route = Route.SITE_LEGAL) {
+ SiteLegalActivity(
siteViewModel = siteViewModel,
onBackClick = appState::popBackStack,
)
diff --git a/app/src/main/java/com/jerboa/ui/components/common/Route.kt b/app/src/main/java/com/jerboa/ui/components/common/Route.kt
index 450139d7b..d1ad38e62 100644
--- a/app/src/main/java/com/jerboa/ui/components/common/Route.kt
+++ b/app/src/main/java/com/jerboa/ui/components/common/Route.kt
@@ -33,6 +33,7 @@ object Route {
const val COMMENT_REPLY = "commentReply"
const val SITE_SIDEBAR = "siteSidebar"
+ const val SITE_LEGAL = "siteLegal"
const val COMMENT_EDIT = "commentEdit"
const val POST_EDIT = "postEdit"
const val POST_REMOVE = "postRemove"
diff --git a/app/src/main/java/com/jerboa/ui/components/home/legal/SiteLegalActivity.kt b/app/src/main/java/com/jerboa/ui/components/home/legal/SiteLegalActivity.kt
new file mode 100644
index 000000000..73ae0ed6f
--- /dev/null
+++ b/app/src/main/java/com/jerboa/ui/components/home/legal/SiteLegalActivity.kt
@@ -0,0 +1,76 @@
+package com.jerboa.ui.components.home.legal
+
+import android.util.Log
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.verticalScroll
+import androidx.compose.material3.ExperimentalMaterial3Api
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Scaffold
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.res.stringResource
+import com.jerboa.R
+import com.jerboa.api.ApiState
+import com.jerboa.model.SiteViewModel
+import com.jerboa.ui.components.common.ApiEmptyText
+import com.jerboa.ui.components.common.ApiErrorText
+import com.jerboa.ui.components.common.LoadingBar
+import com.jerboa.ui.components.common.MyMarkdownText
+import com.jerboa.ui.components.common.SimpleTopAppBar
+import com.jerboa.ui.theme.MEDIUM_PADDING
+import com.jerboa.ui.theme.muted
+
+@OptIn(ExperimentalMaterial3Api::class)
+@Composable
+fun SiteLegalActivity(
+ siteViewModel: SiteViewModel,
+ onBackClick: () -> Unit,
+) {
+ Log.d("jerboa", "got to site legal activity")
+
+ val scrollState = rememberScrollState()
+
+ val title =
+ when (val siteRes = siteViewModel.siteRes) {
+ is ApiState.Success -> stringResource(R.string.site_legal_info_name, siteRes.data.site_view.site.name)
+ else -> {
+ stringResource(R.string.loading)
+ }
+ }
+
+ Scaffold(
+ topBar = {
+ SimpleTopAppBar(
+ text = title,
+ onBackClick,
+ )
+ },
+ content = { padding ->
+ when (val siteRes = siteViewModel.siteRes) {
+ ApiState.Empty -> ApiEmptyText()
+ is ApiState.Failure -> ApiErrorText(siteRes.msg)
+ ApiState.Loading -> LoadingBar(padding)
+ is ApiState.Success -> {
+ Column(
+ modifier =
+ Modifier
+ .padding(padding)
+ .verticalScroll(scrollState),
+ ) {
+ siteRes.data.site_view.local_site.legal_information?.let {
+ MyMarkdownText(
+ modifier = Modifier.padding(horizontal = MEDIUM_PADDING),
+ markdown = it,
+ color = MaterialTheme.colorScheme.onBackground.muted,
+ onClick = {},
+ )
+ }
+ }
+ }
+ else -> {}
+ }
+ },
+ )
+}
diff --git a/app/src/main/java/com/jerboa/ui/components/home/sidebar/SiteSidebarActivity.kt b/app/src/main/java/com/jerboa/ui/components/home/sidebar/SiteSidebarActivity.kt
index 9a8ec0f53..bb0ea875d 100644
--- a/app/src/main/java/com/jerboa/ui/components/home/sidebar/SiteSidebarActivity.kt
+++ b/app/src/main/java/com/jerboa/ui/components/home/sidebar/SiteSidebarActivity.kt
@@ -1,9 +1,16 @@
package com.jerboa.ui.components.home.sidebar
import android.util.Log
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.Policy
import androidx.compose.material3.ExperimentalMaterial3Api
+import androidx.compose.material3.Icon
+import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
+import androidx.compose.ui.res.stringResource
+import com.jerboa.JerboaAppState
+import com.jerboa.R
import com.jerboa.api.ApiState
import com.jerboa.model.SiteViewModel
import com.jerboa.ui.components.common.ApiEmptyText
@@ -14,16 +21,16 @@ import com.jerboa.ui.components.common.SimpleTopAppBar
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SiteSidebarActivity(
+ appState: JerboaAppState,
siteViewModel: SiteViewModel,
- onBackClick: () -> Unit,
) {
Log.d("jerboa", "got to site sidebar activity")
val title =
when (val siteRes = siteViewModel.siteRes) {
- is ApiState.Success -> "${siteRes.data.site_view.site.name} Info"
+ is ApiState.Success -> stringResource(R.string.site_info_name, siteRes.data.site_view.site.name)
else -> {
- "Loading..."
+ stringResource(R.string.loading)
}
}
@@ -31,7 +38,26 @@ fun SiteSidebarActivity(
topBar = {
SimpleTopAppBar(
text = title,
- onBackClick,
+ onClickBack = appState::popBackStack,
+ actions = {
+ when (val siteRes = siteViewModel.siteRes) {
+ is ApiState.Success -> {
+ if (siteRes.data.site_view.local_site.legal_information != null) {
+ IconButton(
+ onClick = {
+ appState.toSiteLegal()
+ },
+ ) {
+ Icon(
+ Icons.Default.Policy,
+ contentDescription = title,
+ )
+ }
+ }
+ }
+ else -> {}
+ }
+ },
)
},
content = { padding ->
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 0c94ecc73..022ebce8f 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -460,4 +460,6 @@
Message
Report %1$s
Block %1$s
+ %1$s info
+ %1$s legal info