Makes sure the Zap the Devs dialog doesn't appear behind the status bar
This commit is contained in:
@@ -28,13 +28,15 @@ import androidx.compose.foundation.layout.Row
|
|||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
import androidx.compose.foundation.verticalScroll
|
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
import androidx.compose.material3.ButtonDefaults
|
import androidx.compose.material3.ButtonDefaults
|
||||||
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.OutlinedTextField
|
import androidx.compose.material3.OutlinedTextField
|
||||||
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Surface
|
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
|
||||||
@@ -42,6 +44,7 @@ import androidx.compose.runtime.LaunchedEffect
|
|||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
@@ -68,12 +71,12 @@ import com.vitorpamplona.amethyst.ui.components.SetDialogToEdgeToEdge
|
|||||||
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.components.toasts.multiline.UserBasedErrorMessage
|
import com.vitorpamplona.amethyst.ui.components.toasts.multiline.UserBasedErrorMessage
|
||||||
|
import com.vitorpamplona.amethyst.ui.navigation.topbars.TopBarWithBackButton
|
||||||
import com.vitorpamplona.amethyst.ui.note.buttons.CloseButton
|
import com.vitorpamplona.amethyst.ui.note.buttons.CloseButton
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.stringRes
|
import com.vitorpamplona.amethyst.ui.stringRes
|
||||||
import com.vitorpamplona.amethyst.ui.theme.ButtonBorder
|
import com.vitorpamplona.amethyst.ui.theme.ButtonBorder
|
||||||
import com.vitorpamplona.amethyst.ui.theme.DoubleHorzSpacer
|
import com.vitorpamplona.amethyst.ui.theme.DoubleHorzSpacer
|
||||||
import com.vitorpamplona.amethyst.ui.theme.DoubleVertSpacer
|
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size10dp
|
import com.vitorpamplona.amethyst.ui.theme.Size10dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size55dp
|
import com.vitorpamplona.amethyst.ui.theme.Size55dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer
|
import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer
|
||||||
@@ -281,6 +284,7 @@ fun ZapButton(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun PayViaIntentDialog(
|
fun PayViaIntentDialog(
|
||||||
payingInvoices: ImmutableList<ZapPaymentHandler.Payable>,
|
payingInvoices: ImmutableList<ZapPaymentHandler.Payable>,
|
||||||
@@ -289,9 +293,8 @@ fun PayViaIntentDialog(
|
|||||||
onError: (UserBasedErrorMessage) -> Unit,
|
onError: (UserBasedErrorMessage) -> Unit,
|
||||||
justShowError: (UserBasedErrorMessage) -> Unit,
|
justShowError: (UserBasedErrorMessage) -> Unit,
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
|
||||||
|
|
||||||
if (payingInvoices.size == 1) {
|
if (payingInvoices.size == 1) {
|
||||||
|
val context = LocalContext.current
|
||||||
val payable = payingInvoices.first()
|
val payable = payingInvoices.first()
|
||||||
payViaIntent(payable.invoice, context, onClose) {
|
payViaIntent(payable.invoice, context, onClose) {
|
||||||
onError(UserBasedErrorMessage(it, payable.info.user))
|
onError(UserBasedErrorMessage(it, payable.info.user))
|
||||||
@@ -307,71 +310,27 @@ fun PayViaIntentDialog(
|
|||||||
),
|
),
|
||||||
) {
|
) {
|
||||||
SetDialogToEdgeToEdge()
|
SetDialogToEdgeToEdge()
|
||||||
Surface {
|
|
||||||
Column(modifier = Modifier.padding(10.dp).verticalScroll(rememberScrollState())) {
|
|
||||||
Row(
|
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
) {
|
|
||||||
CloseButton(onPress = onClose)
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer(modifier = DoubleVertSpacer)
|
Scaffold(
|
||||||
|
topBar = {
|
||||||
payingInvoices.forEachIndexed { index, payable ->
|
TopBarWithBackButton(stringRes(id = R.string.manual_zaps), onClose)
|
||||||
val paid = remember { mutableStateOf(false) }
|
},
|
||||||
|
) { pad ->
|
||||||
Row(
|
LazyColumn(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
Modifier.padding(
|
||||||
modifier = Modifier.padding(vertical = Size10dp),
|
16.dp,
|
||||||
) {
|
pad.calculateTopPadding(),
|
||||||
if (payable.info.user != null) {
|
16.dp,
|
||||||
BaseUserPicture(payable.info.user, Size55dp, accountViewModel = accountViewModel)
|
pad.calculateBottomPadding(),
|
||||||
} else {
|
),
|
||||||
DisplayBlankAuthor(size = Size55dp, accountViewModel = accountViewModel)
|
) {
|
||||||
}
|
itemsIndexed(
|
||||||
|
payingInvoices,
|
||||||
Spacer(modifier = DoubleHorzSpacer)
|
key = { _: Int, invoice: ZapPaymentHandler.Payable ->
|
||||||
|
invoice.invoice
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
},
|
||||||
if (payable.info.user != null) {
|
) { index, payable ->
|
||||||
UsernameDisplay(payable.info.user, accountViewModel = accountViewModel)
|
DisplayPayable(index, payable, justShowError, accountViewModel)
|
||||||
} else {
|
|
||||||
Text(
|
|
||||||
text = stringRes(id = R.string.wallet_number, index + 1),
|
|
||||||
maxLines = 1,
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
fontSize = 18.sp,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Row {
|
|
||||||
Text(
|
|
||||||
text = showAmount((payable.amountMilliSats / 1000.0f).toBigDecimal()),
|
|
||||||
maxLines = 1,
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
fontSize = 18.sp,
|
|
||||||
)
|
|
||||||
Spacer(modifier = StdHorzSpacer)
|
|
||||||
Text(
|
|
||||||
text = stringRes(id = R.string.sats),
|
|
||||||
maxLines = 1,
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
fontSize = 18.sp,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer(modifier = DoubleHorzSpacer)
|
|
||||||
|
|
||||||
PayButton(isActive = !paid.value) {
|
|
||||||
payViaIntent(payable.invoice, context, { paid.value = true }) {
|
|
||||||
justShowError(UserBasedErrorMessage(it, null))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -379,6 +338,69 @@ fun PayViaIntentDialog(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun DisplayPayable(
|
||||||
|
index: Int,
|
||||||
|
payable: ZapPaymentHandler.Payable,
|
||||||
|
justShowError: (UserBasedErrorMessage) -> Unit,
|
||||||
|
accountViewModel: AccountViewModel,
|
||||||
|
) {
|
||||||
|
val paid = rememberSaveable(payable) { mutableStateOf(false) }
|
||||||
|
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
modifier = Modifier.padding(vertical = Size10dp),
|
||||||
|
) {
|
||||||
|
if (payable.info.user != null) {
|
||||||
|
BaseUserPicture(payable.info.user, Size55dp, accountViewModel = accountViewModel)
|
||||||
|
} else {
|
||||||
|
DisplayBlankAuthor(size = Size55dp, accountViewModel = accountViewModel)
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = DoubleHorzSpacer)
|
||||||
|
|
||||||
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
|
if (payable.info.user != null) {
|
||||||
|
UsernameDisplay(payable.info.user, accountViewModel = accountViewModel)
|
||||||
|
} else {
|
||||||
|
Text(
|
||||||
|
text = stringRes(id = R.string.wallet_number, index + 1),
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
fontSize = 18.sp,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Row {
|
||||||
|
Text(
|
||||||
|
text = showAmount((payable.amountMilliSats / 1000.0f).toBigDecimal()),
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
fontSize = 18.sp,
|
||||||
|
)
|
||||||
|
Spacer(modifier = StdHorzSpacer)
|
||||||
|
Text(
|
||||||
|
text = stringRes(id = R.string.sats),
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
fontSize = 18.sp,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = DoubleHorzSpacer)
|
||||||
|
val context = LocalContext.current
|
||||||
|
|
||||||
|
PayButton(isActive = !paid.value) {
|
||||||
|
payViaIntent(payable.invoice, context, { paid.value = true }) {
|
||||||
|
justShowError(UserBasedErrorMessage(it, null))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun payViaIntent(
|
fun payViaIntent(
|
||||||
invoice: String,
|
invoice: String,
|
||||||
context: Context,
|
context: Context,
|
||||||
|
|||||||
@@ -378,6 +378,7 @@
|
|||||||
<string name="report_dialog_title">Block and Report</string>
|
<string name="report_dialog_title">Block and Report</string>
|
||||||
<string name="block_only">Block</string>
|
<string name="block_only">Block</string>
|
||||||
|
|
||||||
|
<string name="manual_zaps">Manual Zap Splits</string>
|
||||||
<string name="bookmarks">Bookmarks</string>
|
<string name="bookmarks">Bookmarks</string>
|
||||||
<string name="drafts">Drafts</string>
|
<string name="drafts">Drafts</string>
|
||||||
<string name="private_bookmarks">Private Bookmarks</string>
|
<string name="private_bookmarks">Private Bookmarks</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user