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 double ratio;
// Contexts
late BuildContext homeContext;
// Logger
var log = Logger();

View File

@ -96,49 +96,6 @@ class HomeProvider with ChangeNotifier {
}
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;
}
@ -164,70 +121,74 @@ class HomeProvider with ChangeNotifier {
WalletsProfilesProvider _historyProvider =
Provider.of<WalletsProfilesProvider>(context, listen: false);
final size = MediaQuery.of(context).size;
const bool _showBottomBar = true;
return Visibility(
visible: _showBottomBar,
child: Container(
color: yellowC,
width: double.infinity,
width: size.width,
height: 80,
child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
const Spacer(flex: 1),
IconButton(
iconSize: 40,
icon: const Image(image: AssetImage('assets/loupe-noire.png')),
onPressed: () {
// Navigator.popUntil(
// context,
// ModalRoute.withName('/'),
// );
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return const SearchScreen();
}),
);
},
),
// SizedBox(width: 0),
const Spacer(flex: 2),
IconButton(
iconSize: 60,
icon: const Image(image: AssetImage('assets/qrcode-scan.png')),
onPressed: () async {
// Navigator.popUntil(
// context,
// ModalRoute.withName('/'),
// );
await _historyProvider.scan(context);
},
),
const Spacer(flex: 2),
IconButton(
iconSize: 60,
icon: const Image(image: AssetImage('assets/wallet.png')),
onPressed: () {
WalletData? defaultWallet =
_myWalletProvider.getDefaultWallet();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return UnlockingWallet(
wallet: defaultWallet,
action: "mywallets",
);
},
),
);
},
),
const Spacer(flex: 1),
],
),
child:
// Stack(
// children: [
// // CustomPaint(
// // size: Size(size.width, 110),
// // painter: CustomRoundedButton(),
// // ),
Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
IconButton(
iconSize: 40,
icon: const Image(image: AssetImage('assets/loupe-noire.png')),
onPressed: () {
Navigator.popUntil(
context,
ModalRoute.withName('/'),
);
Navigator.push(
context,
MaterialPageRoute(builder: (homeContext) {
return const SearchScreen();
}),
);
},
),
IconButton(
iconSize: 70,
icon: const Image(image: AssetImage('assets/qrcode-scan.png')),
onPressed: () async {
Navigator.popUntil(
context,
ModalRoute.withName('/'),
);
_historyProvider.scan(homeContext);
},
),
IconButton(
iconSize: 60,
icon: const Image(image: AssetImage('assets/wallet.png')),
onPressed: () {
Navigator.popUntil(
context,
ModalRoute.withName('/'),
);
WalletData? defaultWallet = _myWalletProvider.getDefaultWallet();
Navigator.push(
context,
MaterialPageRoute(
builder: (homeContext) {
return UnlockingWallet(
wallet: defaultWallet,
action: "mywallets",
);
},
),
);
},
),
]),
),
);
}
@ -250,3 +211,24 @@ class HomeProvider with ChangeNotifier {
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;
debugConnection = res.toString();
notifyListeners();
_homeProvider.changeMessage('Vous êtes pas connecté', 3);
_homeProvider.changeMessage("Vous n'êtes pas connecté:", 3);
// snackNode(ctx, false);
}
@ -335,10 +335,8 @@ class SubstrateSdk with ChangeNotifier {
password,
onStatusChange: (status) {
log.d('Transaction status: ' + status);
if (status == 'Ready') {
transactionStatus = 'sent';
notifyListeners();
}
transactionStatus = status;
notifyListeners();
},
).timeout(
const Duration(seconds: 12),

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -304,11 +304,22 @@ class WalletViewScreen extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
const Text(
'Effectuer un virement',
style: TextStyle(
fontSize: 26, fontWeight: FontWeight.w700),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
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),
Text(
'Depuis:',

View File

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