Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MonKey to banano #628

Merged
merged 29 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
fb39e96
WIP: monkey view + fetching monkey dialog
Jul 21, 2023
ee5a97c
add monkey icon
Jul 21, 2023
8ac085f
fix monkey icon
Jul 22, 2023
a286ba7
monkey view page
Jul 24, 2023
3cbde8b
able to download monkey.png
Jul 25, 2023
b2ec276
monkey.png downloads to user device
Jul 25, 2023
c6c2b42
monkey.svg download to user device
Jul 25, 2023
512960d
changed monkey files around
Jul 25, 2023
78e4cd4
removed unnecessary lines
Jul 25, 2023
6833647
structure change to add monkey image
Jul 26, 2023
2eb10e2
add monkey image to hive and display on wallet card
Jul 26, 2023
032061f
changed generate monkey structure
Jul 26, 2023
ea9f997
Merge branch 'staging' into add-monkey
Jul 26, 2023
86d3258
Monkey help message
Jul 26, 2023
3cb8a6a
WIP: adding monkey to desktop
Jul 26, 2023
5668b04
WIP: adding monkey to desktop
Jul 26, 2023
66e1db9
WIP: scaling monkey view for desktop
Jul 26, 2023
b2aa427
reorg and loading indicator
julian-CStack Jul 26, 2023
4e9ba50
Desktop what is monkey button
Jul 26, 2023
0175939
download/save image on linux
julian-CStack Jul 26, 2023
39882b0
monkey icon in app bar
Jul 26, 2023
9d2b315
desktop layout
julian-CStack Jul 26, 2023
bf309d4
Merge remote-tracking branch 'origin_SW/add-monkey' into add-monkey
julian-CStack Jul 26, 2023
2f5a18b
merge conflict clean things
julian-CStack Jul 26, 2023
d8e6f3c
fix mobile nav error
julian-CStack Jul 26, 2023
8754142
android file path
Jul 26, 2023
04b9cdd
fixed path
Jul 26, 2023
7390c49
set state on download
julian-CStack Jul 26, 2023
f27e818
Merge remote-tracking branch 'origin_SW/staging' into add-monkey
julian-CStack Jul 26, 2023
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
3 changes: 3 additions & 0 deletions assets/svg/monkey.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
275 changes: 275 additions & 0 deletions lib/pages/monkey/monkey_loaded_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
// import 'dart:io';
// import 'dart:typed_data';
//
// import 'package:flutter/material.dart';
// import 'package:flutter_riverpod/flutter_riverpod.dart';
// import 'package:flutter_svg/svg.dart';
// import 'package:http/http.dart' as http;
// import 'package:path_provider/path_provider.dart';
// import 'package:permission_handler/permission_handler.dart';
// import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
// import 'package:stackwallet/providers/global/wallets_provider.dart';
// import 'package:stackwallet/services/coins/banano/banano_wallet.dart';
// import 'package:stackwallet/services/coins/manager.dart';
// import 'package:stackwallet/themes/stack_colors.dart';
// import 'package:stackwallet/utilities/assets.dart';
// import 'package:stackwallet/utilities/enums/coin_enum.dart';
// import 'package:stackwallet/utilities/text_styles.dart';
// import 'package:stackwallet/widgets/background.dart';
// import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
// import 'package:stackwallet/widgets/desktop/secondary_button.dart';
//
// class MonkeyLoadedView extends ConsumerStatefulWidget {
// const MonkeyLoadedView({
// Key? key,
// required this.walletId,
// required this.managerProvider,
// }) : super(key: key);
//
// static const String routeName = "/hasMonkey";
// static const double navBarHeight = 65.0;
//
// final String walletId;
// final ChangeNotifierProvider<Manager> managerProvider;
//
// @override
// ConsumerState<MonkeyLoadedView> createState() => _MonkeyLoadedViewState();
// }
//
// class _MonkeyLoadedViewState extends ConsumerState<MonkeyLoadedView> {
// late final String walletId;
// late final ChangeNotifierProvider<Manager> managerProvider;
//
// String receivingAddress = "";
//
// void getMonkeySVG(String address) async {
// if (address.isEmpty) {
// //address shouldn't be empty
// return;
// }
//
// final http.Response response = await http
// .get(Uri.parse('https://monkey.banano.cc/api/v1/monkey/$address'));
//
// if (response.statusCode == 200) {
// final decodedResponse = response.bodyBytes;
// Directory directory = await getApplicationDocumentsDirectory();
// late Directory sampleFolder;
//
// if (Platform.isAndroid) {
// directory = Directory("/storage/emulated/0/");
// sampleFolder = Directory('${directory!.path}Documents');
// } else if (Platform.isIOS) {
// sampleFolder = Directory(directory!.path);
// } else if (Platform.isLinux) {
// sampleFolder = Directory('${directory!.path}Documents');
// } else if (Platform.isWindows) {
// sampleFolder = Directory('${directory!.path}Documents');
// } else if (Platform.isMacOS) {
// sampleFolder = Directory('${directory!.path}Documents');
// }
//
// try {
// if (!sampleFolder.existsSync()) {
// sampleFolder.createSync(recursive: true);
// }
// } catch (e, s) {
// // todo: come back to this
// debugPrint("$e $s");
// }
//
// final docPath = sampleFolder.path;
// final filePath = "$docPath/monkey.svg";
//
// File imgFile = File(filePath);
// await imgFile.writeAsBytes(decodedResponse);
// } else {
// throw Exception("Failed to get MonKey");
// }
// }
//
// void getMonkeyPNG(String address) async {
// if (address.isEmpty) {
// //address shouldn't be empty
// return;
// }
//
// final http.Response response = await http.get(Uri.parse(
// 'https://monkey.banano.cc/api/v1/monkey/${address}?format=png&size=512&background=false'));
//
// if (response.statusCode == 200) {
// if (Platform.isAndroid) {
// await Permission.storage.request();
// }
//
// final decodedResponse = response.bodyBytes;
// Directory directory = await getApplicationDocumentsDirectory();
// late Directory sampleFolder;
//
// if (Platform.isAndroid) {
// directory = Directory("/storage/emulated/0/");
// sampleFolder = Directory('${directory!.path}Documents');
// } else if (Platform.isIOS) {
// sampleFolder = Directory(directory!.path);
// } else if (Platform.isLinux) {
// sampleFolder = Directory('${directory!.path}Documents');
// } else if (Platform.isWindows) {
// sampleFolder = Directory('${directory!.path}Documents');
// } else if (Platform.isMacOS) {
// sampleFolder = Directory('${directory!.path}Documents');
// }
//
// try {
// if (!sampleFolder.existsSync()) {
// sampleFolder.createSync(recursive: true);
// }
// } catch (e, s) {
// // todo: come back to this
// debugPrint("$e $s");
// }
//
// final docPath = sampleFolder.path;
// final filePath = "$docPath/monkey.png";
//
// File imgFile = File(filePath);
// await imgFile.writeAsBytes(decodedResponse);
// } else {
// throw Exception("Failed to get MonKey");
// }
// }
//
// @override
// void initState() {
// walletId = widget.walletId;
// managerProvider = widget.managerProvider;
//
// WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
// final address = await ref
// .read(walletsChangeNotifierProvider)
// .getManager(walletId)
// .currentReceivingAddress;
// setState(() {
// receivingAddress = address;
// });
// });
//
// super.initState();
// }
//
// @override
// void dispose() {
// super.dispose();
// }
//
// @override
// Widget build(BuildContext context) {
// final Coin coin = ref.watch(managerProvider.select((value) => value.coin));
// final manager = ref.watch(walletsChangeNotifierProvider
// .select((value) => value.getManager(widget.walletId)));
//
// List<int>? imageBytes;
// imageBytes = (manager.wallet as BananoWallet).getMonkeyImageBytes();
//
// return Background(
// child: Stack(
// children: [
// Scaffold(
// appBar: AppBar(
// leading: AppBarBackButton(
// onPressed: () {
// Navigator.of(context).popUntil(
// ModalRoute.withName(WalletView.routeName),
// );
// },
// ),
// title: Text(
// "MonKey",
// style: STextStyles.navBarTitle(context),
// ),
// actions: [
// AspectRatio(
// aspectRatio: 1,
// child: AppBarIconButton(
// icon: SvgPicture.asset(Assets.svg.circleQuestion),
// onPressed: () {
// showDialog<dynamic>(
// context: context,
// useSafeArea: false,
// barrierDismissible: true,
// builder: (context) {
// return Dialog(
// child: Material(
// borderRadius: BorderRadius.circular(
// 20,
// ),
// child: Container(
// height: 200,
// decoration: BoxDecoration(
// color: Theme.of(context)
// .extension<StackColors>()!
// .popupBG,
// borderRadius: BorderRadius.circular(
// 20,
// ),
// ),
// child: Column(
// children: [
// Center(
// child: Text(
// "Help",
// style: STextStyles.pageTitleH2(
// context),
// ),
// )
// ],
// ),
// ),
// ),
// );
// });
// }),
// )
// ],
// ),
// body: 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);
// },
// ),
// ],
// ),
// ),
// ],
// ),
// ),
// ],
// ),
// );
// }
// }
Loading
Loading