Implement new payment view
This commit is contained in:
parent
d4e715e01a
commit
819d5a4b9b
|
@ -29,14 +29,12 @@ const String getHistory = r'''
|
||||||
issuers
|
issuers
|
||||||
comment
|
comment
|
||||||
outputs
|
outputs
|
||||||
writtenTime
|
|
||||||
}
|
}
|
||||||
sending {
|
sending {
|
||||||
currency
|
currency
|
||||||
issuers
|
issuers
|
||||||
comment
|
comment
|
||||||
outputs
|
outputs
|
||||||
writtenTime
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentUd {
|
currentUd {
|
||||||
|
|
|
@ -3,6 +3,7 @@ import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:gecko/globals.dart';
|
import 'package:gecko/globals.dart';
|
||||||
import 'package:gecko/models/g1_wallets_list.dart';
|
import 'package:gecko/models/g1_wallets_list.dart';
|
||||||
|
import 'package:gecko/models/wallets_profiles.dart';
|
||||||
|
|
||||||
class SearchProvider with ChangeNotifier {
|
class SearchProvider with ChangeNotifier {
|
||||||
TextEditingController searchController = TextEditingController();
|
TextEditingController searchController = TextEditingController();
|
||||||
|
@ -17,6 +18,7 @@ class SearchProvider with ChangeNotifier {
|
||||||
Future<List> searchBlockchain() async {
|
Future<List> searchBlockchain() async {
|
||||||
searchResult.clear();
|
searchResult.clear();
|
||||||
int searchTime = DateTime.now().millisecondsSinceEpoch;
|
int searchTime = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
WalletsProfilesProvider _walletProfiles = WalletsProfilesProvider('pubkey');
|
||||||
|
|
||||||
if (cacheTime + cacheDuring <= searchTime) {
|
if (cacheTime + cacheDuring <= searchTime) {
|
||||||
g1WalletsBox.clear();
|
g1WalletsBox.clear();
|
||||||
|
@ -60,6 +62,11 @@ class SearchProvider with ChangeNotifier {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (searchResult.isEmpty &&
|
||||||
|
_walletProfiles.isPubkey(searchController.text)) {
|
||||||
|
searchResult = [G1WalletsList(pubkey: searchController.text)];
|
||||||
|
}
|
||||||
|
|
||||||
return searchResult;
|
return searchResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ class WalletsProfilesProvider with ChangeNotifier {
|
||||||
log.e(e);
|
log.e(e);
|
||||||
return 'false';
|
return 'false';
|
||||||
}
|
}
|
||||||
if (barcode != null && isPubkey(context, barcode)) {
|
if (barcode != null && isPubkey(barcode)) {
|
||||||
outputPubkey.text = barcode;
|
outputPubkey.text = barcode;
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
|
@ -62,10 +62,17 @@ class WalletsProfilesProvider with ChangeNotifier {
|
||||||
WalletData defaultWallet = _myWalletModel.getDefaultWallet(currentChest);
|
WalletData defaultWallet = _myWalletModel.getDefaultWallet(currentChest);
|
||||||
|
|
||||||
String dewif = chestBox.get(currentChest).dewif;
|
String dewif = chestBox.get(currentChest).dewif;
|
||||||
|
int derivation;
|
||||||
|
|
||||||
|
if (chestBox.get(currentChest).isCesium) {
|
||||||
|
derivation = 0;
|
||||||
|
} else {
|
||||||
|
derivation = defaultWallet.derivation;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await DubpRust.simplePaymentFromTransparentAccount(
|
await DubpRust.simplePaymentFromTransparentAccount(
|
||||||
accountIndex: defaultWallet.derivation,
|
accountIndex: derivation,
|
||||||
amount: double.parse(payAmount.text),
|
amount: double.parse(payAmount.text),
|
||||||
txComment: payComment.text,
|
txComment: payComment.text,
|
||||||
dewif: dewif,
|
dewif: dewif,
|
||||||
|
@ -80,7 +87,7 @@ class WalletsProfilesProvider with ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isPubkey(context, pubkey) {
|
bool isPubkey(pubkey) {
|
||||||
final RegExp regExp = RegExp(
|
final RegExp regExp = RegExp(
|
||||||
r'^[a-zA-Z0-9]+$',
|
r'^[a-zA-Z0-9]+$',
|
||||||
caseSensitive: false,
|
caseSensitive: false,
|
||||||
|
@ -193,6 +200,8 @@ class WalletsProfilesProvider with ChangeNotifier {
|
||||||
FetchMoreOptions checkQueryResult(result, opts, _pubkey) {
|
FetchMoreOptions checkQueryResult(result, opts, _pubkey) {
|
||||||
final List<dynamic> blockchainTX =
|
final List<dynamic> blockchainTX =
|
||||||
(result.data['txsHistoryBc']['both']['edges'] as List<dynamic>);
|
(result.data['txsHistoryBc']['both']['edges'] as List<dynamic>);
|
||||||
|
// final List<dynamic> mempoolTX =
|
||||||
|
// (result.data['txsHistoryMp']['receiving'] as List<dynamic>);
|
||||||
|
|
||||||
pageInfo = result.data['txsHistoryBc']['both']['pageInfo'];
|
pageInfo = result.data['txsHistoryBc']['both']['pageInfo'];
|
||||||
fetchMoreCursor = pageInfo['endCursor'];
|
fetchMoreCursor = pageInfo['endCursor'];
|
||||||
|
|
|
@ -9,7 +9,8 @@ import 'package:carousel_slider/carousel_slider.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class ChooseChest extends StatefulWidget {
|
class ChooseChest extends StatefulWidget {
|
||||||
const ChooseChest({Key key}) : super(key: key);
|
const ChooseChest({this.action, Key key}) : super(key: key);
|
||||||
|
final String action;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() {
|
State<StatefulWidget> createState() {
|
||||||
|
@ -29,6 +30,8 @@ class _ChooseChestState extends State<ChooseChest> {
|
||||||
MyWalletsProvider _myWalletProvider =
|
MyWalletsProvider _myWalletProvider =
|
||||||
Provider.of<MyWalletsProvider>(context);
|
Provider.of<MyWalletsProvider>(context);
|
||||||
|
|
||||||
|
log.d(widget.action);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
toolbarHeight: 60 * ratio,
|
toolbarHeight: 60 * ratio,
|
||||||
|
@ -118,7 +121,7 @@ class _ChooseChestState extends State<ChooseChest> {
|
||||||
MaterialPageRoute(builder: (context) {
|
MaterialPageRoute(builder: (context) {
|
||||||
return UnlockingWallet(
|
return UnlockingWallet(
|
||||||
wallet: defaultWallet,
|
wallet: defaultWallet,
|
||||||
action: "mywallets",
|
action: widget.action ?? "mywallets",
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
ModalRoute.withName('/'),
|
ModalRoute.withName('/'),
|
||||||
|
|
|
@ -95,7 +95,7 @@ class UnlockingWallet extends StatelessWidget {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(builder: (context) {
|
MaterialPageRoute(builder: (context) {
|
||||||
return const ChooseChest();
|
return ChooseChest(action: action);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -103,11 +103,14 @@ class UnlockingWallet extends StatelessWidget {
|
||||||
width: 400,
|
width: 400,
|
||||||
height: 70,
|
height: 70,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text('Changer de coffre',
|
child: Text(
|
||||||
style: TextStyle(
|
'Changer de coffre',
|
||||||
fontSize: 22,
|
style: TextStyle(
|
||||||
color: orangeC,
|
fontSize: 22,
|
||||||
fontWeight: FontWeight.w600))),
|
color: orangeC,
|
||||||
|
fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
),
|
||||||
)),
|
)),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
|
@ -222,6 +225,7 @@ class UnlockingWallet extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> _paymentsResult(context) {
|
Future<bool> _paymentsResult(context) {
|
||||||
|
if (resultPay != "Success") log.i(resultPay);
|
||||||
return showDialog<bool>(
|
return showDialog<bool>(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: true, // user must tap button!
|
barrierDismissible: true, // user must tap button!
|
||||||
|
|
|
@ -63,7 +63,7 @@ class OldHistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||||
controller: _homeProvider.searchQuery,
|
controller: _homeProvider.searchQuery,
|
||||||
onChanged: (text) {
|
onChanged: (text) {
|
||||||
log.d("Clé tappé: $text");
|
log.d("Clé tappé: $text");
|
||||||
if (_historyProvider.isPubkey(context, text)) {
|
if (_historyProvider.isPubkey(text)) {
|
||||||
_homeProvider.currentIndex = 0;
|
_homeProvider.currentIndex = 0;
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
|
@ -390,11 +390,13 @@ class OldHistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||||
// _formKey.currentState.save();
|
// _formKey.currentState.save();
|
||||||
// }
|
// }
|
||||||
// _historyProvider.pay(payAmount.text, payComment.text);
|
// _historyProvider.pay(payAmount.text, payComment.text);
|
||||||
Navigator.push(context,
|
Navigator.push(
|
||||||
MaterialPageRoute(builder: (context) {
|
context,
|
||||||
return UnlockingWallet(
|
MaterialPageRoute(builder: (context) {
|
||||||
wallet: defaultWallet, action: "pay");
|
return UnlockingWallet(
|
||||||
}));
|
wallet: defaultWallet, action: "pay");
|
||||||
|
}),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
|
@ -447,7 +449,7 @@ class OldHistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||||
dense: true,
|
dense: true,
|
||||||
isThreeLine: false,
|
isThreeLine: false,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (_historyProvider.isPubkey(context, repository[2])) {
|
if (_historyProvider.isPubkey(repository[2])) {
|
||||||
_homeProvider.currentIndex = 0;
|
_homeProvider.currentIndex = 0;
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
|
|
|
@ -77,7 +77,7 @@ class SearchResultScreen extends StatelessWidget {
|
||||||
contentPadding: const EdgeInsets.all(5),
|
contentPadding: const EdgeInsets.all(5),
|
||||||
leading: g1WalletsBox
|
leading: g1WalletsBox
|
||||||
.get(g1Wallet.pubkey)
|
.get(g1Wallet.pubkey)
|
||||||
.avatar !=
|
?.avatar !=
|
||||||
null
|
null
|
||||||
? ClipOval(
|
? ClipOval(
|
||||||
child: g1WalletsBox
|
child: g1WalletsBox
|
||||||
|
@ -150,7 +150,7 @@ class SearchResultScreen extends StatelessWidget {
|
||||||
pubkey: g1Wallet.pubkey,
|
pubkey: g1Wallet.pubkey,
|
||||||
username: g1WalletsBox
|
username: g1WalletsBox
|
||||||
.get(g1Wallet.pubkey)
|
.get(g1Wallet.pubkey)
|
||||||
.id
|
?.id
|
||||||
?.username,
|
?.username,
|
||||||
avatar: g1WalletsBox
|
avatar: g1WalletsBox
|
||||||
.get(g1Wallet.pubkey)
|
.get(g1Wallet.pubkey)
|
||||||
|
|
|
@ -3,11 +3,14 @@ import 'package:flutter/services.dart';
|
||||||
import 'package:gecko/globals.dart';
|
import 'package:gecko/globals.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:gecko/models/cesium_plus.dart';
|
import 'package:gecko/models/cesium_plus.dart';
|
||||||
|
import 'package:gecko/models/my_wallets.dart';
|
||||||
|
import 'package:gecko/models/wallet_data.dart';
|
||||||
import 'package:gecko/models/wallets_profiles.dart';
|
import 'package:gecko/models/wallets_profiles.dart';
|
||||||
import 'package:gecko/models/queries.dart';
|
import 'package:gecko/models/queries.dart';
|
||||||
import 'package:gecko/screens/avatar_fullscreen.dart';
|
import 'package:gecko/screens/avatar_fullscreen.dart';
|
||||||
import 'package:gecko/screens/common_elements.dart';
|
import 'package:gecko/screens/common_elements.dart';
|
||||||
import 'package:gecko/screens/history.dart';
|
import 'package:gecko/screens/history.dart';
|
||||||
|
import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
|
||||||
import 'package:graphql_flutter/graphql_flutter.dart';
|
import 'package:graphql_flutter/graphql_flutter.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
@ -30,6 +33,7 @@ class WalletViewScreen extends StatelessWidget {
|
||||||
Provider.of<CesiumPlusProvider>(context, listen: false);
|
Provider.of<CesiumPlusProvider>(context, listen: false);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
resizeToAvoidBottomInset: true,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
toolbarHeight: 60 * ratio,
|
toolbarHeight: 60 * ratio,
|
||||||
|
@ -160,7 +164,7 @@ class WalletViewScreen extends StatelessWidget {
|
||||||
image: AssetImage('assets/vector_white.png'),
|
image: AssetImage('assets/vector_white.png'),
|
||||||
)),
|
)),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
null;
|
paymentPopup(context, _historyProvider);
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -177,6 +181,133 @@ class WalletViewScreen extends StatelessWidget {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void paymentPopup(
|
||||||
|
BuildContext context, WalletsProfilesProvider _walletViewProvider) {
|
||||||
|
// WalletsProfilesProvider _walletViewProvider =
|
||||||
|
// Provider.of<WalletsProfilesProvider>(context);
|
||||||
|
const double shapeSize = 20;
|
||||||
|
MyWalletsProvider _myWalletProvider = MyWalletsProvider();
|
||||||
|
WalletData defaultWallet =
|
||||||
|
_myWalletProvider.getDefaultWallet(configBox.get('currentChest'));
|
||||||
|
|
||||||
|
showModalBottomSheet<void>(
|
||||||
|
shape: const RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.only(
|
||||||
|
topRight: Radius.circular(shapeSize),
|
||||||
|
topLeft: Radius.circular(shapeSize),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
isScrollControlled: true,
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return Padding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||||
|
child: Container(
|
||||||
|
height: 400,
|
||||||
|
decoration: const ShapeDecoration(
|
||||||
|
color: Color(0xffffeed1),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.only(
|
||||||
|
topRight: Radius.circular(shapeSize),
|
||||||
|
topLeft: Radius.circular(shapeSize),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(24),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
const Text(
|
||||||
|
'Effectuer un virement',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 26, fontWeight: FontWeight.w700),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Text(
|
||||||
|
'Saisissez dans le champ ci-dessous le montant à virer de ... vers ...',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 19,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: Colors.grey[600]),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
Center(
|
||||||
|
child: Column(children: <Widget>[
|
||||||
|
TextField(
|
||||||
|
controller: _walletViewProvider.payAmount,
|
||||||
|
autofocus: true,
|
||||||
|
maxLines: 1,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
inputFormatters: <TextInputFormatter>[
|
||||||
|
FilteringTextInputFormatter.allow(
|
||||||
|
RegExp(r'^\d+\.?\d{0,2}')),
|
||||||
|
],
|
||||||
|
// onChanged: (v) => _searchProvider.rebuildWidget(),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: '0.00',
|
||||||
|
suffix: const Text('DU/Ğ1'),
|
||||||
|
filled: true,
|
||||||
|
fillColor: Colors.transparent,
|
||||||
|
// border: OutlineInputBorder(
|
||||||
|
// borderSide:
|
||||||
|
// BorderSide(color: Colors.grey[500], width: 2),
|
||||||
|
// borderRadius: BorderRadius.circular(8)),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Colors.grey[500], width: 2),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
contentPadding: const EdgeInsets.all(20),
|
||||||
|
),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 40,
|
||||||
|
color: Colors.black,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 40),
|
||||||
|
// const Spacer(),
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 60,
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
elevation: 4,
|
||||||
|
primary: orangeC, // background
|
||||||
|
onPrimary: Colors.white, // foreground
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) {
|
||||||
|
return UnlockingWallet(
|
||||||
|
wallet: defaultWallet, action: "pay");
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: const Text(
|
||||||
|
'Effectuer le virement',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20, fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).then((value) => _walletViewProvider.payAmount.text = '');
|
||||||
|
}
|
||||||
|
|
||||||
Widget headerProfileView(
|
Widget headerProfileView(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
WalletsProfilesProvider _historyProvider,
|
WalletsProfilesProvider _historyProvider,
|
||||||
|
|
|
@ -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.3+12
|
version: 0.0.3+13
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.7.0 <3.0.0"
|
sdk: ">=2.7.0 <3.0.0"
|
||||||
|
|
Loading…
Reference in New Issue