Compare commits

...

4 Commits

18 changed files with 468 additions and 239 deletions

View File

@ -1,10 +1,30 @@
# This file tracks properties of this Flutter project. # This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc. # Used by Flutter tool to assess capabilities and perform upgrades etc.
# #
# This file should be version controlled and should not be manually edited. # This file should be version controlled.
version: version:
revision: 1aafb3a8b9b0c36241c5f5b34ee914770f015818 revision: 85684f9300908116a78138ea4c6036c35c9a1236
channel: stable channel: stable
project_type: app project_type: app
# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 85684f9300908116a78138ea4c6036c35c9a1236
base_revision: 85684f9300908116a78138ea4c6036c35c9a1236
- platform: android
create_revision: 85684f9300908116a78138ea4c6036c35c9a1236
base_revision: 85684f9300908116a78138ea4c6036c35c9a1236
# User provided section
# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'

View File

@ -0,0 +1,6 @@
package gecko.axiomteam.gecko
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?android:colorBackground" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>

View File

@ -109,7 +109,7 @@
"accountActivity": "Account activity", "accountActivity": "Account activity",
"noNetworkNoHistory": "Network state does not allow\nto display account history", "noNetworkNoHistory": "Network state does not allow\nto display account history",
"noDataToDisplay": "No data to be displayed.", "noDataToDisplay": "No data to be displayed.",
"noTranscationToDisplay": "No transaction to display", "noTransactionToDisplay": "No transaction to display",
"month1": "January", "month1": "January",
"month2": "February", "month2": "February",
"month3": "March", "month3": "March",
@ -168,5 +168,10 @@
"cancel": "Cancel", "cancel": "Cancel",
"inBlockchainResult": "In {} blockchain", "inBlockchainResult": "In {} blockchain",
"search": "Search", "search": "Search",
"currencyNode": "{} node :" "currencyNode": "{} node :",
"contactsManagement": "My contacts",
"noContacts": "You don't have any contact",
"addContact": "Add\nto contacts",
"removeContact": "Remove\nthis contact"
} }

View File

@ -109,7 +109,7 @@
"accountActivity": "Account activity", "accountActivity": "Account activity",
"noNetworkNoHistory": "Network state does not allow\nto display account history", "noNetworkNoHistory": "Network state does not allow\nto display account history",
"noDataToDisplay": "No data to be displayed.", "noDataToDisplay": "No data to be displayed.",
"noTranscationToDisplay": "No transaction to display", "noTransactionToDisplay": "No transaction to display",
"month1": "January", "month1": "January",
"month2": "February", "month2": "February",
"month3": "March", "month3": "March",
@ -168,5 +168,9 @@
"cancel": "Cancel", "cancel": "Cancel",
"inBlockchainResult": "In {} blockchain", "inBlockchainResult": "In {} blockchain",
"search": "Search", "search": "Search",
"currencyNode": "{} node :" "currencyNode": "{} node :",
"contactsManagement": "My contacts",
"noContacts": "You don't have any contact",
"addContact": "Add\nto contacts",
"removeContact": "Remove\nthis contact"
} }

View File

@ -110,7 +110,7 @@
"accountActivity": "Activité du compte", "accountActivity": "Activité du compte",
"noNetworkNoHistory": "L'état du réseau ne permet pas\nd'afficher l'historique du compte", "noNetworkNoHistory": "L'état du réseau ne permet pas\nd'afficher l'historique du compte",
"noDataToDisplay": "Aucune donnée à afficher.", "noDataToDisplay": "Aucune donnée à afficher.",
"noTranscationToDisplay": "Aucune transaction à afficher", "noTransactionToDisplay": "Aucune transaction à afficher",
"month1": "Janvier", "month1": "Janvier",
"month2": "Février", "month2": "Février",
"month3": "Mars", "month3": "Mars",
@ -169,5 +169,9 @@
"cancel": "Annuler", "cancel": "Annuler",
"inBlockchainResult": "Dans la blockchain {}", "inBlockchainResult": "Dans la blockchain {}",
"search": "Rechercher", "search": "Rechercher",
"currencyNode": "Noeud {} :" "currencyNode": "Noeud {} :",
"contactsManagement": "Mes contacts",
"noContacts": "Vous n'avez aucun contact",
"addContact": "Ajouter\naux contacts",
"removeContact": "Supprimer\nce contact"
} }

