mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-10 12:44:31 +00:00
add coin control option to mobile more menu + assets fix
This commit is contained in:
parent
27de4d868e
commit
7319f509f0
6 changed files with 147 additions and 62 deletions
|
@ -50,6 +50,11 @@ class _WalletNavigationBarState extends ConsumerState<WalletNavigationBar> {
|
|||
|
||||
@override
|
||||
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(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
|
@ -97,62 +102,20 @@ class _WalletNavigationBarState extends ConsumerState<WalletNavigationBar> {
|
|||
// const SizedBox(
|
||||
// height: 8,
|
||||
// ),
|
||||
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 (ref.watch(walletsChangeNotifierProvider.select((value) =>
|
||||
value.getManager(widget.walletId).hasCoinControlSupport)))
|
||||
AnimatedOpacity(
|
||||
opacity: scale,
|
||||
duration: duration,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
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,
|
||||
);
|
||||
}
|
||||
// Navigator.of(context).pushNamed(
|
||||
// PaynymHomeView.routeName,
|
||||
// arguments: widget.walletId,
|
||||
// );
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
|
@ -174,14 +137,14 @@ class _WalletNavigationBarState extends ConsumerState<WalletNavigationBar> {
|
|||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Paynym",
|
||||
"Coin control",
|
||||
style: STextStyles.buttonSmall(context),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
),
|
||||
SvgPicture.asset(
|
||||
Assets.svg.robotHead,
|
||||
Assets.svg.coinControl.gamePad,
|
||||
height: 20,
|
||||
width: 20,
|
||||
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(
|
||||
height: 8,
|
||||
),
|
||||
|
@ -410,8 +481,7 @@ class _WalletNavigationBarState extends ConsumerState<WalletNavigationBar> {
|
|||
),
|
||||
),
|
||||
),
|
||||
if (ref.watch(walletsChangeNotifierProvider.select((value) =>
|
||||
value.getManager(widget.walletId).hasPaynymSupport)))
|
||||
if (showMore)
|
||||
RawMaterialButton(
|
||||
constraints: const BoxConstraints(
|
||||
minWidth: 66,
|
||||
|
|
|
@ -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/wallet_sync_status_changed_event.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/paynym_wallet_interface.dart';
|
||||
import 'package:stackwallet/services/mixins/wallet_cache.dart';
|
||||
|
@ -94,7 +95,12 @@ String constructDerivePath({
|
|||
}
|
||||
|
||||
class BitcoinWallet extends CoinServiceAPI
|
||||
with WalletCache, WalletDB, ElectrumXParsing, PaynymWalletInterface {
|
||||
with
|
||||
WalletCache,
|
||||
WalletDB,
|
||||
ElectrumXParsing,
|
||||
PaynymWalletInterface,
|
||||
CoinControlInterface {
|
||||
BitcoinWallet({
|
||||
required String walletId,
|
||||
required String walletName,
|
||||
|
|
|
@ -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/updated_in_background_event.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/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/logger.dart';
|
||||
|
@ -229,6 +230,8 @@ class Manager with ChangeNotifier {
|
|||
|
||||
bool get hasPaynymSupport => _currentWallet is PaynymWalletInterface;
|
||||
|
||||
bool get hasCoinControlSupport => _currentWallet is CoinControlInterface;
|
||||
|
||||
int get rescanOnOpenVersion =>
|
||||
DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNameDBInfo,
|
||||
|
|
3
lib/services/mixins/coin_control_interface.dart
Normal file
3
lib/services/mixins/coin_control_interface.dart
Normal file
|
@ -0,0 +1,3 @@
|
|||
mixin CoinControlInterface {
|
||||
//
|
||||
}
|
|
@ -60,7 +60,7 @@ class _COIN_CONTROL {
|
|||
class _SVG {
|
||||
const _SVG();
|
||||
|
||||
static const coinControl = _COIN_CONTROL();
|
||||
final coinControl = const _COIN_CONTROL();
|
||||
|
||||
String? background(BuildContext context) {
|
||||
switch (Theme.of(context).extension<StackColors>()!.themeType) {
|
||||
|
|
|
@ -324,6 +324,9 @@ flutter:
|
|||
# coin icons
|
||||
- assets/svg/coin_icons/
|
||||
|
||||
# coin control icons
|
||||
- assets/svg/coin_control/
|
||||
|
||||
# lottie animations
|
||||
- assets/lottie/test.json
|
||||
- assets/lottie/test2.json
|
||||
|
|
Loading…
Reference in a new issue