diff --git a/lib/app.dart b/lib/app.dart index e6702f8..c71ab29 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -10,7 +10,7 @@ import 'data/repositories/auth_repository.dart'; import 'di/injection.dart'; import 'features/auth/controllers/auth_cubit.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/service/screens/service_screen.dart'; import 'features/dashboard/screens/dashboard_screen.dart'; @@ -129,7 +129,7 @@ class _NavigationScaffoldState extends State { final List _pages = [ DashboardScreen(), - CardScreen(), + CardManagementScreen(), ServiceScreen(), CustomerInfoScreen() ]; diff --git a/lib/features/card/screens/Card_screen.dart b/lib/features/card/screens/Card_screen.dart deleted file mode 100644 index 68111a6..0000000 --- a/lib/features/card/screens/Card_screen.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:flutter/material.dart'; - -class CardScreen extends StatefulWidget { - const CardScreen({super.key}); - - @override - State createState() => _CardScreen(); -} - -class _CardScreen extends State{ - @override - Widget build(BuildContext context) { - return Scaffold( - - ); - } -} - diff --git a/lib/features/card/screens/block_card_screen.dart b/lib/features/card/screens/block_card_screen.dart new file mode 100644 index 0000000..4917151 --- /dev/null +++ b/lib/features/card/screens/block_card_screen.dart @@ -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 createState() => _BlockCardScreen(); +} + +class _BlockCardScreen extends State{ + final _formKey = GlobalKey(); + final _cardController = TextEditingController(); + final _cvvController = TextEditingController(); + final _expiryController = TextEditingController(); + final _phoneController = TextEditingController(); + + Future _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'), + ), + ], + ), + ), + ), + ); + } + +} \ No newline at end of file diff --git a/lib/features/card/screens/card_management_screen.dart b/lib/features/card/screens/card_management_screen.dart new file mode 100644 index 0000000..307812c --- /dev/null +++ b/lib/features/card/screens/card_management_screen.dart @@ -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 createState() => _CardManagementScreen(); +} + +class _CardManagementScreen extends State{ + @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, + ); + } +} + diff --git a/lib/features/dashboard/screens/dashboard_screen.dart b/lib/features/dashboard/screens/dashboard_screen.dart index 2217617..05a1017 100644 --- a/lib/features/dashboard/screens/dashboard_screen.dart +++ b/lib/features/dashboard/screens/dashboard_screen.dart @@ -108,7 +108,7 @@ class _DashboardScreenState extends State { children: [ _buildQuickLink(Symbols.id_card, "Customer \n Info", () { Navigator.push(context, MaterialPageRoute( - builder: (context) => const CustomerInfoScreen()));; + builder: (context) => const CustomerInfoScreen())); }), _buildQuickLink(Symbols.currency_rupee, "Quick \n Pay", () => print("")),