Skip to content

Commit

Permalink
Merge pull request #32 from Divyakumar21202/main
Browse files Browse the repository at this point in the history
Added function to validate the College Email Id . Also minor Changes
  • Loading branch information
Divyakumar21202 authored Sep 21, 2024
2 parents 7766e27 + a4bf2c6 commit 73d9a50
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 50 deletions.
110 changes: 62 additions & 48 deletions lib/features/User Profile/widgets/confirm_delete_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:mess_mgmt/Global/models/coupon_data_model.dart';
Expand All @@ -17,60 +19,72 @@ showConfirmDeleteDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Are you sure to delete'),
content: Observer(builder: (context) {
final isLoadingLocally = userProfileStore.isLoadingLocally;
if (isLoadingLocally) {
return const AppLoader();
}
return const SizedBox();
}),
actions: [
Observer(builder: (context) {
final isLoadingLocally = userProfileStore.isLoadingLocally;
return Row(
children: [
if (!isLoadingLocally)
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text(
'Cancel',
),
),
ReactionBuilder(
builder: (context) {
return autorun((_) {
final canDialogPop = appState.canDialogPop;
if (canDialogPop) {
return BackdropFilter(
filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10),
child: AlertDialog(
title: const Text('Are you sure to delete?'),
// content: Observer(builder: (context) {
// final isLoadingLocally = userProfileStore.isLoadingLocally;
// if (isLoadingLocally) {
// return const AppLoader();
// }
// return const SizedBox();
// }),
actions: [
Observer(builder: (context) {
final isLoadingLocally = userProfileStore.isLoadingLocally;
if (isLoadingLocally) {
return const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AppLoader(),
],
);
}
return Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
if (!isLoadingLocally)
TextButton(
onPressed: () {
Navigator.pop(context);
}
});
},
child: ElevatedButton(
onPressed: () async {
if (!isLoadingLocally) {
await userProfileStore.deleteCoupon(coupon: coupon);
}
},
child: const Text(
'Cancel',
),
),
ReactionBuilder(
builder: (context) {
return autorun((_) {
final canDialogPop = appState.canDialogPop;
if (canDialogPop) {
Navigator.pop(context);
}
});
},
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
20,
child: ElevatedButton(
onPressed: () async {
if (!isLoadingLocally) {
await userProfileStore.deleteCoupon(coupon: coupon);
}
},
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
20,
),
),
),
),
child: const Text(
'Confirm',
child: const Text(
'Confirm',
),
),
),
),
],
);
}),
],
],
);
}),
],
),
);
},
);
Expand Down
6 changes: 6 additions & 0 deletions lib/features/auth/repository/auth_repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,10 @@ class AuthRepository {
await http.post(uri, body: data).timeout(const Duration(seconds: 7));
return res;
}

static bool validateEmail({required String email}) {
const String emailPattern = r'^[bB]\d{6}@iiit-bh\.ac\.in$';
RegExp expression = RegExp(emailPattern);
return expression.hasMatch(email.trim().toLowerCase());
}
}
7 changes: 6 additions & 1 deletion lib/features/auth/screens/login_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:mess_mgmt/Global/widgets/custom_pwd_tile.dart';
import 'package:mess_mgmt/Global/widgets/custom_text_field.dart';
import 'package:mess_mgmt/Global/widgets/loader.dart';
import 'package:mess_mgmt/features/auth/enums/auth_enum.dart';
import 'package:mess_mgmt/features/auth/repository/auth_repo.dart';
import 'package:mess_mgmt/features/auth/stores/auth_store.dart';

import '../../../Global/widgets/scaffold_messenger.dart';
Expand All @@ -28,7 +29,11 @@ class _LoginScreenState extends State<LoginScreen>

void login() async {
if (!isValidate(_emailController.text)) {
showMessage(message: "Enter Valid Email", context: context);
showMessage(message: "Please Enter The Email", context: context);
return;
}
if (!AuthRepository.validateEmail(email: _emailController.text)) {
showMessage(message: "Enter Your Valid College Email-Id", context: context);
return;
}
if (!isValidate(_pwdController.text)) {
Expand Down
8 changes: 7 additions & 1 deletion lib/features/auth/screens/signup_screen_1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:mess_mgmt/Global/widgets/custom_text_field.dart';
import 'package:mess_mgmt/Global/widgets/loader.dart';
import 'package:mess_mgmt/Global/widgets/scaffold_messenger.dart';
import 'package:mess_mgmt/features/auth/enums/auth_enum.dart';
import 'package:mess_mgmt/features/auth/repository/auth_repo.dart';
import 'package:mess_mgmt/features/auth/stores/auth_store.dart';

import '../../../features/Networking/widgets/wobble_appbar.dart';
Expand Down Expand Up @@ -48,7 +49,12 @@ class _SignupScreenOneState extends State<SignupScreenOne>
return;
}
if (!isValidate(email)) {
showMessage(message: 'Enter Valid Email', context: context);
showMessage(message: 'Please Enter The Email', context: context);
return;
}
if (!AuthRepository.validateEmail(email: _emailController.text)) {
showMessage(
message: "Enter Your Valid College Email-Id", context: context);
return;
}
// navigateAndPopToNextScreen(
Expand Down

0 comments on commit 73d9a50

Please sign in to comment.