This commit is contained in:
poka 2022-05-30 14:48:12 +02:00
parent 1a7224fd57
commit 7bef4a9cd3
10 changed files with 120 additions and 118 deletions

View File

@ -34,6 +34,9 @@ String cesiumPod = "https://g1.data.presles.fr";
late bool isTall; late bool isTall;
late double ratio; late double ratio;
// Contexts
late BuildContext homeContext;
// Logger // Logger
var log = Logger(); var log = Logger();

View File

@ -96,49 +96,6 @@ class HomeProvider with ChangeNotifier {
} }
log.i('ENDPOINT: ' + _listEndpoints.toString()); log.i('ENDPOINT: ' + _listEndpoints.toString());
// int i = 0;
// String? _endpoint;
// int _statusCode = 0;
// final _client = HttpClient();
// _client.connectionTimeout = const Duration(milliseconds: 1000);
// do {
// i++;
// log.d(i.toString() + ' ème essai de recherche de endpoint GVA.');
// log.d('Try GVA endpoint: ${_listEndpoints[i - 1]}');
// int listLenght = _listEndpoints.length - 1;
// if (i > listLenght) {
// log.e('NO VALID GVA ENDPOINT FOUND');
// _endpoint = 'HS';
// break;
// }
// if (i != 0) {
// await Future.delayed(const Duration(milliseconds: 300));
// }
// try {
// final request = await _client.postUrl(Uri.parse(_listEndpoints[i]));
// final response = await request.close();
// _endpoint = _listEndpoints[i];
// _statusCode = response.statusCode;
// } on TimeoutException catch (_) {
// log.e('This endpoint is timeout, next');
// _statusCode = 50;
// continue;
// } on SocketException catch (_) {
// log.e('This endpoint is a bad endpoint, next');
// _statusCode = 70;
// continue;
// } on Exception {
// log.e('Unknown error');
// _statusCode = 60;
// continue;
// }
// } while (_statusCode != 400);
return _listEndpoints; return _listEndpoints;
} }
@ -164,70 +121,74 @@ class HomeProvider with ChangeNotifier {
WalletsProfilesProvider _historyProvider = WalletsProfilesProvider _historyProvider =
Provider.of<WalletsProfilesProvider>(context, listen: false); Provider.of<WalletsProfilesProvider>(context, listen: false);
final size = MediaQuery.of(context).size;
const bool _showBottomBar = true; const bool _showBottomBar = true;
return Visibility( return Visibility(
visible: _showBottomBar, visible: _showBottomBar,
child: Container( child: Container(
color: yellowC, color: yellowC,
width: double.infinity, width: size.width,
height: 80, height: 80,
child: Row( child:
// mainAxisAlignment: MainAxisAlignment.spaceAround, // Stack(
children: [ // children: [
const Spacer(flex: 1), // // CustomPaint(
IconButton( // // size: Size(size.width, 110),
iconSize: 40, // // painter: CustomRoundedButton(),
icon: const Image(image: AssetImage('assets/loupe-noire.png')), // // ),
onPressed: () { Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
// Navigator.popUntil( IconButton(
// context, iconSize: 40,
// ModalRoute.withName('/'), icon: const Image(image: AssetImage('assets/loupe-noire.png')),
// ); onPressed: () {
Navigator.push( Navigator.popUntil(
context, context,
MaterialPageRoute(builder: (context) { ModalRoute.withName('/'),
return const SearchScreen(); );
}), Navigator.push(
); context,
}, MaterialPageRoute(builder: (homeContext) {
), return const SearchScreen();
// SizedBox(width: 0), }),
const Spacer(flex: 2), );
IconButton( },
iconSize: 60, ),
icon: const Image(image: AssetImage('assets/qrcode-scan.png')), IconButton(
onPressed: () async { iconSize: 70,
// Navigator.popUntil( icon: const Image(image: AssetImage('assets/qrcode-scan.png')),
// context, onPressed: () async {
// ModalRoute.withName('/'), Navigator.popUntil(
// ); context,
await _historyProvider.scan(context); ModalRoute.withName('/'),
}, );
), _historyProvider.scan(homeContext);
const Spacer(flex: 2), },
IconButton( ),
iconSize: 60, IconButton(
icon: const Image(image: AssetImage('assets/wallet.png')), iconSize: 60,
onPressed: () { icon: const Image(image: AssetImage('assets/wallet.png')),
WalletData? defaultWallet = onPressed: () {
_myWalletProvider.getDefaultWallet(); Navigator.popUntil(
Navigator.push( context,
context, ModalRoute.withName('/'),
MaterialPageRoute( );
builder: (context) { WalletData? defaultWallet = _myWalletProvider.getDefaultWallet();
return UnlockingWallet( Navigator.push(
wallet: defaultWallet, context,
action: "mywallets", MaterialPageRoute(
); builder: (homeContext) {
}, return UnlockingWallet(
), wallet: defaultWallet,
); action: "mywallets",
}, );
), },
const Spacer(flex: 1), ),
], );
), },
),
]),
), ),
); );
} }
@ -250,3 +211,24 @@ class HomeProvider with ChangeNotifier {
notifyListeners(); notifyListeners();
} }
} }
class CustomRoundedButton extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
Paint paint = Paint()
..color = yellowC
..style = PaintingStyle.fill;
Path path = Path();
path.lineTo(size.width * 0.4, 0);
path.quadraticBezierTo(size.width * 0.5, -40, size.width * 0.6, 0);
path.lineTo(size.width, 0);
path.lineTo(size.width, size.height);
path.lineTo(0, size.height);
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) {
return false;
}
}

