bug fixes
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.bitcointxoko.gudariwallet.ui
|
||||
|
||||
import android.content.ClipboardManager
|
||||
import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
import timber.log.Timber
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.tween
|
||||
@@ -72,7 +74,7 @@ import com.bitcointxoko.gudariwallet.ui.receive.ReceiveScreen
|
||||
import com.bitcointxoko.gudariwallet.ui.send.SendScreen
|
||||
import com.bitcointxoko.gudariwallet.ui.send.SendStrings
|
||||
import com.bitcointxoko.gudariwallet.util.SendInputType
|
||||
import com.bitcointxoko.gudariwallet.data.ContactRepository
|
||||
import com.bitcointxoko.gudariwallet.data.PaymentFeedRepository
|
||||
import com.bitcointxoko.gudariwallet.ui.contacts.ContactDetailScreen
|
||||
import com.bitcointxoko.gudariwallet.ui.contacts.ContactDetailViewModel
|
||||
import kotlinx.coroutines.delay
|
||||
@@ -90,13 +92,14 @@ sealed class TabItem(val route: String, val icon: ImageVector) {
|
||||
private const val ROUTE_HOME = "home"
|
||||
private const val ROUTE_SCANNER = "scanner"
|
||||
private const val ROUTE_HISTORY = "history"
|
||||
private const val ROUTE_PAYMENT_DETAIL = "payment_detail/{checkingId}"
|
||||
private const val ROUTE_PAYMENT_DETAIL = "payment_detail/{paymentHash}"
|
||||
private const val ROUTE_NWC = "nwc"
|
||||
private const val ROUTE_CONNECTION_DETAIL = "connection_detail/{pubkey}"
|
||||
private const val ROUTE_CONTACTS = "contacts"
|
||||
private const val ROUTE_CONTACT_DETAIL = "contacts/{contactId}"
|
||||
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
|
||||
@Composable
|
||||
fun WalletScreen(
|
||||
vm : WalletViewModel,
|
||||
@@ -131,10 +134,17 @@ fun WalletScreen(
|
||||
aliasRepo = vm.aliasRepo,
|
||||
paymentCache = vm.paymentCache,
|
||||
contactRepo = vm.contactRepo,
|
||||
feedRepository = PaymentFeedRepository(
|
||||
paymentCache = vm.paymentCache,
|
||||
contactRepo = vm.contactRepo,
|
||||
nodeAliasRepository = vm.aliasRepo,
|
||||
fiatVm = vm.fiatVm
|
||||
),
|
||||
fiatCurrency = vm.selectedCurrency,
|
||||
fiatSatsPerUnit = vm.fiatSatsPerUnit
|
||||
)
|
||||
}
|
||||
|
||||
val historyVm: HistoryViewModel = viewModel(factory = historyFactory)
|
||||
val nwcVm: NwcViewModel = viewModel(
|
||||
factory = NwcViewModel.Factory(repo = vm.repo, cache = vm.nwcCache) // same pattern as historyVm
|
||||
@@ -367,18 +377,18 @@ fun WalletScreen(
|
||||
ReceiveScreen(
|
||||
vm = vm,
|
||||
nfcVm = nfcVm,
|
||||
onNavigateToPaymentDetail = { checkingId ->
|
||||
navController.navigate("payment_detail/$checkingId")
|
||||
onNavigateToPaymentDetail = { paymentHash ->
|
||||
navController.navigate("payment_detail/$paymentHash")
|
||||
}
|
||||
)
|
||||
}
|
||||
composable(TabItem.Send.route) {
|
||||
SendScreen(
|
||||
vm = vm,
|
||||
vm = vm,
|
||||
nfcVm = nfcVm,
|
||||
onViewDetails = { checkingId, record ->
|
||||
onViewDetails = { paymentHash, record ->
|
||||
historyVm.primePayment(record)
|
||||
navController.navigate("payment_detail/$checkingId") {
|
||||
navController.navigate("payment_detail/$paymentHash") {
|
||||
launchSingleTop = true
|
||||
}
|
||||
},
|
||||
@@ -422,34 +432,30 @@ fun WalletScreen(
|
||||
onClose = {
|
||||
navController.popBackStack(ROUTE_HOME, inclusive = false)
|
||||
},
|
||||
onPaymentClick = { payment ->
|
||||
navController.navigate("payment_detail/${payment.checkingId}")
|
||||
onPaymentClick = { item ->
|
||||
navController.navigate("payment_detail/${item.paymentHash}")
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// Payment detail — back → history (natural back stack)
|
||||
composable(
|
||||
route = ROUTE_PAYMENT_DETAIL,
|
||||
arguments = listOf(navArgument("checkingId") { type = NavType.StringType })
|
||||
route = ROUTE_PAYMENT_DETAIL,
|
||||
arguments = listOf(navArgument("paymentHash") { type = NavType.StringType })
|
||||
) { backStackEntry ->
|
||||
val checkingId = backStackEntry.arguments?.getString("checkingId") ?: ""
|
||||
val historyState by historyVm.filteredState.collectAsStateWithLifecycle()
|
||||
val fallbackState by historyVm.state.collectAsStateWithLifecycle()
|
||||
val payment = remember(historyState, fallbackState, checkingId) {
|
||||
(historyState as? HistoryState.Success)
|
||||
?.payments?.firstOrNull { it.checkingId == checkingId }
|
||||
?: (fallbackState as? HistoryState.Success)
|
||||
?.payments?.firstOrNull { it.checkingId == checkingId }
|
||||
val paymentHash = backStackEntry.arguments?.getString("paymentHash") ?: ""
|
||||
val feedItems by historyVm.feedItems.collectAsStateWithLifecycle()
|
||||
val item = remember(feedItems, paymentHash) {
|
||||
historyVm.findPayment(paymentHash)
|
||||
}
|
||||
if (payment != null) {
|
||||
if (item != null) {
|
||||
PaymentDetailScreen(
|
||||
payment = payment,
|
||||
vm = historyVm,
|
||||
onBack = { navController.popBackStack() }
|
||||
item = item,
|
||||
vm = historyVm,
|
||||
onBack = { navController.popBackStack() }
|
||||
)
|
||||
} else {
|
||||
LaunchedEffect(checkingId) { historyVm.refresh() }
|
||||
LaunchedEffect(paymentHash) { historyVm.refresh() }
|
||||
Box(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentAlignment = Alignment.Center
|
||||
|
||||
Reference in New Issue
Block a user