-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
emergency_contact_view #23
Open
Samarth-143
wants to merge
1
commit into
team-envision:main
Choose a base branch
from
Samarth-143:samarth-emergency_contact
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
lib/app/modules/emergency_contact/bindings/emergency_contact_binding.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>( | ||
() => EmergencyContactController(), | ||
); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
lib/app/modules/emergency_contact/controllers/emergency_contact_controller.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:get/get.dart'; | ||
|
||
class EmergencyContactController extends GetxController { | ||
final formKey = GlobalKey<FormState>(); | ||
|
||
@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, | ||
); | ||
} | ||
} | ||
} | ||
|
257 changes: 257 additions & 0 deletions
257
lib/app/modules/emergency_contact/views/emergency_contact_view.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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), | ||
), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make a separate file of custom textform field, and use that widget as reusable component