CMA 246, 247

aamir_dev
Aamir 1 year ago
parent 7ab3caa364
commit cef48cb1cb

@ -706,5 +706,9 @@
"customerLocation": "موقع العميل", "customerLocation": "موقع العميل",
"deliveryAvailable": "التوصيل متاح", "deliveryAvailable": "التوصيل متاح",
"viewed": "تم المشاهدة", "viewed": "تم المشاهدة",
"itemNoLongerAvailable": "لم يعد هذا العنصر متاحًا." "itemNoLongerAvailable": "لم يعد هذا العنصر متاحًا.",
"updateUserDetails": "تحديث تفاصيل المستخدم",
"enterNewFirstName": "أدخل الاسم الأول",
"enterNewLastName": "أدخل الاسم الأخير",
"userDetailsUpdated": "يتم تحديث تفاصيل المستخدم"
} }

@ -703,6 +703,10 @@
"customerLocation": "Customer Location", "customerLocation": "Customer Location",
"deliveryAvailable": "Delivery Available", "deliveryAvailable": "Delivery Available",
"viewed": "Viewed", "viewed": "Viewed",
"itemNoLongerAvailable": "This item is no longer available." "itemNoLongerAvailable": "This item is no longer available.",
"updateUserDetails": "Update User Details",
"enterNewFirstName": "Enter First Name",
"enterNewLastName": "Enter Last Name",
"userDetailsUpdated": "User Details is Updated"
} }

