fix and improve mnemonic print pdf
This commit is contained in:
parent
b835c701b1
commit
4cbb0bba20
|
@ -9,8 +9,6 @@ import 'package:gecko/models/bip39_words.dart';
|
||||||
import 'package:gecko/models/chest_data.dart';
|
import 'package:gecko/models/chest_data.dart';
|
||||||
import 'package:gecko/models/wallet_data.dart';
|
import 'package:gecko/models/wallet_data.dart';
|
||||||
import 'package:gecko/providers/substrate_sdk.dart';
|
import 'package:gecko/providers/substrate_sdk.dart';
|
||||||
import 'package:pdf/pdf.dart';
|
|
||||||
import 'package:pdf/widgets.dart' as pw;
|
|
||||||
import 'package:polkawallet_sdk/api/apiKeyring.dart';
|
import 'package:polkawallet_sdk/api/apiKeyring.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import "package:unorm_dart/unorm_dart.dart" as unorm;
|
import "package:unorm_dart/unorm_dart.dart" as unorm;
|
||||||
|
@ -151,77 +149,6 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
return pin.text;
|
return pin.text;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Uint8List> printWallet(AsyncSnapshot<List>? mnemoList) async {
|
|
||||||
final ByteData fontData =
|
|
||||||
await rootBundle.load("assets/OpenSans-Regular.ttf");
|
|
||||||
final pw.Font ttf = pw.Font.ttf(fontData.buffer.asByteData());
|
|
||||||
final pdf = pw.Document();
|
|
||||||
|
|
||||||
// const imageProvider = AssetImage('assets/icon/gecko_final.png');
|
|
||||||
// final geckoLogo = await flutterImageProvider(imageProvider);
|
|
||||||
|
|
||||||
pw.Widget arrayCell(dataWord) {
|
|
||||||
return pw.SizedBox(
|
|
||||||
width: 120,
|
|
||||||
child: pw.Column(children: <pw.Widget>[
|
|
||||||
pw.Text(
|
|
||||||
dataWord.split(':')[0],
|
|
||||||
style: pw.TextStyle(
|
|
||||||
fontSize: 15, color: const PdfColor(0.5, 0, 0), font: ttf),
|
|
||||||
),
|
|
||||||
pw.Text(
|
|
||||||
dataWord.split(':')[1],
|
|
||||||
style: pw.TextStyle(
|
|
||||||
fontSize: 20, color: const PdfColor(0, 0, 0), font: ttf),
|
|
||||||
),
|
|
||||||
pw.SizedBox(height: 10)
|
|
||||||
]),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
pdf.addPage(
|
|
||||||
pw.Page(
|
|
||||||
pageFormat: PdfPageFormat.a4,
|
|
||||||
build: (context) {
|
|
||||||
return pw.Column(
|
|
||||||
// mainAxisAlignment: pw.MainAxisAlignment.center,
|
|
||||||
// mainAxisSize: pw.MainAxisSize.max,
|
|
||||||
// crossAxisAlignment: pw.CrossAxisAlignment.center,
|
|
||||||
children: <pw.Widget>[
|
|
||||||
pw.Row(children: <pw.Widget>[
|
|
||||||
arrayCell(mnemoList!.data![0]),
|
|
||||||
arrayCell(mnemoList.data![1]),
|
|
||||||
arrayCell(mnemoList.data![2]),
|
|
||||||
arrayCell(mnemoList.data![3]),
|
|
||||||
]),
|
|
||||||
pw.Row(children: <pw.Widget>[
|
|
||||||
arrayCell(mnemoList.data![4]),
|
|
||||||
arrayCell(mnemoList.data![5]),
|
|
||||||
arrayCell(mnemoList.data![6]),
|
|
||||||
arrayCell(mnemoList.data![7]),
|
|
||||||
]),
|
|
||||||
pw.Row(children: <pw.Widget>[
|
|
||||||
arrayCell(mnemoList.data![8]),
|
|
||||||
arrayCell(mnemoList.data![9]),
|
|
||||||
arrayCell(mnemoList.data![10]),
|
|
||||||
arrayCell(mnemoList.data![11])
|
|
||||||
]),
|
|
||||||
pw.Expanded(
|
|
||||||
child: pw.Align(
|
|
||||||
alignment: pw.Alignment.bottomCenter,
|
|
||||||
child: pw.Text(
|
|
||||||
"Gardez cette feuille préciseusement, à l’abri des lézards indiscrets.",
|
|
||||||
style: pw.TextStyle(fontSize: 15, font: ttf),
|
|
||||||
)))
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
return pdf.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> generateCesiumWalletPubkey(
|
Future<void> generateCesiumWalletPubkey(
|
||||||
String cesiumID, String cesiumPWD) async {
|
String cesiumID, String cesiumPWD) async {
|
||||||
cesiumWallet = durt.CesiumWallet(cesiumID, cesiumPWD);
|
cesiumWallet = durt.CesiumWallet(cesiumID, cesiumPWD);
|
||||||
|
|
|
@ -714,7 +714,7 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
final seed = await sdk.api.keyring.getDecryptedSeed(keyring, pin);
|
final seed = await sdk.api.keyring.getDecryptedSeed(keyring, pin);
|
||||||
|
|
||||||
String seedText;
|
String seedText;
|
||||||
if (seed == null) {
|
if (seed == null || seed.seed == null) {
|
||||||
seedText = '';
|
seedText = '';
|
||||||
} else {
|
} else {
|
||||||
seedText = seed.seed!.split('//')[0];
|
seedText = seed.seed!.split('//')[0];
|
||||||
|
|
|
@ -120,7 +120,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: finish to implement multiqueries
|
//TODO: finish to implement multiqueries
|
||||||
|
|
||||||
// final sub = Provider.of<SubstrateSdk>(context, listen: false);
|
// final sub = Provider.of<SubstrateSdk>(context, listen: false);
|
||||||
// sub.getBalanceMulti([
|
// sub.getBalanceMulti([
|
||||||
// '5CQ8T4qpbYJq7uVsxGPQ5q2df7x3Wa4aRY6HUWMBYjfLZhnn',
|
// '5CQ8T4qpbYJq7uVsxGPQ5q2df7x3Wa4aRY6HUWMBYjfLZhnn',
|
||||||
|
|
|
@ -242,21 +242,19 @@ class PrintWallet extends StatelessWidget {
|
||||||
await rootBundle.load("assets/OpenSans-Regular.ttf");
|
await rootBundle.load("assets/OpenSans-Regular.ttf");
|
||||||
final pw.Font ttf = pw.Font.ttf(fontData.buffer.asByteData());
|
final pw.Font ttf = pw.Font.ttf(fontData.buffer.asByteData());
|
||||||
final pdf = pw.Document();
|
final pdf = pw.Document();
|
||||||
int nbr = 1;
|
|
||||||
|
|
||||||
final seedList = seed.split(' ');
|
final seedList = seed.split(' ');
|
||||||
|
|
||||||
// const imageProvider = AssetImage('assets/icon/gecko_final.png');
|
const imageProvider = AssetImage('assets/icon/gecko_final.png');
|
||||||
// final geckoLogo = await flutterImageProvider(imageProvider);
|
final geckoLogo = await flutterImageProvider(imageProvider);
|
||||||
|
|
||||||
pw.Widget arrayCell(String dataWord, int nbr) {
|
|
||||||
nbr++;
|
|
||||||
|
|
||||||
|
pw.Widget arrayCell(int number, String dataWord) {
|
||||||
return pw.SizedBox(
|
return pw.SizedBox(
|
||||||
width: 120,
|
width: 120,
|
||||||
|
height: 70,
|
||||||
child: pw.Column(children: <pw.Widget>[
|
child: pw.Column(children: <pw.Widget>[
|
||||||
pw.Text(
|
pw.Text(
|
||||||
nbr.toString(),
|
number.toString(),
|
||||||
style: pw.TextStyle(
|
style: pw.TextStyle(
|
||||||
fontSize: 15, color: const PdfColor(0.5, 0, 0), font: ttf),
|
fontSize: 15, color: const PdfColor(0.5, 0, 0), font: ttf),
|
||||||
),
|
),
|
||||||
|
@ -274,38 +272,44 @@ class PrintWallet extends StatelessWidget {
|
||||||
pw.Page(
|
pw.Page(
|
||||||
pageFormat: PdfPageFormat.a4,
|
pageFormat: PdfPageFormat.a4,
|
||||||
build: (context) {
|
build: (context) {
|
||||||
return pw.Column(
|
return pw.Stack(children: <pw.Widget>[
|
||||||
// mainAxisAlignment: pw.MainAxisAlignment.center,
|
pw.Positioned(top: 217, child: pw.Text('-'.padRight(130, '-'))),
|
||||||
// mainAxisSize: pw.MainAxisSize.max,
|
pw.Positioned(bottom: 217, child: pw.Text('-'.padRight(130, '-'))),
|
||||||
// crossAxisAlignment: pw.CrossAxisAlignment.center,
|
pw.Column(
|
||||||
children: <pw.Widget>[
|
// mainAxisAlignment: pw.MainAxisAlignment.center,
|
||||||
pw.Row(children: <pw.Widget>[
|
// mainAxisSize: pw.MainAxisSize.max,
|
||||||
arrayCell(seedList[0], nbr),
|
// crossAxisAlignment: pw.CrossAxisAlignment.center,
|
||||||
arrayCell(seedList[1], nbr),
|
children: <pw.Widget>[
|
||||||
arrayCell(seedList[2], nbr),
|
pw.SizedBox(height: 10),
|
||||||
arrayCell(seedList[3], nbr),
|
pw.Row(children: <pw.Widget>[
|
||||||
]),
|
arrayCell(1, seedList[0]),
|
||||||
pw.Row(children: <pw.Widget>[
|
arrayCell(2, seedList[1]),
|
||||||
arrayCell(seedList[4], nbr),
|
arrayCell(3, seedList[2]),
|
||||||
arrayCell(seedList[5], nbr),
|
arrayCell(4, seedList[3]),
|
||||||
arrayCell(seedList[6], nbr),
|
]),
|
||||||
arrayCell(seedList[7], nbr),
|
pw.Row(children: <pw.Widget>[
|
||||||
]),
|
arrayCell(5, seedList[4]),
|
||||||
pw.Row(children: <pw.Widget>[
|
arrayCell(6, seedList[5]),
|
||||||
arrayCell(seedList[8], nbr),
|
arrayCell(7, seedList[6]),
|
||||||
arrayCell(seedList[9], nbr),
|
arrayCell(8, seedList[7]),
|
||||||
arrayCell(seedList[10], nbr),
|
]),
|
||||||
arrayCell(seedList[11], nbr)
|
pw.Row(children: <pw.Widget>[
|
||||||
]),
|
arrayCell(9, seedList[8]),
|
||||||
pw.Expanded(
|
arrayCell(10, seedList[9]),
|
||||||
child: pw.Align(
|
arrayCell(11, seedList[10]),
|
||||||
alignment: pw.Alignment.bottomCenter,
|
arrayCell(12, seedList[11])
|
||||||
child: pw.Text(
|
]),
|
||||||
"Gardez cette feuille préciseusement, à l’abri des lézards indiscrets.",
|
pw.SizedBox(height: 105),
|
||||||
style: pw.TextStyle(fontSize: 15, font: ttf),
|
pw.Image(geckoLogo, height: 80),
|
||||||
)))
|
pw.SizedBox(height: 205),
|
||||||
],
|
pw.Text(
|
||||||
);
|
"Gardez cette feuille préciseusement, à l’abri des lézards indiscrets.\nElle vous permettra de restaurer tous vos portefeuilles à tout moment.",
|
||||||
|
textAlign: pw.TextAlign.center,
|
||||||
|
style: pw.TextStyle(fontSize: 15, font: ttf),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
]);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -9,12 +9,12 @@ import 'package:gecko/models/widgets_keys.dart';
|
||||||
import 'package:gecko/providers/generate_wallets.dart';
|
import 'package:gecko/providers/generate_wallets.dart';
|
||||||
import 'package:gecko/providers/my_wallets.dart';
|
import 'package:gecko/providers/my_wallets.dart';
|
||||||
import 'package:gecko/providers/wallets_profiles.dart';
|
import 'package:gecko/providers/wallets_profiles.dart';
|
||||||
|
import 'package:gecko/screens/myWallets/show_seed.dart';
|
||||||
import 'package:gecko/widgets/commons/build_progress_bar.dart';
|
import 'package:gecko/widgets/commons/build_progress_bar.dart';
|
||||||
import 'package:gecko/widgets/commons/build_text.dart';
|
import 'package:gecko/widgets/commons/build_text.dart';
|
||||||
import 'package:gecko/screens/onBoarding/6.dart';
|
import 'package:gecko/screens/onBoarding/6.dart';
|
||||||
import 'package:gecko/widgets/commons/fader_transition.dart';
|
import 'package:gecko/widgets/commons/fader_transition.dart';
|
||||||
import 'package:gecko/widgets/commons/offline_info.dart';
|
import 'package:gecko/widgets/commons/offline_info.dart';
|
||||||
import 'package:printing/printing.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
AsyncSnapshot<List>? mnemoList;
|
AsyncSnapshot<List>? mnemoList;
|
||||||
|
@ -63,14 +63,13 @@ class _ChooseChestState extends State<OnboardingStepFive> {
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
// const SizedBox(height: 10),
|
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(builder: (context) {
|
MaterialPageRoute(builder: (context) {
|
||||||
return PrintWallet(
|
return PrintWallet(
|
||||||
generateWalletProvider.generatedMnemonic);
|
generateWalletProvider.generatedMnemonic!);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -79,7 +78,6 @@ class _ChooseChestState extends State<OnboardingStepFive> {
|
||||||
height: 42 * ratio,
|
height: 42 * ratio,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 40,
|
height: 40,
|
||||||
width: 120,
|
width: 120,
|
||||||
|
@ -221,44 +219,6 @@ Widget arrayCell(dataWord) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class PrintWallet extends StatelessWidget {
|
|
||||||
const PrintWallet(this.sentence, {Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
final String? sentence;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final generateWalletProvider =
|
|
||||||
Provider.of<GenerateWalletsProvider>(context, listen: false);
|
|
||||||
return MaterialApp(
|
|
||||||
home: Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
leading: IconButton(
|
|
||||||
icon: const Icon(Icons.arrow_back, color: Colors.black),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
}),
|
|
||||||
backgroundColor: yellowC,
|
|
||||||
foregroundColor: Colors.black,
|
|
||||||
toolbarHeight: 60 * ratio,
|
|
||||||
title: const SizedBox(
|
|
||||||
height: 22,
|
|
||||||
child: Text(
|
|
||||||
'printMyMnemonic',
|
|
||||||
style: TextStyle(fontWeight: FontWeight.w600),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
body: PdfPreview(
|
|
||||||
canDebug: false,
|
|
||||||
canChangeOrientation: false,
|
|
||||||
build: (format) => generateWalletProvider.printWallet(mnemoList),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget nextButton(
|
Widget nextButton(
|
||||||
BuildContext context, String text, bool isFast, bool skipIntro) {
|
BuildContext context, String text, bool isFast, bool skipIntro) {
|
||||||
final generateWalletProvider =
|
final generateWalletProvider =
|
||||||
|
|
20
pubspec.lock
20
pubspec.lock
|
@ -349,10 +349,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: dbus
|
name: dbus
|
||||||
sha256: "6f07cba3f7b3448d42d015bfd3d53fe12e5b36da2423f23838efc1d5fb31a263"
|
sha256: "365c771ac3b0e58845f39ec6deebc76e3276aa9922b0cc60840712094d9047ac"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.8"
|
version: "0.7.10"
|
||||||
decimal:
|
decimal:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -381,10 +381,10 @@ packages:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: durt
|
name: durt
|
||||||
sha256: "1e1c494bd7cd8b372b89e5bc03c07f6e96aad5ef7d2159cfa28da3c181269678"
|
sha256: "97007458aa5ba95c78465af8489e1330d0f7d48c74e10699f6283ce4cf8a5410"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.6"
|
version: "0.1.7"
|
||||||
easy_localization:
|
easy_localization:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -1322,10 +1322,10 @@ packages:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: riverpod
|
name: riverpod
|
||||||
sha256: "2e84315036e64c59affaff7443dea51247bc2fe704461a32f26a27986fb63d55"
|
sha256: "01fa385aa5d6db42fd602d8c400c28ae1c83d1fd6fbae1cbf0f4c78bac58d4b2"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.5"
|
version: "2.4.6"
|
||||||
rxdart:
|
rxdart:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -1354,18 +1354,18 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: sentry
|
name: sentry
|
||||||
sha256: "9cfd325611ab54b57d5e26957466823f05bea9d6cfcc8d48f11817b8bcedf0d1"
|
sha256: e8040183ea1a0323999bce69786ed8429b1b89fbe5815a504d5bb7493a6464cc
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "7.12.0"
|
version: "7.13.1"
|
||||||
sentry_flutter:
|
sentry_flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: sentry_flutter
|
name: sentry_flutter
|
||||||
sha256: "0cd7d622cb63c94fd1b2f87ab508e158b950bd281e2a80f327ebf73bb217eaf3"
|
sha256: "843e317e605e5860e30ae431e9b8724c54f1a8567c9ad495e04595926bf22376"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "7.12.0"
|
version: "7.13.1"
|
||||||
shared_preferences:
|
shared_preferences:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
Loading…
Reference in New Issue