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.
5 changes: 4 additions & 1 deletion undomain/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:undomain/pages/restart/restart.dart';
import 'package:undomain/router/go_router.dart';

void main() {
runApp(const MyApp());
WidgetsFlutterBinding.ensureInitialized();
runApp(RestartWidget(child: ProviderScope(child: const MyApp())));
}

class MyApp extends StatelessWidget {
Expand Down
32 changes: 22 additions & 10 deletions undomain/lib/models/user/user_model.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class UserModel {
final String uid;
final String id;
final String username;
final String password;
final String email;
Expand All @@ -9,10 +9,13 @@ class UserModel {
final DateTime updatedDate;
final String serviceDiscription;
final String? bio;
final List<String>? followers;
final List<String>? following;
final List<dynamic>? followers;
final List<dynamic>? following;
final int? contact;
final String? referenceUrl;
final bool? isVerified;
final String? verifyCode;
final int? codeExpireTime;
UserModel({
required this.contact,
required this.referenceUrl,
Expand All @@ -25,17 +28,20 @@ class UserModel {
required this.serviceDiscription,

required this.profileUrl,
required this.uid,
required this.id,
required this.username,
required this.password,
required this.email,
required this.isCreator,
required this.isVerified,
required this.verifyCode,
required this.codeExpireTime,
});

// convert to json object
Map<String, dynamic> toJson() {
return {
"uid": uid,
"id": id,
"username": username,
"email": email,
"profileUrl": profileUrl,
Expand All @@ -49,27 +55,33 @@ class UserModel {
"referenceUrl": referenceUrl,
"followers": followers,
"following": following,
"isVerified": isVerified,
"verifyCode": verifyCode,
"codeExpireTime": codeExpireTime,
};
}

//convert from json object
factory UserModel.fromJson(Map<String, dynamic> json) {
return UserModel(
uid: json["uid"],
id: json["_id"],
username: json["username"],
serviceDiscription: json["serviceDiscription"] ?? "",
email: json["email"],
password: json["password"],
joinedDate: json["joinedDate"],
updatedDate: json["updatedDate"],
profileUrl: json["image"] ?? "",
joinedDate: DateTime.parse(json["createdAt"]),
updatedDate: DateTime.parse(json["updatedAt"]),
profileUrl: json["profileUrl"] ?? "",
followers: json["followers"] ?? [],
following: json["followings"] ?? [],

bio: json["bio"] ?? "",
contact: json["contact"] ?? "",
contact: json["contact"] ?? 0,
isCreator: json["isCreator"],
referenceUrl: json["referenceUrl"] ?? "",
isVerified: json["isVerified"],
verifyCode: json["verifyCode"] ?? "",
codeExpireTime: json["codeExpireTime"] ?? 0,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,25 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:pinput/pinput.dart';
import 'package:undomain/pages/restart/restart.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 +30,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 +59,47 @@ 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);
RestartWidget.restartApp(context);
} 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 +108,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 +142,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 +159,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
Loading