View File

@ -22,6 +22,8 @@ late Box<WalletData> walletBox;
late Box<ChestData> chestBox; late Box<ChestData> chestBox;
late Box configBox; late Box configBox;
late Box<G1WalletsList> g1WalletsBox; late Box<G1WalletsList> g1WalletsBox;
late Box<G1WalletsList> contactsBox;
// late Box keystoreBox; // late Box keystoreBox;
late Directory imageDirectory; late Directory imageDirectory;

View File

@ -76,6 +76,7 @@ Future<void> main() async {
configBox = await Hive.openBox("configBox"); configBox = await Hive.openBox("configBox");
await Hive.deleteBoxFromDisk('g1WalletsBox'); await Hive.deleteBoxFromDisk('g1WalletsBox');
g1WalletsBox = await Hive.openBox<G1WalletsList>("g1WalletsBox"); g1WalletsBox = await Hive.openBox<G1WalletsList>("g1WalletsBox");
contactsBox = await Hive.openBox<G1WalletsList>("contactsBox");
await _homeProvider.getValidEndpoints(); await _homeProvider.getValidEndpoints();
// await configBox.delete('isCacheChecked'); // await configBox.delete('isCacheChecked');
@ -106,7 +107,7 @@ Future<void> main() async {
}, },
appRunner: () => runApp( appRunner: () => runApp(
EasyLocalization( EasyLocalization(
supportedLocales: const [Locale('en'), Locale('fr')], supportedLocales: const [Locale('en'), Locale('fr'), Locale('es')],
path: 'assets/translations', path: 'assets/translations',
fallbackLocale: const Locale('en'), fallbackLocale: const Locale('en'),
child: Gecko(indexerEndpoint), child: Gecko(indexerEndpoint),

View File

@ -369,7 +369,6 @@ class GenerateWalletsProvider with ChangeNotifier {
Future<bool> scanDerivations(BuildContext context, Future<bool> scanDerivations(BuildContext context,
{int numberScan = 20}) async { {int numberScan = 20}) async {
SubstrateSdk _sub = Provider.of<SubstrateSdk>(context, listen: false); SubstrateSdk _sub = Provider.of<SubstrateSdk>(context, listen: false);
final ss58 = _sub.ss58;
final currentChestNumber = configBox.get('currentChest'); final currentChestNumber = configBox.get('currentChest');
bool isAlive = false; bool isAlive = false;
scanedWalletNumber = 0; scanedWalletNumber = 0;

View File

@ -19,8 +19,6 @@ import 'package:truncate/truncate.dart';
// import 'package:web_socket_channel/io.dart'; // import 'package:web_socket_channel/io.dart';
class SubstrateSdk with ChangeNotifier { class SubstrateSdk with ChangeNotifier {
final int ss58 = 42;
final WalletSDK sdk = WalletSDK(); final WalletSDK sdk = WalletSDK();
final Keyring keyring = Keyring(); final Keyring keyring = Keyring();
String generatedMnemonic = ''; String generatedMnemonic = '';
@ -262,6 +260,7 @@ class SubstrateSdk with ChangeNotifier {
Future<double> getBalance(String address, {bool isUd = false}) async { Future<double> getBalance(String address, {bool isUd = false}) async {
double balance = 0.0; double balance = 0.0;
// log.d('nodeConnected: ' + nodeConnected.toString()); // log.d('nodeConnected: ' + nodeConnected.toString());
if (nodeConnected) { if (nodeConnected) {
final brutBalance = await sdk.api.account.queryBalance(address); final brutBalance = await sdk.api.account.queryBalance(address);

View File

@ -3,6 +3,7 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:gecko/globals.dart'; import 'package:gecko/globals.dart';
import 'package:gecko/models/g1_wallets_list.dart';
import 'package:gecko/providers/cesium_plus.dart'; import 'package:gecko/providers/cesium_plus.dart';
import 'package:gecko/providers/substrate_sdk.dart'; import 'package:gecko/providers/substrate_sdk.dart';
import 'package:gecko/providers/wallet_options.dart'; import 'package:gecko/providers/wallet_options.dart';
@ -186,30 +187,7 @@ class WalletsProfilesProvider with ChangeNotifier {
_walletOptions.idtyStatus(context, _address, _walletOptions.idtyStatus(context, _address,
isOwner: false, color: Colors.black), isOwner: false, color: Colors.black),
getCerts(context, _address, 14), getCerts(context, _address, 14),
if (username == null && const SizedBox(height: 40),
g1WalletsBox.get(_address)?.username != null)
SizedBox(
width: 230,
child: Text(
g1WalletsBox.get(_address)?.username ?? '',
style: const TextStyle(
fontSize: 27,
color: Color(0xff814C00),
),
),
),
if (username != null)
SizedBox(
width: 230,
child: Text(
username,
style: const TextStyle(
fontSize: 27,
color: Color(0xff814C00),
),
),
),
const SizedBox(height: 55),
]), ]),
const Spacer(), const Spacer(),
Column(children: <Widget>[ Column(children: <Widget>[
@ -224,6 +202,20 @@ class WalletsProfilesProvider with ChangeNotifier {
]); ]);
} }
bool isContact(String _address) {
return contactsBox.containsKey(_address);
}
void addContact(G1WalletsList profile) {
log.d(profile.username);
if (isContact(profile.pubkey!)) {
contactsBox.delete(profile.pubkey);
} else {
contactsBox.put(profile.pubkey, profile);
}
notifyListeners();
}
void reload() { void reload() {
notifyListeners(); notifyListeners();
} }

View File

@ -111,7 +111,8 @@ class ActivityScreen extends StatelessWidget with ChangeNotifier {
style: const TextStyle(fontSize: 18), style: const TextStyle(fontSize: 18),
) )
]); ]);
} else if (result.data == null) { } else if (result
.data?['transaction_connection']?['edges'].isEmpty) {
return Column(children: <Widget>[ return Column(children: <Widget>[
const SizedBox(height: 50), const SizedBox(height: 50),
Text( Text(

View File

@ -16,6 +16,7 @@ import 'package:gecko/screens/common_elements.dart';
import 'package:gecko/screens/myWallets/restore_chest.dart'; import 'package:gecko/screens/myWallets/restore_chest.dart';
import 'package:gecko/screens/myWallets/unlocking_wallet.dart'; import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
import 'package:gecko/screens/myWallets/wallets_home.dart'; import 'package:gecko/screens/myWallets/wallets_home.dart';
import 'package:gecko/screens/my_contacts.dart';
import 'package:gecko/screens/onBoarding/1.dart'; import 'package:gecko/screens/onBoarding/1.dart';
import 'package:gecko/screens/search.dart'; import 'package:gecko/screens/search.dart';
import 'package:gecko/screens/settings.dart'; import 'package:gecko/screens/settings.dart';
@ -74,6 +75,19 @@ class HomeScreen extends StatelessWidget {
); );
}, },
), ),
ListTile(
key: const Key('contacts'),
title: Text('contactsManagement'.tr()),
onTap: () {
Navigator.pop(context);
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return const ContactsScreen();
}),
);
},
),
ListTile( ListTile(
key: const Key('substrateSandbox'), key: const Key('substrateSandbox'),
title: const Text('Substrate debug'), title: const Text('Substrate debug'),

View File

@ -0,0 +1,122 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/services.dart';
import 'package:gecko/globals.dart';
import 'package:flutter/material.dart';
import 'package:gecko/providers/cesium_plus.dart';
import 'package:gecko/models/g1_wallets_list.dart';
import 'package:gecko/providers/duniter_indexer.dart';
import 'package:gecko/providers/home.dart';
import 'package:gecko/providers/substrate_sdk.dart';
import 'package:gecko/providers/wallet_options.dart';
import 'package:gecko/providers/wallets_profiles.dart';
import 'package:gecko/screens/common_elements.dart';
import 'package:gecko/screens/wallet_view.dart';
import 'package:provider/provider.dart';
class ContactsScreen extends StatelessWidget {
const ContactsScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
CesiumPlusProvider _cesiumPlusProvider =
Provider.of<CesiumPlusProvider>(context, listen: false);
WalletsProfilesProvider _walletsProfilesClass =
Provider.of<WalletsProfilesProvider>(context, listen: false);
HomeProvider _homeProvider =
Provider.of<HomeProvider>(context, listen: false);
DuniterIndexer _duniterIndexer =
Provider.of<DuniterIndexer>(context, listen: false);
int keyID = 0;
double _avatarSize = 55;
final myContacts = contactsBox.toMap().values.toList();
// myContacts.sort((a, b) {
// final aa = a.username?.toLowerCase() ?? '';
// final bb = b.username?.toLowerCase() ?? '';
// return aa.compareTo(bb);
// });
return Scaffold(
backgroundColor: backgroundColor,
appBar: AppBar(
elevation: 1,
toolbarHeight: 60 * ratio,
title: SizedBox(
height: 22,
child: Text('contactsManagement'.tr()),
),
),
bottomNavigationBar: _homeProvider.bottomAppBar(context),
body: SafeArea(
child: Stack(children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
const SizedBox(height: 40),
if (myContacts.isEmpty)
Text('noContacts'.tr())
else
Expanded(
child: ListView(children: <Widget>[
for (G1WalletsList g1Wallet in myContacts)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 5),
child: ListTile(
key: Key('searchResult${keyID++}'),
horizontalTitleGap: 40,
contentPadding: const EdgeInsets.all(5),
leading: _cesiumPlusProvider
.defaultAvatar(_avatarSize),
title: Row(children: <Widget>[
Text(getShortPubkey(g1Wallet.pubkey!),
style: const TextStyle(
fontSize: 18,
fontFamily: 'Monospace',
fontWeight: FontWeight.w500),
textAlign: TextAlign.center),
]),
trailing: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
balance(context, g1Wallet.pubkey!, 16)
]),
subtitle: Row(children: <Widget>[
_duniterIndexer.getNameByAddress(
context, g1Wallet.pubkey!)
]),
dense: false,
isThreeLine: false,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
_walletsProfilesClass.address =
g1Wallet.pubkey;
return WalletViewScreen(
pubkey: g1Wallet.pubkey,
username: g1WalletsBox
.get(g1Wallet.pubkey)
?.id
?.username,
avatar: g1WalletsBox
.get(g1Wallet.pubkey)
?.avatar,
);
}),
);
}),
),
]),
)
]),
),
CommonElements().offlineInfo(context),
]),
),
);
}
}

