Compare commits
4 Commits
master
...
contactsMa
Author | SHA1 | Date |
---|---|---|
poka | 2037003e6e | |
poka | f275644b83 | |
poka | e40fabda61 | |
poka | f1063efafa |
24
.metadata
24
.metadata
|
@ -1,10 +1,30 @@
|
|||
# This file tracks properties of this Flutter project.
|
||||
# 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:
|
||||
revision: 1aafb3a8b9b0c36241c5f5b34ee914770f015818
|
||||
revision: 85684f9300908116a78138ea4c6036c35c9a1236
|
||||
channel: stable
|
||||
|
||||
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'
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
package gecko.axiomteam.gecko
|
||||
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
|
||||
class MainActivity: FlutterActivity() {
|
||||
}
|
|
@ -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>
|
|
@ -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>
|
|
@ -109,7 +109,7 @@
|
|||
"accountActivity": "Account activity",
|
||||
"noNetworkNoHistory": "Network state does not allow\nto display account history",
|
||||
"noDataToDisplay": "No data to be displayed.",
|
||||
"noTranscationToDisplay": "No transaction to display",
|
||||
"noTransactionToDisplay": "No transaction to display",
|
||||
"month1": "January",
|
||||
"month2": "February",
|
||||
"month3": "March",
|
||||
|
@ -168,5 +168,10 @@
|
|||
"cancel": "Cancel",
|
||||
"inBlockchainResult": "In {} blockchain",
|
||||
"search": "Search",
|
||||
"currencyNode": "{} node :"
|
||||
"currencyNode": "{} node :",
|
||||
"contactsManagement": "My contacts",
|
||||
"noContacts": "You don't have any contact",
|
||||
"addContact": "Add\nto contacts",
|
||||
"removeContact": "Remove\nthis contact"
|
||||
|
||||
}
|
|
@ -109,7 +109,7 @@
|
|||
"accountActivity": "Account activity",
|
||||
"noNetworkNoHistory": "Network state does not allow\nto display account history",
|
||||
"noDataToDisplay": "No data to be displayed.",
|
||||
"noTranscationToDisplay": "No transaction to display",
|
||||
"noTransactionToDisplay": "No transaction to display",
|
||||
"month1": "January",
|
||||
"month2": "February",
|
||||
"month3": "March",
|
||||
|
@ -168,5 +168,9 @@
|
|||
"cancel": "Cancel",
|
||||
"inBlockchainResult": "In {} blockchain",
|
||||
"search": "Search",
|
||||
"currencyNode": "{} node :"
|
||||
"currencyNode": "{} node :",
|
||||
"contactsManagement": "My contacts",
|
||||
"noContacts": "You don't have any contact",
|
||||
"addContact": "Add\nto contacts",
|
||||
"removeContact": "Remove\nthis contact"
|
||||
}
|
|
@ -110,7 +110,7 @@
|
|||
"accountActivity": "Activité du compte",
|
||||
"noNetworkNoHistory": "L'état du réseau ne permet pas\nd'afficher l'historique du compte",
|
||||
"noDataToDisplay": "Aucune donnée à afficher.",
|
||||
"noTranscationToDisplay": "Aucune transaction à afficher",
|
||||
"noTransactionToDisplay": "Aucune transaction à afficher",
|
||||
"month1": "Janvier",
|
||||
"month2": "Février",
|
||||
"month3": "Mars",
|
||||
|
@ -169,5 +169,9 @@
|
|||
"cancel": "Annuler",
|
||||
"inBlockchainResult": "Dans la blockchain {}",
|
||||
"search": "Rechercher",
|
||||
"currencyNode": "Noeud {} :"
|
||||
"currencyNode": "Noeud {} :",
|
||||
"contactsManagement": "Mes contacts",
|
||||
"noContacts": "Vous n'avez aucun contact",
|
||||
"addContact": "Ajouter\naux contacts",
|
||||
"removeContact": "Supprimer\nce contact"
|
||||
}
|
|
@ -22,6 +22,8 @@ late Box<WalletData> walletBox;
|
|||
late Box<ChestData> chestBox;
|
||||
late Box configBox;
|
||||
late Box<G1WalletsList> g1WalletsBox;
|
||||
late Box<G1WalletsList> contactsBox;
|
||||
|
||||
// late Box keystoreBox;
|
||||
late Directory imageDirectory;
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ Future<void> main() async {
|
|||
configBox = await Hive.openBox("configBox");
|
||||
await Hive.deleteBoxFromDisk('g1WalletsBox');
|
||||
g1WalletsBox = await Hive.openBox<G1WalletsList>("g1WalletsBox");
|
||||
contactsBox = await Hive.openBox<G1WalletsList>("contactsBox");
|
||||
|
||||
await _homeProvider.getValidEndpoints();
|
||||
// await configBox.delete('isCacheChecked');
|
||||
|
@ -106,7 +107,7 @@ Future<void> main() async {
|
|||
},
|
||||
appRunner: () => runApp(
|
||||
EasyLocalization(
|
||||
supportedLocales: const [Locale('en'), Locale('fr')],
|
||||
supportedLocales: const [Locale('en'), Locale('fr'), Locale('es')],
|
||||
path: 'assets/translations',
|
||||
fallbackLocale: const Locale('en'),
|
||||
child: Gecko(indexerEndpoint),
|
||||
|
|
|
@ -369,7 +369,6 @@ class GenerateWalletsProvider with ChangeNotifier {
|
|||
Future<bool> scanDerivations(BuildContext context,
|
||||
{int numberScan = 20}) async {
|
||||
SubstrateSdk _sub = Provider.of<SubstrateSdk>(context, listen: false);
|
||||
final ss58 = _sub.ss58;
|
||||
final currentChestNumber = configBox.get('currentChest');
|
||||
bool isAlive = false;
|
||||
scanedWalletNumber = 0;
|
||||
|
|
|
@ -19,8 +19,6 @@ import 'package:truncate/truncate.dart';
|
|||
// import 'package:web_socket_channel/io.dart';
|
||||
|
||||
class SubstrateSdk with ChangeNotifier {
|
||||
final int ss58 = 42;
|
||||
|
||||
final WalletSDK sdk = WalletSDK();
|
||||
final Keyring keyring = Keyring();
|
||||
String generatedMnemonic = '';
|
||||
|
@ -262,6 +260,7 @@ class SubstrateSdk with ChangeNotifier {
|
|||
|
||||
Future<double> getBalance(String address, {bool isUd = false}) async {
|
||||
double balance = 0.0;
|
||||
|
||||
// log.d('nodeConnected: ' + nodeConnected.toString());
|
||||
if (nodeConnected) {
|
||||
final brutBalance = await sdk.api.account.queryBalance(address);
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'package:easy_localization/easy_localization.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.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/substrate_sdk.dart';
|
||||
import 'package:gecko/providers/wallet_options.dart';
|
||||
|
@ -186,30 +187,7 @@ class WalletsProfilesProvider with ChangeNotifier {
|
|||
_walletOptions.idtyStatus(context, _address,
|
||||
isOwner: false, color: Colors.black),
|
||||
getCerts(context, _address, 14),
|
||||
if (username == null &&
|
||||
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 SizedBox(height: 40),
|
||||
]),
|
||||
const Spacer(),
|
||||
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() {
|
||||
notifyListeners();
|
||||
}
|
||||
|
|
|
@ -111,7 +111,8 @@ class ActivityScreen extends StatelessWidget with ChangeNotifier {
|
|||
style: const TextStyle(fontSize: 18),
|
||||
)
|
||||
]);
|
||||
} else if (result.data == null) {
|
||||
} else if (result
|
||||
.data?['transaction_connection']?['edges'].isEmpty) {
|
||||
return Column(children: <Widget>[
|
||||
const SizedBox(height: 50),
|
||||
Text(
|
||||
|
|
|
@ -16,6 +16,7 @@ import 'package:gecko/screens/common_elements.dart';
|
|||
import 'package:gecko/screens/myWallets/restore_chest.dart';
|
||||
import 'package:gecko/screens/myWallets/unlocking_wallet.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/search.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(
|
||||
key: const Key('substrateSandbox'),
|
||||
title: const Text('Substrate debug'),
|
||||
|
|
|
@ -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),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ 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/models/g1_wallets_list.dart';
|
||||
import 'package:gecko/providers/cesium_plus.dart';
|
||||
import 'package:gecko/providers/home.dart';
|
||||
import 'package:gecko/providers/substrate_sdk.dart';
|
||||
|
@ -25,8 +26,8 @@ class WalletViewScreen extends StatelessWidget {
|
|||
final String? pubkey;
|
||||
final String? username;
|
||||
final Image? avatar;
|
||||
final double buttonSize = 100;
|
||||
final double buttonFontSize = 18;
|
||||
final double buttonSize = 70;
|
||||
final double buttonFontSize = 16;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -93,9 +94,9 @@ class WalletViewScreen extends StatelessWidget {
|
|||
child: const Padding(
|
||||
padding: EdgeInsets.all(13),
|
||||
child: Image(
|
||||
image: AssetImage(
|
||||
'assets/walletOptions/clock.png'),
|
||||
height: 90)),
|
||||
image: AssetImage(
|
||||
'assets/walletOptions/clock.png'),
|
||||
)),
|
||||
onTap: () {
|
||||
// _historyProvider.nPage = 1;
|
||||
Navigator.push(
|
||||
|
@ -119,193 +120,40 @@ class WalletViewScreen extends StatelessWidget {
|
|||
fontSize: buttonFontSize, fontWeight: FontWeight.w500),
|
||||
),
|
||||
]),
|
||||
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: 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');
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
}),
|
||||
),
|
||||
),
|
||||
Consumer<WalletsProfilesProvider>(
|
||||
builder: (context, _walletProfile, _) {
|
||||
return Column(children: <Widget>[
|
||||
SizedBox(
|
||||
height: buttonSize,
|
||||
width: buttonSize,
|
||||
child: ClipOval(
|
||||
child: Material(
|
||||
color: const Color(0xffFFD58D), // button color
|
||||
child: InkWell(
|
||||
key: const Key('addContact'),
|
||||
splashColor: orangeC, // inkwell color
|
||||
child: const Icon(
|
||||
Icons.add_reaction_outlined,
|
||||
size: 40,
|
||||
),
|
||||
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(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(
|
||||
"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]),
|
||||
),
|
||||
]),
|
||||
]),
|
||||
);
|
||||
},
|
||||
);
|
||||
onTap: () {
|
||||
final _newContact = G1WalletsList(
|
||||
pubkey: pubkey!, username: username);
|
||||
_walletProfile.addContact(_newContact);
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 9),
|
||||
Text(
|
||||
_walletProfile.isContact(pubkey!)
|
||||
? "removeContact".tr()
|
||||
: "addContact".tr(),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: buttonFontSize, fontWeight: FontWeight.w500),
|
||||
),
|
||||
]);
|
||||
}),
|
||||
Column(children: <Widget>[
|
||||
SizedBox(
|
||||
|
@ -317,10 +165,11 @@ class WalletViewScreen extends StatelessWidget {
|
|||
key: const Key('copyKey'),
|
||||
splashColor: orangeC, // inkwell color
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: Image(
|
||||
image: AssetImage('assets/copy_key.png'),
|
||||
height: 90)),
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Image(
|
||||
image: AssetImage('assets/copy_key.png'),
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
Clipboard.setData(ClipboardData(text: pubkey));
|
||||
snackCopyKey(context);
|
||||
|
@ -337,12 +186,14 @@ class WalletViewScreen extends StatelessWidget {
|
|||
),
|
||||
]),
|
||||
]),
|
||||
const SizedBox(height: 10),
|
||||
certifyButton(context),
|
||||
const Spacer(),
|
||||
Consumer<SubstrateSdk>(builder: (context, _sub, _) {
|
||||
return Opacity(
|
||||
opacity: _sub.nodeConnected ? 1 : 0.5,
|
||||
child: Container(
|
||||
height: buttonSize,
|
||||
height: 90,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xff7c94b6),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(100)),
|
||||
|
@ -379,7 +230,7 @@ class WalletViewScreen extends StatelessWidget {
|
|||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: _sub.nodeConnected ? Colors.black : Colors.grey[500],
|
||||
fontSize: buttonFontSize,
|
||||
fontSize: buttonFontSize + 1,
|
||||
fontWeight: FontWeight.w500),
|
||||
);
|
||||
}),
|
||||
|
@ -677,4 +528,183 @@ class WalletViewScreen extends StatelessWidget {
|
|||
});
|
||||
}).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]),
|
||||
),
|
||||
]),
|
||||
]),
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1034,8 +1034,8 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: gecko-work
|
||||
resolved-ref: "7b6ffbefcdcedf073eeba41881b8da2fac202e3f"
|
||||
ref: gecko-old
|
||||
resolved-ref: "87096351fb187614b6386343615db39a2f2b5b9b"
|
||||
url: "https://github.com/poka-IT/sdk.git"
|
||||
source: git
|
||||
version: "0.4.8"
|
||||
|
|
|
@ -5,7 +5,7 @@ description: Pay with G1.
|
|||
# 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
|
||||
|
||||
version: 0.0.9+13
|
||||
version: 0.0.9+14
|
||||
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
|
@ -64,10 +64,10 @@ dependencies:
|
|||
desktop_window: ^0.4.0
|
||||
durt: ^0.1.6
|
||||
package_info_plus: ^1.4.2
|
||||
polkawallet_sdk: #^0.4.7
|
||||
polkawallet_sdk: #^0.4.8
|
||||
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
|
||||
web_socket_channel: ^2.2.0
|
||||
connectivity_plus: ^2.3.3
|
||||
|
|
Loading…
Reference in New Issue