feat: special embeds control UI
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
e4406b2966
commit
48e20d5464
|
|
@ -3,12 +3,21 @@ package chat.revolt.components.chat.specialembeds
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import chat.revolt.api.schemas.Special
|
import chat.revolt.api.schemas.Special
|
||||||
|
import chat.revolt.api.settings.LoadedSettings
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SpecialEmbedSwitch(special: Special, modifier: Modifier = Modifier) {
|
fun SpecialEmbedSwitch(special: Special, modifier: Modifier = Modifier) {
|
||||||
when (special.type) {
|
when {
|
||||||
"YouTube" -> YoutubeEmbedSwitch(special, modifier)
|
(special.type == "YouTube") && LoadedSettings.specialEmbedSettings.embedYouTube -> YoutubeEmbedSwitch(
|
||||||
"AppleMusic" -> AppleMusicEmbed(special, modifier)
|
special,
|
||||||
|
modifier
|
||||||
|
)
|
||||||
|
|
||||||
|
(special.type == "AppleMusic") && LoadedSettings.specialEmbedSettings.embedAppleMusic -> AppleMusicEmbed(
|
||||||
|
special,
|
||||||
|
modifier
|
||||||
|
)
|
||||||
|
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package chat.revolt.screens.settings
|
package chat.revolt.screens.settings
|
||||||
|
|
||||||
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.imePadding
|
import androidx.compose.foundation.layout.imePadding
|
||||||
|
|
@ -13,7 +14,9 @@ import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.LargeTopAppBar
|
import androidx.compose.material3.LargeTopAppBar
|
||||||
|
import androidx.compose.material3.ListItem
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
|
import androidx.compose.material3.Switch
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TopAppBarDefaults
|
import androidx.compose.material3.TopAppBarDefaults
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
|
@ -21,6 +24,7 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
|
|
@ -28,6 +32,7 @@ import androidx.navigation.NavController
|
||||||
import chat.revolt.R
|
import chat.revolt.R
|
||||||
import chat.revolt.api.settings.LoadedSettings
|
import chat.revolt.api.settings.LoadedSettings
|
||||||
import chat.revolt.api.settings.MessageReplyStyle
|
import chat.revolt.api.settings.MessageReplyStyle
|
||||||
|
import chat.revolt.api.settings.SpecialEmbedSettings
|
||||||
import chat.revolt.api.settings.SyncedSettings
|
import chat.revolt.api.settings.SyncedSettings
|
||||||
import chat.revolt.components.generic.ListHeader
|
import chat.revolt.components.generic.ListHeader
|
||||||
import chat.revolt.components.generic.RadioItem
|
import chat.revolt.components.generic.RadioItem
|
||||||
|
|
@ -40,6 +45,13 @@ class ChatSettingsScreenViewModel : ViewModel() {
|
||||||
LoadedSettings.messageReplyStyle = next
|
LoadedSettings.messageReplyStyle = next
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateSpecialEmbedSettings(next: SpecialEmbedSettings) {
|
||||||
|
viewModelScope.launch {
|
||||||
|
SyncedSettings.updateAndroid(SyncedSettings.android.copy(specialEmbedSettings = next))
|
||||||
|
LoadedSettings.specialEmbedSettings = next
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
|
|
@ -106,6 +118,58 @@ fun ChatSettingsScreen(
|
||||||
label = { Text(text = stringResource(R.string.settings_chat_quick_reply_double_tap)) }
|
label = { Text(text = stringResource(R.string.settings_chat_quick_reply_double_tap)) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ListHeader {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.settings_chat_interactive_embeds)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Text(
|
||||||
|
stringResource(R.string.settings_chat_interactive_embeds_description),
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(vertical = 8.dp, horizontal = 16.dp),
|
||||||
|
)
|
||||||
|
|
||||||
|
Column {
|
||||||
|
ListItem(
|
||||||
|
headlineContent = {
|
||||||
|
Text(stringResource(R.string.settings_chat_interactive_embeds_youtube))
|
||||||
|
},
|
||||||
|
trailingContent = {
|
||||||
|
Switch(
|
||||||
|
checked = LoadedSettings.specialEmbedSettings.embedYouTube,
|
||||||
|
onCheckedChange = null
|
||||||
|
)
|
||||||
|
},
|
||||||
|
modifier = Modifier.clickable {
|
||||||
|
viewModel.updateSpecialEmbedSettings(
|
||||||
|
LoadedSettings.specialEmbedSettings.copy(
|
||||||
|
embedYouTube = !LoadedSettings.specialEmbedSettings.embedYouTube
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
ListItem(
|
||||||
|
headlineContent = {
|
||||||
|
Text(stringResource(R.string.settings_chat_interactive_embeds_apple_music))
|
||||||
|
},
|
||||||
|
trailingContent = {
|
||||||
|
Switch(
|
||||||
|
checked = LoadedSettings.specialEmbedSettings.embedAppleMusic,
|
||||||
|
onCheckedChange = null
|
||||||
|
)
|
||||||
|
},
|
||||||
|
modifier = Modifier.clickable {
|
||||||
|
viewModel.updateSpecialEmbedSettings(
|
||||||
|
LoadedSettings.specialEmbedSettings.copy(
|
||||||
|
embedAppleMusic = !LoadedSettings.specialEmbedSettings.embedAppleMusic
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -615,6 +615,10 @@
|
||||||
<string name="settings_chat_quick_reply_none">Long press to reply</string>
|
<string name="settings_chat_quick_reply_none">Long press to reply</string>
|
||||||
<string name="settings_chat_quick_reply_swipe_from_end">Swipe to reply</string>
|
<string name="settings_chat_quick_reply_swipe_from_end">Swipe to reply</string>
|
||||||
<string name="settings_chat_quick_reply_double_tap">Double tap to reply</string>
|
<string name="settings_chat_quick_reply_double_tap">Double tap to reply</string>
|
||||||
|
<string name="settings_chat_interactive_embeds">Interactive Embeds</string>
|
||||||
|
<string name="settings_chat_interactive_embeds_description">Interactive Embeds allow you to interact with some types of links directly inside chat. For example, you can play YouTube videos or preview albums from Apple Music.</string>
|
||||||
|
<string name="settings_chat_interactive_embeds_youtube">YouTube</string>
|
||||||
|
<string name="settings_chat_interactive_embeds_apple_music">Apple Music</string>
|
||||||
|
|
||||||
<string name="settings_feedback">Feedback</string>
|
<string name="settings_feedback">Feedback</string>
|
||||||
<string name="settings_feedback_description">Join the Revolt server to give feedback or suggestions and report bugs.</string>
|
<string name="settings_feedback_description">Join the Revolt server to give feedback or suggestions and report bugs.</string>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue