IMPS implementation
This commit is contained in:
@@ -12,7 +12,7 @@ class ImpsService {
|
|||||||
try {
|
try {
|
||||||
await Future.delayed(const Duration(seconds: 3));
|
await Future.delayed(const Duration(seconds: 3));
|
||||||
final response = await _dio.post(
|
final response = await _dio.post(
|
||||||
'/api/payment/rtgs',
|
'/api/payment/imps',
|
||||||
data: transaction.toJson(),
|
data: transaction.toJson(),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ class ImpsService {
|
|||||||
return ImpsResponse.fromJson(response.data);
|
return ImpsResponse.fromJson(response.data);
|
||||||
} else {
|
} else {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
'RTGS transaction failed with status code: ${response.statusCode}');
|
'IMPS transaction failed with status code: ${response.statusCode}');
|
||||||
}
|
}
|
||||||
} on DioException {
|
} on DioException {
|
||||||
rethrow;
|
rethrow;
|
||||||
|
@@ -98,7 +98,7 @@ class _KMobileState extends State<KMobile> {
|
|||||||
],
|
],
|
||||||
title: 'kMobile',
|
title: 'kMobile',
|
||||||
theme: themeState.getThemeData(),
|
theme: themeState.getThemeData(),
|
||||||
darkTheme: themeState.getThemeData(),
|
//darkTheme: themeState.getThemeData(),
|
||||||
themeMode: ThemeMode.system,
|
themeMode: ThemeMode.system,
|
||||||
onGenerateRoute: AppRoutes.generateRoute,
|
onGenerateRoute: AppRoutes.generateRoute,
|
||||||
initialRoute: AppRoutes.splash,
|
initialRoute: AppRoutes.splash,
|
||||||
@@ -472,3 +472,4 @@ class BiometricPromptScreen extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,17 +16,17 @@ class AppThemes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static ThemeData getDarkTheme(ThemeType type) {
|
// static ThemeData getDarkTheme(ThemeType type) {
|
||||||
switch (type) {
|
// switch (type) {
|
||||||
case ThemeType.green:
|
// case ThemeType.green:
|
||||||
return ThemeData.dark().copyWith(primaryColor: Colors.green);
|
// return ThemeData.dark().copyWith(primaryColor: Colors.green);
|
||||||
case ThemeType.orange:
|
// case ThemeType.orange:
|
||||||
return ThemeData.dark().copyWith(primaryColor: Colors.orange);
|
// return ThemeData.dark().copyWith(primaryColor: Colors.orange);
|
||||||
case ThemeType.blue:
|
// case ThemeType.blue:
|
||||||
return ThemeData.dark().copyWith(primaryColor: Colors.blue);
|
// return ThemeData.dark().copyWith(primaryColor: Colors.blue);
|
||||||
case ThemeType.violet:
|
// case ThemeType.violet:
|
||||||
default:
|
// default:
|
||||||
return ThemeData.dark().copyWith(primaryColor: Colors.deepPurple);
|
// return ThemeData.dark().copyWith(primaryColor: Colors.deepPurple);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
@@ -19,13 +19,12 @@ class ImpsTransaction {
|
|||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
return {
|
return {
|
||||||
'stFromAccDetails': fromAccount,
|
'fromAccount': fromAccount,
|
||||||
'stBenAccNo': toAccount,
|
'toAccount': toAccount,
|
||||||
'stTransferAmount': amount,
|
'amount': amount,
|
||||||
'stBenIFSC': ifscCode,
|
'ifscCode': ifscCode,
|
||||||
//'remitterName': remitterName,
|
'remitterName': remitterName,
|
||||||
'stBeneName': beneficiaryName,
|
'beneficiaryName': beneficiaryName,
|
||||||
'stRemarks': "Check",
|
|
||||||
'tpin': tpin,
|
'tpin': tpin,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -14,3 +14,6 @@ class RtgsResponse {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import 'package:kmobile/api/services/rtgs_service.dart';
|
import 'package:kmobile/api/services/rtgs_service.dart';
|
||||||
import 'package:kmobile/api/services/neft_service.dart';
|
import 'package:kmobile/api/services/neft_service.dart';
|
||||||
|
import 'package:kmobile/api/services/imps_service.dart';
|
||||||
import 'package:get_it/get_it.dart';
|
import 'package:get_it/get_it.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:kmobile/api/services/beneficiary_service.dart';
|
import 'package:kmobile/api/services/beneficiary_service.dart';
|
||||||
@@ -44,6 +45,7 @@ Future<void> setupDependencies() async {
|
|||||||
getIt.registerSingleton<BeneficiaryService>(BeneficiaryService(getIt<Dio>()));
|
getIt.registerSingleton<BeneficiaryService>(BeneficiaryService(getIt<Dio>()));
|
||||||
getIt.registerSingleton<NeftService>(NeftService(getIt<Dio>()));
|
getIt.registerSingleton<NeftService>(NeftService(getIt<Dio>()));
|
||||||
getIt.registerSingleton<RtgsService>(RtgsService(getIt<Dio>()));
|
getIt.registerSingleton<RtgsService>(RtgsService(getIt<Dio>()));
|
||||||
|
getIt.registerSingleton<ImpsService>(ImpsService(getIt<Dio>()));
|
||||||
|
|
||||||
// Add auth interceptor after repository is available
|
// Add auth interceptor after repository is available
|
||||||
getIt<Dio>().interceptors.add(
|
getIt<Dio>().interceptors.add(
|
||||||
@@ -59,8 +61,8 @@ Dio _createDioClient() {
|
|||||||
final dio = Dio(
|
final dio = Dio(
|
||||||
BaseOptions(
|
BaseOptions(
|
||||||
baseUrl:
|
baseUrl:
|
||||||
'http://lb-test-mobile-banking-app-192209417.ap-south-1.elb.amazonaws.com:8080',
|
//'http://lb-test-mobile-banking-app-192209417.ap-south-1.elb.amazonaws.com:8080',
|
||||||
//'http://localhost:8081',
|
'http://localhost:8081',
|
||||||
connectTimeout: const Duration(seconds: 5),
|
connectTimeout: const Duration(seconds: 5),
|
||||||
receiveTimeout: const Duration(seconds: 10),
|
receiveTimeout: const Duration(seconds: 10),
|
||||||
headers: {
|
headers: {
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
// ignore_for_file: avoid_print
|
// ignore_for_file: avoid_print, use_build_context_synchronously, duplicate_ignore
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:kmobile/api/services/neft_service.dart';
|
import 'package:kmobile/api/services/neft_service.dart';
|
||||||
import 'package:kmobile/api/services/rtgs_service.dart';
|
import 'package:kmobile/api/services/rtgs_service.dart';
|
||||||
|
import 'package:kmobile/api/services/imps_service.dart';
|
||||||
|
import 'package:kmobile/data/models/imps_transaction.dart';
|
||||||
import 'package:kmobile/widgets/bank_logos.dart';
|
import 'package:kmobile/widgets/bank_logos.dart';
|
||||||
import 'package:kmobile/data/models/beneficiary.dart';
|
import 'package:kmobile/data/models/beneficiary.dart';
|
||||||
import 'package:kmobile/data/models/neft_transaction.dart';
|
import 'package:kmobile/data/models/neft_transaction.dart';
|
||||||
@@ -15,7 +17,7 @@ import 'package:kmobile/features/fund_transfer/screens/payment_animation.dart';
|
|||||||
import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
|
import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
|
||||||
import '../../../l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
enum TransactionMode { neft, rtgs }
|
enum TransactionMode { neft, rtgs, imps }
|
||||||
|
|
||||||
class FundTransferAmountScreen extends StatefulWidget {
|
class FundTransferAmountScreen extends StatefulWidget {
|
||||||
final String debitAccountNo;
|
final String debitAccountNo;
|
||||||
@@ -133,64 +135,66 @@ class _FundTransferAmountScreenState extends State<FundTransferAmountScreen> {
|
|||||||
completer.complete(paymentResponse);
|
completer.complete(paymentResponse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// else if (_selectedMode == TransactionMode.imps){
|
|
||||||
// final rtgsTx = RtgsTransaction(
|
//IMPS transaction
|
||||||
// fromAccount: widget.debitAccountNo,
|
else if (_selectedMode == TransactionMode.imps){
|
||||||
// toAccount: widget.creditBeneficiary.accountNo,
|
final impsTx = ImpsTransaction(
|
||||||
// amount: _amountController.text,
|
fromAccount: widget.debitAccountNo,
|
||||||
// ifscCode: widget.creditBeneficiary.ifscCode,
|
toAccount: widget.creditBeneficiary.accountNo,
|
||||||
// remitterName: widget.remitterName,
|
amount: _amountController.text,
|
||||||
// beneficiaryName: widget.creditBeneficiary.name,
|
ifscCode: widget.creditBeneficiary.ifscCode,
|
||||||
// tpin: tpin,
|
remitterName: widget.remitterName,
|
||||||
// );
|
beneficiaryName: widget.creditBeneficiary.name,
|
||||||
// final rtgsService = getIt<RtgsService>();
|
tpin: tpin,
|
||||||
// final completer = Completer<PaymentResponse>();
|
);
|
||||||
|
final impsService = getIt<ImpsService>();
|
||||||
|
final completer = Completer<PaymentResponse>();
|
||||||
|
|
||||||
// Navigator.of(pinScreenContext).pushReplacement(
|
Navigator.of(pinScreenContext).pushReplacement(
|
||||||
// MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
// builder: (_) => PaymentAnimationScreen(
|
builder: (_) => PaymentAnimationScreen(
|
||||||
// paymentResponse: completer.future),
|
paymentResponse: completer.future),
|
||||||
// ),
|
),
|
||||||
// );
|
);
|
||||||
|
|
||||||
// try {
|
try {
|
||||||
// final rtgsResponse =
|
final impsResponse =
|
||||||
// await rtgsService.processRtgsTransaction(rtgsTx);
|
await impsService.processImpsTransaction(impsTx);
|
||||||
// final paymentResponse = PaymentResponse(
|
final paymentResponse = PaymentResponse(
|
||||||
// isSuccess: rtgsResponse.message.toUpperCase() == 'SUCCESS',
|
isSuccess: impsResponse.message.toUpperCase() == 'SUCCESS',
|
||||||
// date: DateTime.now(),
|
date: DateTime.now(),
|
||||||
// creditedAccount: rtgsTx.toAccount,
|
creditedAccount: impsTx.toAccount,
|
||||||
// amount: rtgsTx.amount,
|
amount: impsTx.amount,
|
||||||
// currency: 'INR',
|
currency: 'INR',
|
||||||
// utr: rtgsResponse.utr,
|
utr: impsResponse.utr,
|
||||||
// );
|
);
|
||||||
// completer.complete(paymentResponse);
|
completer.complete(paymentResponse);
|
||||||
// } on DioException catch(e) {
|
} on DioException catch(e) {
|
||||||
// print('dio exception');
|
print('dio exception');
|
||||||
// print(e.toString());
|
print(e.toString());
|
||||||
|
|
||||||
// final error = jsonDecode(e.response.toString())['error'];
|
final error = jsonDecode(e.response.toString())['error'];
|
||||||
// var errorMessage =
|
var errorMessage =
|
||||||
// {
|
{
|
||||||
// "INCORRECT_TPIN" : "Please Enter the correct TPIN",
|
"INCORRECT_TPIN" : "Please Enter the correct TPIN",
|
||||||
// "INSUFFICIENT_FUNDS": "Your account does not have sufficient balance"
|
"INSUFFICIENT_FUNDS": "Your account does not have sufficient balance"
|
||||||
// }[error] ?? "Something Went Wrong";
|
}[error] ?? "Something Went Wrong";
|
||||||
|
|
||||||
// final paymentResponse = PaymentResponse(
|
final paymentResponse = PaymentResponse(
|
||||||
// isSuccess: false,
|
isSuccess: false,
|
||||||
// errorMessage: errorMessage,
|
errorMessage: errorMessage,
|
||||||
// );
|
);
|
||||||
// completer.complete(paymentResponse);
|
completer.complete(paymentResponse);
|
||||||
// } catch (e) {
|
} catch (e) {
|
||||||
// print('generic exception');
|
print('generic exception');
|
||||||
// print(e.toString());
|
print(e.toString());
|
||||||
// final paymentResponse = PaymentResponse(
|
final paymentResponse = PaymentResponse(
|
||||||
// isSuccess: false,
|
isSuccess: false,
|
||||||
// errorMessage: "Something went Wrong",
|
errorMessage: "Something went Wrong",
|
||||||
// );
|
);
|
||||||
// completer.complete(paymentResponse);
|
completer.complete(paymentResponse);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
else {
|
else {
|
||||||
final rtgsTx = RtgsTransaction(
|
final rtgsTx = RtgsTransaction(
|
||||||
fromAccount: widget.debitAccountNo,
|
fromAccount: widget.debitAccountNo,
|
||||||
@@ -325,7 +329,9 @@ class _FundTransferAmountScreenState extends State<FundTransferAmountScreen> {
|
|||||||
child: ToggleButtons(
|
child: ToggleButtons(
|
||||||
isSelected: [
|
isSelected: [
|
||||||
_selectedMode == TransactionMode.neft,
|
_selectedMode == TransactionMode.neft,
|
||||||
_selectedMode == TransactionMode.rtgs
|
_selectedMode == TransactionMode.rtgs,
|
||||||
|
_selectedMode == TransactionMode.imps,
|
||||||
|
|
||||||
],
|
],
|
||||||
onPressed: (index) {
|
onPressed: (index) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -352,10 +358,10 @@ class _FundTransferAmountScreenState extends State<FundTransferAmountScreen> {
|
|||||||
horizontal: 24.0, vertical: 12.0),
|
horizontal: 24.0, vertical: 12.0),
|
||||||
child: Text(AppLocalizations.of(context).rtgs),
|
child: Text(AppLocalizations.of(context).rtgs),
|
||||||
),
|
),
|
||||||
// Padding(
|
Padding(
|
||||||
// padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
|
padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
|
||||||
// child: Text(AppLocalizations.of(context).imps),
|
child: Text(AppLocalizations.of(context).imps),
|
||||||
// ),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@@ -1,7 +1,11 @@
|
|||||||
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:kmobile/api/services/imps_service.dart';
|
||||||
import 'package:kmobile/api/services/neft_service.dart';
|
import 'package:kmobile/api/services/neft_service.dart';
|
||||||
import 'package:kmobile/api/services/rtgs_service.dart';
|
import 'package:kmobile/api/services/rtgs_service.dart';
|
||||||
|
import 'package:kmobile/data/models/imps_transaction.dart';
|
||||||
import 'package:kmobile/data/models/neft_transaction.dart';
|
import 'package:kmobile/data/models/neft_transaction.dart';
|
||||||
import 'package:kmobile/data/models/payment_response.dart';
|
import 'package:kmobile/data/models/payment_response.dart';
|
||||||
import 'package:kmobile/data/models/rtgs_transaction.dart';
|
import 'package:kmobile/data/models/rtgs_transaction.dart';
|
||||||
@@ -118,6 +122,7 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
|||||||
return [
|
return [
|
||||||
AppLocalizations.of(context).neft,
|
AppLocalizations.of(context).neft,
|
||||||
AppLocalizations.of(context).rtgs,
|
AppLocalizations.of(context).rtgs,
|
||||||
|
AppLocalizations.of(context).imps,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,6 +156,8 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
|||||||
final amount = double.tryParse(amountController.text) ?? 0;
|
final amount = double.tryParse(amountController.text) ?? 0;
|
||||||
final selectedMode = transactionModes(context)[selectedTransactionIndex];
|
final selectedMode = transactionModes(context)[selectedTransactionIndex];
|
||||||
final isRtgs = selectedMode == AppLocalizations.of(context).rtgs;
|
final isRtgs = selectedMode == AppLocalizations.of(context).rtgs;
|
||||||
|
final isNeft = selectedMode == AppLocalizations.of(context).neft;
|
||||||
|
final isImps = selectedMode == AppLocalizations.of(context).imps;
|
||||||
|
|
||||||
if (isRtgs && amount < 200000) {
|
if (isRtgs && amount < 200000) {
|
||||||
showDialog(
|
showDialog(
|
||||||
@@ -174,14 +181,14 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
|||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => TransactionPinScreen(
|
builder: (context) => TransactionPinScreen(
|
||||||
onPinCompleted: (pinScreenContext, tpin) async {
|
onPinCompleted: (pinScreenContext, tpin) async {
|
||||||
if (!isRtgs) {
|
if (isNeft) {
|
||||||
// NEFT
|
// NEFT
|
||||||
final neftTx = NeftTransaction(
|
final neftTx = NeftTransaction(
|
||||||
fromAccount: widget.debitAccount,
|
fromAccount: widget.debitAccount,
|
||||||
toAccount: accountNumberController.text,
|
toAccount: accountNumberController.text,
|
||||||
amount: amountController.text,
|
amount: amountController.text,
|
||||||
ifscCode: ifscController.text,
|
ifscCode: ifscController.text,
|
||||||
remitterName: "Unknown", // TODO: Get actual remitter name
|
remitterName: "Unknown",
|
||||||
beneficiaryName: nameController.text,
|
beneficiaryName: nameController.text,
|
||||||
tpin: tpin,
|
tpin: tpin,
|
||||||
);
|
);
|
||||||
@@ -214,14 +221,58 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
|||||||
);
|
);
|
||||||
completer.complete(paymentResponse);
|
completer.complete(paymentResponse);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (isImps) {
|
||||||
|
// IMPS
|
||||||
|
final impsTx = ImpsTransaction(
|
||||||
|
fromAccount: widget.debitAccount,
|
||||||
|
toAccount: accountNumberController.text,
|
||||||
|
amount: amountController.text,
|
||||||
|
ifscCode: ifscController.text,
|
||||||
|
remitterName: "Unknown",
|
||||||
|
beneficiaryName: nameController.text,
|
||||||
|
tpin: tpin,
|
||||||
|
);
|
||||||
|
final impsService = getIt<ImpsService>();
|
||||||
|
final completer = Completer<PaymentResponse>();
|
||||||
|
|
||||||
|
Navigator.of(pinScreenContext).pushReplacement(
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (_) => PaymentAnimationScreen(
|
||||||
|
paymentResponse: completer.future),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
final neftResponse =
|
||||||
|
await impsService.processImpsTransaction(impsTx);
|
||||||
|
final paymentResponse = PaymentResponse(
|
||||||
|
isSuccess: neftResponse.message.toUpperCase() == 'SUCCESS',
|
||||||
|
date: DateTime.now(),
|
||||||
|
creditedAccount: impsTx.toAccount,
|
||||||
|
amount: impsTx.amount,
|
||||||
|
currency: 'INR',
|
||||||
|
utr: neftResponse.utr,
|
||||||
|
);
|
||||||
|
completer.complete(paymentResponse);
|
||||||
|
} catch (e) {
|
||||||
|
final paymentResponse = PaymentResponse(
|
||||||
|
isSuccess: false,
|
||||||
|
errorMessage: e.toString(),
|
||||||
|
);
|
||||||
|
completer.complete(paymentResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isRtgs) {
|
||||||
// RTGS
|
// RTGS
|
||||||
final rtgsTx = RtgsTransaction(
|
final rtgsTx = RtgsTransaction(
|
||||||
fromAccount: widget.debitAccount,
|
fromAccount: widget.debitAccount,
|
||||||
toAccount: accountNumberController.text,
|
toAccount: accountNumberController.text,
|
||||||
amount: amountController.text,
|
amount: amountController.text,
|
||||||
ifscCode: ifscController.text,
|
ifscCode: ifscController.text,
|
||||||
remitterName: "Unknown", // TODO: Get actual remitter name
|
remitterName: "Unknown",
|
||||||
beneficiaryName: nameController.text,
|
beneficiaryName: nameController.text,
|
||||||
tpin: tpin,
|
tpin: tpin,
|
||||||
);
|
);
|
||||||
|
@@ -1,43 +1,148 @@
|
|||||||
import '../../../l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class BranchLocatorScreen extends StatelessWidget {
|
class Branch {
|
||||||
|
final String name;
|
||||||
|
final String code;
|
||||||
|
final String ifsc;
|
||||||
|
final String address;
|
||||||
|
|
||||||
|
Branch({required this.name, required this.code, required this.ifsc, required this.address,});
|
||||||
|
}
|
||||||
|
|
||||||
|
class BranchLocatorScreen extends StatefulWidget {
|
||||||
const BranchLocatorScreen({super.key});
|
const BranchLocatorScreen({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
State<BranchLocatorScreen> createState() => _BranchLocatorScreenState();
|
||||||
return Scaffold(
|
}
|
||||||
appBar: AppBar(
|
|
||||||
title: Text(AppLocalizations.of(context).branchLocator),
|
class _BranchLocatorScreenState extends State<BranchLocatorScreen> {
|
||||||
),
|
final TextEditingController _searchController = TextEditingController();
|
||||||
body: Center(
|
|
||||||
child: Column(
|
// Static list of 5 branches
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
final List<Branch> _branches = [
|
||||||
children: [
|
Branch(name: "Dharamsala - Head Office", code: "002", ifsc: "KACE0000002", address: "Civil Lines Dharmashala, Kangra, HP - 176215"),
|
||||||
Icon(
|
Branch(name: "Kangra", code: "033", ifsc: "KACE0000033", address: "Rajput Bhawankangrapo Kangra, Kangra, HP "),
|
||||||
Icons.location_on,
|
];
|
||||||
size: 80,
|
|
||||||
color: Theme.of(context).primaryColor,
|
List<Branch> _filteredBranches = [];
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
@override
|
||||||
Text(
|
void initState() {
|
||||||
AppLocalizations.of(context).findnearbybranched,
|
super.initState();
|
||||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
_filteredBranches = _branches; // Initially show all branches
|
||||||
),
|
}
|
||||||
const SizedBox(height: 24),
|
|
||||||
ElevatedButton.icon(
|
void _filterBranches(String query) {
|
||||||
icon: const Icon(Icons.search),
|
setState(() {
|
||||||
label: Text( AppLocalizations.of(context).searchbranch),
|
if (query.isEmpty) {
|
||||||
onPressed: () {
|
_filteredBranches = _branches;
|
||||||
// Place API here
|
} else {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_filteredBranches = _branches.where((branch) {
|
||||||
SnackBar(content: Text( AppLocalizations.of(context).branchsearchsoon)),
|
final lowerQuery = query.toLowerCase();
|
||||||
);
|
return branch.name.toLowerCase().contains(lowerQuery) ||
|
||||||
},
|
branch.code.toLowerCase().contains(lowerQuery) ||
|
||||||
),
|
branch.ifsc.toLowerCase().contains(lowerQuery) ||
|
||||||
],
|
branch.address.toLowerCase().contains(lowerQuery);
|
||||||
),
|
}).toList();
|
||||||
),
|
}
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
// @override
|
||||||
|
// Widget build(BuildContext context) {
|
||||||
|
// return Scaffold(
|
||||||
|
// appBar: AppBar(
|
||||||
|
// title: Text(AppLocalizations.of(context).branchLocator),
|
||||||
|
// ),
|
||||||
|
// body: Center(
|
||||||
|
// child: Column(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
// children: [
|
||||||
|
// Icon(
|
||||||
|
// Icons.location_on,
|
||||||
|
// size: 80,
|
||||||
|
// color: Theme.of(context).primaryColor,
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 16),
|
||||||
|
// Text(
|
||||||
|
// AppLocalizations.of(context).findnearbybranched,
|
||||||
|
// style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 24),
|
||||||
|
// ElevatedButton.icon(
|
||||||
|
// icon: const Icon(Icons.search),
|
||||||
|
// label: Text( AppLocalizations.of(context).searchbranch),
|
||||||
|
// onPressed: () {
|
||||||
|
// // Place API here
|
||||||
|
|
||||||
|
// // ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
// // SnackBar(content: Text( AppLocalizations.of(context).branchsearchsoon)),
|
||||||
|
// // );
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text(AppLocalizations.of(context).branchLocator),
|
||||||
|
),
|
||||||
|
body: Column(
|
||||||
|
children: [
|
||||||
|
// Search bar
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(12.0),
|
||||||
|
child: TextField(
|
||||||
|
controller: _searchController,
|
||||||
|
onChanged: _filterBranches,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: AppLocalizations.of(context).searchbranchby,
|
||||||
|
prefixIcon: const Icon(Icons.search),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// List of branches
|
||||||
|
Expanded(
|
||||||
|
child: _filteredBranches.isEmpty
|
||||||
|
? const Center(child: Text("No matching branches found"))
|
||||||
|
: ListView.builder(
|
||||||
|
itemCount: _filteredBranches.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final branch = _filteredBranches[index];
|
||||||
|
return Card(
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||||
|
child: ListTile(
|
||||||
|
leading: Icon(Icons.location_city, color: Theme.of(context).primaryColor),
|
||||||
|
title: Text(branch.name, style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||||
|
subtitle: Text("Code: ${branch.code} | IFSC: ${branch.ifsc} \nBranch Address: ${branch.address}"),
|
||||||
|
onTap: () {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(content: Text("Selected ${branch.name}")),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -249,6 +249,7 @@
|
|||||||
"validateBeneficiaryproceeding": "Please validate beneficiary before proceeding",
|
"validateBeneficiaryproceeding": "Please validate beneficiary before proceeding",
|
||||||
"findnearbybranched": "Find nearby branches",
|
"findnearbybranched": "Find nearby branches",
|
||||||
"searchbranch": "Search Branch",
|
"searchbranch": "Search Branch",
|
||||||
|
"searchbranchby": "Search by Branch Name / Code / IFSC",
|
||||||
"branchsearchsoon": "Branch search coming soon..."
|
"branchsearchsoon": "Branch search coming soon..."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -249,5 +249,6 @@
|
|||||||
"validateBeneficiaryproceeding": "कृपया आगे बढ़ने से पहले लाभार्थी को पट्टे पर मान्य करें",
|
"validateBeneficiaryproceeding": "कृपया आगे बढ़ने से पहले लाभार्थी को पट्टे पर मान्य करें",
|
||||||
"findnearbybranched": "आस-पास की शाखाएँ खोजें",
|
"findnearbybranched": "आस-पास की शाखाएँ खोजें",
|
||||||
"searchbranch": "शाखा खोजें",
|
"searchbranch": "शाखा खोजें",
|
||||||
|
"searchbranchby": "शाखा खोजें नाम / बैंक कोड / आईएफएससी द्वारा",
|
||||||
"branchsearchsoon": "शाखा खोज सुविधा जल्द ही आ रही है..."
|
"branchsearchsoon": "शाखा खोज सुविधा जल्द ही आ रही है..."
|
||||||
}
|
}
|
||||||
|
@@ -1517,6 +1517,12 @@ abstract class AppLocalizations {
|
|||||||
/// **'Search Branch'**
|
/// **'Search Branch'**
|
||||||
String get searchbranch;
|
String get searchbranch;
|
||||||
|
|
||||||
|
/// No description provided for @searchbranchby.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'Search by Branch Name / Code / IFSC'**
|
||||||
|
String get searchbranchby;
|
||||||
|
|
||||||
/// No description provided for @branchsearchsoon.
|
/// No description provided for @branchsearchsoon.
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
|
@@ -719,6 +719,9 @@ class AppLocalizationsEn extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get searchbranch => 'Search Branch';
|
String get searchbranch => 'Search Branch';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get searchbranchby => 'Search by Branch Name / Code / IFSC';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get branchsearchsoon => 'Branch search coming soon...';
|
String get branchsearchsoon => 'Branch search coming soon...';
|
||||||
}
|
}
|
||||||
|
@@ -719,6 +719,9 @@ class AppLocalizationsHi extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get searchbranch => 'शाखा खोजें';
|
String get searchbranch => 'शाखा खोजें';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get searchbranchby => 'शाखा खोजें नाम / बैंक कोड / आईएफएससी द्वारा';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get branchsearchsoon => 'शाखा खोज सुविधा जल्द ही आ रही है...';
|
String get branchsearchsoon => 'शाखा खोज सुविधा जल्द ही आ रही है...';
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user