@ -37,6 +37,7 @@ class ApiConsts {
static String LogoutUser = "${baseUrlServices}api/Account/Logout"; static String LogoutUser = "${baseUrlServices}api/Account/Logout";
static String UpdateUserImage = "${baseUrlServices}api/User_UpdateProfileImage"; static String UpdateUserImage = "${baseUrlServices}api/User_UpdateProfileImage";
static String GetUserImage = "${baseUrlServices}api/ProfileImage"; static String GetUserImage = "${baseUrlServices}api/ProfileImage";
static String userUpdate = "${baseUrlServices}api/User_Update";
//Profile //Profile
static String fetProviderDocument = "${baseUrlServices}api/ServiceProviders/ServiceProviderDocument_Get"; static String fetProviderDocument = "${baseUrlServices}api/ServiceProviders/ServiceProviderDocument_Get";

@ -43,6 +43,7 @@ import 'package:mc_common_app/views/user/register_page.dart';
import 'package:mc_common_app/views/user/register_provider_page.dart'; import 'package:mc_common_app/views/user/register_provider_page.dart';
import 'package:mc_common_app/views/user/register_selection_page.dart'; import 'package:mc_common_app/views/user/register_selection_page.dart';
import 'package:mc_common_app/views/splash/splash_page.dart'; import 'package:mc_common_app/views/splash/splash_page.dart';
import 'package:mc_common_app/views/user/update_user_details.dart';
import 'package:mc_common_app/views/user/vertify_password_page.dart'; import 'package:mc_common_app/views/user/vertify_password_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mc_common_app/widgets/image_viewer/image_viewer_screen.dart'; import 'package:mc_common_app/widgets/image_viewer/image_viewer_screen.dart';
@ -166,6 +167,7 @@ class AppRoutes {
//Chat //Chat
static const String chatView = "/chatView"; static const String chatView = "/chatView";
static const String updateUserDetails = "/updateUserDetails";
static const String initialRoute = splash; static const String initialRoute = splash;
static final Map<String, WidgetBuilder> routes = { static final Map<String, WidgetBuilder> routes = {
@ -185,6 +187,7 @@ class AppRoutes {
forgetPasswordMethodPage: (context) => ForgetPasswordMethodPage(ModalRoute.of(context)!.settings.arguments as String), forgetPasswordMethodPage: (context) => ForgetPasswordMethodPage(ModalRoute.of(context)!.settings.arguments as String),
changeMobilePage: (context) => ChangeMobilePage(), changeMobilePage: (context) => ChangeMobilePage(),
changeEmailPage: (context) => const ChangeEmailPage(), changeEmailPage: (context) => const ChangeEmailPage(),
updateUserDetails: (context) => const UpdateUserDetails(),
changePassword: (context) => const ChangePasswordPage(), changePassword: (context) => const ChangePasswordPage(),
editAccountPage: (context) => const EditAccountPage(), editAccountPage: (context) => const EditAccountPage(),
profileView: (context) => const ProfileScreen(), profileView: (context) => const ProfileScreen(),

@ -722,7 +722,11 @@ class CodegenLoader extends AssetLoader{
"customerLocation": "موقع العميل", "customerLocation": "موقع العميل",
"deliveryAvailable": "التوصيل متاح", "deliveryAvailable": "التوصيل متاح",
"viewed": "تم المشاهدة", "viewed": "تم المشاهدة",
"itemNoLongerAvailable": "لم يعد هذا العنصر متاحًا." "itemNoLongerAvailable": "لم يعد هذا العنصر متاحًا.",
"updateUserDetails": "تحديث تفاصيل المستخدم",
"enterNewFirstName": "أدخل الاسم الأول",
"enterNewLastName": "أدخل الاسم الأخير",
"userDetailsUpdated": "يتم تحديث تفاصيل المستخدم"
}; };
static const Map<String,dynamic> en_US = { static const Map<String,dynamic> en_US = {
"firstTimeLogIn": "First Time Log In", "firstTimeLogIn": "First Time Log In",
@ -1429,7 +1433,11 @@ static const Map<String,dynamic> en_US = {
"customerLocation": "Customer Location", "customerLocation": "Customer Location",
"deliveryAvailable": "Delivery Available", "deliveryAvailable": "Delivery Available",
"viewed": "Viewed", "viewed": "Viewed",
"itemNoLongerAvailable": "This item is no longer available." "itemNoLongerAvailable": "This item is no longer available.",
"updateUserDetails": "Update User Details",
"enterNewFirstName": "Enter First Name",
"enterNewLastName": "Enter Last Name",
"userDetailsUpdated": "User Details is Updated"
}; };
static const Map<String, Map<String,dynamic>> mapLocales = {"ar_SA": ar_SA, "en_US": en_US}; static const Map<String, Map<String,dynamic>> mapLocales = {"ar_SA": ar_SA, "en_US": en_US};
} }

@ -686,5 +686,9 @@ abstract class LocaleKeys {
static const deliveryAvailable = 'deliveryAvailable'; static const deliveryAvailable = 'deliveryAvailable';
static const viewed = 'viewed'; static const viewed = 'viewed';
static const itemNoLongerAvailable = 'itemNoLongerAvailable'; static const itemNoLongerAvailable = 'itemNoLongerAvailable';
static const updateUserDetails = 'updateUserDetails';
static const enterNewFirstName = 'enterNewFirstName';
static const enterNewLastName = 'enterNewLastName';
static const userDetailsUpdated = 'userDetailsUpdated';
} }

@ -55,7 +55,7 @@ abstract class UserRepo {
Future<GenericRespModel> changePassword(String currentPassword, String newPassword); Future<GenericRespModel> changePassword(String currentPassword, String newPassword);
//Future<GenericRespModel> updateUserInfo(String firstName, String lastName); Future<Map<String, dynamic>> updateUserInfo(String firstName, String lastName);
Future<ChangeMobileRespModel> changeMobileNoOTPRequest(countryID, String mobileNo, String password); Future<ChangeMobileRespModel> changeMobileNoOTPRequest(countryID, String mobileNo, String password);
@ -256,12 +256,12 @@ class UserRepoImp implements UserRepo {
return await injector.get<ApiClient>().postJsonForObject((json) => ConfirmEmailRespModel.fromJson(json), ApiConsts.ChangeEmail, postParams, token: t); return await injector.get<ApiClient>().postJsonForObject((json) => ConfirmEmailRespModel.fromJson(json), ApiConsts.ChangeEmail, postParams, token: t);
} }
// @override @override
// Future<GenericRespModel> updateUserInfo(String firstName, String lastName) async { Future<Map<String, dynamic>> updateUserInfo(String firstName, String lastName) async {
// var postParams = {"userID": "${AppState().getUser.data!.userInfo!.id}", "firstName": "${firstName}", "lastName": "${lastName}", "genderID": 0, "cityID": 0}; var postParams = {"userID": "${AppState().getUser.data!.userInfo!.userId}", "firstName": "${firstName}", "lastName": "${lastName}", "genderID": 1, "cityID": 1};
// String t = AppState().getUser.data!.accessToken ?? ""; String t = AppState().getUser.data!.accessToken ?? "";
// return await injector.get<ApiClient>().postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.update, postParams, token: t); return await injector.get<ApiClient>().postJsonForObject((json) => json, ApiConsts.userUpdate, postParams, token: t);
// } }
@override @override
Future<VerifyEmailRespModel> emailVerify(String email, String userID) async { Future<VerifyEmailRespModel> emailVerify(String email, String userID) async {

@ -164,21 +164,26 @@ class UserVM extends BaseVM {
} }
} }
// Future<void> userDetailsUpdate(BuildContext context, String firstName, String lastName) async { Future<void> userDetailsUpdate(BuildContext context, String firstName, String lastName) async {
// Utils.showLoading(context); Utils.showLoading(context);
// GenericRespModel res = await userRepo.changePassword(currentPassword, newPassword); Map<String, dynamic> res = await userRepo.updateUserInfo(firstName, lastName);
// Utils.hideLoading(context); Utils.hideLoading(context);
// if (res.messageStatus == 1) { if (res["data"] != null && res["data"].isNotEmpty) {
// Utils.showToast(LocaleKeys.passwordIsUpdated.tr()); User localUser = AppState().getUser;
// if (localUser.data != null) {
// Navigator.of(context).pushNamedAndRemoveUntil(AppRoutes.profileView, (Route<dynamic> route) => true); localUser.data!.userInfo!.firstName = res["data"]["firstName"];
// } else { localUser.data!.userInfo!.lastName = res["data"]["lastName"];
// Utils.showToast(res.message ?? ""); AppState().setUser = localUser;
// } }
// } Utils.showToast(LocaleKeys.userDetailsUpdated.tr());
pop(context);
Future<void> performCompleteProfile( } else {
BuildContext context, { Utils.showToast(res.toString() ?? "");
}
notifyListeners();
}
Future<void> performCompleteProfile(BuildContext context, {
required String password, required String password,
required String confirmPassword, required String confirmPassword,
required String firstName, required String firstName,
@ -190,14 +195,7 @@ class UserVM extends BaseVM {
if (Utils.passwordValidateStructure(password)) { if (Utils.passwordValidateStructure(password)) {
if (password == confirmPassword) { if (password == confirmPassword) {
Utils.showLoading(context); Utils.showLoading(context);
RegisterUserRespModel user = await userRepo.basicComplete( RegisterUserRespModel user = await userRepo.basicComplete(userId ?? "", firstName, lastName, email, password, isNeedToPassToken: isNeedToPassToken);
userId ?? "",
firstName,
lastName,
email,
password,
isNeedToPassToken: isNeedToPassToken,
);
Utils.hideLoading(context); Utils.hideLoading(context);
if (user.messageStatus == 1) { if (user.messageStatus == 1) {
Utils.showToast(LocaleKeys.successfullyRegistered.tr()); Utils.showToast(LocaleKeys.successfullyRegistered.tr());
@ -551,8 +549,8 @@ class UserVM extends BaseVM {
type == ClassType.NUMBER && countryCode != null type == ClassType.NUMBER && countryCode != null
? countryCode + phoneNum ? countryCode + phoneNum
: type == ClassType.NUMBER && countryCode == null : type == ClassType.NUMBER && countryCode == null
? phoneNum ? phoneNum
: phoneNum, : phoneNum,
password); password);
Utils.hideLoading(context); Utils.hideLoading(context);
LoginPasswordRespModel user = LoginPasswordRespModel.fromJson(jsonDecode(response.body)); LoginPasswordRespModel user = LoginPasswordRespModel.fromJson(jsonDecode(response.body));
@ -560,8 +558,8 @@ class UserVM extends BaseVM {
SharedPrefManager.setPhoneOrEmail(type == ClassType.NUMBER && countryCode != null SharedPrefManager.setPhoneOrEmail(type == ClassType.NUMBER && countryCode != null
? countryCode + phoneNum ? countryCode + phoneNum
: type == ClassType.NUMBER && countryCode == null : type == ClassType.NUMBER && countryCode == null
? phoneNum ? phoneNum
: phoneNum); : phoneNum);
SharedPrefManager.setUserPassword(password); SharedPrefManager.setUserPassword(password);
navigateReplaceWithName(context, AppRoutes.loginMethodSelection, arguments: user.data!.userToken); navigateReplaceWithName(context, AppRoutes.loginMethodSelection, arguments: user.data!.userToken);
} else { } else {
@ -675,8 +673,13 @@ class UserVM extends BaseVM {
} }
void changeLanguage(BuildContext context) { void changeLanguage(BuildContext context) {
print("${EasyLocalization.of(context)?.currentLocale}"); print("${EasyLocalization
if (EasyLocalization.of(context)?.currentLocale?.countryCode == "SA") { .of(context)
?.currentLocale}");
if (EasyLocalization
.of(context)
?.currentLocale
?.countryCode == "SA") {
context.setLocale(const Locale("en", "US")); context.setLocale(const Locale("en", "US"));
} else { } else {
context.setLocale(const Locale('ar', 'SA')); context.setLocale(const Locale('ar', 'SA'));
@ -699,8 +702,13 @@ class UserVM extends BaseVM {
AppState().setUser = null; AppState().setUser = null;
if (AppState().currentAppType == AppType.provider) { if (AppState().currentAppType == AppType.provider) {
AppState().setproviderSubscription = null; AppState().setproviderSubscription = null;
context.read<SubscriptionsVM>().mySubscriptionsBySp.clear(); context
context.read<SubscriptionsVM>().allSubscriptions = SubscriptionModel(); .read<SubscriptionsVM>()
.mySubscriptionsBySp
.clear();
context
.read<SubscriptionsVM>()
.allSubscriptions = SubscriptionModel();
} }
navigateReplaceWithNameUntilRoute(context, AppRoutes.registerSelection); navigateReplaceWithNameUntilRoute(context, AppRoutes.registerSelection);

@ -72,21 +72,21 @@ class _ProfileScreenState extends State<ProfileScreen> {
decoration: BoxDecoration( decoration: BoxDecoration(
image: AppState().getUser.data!.userInfo!.userLocalImage != null image: AppState().getUser.data!.userInfo!.userLocalImage != null
? DecorationImage( ? DecorationImage(
image: FileImage(AppState().getUser.data!.userInfo!.userLocalImage!), image: FileImage(AppState().getUser.data!.userInfo!.userLocalImage!),
fit: BoxFit.cover, fit: BoxFit.cover,
) )
: AppState().getUser.data!.userInfo!.userImageUrl != null : AppState().getUser.data!.userInfo!.userImageUrl != null
? DecorationImage( ? DecorationImage(
image: CachedNetworkImageProvider( image: CachedNetworkImageProvider(
AppState().getUser.data!.userInfo!.userImageUrl, AppState().getUser.data!.userInfo!.userImageUrl,
), ),
fit: BoxFit.cover, fit: BoxFit.cover,
) )
: DecorationImage( : DecorationImage(
image: AssetImage( image: AssetImage(
MyAssets.icLogoWhitePng, MyAssets.icLogoWhitePng,
), ),
), ),
), ),
child: BackdropFilter( child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 7.0, sigmaY: 7.0), filter: ImageFilter.blur(sigmaX: 7.0, sigmaY: 7.0),
@ -107,24 +107,16 @@ class _ProfileScreenState extends State<ProfileScreen> {
60.height, 60.height,
Row( Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
"${AppState().getUser.data!.userInfo!.firstName} ${AppState().getUser.data!.userInfo!.lastName ?? ""}".toText(fontSize: 20).paddingOnly(left: 25), "${AppState().getUser.data!.userInfo!.firstName} ${AppState().getUser.data!.userInfo!.lastName ?? ""}".toText(fontSize: 20).paddingOnly(left: 25, right: 10),
Container( MyAssets.icEdit.buildSvg(width: 15).onPress(
height: 40, () async {
width: 40, Navigator.pushNamed(context, AppRoutes.updateUserDetails);
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(color: MyColors.white, shape: BoxShape.circle, border: Border.all(color: MyColors.darkTextColor, width: 0.1)),
child: MyAssets.icEdit.buildSvg(),
).onPress(
() async {
await model.updateUserImage(context);
}, },
), ),
], ],
).margin(left: 0, top: 0, right: 24, bottom: 0).onPress(() { ).margin(left: 0, top: 0, right: 24, bottom: 0),
print("Change User Name Here");
}),
Column( Column(
children: [ children: [
if (AppState().currentAppType == AppType.provider && mySubscription != null) ...[ if (AppState().currentAppType == AppType.provider && mySubscription != null) ...[
@ -169,7 +161,11 @@ class _ProfileScreenState extends State<ProfileScreen> {
}, },
), ),
], ],
).toContainer(width: double.infinity, isShadowEnabled: true, paddingAll: 10, margin: const EdgeInsets.fromLTRB(24, 20, 24, 0), borderRadius: 0), ).toContainer(width: double.infinity,
isShadowEnabled: true,
paddingAll: 10,
margin: const EdgeInsets.fromLTRB(24, 20, 24, 0),
borderRadius: 0),
], ],
), ),
), ),
@ -177,67 +173,83 @@ class _ProfileScreenState extends State<ProfileScreen> {
], ],
), ),
Positioned( Positioned(
top: MediaQuery.of(context).size.height * 0.24, top: MediaQuery
.of(context)
.size
.height * 0.24,
child: Container( child: Container(
height: 100, height: 100,
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: ClipOval( child: ClipOval(
child: AppState().getUser.data!.userInfo!.userLocalImage != null child: AppState().getUser.data!.userInfo!.userLocalImage != null
? Image.file( ? Image.file(
AppState().getUser.data!.userInfo!.userLocalImage!, AppState().getUser.data!.userInfo!.userLocalImage!,
width: 100, width: 100,
height: 100, height: 100,
fit: BoxFit.fill, fit: BoxFit.fill,
) )
: CachedNetworkImage( : CachedNetworkImage(
imageUrl: "${AppState().getUser.data!.userInfo!.userImageUrl}", imageUrl: "${AppState().getUser.data!.userInfo!.userImageUrl}",
imageBuilder: (context, imageProvider) => Container( imageBuilder: (context, imageProvider) =>
decoration: BoxDecoration( Container(
image: DecorationImage( decoration: BoxDecoration(
image: imageProvider, image: DecorationImage(
fit: BoxFit.cover, image: imageProvider,
), fit: BoxFit.cover,
), ),
), ),
placeholder: (context, url) => const Center(child: CircularProgressIndicator()),
errorWidget: (context, url, error) => const Icon(Icons.error),
width: 100,
height: 100,
fit: BoxFit.fill,
fadeInCurve: Curves.easeIn,
fadeInDuration: const Duration(milliseconds: 1000),
useOldImageOnUrlChange: false,
), ),
placeholder: (context, url) => const Center(child: CircularProgressIndicator()),
errorWidget: (context, url, error) => const Icon(Icons.error),
width: 100,
height: 100,
fit: BoxFit.fill,
fadeInCurve: Curves.easeIn,
fadeInDuration: const Duration(milliseconds: 1000),
useOldImageOnUrlChange: false,
),
), ),
).horPaddingMain(), ).horPaddingMain(),
), ),
Positioned( Positioned(
top: MediaQuery.of(context).size.height * 0.30, top: MediaQuery
right: MediaQuery.of(context).size.height * 0.03, .of(context)
.size
.height * 0.30,
right: MediaQuery
.of(context)
.size
.height * 0.03,
child: Container( child: Container(
height: 40, height: 40,
width: 40, width: 40,
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
decoration: BoxDecoration(color: MyColors.white, shape: BoxShape.circle, border: Border.all(color: MyColors.darkTextColor, width: 0.1)), decoration: BoxDecoration(color: MyColors.white, shape: BoxShape.circle, border: Border.all(color: MyColors.darkTextColor, width: 0.1)),
child: MyAssets.icEdit.buildSvg(), child: Center(child: MyAssets.icEdit.buildSvg(),),
).onPress( ).onPress(
() async { () async {
await model.updateUserImage(context); await model.updateUserImage(context);
}, },
), ),
), ),
Positioned( Positioned(
top: MediaQuery.of(context).size.height * 0.05, top: MediaQuery
left: MediaQuery.of(context).size.height * 0.03, .of(context)
.size
.height * 0.05,
left: MediaQuery
.of(context)
.size
.height * 0.03,
child: const Icon(Icons.arrow_back_ios, color: Colors.black, size: 18) child: const Icon(Icons.arrow_back_ios, color: Colors.black, size: 18)
.toContainer( .toContainer(
padding: const EdgeInsets.only(left: 5), padding: const EdgeInsets.only(left: 5),
borderRadius: 100, borderRadius: 100,
borderColor: MyColors.lightGreyEFColor, borderColor: MyColors.lightGreyEFColor,
isEnabledBorder: true, isEnabledBorder: true,
height: 40, height: 40,
width: 40, width: 40,
) )
.onPress(() => pop(context))), .onPress(() => pop(context))),
], ],
); );

