feat: move jenvolt link out of settings
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
f9784a67a2
commit
66bc50ee39
|
|
@ -1,54 +1,70 @@
|
|||
package chat.revolt.components.screens.home
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.AccountBox
|
||||
import androidx.compose.material3.ElevatedButton
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
fun LinkOnHome(
|
||||
heading: String,
|
||||
icon: ImageVector,
|
||||
onClick: () -> Unit,
|
||||
heading: @Composable () -> Unit,
|
||||
icon: @Composable (Modifier) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
description: @Composable () -> Unit = {},
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
ElevatedButton(
|
||||
onClick = onClick,
|
||||
Box(
|
||||
modifier = modifier
|
||||
.padding(10.dp)
|
||||
.clip(MaterialTheme.shapes.medium)
|
||||
.clickable { onClick() }
|
||||
.padding(20.dp)
|
||||
.fillMaxWidth()
|
||||
.clickable { onClick() },
|
||||
.padding(vertical = 5.dp),
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Icon(
|
||||
imageVector = icon,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.padding(10.dp)
|
||||
)
|
||||
Text(
|
||||
text = heading,
|
||||
style = MaterialTheme.typography.titleMedium.copy(
|
||||
fontWeight = FontWeight.Bold
|
||||
),
|
||||
modifier = Modifier.padding(5.dp)
|
||||
)
|
||||
icon(Modifier.padding(end = 14.dp))
|
||||
|
||||
Column {
|
||||
CompositionLocalProvider(
|
||||
LocalTextStyle provides MaterialTheme.typography.titleMedium.copy(
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
) {
|
||||
heading()
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(2.dp))
|
||||
|
||||
CompositionLocalProvider(
|
||||
LocalTextStyle provides MaterialTheme.typography.bodySmall.copy(
|
||||
fontWeight = FontWeight.Normal
|
||||
)
|
||||
) {
|
||||
description()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -57,8 +73,9 @@ fun LinkOnHome(
|
|||
@Composable
|
||||
fun LinkOnHomePreview() {
|
||||
LinkOnHome(
|
||||
heading = "Heading",
|
||||
icon = Icons.Default.AccountBox,
|
||||
heading = { Text("Heading") },
|
||||
description = { Text("Description") },
|
||||
icon = { mod -> Icon(Icons.Default.AccountBox, null, modifier = mod) },
|
||||
onClick = { }
|
||||
)
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
package chat.revolt.screens.chat.views
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import androidx.compose.animation.core.LinearEasing
|
||||
import androidx.compose.animation.core.RepeatMode
|
||||
import androidx.compose.animation.core.animateFloat
|
||||
|
|
@ -9,21 +11,31 @@ import androidx.compose.animation.core.tween
|
|||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.safeDrawingPadding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Star
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.rotate
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.navigation.NavController
|
||||
import chat.revolt.R
|
||||
import chat.revolt.activities.InviteActivity
|
||||
import chat.revolt.components.generic.PageHeader
|
||||
import chat.revolt.components.screens.home.LinkOnHome
|
||||
|
||||
@Composable
|
||||
fun HomeScreen(navController: NavController) {
|
||||
val context = LocalContext.current
|
||||
|
||||
val catTransition = rememberInfiniteTransition(label = "cat")
|
||||
val catRotation by catTransition.animateFloat(
|
||||
initialValue = 0f,
|
||||
|
|
@ -51,5 +63,28 @@ fun HomeScreen(navController: NavController) {
|
|||
modifier = Modifier.rotate(catRotation),
|
||||
)
|
||||
}
|
||||
|
||||
Column(Modifier.padding(16.dp)) {
|
||||
LinkOnHome(
|
||||
icon = { modifier ->
|
||||
Icon(
|
||||
imageVector = Icons.Default.Star,
|
||||
contentDescription = stringResource(id = R.string.home_join_jenvolt),
|
||||
modifier = modifier
|
||||
)
|
||||
},
|
||||
heading = { Text(text = stringResource(id = R.string.home_join_jenvolt)) },
|
||||
description = { Text(text = stringResource(id = R.string.home_join_jenvolt_description)) },
|
||||
) {
|
||||
context.startActivity(
|
||||
Intent(
|
||||
context,
|
||||
InviteActivity::class.java
|
||||
)
|
||||
.setData(Uri.parse("https://rvlt.gg/jen"))
|
||||
.setAction(Intent.ACTION_VIEW)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
package chat.revolt.screens.settings
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
|
|
@ -14,7 +12,6 @@ import androidx.compose.material.icons.filled.Close
|
|||
import androidx.compose.material.icons.filled.DateRange
|
||||
import androidx.compose.material.icons.filled.Info
|
||||
import androidx.compose.material.icons.filled.Settings
|
||||
import androidx.compose.material.icons.filled.Star
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
|
|
@ -30,7 +27,6 @@ import androidx.lifecycle.ViewModel
|
|||
import androidx.navigation.NavController
|
||||
import chat.revolt.BuildConfig
|
||||
import chat.revolt.R
|
||||
import chat.revolt.activities.InviteActivity
|
||||
import chat.revolt.api.RevoltAPI
|
||||
import chat.revolt.api.settings.GlobalState
|
||||
import chat.revolt.components.generic.PageHeader
|
||||
|
|
@ -59,8 +55,6 @@ fun SettingsScreen(
|
|||
navController: NavController,
|
||||
viewModel: SettingsScreenViewModel = hiltViewModel()
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
|
|
@ -195,32 +189,6 @@ fun SettingsScreen(
|
|||
navController.navigate("settings/changelogs")
|
||||
}
|
||||
|
||||
SheetClickable(
|
||||
icon = { modifier ->
|
||||
Icon(
|
||||
imageVector = Icons.Default.Star,
|
||||
contentDescription = stringResource(id = R.string.logout),
|
||||
modifier = modifier
|
||||
)
|
||||
},
|
||||
label = { textStyle ->
|
||||
Text(
|
||||
text = stringResource(id = R.string.settings_join_jenvolt),
|
||||
style = textStyle
|
||||
)
|
||||
},
|
||||
modifier = Modifier.testTag("settings_join_jenvolt")
|
||||
) {
|
||||
context.startActivity(
|
||||
Intent(
|
||||
context,
|
||||
InviteActivity::class.java
|
||||
)
|
||||
.setData(Uri.parse("https://rvlt.gg/jen"))
|
||||
.setAction(Intent.ACTION_VIEW)
|
||||
)
|
||||
}
|
||||
|
||||
SheetClickable(
|
||||
icon = { modifier ->
|
||||
Icon(
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import androidx.compose.material.icons.Icons
|
|||
import androidx.compose.material.icons.filled.Build
|
||||
import androidx.compose.material.icons.filled.ExitToApp
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
|
|
@ -58,8 +59,14 @@ fun AddServerSheet() {
|
|||
Spacer(modifier = Modifier.height(4.dp))
|
||||
|
||||
LinkOnHome(
|
||||
heading = stringResource(id = R.string.add_server_sheet_join_by_invite),
|
||||
icon = Icons.Default.ExitToApp,
|
||||
heading = { Text(stringResource(id = R.string.add_server_sheet_join_by_invite)) },
|
||||
icon = { modifier ->
|
||||
Icon(
|
||||
imageVector = Icons.Default.ExitToApp,
|
||||
contentDescription = stringResource(id = R.string.add_server_sheet_join_by_invite),
|
||||
modifier = modifier
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
joinFromInviteModalOpen.value = true
|
||||
}
|
||||
|
|
@ -68,8 +75,14 @@ fun AddServerSheet() {
|
|||
Spacer(modifier = Modifier.height(4.dp))
|
||||
|
||||
LinkOnHome(
|
||||
heading = stringResource(id = R.string.add_server_sheet_create_new),
|
||||
icon = Icons.Default.Build,
|
||||
heading = { Text(stringResource(id = R.string.add_server_sheet_create_new)) },
|
||||
icon = { modifier ->
|
||||
Icon(
|
||||
imageVector = Icons.Default.Build,
|
||||
contentDescription = stringResource(id = R.string.add_server_sheet_create_new),
|
||||
modifier = modifier
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
|
|
|
|||
|
|
@ -108,6 +108,9 @@
|
|||
<string name="home">Home</string>
|
||||
<string name="menu">Menu</string>
|
||||
<string name="logout">Log out</string>
|
||||
|
||||
<string name="home_join_jenvolt">Join Jenvolt</string>
|
||||
<string name="home_join_jenvolt_description">Jenvolt is the developer-run space for all things Android app and more. Support, feedback go here. Maybe you will get to try out new features! 👀</string>
|
||||
|
||||
<string name="server_plus_alt">Add server</string>
|
||||
|
||||
|
|
@ -347,8 +350,6 @@
|
|||
<string name="settings_appearance_theme_m3dynamic_unsupported">Material You (unsupported)</string>
|
||||
<string name="settings_appearance_theme_m3dynamic_unsupported_toast">Material You is not supported on this device.</string>
|
||||
|
||||
<string name="settings_join_jenvolt">Join Jenvolt</string>
|
||||
|
||||
<string name="settings_feedback">Feedback</string>
|
||||
<string name="settings_feedback_introduction">Any feedback you have for Revolt is greatly appreciated and all feedback is read by the development team of our Android app.</string>
|
||||
<string name="settings_feedback_category">Category</string>
|
||||
|
|
|
|||
Loading…
Reference in New Issue