Skip to content

Commit

Permalink
update mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
amazingCoding committed Apr 19, 2023
1 parent 17b3bce commit 738422a
Show file tree
Hide file tree
Showing 44 changed files with 510 additions and 353 deletions.
2 changes: 2 additions & 0 deletions lib/common/color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class DarkColors {
static const transactionColor = Color(0x4DA0A3BD);
static const greenColor = Color(0xFF168A3C);
static const redColor = Color(0xFFDD4556);
// gold
static const yellowColor = Color(0xFFE8B000);
// 20% opacity
static const redColorMask = Color(0x33DD4556);
// 40% opacity
Expand Down
15 changes: 13 additions & 2 deletions lib/common/global.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class Global {

static const String rpcURL = 'https://testnet-rpc.xdagj.org';
static const String explorURL = 'https://testexplorer.xdag.io/api';

static const String mainRpcURL = 'https://mainnet-rpc.xdagj.org';
static const String mainExplorURL = 'https://mainnet-explorer.xdagj.org/api';

static const bool isTest = false;

static SharedPreferences get prefs => _prefs;
Expand All @@ -59,7 +63,9 @@ class Global {
walletConfig = WalletConfig(local: 0, hasSetPassword: false, hasSetBiometrics: false);
walletListBox = await Hive.openBox<Wallet>(walletListKey);
List<String>? contactsList = _prefs.getStringList(contactsListKey);
contactsListBox = [];
contactsListBox = [
ContactsItem("Community Fund", '4duPWMbYUgAifVYkKDCWxLvRRkSByf5gb'),
];
if (contactsList != null) {
for (var item in contactsList) {
contactsListBox.add(ContactsItem.fromJson(item));
Expand All @@ -75,7 +81,7 @@ class Global {
static updateConfig() async {
// locale
int locale = _prefs.getInt(_localeKey) ?? 0;
int network = _prefs.getInt(_newWorkKey) ?? 1;
int network = _prefs.getInt(_newWorkKey) ?? 0;
// secure
bool hasSetPassword = await _storage.containsKey(key: _passwordKey);
bool hasSetBiometrics = _prefs.getBool(_biometricsKey) ?? false;
Expand All @@ -94,6 +100,11 @@ class Global {
walletConfig.local = index;
}

static saveNetwork(int index) async {
await _prefs.setInt(_newWorkKey, index);
walletConfig.network = index;
}

static savePassword(String password) async {
await _storage.write(key: _passwordKey, value: password);
walletConfig.hasSetPassword = true;
Expand Down
13 changes: 7 additions & 6 deletions lib/common/helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ class Helper {
static final GlobalKey<ScaffoldMessengerState> scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
static bool isDesktop = Platform.isLinux || Platform.isMacOS || Platform.isWindows;
static bool checkName(String name) {
// only allow letters, numbers, and spaces
RegExp regExp = RegExp(r"^[a-zA-Z0-9 ]+$");
return regExp.hasMatch(name);
// RegExp regExp = RegExp(r"^[a-zA-Z0-9\u4e00-\u9fa5]+$");
RegExp regExp2 = RegExp(r",");
// print(regExp2.hasMatch(name));
return !regExp2.hasMatch(name);
}

static String removeTrailingZeros(String str) {
Expand Down Expand Up @@ -79,7 +80,7 @@ class Helper {
duration: const Duration(seconds: 1),
content: Text(
msg,
style: const TextStyle(fontSize: 14, fontFamily: 'RobotoMono', fontWeight: FontWeight.w400, color: Colors.white),
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w400, color: Colors.white),
),
));
}
Expand All @@ -90,7 +91,7 @@ class Helper {
behavior: SnackBarBehavior.floating,
content: Text(
msg,
style: const TextStyle(fontSize: 14, fontFamily: 'RobotoMono', fontWeight: FontWeight.w400, color: Colors.white),
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w400, color: Colors.white),
),
));
}
Expand Down Expand Up @@ -126,7 +127,7 @@ class Helper {
child: Center(
child: Text(
title,
style: const TextStyle(color: Colors.white, fontFamily: 'RobotoMono', fontSize: 20.0, fontWeight: FontWeight.w700),
style: const TextStyle(color: Colors.white, fontSize: 20.0, fontWeight: FontWeight.w700),
),
)),
const SizedBox(width: 40)
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 @@ -122,5 +122,6 @@
"tips":"Tipps",
"wallet_tips":"Wischen Sie den Eintrag nach rechts, um das Wallet zu löschen。",
"hide_balance":"Guthaben ausblenden",
"contact_address_repeat": "Kontaktadresse existiert bereits"
"contact_address_repeat": "Kontaktadresse existiert bereits",
"no_wallets":"Keine Wallet"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,6 @@
"tips":"Tips",
"wallet_tips":"Swipe the item to the right to delete the wallet.",
"hide_balance":"Hide Balance",
"contact_address_repeat":"Contact address already exists"
"contact_address_repeat":"Contact address already exists",
"no_wallets":"Any wallet"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,6 @@
"tips": "Consejos",
"wallet_tips": "Desliza el elemento hacia la derecha para eliminar la billetera.",
"hide_balance": "Ocultar saldo",
"contact_address_repeat": "La dirección del contacto ya existe"
"contact_address_repeat": "La dirección del contacto ya existe",
"no_wallets": "Cualquier cartera"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,6 @@
"tips":"Conseils",
"wallet_tips":"Balayez l'élément vers la droite pour supprimer le portefeuille.",
"hide_balance":"Masquer le solde",
"contact_address_repeat": "L'adresse de contact existe déjà"
"contact_address_repeat": "L'adresse de contact existe déjà",
"no_wallets": "Aucun portefeuille"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_it.arb
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,6 @@
"tips": "Suggerimenti",
"wallet_tips": "Scorri l'elemento verso destra per eliminare il portafoglio",
"hide_balance": "Nascondi saldo",
"contact_address_repeat": "L'indirizzo del contatto è già stato aggiunto"
"contact_address_repeat": "L'indirizzo del contatto è già stato aggiunto",
"no_wallets": "Nessun portafoglio"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_ja.arb
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,6 @@
"tips":"ヒント",
"wallet_tips":"ウォレットを削除するには、アイテムを右にスワイプしてください。",
"hide_balance":"残高を非表示",
"contact_address_repeat": "連絡先がすでに存在しています"
"contact_address_repeat": "連絡先がすでに存在しています",
"no_wallets":"ウォレットがありません"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_ru.arb
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,6 @@
"tips":"Советы",
"wallet_tips":"Чтобы удалить кошелек, проведите элемент вправо.",
"hide_balance":"Скрыть баланс",
"contact_address_repeat": "Контактный адрес уже существует"
"contact_address_repeat": "Контактный адрес уже существует",
"no_wallets":"Нет кошельков"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,6 @@
"tips":"提示",
"wallet_tips":"向右滑动该项以删除钱包。",
"hide_balance":"隐藏余额",
"contact_address_repeat": "联系地址已存在"
"contact_address_repeat": "联系地址已存在",
"no_wallets":"没有钱包"
}
3 changes: 2 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ class MyWidget extends StatelessWidget {
supportedLocales: AppLocalizations.supportedLocales,
locale: configModal.local,
theme: ThemeData(
fontFamily: "RobotoMono",
// 日文,中文使用系统默认字体
fontFamily: configModal.local == const Locale("ja") || configModal.local == const Locale("zh") ? "system-font" : "RobotoMono",
scrollbarTheme: !Helper.isDesktop
? null
: ScrollbarThemeData(
Expand Down
13 changes: 13 additions & 0 deletions lib/model/config_modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ class ConfigModal extends ChangeNotifier {
notifyListeners();
}

String getCurrentRpc() {
return walletConfig.network == 0 ? Global.mainRpcURL : Global.rpcURL;
}

String getCurrentExplorer() {
return walletConfig.network == 0 ? Global.mainExplorURL : Global.explorURL;
}

changeNetwork(int pos) async {
await Global.saveNetwork(pos);
notifyListeners();
}

savePassword(String password) async {
await Global.savePassword(password);
notifyListeners();
Expand Down
12 changes: 12 additions & 0 deletions lib/model/wallet_modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ class WalletModal extends ChangeNotifier {
return defaultWallet ?? Wallet('', '', '', true, true, false);
}

// 获取去除当前钱包的其他钱包
List<Wallet> getOtherWallet() {
List<Wallet> list = [];
for (var i = 0; i < walletList.length; i++) {
Wallet? wallet = walletList.getAt(i);
if (wallet != null && wallet.address != defaultWallet?.address) {
list.add(wallet);
}
}
return list;
}

createWallet({required String name, required String address, required String data, bool needBackUp = false}) async {
try {
Wallet newWallet = await Global.createWallet(
Expand Down
10 changes: 6 additions & 4 deletions lib/page/common/add_contacts_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class _AddContactsPage extends State<AddContactsPage> {
},
textInputAction: TextInputAction.next,
keyboardAppearance: Brightness.dark,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w500, color: Colors.white, fontFamily: 'RobotoMono'),
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w500, color: Colors.white),
decoration: InputDecoration(
filled: true,
contentPadding: const EdgeInsets.all(15),
Expand All @@ -157,7 +157,6 @@ class _AddContactsPage extends State<AddContactsPage> {
decoration: TextDecoration.none,
fontSize: 16,
fontWeight: FontWeight.w500,
fontFamily: 'RobotoMono',
color: Colors.white54,
),
enabledBorder: const OutlineInputBorder(
Expand Down Expand Up @@ -193,7 +192,11 @@ class _AddContactsPage extends State<AddContactsPage> {
},
textInputAction: TextInputAction.next,
keyboardAppearance: Brightness.dark,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w500, color: Colors.white, fontFamily: 'RobotoMono'),
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.white,
),
decoration: InputDecoration(
filled: true,
contentPadding: const EdgeInsets.all(15),
Expand All @@ -203,7 +206,6 @@ class _AddContactsPage extends State<AddContactsPage> {
decoration: TextDecoration.none,
fontSize: 16,
fontWeight: FontWeight.w500,
fontFamily: 'RobotoMono',
color: Colors.white54,
),
enabledBorder: const OutlineInputBorder(
Expand Down
13 changes: 8 additions & 5 deletions lib/page/common/back_up_test_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ class _BackUpTestPageState extends State<BackUpTestPage> {
);
},
textInputAction: TextInputAction.done,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w500, color: Colors.white, fontFamily: 'RobotoMono'),
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.white,
),
decoration: InputDecoration(
filled: true,
contentPadding: const EdgeInsets.all(15),
Expand All @@ -223,7 +227,6 @@ class _BackUpTestPageState extends State<BackUpTestPage> {
decoration: TextDecoration.none,
fontSize: 16,
fontWeight: FontWeight.w500,
fontFamily: 'RobotoMono',
color: Colors.white54,
),
enabledBorder: const OutlineInputBorder(
Expand Down Expand Up @@ -331,17 +334,17 @@ class _BackUpTestPageState extends State<BackUpTestPage> {
const SizedBox(height: 20),
Text(
AppLocalizations.of(context).successful,
style: const TextStyle(color: DarkColors.mainColor, fontFamily: 'RobotoMono', fontSize: 24.0, fontWeight: FontWeight.w700),
style: const TextStyle(color: DarkColors.mainColor, fontSize: 24.0, fontWeight: FontWeight.w700),
),
const SizedBox(height: 20),
Text(
AppLocalizations.of(context).backup_test_tips_4,
style: const TextStyle(color: Colors.white, fontFamily: 'RobotoMono', fontSize: 14.0, fontWeight: FontWeight.w500),
style: const TextStyle(color: Colors.white, fontSize: 14.0, fontWeight: FontWeight.w500),
),
const SizedBox(height: 10),
Text(
AppLocalizations.of(context).backup_test_tips_5,
style: const TextStyle(color: Colors.white, fontFamily: 'RobotoMono', fontSize: 14.0, fontWeight: FontWeight.w500),
style: const TextStyle(color: Colors.white, fontSize: 14.0, fontWeight: FontWeight.w500),
)
],
),
Expand Down
9 changes: 6 additions & 3 deletions lib/page/common/create_wallet_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,11 @@ class _CreateWalletPageState extends State<CreateWalletPage> {
);
},
textInputAction: TextInputAction.next,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w500, color: Colors.white, fontFamily: 'RobotoMono'),
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.white,
),
decoration: InputDecoration(
filled: true,
contentPadding: const EdgeInsets.all(15),
Expand All @@ -229,7 +233,6 @@ class _CreateWalletPageState extends State<CreateWalletPage> {
decoration: TextDecoration.none,
fontSize: 16,
fontWeight: FontWeight.w500,
fontFamily: 'RobotoMono',
color: Colors.white54,
),
enabledBorder: const OutlineInputBorder(
Expand Down Expand Up @@ -381,7 +384,7 @@ class _CreateWalletPageState extends State<CreateWalletPage> {
behavior: SnackBarBehavior.fixed,
content: Text(
e.toString(),
style: const TextStyle(fontSize: 14, fontFamily: 'RobotoMono', fontWeight: FontWeight.w400, color: Colors.white),
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w400, color: Colors.white),
),
));
}
Expand Down
16 changes: 8 additions & 8 deletions lib/page/common/langs_select.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class LangsSelectPage extends StatelessWidget {
const SizedBox(width: 15),
Text(
index == 0 ? AppLocalizations.of(context).auto : item.name,
style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w700, fontFamily: "RobotoMono"),
style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w700),
),
const Spacer(),
if (config.walletConfig.local == index) Image.asset('images/select.png', width: 20, height: 20) else const SizedBox(width: 20),
Expand Down Expand Up @@ -69,9 +69,9 @@ class NetWorkSelectPage extends StatelessWidget {

@override
Widget build(BuildContext context) {
// double screenHeight = ScreenHelper.screenHeight;
ConfigModal config = Provider.of<ConfigModal>(context);
double bottomPadding = ScreenHelper.bottomPadding;
List<String> netWorks = ["TestNet"];
List<String> netWorks = ConfigModal.netWorks;
double height = 60 + (bottomPadding > 0 ? bottomPadding : 20) + 70 * netWorks.length + 10;
return ModalFrame(
height: height,
Expand All @@ -98,18 +98,18 @@ class NetWorkSelectPage extends StatelessWidget {
const SizedBox(width: 15),
Text(
item,
style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w700, fontFamily: "RobotoMono"),
style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w700),
),
const Spacer(),
// if (config.walletConfig.local == index) Image.asset('images/select.png', width: 20, height: 20) else const SizedBox(width: 20),
Image.asset('images/select.png', width: 20, height: 20),
if (config.walletConfig.network == index) Image.asset('images/select.png', width: 20, height: 20) else const SizedBox(width: 20),
// Image.asset('images/select.png', width: 20, height: 20),
const SizedBox(width: 15),
],
),
),
onPressed: () {
// config.changeLocal(index);
// Navigator.of(context).pop();
config.changeNetwork(index);
Navigator.of(context).pop();
},
);
},
Expand Down
1 change: 0 additions & 1 deletion lib/page/common/legal_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class LegalPage extends StatelessWidget {
const descStyle = TextStyle(
decoration: TextDecoration.none,
fontSize: 14,
fontFamily: 'RobotoMono',
fontWeight: FontWeight.w500,
color: Colors.white,
);
Expand Down
2 changes: 1 addition & 1 deletion lib/page/common/password_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class _PasswordPageState extends State<PasswordPage> {
behavior: SnackBarBehavior.fixed,
content: Text(
AppLocalizations.of(context).change_password_success,
style: const TextStyle(fontSize: 14, fontFamily: 'RobotoMono', fontWeight: FontWeight.w400, color: Colors.white),
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w400, color: Colors.white),
),
));
// Helper.showSnackBar(AppLocalizations.of(context).change_password_success);
Expand Down
1 change: 0 additions & 1 deletion lib/page/common/security_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class SecurityPage extends StatelessWidget {
}
const descStyle = TextStyle(
fontSize: 16,
fontFamily: 'RobotoMono',
fontWeight: FontWeight.w500,
color: Colors.white,
);
Expand Down
Loading

0 comments on commit 738422a

Please sign in to comment.