Skip to content

Commit

Permalink
Merge branch 'version10'
Browse files Browse the repository at this point in the history
  • Loading branch information
amazingCoding committed Apr 16, 2023
2 parents fec3867 + 1bff968 commit a0e14a2
Show file tree
Hide file tree
Showing 30 changed files with 218 additions and 157 deletions.
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<application
android:enableOnBackInvokedCallback="true"
android:label="XDAG-Pro"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
Expand Down
5 changes: 2 additions & 3 deletions lib/common/global.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,8 @@ class Global {
),
],
options: const AuthenticationOptions(biometricOnly: true, sensitiveTransaction: false));
} on PlatformException catch (e) {
// print(e);
}
// ignore: empty_catches
} on PlatformException {}
return authenticated;
}

Expand Down
1 change: 1 addition & 0 deletions lib/common/transaction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class TransactionHelper {

static bool checkAddress(String address) {
try {
if (address.isEmpty) return false;
var addrBytes = Helper.base58Decode(address).reversed.toList();
Helper.base58Decode('4AzP6NX68y854ztnSMuBYLj8KHHAtX5HK').reversed.toList();
if (addrBytes.length != 24) {
Expand Down
3 changes: 2 additions & 1 deletion lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,6 @@
"no_contacts":"Keine Kontakte",
"tips":"Tipps",
"wallet_tips":"Wischen Sie den Eintrag nach rechts, um das Wallet zu löschen。",
"hide_balance":"Guthaben ausblenden"
"hide_balance":"Guthaben ausblenden",
"contact_address_repeat": "Kontaktadresse existiert bereits"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,6 @@
"no_contacts":"Any contact",
"tips":"Tips",
"wallet_tips":"Swipe the item to the right to delete the wallet.",
"hide_balance":"Hide Balance"
"hide_balance":"Hide Balance",
"contact_address_repeat":"Contact address already exists"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,6 @@
"no_contacts":"Aucun contact",
"tips":"Conseils",
"wallet_tips":"Balayez l'élément vers la droite pour supprimer le portefeuille.",
"hide_balance":"Masquer le solde"
"hide_balance":"Masquer le solde",
"contact_address_repeat": "L'adresse de contact existe déjà"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_ja.arb
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,6 @@
"no_contacts":"連絡先がありません",
"tips":"ヒント",
"wallet_tips":"ウォレットを削除するには、アイテムを右にスワイプしてください。",
"hide_balance":"残高を非表示"
"hide_balance":"残高を非表示",
"contact_address_repeat": "連絡先がすでに存在しています"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_ru.arb
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,6 @@
"no_contacts":"Нет контактов",
"tips":"Советы",
"wallet_tips":"Чтобы удалить кошелек, проведите элемент вправо.",
"hide_balance":"Скрыть баланс"
"hide_balance":"Скрыть баланс",
"contact_address_repeat": "Контактный адрес уже существует"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,6 @@
"no_contacts":"没有联系人",
"tips":"提示",
"wallet_tips":"向右滑动该项以删除钱包。",
"hide_balance":"隐藏余额"
"hide_balance":"隐藏余额",
"contact_address_repeat": "联系地址已存在"
}
2 changes: 0 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_statusbarcolor_ns/flutter_statusbarcolor_ns.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:xdag/common/color.dart';
Expand Down Expand Up @@ -109,7 +108,6 @@ class MyWidget extends StatelessWidget {
"/create": (context) => const CreateWalletPage(),
"/faceid": (context) => const FaceIDPage(),
"/select": (context) => const WalletListPage(),
// "/security_wallet": (context) => const SecureWalletPage(),
"/wallet": (context) => const WalletHomePage(),
"/security": (context) => const SecurityPage(),
"/legal": (context) => const LegalPage(),
Expand Down
20 changes: 17 additions & 3 deletions lib/page/common/add_contacts_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:io';
import 'package:auto_size_text_field/auto_size_text_field.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:xdag/common/color.dart';
Expand Down Expand Up @@ -41,9 +40,9 @@ class _AddContactsPage extends State<AddContactsPage> {

@override
Widget build(BuildContext context) {
bool isButtonEnable = controller.text.isNotEmpty && controller2.text.isNotEmpty;
bool isButtonEnable = controller.text.trim().isNotEmpty && controller2.text.isNotEmpty;
if (widget.isEdit) {
isButtonEnable = controller.text.isNotEmpty && controller2.text.isNotEmpty && (controller.text != widget.item!.address || controller2.text != widget.item!.name);
isButtonEnable = controller.text.trim().isNotEmpty && controller2.text.isNotEmpty && (controller.text != widget.item!.address || controller2.text != widget.item!.name);
}
ContactsModal contacts = Provider.of<ContactsModal>(context);
return Scaffold(
Expand Down Expand Up @@ -104,6 +103,7 @@ class _AddContactsPage extends State<AddContactsPage> {
error = AppLocalizations.of(context).walletAddressError;
});
}
// ignore: empty_catches
} catch (e) {}
},
child: Row(
Expand Down Expand Up @@ -259,6 +259,20 @@ class _AddContactsPage extends State<AddContactsPage> {
if (widget.isEdit) {
await contacts.changeContacts(index: widget.index, name: controller2.text, address: controller.text);
} else {
// 检查有没有重复地址
bool hasRepeat = false;
for (var i = 0; i < contacts.contactsList.length; i++) {
if (contacts.contactsList[i].address == controller.text) {
hasRepeat = true;
break;
}
}
if (hasRepeat) {
setState(() {
error = AppLocalizations.of(context).contact_address_repeat;
});
return;
}
await contacts.addContacts(name: controller2.text, address: controller.text);
}
if (mounted) Navigator.pop(context);
Expand Down
4 changes: 0 additions & 4 deletions lib/page/common/check_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:xdag/common/color.dart';
Expand Down Expand Up @@ -53,8 +51,6 @@ class _CheckPageState extends State<CheckPage> {
tipsText = AppLocalizations.of(context).use_biometrics_tips_3;
}
var padding = Helper.isDesktop ? 10.0 : ScreenHelper.topPadding;

// print(Global.devBiometricsType != -1 && !widget.onlyPassword);
return Scaffold(
backgroundColor: DarkColors.bgColor,
body: WillPopScope(
Expand Down
3 changes: 1 addition & 2 deletions lib/page/common/create_wallet_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:isolate';
import 'package:auto_size_text_field/auto_size_text_field.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -106,7 +105,7 @@ class _CreateWalletPageState extends State<CreateWalletPage> {
args = ModalRoute.of(context)!.settings.arguments as CreateWalletPageRouteParams;
}
int selectIndex = isPrivateKey ? 1 : 0;
bool isButtonEnable = walletName.isNotEmpty && isAgree;
bool isButtonEnable = walletName.trim().isNotEmpty && isAgree;
if (args.isImport) {
if (isPrivateKey) {
isButtonEnable = isButtonEnable && importContent.length == 64;
Expand Down
2 changes: 0 additions & 2 deletions lib/page/common/face_id_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:xdag/common/color.dart';
Expand Down
72 changes: 0 additions & 72 deletions lib/page/common/secure_wallet_page.dart

This file was deleted.

41 changes: 25 additions & 16 deletions lib/page/detail/contacts_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:io';
import 'package:auto_size_text_field/auto_size_text_field.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:xdag/common/color.dart';
Expand All @@ -23,7 +22,7 @@ class ContactsPage extends StatefulWidget {

class ContactsStatePage extends State<ContactsPage> {
late TextEditingController controller;
String walletAddress = "";
bool isButtonEnable = false;
String error = "";
@override
void initState() {
Expand All @@ -33,7 +32,7 @@ class ContactsStatePage extends State<ContactsPage> {

@override
Widget build(BuildContext context) {
bool isButtonEnable = walletAddress.isNotEmpty;
// bool isButtonEnable = controller.text.isNotEmpty;
ContactsModal contacts = Provider.of<ContactsModal>(context);
return Scaffold(
backgroundColor: DarkColors.bgColor,
Expand Down Expand Up @@ -75,7 +74,8 @@ class ContactsStatePage extends State<ContactsPage> {
bool flag = TransactionHelper.checkAddress(res);
if (flag) {
setState(() {
walletAddress = res;
// walletAddress = res;
isButtonEnable = true;
error = "";
});
controller.text = res;
Expand All @@ -84,18 +84,21 @@ class ContactsStatePage extends State<ContactsPage> {
controller.clear();
controller.selection = TextSelection.fromPosition(const TextPosition(offset: 0));
setState(() {
walletAddress = "";
// walletAddress = "";
isButtonEnable = false;
error = AppLocalizations.of(context).walletAddressError;
});
}
} else {
controller.clear();
controller.selection = TextSelection.fromPosition(const TextPosition(offset: 0));
setState(() {
walletAddress = "";
// walletAddress = "";
isButtonEnable = false;
error = AppLocalizations.of(context).walletAddressError;
});
}
// ignore: empty_catches
} catch (e) {}
},
child: Row(
Expand All @@ -118,7 +121,7 @@ class ContactsStatePage extends State<ContactsPage> {
controller: controller,
onChanged: (value) {
setState(() {
walletAddress = value;
isButtonEnable = value.isNotEmpty;
error = "";
});
},
Expand Down Expand Up @@ -209,13 +212,19 @@ class ContactsStatePage extends State<ContactsPage> {
return MyCupertinoButton(
padding: EdgeInsets.zero,
onPressed: () async {
controller.text = item.address;
controller.selection = TextSelection.fromPosition(TextPosition(offset: item.address.length));
Navigator.pushNamed(
context,
'/send',
arguments: SendPageRouteParams(address: item.address),
);
// controller.text = item.address;
// controller.selection = TextSelection.fromPosition(TextPosition(offset: item.address.length));
// setState(() {
// isButtonEnable = true;
// error = "";
// });
if (mounted) {
Navigator.pushNamed(
context,
'/send',
arguments: SendPageRouteParams(address: item.address, name: item.name),
);
}
},
child: Container(
decoration: BoxDecoration(
Expand Down Expand Up @@ -265,12 +274,12 @@ class ContactsStatePage extends State<ContactsPage> {
disable: !isButtonEnable,
onPressed: () async {
// to send
bool flag = TransactionHelper.checkAddress(walletAddress);
bool flag = TransactionHelper.checkAddress(controller.text);
if (flag) {
Navigator.pushNamed(
context,
'/send',
arguments: SendPageRouteParams(address: walletAddress),
arguments: SendPageRouteParams(address: controller.text),
);
} else {
setState(() {
Expand Down
1 change: 0 additions & 1 deletion lib/page/detail/receive_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
Expand Down
Loading

0 comments on commit a0e14a2

Please sign in to comment.