View File

@ -2,6 +2,7 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:gecko/globals.dart'; import 'package:gecko/globals.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gecko/models/g1_wallets_list.dart';
import 'package:gecko/providers/cesium_plus.dart'; import 'package:gecko/providers/cesium_plus.dart';
import 'package:gecko/providers/home.dart'; import 'package:gecko/providers/home.dart';
import 'package:gecko/providers/substrate_sdk.dart'; import 'package:gecko/providers/substrate_sdk.dart';
@ -25,8 +26,8 @@ class WalletViewScreen extends StatelessWidget {
final String? pubkey; final String? pubkey;
final String? username; final String? username;
final Image? avatar; final Image? avatar;
final double buttonSize = 100; final double buttonSize = 70;
final double buttonFontSize = 18; final double buttonFontSize = 16;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -93,9 +94,9 @@ class WalletViewScreen extends StatelessWidget {
child: const Padding( child: const Padding(
padding: EdgeInsets.all(13), padding: EdgeInsets.all(13),
child: Image( child: Image(
image: AssetImage( image: AssetImage(
'assets/walletOptions/clock.png'), 'assets/walletOptions/clock.png'),
height: 90)), )),
onTap: () { onTap: () {
// _historyProvider.nPage = 1; // _historyProvider.nPage = 1;
Navigator.push( Navigator.push(
@ -119,193 +120,40 @@ class WalletViewScreen extends StatelessWidget {
fontSize: buttonFontSize, fontWeight: FontWeight.w500), fontSize: buttonFontSize, fontWeight: FontWeight.w500),
), ),
]), ]),
Consumer<SubstrateSdk>(builder: (context, _sub, _) { Consumer<WalletsProfilesProvider>(
WalletData? _defaultWallet = builder: (context, _walletProfile, _) {
_myWalletProvider.getDefaultWallet(); return Column(children: <Widget>[
return FutureBuilder( SizedBox(
future: _sub.certState(_defaultWallet.address!, height: buttonSize,
pubkey!), // .canCertify(_defaultWallet.address!, pubkey!), width: buttonSize,
builder: (context, AsyncSnapshot<Map<String, int>> snapshot) { child: ClipOval(
// log.d(snapshot.data); child: Material(
if (snapshot.data == null) return const SizedBox(); color: const Color(0xffFFD58D), // button color
String _duration = ''; child: InkWell(
if (snapshot.data!['certDelay'] != null || key: const Key('addContact'),
snapshot.data!['certRenewable'] != null) { splashColor: orangeC, // inkwell color
final Duration _durationSeconds = Duration( child: const Icon(
seconds: snapshot.data!['certDelay'] ?? Icons.add_reaction_outlined,
snapshot.data!['certRenewable']!); size: 40,
final int _seconds = _durationSeconds.inSeconds;
final int _minutes = _durationSeconds.inMinutes;
if (_seconds <= 0) {
_duration = 'seconds'.tr(args: ['0']);
} else if (_seconds <= 60) {
_duration = 'seconds'.tr(args: [_seconds.toString()]);
} else if (_seconds <= 3600) {
_duration = 'minutes'.tr(args: [_minutes.toString()]);
} else if (_seconds <= 86400) {
final int _hours = _durationSeconds.inHours;
final int _minutesLeft = _minutes - _hours * 60;
String _showMinutes = '';
if (_minutesLeft < 60) {}
_showMinutes =
'minutes'.tr(args: [_minutesLeft.toString()]);
_duration =
'hours'.tr(args: [_hours.toString(), _showMinutes]);
} else if (_seconds <= 2592000) {
final int _days = _durationSeconds.inDays;
_duration = 'days'.tr(args: [_days.toString()]);
} else {
final int _months =
(_durationSeconds.inDays / 30).round();
_duration = 'months'.tr(args: [_months.toString()]);
}
}
return Visibility(
visible: (snapshot.data != {}),
child: Column(children: <Widget>[
if (snapshot.data!['canCert'] != null ||
_duration == 'seconds'.tr(args: ['0']))
Column(children: <Widget>[
SizedBox(
height: buttonSize,
child: ClipOval(
child: Material(
color:
const Color(0xffFFD58D), // button color
child: InkWell(
key: const Key('copyKey'),
splashColor: orangeC, // inkwell color
child: const Padding(
padding: EdgeInsets.only(bottom: 0),
child: Image(
image: AssetImage(
'assets/gecko_certify.png')),
),
onTap: () async {
final bool? _result =
await confirmPopup(
context,
"areYouSureYouWantToCertify".tr(
args: [
getShortPubkey(pubkey!)
]));
if (_result ?? false) {
String? _pin;
if (_myWalletProvider.pinCode == '') {
_pin = await Navigator.push(
context,
MaterialPageRoute(
builder: (homeContext) {
return UnlockingWallet(
wallet: defaultWallet);
},
),
);
}
if (_pin != null ||
_myWalletProvider.pinCode != '') {
WalletsProfilesProvider
_walletViewProvider = Provider
.of<WalletsProfilesProvider>(
context,
listen: false);
final acc = _sub.getCurrentWallet();
_sub.certify(
acc.address!,
_pin ??
_myWalletProvider.pinCode,
_walletViewProvider.address!);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return const TransactionInProgress(
transType: 'cert');
}),
);
}
}
}),
),
),
), ),
const SizedBox(height: 9), onTap: () {
Text( final _newContact = G1WalletsList(
"certify".tr(), pubkey: pubkey!, username: username);
textAlign: TextAlign.center, _walletProfile.addContact(_newContact);
style: TextStyle( }),
fontSize: buttonFontSize, ),
fontWeight: FontWeight.w500), ),
), ),
]), const SizedBox(height: 9),
if (snapshot.data!['certDelay'] != null) Text(
Column(children: <Widget>[ _walletProfile.isContact(pubkey!)
SizedBox( ? "removeContact".tr()
height: buttonSize, : "addContact".tr(),
child: Padding( textAlign: TextAlign.center,
padding: const EdgeInsets.only(bottom: 0), style: TextStyle(
child: Container( fontSize: buttonFontSize, fontWeight: FontWeight.w500),
foregroundDecoration: const BoxDecoration( ),
color: Colors.grey, ]);
backgroundBlendMode: BlendMode.saturation,
),
child: const Opacity(
opacity: 0.5,
child: Image(
image: AssetImage(
'assets/gecko_certify.png')),
),
),
),
),
Text(
"mustWaitXBeforeCertify"
.tr(args: [_duration.toString()]),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: buttonFontSize - 4,
fontWeight: FontWeight.w400,
color: Colors.grey[600]),
),
]),
if (snapshot.data!['certRenewable'] != null &&
_duration != 'seconds'.tr(args: ['0']))
Column(children: <Widget>[
SizedBox(
height: buttonSize,
child: Padding(
padding: const EdgeInsets.only(bottom: 0),
child: Container(
foregroundDecoration: const BoxDecoration(
color: Colors.grey,
backgroundBlendMode: BlendMode.saturation,
),
child: const Opacity(
opacity: 0.5,
child: Image(
image: AssetImage(
'assets/gecko_certify.png')),
),
),
),
),
Text(
"canRenewCertInX"
.tr(args: [_duration.toString()]),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: buttonFontSize - 4,
fontWeight: FontWeight.w400,
color: Colors.grey[600]),
),
]),
]),
);
},
);
}), }),
Column(children: <Widget>[ Column(children: <Widget>[
SizedBox( SizedBox(
@ -317,10 +165,11 @@ class WalletViewScreen extends StatelessWidget {
key: const Key('copyKey'), key: const Key('copyKey'),
splashColor: orangeC, // inkwell color splashColor: orangeC, // inkwell color
child: const Padding( child: const Padding(
padding: EdgeInsets.all(20), padding: EdgeInsets.all(16),
child: Image( child: Image(
image: AssetImage('assets/copy_key.png'), image: AssetImage('assets/copy_key.png'),
height: 90)), ),
),
onTap: () { onTap: () {
Clipboard.setData(ClipboardData(text: pubkey)); Clipboard.setData(ClipboardData(text: pubkey));
snackCopyKey(context); snackCopyKey(context);
@ -337,12 +186,14 @@ class WalletViewScreen extends StatelessWidget {
), ),
]), ]),
]), ]),
const SizedBox(height: 10),
certifyButton(context),
const Spacer(), const Spacer(),
Consumer<SubstrateSdk>(builder: (context, _sub, _) { Consumer<SubstrateSdk>(builder: (context, _sub, _) {
return Opacity( return Opacity(
opacity: _sub.nodeConnected ? 1 : 0.5, opacity: _sub.nodeConnected ? 1 : 0.5,
child: Container( child: Container(
height: buttonSize, height: 90,
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color(0xff7c94b6), color: const Color(0xff7c94b6),
borderRadius: const BorderRadius.all(Radius.circular(100)), borderRadius: const BorderRadius.all(Radius.circular(100)),
@ -379,7 +230,7 @@ class WalletViewScreen extends StatelessWidget {
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
color: _sub.nodeConnected ? Colors.black : Colors.grey[500], color: _sub.nodeConnected ? Colors.black : Colors.grey[500],
fontSize: buttonFontSize, fontSize: buttonFontSize + 1,
fontWeight: FontWeight.w500), fontWeight: FontWeight.w500),
); );
}), }),
@ -677,4 +528,183 @@ class WalletViewScreen extends StatelessWidget {
}); });
}).then((value) => _walletViewProvider.payAmount.text = ''); }).then((value) => _walletViewProvider.payAmount.text = '');
} }
Widget certifyButton(BuildContext context) {
MyWalletsProvider _myWalletProvider =
Provider.of<MyWalletsProvider>(context, listen: false);
WalletData? defaultWallet = _myWalletProvider.getDefaultWallet();
return Consumer<SubstrateSdk>(builder: (context, _sub, _) {
WalletData? _defaultWallet = _myWalletProvider.getDefaultWallet();
return FutureBuilder(
future: _sub.certState(_defaultWallet.address!,
pubkey!), // .canCertify(_defaultWallet.address!, pubkey!),
builder: (context, AsyncSnapshot<Map<String, int>> snapshot) {
// log.d(snapshot.data);
if (snapshot.data == null) return const SizedBox();
String _duration = '';
if (snapshot.data!['certDelay'] != null ||
snapshot.data!['certRenewable'] != null) {
final Duration _durationSeconds = Duration(
seconds: snapshot.data!['certDelay'] ??
snapshot.data!['certRenewable']!);
final int _seconds = _durationSeconds.inSeconds;
final int _minutes = _durationSeconds.inMinutes;
if (_seconds <= 0) {
_duration = 'seconds'.tr(args: ['0']);
} else if (_seconds <= 60) {
_duration = 'seconds'.tr(args: [_seconds.toString()]);
} else if (_seconds <= 3600) {
_duration = 'minutes'.tr(args: [_minutes.toString()]);
} else if (_seconds <= 86400) {
final int _hours = _durationSeconds.inHours;
final int _minutesLeft = _minutes - _hours * 60;
String _showMinutes = '';
if (_minutesLeft < 60) {}
_showMinutes = 'minutes'.tr(args: [_minutesLeft.toString()]);
_duration = 'hours'.tr(args: [_hours.toString(), _showMinutes]);
} else if (_seconds <= 2592000) {
final int _days = _durationSeconds.inDays;
_duration = 'days'.tr(args: [_days.toString()]);
} else {
final int _months = (_durationSeconds.inDays / 30).round();
_duration = 'months'.tr(args: [_months.toString()]);
}
}
return Visibility(
visible: (snapshot.data != {}),
child: Column(children: <Widget>[
if (snapshot.data!['canCert'] != null ||
_duration == 'seconds'.tr(args: ['0']))
Column(children: <Widget>[
SizedBox(
height: 90,
child: ClipOval(
child: Material(
color: const Color(0xffFFD58D), // button color
child: InkWell(
key: const Key('certify'),
splashColor: orangeC, // inkwell color
child: const Padding(
padding: EdgeInsets.all(12),
child: Image(
image:
AssetImage('assets/gecko_certify.png')),
),
onTap: () async {
final bool? _result = await confirmPopup(
context,
"areYouSureYouWantToCertify"
.tr(args: [getShortPubkey(pubkey!)]));
if (_result ?? false) {
String? _pin;
if (_myWalletProvider.pinCode == '') {
_pin = await Navigator.push(
context,
MaterialPageRoute(
builder: (homeContext) {
return UnlockingWallet(
wallet: defaultWallet);
},
),
);
}
if (_pin != null ||
_myWalletProvider.pinCode != '') {
WalletsProfilesProvider _walletViewProvider =
Provider.of<WalletsProfilesProvider>(
context,
listen: false);
final acc = _sub.getCurrentWallet();
_sub.certify(
acc.address!,
_pin ?? _myWalletProvider.pinCode,
_walletViewProvider.address!);
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return const TransactionInProgress(
transType: 'cert');
}),
);
}
}
}),
),
),
),
const SizedBox(height: 9),
Text(
"certify".tr(),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: buttonFontSize, fontWeight: FontWeight.w500),
),
]),
if (snapshot.data!['certDelay'] != null)
Column(children: <Widget>[
SizedBox(
height: buttonSize,
child: Padding(
padding: const EdgeInsets.only(top: 12),
child: Container(
foregroundDecoration: const BoxDecoration(
color: Colors.grey,
backgroundBlendMode: BlendMode.saturation,
),
child: const Opacity(
opacity: 0.5,
child: Image(
image: AssetImage('assets/gecko_certify.png')),
),
),
),
),
Text(
"mustWaitXBeforeCertify".tr(args: [_duration.toString()]),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: buttonFontSize - 2,
fontWeight: FontWeight.w400,
color: Colors.grey[600]),
),
]),
if (snapshot.data!['certRenewable'] != null &&
_duration != 'seconds'.tr(args: ['0']))
Column(children: <Widget>[
SizedBox(
height: buttonSize,
child: Padding(
padding: const EdgeInsets.only(top: 12),
child: Container(
foregroundDecoration: const BoxDecoration(
color: Colors.grey,
backgroundBlendMode: BlendMode.saturation,
),
child: const Opacity(
opacity: 0.5,
child: Image(
image: AssetImage('assets/gecko_certify.png')),
),
),
),
),
Text(
"canRenewCertInX".tr(args: [_duration.toString()]),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: buttonFontSize - 2,
fontWeight: FontWeight.w400,
color: Colors.grey[600]),
),
]),
]),
);
},
);
});
}
} }

