implemented hotrecharge changes
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:provider/provider.dart';
|
||||
import 'package:qpay/models/responsive_policy.dart';
|
||||
import 'package:qpay/screens/pay/pay_controller.dart';
|
||||
import 'package:qpay/screens/transaction_controller.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:skeletonizer/skeletonizer.dart';
|
||||
|
||||
class PayScreen extends StatefulWidget {
|
||||
@@ -21,6 +22,7 @@ class _PayScreenState extends State<PayScreen> with TickerProviderStateMixin {
|
||||
late Animation<Offset> _slideAnimation;
|
||||
late PayController controller;
|
||||
late TransactionController transactionController;
|
||||
late SharedPreferences prefs;
|
||||
|
||||
final List<Animation<Offset>> _animations = [];
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
@@ -73,9 +75,7 @@ class _PayScreenState extends State<PayScreen> with TickerProviderStateMixin {
|
||||
transactionController.model.formData.creditName ?? '';
|
||||
_emailController.text =
|
||||
transactionController.model.formData.creditEmail ?? '';
|
||||
_amountController.text =
|
||||
transactionController.model.formData.amount;
|
||||
|
||||
_amountController.text = transactionController.model.formData.amount;
|
||||
|
||||
// Initialize phone number and country code
|
||||
// updatePhoneNumber(transactionController.model.formData.creditPhone ?? '');
|
||||
@@ -92,15 +92,13 @@ class _PayScreenState extends State<PayScreen> with TickerProviderStateMixin {
|
||||
),
|
||||
);
|
||||
|
||||
_slideAnimation = Tween<Offset>(
|
||||
begin: const Offset(0, 0.1),
|
||||
end: Offset.zero,
|
||||
).animate(
|
||||
CurvedAnimation(
|
||||
parent: _controller,
|
||||
curve: const Interval(0.0, 0.5, curve: Curves.easeOut),
|
||||
),
|
||||
);
|
||||
_slideAnimation =
|
||||
Tween<Offset>(begin: const Offset(0, 0.1), end: Offset.zero).animate(
|
||||
CurvedAnimation(
|
||||
parent: _controller,
|
||||
curve: const Interval(0.0, 0.5, curve: Curves.easeOut),
|
||||
),
|
||||
);
|
||||
|
||||
List<int> buttonIndices = [0, 1];
|
||||
for (int i = 0; i < buttonIndices.length; i++) {
|
||||
@@ -115,6 +113,14 @@ class _PayScreenState extends State<PayScreen> with TickerProviderStateMixin {
|
||||
}
|
||||
|
||||
_controller.forward();
|
||||
_setupData();
|
||||
}
|
||||
|
||||
_setupData() async {
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
if (prefs.containsKey('phone')) {
|
||||
updatePhoneNumber(prefs.getString('phone')!);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updatePhoneNumber(String phoneNumber) async {
|
||||
@@ -154,15 +160,14 @@ class _PayScreenState extends State<PayScreen> with TickerProviderStateMixin {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading:
|
||||
context.canPop()
|
||||
? IconButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
},
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
)
|
||||
: SizedBox.shrink(),
|
||||
leading: context.canPop()
|
||||
? IconButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
},
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
)
|
||||
: SizedBox.shrink(),
|
||||
title: const Text(
|
||||
'Make Payment',
|
||||
style: TextStyle(color: Colors.black87),
|
||||
@@ -182,22 +187,30 @@ class _PayScreenState extends State<PayScreen> with TickerProviderStateMixin {
|
||||
key: _formKey,
|
||||
child: Center(
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
return SizedBox(
|
||||
width: double.parse(constraints.maxWidth > ResponsivePolicy.md ?
|
||||
ResponsivePolicy.md.toString() :
|
||||
constraints.maxWidth.toString()),
|
||||
builder: (context, constraints) {
|
||||
return SizedBox(
|
||||
width: double.parse(
|
||||
constraints.maxWidth > ResponsivePolicy.md
|
||||
? ResponsivePolicy.md.toString()
|
||||
: constraints.maxWidth.toString(),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.black87.withAlpha(20)),
|
||||
border: Border.all(
|
||||
color: Colors.black87.withAlpha(20),
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20),
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: 10,
|
||||
horizontal: 20,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"TRANSACTIONS DETAILS",
|
||||
@@ -208,7 +221,8 @@ class _PayScreenState extends State<PayScreen> with TickerProviderStateMixin {
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Provider",
|
||||
@@ -218,20 +232,25 @@ class _PayScreenState extends State<PayScreen> with TickerProviderStateMixin {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
controller.model.selectedProvider?.name ?? "",
|
||||
controller
|
||||
.model
|
||||
.selectedProvider
|
||||
?.name ??
|
||||
"",
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
controller
|
||||
.model
|
||||
.selectedProvider
|
||||
?.accountFieldName ??
|
||||
.model
|
||||
.selectedProvider
|
||||
?.accountFieldName ??
|
||||
"",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
@@ -271,7 +290,9 @@ class _PayScreenState extends State<PayScreen> with TickerProviderStateMixin {
|
||||
? Icons.arrow_drop_up
|
||||
: Icons.arrow_drop_down,
|
||||
),
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.primary,
|
||||
),
|
||||
Text(
|
||||
showAdditionalRecipientDetails
|
||||
@@ -299,7 +320,7 @@ class _PayScreenState extends State<PayScreen> with TickerProviderStateMixin {
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -326,21 +347,21 @@ class _PayScreenState extends State<PayScreen> with TickerProviderStateMixin {
|
||||
'Debit Phone Number',
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
|
||||
),
|
||||
if(!kIsWeb)
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
if (await FlutterContacts.requestPermission()) {
|
||||
final contact = await FlutterContacts.openExternalPick();
|
||||
if (contact != null) {
|
||||
updatePhoneNumber(contact.phones.first.normalizedNumber);
|
||||
if (!kIsWeb)
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
if (await FlutterContacts.requestPermission()) {
|
||||
final contact = await FlutterContacts.openExternalPick();
|
||||
if (contact != null) {
|
||||
updatePhoneNumber(contact.phones.first.normalizedNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
"Fetch from contacts",
|
||||
style: TextStyle(fontSize: 12, color: Colors.red),
|
||||
},
|
||||
child: Text(
|
||||
"Fetch from contacts",
|
||||
style: TextStyle(fontSize: 12, color: Colors.red),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
@@ -361,23 +382,22 @@ class _PayScreenState extends State<PayScreen> with TickerProviderStateMixin {
|
||||
isExpanded: true,
|
||||
icon: const Icon(Icons.arrow_drop_down),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
items:
|
||||
countryCodes.map((country) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: country['code'],
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(country['flag']!),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
country['code']!,
|
||||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
],
|
||||
items: countryCodes.map((country) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: country['code'],
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(country['flag']!),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
country['code']!,
|
||||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (String? newValue) {
|
||||
if (newValue != null) {
|
||||
setState(() {
|
||||
@@ -585,8 +605,10 @@ class _PayScreenState extends State<PayScreen> with TickerProviderStateMixin {
|
||||
...controller.model.products.map(
|
||||
(e) => DropdownMenuItem<String>(
|
||||
value: e.uid,
|
||||
child: Text('${e.displayName} - '
|
||||
'${transactionController.model.formData.debitCurrency}${e.defaultAmount}'),
|
||||
child: Text(
|
||||
'${e.displayName} - '
|
||||
'${transactionController.model.formData.debitCurrency}${e.defaultAmount}',
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user