mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-02-03 19:56:31 +00:00
WIP: scaling monkey view for desktop
This commit is contained in:
parent
5668b045e5
commit
66e1db9b52
1 changed files with 207 additions and 108 deletions
|
@ -9,6 +9,7 @@ import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:stackwallet/pages/monkey/sub_widgets/fetch_monkey_dialog.dart';
|
import 'package:stackwallet/pages/monkey/sub_widgets/fetch_monkey_dialog.dart';
|
||||||
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
||||||
|
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart';
|
||||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||||
import 'package:stackwallet/services/coins/banano/banano_wallet.dart';
|
import 'package:stackwallet/services/coins/banano/banano_wallet.dart';
|
||||||
import 'package:stackwallet/services/coins/manager.dart';
|
import 'package:stackwallet/services/coins/manager.dart';
|
||||||
|
@ -17,6 +18,7 @@ import 'package:stackwallet/themes/stack_colors.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
|
import 'package:stackwallet/utilities/util.dart';
|
||||||
import 'package:stackwallet/widgets/background.dart';
|
import 'package:stackwallet/widgets/background.dart';
|
||||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||||
|
@ -24,6 +26,9 @@ 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/stack_dialog.dart';
|
import 'package:stackwallet/widgets/stack_dialog.dart';
|
||||||
|
|
||||||
|
import '../../widgets/desktop/desktop_app_bar.dart';
|
||||||
|
import '../../widgets/desktop/desktop_scaffold.dart';
|
||||||
|
|
||||||
class MonkeyView extends ConsumerStatefulWidget {
|
class MonkeyView extends ConsumerStatefulWidget {
|
||||||
const MonkeyView({
|
const MonkeyView({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
@ -193,25 +198,57 @@ class _MonkeyViewState extends ConsumerState<MonkeyView> {
|
||||||
final manager = ref.watch(walletsChangeNotifierProvider
|
final manager = ref.watch(walletsChangeNotifierProvider
|
||||||
.select((value) => value.getManager(widget.walletId)));
|
.select((value) => value.getManager(widget.walletId)));
|
||||||
|
|
||||||
|
final bool isDesktop = Util.isDesktop;
|
||||||
|
|
||||||
List<int>? imageBytes;
|
List<int>? imageBytes;
|
||||||
imageBytes = (manager.wallet as BananoWallet).getMonkeyImageBytes();
|
imageBytes = (manager.wallet as BananoWallet).getMonkeyImageBytes();
|
||||||
|
|
||||||
|
//edit for desktop
|
||||||
return Background(
|
return Background(
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Scaffold(
|
ConditionalParent(
|
||||||
appBar: AppBar(
|
condition: isDesktop,
|
||||||
leading: AppBarBackButton(
|
builder: (child) => DesktopScaffold(
|
||||||
onPressed: () {
|
appBar: DesktopAppBar(
|
||||||
Navigator.of(context).pop();
|
background: Theme.of(context).extension<StackColors>()!.popupBG,
|
||||||
},
|
leading: Expanded(
|
||||||
),
|
child: Row(
|
||||||
title: Text(
|
children: [
|
||||||
"MonKey",
|
const SizedBox(
|
||||||
style: STextStyles.navBarTitle(context),
|
width: 32,
|
||||||
),
|
),
|
||||||
actions: [
|
AppBarIconButton(
|
||||||
AspectRatio(
|
size: 32,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.textFieldDefaultBG,
|
||||||
|
shadows: const [],
|
||||||
|
icon: SvgPicture.asset(
|
||||||
|
Assets.svg.arrowLeft,
|
||||||
|
width: 18,
|
||||||
|
height: 18,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.topNavIconPrimary,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
if (mounted) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 15,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"MonKey",
|
||||||
|
style: STextStyles.navBarTitle(context),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
trailing: AspectRatio(
|
||||||
aspectRatio: 1,
|
aspectRatio: 1,
|
||||||
child: AppBarIconButton(
|
child: AppBarIconButton(
|
||||||
icon: SvgPicture.asset(Assets.svg.circleQuestion),
|
icon: SvgPicture.asset(Assets.svg.circleQuestion),
|
||||||
|
@ -221,7 +258,7 @@ class _MonkeyViewState extends ConsumerState<MonkeyView> {
|
||||||
useSafeArea: false,
|
useSafeArea: false,
|
||||||
barrierDismissible: true,
|
barrierDismissible: true,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return const StackOkDialog(
|
return const StackDialog(
|
||||||
title: "About MonKeys",
|
title: "About MonKeys",
|
||||||
message:
|
message:
|
||||||
"A MonKey is a visual representation of your Banano address.",
|
"A MonKey is a visual representation of your Banano address.",
|
||||||
|
@ -229,112 +266,174 @@ class _MonkeyViewState extends ConsumerState<MonkeyView> {
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
],
|
useSpacers: false,
|
||||||
),
|
isCompactHeight: true,
|
||||||
body: ConditionalParent(
|
|
||||||
condition: imageBytes != null,
|
|
||||||
builder: (child) => Column(
|
|
||||||
children: [
|
|
||||||
const Spacer(
|
|
||||||
flex: 1,
|
|
||||||
),
|
|
||||||
if (imageBytes != null)
|
|
||||||
Container(
|
|
||||||
child: SvgPicture.memory(Uint8List.fromList(imageBytes!)),
|
|
||||||
width: 300,
|
|
||||||
height: 300,
|
|
||||||
),
|
|
||||||
const Spacer(
|
|
||||||
flex: 1,
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
SecondaryButton(
|
|
||||||
label: "Download as SVG",
|
|
||||||
onPressed: () async {
|
|
||||||
getMonkeySVG(receivingAddress);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
SecondaryButton(
|
|
||||||
label: "Download as PNG",
|
|
||||||
onPressed: () {
|
|
||||||
getMonkeyPNG(receivingAddress);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// child,
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
child: Column(
|
body: child,
|
||||||
children: [
|
),
|
||||||
const Spacer(
|
child: ConditionalParent(
|
||||||
flex: 4,
|
condition: !isDesktop,
|
||||||
|
builder: (child) => Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
leading: AppBarBackButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
),
|
),
|
||||||
Center(
|
title: Text(
|
||||||
child: Column(
|
"MonKey",
|
||||||
children: [
|
style: STextStyles.navBarTitle(context),
|
||||||
Opacity(
|
),
|
||||||
opacity: 0.2,
|
actions: [
|
||||||
child: SvgPicture.file(
|
AspectRatio(
|
||||||
File(
|
aspectRatio: 1,
|
||||||
ref.watch(coinIconProvider(coin)),
|
child: AppBarIconButton(
|
||||||
),
|
icon: SvgPicture.asset(
|
||||||
width: 200,
|
Assets.svg.circleQuestion,
|
||||||
height: 200,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 40,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
"You do not have a MonKey yet. \nFetch yours now!",
|
|
||||||
style: STextStyles.smallMed14(context).copyWith(
|
|
||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
.extension<StackColors>()!
|
.extension<StackColors>()!
|
||||||
.textDark3,
|
.infoItemText,
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.center,
|
onPressed: () {
|
||||||
),
|
showDialog<dynamic>(
|
||||||
],
|
context: context,
|
||||||
|
useSafeArea: false,
|
||||||
|
barrierDismissible: true,
|
||||||
|
builder: (context) {
|
||||||
|
return const StackOkDialog(
|
||||||
|
title: "About MonKeys",
|
||||||
|
message:
|
||||||
|
"A MonKey is a visual representation of your Banano address.",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: child,
|
||||||
|
),
|
||||||
|
child: ConditionalParent(
|
||||||
|
condition: isDesktop,
|
||||||
|
builder: (child) => SizedBox(
|
||||||
|
width: 300,
|
||||||
|
height: 300,
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
child: ConditionalParent(
|
||||||
|
condition: imageBytes != null,
|
||||||
|
builder: (child) => Column(
|
||||||
|
children: [
|
||||||
|
const Spacer(
|
||||||
|
flex: 1,
|
||||||
|
),
|
||||||
|
if (imageBytes != null)
|
||||||
|
Container(
|
||||||
|
child: SvgPicture.memory(
|
||||||
|
Uint8List.fromList(imageBytes!)),
|
||||||
|
width: 300,
|
||||||
|
height: 300,
|
||||||
|
),
|
||||||
|
const Spacer(
|
||||||
|
flex: 1,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
SecondaryButton(
|
||||||
|
label: "Download as SVG",
|
||||||
|
onPressed: () async {
|
||||||
|
getMonkeySVG(receivingAddress);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
SecondaryButton(
|
||||||
|
label: "Download as PNG",
|
||||||
|
onPressed: () {
|
||||||
|
getMonkeyPNG(receivingAddress);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// child,
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const Spacer(
|
child: Column(
|
||||||
flex: 6,
|
children: [
|
||||||
),
|
const Spacer(
|
||||||
Padding(
|
flex: 4,
|
||||||
padding: const EdgeInsets.all(16.0),
|
),
|
||||||
child: PrimaryButton(
|
Center(
|
||||||
label: "Fetch MonKey",
|
child: Column(
|
||||||
onPressed: () async {
|
children: [
|
||||||
getMonkeyImage(receivingAddress);
|
Opacity(
|
||||||
|
opacity: 0.2,
|
||||||
|
child: SvgPicture.file(
|
||||||
|
File(
|
||||||
|
ref.watch(coinIconProvider(coin)),
|
||||||
|
),
|
||||||
|
width: 200,
|
||||||
|
height: 200,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 40,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"You do not have a MonKey yet. \nFetch yours now!",
|
||||||
|
style: STextStyles.smallMed14(context).copyWith(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.textDark3,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Spacer(
|
||||||
|
flex: 6,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: PrimaryButton(
|
||||||
|
label: "Fetch MonKey",
|
||||||
|
onPressed: () async {
|
||||||
|
getMonkeyImage(receivingAddress);
|
||||||
|
|
||||||
showDialog<dynamic>(
|
showDialog<dynamic>(
|
||||||
context: context,
|
context: context,
|
||||||
useSafeArea: false,
|
useSafeArea: false,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return FetchMonkeyDialog(
|
return FetchMonkeyDialog(
|
||||||
onCancel: () async {
|
onCancel: () async {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await Future<void>.delayed(
|
||||||
|
const Duration(seconds: 2));
|
||||||
|
|
||||||
|
if (isDesktop) {
|
||||||
|
Navigator.of(context).popUntil(
|
||||||
|
ModalRoute.withName(
|
||||||
|
DesktopWalletView.routeName),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).popUntil(
|
||||||
|
ModalRoute.withName(WalletView.routeName),
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
),
|
||||||
|
),
|
||||||
await Future<void>.delayed(const Duration(seconds: 2));
|
],
|
||||||
|
|
||||||
Navigator.of(context).popUntil(
|
|
||||||
ModalRoute.withName(WalletView.routeName),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue