Adds UI Feedback for Custom Zaps
This commit is contained in:
@@ -989,11 +989,29 @@ fun ZapReaction(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wantsToChangeZapAmount) {
|
if (wantsToChangeZapAmount) {
|
||||||
UpdateZapAmountDialog({ wantsToChangeZapAmount = false }, accountViewModel = accountViewModel)
|
UpdateZapAmountDialog(
|
||||||
|
onClose = { wantsToChangeZapAmount = false },
|
||||||
|
accountViewModel = accountViewModel
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wantsToSetCustomZap) {
|
if (wantsToSetCustomZap) {
|
||||||
ZapCustomDialog({ wantsToSetCustomZap = false }, accountViewModel, baseNote)
|
ZapCustomDialog(
|
||||||
|
onClose = { wantsToSetCustomZap = false },
|
||||||
|
onError = {
|
||||||
|
scope.launch {
|
||||||
|
zappingProgress = 0f
|
||||||
|
showErrorMessageDialog = it
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onProgress = {
|
||||||
|
scope.launch(Dispatchers.Main) {
|
||||||
|
zappingProgress = it
|
||||||
|
}
|
||||||
|
},
|
||||||
|
accountViewModel = accountViewModel,
|
||||||
|
baseNote = baseNote
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zappingProgress > 0.00001 && zappingProgress < 0.99999) {
|
if (zappingProgress > 0.00001 && zappingProgress < 0.99999) {
|
||||||
|
|||||||
@@ -197,7 +197,11 @@ class UpdateZapAmountViewModel(val account: Account) : ViewModel() {
|
|||||||
|
|
||||||
@OptIn(ExperimentalLayoutApi::class)
|
@OptIn(ExperimentalLayoutApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun UpdateZapAmountDialog(onClose: () -> Unit, nip47uri: String? = null, accountViewModel: AccountViewModel) {
|
fun UpdateZapAmountDialog(
|
||||||
|
onClose: () -> Unit,
|
||||||
|
nip47uri: String? = null,
|
||||||
|
accountViewModel: AccountViewModel
|
||||||
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.vitorpamplona.amethyst.ui.note
|
package com.vitorpamplona.amethyst.ui.note
|
||||||
|
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
import androidx.compose.material.*
|
import androidx.compose.material.*
|
||||||
@@ -31,8 +30,6 @@ import com.vitorpamplona.amethyst.ui.theme.ButtonBorder
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
||||||
import com.vitorpamplona.quartz.events.LnZapEvent
|
import com.vitorpamplona.quartz.events.LnZapEvent
|
||||||
import kotlinx.collections.immutable.toImmutableList
|
import kotlinx.collections.immutable.toImmutableList
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
|
|
||||||
class ZapOptionstViewModel : ViewModel() {
|
class ZapOptionstViewModel : ViewModel() {
|
||||||
private var account: Account? = null
|
private var account: Account? = null
|
||||||
@@ -61,17 +58,20 @@ class ZapOptionstViewModel : ViewModel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ZapCustomDialog(onClose: () -> Unit, accountViewModel: AccountViewModel, baseNote: Note) {
|
fun ZapCustomDialog(
|
||||||
|
onClose: () -> Unit,
|
||||||
|
onError: (text: String) -> Unit,
|
||||||
|
onProgress: (percent: Float) -> Unit,
|
||||||
|
accountViewModel: AccountViewModel,
|
||||||
|
baseNote: Note
|
||||||
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val scope = rememberCoroutineScope()
|
|
||||||
val postViewModel: ZapOptionstViewModel = viewModel()
|
val postViewModel: ZapOptionstViewModel = viewModel()
|
||||||
|
|
||||||
LaunchedEffect(accountViewModel) {
|
LaunchedEffect(accountViewModel) {
|
||||||
postViewModel.load(accountViewModel.account)
|
postViewModel.load(accountViewModel.account)
|
||||||
}
|
}
|
||||||
|
|
||||||
var zappingProgress by remember { mutableStateOf(0f) }
|
|
||||||
|
|
||||||
val zapTypes = listOf(
|
val zapTypes = listOf(
|
||||||
Triple(LnZapEvent.ZapType.PUBLIC, stringResource(id = R.string.zap_type_public), stringResource(id = R.string.zap_type_public_explainer)),
|
Triple(LnZapEvent.ZapType.PUBLIC, stringResource(id = R.string.zap_type_public), stringResource(id = R.string.zap_type_public_explainer)),
|
||||||
Triple(LnZapEvent.ZapType.PRIVATE, stringResource(id = R.string.zap_type_private), stringResource(id = R.string.zap_type_private_explainer)),
|
Triple(LnZapEvent.ZapType.PRIVATE, stringResource(id = R.string.zap_type_private), stringResource(id = R.string.zap_type_private_explainer)),
|
||||||
@@ -111,17 +111,8 @@ fun ZapCustomDialog(onClose: () -> Unit, accountViewModel: AccountViewModel, bas
|
|||||||
null,
|
null,
|
||||||
postViewModel.customMessage.text,
|
postViewModel.customMessage.text,
|
||||||
context,
|
context,
|
||||||
onError = {
|
onError = onError,
|
||||||
zappingProgress = 0f
|
onProgress = onProgress,
|
||||||
scope.launch {
|
|
||||||
Toast.makeText(context, it, Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onProgress = {
|
|
||||||
scope.launch(Dispatchers.Main) {
|
|
||||||
zappingProgress = it
|
|
||||||
}
|
|
||||||
},
|
|
||||||
zapType = selectedZapType
|
zapType = selectedZapType
|
||||||
)
|
)
|
||||||
onClose()
|
onClose()
|
||||||
|
|||||||
Reference in New Issue
Block a user