Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import '../../../../themes/stack_colors.dart';
import '../../../../utilities/constants.dart';
import '../../../../utilities/enums/wallet_balance_toggle_state.dart';
import '../../../../utilities/text_styles.dart';
import '../../../../wallets/isar/providers/wallet_info_provider.dart';

class DesktopBalanceToggleButton extends ConsumerWidget {
const DesktopBalanceToggleButton({
Expand Down Expand Up @@ -74,37 +75,53 @@ class DesktopBalanceToggleButton extends ConsumerWidget {
class DesktopPrivateBalanceToggleButton extends ConsumerWidget {
const DesktopPrivateBalanceToggleButton({
super.key,
required this.walletId,
this.onPressed,
});

final String walletId;
final VoidCallback? onPressed;

@override
Widget build(BuildContext context, WidgetRef ref) {
final currentType = ref.watch(publicPrivateBalanceStateProvider);

final showLelantus =
ref.watch(pWalletBalanceSecondary(walletId)).spendable.raw >
BigInt.zero;

return SizedBox(
height: 22,
width: 80,
child: MaterialButton(
color: Theme.of(context).extension<StackColors>()!.buttonBackSecondary,
splashColor: Theme.of(context).extension<StackColors>()!.highlight,
onPressed: () {
switch (currentType) {
case FiroType.public:
ref.read(publicPrivateBalanceStateProvider.state).state =
FiroType.lelantus;
break;
if (showLelantus) {
switch (currentType) {
case FiroType.public:
ref.read(publicPrivateBalanceStateProvider.state).state =
FiroType.lelantus;
break;

case FiroType.lelantus:
ref.read(publicPrivateBalanceStateProvider.state).state =
FiroType.spark;
break;

case FiroType.lelantus:
case FiroType.spark:
ref.read(publicPrivateBalanceStateProvider.state).state =
FiroType.public;
break;
}
} else {
if (currentType != FiroType.spark) {
ref.read(publicPrivateBalanceStateProvider.state).state =
FiroType.spark;
break;

case FiroType.spark:
} else {
ref.read(publicPrivateBalanceStateProvider.state).state =
FiroType.public;
break;
}
}
onPressed?.call();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1107,28 +1107,30 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
],
),
),
DropdownMenuItem(
value: FiroType.lelantus,
child: Row(
children: [
Text(
"Lelantus balance",
style: STextStyles.itemSubtitle12(context),
),
const SizedBox(
width: 10,
),
Text(
ref.watch(pAmountFormatter(coin)).format(
ref
.watch(pWalletBalanceSecondary(walletId))
.spendable,
),
style: STextStyles.itemSubtitle(context),
),
],
if (ref.watch(pWalletBalanceSecondary(walletId)).spendable.raw >
BigInt.zero)
DropdownMenuItem(
value: FiroType.lelantus,
child: Row(
children: [
Text(
"Lelantus balance",
style: STextStyles.itemSubtitle12(context),
),
const SizedBox(
width: 10,
),
Text(
ref.watch(pAmountFormatter(coin)).format(
ref
.watch(pWalletBalanceSecondary(walletId))
.spendable,
),
style: STextStyles.itemSubtitle(context),
),
],
),
),
),
DropdownMenuItem(
value: FiroType.public,
child: Row(
Expand Down
Loading
Loading