Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added undomain/assets/Frame 15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added undomain/assets/box1.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added undomain/assets/box2.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added undomain/assets/mess.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added undomain/assets/pic.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions undomain/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:undomain/router/go_router.dart';

void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(const MyApp());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:pinput/pinput.dart';
import 'package:undomain/router/router_names.dart';
import 'package:undomain/services/auth_services/authservices.dart';
import 'package:undomain/util/colors/colors.dart';
import 'package:undomain/util/global/global_function.dart';
import 'package:undomain/util/global/global_varibles.dart';
import 'package:undomain/util/textstyles/text_styles.dart';
import 'package:undomain/widgets/buttons/authpage_button.dart';

class EmailVerification extends StatefulWidget {
const EmailVerification({super.key});
final String userid;
final bool isForRegister;
final String? email;
const EmailVerification({
super.key,
required this.userid,
required this.isForRegister,
this.email,
});

@override
State<EmailVerification> createState() => _EmailVerificationState();
Expand All @@ -18,7 +31,10 @@ class EmailVerification extends StatefulWidget {
class _EmailVerificationState extends State<EmailVerification> {
late Timer _timer;
int _start = 60;

bool _isLoading = false;
TextEditingController _pincontroller = TextEditingController();
final GlobalFunction _globalFunction = GlobalFunction();
final Authservices _authservices = Authservices();
@override
void initState() {
startTimer();
Expand All @@ -44,9 +60,55 @@ class _EmailVerificationState extends State<EmailVerification> {
});
}

void _onSubmit(String pin) {
// Validate or verify PIN here
print("Entered Code: $pin");
//request when complete the pinput
void _onSubmit(String pin) async {
setState(() {
_isLoading = true;
});
if (pin.isEmpty || widget.userid.isEmpty) {
_globalFunction.snackBarMassage(context, "Empty User Data", 3);
return;
// GoRouter.of(context).goNamed(RouterNames.homePage);
}

//for user registration
if (widget.isForRegister) {
final response = await _authservices.verifyNewUser(
userId: widget.userid,
verifyCode: pin,
);
if (response["success"]) {
String base64String = response["user"]["profileUrl"];
Uint8List imagesBytes = base64Decode(base64String);
GoRouter.of(context).goNamed(
RouterNames.homePage,
extra: {
"userId": response["user"]["id"],
"username": response["user"]["username"],
"email": response["user"]["email"],
"profileUrl": imagesBytes,
},
);
} else {
_globalFunction.snackBarMassage(context, response["massage"], 3);
}
//for password reset
} else {
final response = await _authservices.verifyResetPassword(
email: widget.email!,
otp: pin,
password: widget.userid,
);
if (response["success"]) {
GoRouter.of(context).goNamed(RouterNames.loginPage);
} else {
_globalFunction.snackBarMassage(context, response["massage"], 3);
}
}
setState(() {
_isLoading = false;
_pincontroller.clear();
});
}

@override
Expand All @@ -55,13 +117,22 @@ class _EmailVerificationState extends State<EmailVerification> {
final defaultPinTheme = PinTheme(
width: (pinputSize - 0.08) / 5,
height: (pinputSize - 0.08) / 5,
textStyle: TextStyle(fontSize: 20, color: Colors.black),
textStyle: TextStyle(fontSize: 20, color: utilPrimaryBlack),
decoration: BoxDecoration(
border: Border.all(color: Colors.grey),
// border: Border.all(color: utilPrimaryGrey),
borderRadius: BorderRadius.circular(10),
color: utilPrimaryWhite,
boxShadow: [
BoxShadow(
offset: Offset(1, 2),
blurRadius: 2,
color: utilPrimaryGrey.withOpacity(0.5),
),
],
),
);
return Scaffold(
resizeToAvoidBottomInset: false,
body: Padding(
padding: EdgeInsets.symmetric(
horizontal: authScreenPaddingH,
Expand All @@ -80,6 +151,7 @@ class _EmailVerificationState extends State<EmailVerification> {
SizedBox(height: MediaQuery.of(context).size.height * 0.02),
//pinputs
Pinput(
controller: _pincontroller,
length: 5,
keyboardType: TextInputType.number,
onCompleted: _onSubmit,
Expand All @@ -96,14 +168,20 @@ class _EmailVerificationState extends State<EmailVerification> {
],
),
)
: Text("Resend", style: textLabel),
: TextButton(
onPressed: () {},
child: Text("Resend", style: textLabelRed),
),
],
),
SizedBox(height: MediaQuery.of(context).size.height * 0.08),
Column(
children: [
//verify button:to home page
AuthpageButton(path: RouterNames.homePage, text: "Verify"),
GestureDetector(
onTap: () => _onSubmit(_pincontroller.text),
child: AuthpageButton(text: "Verify", isLoading: _isLoading),
),
//to login page
TextButton(
onPressed: () {
Expand Down
185 changes: 185 additions & 0 deletions undomain/lib/pages/authentication/fogotpassword/fogot_password.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:undomain/router/router_names.dart';
import 'package:undomain/services/auth_services/authservices.dart';
import 'package:undomain/util/global/global_function.dart';
import 'package:undomain/util/global/global_varibles.dart';
import 'package:undomain/util/textstyles/text_styles.dart';
import 'package:undomain/widgets/buttons/authpage_button.dart';
import 'package:undomain/widgets/textboxes/authtext_box.dart';

class FogotPassword extends StatefulWidget {
const FogotPassword({super.key});

@override
State<FogotPassword> createState() => _FogotPasswordState();
}

class _FogotPasswordState extends State<FogotPassword> {
final TextEditingController _confirmpasswordcontroller =
TextEditingController();
final TextEditingController _passwordcontroller = TextEditingController();
final TextEditingController _emailcontroller = TextEditingController();
final _formKey = GlobalKey<FormState>();
bool _isLoading = false;
final Authservices _authservices = Authservices();
final GlobalFunction _globalFunction = GlobalFunction();
//regexp for password
final RegExp passwordRegExp = RegExp(
r'^(?=.*[A-Za-z])(?=.*\d)(?=.*[!@#$%^&*(),.?":{}|<>]).{6,}$',
);
String confirmpasswordHint = "@confirm password";
bool isconfirmpasswordValid = true;
String passwordHint = "@password";
String emailHint = "@email";
bool isPasswordValid = true;

Future<void> _getCodeForResetPassword() async {
setState(() {
_isLoading = true;
});

final response = await _authservices.sendPasswordResetRequest(
email: _emailcontroller.text,
);
if (response["success"]) {
GoRouter.of(context).goNamed(
RouterNames.verificationPage,
extra: {
"userId": _passwordcontroller.text,
"isFromRegister": false,
"email": response["user"]["id"],
},
);
} else {
_globalFunction.snackBarMassage(context, response["massage"], 3);
}
setState(() {
_isLoading = false;
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
body: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: authScreenPaddingH,
vertical: authScreenPaddingV,
),
child: Column(
children: [
SizedBox(height: MediaQuery.of(context).size.height * 0.08),
//title
Column(children: [Text("Date NET.", style: textDisplay)]),
SizedBox(height: MediaQuery.of(context).size.height * 0.15),
//auth details
Form(
key: _formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
//password
AuthtextBox(
isValid: isPasswordValid,
controller: _emailcontroller,
hint: emailHint,
isShow: false,
onSubmit: (p0) {},
textInputAction: TextInputAction.next,
textInputType: TextInputType.emailAddress,

validChecker: (value) => null,
),
SizedBox(height: MediaQuery.of(context).size.height * 0.02),
AuthtextBox(
isValid: isPasswordValid,
controller: _passwordcontroller,
hint: passwordHint,
isShow: false,
onSubmit: (p0) {},
textInputAction: TextInputAction.next,
textInputType: TextInputType.name,

validChecker: (value) => null,
),
SizedBox(height: MediaQuery.of(context).size.height * 0.02),
//confirm password
AuthtextBox(
controller: _confirmpasswordcontroller,
isValid: isconfirmpasswordValid,
hint: confirmpasswordHint,
isShow: false,
onSubmit: (p0) {},
textInputAction: TextInputAction.done,
textInputType: TextInputType.visiblePassword,
validChecker: (value) => null,
),

SizedBox(height: MediaQuery.of(context).size.height * 0.25),
Column(
children: [
//if valid form state
GestureDetector(
onTap: () async {
if (_confirmpasswordcontroller.text.isEmpty &&
_passwordcontroller.text.isEmpty) {
setState(() {
isPasswordValid = false;
passwordHint = "please enter your @password";
isconfirmpasswordValid = false;
confirmpasswordHint =
"please confirm your password";
});
} else if (!passwordRegExp.hasMatch(
_passwordcontroller.text,
)) {
setState(() {
passwordHint = "weak password";
_passwordcontroller.clear();
});
} else if (_passwordcontroller.text !=
_confirmpasswordcontroller.text) {
setState(() {
confirmpasswordHint =
"password mismatching please check your password";
_confirmpasswordcontroller.clear();
});
} else {
await _getCodeForResetPassword();
}
},

child: AuthpageButton(
text: "Submit",
isLoading: false,
),
),
//to register page
TextButton(
onPressed: () {
GoRouter.of(
context,
).goNamed(RouterNames.registerPage);
},
child: Text(
"Create new account",
style: textLabelRed,
),
),
],
),

//to home page
],
),
),
],
),
),
),
);
}
}
Loading