View File

@ -106,7 +106,7 @@ class SubstrateSdk with ChangeNotifier {
nodeConnected = false; nodeConnected = false;
debugConnection = res.toString(); debugConnection = res.toString();
notifyListeners(); notifyListeners();
_homeProvider.changeMessage('Vous êtes pas connecté', 3); _homeProvider.changeMessage("Vous n'êtes pas connecté:", 3);
// snackNode(ctx, false); // snackNode(ctx, false);
} }
@ -335,10 +335,8 @@ class SubstrateSdk with ChangeNotifier {
password, password,
onStatusChange: (status) { onStatusChange: (status) {
log.d('Transaction status: ' + status); log.d('Transaction status: ' + status);
if (status == 'Ready') { transactionStatus = status;
transactionStatus = 'sent'; notifyListeners();
notifyListeners();
}
}, },
).timeout( ).timeout(
const Duration(seconds: 12), const Duration(seconds: 12),

View File

@ -62,7 +62,7 @@ class WalletOptionsProvider with ChangeNotifier {
final bool? _answer = await (confirmPopup(context, final bool? _answer = await (confirmPopup(context,
'Êtes-vous sûr de vouloir oublier le portefeuille "${wallet.name}" ?')); 'Êtes-vous sûr de vouloir oublier le portefeuille "${wallet.name}" ?'));
if (_answer!) { if (_answer ?? false) {
await walletBox.delete(wallet.key); await walletBox.delete(wallet.key);
await _sub.deleteAccounts([wallet.address!]); await _sub.deleteAccounts([wallet.address!]);

View File

@ -27,7 +27,7 @@ class WalletsProfilesProvider with ChangeNotifier {
int nRepositories = 20; int nRepositories = 20;
int nPage = 1; int nPage = 1;
Future scan(context) async { Future<String> scan(context) async {
if (Platform.isAndroid || Platform.isIOS) { if (Platform.isAndroid || Platform.isIOS) {
await Permission.camera.request(); await Permission.camera.request();
} }
@ -42,7 +42,7 @@ class WalletsProfilesProvider with ChangeNotifier {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) { MaterialPageRoute(builder: (context) {
return WalletViewScreen(pubkey: pubkey); return WalletViewScreen(pubkey: barcode!);
}), }),
); );
} else { } else {

View File

@ -24,6 +24,7 @@ class HomeScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
homeContext = context;
MyWalletsProvider _myWalletProvider = MyWalletsProvider _myWalletProvider =
Provider.of<MyWalletsProvider>(context); Provider.of<MyWalletsProvider>(context);
Provider.of<ChestProvider>(context); Provider.of<ChestProvider>(context);

View File

@ -53,7 +53,9 @@ class SettingsScreen extends StatelessWidget {
child: Row(children: [ child: Row(children: [
Text(' Noeud $currencyName :'), Text(' Noeud $currencyName :'),
const Spacer(), const Spacer(),
Icon(_sub.nodeConnected ? Icons.check : Icons.close), Icon(_sub.nodeConnected && !_sub.isLoadingEndpoint
? Icons.check
: Icons.close),
const Spacer(), const Spacer(),
SizedBox( SizedBox(
width: 200, width: 200,

View File

@ -58,7 +58,12 @@ class TransactionInProgress extends StatelessWidget {
_resultText = 'Envoi en cours ...'; _resultText = 'Envoi en cours ...';
} }
break; break;
case 'sent': case 'Ready':
{
_resultText = 'En cours de propagation...';
}
break;
case 'Broadcast':
{ {
_resultText = 'En cours de validation ...'; _resultText = 'En cours de validation ...';
} }
@ -81,7 +86,7 @@ class TransactionInProgress extends StatelessWidget {
_sub.transactionStatus = ''; _sub.transactionStatus = '';
Navigator.pop(context); Navigator.pop(context);
Navigator.pop(context); Navigator.pop(context);
if (_actionName == 'pay') { if (transType == 'pay') {
Navigator.pop(context); Navigator.pop(context);
} }
return Future<bool>.value(true); return Future<bool>.value(true);
@ -186,7 +191,7 @@ class TransactionInProgress extends StatelessWidget {
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
Navigator.pop(context); Navigator.pop(context);
if (_actionName == 'pay') { if (transType == 'pay') {
Navigator.pop(context); Navigator.pop(context);
} }
}, },

View File

@ -304,11 +304,22 @@ class WalletViewScreen extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
const Text( Row(
'Effectuer un virement', mainAxisAlignment: MainAxisAlignment.spaceBetween,
style: TextStyle( children: [
fontSize: 26, fontWeight: FontWeight.w700), const Text(
), 'Effectuer un virement',
style: TextStyle(
fontSize: 26, fontWeight: FontWeight.w700),
),
IconButton(
iconSize: 40,
icon: const Icon(Icons.cancel_outlined),
onPressed: () {
Navigator.pop(context);
},
),
]),
const SizedBox(height: 20), const SizedBox(height: 20),
Text( Text(
'Depuis:', 'Depuis:',

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.7+4 version: 0.0.7+5
environment: environment:
sdk: '>=2.12.0 <3.0.0' sdk: '>=2.12.0 <3.0.0'