145 lines
5.0 KiB
Dart
145 lines
5.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:kmobile/data/models/user.dart';
|
|
import 'package:kmobile/features/auth/controllers/auth_cubit.dart';
|
|
import 'package:kmobile/features/auth/controllers/auth_state.dart';
|
|
import 'package:kmobile/features/fund_transfer/screens/fund_transfer_beneficiary_screen.dart';
|
|
import 'package:kmobile/features/fund_transfer/screens/fund_transfer_self_accounts_screen.dart';
|
|
import 'package:material_symbols_icons/symbols.dart';
|
|
import '../../../l10n/app_localizations.dart'; // Keep localizations
|
|
|
|
class FundTransferScreen extends StatelessWidget {
|
|
final String creditAccountNo;
|
|
final String remitterName;
|
|
final List<User> accounts; // Continue to accept the list of accounts
|
|
|
|
const FundTransferScreen({
|
|
super.key,
|
|
required this.creditAccountNo,
|
|
required this.remitterName,
|
|
required this.accounts, // It is passed from the dashboard
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
// Restore localization for the title
|
|
title: Text(AppLocalizations.of(context)
|
|
.fundTransfer
|
|
.replaceFirst(RegExp('\n'), '')),
|
|
),
|
|
// Wrap with BlocBuilder to check the authentication state
|
|
body: BlocBuilder<AuthCubit, AuthState>(
|
|
builder: (context, state) {
|
|
return Stack(
|
|
children: [
|
|
ListView(
|
|
children: [
|
|
FundTransferManagementTile(
|
|
icon: Symbols.person,
|
|
// Restore localization for the label
|
|
label: "Self Pay",
|
|
onTap: () {
|
|
// The accounts list is passed directly from the constructor
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => FundTransferSelfAccountsScreen(
|
|
debitAccountNo: creditAccountNo,
|
|
remitterName: remitterName,
|
|
accounts: accounts,
|
|
),
|
|
),
|
|
);
|
|
},
|
|
// Disable the tile if the state is not Authenticated
|
|
disable: state is! Authenticated,
|
|
),
|
|
const Divider(height: 1),
|
|
FundTransferManagementTile(
|
|
icon: Symbols.input_circle,
|
|
// Restore localization for the label
|
|
label: AppLocalizations.of(context).ownBank,
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => FundTransferBeneficiaryScreen(
|
|
creditAccountNo: creditAccountNo,
|
|
remitterName: remitterName,
|
|
isOwnBank: true,
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
const Divider(height: 1),
|
|
FundTransferManagementTile(
|
|
icon: Symbols.output_circle,
|
|
// Restore localization for the label
|
|
label: AppLocalizations.of(context).outsideBank,
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => FundTransferBeneficiaryScreen(
|
|
creditAccountNo: creditAccountNo,
|
|
remitterName: remitterName,
|
|
isOwnBank: false,
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
const Divider(height: 1),
|
|
],
|
|
),
|
|
IgnorePointer(
|
|
child: Center(
|
|
child: Opacity(
|
|
opacity: 0.07, // Reduced opacity
|
|
child: ClipOval(
|
|
child: Image.asset(
|
|
'assets/images/logo.png',
|
|
width: 200, // Adjust size as needed
|
|
height: 200, // Adjust size as needed
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class FundTransferManagementTile extends StatelessWidget {
|
|
final IconData icon;
|
|
final String label;
|
|
final VoidCallback onTap;
|
|
final bool disable;
|
|
|
|
const FundTransferManagementTile({
|
|
super.key,
|
|
required this.icon,
|
|
required this.label,
|
|
required this.onTap,
|
|
this.disable = false,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListTile(
|
|
leading: Icon(icon),
|
|
title: Text(label),
|
|
trailing: const Icon(Symbols.arrow_right, size: 20),
|
|
onTap: onTap,
|
|
enabled: !disable,
|
|
);
|
|
}
|
|
}
|