2023-12-11 01:20:32 -08:00
|
|
|
@file:Suppress("ktlint:standard:filename")
|
2022-06-22 02:48:19 -07:00
|
|
|
|
2023-02-28 05:54:07 -08:00
|
|
|
package co.electriccoin.zcash.ui.screen.receive
|
2022-04-25 05:35:30 -07:00
|
|
|
|
|
|
|
import androidx.activity.ComponentActivity
|
|
|
|
import androidx.activity.viewModels
|
|
|
|
import androidx.compose.runtime.Composable
|
2022-12-22 00:38:02 -08:00
|
|
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
2023-02-17 03:05:23 -08:00
|
|
|
import cash.z.ecc.android.sdk.model.WalletAddresses
|
2023-12-06 06:29:12 -08:00
|
|
|
import co.electriccoin.zcash.ui.common.viewmodel.WalletViewModel
|
2023-12-18 05:31:25 -08:00
|
|
|
import co.electriccoin.zcash.ui.design.component.CircularScreenProgressIndicator
|
2023-02-28 05:54:07 -08:00
|
|
|
import co.electriccoin.zcash.ui.screen.receive.view.Receive
|
2022-04-25 05:35:30 -07:00
|
|
|
|
|
|
|
@Composable
|
2023-02-28 05:54:07 -08:00
|
|
|
internal fun WrapReceive(
|
2022-04-25 05:35:30 -07:00
|
|
|
activity: ComponentActivity,
|
2023-12-18 05:31:25 -08:00
|
|
|
onSettings: () -> Unit,
|
2022-04-25 05:35:30 -07:00
|
|
|
onAddressDetails: () -> Unit,
|
|
|
|
) {
|
|
|
|
val viewModel by activity.viewModels<WalletViewModel>()
|
2022-12-22 00:38:02 -08:00
|
|
|
val walletAddresses = viewModel.addresses.collectAsStateWithLifecycle().value
|
2022-04-25 05:35:30 -07:00
|
|
|
|
2023-02-28 05:54:07 -08:00
|
|
|
WrapReceive(
|
2022-04-25 05:35:30 -07:00
|
|
|
walletAddresses,
|
2023-12-18 05:31:25 -08:00
|
|
|
onSettings = onSettings,
|
2022-04-25 05:35:30 -07:00
|
|
|
onAddressDetails = onAddressDetails,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
@Composable
|
2023-02-28 05:54:07 -08:00
|
|
|
internal fun WrapReceive(
|
2022-04-25 05:35:30 -07:00
|
|
|
walletAddresses: WalletAddresses?,
|
2023-12-18 05:31:25 -08:00
|
|
|
onSettings: () -> Unit,
|
2022-04-25 05:35:30 -07:00
|
|
|
onAddressDetails: () -> Unit,
|
|
|
|
) {
|
|
|
|
if (null == walletAddresses) {
|
2024-01-02 00:03:12 -08:00
|
|
|
// TODO [#1146]: Consider moving CircularScreenProgressIndicator from Android layer to View layer
|
|
|
|
// TODO [#1146]: Improve this by allowing screen composition and updating it after the data is available
|
|
|
|
// TODO [#1146]: https://github.com/Electric-Coin-Company/zashi-android/issues/1146
|
2023-12-18 05:31:25 -08:00
|
|
|
CircularScreenProgressIndicator()
|
2022-04-25 05:35:30 -07:00
|
|
|
} else {
|
2023-02-28 05:54:07 -08:00
|
|
|
Receive(
|
2022-04-25 05:35:30 -07:00
|
|
|
walletAddresses.unified,
|
2023-12-18 05:31:25 -08:00
|
|
|
onSettings = onSettings,
|
2022-04-25 05:35:30 -07:00
|
|
|
onAddressDetails = onAddressDetails,
|
2023-12-07 07:35:27 -08:00
|
|
|
onAdjustBrightness = { /* Just for testing */ }
|
2022-04-25 05:35:30 -07:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|