add coin control option to mobile more menu + assets fix

This commit is contained in:
julian 2023-03-06 10:34:41 -06:00
parent 27de4d868e
commit 7319f509f0
6 changed files with 147 additions and 62 deletions

View file

@ -50,6 +50,11 @@ class _WalletNavigationBarState extends ConsumerState<WalletNavigationBar> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final showMore = ref.watch(walletsChangeNotifierProvider.select(
(value) => value.getManager(widget.walletId).hasPaynymSupport)) ||
ref.watch(walletsChangeNotifierProvider.select((value) =>
value.getManager(widget.walletId).hasCoinControlSupport));
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
@ -97,62 +102,20 @@ class _WalletNavigationBarState extends ConsumerState<WalletNavigationBar> {
// const SizedBox( // const SizedBox(
// height: 8, // height: 8,
// ), // ),
AnimatedOpacity( if (ref.watch(walletsChangeNotifierProvider.select((value) =>
opacity: scale, value.getManager(widget.walletId).hasCoinControlSupport)))
duration: duration, AnimatedOpacity(
child: Consumer(builder: (context, ref, __) { opacity: scale,
return GestureDetector( duration: duration,
onTap: () async { child: GestureDetector(
setState(() { onTap: () {
scale = 0;
});
unawaited(
showDialog(
context: context,
builder: (context) => const LoadingIndicator(
width: 100,
),
),
);
final manager = ref
.read(walletsChangeNotifierProvider)
.getManager(widget.walletId);
final paynymInterface =
manager.wallet as PaynymWalletInterface;
final code = await paynymInterface.getPaymentCode(
DerivePathTypeExt.primaryFor(manager.coin));
final account = await ref
.read(paynymAPIProvider)
.nym(code.toString());
Logging.instance.log(
"my nym account: $account",
level: LogLevel.Info,
);
if (mounted) { if (mounted) {
Navigator.of(context).pop(); Navigator.of(context).pop();
// check if account exists and for matching code to see if claimed // Navigator.of(context).pushNamed(
if (account.value != null && // PaynymHomeView.routeName,
account.value!.codes.first.claimed) { // arguments: widget.walletId,
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,
);
}
} }
}, },
child: Container( child: Container(
@ -174,14 +137,14 @@ class _WalletNavigationBarState extends ConsumerState<WalletNavigationBar> {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text( Text(
"Paynym", "Coin control",
style: STextStyles.buttonSmall(context), style: STextStyles.buttonSmall(context),
), ),
const SizedBox( const SizedBox(
width: 16, width: 16,
), ),
SvgPicture.asset( SvgPicture.asset(
Assets.svg.robotHead, Assets.svg.coinControl.gamePad,
height: 20, height: 20,
width: 20, width: 20,
color: Theme.of(context) color: Theme.of(context)
@ -191,9 +154,117 @@ class _WalletNavigationBarState extends ConsumerState<WalletNavigationBar> {
], ],
), ),
), ),
); ),
}), ),
), if (ref.watch(walletsChangeNotifierProvider.select((value) =>
value
.getManager(widget.walletId)
.hasCoinControlSupport)) &&
ref.watch(walletsChangeNotifierProvider.select((value) =>
value.getManager(widget.walletId).hasPaynymSupport)))
const SizedBox(
height: 8,
),
if (ref.watch(walletsChangeNotifierProvider.select((value) =>
value.getManager(widget.walletId).hasPaynymSupport)))
AnimatedOpacity(
opacity: scale,
duration: duration,
child: Consumer(builder: (context, ref, __) {
return GestureDetector(
onTap: () async {
setState(() {
scale = 0;
});
unawaited(
showDialog(
context: context,
builder: (context) => const LoadingIndicator(
width: 100,
),
),
);
final manager = ref
.read(walletsChangeNotifierProvider)
.getManager(widget.walletId);
final paynymInterface =
manager.wallet as PaynymWalletInterface;
final code = await paynymInterface.getPaymentCode(
DerivePathTypeExt.primaryFor(manager.coin));
final account = await ref
.read(paynymAPIProvider)
.nym(code.toString());
Logging.instance.log(
"my nym account: $account",
level: LogLevel.Info,
);
if (mounted) {
Navigator.of(context).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,
);
}
}
},
child: Container(
padding: const EdgeInsets.all(16),
width: 146,
decoration: BoxDecoration(
color: Theme.of(context)
.extension<StackColors>()!
.popupBG,
boxShadow: [
Theme.of(context)
.extension<StackColors>()!
.standardBoxShadow
],
borderRadius: BorderRadius.circular(
widget.height / 2.0,
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Paynym",
style: STextStyles.buttonSmall(context),
),
const SizedBox(
width: 16,
),
SvgPicture.asset(
Assets.svg.robotHead,
height: 20,
width: 20,
color: Theme.of(context)
.extension<StackColors>()!
.bottomNavIconIcon,
),
],
),
),
);
}),
),
const SizedBox( const SizedBox(
height: 8, height: 8,
), ),
@ -410,8 +481,7 @@ class _WalletNavigationBarState extends ConsumerState<WalletNavigationBar> {
), ),
), ),
), ),
if (ref.watch(walletsChangeNotifierProvider.select((value) => if (showMore)
value.getManager(widget.walletId).hasPaynymSupport)))
RawMaterialButton( RawMaterialButton(
constraints: const BoxConstraints( constraints: const BoxConstraints(
minWidth: 66, minWidth: 66,

View file

@ -24,6 +24,7 @@ import 'package:stackwallet/services/event_bus/events/global/refresh_percent_cha
import 'package:stackwallet/services/event_bus/events/global/updated_in_background_event.dart'; import 'package:stackwallet/services/event_bus/events/global/updated_in_background_event.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';
import 'package:stackwallet/services/mixins/coin_control_interface.dart';
import 'package:stackwallet/services/mixins/electrum_x_parsing.dart'; import 'package:stackwallet/services/mixins/electrum_x_parsing.dart';
import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart'; import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart';
import 'package:stackwallet/services/mixins/wallet_cache.dart'; import 'package:stackwallet/services/mixins/wallet_cache.dart';
@ -94,7 +95,12 @@ String constructDerivePath({
} }
class BitcoinWallet extends CoinServiceAPI class BitcoinWallet extends CoinServiceAPI
with WalletCache, WalletDB, ElectrumXParsing, PaynymWalletInterface { with
WalletCache,
WalletDB,
ElectrumXParsing,
PaynymWalletInterface,
CoinControlInterface {
BitcoinWallet({ BitcoinWallet({
required String walletId, required String walletId,
required String walletName, required String walletName,

View file

@ -10,6 +10,7 @@ import 'package:stackwallet/services/coins/coin_service.dart';
import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart'; import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart';
import 'package:stackwallet/services/event_bus/events/global/updated_in_background_event.dart'; import 'package:stackwallet/services/event_bus/events/global/updated_in_background_event.dart';
import 'package:stackwallet/services/event_bus/global_event_bus.dart'; import 'package:stackwallet/services/event_bus/global_event_bus.dart';
import 'package:stackwallet/services/mixins/coin_control_interface.dart';
import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart'; import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/logger.dart';
@ -229,6 +230,8 @@ class Manager with ChangeNotifier {
bool get hasPaynymSupport => _currentWallet is PaynymWalletInterface; bool get hasPaynymSupport => _currentWallet is PaynymWalletInterface;
bool get hasCoinControlSupport => _currentWallet is CoinControlInterface;
int get rescanOnOpenVersion => int get rescanOnOpenVersion =>
DB.instance.get<dynamic>( DB.instance.get<dynamic>(
boxName: DB.boxNameDBInfo, boxName: DB.boxNameDBInfo,

View file

@ -0,0 +1,3 @@
mixin CoinControlInterface {
//
}

View file

@ -60,7 +60,7 @@ class _COIN_CONTROL {
class _SVG { class _SVG {
const _SVG(); const _SVG();
static const coinControl = _COIN_CONTROL(); final coinControl = const _COIN_CONTROL();
String? background(BuildContext context) { String? background(BuildContext context) {
switch (Theme.of(context).extension<StackColors>()!.themeType) { switch (Theme.of(context).extension<StackColors>()!.themeType) {

View file

@ -324,6 +324,9 @@ flutter:
# coin icons # coin icons
- assets/svg/coin_icons/ - assets/svg/coin_icons/
# coin control icons
- assets/svg/coin_control/
# lottie animations # lottie animations
- assets/lottie/test.json - assets/lottie/test.json
- assets/lottie/test2.json - assets/lottie/test2.json