mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-29 19:43:23 +02:00
Adds DM and Search default buttons to the dialogs.
This commit is contained in:
@@ -67,9 +67,9 @@ val DefaultNIP65List =
|
|||||||
|
|
||||||
val DefaultDMRelayList =
|
val DefaultDMRelayList =
|
||||||
listOf(
|
listOf(
|
||||||
RelayUrlFormatter.normalize("wss://auth.nostr1.com/"),
|
RelayUrlFormatter.normalize("wss://auth.nostr1.com"),
|
||||||
RelayUrlFormatter.normalize("wss://nostr.mom/"),
|
RelayUrlFormatter.normalize("wss://relay.0xchat.com"),
|
||||||
RelayUrlFormatter.normalize("wss://nos.lol/"),
|
RelayUrlFormatter.normalize("wss://nos.lol"),
|
||||||
)
|
)
|
||||||
|
|
||||||
val DefaultSearchRelayList =
|
val DefaultSearchRelayList =
|
||||||
@@ -357,7 +357,6 @@ class AccountSettings(
|
|||||||
|
|
||||||
// Events might be different objects, we have to compare their ids.
|
// Events might be different objects, we have to compare their ids.
|
||||||
if (backupAppSpecificData?.id != appSettings.id) {
|
if (backupAppSpecificData?.id != appSettings.id) {
|
||||||
println("AABBCC Update App Specific Data")
|
|
||||||
backupAppSpecificData = appSettings
|
backupAppSpecificData = appSettings
|
||||||
syncedSettings.updateFrom(newSyncedSettings)
|
syncedSettings.updateFrom(newSyncedSettings)
|
||||||
|
|
||||||
|
@@ -29,6 +29,7 @@ import androidx.compose.foundation.layout.padding
|
|||||||
import androidx.compose.material3.Card
|
import androidx.compose.material3.Card
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.OutlinedButton
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TopAppBar
|
import androidx.compose.material3.TopAppBar
|
||||||
@@ -42,6 +43,8 @@ import androidx.compose.ui.window.Dialog
|
|||||||
import androidx.compose.ui.window.DialogProperties
|
import androidx.compose.ui.window.DialogProperties
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
|
import com.vitorpamplona.amethyst.model.DefaultDMRelayList
|
||||||
|
import com.vitorpamplona.amethyst.ui.components.SetDialogToEdgeToEdge
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.INav
|
import com.vitorpamplona.amethyst.ui.navigation.INav
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.CloseButton
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.CloseButton
|
||||||
@@ -50,6 +53,7 @@ import com.vitorpamplona.amethyst.ui.stringRes
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer
|
import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer
|
||||||
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
|
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
|
||||||
import com.vitorpamplona.amethyst.ui.theme.imageModifier
|
import com.vitorpamplona.amethyst.ui.theme.imageModifier
|
||||||
|
import com.vitorpamplona.ammolite.relays.RelayStat
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
@@ -66,6 +70,7 @@ fun AddDMRelayListDialog(
|
|||||||
onDismissRequest = onClose,
|
onDismissRequest = onClose,
|
||||||
properties = DialogProperties(usePlatformDefaultWidth = false),
|
properties = DialogProperties(usePlatformDefaultWidth = false),
|
||||||
) {
|
) {
|
||||||
|
SetDialogToEdgeToEdge()
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
@@ -114,7 +119,7 @@ fun AddDMRelayListDialog(
|
|||||||
),
|
),
|
||||||
verticalArrangement = Arrangement.SpaceAround,
|
verticalArrangement = Arrangement.SpaceAround,
|
||||||
) {
|
) {
|
||||||
Explanation()
|
Explanation(postViewModel)
|
||||||
|
|
||||||
DMRelayList(postViewModel, accountViewModel, onClose, nav)
|
DMRelayList(postViewModel, accountViewModel, onClose, nav)
|
||||||
}
|
}
|
||||||
@@ -123,7 +128,7 @@ fun AddDMRelayListDialog(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun Explanation() {
|
private fun Explanation(postViewModel: DMRelayListViewModel) {
|
||||||
Card(modifier = MaterialTheme.colorScheme.imageModifier) {
|
Card(modifier = MaterialTheme.colorScheme.imageModifier) {
|
||||||
Column(modifier = Modifier.padding(16.dp)) {
|
Column(modifier = Modifier.padding(16.dp)) {
|
||||||
Text(
|
Text(
|
||||||
@@ -133,8 +138,25 @@ private fun Explanation() {
|
|||||||
Spacer(modifier = StdVertSpacer)
|
Spacer(modifier = StdVertSpacer)
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = stringRes(id = R.string.dm_relays_not_found_examples),
|
text = stringRes(id = R.string.dm_relays_not_found_examples2),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Spacer(modifier = StdVertSpacer)
|
||||||
|
|
||||||
|
ResetDMRelaysLonger(postViewModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ResetDMRelaysLonger(postViewModel: DMRelayListViewModel) {
|
||||||
|
OutlinedButton(
|
||||||
|
onClick = {
|
||||||
|
postViewModel.deleteAll()
|
||||||
|
DefaultDMRelayList.forEach { postViewModel.addRelay(BasicRelaySetupInfo(it, RelayStat())) }
|
||||||
|
postViewModel.loadRelayDocuments()
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
Text(stringRes(R.string.default_relays_longer))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -29,6 +29,7 @@ import androidx.compose.foundation.layout.padding
|
|||||||
import androidx.compose.material3.Card
|
import androidx.compose.material3.Card
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.OutlinedButton
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TopAppBar
|
import androidx.compose.material3.TopAppBar
|
||||||
@@ -42,6 +43,7 @@ import androidx.compose.ui.window.Dialog
|
|||||||
import androidx.compose.ui.window.DialogProperties
|
import androidx.compose.ui.window.DialogProperties
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
|
import com.vitorpamplona.amethyst.ui.components.SetDialogToEdgeToEdge
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.INav
|
import com.vitorpamplona.amethyst.ui.navigation.INav
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.CloseButton
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.CloseButton
|
||||||
@@ -50,6 +52,8 @@ import com.vitorpamplona.amethyst.ui.stringRes
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer
|
import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer
|
||||||
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
|
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
|
||||||
import com.vitorpamplona.amethyst.ui.theme.imageModifier
|
import com.vitorpamplona.amethyst.ui.theme.imageModifier
|
||||||
|
import com.vitorpamplona.ammolite.relays.Constants
|
||||||
|
import com.vitorpamplona.ammolite.relays.RelayStat
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
@@ -66,6 +70,7 @@ fun AddSearchRelayListDialog(
|
|||||||
onDismissRequest = onClose,
|
onDismissRequest = onClose,
|
||||||
properties = DialogProperties(usePlatformDefaultWidth = false),
|
properties = DialogProperties(usePlatformDefaultWidth = false),
|
||||||
) {
|
) {
|
||||||
|
SetDialogToEdgeToEdge()
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
@@ -114,7 +119,7 @@ fun AddSearchRelayListDialog(
|
|||||||
),
|
),
|
||||||
verticalArrangement = Arrangement.SpaceAround,
|
verticalArrangement = Arrangement.SpaceAround,
|
||||||
) {
|
) {
|
||||||
Explanation()
|
Explanation(postViewModel)
|
||||||
|
|
||||||
SearchRelayList(postViewModel, accountViewModel, onClose, nav)
|
SearchRelayList(postViewModel, accountViewModel, onClose, nav)
|
||||||
}
|
}
|
||||||
@@ -123,7 +128,7 @@ fun AddSearchRelayListDialog(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun Explanation() {
|
private fun Explanation(postViewModel: SearchRelayListViewModel) {
|
||||||
Card(modifier = MaterialTheme.colorScheme.imageModifier) {
|
Card(modifier = MaterialTheme.colorScheme.imageModifier) {
|
||||||
Column(modifier = Modifier.padding(16.dp)) {
|
Column(modifier = Modifier.padding(16.dp)) {
|
||||||
Text(
|
Text(
|
||||||
@@ -135,6 +140,23 @@ private fun Explanation() {
|
|||||||
Text(
|
Text(
|
||||||
text = stringRes(id = R.string.search_relays_not_found_examples),
|
text = stringRes(id = R.string.search_relays_not_found_examples),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Spacer(modifier = StdVertSpacer)
|
||||||
|
|
||||||
|
ResetSearchRelaysLonger(postViewModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ResetSearchRelaysLonger(postViewModel: SearchRelayListViewModel) {
|
||||||
|
OutlinedButton(
|
||||||
|
onClick = {
|
||||||
|
postViewModel.deleteAll()
|
||||||
|
Constants.defaultSearchRelaySet.forEach { postViewModel.addRelay(BasicRelaySetupInfo(it, RelayStat())) }
|
||||||
|
postViewModel.loadRelayDocuments()
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
Text(stringRes(R.string.default_relays_longer))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -24,6 +24,7 @@ import androidx.compose.foundation.layout.Arrangement
|
|||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.consumeWindowInsets
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
@@ -49,6 +50,8 @@ import androidx.compose.ui.window.DialogProperties
|
|||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
|
import com.vitorpamplona.amethyst.model.DefaultDMRelayList
|
||||||
|
import com.vitorpamplona.amethyst.model.DefaultSearchRelayList
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.INav
|
import com.vitorpamplona.amethyst.ui.navigation.INav
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.rememberExtendedNav
|
import com.vitorpamplona.amethyst.ui.navigation.rememberExtendedNav
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
@@ -171,19 +174,18 @@ fun MappedAllRelayListView(
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
) { pad ->
|
) { pad ->
|
||||||
Column(
|
LazyColumn(
|
||||||
|
contentPadding = FeedPadding,
|
||||||
modifier =
|
modifier =
|
||||||
Modifier
|
Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.padding(
|
.padding(
|
||||||
16.dp,
|
start = 10.dp,
|
||||||
pad.calculateTopPadding(),
|
end = 10.dp,
|
||||||
16.dp,
|
top = pad.calculateTopPadding(),
|
||||||
pad.calculateBottomPadding(),
|
bottom = pad.calculateBottomPadding(),
|
||||||
),
|
).consumeWindowInsets(pad),
|
||||||
verticalArrangement = Arrangement.SpaceAround,
|
|
||||||
) {
|
) {
|
||||||
LazyColumn(contentPadding = FeedPadding) {
|
|
||||||
item {
|
item {
|
||||||
SettingsCategory(
|
SettingsCategory(
|
||||||
stringRes(R.string.public_home_section),
|
stringRes(R.string.public_home_section),
|
||||||
@@ -202,9 +204,12 @@ fun MappedAllRelayListView(
|
|||||||
renderNip65NotifItems(notifFeedState, nip65ViewModel, accountViewModel, newNav)
|
renderNip65NotifItems(notifFeedState, nip65ViewModel, accountViewModel, newNav)
|
||||||
|
|
||||||
item {
|
item {
|
||||||
SettingsCategory(
|
SettingsCategoryWithButton(
|
||||||
stringRes(R.string.private_inbox_section),
|
stringRes(R.string.private_inbox_section),
|
||||||
stringRes(R.string.private_inbox_section_explainer),
|
stringRes(R.string.private_inbox_section_explainer),
|
||||||
|
action = {
|
||||||
|
ResetDMRelays(dmViewModel)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
renderDMItems(dmFeedState, dmViewModel, accountViewModel, newNav)
|
renderDMItems(dmFeedState, dmViewModel, accountViewModel, newNav)
|
||||||
@@ -259,7 +264,6 @@ fun MappedAllRelayListView(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -280,7 +284,20 @@ fun ResetSearchRelays(postViewModel: SearchRelayListViewModel) {
|
|||||||
OutlinedButton(
|
OutlinedButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
postViewModel.deleteAll()
|
postViewModel.deleteAll()
|
||||||
Constants.defaultSearchRelaySet.forEach { postViewModel.addRelay(BasicRelaySetupInfo(it, RelayStat())) }
|
DefaultSearchRelayList.forEach { postViewModel.addRelay(BasicRelaySetupInfo(it, RelayStat())) }
|
||||||
|
postViewModel.loadRelayDocuments()
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
Text(stringRes(R.string.default_relays))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ResetDMRelays(postViewModel: DMRelayListViewModel) {
|
||||||
|
OutlinedButton(
|
||||||
|
onClick = {
|
||||||
|
postViewModel.deleteAll()
|
||||||
|
DefaultDMRelayList.forEach { postViewModel.addRelay(BasicRelaySetupInfo(it, RelayStat())) }
|
||||||
postViewModel.loadRelayDocuments()
|
postViewModel.loadRelayDocuments()
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
|
@@ -53,6 +53,7 @@ import com.vitorpamplona.amethyst.model.FeatureSetType
|
|||||||
import com.vitorpamplona.amethyst.ui.actions.CrossfadeIfEnabled
|
import com.vitorpamplona.amethyst.ui.actions.CrossfadeIfEnabled
|
||||||
import com.vitorpamplona.amethyst.ui.components.ClickableEmail
|
import com.vitorpamplona.amethyst.ui.components.ClickableEmail
|
||||||
import com.vitorpamplona.amethyst.ui.components.ClickableUrl
|
import com.vitorpamplona.amethyst.ui.components.ClickableUrl
|
||||||
|
import com.vitorpamplona.amethyst.ui.components.SetDialogToEdgeToEdge
|
||||||
import com.vitorpamplona.amethyst.ui.components.TranslatableRichTextViewer
|
import com.vitorpamplona.amethyst.ui.components.TranslatableRichTextViewer
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.INav
|
import com.vitorpamplona.amethyst.ui.navigation.INav
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.rememberExtendedNav
|
import com.vitorpamplona.amethyst.ui.navigation.rememberExtendedNav
|
||||||
@@ -104,6 +105,7 @@ fun RelayInformationDialog(
|
|||||||
dismissOnClickOutside = false,
|
dismissOnClickOutside = false,
|
||||||
),
|
),
|
||||||
) {
|
) {
|
||||||
|
SetDialogToEdgeToEdge()
|
||||||
Surface {
|
Surface {
|
||||||
val color =
|
val color =
|
||||||
remember {
|
remember {
|
||||||
|
@@ -144,12 +144,6 @@ fun AddInboxRelayForDMCard(
|
|||||||
|
|
||||||
Spacer(modifier = StdVertSpacer)
|
Spacer(modifier = StdVertSpacer)
|
||||||
|
|
||||||
Text(
|
|
||||||
text = stringRes(id = R.string.dm_relays_not_found_examples),
|
|
||||||
)
|
|
||||||
|
|
||||||
Spacer(modifier = StdVertSpacer)
|
|
||||||
|
|
||||||
var wantsToEditRelays by remember { mutableStateOf(false) }
|
var wantsToEditRelays by remember { mutableStateOf(false) }
|
||||||
if (wantsToEditRelays) {
|
if (wantsToEditRelays) {
|
||||||
AddDMRelayListDialog({ wantsToEditRelays = false }, accountViewModel, nav = nav)
|
AddDMRelayListDialog({ wantsToEditRelays = false }, accountViewModel, nav = nav)
|
||||||
|
@@ -635,6 +635,7 @@
|
|||||||
<string name="nip05_checking">Checking Nostr address</string>
|
<string name="nip05_checking">Checking Nostr address</string>
|
||||||
<string name="select_deselect_all">Select/Deselect all</string>
|
<string name="select_deselect_all">Select/Deselect all</string>
|
||||||
<string name="default_relays">Default</string>
|
<string name="default_relays">Default</string>
|
||||||
|
<string name="default_relays_longer">Reset to Defaults</string>
|
||||||
<string name="select_a_relay_to_continue">Select a relay to continue</string>
|
<string name="select_a_relay_to_continue">Select a relay to continue</string>
|
||||||
|
|
||||||
<string name="zap_forward_title">Forward Zaps to:</string>
|
<string name="zap_forward_title">Forward Zaps to:</string>
|
||||||
|
Reference in New Issue
Block a user