mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
initial desktop paynym ui set up and state provider refactor
This commit is contained in:
parent
0b30ac435b
commit
f4729526e6
6 changed files with 77 additions and 5 deletions
|
@ -7,6 +7,7 @@ import 'package:stackwallet/pages/paynym/paynym_home_view.dart';
|
||||||
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
||||||
import 'package:stackwallet/providers/global/paynym_api_provider.dart';
|
import 'package:stackwallet/providers/global/paynym_api_provider.dart';
|
||||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||||
|
import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart';
|
||||||
import 'package:stackwallet/services/coins/coin_paynym_extension.dart';
|
import 'package:stackwallet/services/coins/coin_paynym_extension.dart';
|
||||||
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart';
|
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
|
|
|
@ -4,11 +4,11 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:stackwallet/models/paynym/paynym_account.dart';
|
|
||||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||||
import 'package:stackwallet/pages/paynym/add_new_paynym_follow_view.dart';
|
import 'package:stackwallet/pages/paynym/add_new_paynym_follow_view.dart';
|
||||||
import 'package:stackwallet/pages/paynym/dialogs/paynym_qr_popup.dart';
|
import 'package:stackwallet/pages/paynym/dialogs/paynym_qr_popup.dart';
|
||||||
import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart';
|
import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart';
|
||||||
|
import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
import 'package:stackwallet/utilities/format.dart';
|
import 'package:stackwallet/utilities/format.dart';
|
||||||
|
@ -24,9 +24,6 @@ import 'package:stackwallet/widgets/icon_widgets/share_icon.dart';
|
||||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||||
import 'package:stackwallet/widgets/toggle.dart';
|
import 'package:stackwallet/widgets/toggle.dart';
|
||||||
|
|
||||||
final myPaynymAccountStateProvider =
|
|
||||||
StateProvider<PaynymAccount?>((ref) => null);
|
|
||||||
|
|
||||||
class PaynymHomeView extends ConsumerStatefulWidget {
|
class PaynymHomeView extends ConsumerStatefulWidget {
|
||||||
const PaynymHomeView({
|
const PaynymHomeView({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
|
|
@ -5,10 +5,10 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:stackwallet/models/paynym/paynym_account_lite.dart';
|
import 'package:stackwallet/models/paynym/paynym_account_lite.dart';
|
||||||
import 'package:stackwallet/models/paynym/paynym_response.dart';
|
import 'package:stackwallet/models/paynym/paynym_response.dart';
|
||||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||||
import 'package:stackwallet/pages/paynym/paynym_home_view.dart';
|
|
||||||
import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart';
|
import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart';
|
||||||
import 'package:stackwallet/providers/global/paynym_api_provider.dart';
|
import 'package:stackwallet/providers/global/paynym_api_provider.dart';
|
||||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||||
|
import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart';
|
||||||
import 'package:stackwallet/services/coins/coin_paynym_extension.dart';
|
import 'package:stackwallet/services/coins/coin_paynym_extension.dart';
|
||||||
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart';
|
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart';
|
||||||
import 'package:stackwallet/utilities/format.dart';
|
import 'package:stackwallet/utilities/format.dart';
|
||||||
|
|
|
@ -7,6 +7,7 @@ import 'package:stackwallet/pages/paynym/paynym_claim_view.dart';
|
||||||
import 'package:stackwallet/pages/paynym/paynym_home_view.dart';
|
import 'package:stackwallet/pages/paynym/paynym_home_view.dart';
|
||||||
import 'package:stackwallet/providers/global/paynym_api_provider.dart';
|
import 'package:stackwallet/providers/global/paynym_api_provider.dart';
|
||||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||||
|
import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart';
|
||||||
import 'package:stackwallet/services/coins/coin_paynym_extension.dart';
|
import 'package:stackwallet/services/coins/coin_paynym_extension.dart';
|
||||||
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart';
|
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
|
|
|
@ -17,6 +17,9 @@ import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub
|
||||||
import 'package:stackwallet/providers/global/auto_swb_service_provider.dart';
|
import 'package:stackwallet/providers/global/auto_swb_service_provider.dart';
|
||||||
import 'package:stackwallet/providers/providers.dart';
|
import 'package:stackwallet/providers/providers.dart';
|
||||||
import 'package:stackwallet/providers/ui/transaction_filter_provider.dart';
|
import 'package:stackwallet/providers/ui/transaction_filter_provider.dart';
|
||||||
|
import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart';
|
||||||
|
import 'package:stackwallet/services/coins/coin_paynym_extension.dart';
|
||||||
|
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart';
|
||||||
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
|
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
|
||||||
import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart';
|
import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart';
|
||||||
import 'package:stackwallet/services/event_bus/global_event_bus.dart';
|
import 'package:stackwallet/services/event_bus/global_event_bus.dart';
|
||||||
|
@ -36,10 +39,15 @@ import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
||||||
import 'package:stackwallet/widgets/hover_text_field.dart';
|
import 'package:stackwallet/widgets/hover_text_field.dart';
|
||||||
|
import 'package:stackwallet/widgets/loading_indicator.dart';
|
||||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||||
import 'package:stackwallet/widgets/stack_dialog.dart';
|
import 'package:stackwallet/widgets/stack_dialog.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
|
|
||||||
|
import '../../../pages/paynym/paynym_claim_view.dart';
|
||||||
|
import '../../../pages/paynym/paynym_home_view.dart';
|
||||||
|
import '../../../providers/global/paynym_api_provider.dart';
|
||||||
|
|
||||||
/// [eventBus] should only be set during testing
|
/// [eventBus] should only be set during testing
|
||||||
class DesktopWalletView extends ConsumerStatefulWidget {
|
class DesktopWalletView extends ConsumerStatefulWidget {
|
||||||
const DesktopWalletView({
|
const DesktopWalletView({
|
||||||
|
@ -281,6 +289,51 @@ class _DesktopWalletViewState extends ConsumerState<DesktopWalletView> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> onPaynymButtonPressed() async {
|
||||||
|
unawaited(
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => const LoadingIndicator(
|
||||||
|
width: 100,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// todo make generic and not doge specific
|
||||||
|
final wallet = (ref
|
||||||
|
.read(walletsChangeNotifierProvider)
|
||||||
|
.getManager(widget.walletId)
|
||||||
|
.wallet as DogecoinWallet);
|
||||||
|
|
||||||
|
final code = await wallet.getPaymentCode();
|
||||||
|
|
||||||
|
final account = await ref.read(paynymAPIProvider).nym(code.toString());
|
||||||
|
|
||||||
|
Logging.instance.log(
|
||||||
|
"my nym account: $account",
|
||||||
|
level: LogLevel.Info,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (mounted) {
|
||||||
|
Navigator.of(context, rootNavigator: true).pop();
|
||||||
|
|
||||||
|
// check if account exists and for matching code to see if claimed
|
||||||
|
if (account.value != null && account.value!.codes.first.claimed) {
|
||||||
|
ref.read(myPaynymAccountStateProvider.state).state = account.value!;
|
||||||
|
|
||||||
|
await Navigator.of(context).pushNamed(
|
||||||
|
PaynymHomeView.routeName,
|
||||||
|
arguments: widget.walletId,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
await Navigator.of(context).pushNamed(
|
||||||
|
PaynymClaimView.routeName,
|
||||||
|
arguments: widget.walletId,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
controller = TextEditingController();
|
controller = TextEditingController();
|
||||||
|
@ -482,6 +535,21 @@ class _DesktopWalletViewState extends ConsumerState<DesktopWalletView> {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
if (coin.hasPaynymSupport)
|
||||||
|
SecondaryButton(
|
||||||
|
label: "PayNym",
|
||||||
|
width: 160,
|
||||||
|
buttonHeight: ButtonHeight.l,
|
||||||
|
icon: SvgPicture.asset(
|
||||||
|
Assets.svg.user,
|
||||||
|
height: 20,
|
||||||
|
width: 20,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.buttonTextSecondary,
|
||||||
|
),
|
||||||
|
onPressed: onPaynymButtonPressed,
|
||||||
|
),
|
||||||
// if (coin == Coin.firo) const SizedBox(width: 16),
|
// if (coin == Coin.firo) const SizedBox(width: 16),
|
||||||
// SecondaryButton(
|
// SecondaryButton(
|
||||||
// width: 180,
|
// width: 180,
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:stackwallet/models/paynym/paynym_account.dart';
|
||||||
|
|
||||||
|
final myPaynymAccountStateProvider =
|
||||||
|
StateProvider<PaynymAccount?>((ref) => null);
|
Loading…
Reference in a new issue