fixed issues

fatima
Fatimah Alshammari 4 years ago
parent 7921ffe26d
commit 47f10738d7

@ -41,5 +41,11 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSCameraUsageDescription</key>
<string>Access to take a photo by camera</string>
<key>NSAppleMusicUsageDescription</key>
<string>Access to pick a photo</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Access to pick a photo</string>
</dict>
</plist>

@ -107,4 +107,13 @@ class UserApiClent {
//return await ApiClient().postJsonForObject((json) => ConfirmPassword.fromJson(json), ApiConsts.ForgetPassword, postParams);
}
Future<Response> ChangePassword(String currentPasswor, String newPassword) async {
var postParams = {
"currentPasswor": currentPasswor,
"newPassword": newPassword,
};
return await ApiClient().postJsonForResponse(ApiConsts.ChangePassword, postParams);
}
}

@ -18,8 +18,9 @@ class ApiConsts {
static String ForgetPasswordOTPRequest = baseUrlServices + "api/Account/ForgetPasswordOTPRequest";
static String ForgetPasswordOTPCompare = baseUrlServices + "api/Account/ForgetPasswordOTPCompare";
static String ForgetPassword = baseUrlServices + "api/Account/ForgetPassword";
static String Login_Email_OTP = baseUrlServices + "api/Account/EmailVerify";
static String Login_Email_OTPVerify = baseUrlServices + "api/Account/EmailVerifyOTPVerify";
static String ChangePassword = baseUrlServices + "api/Account/ChangePassword";
//Profile
static String GetProviderDocument = baseUrlServices + "api/ServiceProviders/ServiceProviderDocument_Get";
static String ServiceProviderDocument_Update = baseUrlServices + "api/ServiceProviders/ServiceProviderDocument_Update";

@ -4,6 +4,7 @@ import 'package:car_provider_app/pages/settings/create_services_page.dart';
import 'package:car_provider_app/pages/settings/dealership_page.dart';
import 'package:car_provider_app/pages/settings/define_branch_page.dart';
import 'package:car_provider_app/pages/settings/define_license_page.dart';
import 'package:car_provider_app/pages/user/change_password_page.dart';
import 'package:car_provider_app/pages/user/complete_profile_page.dart';
import 'package:car_provider_app/pages/user/confirm_new_password_page.dart';
import 'package:car_provider_app/pages/user/forget_password_page.dart';
@ -37,6 +38,7 @@ class AppRoutes {
static final String vertifyPassword = "/vertifyPassword";
static final String confirmNewPasswordPage = "/confirmNewPasswordPage";
static final String defineLicense = "/defineLicese";
static final String changePassword = "/changePassword";
static final String dashboard = "/dashboard";
@ -64,7 +66,7 @@ class AppRoutes {
defineLicense: (context) => DefineLicensePage(),
vertifyPassword: (context) => VerifyPasswordPage(),
confirmNewPasswordPage: (context) => ConfirmNewPasswordPage(ModalRoute.of(context)!.settings.arguments as String),
changePassword: (context) => ChangePasswordPage(ModalRoute.of(context)!.settings.arguments as String),
//Home page
dashboard: (context) => DashboardPage(),

@ -76,6 +76,10 @@ extension EmailValidator on String {
return RegExp(r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$').hasMatch(this);
}
bool isNum() {
return RegExp(r'[0-9]').hasMatch(this);
}
String toFormattedDate() {
String date = this.split("T")[0];
String time = this.split("T")[1];

@ -0,0 +1,34 @@
import 'dart:convert';
ChangePassword confirmPasswordFromJson(String str) => ChangePassword.fromJson(json.decode(str));
String changePasswordToJson(ChangePassword data) => json.encode(data.toJson());
class ChangePassword {
int? messageStatus;
Null? totalItemsCount;
bool? data;
String? message;
ChangePassword(
{this.messageStatus, this.totalItemsCount, this.data, this.message});
ChangePassword.fromJson(Map<String, dynamic> json) {
messageStatus = json['messageStatus'];
totalItemsCount = json['totalItemsCount'];
data = json['data'];
message = json['message'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['messageStatus'] = this.messageStatus;
data['totalItemsCount'] = this.totalItemsCount;
data['data'] = this.data;
data['message'] = this.message;
return data;
}
}

@ -9,15 +9,29 @@ import 'package:car_provider_app/extensions/string_extensions.dart';
import 'package:car_provider_app/extensions/widget_extensions.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:image_picker/image_picker.dart';
import 'dart:io';
class DashboardPage extends StatefulWidget {
@override
State<DashboardPage> createState() => _DashboardPageState();
}
enum ImageSourceType { gallery, camera }
class _DashboardPageState extends State<DashboardPage> {
String userName = "";
// void _handleURLButtonPress(BuildContext context, var type) {
// Navigator.push(context,
// MaterialPageRoute(builder: (context) => ImageFromGalleryEx(type)));
// }
File? imagePicked;
final _picker = ImagePicker();
@override
void initState() {
// TODO: implement initState
@ -38,10 +52,12 @@ class _DashboardPageState extends State<DashboardPage> {
),
drawer: showDrawer(context),
body: Container(
child: Container(
child: Center(
child: "Dashboard/Main Page".toText24(),
),
),
),
);
}
@ -49,6 +65,8 @@ class _DashboardPageState extends State<DashboardPage> {
return Drawer(
child: Container(
child: Column(
children: [
Stack(
children:[
Container(
width: double.infinity,
@ -60,6 +78,40 @@ class _DashboardPageState extends State<DashboardPage> {
color: accentColor.withOpacity(0.3),
),
),
Positioned(
top: 10,
right: 10,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.circular(30),
),
child: Icon(Icons.edit,
color: Colors.blue,).onPress(() {
_openImagePicker();
// _handleURLButtonPress(context, ImageSourceType.camera);
}),
),
],
),
)
] ),
// Container(
// width: double.infinity,
// height: 200,
// color: accentColor.withOpacity(0.3),
// child: Icon(
// Icons.person,
// size: 80,
// color: accentColor.withOpacity(0.3),
// ),
// ),
Container(
width: double.infinity,
color: accentColor.withOpacity(0.1),
@ -108,6 +160,9 @@ class _DashboardPageState extends State<DashboardPage> {
ListTile(
leading: SvgPicture.asset("assets/images/ic_lock.svg"),
title: "Change Password".toText12(),
onTap: (){
navigateWithName(context, AppRoutes.changePassword);
},
),
ListTile(
leading: SvgPicture.asset("assets/images/ic_mobile.svg"),
@ -126,4 +181,67 @@ class _DashboardPageState extends State<DashboardPage> {
),
);
}
// Implementing the image picker
// Future<void> _openImagePicker() async {
// final XFile? pickedImage =
// await _picker.pickImage(source: ImageSource.gallery);
// if (pickedImage != null) {
// setState(() {
// // _image = File(pickedImage.path);
// });
// }
// }
void _openImagePicker() {
showDialog<ImageSource>(
context: context,
builder: (context) => AlertDialog(
content: Text("Choose image source"),
actions: [
FlatButton(
child: Text("Camera"),
onPressed: () =>
cameraImage()
),
FlatButton(
child: Text("Gallery"),
onPressed: () => gallaryImage()
),
]
),
// .then((ImageSource source) async {
// if (source != null) {
// final pickedFile = await ImagePicker().getImage(source: source);
// setState(() => imagePicked = File(pickedFile.path));
// }
// }
);
}
void gallaryImage() async {
final picker = ImagePicker();
final pickedImage = await picker.pickImage(
source: ImageSource.gallery,
);
final pickedImageFile = File(pickedImage!.path);
setState(() {
imagePicked = pickedImageFile;
});
}
void cameraImage() async {
final picker = ImagePicker();
final pickedImage = await picker.pickImage(
source: ImageSource.camera,
);
final pickedImageFile = File(pickedImage!.path);
setState(() {
imagePicked = pickedImageFile;
});
}
}

@ -0,0 +1,111 @@
import 'package:car_provider_app/api/client/user_api_client.dart';
import 'package:car_provider_app/classes/utils.dart';
import 'package:car_provider_app/config/routes.dart';
import 'package:car_provider_app/models/user/change_password.dart';
import 'package:car_provider_app/models/user/confirm_password.dart';
import 'package:car_provider_app/utils/navigator.dart';
import 'package:car_provider_app/utils/utils.dart';
import 'package:car_provider_app/widgets/app_bar.dart';
import 'package:car_provider_app/widgets/dialog/dialogs.dart';
import 'package:car_provider_app/widgets/dialog/message_dialog.dart';
import 'package:car_provider_app/widgets/show_fill_button.dart';
import 'package:car_provider_app/extensions/string_extensions.dart';
import 'package:car_provider_app/extensions/int_extensions.dart';
import 'package:car_provider_app/widgets/txt_field.dart';
import 'package:flutter/material.dart';
import 'dart:convert';
import 'package:http/http.dart';
class ChangePasswordPage extends StatefulWidget {
String userToken;
ChangePasswordPage(this.userToken, {Key? key}) : super(key: key);
@override
State<ChangePasswordPage> createState() => _ChangePasswordPageState();
}
class _ChangePasswordPageState extends State<ChangePasswordPage> {
String newPassword = "";
String currentPasswor = '';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: appBar(title: "Change Password"),
body: SingleChildScrollView(
child: Container(
// width: double.infinity,
// height: double.infinity,
padding: EdgeInsets.all(40),
child: Column(
children: [
"Inter New Phone Number".toText24(),
12.height,
TextFormField(
decoration: InputDecoration(
hintText: "Enter Old Password",
hintStyle: TextStyle(color: Colors.grey),
border: OutlineInputBorder(
borderRadius: const BorderRadius.all(
const Radius.circular(5.0),
),
),
),
obscureText: true,
onChanged: (v) => currentPasswor = v,
),
12.height,
TextFormField(
decoration: InputDecoration(
hintText: "Inter New Password",
hintStyle: TextStyle(color: Colors.grey),
border: OutlineInputBorder(
borderRadius: const BorderRadius.all(
const Radius.circular(5.0),
),
),
),
obscureText: true,
onChanged: (v) => newPassword = v,
),
40.height,
ShowFillButton(
title: "Confirm",
width: double.infinity,
onPressed: () {changePassword(context);
},
),
],
),
),
),
);
}
Future<void> changePassword(BuildContext context) async {
if(validateStructure(newPassword??"")){
Utils.showLoading(context);
Response res = await UserApiClent().ChangePassword(currentPasswor, newPassword);
Utils.hideLoading(context);
ChangePassword data = ChangePassword.fromJson(jsonDecode(res.body));
if (data.messageStatus == 1) {
Utils.showToast("Password is Updated");
navigateWithName(context, AppRoutes.loginWithPassword);
} else {
Utils.showToast(data.message ?? "");
}
}else{
Utils.showToast("Password Should contains Character, Number, Capital and small letters");
}
}
bool validateStructure(String value){
String pattern = r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{6,}$';
RegExp regExp = new RegExp(pattern);
return regExp.hasMatch(value);
}
}

@ -27,7 +27,7 @@ class CompleteProfilePage extends StatefulWidget {
class _CompleteProfilePageState extends State<CompleteProfilePage> {
String? firstName = "", lastName = "", email = "", password = "", confirmPassword = "";
bool isChecked = false;
@override
void initState() {
// TODO: implement initState
@ -51,6 +51,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
TxtField(
hint: "First Name",
value: firstName,
onChanged: (v) {
firstName = v;
},
@ -58,6 +59,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
12.height,
TxtField(
hint: "Surname",
value: lastName,
onChanged: (v) {
lastName = v;
},
@ -65,6 +67,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
12.height,
TxtField(
hint: "Email",
value: email,
onChanged: (v) {
email = v;
},
@ -74,6 +77,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
hint: "Create Password",
isPasswordEnabled: true,
maxLines: 1,
value: password,
onChanged: (v) {
password = v;
},
@ -83,6 +87,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
hint: "Confirm Password",
isPasswordEnabled: true,
maxLines: 1,
value: confirmPassword,
onChanged: (v) {
confirmPassword = v;
},
@ -92,13 +97,18 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
// hint: "Phone Number",
// ),
50.height,
"By creating an account you agree to our Terms of Service and Privacy Policy".toText12(),
Row(
children: [
buildCheckbox(),
"By creating an account you agree to our Terms of Service and\n Privacy Policy".toText12(),
],
),
16.height,
ShowFillButton(
title: "Continue",
width: double.infinity,
onPressed: () {
performCompleteProfile();
if(validation()) performCompleteProfile();
},
),
],
@ -107,7 +117,41 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
),
),
);
}
Widget buildCheckbox() => Checkbox(
value: isChecked,
activeColor: Colors.blue,
onChanged: (value){
setState(() {
isChecked = value!;
});
},
);
// Future<void> performCompleteProfile() async {
// if(validateStructure(password??"")){
// if (password == confirmPassword) {
// print(widget.user.data!.userId??"userId");
// Utils.showLoading(context);
// RegisterUser user = await UserApiClent().basicComplete(widget.user.data?.userId ?? "", firstName!, lastName!, email!, password!);
// Utils.hideLoading(context);
// if (user.messageStatus == 1) {
// Utils.showToast( "Successfully registered, Please login once");
// pop(context);
// // pop(context);
// // navigateReplaceWithName(context, AppRoutes.dashboard,arguments: user);
// } else {
// Utils.showToast(user.message ?? "");
// }
// } else {
// Utils.showToast("Please enter same password");
// }
// }else{
// Utils.showToast("Password Should contains character, Number, Capital and small letters");
// }
//
// }
Future<void> performCompleteProfile() async {
if (validateStructure(password ?? "")) {
@ -117,9 +161,8 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
RegisterUser user = await UserApiClent().basicComplete(widget.user.data?.userId ?? "", firstName!, lastName!, email!, password!);
Utils.hideLoading(context);
if (user.messageStatus == 1) {
Utils.showToast( "Successfully registered, Please login once");
Utils.showToast("Successfully Registered, Please login once");
pop(context);
// pop(context);
// navigateReplaceWithName(context, AppRoutes.dashboard,arguments: user);
} else {
Utils.showToast(user.message ?? "");
@ -128,9 +171,8 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
Utils.showToast("Please enter same password");
}
} else {
Utils.showToast("Password Should contains character, Number, Capital and small letters");
Utils.showToast("Password Should contains Character, Number, Capital and small letters");
}
}
bool validateStructure(String value){
@ -138,4 +180,22 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
RegExp regExp = new RegExp(pattern);
return regExp.hasMatch(value);
}
bool validation() {
bool isValid = true;
if (firstName!.isEmpty) {
Utils.showToast("First name is mandatory");
isValid = false;
} else if (lastName!.isEmpty) {
Utils.showToast("Surname is mandatory");
isValid = false;
} else if (password!.isEmpty) {
Utils.showToast("Password is mandatory");
isValid = false;
}else if (!isChecked) {
Utils.showToast("Please accept terms");
isValid = false;
}
return isValid;
}
}

@ -86,6 +86,7 @@ class _ConfirmNewPasswordPageState extends State<ConfirmNewPasswordPage> {
}
Future<void> confirmPasswordOTP(BuildContext context) async {
if(validateStructure(newPassword??"")){
Utils.showLoading(context);
Response res = await UserApiClent().ForgetPassword(widget.userToken, newPassword);
Utils.hideLoading(context);
@ -96,6 +97,9 @@ class _ConfirmNewPasswordPageState extends State<ConfirmNewPasswordPage> {
} else {
Utils.showToast(data.message ?? "");
}
}else{
Utils.showToast("Password Should contains Character, Number, Capital and small letters");
}
}
bool validation() {
@ -106,4 +110,10 @@ class _ConfirmNewPasswordPageState extends State<ConfirmNewPasswordPage> {
}
return isValid;
}
bool validateStructure(String value){
String pattern = r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{6,}$';
RegExp regExp = new RegExp(pattern);
return regExp.hasMatch(value);
}
}

@ -26,6 +26,7 @@ import 'package:http/http.dart';
class LoginWithPassword extends StatelessWidget {
int otpType = 1;
String phoneNum = "", password = "";
String email = "";
@override
Widget build(BuildContext context) {
@ -37,10 +38,10 @@ class LoginWithPassword extends StatelessWidget {
padding: EdgeInsets.all(40),
child: Column(
children: [
"Login".toText24(),
"Enter Mobile or Email".toText24(),
mFlex(1),
TxtField(
hint: "966501234567",
hint: "Enter phone number or email",
value: phoneNum,
onChanged: (v) {
phoneNum = v;
@ -48,7 +49,7 @@ class LoginWithPassword extends StatelessWidget {
),
12.height,
TxtField(
hint: "Password",
hint: "Enter Password",
value: password,
isPasswordEnabled: true,
maxLines: 1,
@ -67,7 +68,7 @@ class LoginWithPassword extends StatelessWidget {
),
50.height,
ShowFillButton(
title: "Continue",
title: "Log In",
width: double.infinity,
onPressed: () {
performBasicOtp(context);
@ -93,4 +94,10 @@ class LoginWithPassword extends StatelessWidget {
Utils.showToast(user.message ?? "");
}
}
Future<void> performBasicOtpEmail(BuildContext context) async {
}
}

@ -50,6 +50,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
cross_file:
dependency: transitive
description:
name: cross_file
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.2"
crypto:
dependency: transitive
description:
@ -238,6 +245,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
image_picker:
dependency: "direct main"
description:
name: image_picker
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.4+11"
image_picker_for_web:
dependency: transitive
description:
name: image_picker_for_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.6"
image_picker_platform_interface:
dependency: transitive
description:
name: image_picker_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.4"
injector:
dependency: "direct main"
description:

@ -47,10 +47,12 @@ dependencies:
file_picker: ^4.4.0
# google
google_maps_flutter: ^2.1.1
geolocator: any
geocoding: ^2.0.2
image_picker: ^0.8.4+4

Loading…
Cancel
Save