View File

@ -1034,8 +1034,8 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
path: "." path: "."
ref: gecko-work ref: gecko-old
resolved-ref: "7b6ffbefcdcedf073eeba41881b8da2fac202e3f" resolved-ref: "87096351fb187614b6386343615db39a2f2b5b9b"
url: "https://github.com/poka-IT/sdk.git" url: "https://github.com/poka-IT/sdk.git"
source: git source: git
version: "0.4.8" version: "0.4.8"

View File

@ -5,7 +5,7 @@ description: Pay with G1.
# pub.dev using `pub publish`. This is preferred for private packages. # pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 0.0.9+13 version: 0.0.9+14
environment: environment:
sdk: '>=2.12.0 <3.0.0' sdk: '>=2.12.0 <3.0.0'
@ -64,10 +64,10 @@ dependencies:
desktop_window: ^0.4.0 desktop_window: ^0.4.0
durt: ^0.1.6 durt: ^0.1.6
package_info_plus: ^1.4.2 package_info_plus: ^1.4.2
polkawallet_sdk: #^0.4.7 polkawallet_sdk: #^0.4.8
git: git:
url: https://github.com/poka-IT/sdk.git #https://github.com/poka-IT/sdk.git url: https://github.com/poka-IT/sdk.git #https://github.com/poka-IT/sdk.git
ref: gecko-work ref: gecko-old
dots_indicator: ^2.1.0 dots_indicator: ^2.1.0
web_socket_channel: ^2.2.0 web_socket_channel: ^2.2.0
connectivity_plus: ^2.3.3 connectivity_plus: ^2.3.3