implemented TPIN and quick pay within bank
This commit is contained in:
@@ -1,8 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
import 'package:kmobile/data/models/transaction.dart';
|
||||
import 'package:kmobile/data/repositories/transaction_repository.dart';
|
||||
import 'package:kmobile/di/injection.dart';
|
||||
|
||||
class AccountStatementScreen extends StatefulWidget {
|
||||
const AccountStatementScreen({super.key});
|
||||
final String accountNo;
|
||||
const AccountStatementScreen({
|
||||
super.key,
|
||||
required this.accountNo,
|
||||
});
|
||||
|
||||
@override
|
||||
State<AccountStatementScreen> createState() => _AccountStatementScreen();
|
||||
@@ -11,94 +20,71 @@ class AccountStatementScreen extends StatefulWidget {
|
||||
class _AccountStatementScreen extends State<AccountStatementScreen> {
|
||||
DateTime? fromDate;
|
||||
DateTime? toDate;
|
||||
final _amountRangeController = TextEditingController(text: "");
|
||||
final transactions = [
|
||||
{
|
||||
"desc": "Transfer From ICICI Bank subsidy",
|
||||
"amount": "+₹133.98",
|
||||
"type": "Cr",
|
||||
"time": "21-02-2024 13:09:30"
|
||||
},
|
||||
{
|
||||
"desc": "Mobile recharge",
|
||||
"amount": "-₹299.00",
|
||||
"type": "Dr",
|
||||
"time": "21-02-2024 13:09:30"
|
||||
},
|
||||
{
|
||||
"desc": "NEFT received from Jaya Saha",
|
||||
"amount": "+₹987.80",
|
||||
"type": "Cr",
|
||||
"time": "21-02-2024 13:09:30"
|
||||
},
|
||||
{
|
||||
"desc": "Transfer From ICICI Bank subsidy",
|
||||
"amount": "+₹100.00",
|
||||
"type": "Cr",
|
||||
"time": "21-02-2024 13:09:30"
|
||||
},
|
||||
{
|
||||
"desc": "Transfer From ICICI Bank subsidy",
|
||||
"amount": "-₹100.00",
|
||||
"type": "Dr",
|
||||
"time": "21-02-2024 13:09:30"
|
||||
},
|
||||
{
|
||||
"desc": "Transfer From ICICI Bank subsidy",
|
||||
"amount": "+₹100.00",
|
||||
"type": "Cr",
|
||||
"time": "21-02-2024 13:09:30"
|
||||
},
|
||||
{
|
||||
"desc": "Transfer From ICICI Bank subsidy",
|
||||
"amount": "+₹100.00",
|
||||
"type": "Cr",
|
||||
"time": "21-02-2024 13:09:30"
|
||||
},
|
||||
];
|
||||
bool _txLoading = true;
|
||||
List<Transaction> _transactions = [];
|
||||
final _minAmountController = TextEditingController();
|
||||
final _maxAmountController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadTransactions();
|
||||
}
|
||||
|
||||
Future<void> _loadTransactions() async {
|
||||
setState(() {
|
||||
_txLoading = true;
|
||||
_transactions = [];
|
||||
});
|
||||
try {
|
||||
final repo = getIt<TransactionRepository>();
|
||||
final txs = await repo.fetchTransactions(widget.accountNo);
|
||||
setState(() => _transactions = txs);
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Failed to load transactions: $e')),
|
||||
);
|
||||
} finally {
|
||||
setState(() => _txLoading = false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _selectFromDate(BuildContext context) async {
|
||||
final DateTime now = DateTime.now();
|
||||
|
||||
final DateTime? picked = await showDatePicker(
|
||||
final now = DateTime.now();
|
||||
final picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: fromDate ?? now,
|
||||
firstDate: DateTime(2020), // or your app's start limit
|
||||
lastDate: now, // No future date
|
||||
firstDate: DateTime(2020),
|
||||
lastDate: now,
|
||||
);
|
||||
|
||||
if (picked != null) {
|
||||
setState(() {
|
||||
fromDate = picked;
|
||||
toDate = null; // reset toDate when fromDate changes
|
||||
toDate = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _selectToDate(BuildContext context) async {
|
||||
if (fromDate == null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
||||
content: Text('Please select From Date first'),
|
||||
));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Please select From Date first')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
final DateTime now = DateTime.now();
|
||||
|
||||
final DateTime lastAllowedDate = fromDate!.add(const Duration(days: 31));
|
||||
final DateTime maxToDate = lastAllowedDate.isBefore(now) ? lastAllowedDate : now;
|
||||
|
||||
final DateTime? picked = await showDatePicker(
|
||||
final now = DateTime.now();
|
||||
final maxToDate = fromDate!.add(const Duration(days: 31)).isBefore(now)
|
||||
? fromDate!.add(const Duration(days: 31))
|
||||
: now;
|
||||
final picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: toDate ?? fromDate!,
|
||||
firstDate: fromDate!, // 🔒 can't be before fromDate
|
||||
lastDate: maxToDate, // 🔒 not more than 1 month or future
|
||||
firstDate: fromDate!,
|
||||
lastDate: maxToDate,
|
||||
);
|
||||
|
||||
if (picked != null) {
|
||||
setState(() {
|
||||
toDate = picked;
|
||||
});
|
||||
setState(() => toDate = picked);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +96,8 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_amountRangeController.dispose();
|
||||
_minAmountController.dispose();
|
||||
_maxAmountController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -120,22 +107,25 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(Symbols.arrow_back_ios_new),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
title: const Text(
|
||||
'Account Statement',
|
||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
),
|
||||
centerTitle: false,
|
||||
actions: const [
|
||||
actions: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 10.0),
|
||||
padding: const EdgeInsets.only(right: 10.0),
|
||||
child: CircleAvatar(
|
||||
backgroundImage: AssetImage('assets/images/avatar.jpg'),
|
||||
// Replace with your image
|
||||
backgroundColor: Colors.grey[200],
|
||||
radius: 20,
|
||||
child: SvgPicture.asset(
|
||||
'assets/images/avatar_male.svg',
|
||||
width: 40,
|
||||
height: 40,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -145,58 +135,158 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Filters',
|
||||
style: TextStyle(fontSize: 17),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const Text('Filters', style: TextStyle(fontSize: 17)),
|
||||
const SizedBox(height: 15),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(child: GestureDetector(
|
||||
onTap: () => _selectFromDate(context),
|
||||
child: buildDateBox("From Date", fromDate),
|
||||
),),
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () => _selectFromDate(context),
|
||||
child: buildDateBox("From Date", fromDate),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: GestureDetector(
|
||||
onTap: () => _selectToDate(context),
|
||||
child: buildDateBox("To Date", toDate),
|
||||
),),
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () => _selectToDate(context),
|
||||
child: buildDateBox("To Date", toDate),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildFilterBox(""),
|
||||
child: TextFormField(
|
||||
controller: _minAmountController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Min Amount',
|
||||
border: OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
controller: _maxAmountController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Max Amount',
|
||||
border: OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.done,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
SizedBox(
|
||||
width: 75,
|
||||
width: 70,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
),
|
||||
child: const Text(
|
||||
'Go',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
|
||||
)),
|
||||
)
|
||||
onPressed: _loadTransactions,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
),
|
||||
child: const Icon(
|
||||
Symbols.arrow_forward,
|
||||
color: Colors.white,
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 35),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: transactions.length,
|
||||
itemBuilder: (context, index) {
|
||||
final txn = transactions[index];
|
||||
return _buildTransactionTile(txn);
|
||||
},
|
||||
if (!_txLoading && _transactions.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12.0),
|
||||
child: Text(
|
||||
'Showing last 10 transactions.',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.grey[700],
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: _txLoading
|
||||
? ListView.builder(
|
||||
itemCount: 3,
|
||||
itemBuilder: (_, __) => ListTile(
|
||||
leading: Shimmer.fromColors(
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: const CircleAvatar(
|
||||
radius: 12, backgroundColor: Colors.white),
|
||||
),
|
||||
title: Shimmer.fromColors(
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: Container(
|
||||
height: 10, width: 100, color: Colors.white),
|
||||
),
|
||||
subtitle: Shimmer.fromColors(
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: Container(
|
||||
height: 8, width: 60, color: Colors.white),
|
||||
),
|
||||
),
|
||||
)
|
||||
: _transactions.isEmpty
|
||||
? Center(
|
||||
child: Text(
|
||||
'No transactions found for this account.',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
itemCount: _transactions.length,
|
||||
itemBuilder: (context, index) {
|
||||
final txn = _transactions[index];
|
||||
final isCredit = txn.type == 'CR';
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(txn.date ?? '',
|
||||
style: const TextStyle(color: Colors.grey)),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(txn.name ?? '',
|
||||
style: const TextStyle(fontSize: 16)),
|
||||
),
|
||||
Text(
|
||||
"${isCredit ? '+' : '-'}₹${txn.amount}",
|
||||
style: TextStyle(
|
||||
color: isCredit
|
||||
? Colors.green
|
||||
: Colors.red,
|
||||
// fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -216,65 +306,14 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
||||
children: [
|
||||
Text(
|
||||
date != null ? _formatDate(date) : label,
|
||||
style: TextStyle(fontSize: 16,
|
||||
color: date != null ? Colors.black: Colors.grey),
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: date != null ? Colors.black : Colors.grey,
|
||||
),
|
||||
),
|
||||
const Icon(Icons.arrow_drop_down),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFilterBox(String text) {
|
||||
return TextFormField(
|
||||
controller: _amountRangeController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Amount Range',
|
||||
// prefixIcon: Icon(Icons.person),
|
||||
border: OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter amount range';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTransactionTile(Map<String, String> txn) {
|
||||
final isCredit = txn['type'] == "Cr";
|
||||
final amountColor = isCredit ? Colors.green : Colors.red;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(txn['time']!, style: const TextStyle(color: Colors.grey)),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child:
|
||||
Text(txn['desc']!, style: const TextStyle(fontSize: 16))),
|
||||
Text(
|
||||
"${txn['amount']} ${txn['type']}",
|
||||
style: TextStyle(color: amountColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -106,7 +106,7 @@ class _BlockCardScreen extends State<BlockCardScreen> {
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) => value != null && value.length == 16
|
||||
validator: (value) => value != null && value.length == 11
|
||||
? null
|
||||
: 'Enter valid card number',
|
||||
),
|
||||
|
@@ -96,7 +96,7 @@ class _CardPinChangeDetailsScreen extends State<CardPinChangeDetailsScreen> {
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) => value != null && value.length == 16
|
||||
validator: (value) => value != null && value.length == 11
|
||||
? null
|
||||
: 'Enter valid card number',
|
||||
),
|
||||
|
@@ -1,6 +1,9 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:kmobile/data/repositories/transaction_repository.dart';
|
||||
import 'package:kmobile/di/injection.dart';
|
||||
import 'package:kmobile/features/accounts/screens/account_info_screen.dart';
|
||||
import 'package:kmobile/features/accounts/screens/account_statement_screen.dart';
|
||||
@@ -8,7 +11,6 @@ import 'package:kmobile/features/auth/controllers/auth_cubit.dart';
|
||||
import 'package:kmobile/features/auth/controllers/auth_state.dart';
|
||||
import 'package:kmobile/features/customer_info/screens/customer_info_screen.dart';
|
||||
import 'package:kmobile/features/beneficiaries/screens/manage_beneficiaries_screen.dart';
|
||||
import 'package:kmobile/features/dashboard/widgets/transaction_list_placeholder.dart';
|
||||
import 'package:kmobile/features/enquiry/screens/enquiry_screen.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/fund_transfer_beneficiary_screen.dart';
|
||||
import 'package:kmobile/features/quick_pay/screens/quick_pay_screen.dart';
|
||||
@@ -17,6 +19,7 @@ import 'package:local_auth/local_auth.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
import 'package:kmobile/data/models/transaction.dart';
|
||||
|
||||
class DashboardScreen extends StatefulWidget {
|
||||
const DashboardScreen({super.key});
|
||||
@@ -31,6 +34,34 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
bool isRefreshing = false;
|
||||
bool isBalanceLoading = false;
|
||||
bool _biometricPromptShown = false;
|
||||
bool _txLoading = false;
|
||||
List<Transaction> _transactions = [];
|
||||
bool _txInitialized = false;
|
||||
|
||||
Future<void> _loadTransactions(String accountNo) async {
|
||||
setState(() {
|
||||
_txLoading = true;
|
||||
_transactions = [];
|
||||
});
|
||||
try {
|
||||
final repo = getIt<TransactionRepository>();
|
||||
final txs = await repo.fetchTransactions(accountNo);
|
||||
var fiveTxns = <Transaction>[];
|
||||
//only take the first 5 transactions
|
||||
if (txs.length > 5) {
|
||||
fiveTxns = txs.sublist(0, 5);
|
||||
} else {
|
||||
fiveTxns = txs;
|
||||
}
|
||||
setState(() => _transactions = fiveTxns);
|
||||
} catch (e) {
|
||||
log(accountNo, error: e);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Failed to load transactions: $e')));
|
||||
} finally {
|
||||
setState(() => _txLoading = false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _refreshAccountData(BuildContext context) async {
|
||||
setState(() {
|
||||
@@ -200,6 +231,13 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
if (state is Authenticated) {
|
||||
final users = state.users;
|
||||
final currAccount = users[selectedAccountIndex];
|
||||
// first‐time load
|
||||
if (!_txInitialized) {
|
||||
_txInitialized = true;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_loadTransactions(currAccount.accountNo!);
|
||||
});
|
||||
}
|
||||
final firstName = getProcessedFirstName(currAccount.name);
|
||||
|
||||
return SingleChildScrollView(
|
||||
@@ -267,7 +305,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
selectedAccountIndex = newIndex;
|
||||
});
|
||||
await Future.delayed(
|
||||
const Duration(seconds: 1));
|
||||
const Duration(milliseconds: 200));
|
||||
setState(() {
|
||||
isBalanceLoading = false;
|
||||
});
|
||||
@@ -276,6 +314,8 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
selectedAccountIndex = newIndex;
|
||||
});
|
||||
}
|
||||
await _loadTransactions(
|
||||
users[newIndex].accountNo!);
|
||||
},
|
||||
),
|
||||
const Spacer(),
|
||||
@@ -381,8 +421,8 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const QuickPayScreen()));
|
||||
builder: (context) => QuickPayScreen(
|
||||
debitAccount: currAccount.accountNo!)));
|
||||
}),
|
||||
_buildQuickLink(Symbols.send_money, "Fund \n Transfer",
|
||||
() {
|
||||
@@ -391,7 +431,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const FundTransferBeneficiaryScreen()));
|
||||
}),
|
||||
}, disable: true),
|
||||
_buildQuickLink(
|
||||
Symbols.server_person, "Account \n Info", () {
|
||||
Navigator.push(
|
||||
@@ -405,8 +445,10 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const AccountStatementScreen()));
|
||||
builder: (context) => AccountStatementScreen(
|
||||
accountNo: users[selectedAccountIndex]
|
||||
.accountNo!,
|
||||
)));
|
||||
}),
|
||||
_buildQuickLink(
|
||||
Symbols.checkbook, "Handle \n Cheque", () {},
|
||||
@@ -418,7 +460,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const ManageBeneficiariesScreen()));
|
||||
}),
|
||||
}, disable: true),
|
||||
_buildQuickLink(Symbols.support_agent, "Contact \n Us",
|
||||
() {
|
||||
Navigator.push(
|
||||
@@ -436,25 +478,43 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
style: TextStyle(fontSize: 17),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (currAccount.transactions != null &&
|
||||
currAccount.transactions!.isNotEmpty)
|
||||
...currAccount.transactions!.map((tx) => ListTile(
|
||||
if (_txLoading)
|
||||
..._buildTransactionShimmer()
|
||||
else if (_transactions.isNotEmpty)
|
||||
..._transactions.map((tx) => ListTile(
|
||||
leading: Icon(
|
||||
tx.type == 'CR'
|
||||
? Symbols.call_received
|
||||
: Symbols.call_made,
|
||||
color: tx.type == 'CR'
|
||||
? Colors.green
|
||||
: Colors.red),
|
||||
title: Text(tx.name ?? ''),
|
||||
subtitle: Text(tx.date ?? ''),
|
||||
tx.type == 'CR'
|
||||
? Symbols.call_received
|
||||
: Symbols.call_made,
|
||||
color:
|
||||
tx.type == 'CR' ? Colors.green : Colors.red,
|
||||
),
|
||||
title: Text(
|
||||
tx.name != null
|
||||
? (tx.name!.length > 18
|
||||
? tx.name!.substring(0, 20)
|
||||
: tx.name!)
|
||||
: '',
|
||||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
subtitle: Text(tx.date ?? '',
|
||||
style: const TextStyle(fontSize: 12)),
|
||||
trailing: Text("₹${tx.amount}",
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
)),
|
||||
style: const TextStyle(fontSize: 16)),
|
||||
))
|
||||
else
|
||||
const EmptyTransactionsPlaceholder(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 24.0),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'No transactions found for this account.',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -466,6 +526,28 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _buildTransactionShimmer() {
|
||||
return List.generate(3, (i) {
|
||||
return ListTile(
|
||||
leading: Shimmer.fromColors(
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: const CircleAvatar(radius: 12, backgroundColor: Colors.white),
|
||||
),
|
||||
title: Shimmer.fromColors(
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: Container(height: 10, width: 100, color: Colors.white),
|
||||
),
|
||||
subtitle: Shimmer.fromColors(
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: Container(height: 8, width: 60, color: Colors.white),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildQuickLink(IconData icon, String label, VoidCallback onTap,
|
||||
{bool disable = false}) {
|
||||
return InkWell(
|
||||
|
@@ -11,27 +11,43 @@ class EnquiryScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _EnquiryScreen extends State<EnquiryScreen> {
|
||||
Future<void> _launchEmail() async {
|
||||
final Uri emailUri = Uri(
|
||||
scheme: 'mailto',
|
||||
path: 'helpdesk@kccb.in',
|
||||
);
|
||||
Future<void> _launchEmailAddress(String email) async {
|
||||
final Uri emailUri = Uri(scheme: 'mailto', path: email);
|
||||
if (await canLaunchUrl(emailUri)) {
|
||||
await launchUrl(emailUri);
|
||||
} else {
|
||||
debugPrint('Could not launch email client');
|
||||
debugPrint('Could not launch email client for $email');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _launchPhone() async {
|
||||
final Uri phoneUri = Uri(scheme: 'tel', path: '0651-312861');
|
||||
Future<void> _launchPhoneNumber(String phone) async {
|
||||
final Uri phoneUri = Uri(scheme: 'tel', path: phone);
|
||||
if (await canLaunchUrl(phoneUri)) {
|
||||
await launchUrl(phoneUri);
|
||||
} else {
|
||||
debugPrint('Could not launch phone dialer');
|
||||
debugPrint('Could not launch dialer for $phone');
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildContactItem(String role, String email, String phone) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(role, style: const TextStyle(color: Colors.grey)),
|
||||
const SizedBox(height: 4),
|
||||
GestureDetector(
|
||||
onTap: () => _launchEmailAddress(email),
|
||||
child: Text(email, style: const TextStyle(color: Colors.blue)),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
GestureDetector(
|
||||
onTap: () => _launchPhoneNumber(phone),
|
||||
child: Text(phone, style: const TextStyle(color: Colors.blue)),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -68,32 +84,50 @@ class _EnquiryScreen extends State<EnquiryScreen> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text("Mail us at", style: TextStyle(color: Colors.grey)),
|
||||
const SizedBox(height: 4),
|
||||
GestureDetector(
|
||||
onTap: _launchEmail,
|
||||
child: const Text(
|
||||
"helpdesk@kccb.in",
|
||||
style: TextStyle(color: Colors.blue),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const Text("Call us at", style: TextStyle(color: Colors.grey)),
|
||||
const SizedBox(height: 4),
|
||||
GestureDetector(
|
||||
onTap: _launchPhone,
|
||||
child: const Text(
|
||||
"0651-312861",
|
||||
style: TextStyle(color: Colors.blue),
|
||||
),
|
||||
),
|
||||
// … existing Mail us / Call us / Write to us …
|
||||
|
||||
const SizedBox(height: 20),
|
||||
const Text("Write to us", style: TextStyle(color: Colors.grey)),
|
||||
const SizedBox(height: 4),
|
||||
const Text(
|
||||
"101 Street, Some Street, Some Address\nSome Address",
|
||||
"complaint@kccb.in",
|
||||
style: TextStyle(color: Colors.blue),
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
"Key Contacts",
|
||||
style: TextStyle(
|
||||
fontSize: 17,
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
// horizontal line
|
||||
),
|
||||
Divider(color: Colors.grey[300]),
|
||||
const SizedBox(height: 16),
|
||||
_buildContactItem(
|
||||
"Chairman",
|
||||
"chairman@kccb.in",
|
||||
"01892-222677",
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildContactItem(
|
||||
"Managing Director",
|
||||
"md@kccb.in",
|
||||
"01892-224969",
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildContactItem(
|
||||
"General Manager (West)",
|
||||
"gmw@kccb.in",
|
||||
"01892-223280",
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildContactItem(
|
||||
"General Manager (North)",
|
||||
"gmn@kccb.in",
|
||||
"01892-224607",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@@ -22,10 +22,13 @@ class _FundTransferScreen extends State<FundTransferScreen> {
|
||||
} else if (key == 'done') {
|
||||
if (kDebugMode) {
|
||||
print('Amount entered: $amount');
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const TransactionPinScreen()));
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(
|
||||
// builder: (context) => const TransactionPinScreen(
|
||||
// transactionData: {},
|
||||
// transactionCode: 'TRANSFER'
|
||||
// )));
|
||||
}
|
||||
} else {
|
||||
amount += key;
|
||||
|
205
lib/features/fund_transfer/screens/payment_animation.dart
Normal file
205
lib/features/fund_transfer/screens/payment_animation.dart
Normal file
@@ -0,0 +1,205 @@
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui' as ui;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:kmobile/data/models/payment_response.dart';
|
||||
import 'package:lottie/lottie.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
class PaymentAnimationScreen extends StatefulWidget {
|
||||
final Future<PaymentResponse> paymentResponse;
|
||||
|
||||
const PaymentAnimationScreen({
|
||||
super.key,
|
||||
required this.paymentResponse,
|
||||
});
|
||||
|
||||
@override
|
||||
State<PaymentAnimationScreen> createState() => _PaymentAnimationScreenState();
|
||||
}
|
||||
|
||||
class _PaymentAnimationScreenState extends State<PaymentAnimationScreen> {
|
||||
final GlobalKey _shareKey = GlobalKey();
|
||||
|
||||
Future<void> _shareScreenshot() async {
|
||||
try {
|
||||
RenderRepaintBoundary boundary =
|
||||
_shareKey.currentContext!.findRenderObject() as RenderRepaintBoundary;
|
||||
ui.Image image = await boundary.toImage(pixelRatio: 3.0);
|
||||
ByteData? byteData =
|
||||
await image.toByteData(format: ui.ImageByteFormat.png);
|
||||
Uint8List pngBytes = byteData!.buffer.asUint8List();
|
||||
|
||||
final tempDir = await getTemporaryDirectory();
|
||||
final file = await File('${tempDir.path}/payment_result.png').create();
|
||||
await file.writeAsBytes(pngBytes);
|
||||
|
||||
await Share.shareXFiles([XFile(file.path)], text: 'Payment Result');
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Failed to share screenshot: $e')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: FutureBuilder<PaymentResponse>(
|
||||
future: widget.paymentResponse,
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return Center(
|
||||
child: Lottie.asset(
|
||||
'assets/animations/rupee.json',
|
||||
width: 200,
|
||||
height: 200,
|
||||
repeat: true,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final response = snapshot.data!;
|
||||
final isSuccess = response.isSuccess;
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
Center(
|
||||
child: RepaintBoundary(
|
||||
key: _shareKey,
|
||||
child: Container(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 80),
|
||||
Lottie.asset(
|
||||
isSuccess
|
||||
? 'assets/animations/done.json'
|
||||
: 'assets/animations/error.json',
|
||||
width: 200,
|
||||
height: 200,
|
||||
repeat: false,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
isSuccess
|
||||
? Column(
|
||||
children: [
|
||||
const Text(
|
||||
'Payment Successful!',
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.green),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (response.amount != null)
|
||||
Text(
|
||||
'Amount: ${response.amount} ${response.currency ?? ''}',
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontFamily: 'Rubik'),
|
||||
),
|
||||
if (response.creditedAccount != null)
|
||||
Text(
|
||||
'Credited Account: ${response.creditedAccount}',
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontFamily: 'Rubik'),
|
||||
),
|
||||
if (response.date != null)
|
||||
Text(
|
||||
'Date: ${response.date!.toLocal().toIso8601String()}',
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
const Text(
|
||||
'Payment Failed',
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.red),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (response.errorMessage != null)
|
||||
Text(
|
||||
response.errorMessage!,
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Buttons at the bottom
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 80,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
ElevatedButton.icon(
|
||||
onPressed: _shareScreenshot,
|
||||
icon: Icon(
|
||||
Icons.share_rounded,
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
label: Text('Share',
|
||||
style:
|
||||
TextStyle(color: Theme.of(context).primaryColor)),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 32, vertical: 12),
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(
|
||||
color: Theme.of(context).primaryColor,
|
||||
width: 1,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
textStyle: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.black),
|
||||
),
|
||||
),
|
||||
ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
Navigator.of(context)
|
||||
.popUntil((route) => route.isFirst);
|
||||
},
|
||||
label: const Text('Done'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 45, vertical: 12),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
textStyle: const TextStyle(
|
||||
fontSize: 18, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
159
lib/features/fund_transfer/screens/tpin_otp_screen.dart
Normal file
159
lib/features/fund_transfer/screens/tpin_otp_screen.dart
Normal file
@@ -0,0 +1,159 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/tpin_set_screen.dart';
|
||||
|
||||
class TpinOtpScreen extends StatefulWidget {
|
||||
const TpinOtpScreen({super.key});
|
||||
|
||||
@override
|
||||
State<TpinOtpScreen> createState() => _TpinOtpScreenState();
|
||||
}
|
||||
|
||||
class _TpinOtpScreenState extends State<TpinOtpScreen> {
|
||||
final List<FocusNode> _focusNodes = List.generate(4, (_) => FocusNode());
|
||||
final List<TextEditingController> _controllers =
|
||||
List.generate(4, (_) => TextEditingController());
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
for (final node in _focusNodes) {
|
||||
node.dispose();
|
||||
}
|
||||
for (final ctrl in _controllers) {
|
||||
ctrl.dispose();
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onOtpChanged(int idx, String value) {
|
||||
if (value.length == 1 && idx < 3) {
|
||||
_focusNodes[idx + 1].requestFocus();
|
||||
}
|
||||
if (value.isEmpty && idx > 0) {
|
||||
_focusNodes[idx - 1].requestFocus();
|
||||
}
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
String get _enteredOtp => _controllers.map((c) => c.text).join();
|
||||
|
||||
void _verifyOtp() {
|
||||
if (_enteredOtp == '0000') {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => TpinSetScreen(),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Invalid OTP')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Enter OTP'),
|
||||
centerTitle: true,
|
||||
elevation: 0,
|
||||
),
|
||||
body: Center(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.lock_outline,
|
||||
size: 48, color: theme.colorScheme.primary),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'OTP Verification',
|
||||
style: theme.textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Enter the 4-digit OTP sent to your mobile number.',
|
||||
textAlign: TextAlign.center,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: Colors.grey[700],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: List.generate(4, (i) {
|
||||
return Container(
|
||||
width: 48,
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: TextField(
|
||||
controller: _controllers[i],
|
||||
focusNode: _focusNodes[i],
|
||||
keyboardType: TextInputType.number,
|
||||
textAlign: TextAlign.center,
|
||||
maxLength: 1,
|
||||
obscureText: true,
|
||||
obscuringCharacter: '⬤',
|
||||
decoration: InputDecoration(
|
||||
counterText: '',
|
||||
filled: true,
|
||||
fillColor: Colors.blue[50],
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(
|
||||
color: theme.colorScheme.primary,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(
|
||||
color: theme.colorScheme.primary,
|
||||
width: 2.5,
|
||||
),
|
||||
),
|
||||
),
|
||||
onChanged: (val) => _onOtpChanged(i, val),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
ElevatedButton.icon(
|
||||
icon: const Icon(Icons.verified_user_rounded),
|
||||
label: const Text(
|
||||
'Verify OTP',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: theme.colorScheme.primary,
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 14, horizontal: 28),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
),
|
||||
onPressed: _enteredOtp.length == 4 ? _verifyOtp : null,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
// Resend OTP logic here
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('OTP resent (mock)')),
|
||||
);
|
||||
},
|
||||
child: const Text('Resend OTP'),
|
||||
),
|
||||
const SizedBox(height: 60),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
77
lib/features/fund_transfer/screens/tpin_prompt_screen.dart
Normal file
77
lib/features/fund_transfer/screens/tpin_prompt_screen.dart
Normal file
@@ -0,0 +1,77 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/tpin_otp_screen.dart';
|
||||
|
||||
class TpinSetupPromptScreen extends StatelessWidget {
|
||||
const TpinSetupPromptScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Set TPIN'),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 100.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.lock_person_rounded,
|
||||
size: 60, color: theme.colorScheme.primary),
|
||||
const SizedBox(height: 18),
|
||||
Text(
|
||||
'TPIN Required',
|
||||
style: theme.textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
'You need to set your TPIN to continue with secure transactions.',
|
||||
textAlign: TextAlign.center,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: Colors.grey[700],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
ElevatedButton.icon(
|
||||
icon: const Icon(Icons.arrow_forward_rounded),
|
||||
label: const Text(
|
||||
'Set TPIN',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: theme.colorScheme.primary,
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 14, horizontal: 32),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => const TpinOtpScreen(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 18.0),
|
||||
child: Text(
|
||||
'Your TPIN is a 6-digit code used to authorize transactions. Keep it safe and do not share it with anyone.',
|
||||
textAlign: TextAlign.center,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
215
lib/features/fund_transfer/screens/tpin_set_screen.dart
Normal file
215
lib/features/fund_transfer/screens/tpin_set_screen.dart
Normal file
@@ -0,0 +1,215 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/api/services/auth_service.dart';
|
||||
import 'package:kmobile/di/injection.dart';
|
||||
|
||||
enum TPinMode { set, confirm }
|
||||
|
||||
class TpinSetScreen extends StatefulWidget {
|
||||
const TpinSetScreen({super.key});
|
||||
|
||||
@override
|
||||
State<TpinSetScreen> createState() => _TpinSetScreenState();
|
||||
}
|
||||
|
||||
class _TpinSetScreenState extends State<TpinSetScreen> {
|
||||
TPinMode _mode = TPinMode.set;
|
||||
final List<String> _tpin = [];
|
||||
String? _initialTpin;
|
||||
String? _errorText;
|
||||
|
||||
void addDigit(String digit) {
|
||||
if (_tpin.length < 6) {
|
||||
setState(() {
|
||||
_tpin.add(digit);
|
||||
_errorText = null;
|
||||
});
|
||||
if (_tpin.length == 6) {
|
||||
_handleComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void deleteDigit() {
|
||||
if (_tpin.isNotEmpty) {
|
||||
setState(() {
|
||||
_tpin.removeLast();
|
||||
_errorText = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void _handleComplete() async {
|
||||
final pin = _tpin.join();
|
||||
if (_mode == TPinMode.set) {
|
||||
setState(() {
|
||||
_initialTpin = pin;
|
||||
_tpin.clear();
|
||||
_mode = TPinMode.confirm;
|
||||
});
|
||||
} else if (_mode == TPinMode.confirm) {
|
||||
if (_initialTpin == pin) {
|
||||
final authService = getIt<AuthService>();
|
||||
try {
|
||||
await authService.setTpin(pin);
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
_errorText = "Failed to set TPIN. Please try again.";
|
||||
_tpin.clear();
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!mounted) return;
|
||||
// Show success dialog before popping
|
||||
await showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (ctx) => AlertDialog(
|
||||
shape:
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(18)),
|
||||
title: const Column(
|
||||
children: [
|
||||
Icon(Icons.check_circle, color: Colors.green, size: 60),
|
||||
SizedBox(height: 12),
|
||||
Text('Success!', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
],
|
||||
),
|
||||
content: const Text(
|
||||
'Your TPIN was set up successfully.',
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
child: const Text('OK', style: TextStyle(fontSize: 16)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
} else {
|
||||
setState(() {
|
||||
_errorText = "Pins do not match. Try again.";
|
||||
_tpin.clear();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Widget buildPinDots() {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: List.generate(6, (index) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.all(8),
|
||||
width: 15,
|
||||
height: 15,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: index < _tpin.length ? Colors.black : Colors.grey[400],
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildNumberPad() {
|
||||
List<List<String>> keys = [
|
||||
['1', '2', '3'],
|
||||
['4', '5', '6'],
|
||||
['7', '8', '9'],
|
||||
['Enter', '0', '<']
|
||||
];
|
||||
|
||||
return Column(
|
||||
children: keys.map((row) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: row.map((key) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
if (key == '<') {
|
||||
deleteDigit();
|
||||
} else if (key == 'Enter') {
|
||||
if (_tpin.length == 6) {
|
||||
_handleComplete();
|
||||
} else {
|
||||
setState(() {
|
||||
_errorText = "Please enter 6 digits";
|
||||
});
|
||||
}
|
||||
} else if (key.isNotEmpty) {
|
||||
addDigit(key);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
width: 70,
|
||||
height: 70,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.grey[200],
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: key == 'Enter'
|
||||
? const Icon(Icons.check)
|
||||
: Text(
|
||||
key == '<' ? '⌫' : key,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: key == 'Enter' ? Colors.blue : Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
String getTitle() {
|
||||
switch (_mode) {
|
||||
case TPinMode.set:
|
||||
return "Set your new TPIN";
|
||||
case TPinMode.confirm:
|
||||
return "Confirm your new TPIN";
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Set TPIN')),
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
const Spacer(),
|
||||
const Icon(Icons.lock_outline, size: 60, color: Colors.blue),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
getTitle(),
|
||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
buildPinDots(),
|
||||
if (_errorText != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: Text(_errorText!,
|
||||
style: const TextStyle(color: Colors.red)),
|
||||
),
|
||||
const Spacer(),
|
||||
buildNumberPad(),
|
||||
const Spacer(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,9 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/api/services/auth_service.dart';
|
||||
import 'package:kmobile/api/services/payment_service.dart';
|
||||
import 'package:kmobile/data/models/transfer.dart';
|
||||
import 'package:kmobile/di/injection.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/payment_animation.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/tpin_prompt_screen.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/transaction_success_screen.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
|
||||
class TransactionPinScreen extends StatefulWidget {
|
||||
const TransactionPinScreen({super.key});
|
||||
final Transfer transactionData;
|
||||
const TransactionPinScreen({super.key, required this.transactionData});
|
||||
|
||||
@override
|
||||
State<TransactionPinScreen> createState() => _TransactionPinScreen();
|
||||
@@ -11,6 +18,38 @@ class TransactionPinScreen extends StatefulWidget {
|
||||
|
||||
class _TransactionPinScreen extends State<TransactionPinScreen> {
|
||||
final List<String> _pin = [];
|
||||
bool _loading = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_checkIfTpinIsSet();
|
||||
}
|
||||
|
||||
Future<void> _checkIfTpinIsSet() async {
|
||||
setState(() => _loading = true);
|
||||
try {
|
||||
final authService = getIt<AuthService>();
|
||||
final isSet = await authService.checkTpin();
|
||||
if (!isSet && mounted) {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => const TpinSetupPromptScreen(),
|
||||
),
|
||||
);
|
||||
} else if (mounted) {
|
||||
setState(() => _loading = false);
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
setState(() => _loading = false);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Failed to check TPIN status')),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _onKeyPressed(String value) {
|
||||
setState(() {
|
||||
@@ -43,16 +82,13 @@ class _TransactionPinScreen extends State<TransactionPinScreen> {
|
||||
Widget _buildKey(String label, {IconData? icon}) {
|
||||
return Expanded(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
onTap: () async {
|
||||
if (label == 'back') {
|
||||
_onKeyPressed('back');
|
||||
} else if (label == 'done') {
|
||||
// Handle submit if needed
|
||||
if (_pin.length == 6) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const TransactionSuccessScreen()));
|
||||
await sendTransaction();
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text("Please enter a 6-digit TPIN")),
|
||||
@@ -90,6 +126,27 @@ class _TransactionPinScreen extends State<TransactionPinScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> sendTransaction() async {
|
||||
final paymentService = getIt<PaymentService>();
|
||||
final transfer = widget.transactionData;
|
||||
transfer.tpin = _pin.join();
|
||||
try {
|
||||
final paymentResponse = paymentService.processQuickPayWithinBank(transfer);
|
||||
|
||||
Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => PaymentAnimationScreen(paymentResponse: paymentResponse)
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(e.toString())),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -105,35 +162,23 @@ class _TransactionPinScreen extends State<TransactionPinScreen> {
|
||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
),
|
||||
centerTitle: false,
|
||||
actions: const [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 10.0),
|
||||
child: CircleAvatar(
|
||||
backgroundImage: AssetImage('assets/images/avatar.jpg'),
|
||||
// Replace with your image
|
||||
radius: 20,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 20.0),
|
||||
child: Column(
|
||||
children: [
|
||||
const Spacer(),
|
||||
const Text(
|
||||
'Enter Your TPIN',
|
||||
style: TextStyle(fontSize: 18),
|
||||
padding: const EdgeInsets.only(bottom: 20.0),
|
||||
child: Column(
|
||||
children: [
|
||||
const Spacer(),
|
||||
const Text(
|
||||
'Enter Your TPIN',
|
||||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_buildPinIndicators(),
|
||||
const Spacer(),
|
||||
_buildKeypad(),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_buildPinIndicators(),
|
||||
const Spacer(),
|
||||
_buildKeypad(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -7,16 +7,14 @@ import 'package:screenshot/screenshot.dart';
|
||||
import '../../../app.dart';
|
||||
|
||||
class TransactionSuccessScreen extends StatefulWidget {
|
||||
const TransactionSuccessScreen({super.key});
|
||||
final String creditAccount;
|
||||
const TransactionSuccessScreen({super.key, required this.creditAccount});
|
||||
|
||||
@override
|
||||
State<TransactionSuccessScreen> createState() => _TransactionSuccessScreen();
|
||||
}
|
||||
|
||||
class _TransactionSuccessScreen extends State<TransactionSuccessScreen> {
|
||||
final String transactionDate = "18th March, 2025 04:30 PM";
|
||||
final String referenceNumber = "TXN32131093012931993";
|
||||
|
||||
final ScreenshotController _screenshotController = ScreenshotController();
|
||||
|
||||
Future<void> _shareScreenshot() async {
|
||||
@@ -35,6 +33,10 @@ class _TransactionSuccessScreen extends State<TransactionSuccessScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final String transactionDate =
|
||||
DateTime.now().toLocal().toString().split(' ')[0];
|
||||
final String creditAccount = widget.creditAccount;
|
||||
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Stack(
|
||||
@@ -74,7 +76,7 @@ class _TransactionSuccessScreen extends State<TransactionSuccessScreen> {
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
"Reference No: $referenceNumber",
|
||||
"To Account Number: $creditAccount",
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.black87,
|
||||
@@ -102,9 +104,9 @@ class _TransactionSuccessScreen extends State<TransactionSuccessScreen> {
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
backgroundColor: Colors.white,
|
||||
foregroundColor: Colors.blueAccent,
|
||||
side: const BorderSide(color: Colors.black, width: 1),
|
||||
elevation: 0
|
||||
),
|
||||
side:
|
||||
const BorderSide(color: Colors.black, width: 1),
|
||||
elevation: 0),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
@@ -115,7 +117,8 @@ class _TransactionSuccessScreen extends State<TransactionSuccessScreen> {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const NavigationScaffold()));
|
||||
builder: (context) =>
|
||||
const NavigationScaffold()));
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: const StadiumBorder(),
|
||||
@@ -135,5 +138,4 @@ class _TransactionSuccessScreen extends State<TransactionSuccessScreen> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -6,7 +6,8 @@ import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
import '../../fund_transfer/screens/transaction_pin_screen.dart';
|
||||
|
||||
class QuickPayOutsideBankScreen extends StatefulWidget {
|
||||
const QuickPayOutsideBankScreen({super.key});
|
||||
final String debitAccount;
|
||||
const QuickPayOutsideBankScreen({super.key, required this.debitAccount});
|
||||
|
||||
@override
|
||||
State<QuickPayOutsideBankScreen> createState() =>
|
||||
@@ -82,12 +83,12 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
child: ListView(
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
const Row(
|
||||
Row(
|
||||
children: [
|
||||
Text('Debit from:'),
|
||||
const Text('Debit from:'),
|
||||
Text(
|
||||
'0300015678903456',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500),
|
||||
widget.debitAccount,
|
||||
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w500),
|
||||
)
|
||||
],
|
||||
),
|
||||
@@ -113,7 +114,7 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Account number is required';
|
||||
} else if (value.length != 16) {
|
||||
} else if (value.length != 11) {
|
||||
return 'Enter a valid account number';
|
||||
}
|
||||
return null;
|
||||
@@ -373,11 +374,14 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
SnackBar(
|
||||
content: Text('Paying via $selectedMode...')),
|
||||
);
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const TransactionPinScreen()));
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(
|
||||
// builder: (context) =>
|
||||
// const TransactionPinScreen(
|
||||
// transactionData: {},
|
||||
// transactionCode: 'PAYMENT',
|
||||
// )));
|
||||
}
|
||||
},
|
||||
)),
|
||||
|
@@ -5,7 +5,8 @@ import 'package:kmobile/features/quick_pay/screens/quick_pay_within_bank_screen.
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
|
||||
class QuickPayScreen extends StatefulWidget {
|
||||
const QuickPayScreen({super.key});
|
||||
final String debitAccount;
|
||||
const QuickPayScreen({super.key, required this.debitAccount});
|
||||
|
||||
@override
|
||||
State<QuickPayScreen> createState() => _QuickPayScreen();
|
||||
@@ -52,20 +53,21 @@ class _QuickPayScreen extends State<QuickPayScreen> {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const QuickPayWithinBankScreen()));
|
||||
builder: (context) => QuickPayWithinBankScreen(debitAccount: widget.debitAccount)));
|
||||
},
|
||||
),
|
||||
const Divider(
|
||||
height: 1,
|
||||
),
|
||||
QuickPayManagementTile(
|
||||
disable: true,
|
||||
icon: Symbols.output_circle,
|
||||
label: 'Outside Bank',
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const QuickPayOutsideBankScreen()));
|
||||
builder: (context) => QuickPayOutsideBankScreen(debitAccount: widget.debitAccount)));
|
||||
},
|
||||
),
|
||||
const Divider(
|
||||
@@ -81,12 +83,14 @@ class QuickPayManagementTile extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final VoidCallback onTap;
|
||||
final bool disable;
|
||||
|
||||
const QuickPayManagementTile({
|
||||
super.key,
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.onTap,
|
||||
this.disable = false,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -96,6 +100,7 @@ class QuickPayManagementTile extends StatelessWidget {
|
||||
title: Text(label),
|
||||
trailing: const Icon(Symbols.arrow_right, size: 20),
|
||||
onTap: onTap,
|
||||
enabled: !disable,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:flutter_swipe_button/flutter_swipe_button.dart';
|
||||
import 'package:kmobile/data/models/transfer.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
|
||||
import '../../fund_transfer/screens/transaction_pin_screen.dart';
|
||||
|
||||
class QuickPayWithinBankScreen extends StatefulWidget {
|
||||
const QuickPayWithinBankScreen({super.key});
|
||||
final String debitAccount;
|
||||
const QuickPayWithinBankScreen({super.key, required this.debitAccount});
|
||||
|
||||
@override
|
||||
State<QuickPayWithinBankScreen> createState() => _QuickPayWithinBankScreen();
|
||||
@@ -18,8 +20,8 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
final TextEditingController accountNumberController = TextEditingController();
|
||||
final TextEditingController confirmAccountNumberController =
|
||||
TextEditingController();
|
||||
final TextEditingController nameController = TextEditingController();
|
||||
final TextEditingController amountController = TextEditingController();
|
||||
String? _selectedAccountType;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -59,14 +61,19 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
const Row(
|
||||
children: [
|
||||
Text('Debit from:'),
|
||||
Text(
|
||||
'0300015678903456',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500),
|
||||
)
|
||||
],
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Debit Account Number',
|
||||
border: OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
),
|
||||
readOnly: true,
|
||||
controller: TextEditingController(text: widget.debitAccount),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
enabled: false,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
TextFormField(
|
||||
@@ -90,21 +97,21 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Account number is required';
|
||||
} else if (value.length != 16) {
|
||||
} else if (value.length != 11) {
|
||||
return 'Enter a valid account number';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: 15.0, top: 5),
|
||||
child: Text(
|
||||
'Beneficiary Account Number',
|
||||
style: TextStyle(color: Colors.black54),
|
||||
),
|
||||
)),
|
||||
// const Align(
|
||||
// alignment: Alignment.topLeft,
|
||||
// child: Padding(
|
||||
// padding: EdgeInsets.only(left: 15.0, top: 5),
|
||||
// child: Text(
|
||||
// 'Beneficiary Account Number',
|
||||
// style: TextStyle(color: Colors.black54),
|
||||
// ),
|
||||
// )),
|
||||
const SizedBox(height: 25),
|
||||
TextFormField(
|
||||
controller: confirmAccountNumberController,
|
||||
@@ -135,9 +142,9 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
TextFormField(
|
||||
DropdownButtonFormField<String>(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Name',
|
||||
labelText: 'Beneficiary Account Type',
|
||||
border: OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
@@ -149,25 +156,38 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
controller: nameController,
|
||||
keyboardType: TextInputType.name,
|
||||
textInputAction: TextInputAction.next,
|
||||
value: _selectedAccountType,
|
||||
items: const [
|
||||
DropdownMenuItem(
|
||||
value: 'SB',
|
||||
child: Text('Savings'),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 'LN',
|
||||
child: Text('Loan'),
|
||||
),
|
||||
],
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_selectedAccountType = value;
|
||||
});
|
||||
},
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Name is required';
|
||||
return 'Please select account type';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: 15.0, top: 5),
|
||||
child: Text(
|
||||
'Beneficiary Name',
|
||||
style: TextStyle(color: Colors.black54),
|
||||
),
|
||||
)),
|
||||
// const Align(
|
||||
// alignment: Alignment.topLeft,
|
||||
// child: Padding(
|
||||
// padding: EdgeInsets.only(left: 15.0, top: 5),
|
||||
// child: Text(
|
||||
// 'Beneficiary Account Type',
|
||||
// style: TextStyle(color: Colors.black54),
|
||||
// ),
|
||||
// )),
|
||||
const SizedBox(height: 25),
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(
|
||||
@@ -205,29 +225,48 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
Icons.arrow_forward,
|
||||
color: Colors.white,
|
||||
),
|
||||
activeThumbColor: Colors.blue[900],
|
||||
activeTrackColor: Colors.blue.shade100,
|
||||
activeThumbColor: Theme.of(context).primaryColor,
|
||||
activeTrackColor:
|
||||
Theme.of(context).colorScheme.secondary.withAlpha(100),
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
height: 56,
|
||||
child: const Text(
|
||||
"Swipe to Pay",
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
onSwipe: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
// Perform payment logic
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Processing Payment...')),
|
||||
);
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const TransactionPinScreen()));
|
||||
builder: (context) => TransactionPinScreen(
|
||||
transactionData: Transfer(
|
||||
fromAccount: widget.debitAccount,
|
||||
toAccount: accountNumberController.text,
|
||||
toAccountType: _selectedAccountType!,
|
||||
amount: amountController.text,
|
||||
),
|
||||
)));
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
// SliderButton(
|
||||
// action: () async {
|
||||
// ///Do something here OnSlide
|
||||
// return true;
|
||||
// },
|
||||
// label: const Text(
|
||||
// "Slide to pay",
|
||||
// style: TextStyle(
|
||||
// color: Color(0xff4a4a4a),
|
||||
// fontWeight: FontWeight.w500,
|
||||
// fontSize: 17),
|
||||
// ),
|
||||
// icon: Icon(Symbols.arrow_forward,
|
||||
// color: Theme.of(context).primaryColor, weight: 200),
|
||||
// )
|
||||
],
|
||||
),
|
||||
),
|
||||
|
Reference in New Issue
Block a user