card-management
This commit is contained in:
parent
0781aeb4e1
commit
2b2605cecc
@ -10,7 +10,7 @@ import 'data/repositories/auth_repository.dart';
|
|||||||
import 'di/injection.dart';
|
import 'di/injection.dart';
|
||||||
import 'features/auth/controllers/auth_cubit.dart';
|
import 'features/auth/controllers/auth_cubit.dart';
|
||||||
import 'features/auth/controllers/auth_state.dart';
|
import 'features/auth/controllers/auth_state.dart';
|
||||||
import 'features/card/screens/Card_screen.dart';
|
import 'features/card/screens/card_management_screen.dart';
|
||||||
import 'features/auth/screens/login_screen.dart';
|
import 'features/auth/screens/login_screen.dart';
|
||||||
import 'features/service/screens/service_screen.dart';
|
import 'features/service/screens/service_screen.dart';
|
||||||
import 'features/dashboard/screens/dashboard_screen.dart';
|
import 'features/dashboard/screens/dashboard_screen.dart';
|
||||||
@ -129,7 +129,7 @@ class _NavigationScaffoldState extends State<NavigationScaffold> {
|
|||||||
|
|
||||||
final List<Widget> _pages = [
|
final List<Widget> _pages = [
|
||||||
DashboardScreen(),
|
DashboardScreen(),
|
||||||
CardScreen(),
|
CardManagementScreen(),
|
||||||
ServiceScreen(),
|
ServiceScreen(),
|
||||||
CustomerInfoScreen()
|
CustomerInfoScreen()
|
||||||
];
|
];
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class CardScreen extends StatefulWidget {
|
|
||||||
const CardScreen({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<CardScreen> createState() => _CardScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CardScreen extends State<CardScreen>{
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
187
lib/features/card/screens/block_card_screen.dart
Normal file
187
lib/features/card/screens/block_card_screen.dart
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||||
|
|
||||||
|
class BlockCardScreen extends StatefulWidget {
|
||||||
|
const BlockCardScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<BlockCardScreen> createState() => _BlockCardScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _BlockCardScreen extends State<BlockCardScreen>{
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
final _cardController = TextEditingController();
|
||||||
|
final _cvvController = TextEditingController();
|
||||||
|
final _expiryController = TextEditingController();
|
||||||
|
final _phoneController = TextEditingController();
|
||||||
|
|
||||||
|
Future<void> _pickExpiryDate() async {
|
||||||
|
final now = DateTime.now();
|
||||||
|
final selectedDate = await showDatePicker(
|
||||||
|
context: context,
|
||||||
|
initialDate: now,
|
||||||
|
firstDate: now,
|
||||||
|
lastDate: DateTime(now.year + 10),
|
||||||
|
);
|
||||||
|
if (selectedDate != null) {
|
||||||
|
_expiryController.text = DateFormat('dd/MM/yyyy').format(selectedDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _blockCard() {
|
||||||
|
if (_formKey.currentState?.validate() ?? false) {
|
||||||
|
// Call your backend logic here
|
||||||
|
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('Card has been blocked'),
|
||||||
|
duration: Duration(seconds: 3),
|
||||||
|
behavior: SnackBarBehavior.floating,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
leading: IconButton(icon: const Icon(Symbols.arrow_back_ios_new),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},),
|
||||||
|
title: const Text('Block Card', 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.all(10.0),
|
||||||
|
child: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: ListView(
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
TextFormField(
|
||||||
|
controller: _cardController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Card Number',
|
||||||
|
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) =>
|
||||||
|
value != null && value.length == 16 ? null : 'Enter valid card number',
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: TextFormField(
|
||||||
|
controller: _cvvController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'CVV',
|
||||||
|
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,
|
||||||
|
obscureText: true,
|
||||||
|
validator: (value) =>
|
||||||
|
value != null && value.length == 3 ? null : 'CVV must be 3 digits',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
Expanded(
|
||||||
|
child: TextFormField(
|
||||||
|
controller: _expiryController,
|
||||||
|
readOnly: true,
|
||||||
|
onTap: _pickExpiryDate,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Expiry Date',
|
||||||
|
suffixIcon: Icon(Icons.calendar_today),
|
||||||
|
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),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
validator: (value) =>
|
||||||
|
value != null && value.isNotEmpty ? null : 'Select expiry date',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
TextFormField(
|
||||||
|
controller: _phoneController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Phone',
|
||||||
|
prefixIcon: Icon(Icons.phone),
|
||||||
|
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),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
textInputAction: TextInputAction.done,
|
||||||
|
keyboardType: TextInputType.phone,
|
||||||
|
validator: (value) =>
|
||||||
|
value != null && value.length >= 10 ? null : 'Enter valid phone number',
|
||||||
|
),
|
||||||
|
const SizedBox(height: 35),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: _blockCard,
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
shape: const StadiumBorder(),
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
|
backgroundColor: Colors.blue[900],
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
),
|
||||||
|
child: const Text('Block'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
93
lib/features/card/screens/card_management_screen.dart
Normal file
93
lib/features/card/screens/card_management_screen.dart
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:kmobile/features/card/screens/block_card_screen.dart';
|
||||||
|
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||||
|
|
||||||
|
class CardManagementScreen extends StatefulWidget {
|
||||||
|
const CardManagementScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CardManagementScreen> createState() => _CardManagementScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CardManagementScreen extends State<CardManagementScreen>{
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
automaticallyImplyLeading: false,
|
||||||
|
title: const Text('Card Management', 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: ListView(
|
||||||
|
children: [
|
||||||
|
CardManagementTile(
|
||||||
|
icon: Symbols.add,
|
||||||
|
label: 'Apply Debit Card',
|
||||||
|
onTap: () {
|
||||||
|
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
const Divider(height: 1,),
|
||||||
|
|
||||||
|
CardManagementTile(
|
||||||
|
icon: Symbols.remove_moderator,
|
||||||
|
label: 'Block / Unblock Card',
|
||||||
|
onTap: () {
|
||||||
|
Navigator.push(context, MaterialPageRoute(
|
||||||
|
builder: (context) => const BlockCardScreen()));;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
const Divider(height: 1,),
|
||||||
|
|
||||||
|
CardManagementTile(
|
||||||
|
icon: Symbols.password_2,
|
||||||
|
label: 'Change Card PIN',
|
||||||
|
onTap: () {
|
||||||
|
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
const Divider(height: 1,),
|
||||||
|
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class CardManagementTile extends StatelessWidget {
|
||||||
|
final IconData icon;
|
||||||
|
final String label;
|
||||||
|
final VoidCallback onTap;
|
||||||
|
|
||||||
|
const CardManagementTile({
|
||||||
|
super.key,
|
||||||
|
required this.icon,
|
||||||
|
required this.label,
|
||||||
|
required this.onTap,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListTile(
|
||||||
|
leading: Icon(icon),
|
||||||
|
title: Text(label),
|
||||||
|
trailing: const Icon(Symbols.arrow_right, size: 16),
|
||||||
|
onTap: onTap,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -108,7 +108,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
|||||||
children: [
|
children: [
|
||||||
_buildQuickLink(Symbols.id_card, "Customer \n Info", () {
|
_buildQuickLink(Symbols.id_card, "Customer \n Info", () {
|
||||||
Navigator.push(context, MaterialPageRoute(
|
Navigator.push(context, MaterialPageRoute(
|
||||||
builder: (context) => const CustomerInfoScreen()));;
|
builder: (context) => const CustomerInfoScreen()));
|
||||||
}),
|
}),
|
||||||
_buildQuickLink(Symbols.currency_rupee, "Quick \n Pay",
|
_buildQuickLink(Symbols.currency_rupee, "Quick \n Pay",
|
||||||
() => print("")),
|
() => print("")),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user