feat: convert UpdateZapAmountDialog to Route
- Add Route.UpdateZapAmount to Routes.kt with optional nip47 parameter - Create UpdateZapAmountScreen.kt as a Scaffold-based screen using SavingTopBar - Register composableFromBottomArgs<Route.UpdateZapAmount> in AppNavigation.kt - Replace dialog state in AllSettingsScreen with nav.nav(Route.UpdateZapAmount()) - Replace dialog state in ReactionsRow with nav.nav(Route.UpdateZapAmount()) - Remove UpdateZapAmountDialog composables, keeping UpdateZapAmountContent and authenticate helpers https://claude.ai/code/session_01N95sLM14khkJupTfvJcoKq
This commit is contained in:
@@ -107,6 +107,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.RelayInformationScre
|
|||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.search.SearchScreen
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.search.SearchScreen
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.AllSettingsScreen
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.AllSettingsScreen
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.NIP47SetupScreen
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.NIP47SetupScreen
|
||||||
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.UpdateZapAmountScreen
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.SecurityFiltersScreen
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.SecurityFiltersScreen
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.SettingsScreen
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.SettingsScreen
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.UserSettingsScreen
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.UserSettingsScreen
|
||||||
@@ -172,6 +173,7 @@ fun AppNavigation(
|
|||||||
composableFromEnd<Route.Settings> { SettingsScreen(accountViewModel, nav) }
|
composableFromEnd<Route.Settings> { SettingsScreen(accountViewModel, nav) }
|
||||||
composableFromEnd<Route.UserSettings> { UserSettingsScreen(accountViewModel, nav) }
|
composableFromEnd<Route.UserSettings> { UserSettingsScreen(accountViewModel, nav) }
|
||||||
composableFromBottomArgs<Route.Nip47NWCSetup> { NIP47SetupScreen(accountViewModel, nav, it.nip47) }
|
composableFromBottomArgs<Route.Nip47NWCSetup> { NIP47SetupScreen(accountViewModel, nav, it.nip47) }
|
||||||
|
composableFromBottomArgs<Route.UpdateZapAmount> { UpdateZapAmountScreen(accountViewModel, nav, it.nip47) }
|
||||||
composableFromEndArgs<Route.EditRelays> { AllRelayListScreen(accountViewModel, nav) }
|
composableFromEndArgs<Route.EditRelays> { AllRelayListScreen(accountViewModel, nav) }
|
||||||
composableFromEndArgs<Route.EditMediaServers> { AllMediaServersScreen(accountViewModel, nav) }
|
composableFromEndArgs<Route.EditMediaServers> { AllMediaServersScreen(accountViewModel, nav) }
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,10 @@ sealed class Route {
|
|||||||
val nip47: String? = null,
|
val nip47: String? = null,
|
||||||
) : Route()
|
) : Route()
|
||||||
|
|
||||||
|
@Serializable data class UpdateZapAmount(
|
||||||
|
val nip47: String? = null,
|
||||||
|
) : Route()
|
||||||
|
|
||||||
@Serializable data class Profile(
|
@Serializable data class Profile(
|
||||||
val id: String,
|
val id: String,
|
||||||
) : Route()
|
) : Route()
|
||||||
@@ -352,6 +356,7 @@ fun getRouteWithArguments(navController: NavHostController): Route? {
|
|||||||
dest.hasRoute<Route.EditRelays>() -> entry.toRoute<Route.EditRelays>()
|
dest.hasRoute<Route.EditRelays>() -> entry.toRoute<Route.EditRelays>()
|
||||||
dest.hasRoute<Route.EditMediaServers>() -> entry.toRoute<Route.EditMediaServers>()
|
dest.hasRoute<Route.EditMediaServers>() -> entry.toRoute<Route.EditMediaServers>()
|
||||||
dest.hasRoute<Route.Nip47NWCSetup>() -> entry.toRoute<Route.Nip47NWCSetup>()
|
dest.hasRoute<Route.Nip47NWCSetup>() -> entry.toRoute<Route.Nip47NWCSetup>()
|
||||||
|
dest.hasRoute<Route.UpdateZapAmount>() -> entry.toRoute<Route.UpdateZapAmount>()
|
||||||
dest.hasRoute<Route.Room>() -> entry.toRoute<Route.Room>()
|
dest.hasRoute<Route.Room>() -> entry.toRoute<Route.Room>()
|
||||||
dest.hasRoute<Route.NewShortNote>() -> entry.toRoute<Route.NewShortNote>()
|
dest.hasRoute<Route.NewShortNote>() -> entry.toRoute<Route.NewShortNote>()
|
||||||
dest.hasRoute<Route.VoiceReply>() -> entry.toRoute<Route.VoiceReply>()
|
dest.hasRoute<Route.VoiceReply>() -> entry.toRoute<Route.VoiceReply>()
|
||||||
|
|||||||
@@ -1039,7 +1039,6 @@ fun ZapReaction(
|
|||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
var wantsToZap by remember { mutableStateOf(false) }
|
var wantsToZap by remember { mutableStateOf(false) }
|
||||||
var wantsToChangeZapAmount by remember { mutableStateOf(false) }
|
|
||||||
var wantsToSetCustomZap by remember { mutableStateOf(false) }
|
var wantsToSetCustomZap by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
@@ -1090,7 +1089,7 @@ fun ZapReaction(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLongClick = { wantsToChangeZapAmount = true },
|
onLongClick = { nav.nav(Route.UpdateZapAmount()) },
|
||||||
onDoubleClick = { wantsToSetCustomZap = true },
|
onDoubleClick = { wantsToSetCustomZap = true },
|
||||||
),
|
),
|
||||||
) {
|
) {
|
||||||
@@ -1107,7 +1106,7 @@ fun ZapReaction(
|
|||||||
onChangeAmount = {
|
onChangeAmount = {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
wantsToZap = false
|
wantsToZap = false
|
||||||
wantsToChangeZapAmount = true
|
nav.nav(Route.UpdateZapAmount())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError = { _, message, user ->
|
onError = { _, message, user ->
|
||||||
@@ -1133,13 +1132,6 @@ fun ZapReaction(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wantsToChangeZapAmount) {
|
|
||||||
UpdateZapAmountDialog(
|
|
||||||
onClose = { wantsToChangeZapAmount = false },
|
|
||||||
accountViewModel = accountViewModel,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wantsToSetCustomZap) {
|
if (wantsToSetCustomZap) {
|
||||||
ZapCustomDialog(
|
ZapCustomDialog(
|
||||||
onZapStarts = { zapStartingTime = TimeUtils.now() },
|
onZapStarts = { zapStartingTime = TimeUtils.now() },
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ import androidx.compose.material3.Icon
|
|||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.OutlinedTextField
|
import androidx.compose.material3.OutlinedTextField
|
||||||
import androidx.compose.material3.Surface
|
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
@@ -78,14 +77,9 @@ import androidx.compose.ui.text.input.PasswordVisualTransformation
|
|||||||
import androidx.compose.ui.text.input.VisualTransformation
|
import androidx.compose.ui.text.input.VisualTransformation
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.window.Dialog
|
|
||||||
import androidx.compose.ui.window.DialogProperties
|
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.ui.components.TextSpinner
|
import com.vitorpamplona.amethyst.ui.components.TextSpinner
|
||||||
import com.vitorpamplona.amethyst.ui.components.TitleExplainer
|
import com.vitorpamplona.amethyst.ui.components.TitleExplainer
|
||||||
import com.vitorpamplona.amethyst.ui.note.buttons.CloseButton
|
|
||||||
import com.vitorpamplona.amethyst.ui.note.buttons.SaveButton
|
|
||||||
import com.vitorpamplona.amethyst.ui.painterRes
|
import com.vitorpamplona.amethyst.ui.painterRes
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.keyBackup.getFragmentActivity
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.keyBackup.getFragmentActivity
|
||||||
@@ -99,70 +93,6 @@ import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
|||||||
import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent
|
import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent
|
||||||
import kotlinx.collections.immutable.toImmutableList
|
import kotlinx.collections.immutable.toImmutableList
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun UpdateZapAmountDialog(
|
|
||||||
onClose: () -> Unit,
|
|
||||||
nip47uri: String? = null,
|
|
||||||
accountViewModel: AccountViewModel,
|
|
||||||
) {
|
|
||||||
val postViewModel: UpdateZapAmountViewModel = viewModel()
|
|
||||||
postViewModel.init(accountViewModel)
|
|
||||||
|
|
||||||
LaunchedEffect(accountViewModel, postViewModel) {
|
|
||||||
postViewModel.load()
|
|
||||||
}
|
|
||||||
UpdateZapAmountDialog(postViewModel, onClose, nip47uri, accountViewModel)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun UpdateZapAmountDialog(
|
|
||||||
postViewModel: UpdateZapAmountViewModel,
|
|
||||||
onClose: () -> Unit,
|
|
||||||
nip47uri: String? = null,
|
|
||||||
accountViewModel: AccountViewModel,
|
|
||||||
) {
|
|
||||||
Dialog(
|
|
||||||
onDismissRequest = { onClose() },
|
|
||||||
properties =
|
|
||||||
DialogProperties(
|
|
||||||
usePlatformDefaultWidth = false,
|
|
||||||
dismissOnClickOutside = false,
|
|
||||||
decorFitsSystemWindows = false,
|
|
||||||
),
|
|
||||||
) {
|
|
||||||
Surface(
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
) {
|
|
||||||
Column {
|
|
||||||
Row(
|
|
||||||
modifier = Modifier.fillMaxWidth().padding(10.dp),
|
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
) {
|
|
||||||
CloseButton(
|
|
||||||
onPress = {
|
|
||||||
postViewModel.cancel()
|
|
||||||
onClose()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
SaveButton(
|
|
||||||
onPost = {
|
|
||||||
postViewModel.sendPost()
|
|
||||||
onClose()
|
|
||||||
},
|
|
||||||
isActive = postViewModel.hasChanged(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(10.dp))
|
|
||||||
|
|
||||||
UpdateZapAmountContent(postViewModel, onClose, nip47uri, accountViewModel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@OptIn(ExperimentalLayoutApi::class)
|
@OptIn(ExperimentalLayoutApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun UpdateZapAmountContent(
|
fun UpdateZapAmountContent(
|
||||||
|
|||||||
+1
-10
@@ -58,7 +58,6 @@ import com.vitorpamplona.amethyst.ui.navigation.navs.INav
|
|||||||
import com.vitorpamplona.amethyst.ui.navigation.routes.Route
|
import com.vitorpamplona.amethyst.ui.navigation.routes.Route
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.topbars.TopBarWithBackButton
|
import com.vitorpamplona.amethyst.ui.navigation.topbars.TopBarWithBackButton
|
||||||
import com.vitorpamplona.amethyst.ui.note.UpdateReactionTypeDialog
|
import com.vitorpamplona.amethyst.ui.note.UpdateReactionTypeDialog
|
||||||
import com.vitorpamplona.amethyst.ui.note.UpdateZapAmountDialog
|
|
||||||
import com.vitorpamplona.amethyst.ui.painterRes
|
import com.vitorpamplona.amethyst.ui.painterRes
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.keyBackup.AccountBackupDialog
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.keyBackup.AccountBackupDialog
|
||||||
@@ -85,7 +84,6 @@ fun AllSettingsScreen(
|
|||||||
val tint = MaterialTheme.colorScheme.onBackground
|
val tint = MaterialTheme.colorScheme.onBackground
|
||||||
|
|
||||||
var showReactionDialog by remember { mutableStateOf(false) }
|
var showReactionDialog by remember { mutableStateOf(false) }
|
||||||
var wantsToChangeZapAmount by remember { mutableStateOf(false) }
|
|
||||||
|
|
||||||
if (showReactionDialog) {
|
if (showReactionDialog) {
|
||||||
UpdateReactionTypeDialog(
|
UpdateReactionTypeDialog(
|
||||||
@@ -95,13 +93,6 @@ fun AllSettingsScreen(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wantsToChangeZapAmount) {
|
|
||||||
UpdateZapAmountDialog(
|
|
||||||
onClose = { wantsToChangeZapAmount = false },
|
|
||||||
accountViewModel = accountViewModel,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
TopBarWithBackButton(stringRes(id = R.string.settings), nav::popBack)
|
TopBarWithBackButton(stringRes(id = R.string.settings), nav::popBack)
|
||||||
@@ -135,7 +126,7 @@ fun AllSettingsScreen(
|
|||||||
title = R.string.zaps,
|
title = R.string.zaps,
|
||||||
icon = Icons.Outlined.Bolt,
|
icon = Icons.Outlined.Bolt,
|
||||||
tint = tint,
|
tint = tint,
|
||||||
onClick = { wantsToChangeZapAmount = true },
|
onClick = { nav.nav(Route.UpdateZapAmount()) },
|
||||||
)
|
)
|
||||||
HorizontalDivider()
|
HorizontalDivider()
|
||||||
SettingsNavigationRow(
|
SettingsNavigationRow(
|
||||||
|
|||||||
+85
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2025 Vitor Pamplona
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||||
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package com.vitorpamplona.amethyst.ui.screen.loggedIn.settings
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
|
import androidx.compose.material3.Scaffold
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
|
import com.vitorpamplona.amethyst.R
|
||||||
|
import com.vitorpamplona.amethyst.ui.navigation.navs.INav
|
||||||
|
import com.vitorpamplona.amethyst.ui.navigation.topbars.SavingTopBar
|
||||||
|
import com.vitorpamplona.amethyst.ui.note.UpdateZapAmountContent
|
||||||
|
import com.vitorpamplona.amethyst.ui.note.UpdateZapAmountViewModel
|
||||||
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun UpdateZapAmountScreen(
|
||||||
|
accountViewModel: AccountViewModel,
|
||||||
|
nav: INav,
|
||||||
|
nip47: String? = null,
|
||||||
|
) {
|
||||||
|
val postViewModel: UpdateZapAmountViewModel = viewModel()
|
||||||
|
postViewModel.init(accountViewModel)
|
||||||
|
|
||||||
|
LaunchedEffect(accountViewModel, postViewModel) {
|
||||||
|
postViewModel.load()
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateZapAmountScreen(postViewModel, accountViewModel, nav, nip47)
|
||||||
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
|
@Composable
|
||||||
|
fun UpdateZapAmountScreen(
|
||||||
|
postViewModel: UpdateZapAmountViewModel,
|
||||||
|
accountViewModel: AccountViewModel,
|
||||||
|
nav: INav,
|
||||||
|
nip47: String? = null,
|
||||||
|
) {
|
||||||
|
Scaffold(
|
||||||
|
topBar = {
|
||||||
|
SavingTopBar(
|
||||||
|
titleRes = R.string.zaps,
|
||||||
|
isActive = postViewModel::hasChanged,
|
||||||
|
onCancel = {
|
||||||
|
postViewModel.cancel()
|
||||||
|
nav.popBack()
|
||||||
|
},
|
||||||
|
onPost = {
|
||||||
|
postViewModel.sendPost()
|
||||||
|
nav.popBack()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
Column(Modifier.padding(it)) {
|
||||||
|
UpdateZapAmountContent(postViewModel, onClose = {
|
||||||
|
postViewModel.cancel()
|
||||||
|
nav.popBack()
|
||||||
|
}, nip47, accountViewModel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user