@ -0,0 +1,68 @@
import 'package:mc_common_app/extensions/int_extensions.dart';
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/generated/locale_keys.g.dart';
import 'package:mc_common_app/view_models/user_view_model.dart';
import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
import 'package:mc_common_app/widgets/button/show_fill_button.dart';
import 'package:mc_common_app/widgets/txt_field.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class UpdateUserDetails extends StatefulWidget {
const UpdateUserDetails({Key? key}) : super(key: key);
@override
State<UpdateUserDetails> createState() => _UpdateUserDetailsState();
}
class _UpdateUserDetailsState extends State<UpdateUserDetails> {
String firstname = "";
String lastname = "";
late UserVM userVM;
@override
void initState() {
userVM = Provider.of<UserVM>(context, listen: false);
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: CustomAppBar(
title: LocaleKeys.updateUserDetails.tr(),
),
body: SingleChildScrollView(
child: Container(
// width: double.infinity,
// height: double.infinity,
padding: const EdgeInsets.all(20),
child: Column(
children: [
TxtField(
hint: LocaleKeys.enterNewFirstName.tr(),
onChanged: (v) => firstname = v,
),
12.height,
TxtField(
hint: LocaleKeys.enterNewLastName.tr(),
onChanged: (v) => lastname = v,
),
40.height,
ShowFillButton(
title: LocaleKeys.confirm.tr(),
maxWidth: double.infinity,
onPressed: () async {
await userVM.userDetailsUpdate(context, firstname, lastname);
},
),
],
),
),
),
);
}
}
Loading…
Cancel
Save