diff --git a/fonts/Urbanist-Regular.ttf b/fonts/Urbanist-Regular.ttf new file mode 100644 index 0000000..eda2a96 Binary files /dev/null and b/fonts/Urbanist-Regular.ttf differ diff --git a/lib/app/modules/emergency_contact/bindings/emergency_contact_binding.dart b/lib/app/modules/emergency_contact/bindings/emergency_contact_binding.dart new file mode 100644 index 0000000..298cf10 --- /dev/null +++ b/lib/app/modules/emergency_contact/bindings/emergency_contact_binding.dart @@ -0,0 +1,12 @@ +import 'package:get/get.dart'; + +import '../controllers/emergency_contact_controller.dart'; + +class EmergencyContactBinding extends Bindings { + @override + void dependencies() { + Get.lazyPut( + () => EmergencyContactController(), + ); + } +} diff --git a/lib/app/modules/emergency_contact/controllers/emergency_contact_controller.dart b/lib/app/modules/emergency_contact/controllers/emergency_contact_controller.dart new file mode 100644 index 0000000..dfeedcf --- /dev/null +++ b/lib/app/modules/emergency_contact/controllers/emergency_contact_controller.dart @@ -0,0 +1,44 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +class EmergencyContactController extends GetxController { + final formKey = GlobalKey(); + + @override + void onInit() { + super.onInit(); + } + + @override + void onReady() { + super.onReady(); + } + + @override + void onClose() { + super.onClose(); + } + + // Observables for each form field + var name = ''.obs; + var mobileNumber = ''.obs; + var email = ''.obs; + var relation = ''.obs; + + // Method to validate and save form + void saveDetails() { + if (formKey.currentState!.validate()) { + formKey.currentState!.save(); + // Perform additional logic for saving the data + Get.snackbar('Success', 'Emergency contact details saved successfully', + snackPosition: SnackPosition.BOTTOM); + } else { + Get.snackbar( + 'Error', + 'Please fill all fields correctly', + snackPosition: SnackPosition.BOTTOM, + ); + } + } +} + diff --git a/lib/app/modules/emergency_contact/views/emergency_contact_view.dart b/lib/app/modules/emergency_contact/views/emergency_contact_view.dart new file mode 100644 index 0000000..8eec4b9 --- /dev/null +++ b/lib/app/modules/emergency_contact/views/emergency_contact_view.dart @@ -0,0 +1,257 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:here_for_you_app/app/modules/emergency_contact/controllers/emergency_contact_controller.dart'; // Import the controller + +class EmergencyContactView extends StatelessWidget { + final EmergencyContactController _controller = Get.put(EmergencyContactController()); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + leading: IconButton( + icon: Icon( + Icons.arrow_back, + size: 35, + ), + onPressed: () { + Get.back(); // Navigate to the previous screen + }, + ), + titleSpacing: -10, // Make title align close to the back button + title: Text( + 'Emergency Contact', + style: TextStyle( + fontFamily: 'Urbanist', + fontWeight: FontWeight.bold, + fontSize: 25, + ), + ), + backgroundColor: Colors.transparent, + elevation: 0, // Remove shadow + ), + body: SingleChildScrollView( + padding: const EdgeInsets.all(16.0), + child: Form( + key: _controller.formKey, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Name Label and TextFormField with Shadow + SizedBox(height: 20), + Text( + 'Name', + style: TextStyle( + fontFamily: 'Urbanist', + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + SizedBox(height: 7), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(35), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.3), + spreadRadius: 3, + blurRadius: 6, + offset: Offset(0, 3), // Shadow position + ), + ], + ), + child: TextFormField( + decoration: InputDecoration( + hintText: 'Enter emergency contact name', + filled: true, // Enable filling + fillColor: Colors.white, // Set the fill color to white + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(35), // Rounded corners + ), + contentPadding: EdgeInsets.symmetric(horizontal:14,vertical: 8), // Consistent height + ), + style: TextStyle(fontFamily: 'Urbanist'), + onSaved: (value) => _controller.name.value = value!, + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter a name'; + } + return null; + }, + ), + ), + SizedBox(height: 20), + + // Mobile Number Label and TextFormField with Shadow + Text( + 'Mobile Number', + style: TextStyle( + fontFamily: 'Urbanist', + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + SizedBox(height: 7), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(35), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.3), + spreadRadius: 3, + blurRadius: 6, + offset: Offset(0, 3), // Shadow position + ), + ], + ), + child: TextFormField( + decoration: InputDecoration( + hintText: 'Enter emergency contact number', + filled: true, // Enable filling + fillColor: Colors.white, // Set the fill color to white + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(35), // Rounded corners + ), + contentPadding: EdgeInsets.symmetric(horizontal:14,vertical: 8), // Consistent height + ), + keyboardType: TextInputType.phone, + style: TextStyle(fontFamily: 'Urbanist'), + onSaved: (value) => _controller.mobileNumber.value = value!, + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter a mobile number'; + } + if (value.length != 10) { + return 'Mobile number should be 10 digits'; + } + return null; + }, + ), + ), + SizedBox(height: 20), + + // Email Label and TextFormField with Shadow + Text( + 'Email', + style: TextStyle( + fontFamily: 'Urbanist', + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + SizedBox(height: 7), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(35), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.3), + spreadRadius: 3, + blurRadius: 6, + offset: Offset(0, 3), // Shadow position + ), + ], + ), + child: TextFormField( + decoration: InputDecoration( + hintText: 'Enter emergency contact email', + filled: true, // Enable filling + fillColor: Colors.white, // Set the fill color to white + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(35), + ), + contentPadding: EdgeInsets.symmetric(horizontal:14,vertical: 8), // Consistent height + ), + keyboardType: TextInputType.emailAddress, + style: TextStyle(fontFamily: 'Urbanist'), + onSaved: (value) => _controller.email.value = value!, + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter an email'; + } + if (!GetUtils.isEmail(value)) { + return 'Enter a valid email'; + } + return null; + }, + ), + ), + SizedBox(height: 20), + + // Relation Label and TextFormField with Shadow + Text( + 'Relation', + style: TextStyle( + fontFamily: 'Urbanist', + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + SizedBox(height: 7), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(35), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.3), + spreadRadius: 3, + blurRadius: 6, + offset: Offset(0, 3), // Shadow position + ), + ], + ), + child: TextFormField( + decoration: InputDecoration( + hintText: 'How is emergency contact related to you?', + hintStyle: TextStyle( + fontFamily: 'Urbanist', + fontSize: 13, + ), + filled: true, // Enable filling + fillColor: Colors.white, // Set the fill color to white + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(35), // Rounded corners + ), + contentPadding: EdgeInsets.symmetric(horizontal:12,vertical: 8), // Consistent height + ), + style: TextStyle(fontFamily: 'Urbanist'), + onSaved: (value) => _controller.relation.value = value!, + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter the relation'; + } + return null; + }, + ), + ), + SizedBox(height: 30), + + // Save Button + Center( + child: ElevatedButton( + onPressed: () { + _controller.saveDetails(); + }, + child: Text( + 'Save Details', + style: TextStyle( + fontFamily: 'Urbanist', + fontSize: 18, + fontWeight: FontWeight.bold, + color: Colors.white, + ), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.black, + padding: EdgeInsets.symmetric(horizontal: 105, vertical: 12), + textStyle: TextStyle(fontSize: 10), + ), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/app/routes/app_pages.dart b/lib/app/routes/app_pages.dart index 8d40819..9b22767 100644 --- a/lib/app/routes/app_pages.dart +++ b/lib/app/routes/app_pages.dart @@ -1,5 +1,7 @@ import 'package:get/get.dart'; +import '../modules/emergency_contact/bindings/emergency_contact_binding.dart'; +import '../modules/emergency_contact/views/emergency_contact_view.dart'; import '../modules/home/bindings/home_binding.dart'; import '../modules/home/views/home_view.dart'; @@ -8,7 +10,7 @@ part 'app_routes.dart'; class AppPages { AppPages._(); - static const INITIAL = Routes.HOME; + static const INITIAL = Routes.EMERGENCY_CONTACT; static final routes = [ GetPage( @@ -16,5 +18,10 @@ class AppPages { page: () => const HomeView(), binding: HomeBinding(), ), + GetPage( + name: _Paths.EMERGENCY_CONTACT, + page: () =>EmergencyContactView(), + binding: EmergencyContactBinding(), + ), ]; } diff --git a/lib/app/routes/app_routes.dart b/lib/app/routes/app_routes.dart index 66fbe17..54316aa 100644 --- a/lib/app/routes/app_routes.dart +++ b/lib/app/routes/app_routes.dart @@ -4,9 +4,11 @@ part of 'app_pages.dart'; abstract class Routes { Routes._(); static const HOME = _Paths.HOME; + static const EMERGENCY_CONTACT = _Paths.EMERGENCY_CONTACT; } abstract class _Paths { _Paths._(); static const HOME = '/home'; + static const EMERGENCY_CONTACT = '/emergency-contact'; } diff --git a/lib/main.dart b/lib/main.dart index d90a1eb..7d4cd47 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -10,6 +10,7 @@ void main() { title: "Application", initialRoute: AppPages.INITIAL, getPages: AppPages.routes, + debugShowCheckedModeBanner: false, ), ); } diff --git a/pubspec.yaml b/pubspec.yaml index fae1bf5..648d970 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -27,6 +27,8 @@ environment: # dependencies can be manually updated by changing the version numbers below to # the latest version available on pub.dev. To see which dependencies have newer # versions available, run `flutter pub outdated`. + + dependencies: flutter: sdk: flutter @@ -59,6 +61,12 @@ flutter: # the material Icons class. uses-material-design: true + fonts: + - family: Urbanist + fonts: + - asset: fonts/Urbanist-regular.ttf + + # To add assets to your application, add an assets section, like this: # assets: # - images/a_dot_burr.jpeg @@ -75,10 +83,7 @@ flutter: # "family" key with the font family name, and a "fonts" key with a # list giving the asset and other descriptors for the font. For # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf # style: italic # - family: Trajan Pro @@ -89,3 +94,4 @@ flutter: # # For details regarding fonts from package dependencies, # see https://flutter.dev/to/font-from-package +