lock identity name format on confirmation
This commit is contained in:
parent
dd49e76fa1
commit
2facd8cd7f
|
@ -3,6 +3,7 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:gecko/globals.dart';
|
import 'package:gecko/globals.dart';
|
||||||
import 'package:gecko/providers/duniter_indexer.dart';
|
import 'package:gecko/providers/duniter_indexer.dart';
|
||||||
|
@ -214,7 +215,7 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
return await sub.idtyStatus(address) == 'Validated';
|
return await sub.idtyStatus(address) == 'Validated';
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String?> validateIdentity(BuildContext context) async {
|
Future<String?> confirmIdentityPopup(BuildContext context) async {
|
||||||
TextEditingController idtyName = TextEditingController();
|
TextEditingController idtyName = TextEditingController();
|
||||||
SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false);
|
SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false);
|
||||||
WalletOptionsProvider walletOptions =
|
WalletOptionsProvider walletOptions =
|
||||||
|
@ -238,6 +239,11 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
TextField(
|
TextField(
|
||||||
onChanged: (_) => notifyListeners(),
|
onChanged: (_) => notifyListeners(),
|
||||||
|
inputFormatters: <TextInputFormatter>[
|
||||||
|
// FilteringTextInputFormatter.allow(RegExp("[0-9a-zA-Z]")),
|
||||||
|
FilteringTextInputFormatter.deny(RegExp(r'^ ')),
|
||||||
|
// FilteringTextInputFormatter.deny(RegExp(r' $')),
|
||||||
|
],
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
controller: idtyName,
|
controller: idtyName,
|
||||||
|
@ -257,13 +263,17 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
"validate".tr(),
|
"validate".tr(),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 21,
|
fontSize: 21,
|
||||||
color: idtyName.text.length >= 2
|
color: idtyName.text.length.clamp(3, 64) ==
|
||||||
|
idtyName.text.length
|
||||||
? const Color(0xffD80000)
|
? const Color(0xffD80000)
|
||||||
: Colors.grey,
|
: Colors.grey,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (idtyName.text.length >= 2) {
|
idtyName.text = idtyName.text.trim().replaceAll(' ', '');
|
||||||
|
|
||||||
|
if (idtyName.text.length.clamp(3, 64) ==
|
||||||
|
idtyName.text.length) {
|
||||||
WalletData? defaultWallet =
|
WalletData? defaultWallet =
|
||||||
myWalletProvider.getDefaultWallet();
|
myWalletProvider.getDefaultWallet();
|
||||||
|
|
||||||
|
@ -291,8 +301,8 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
MaterialPageRoute(builder: (context) {
|
MaterialPageRoute(builder: (context) {
|
||||||
return TransactionInProgress(
|
return TransactionInProgress(
|
||||||
transType: 'comfirmIdty',
|
transType: 'comfirmIdty',
|
||||||
fromAddress: wallet.address,
|
fromAddress: getShortPubkey(wallet.address!),
|
||||||
toAddress: wallet.address,
|
toAddress: getShortPubkey(wallet.address!),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
@ -298,7 +298,7 @@ class WalletOptions extends StatelessWidget {
|
||||||
onPrimary: Colors.white, // foreground
|
onPrimary: Colors.white, // foreground
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
walletProvider.validateIdentity(context);
|
walletProvider.confirmIdentityPopup(context);
|
||||||
// Navigator.push(
|
// Navigator.push(
|
||||||
// context,
|
// context,
|
||||||
// MaterialPageRoute(builder: (context) {
|
// MaterialPageRoute(builder: (context) {
|
||||||
|
|
Loading…
Reference in New Issue