CMA 246, 247

aamir_dev
Aamir 11 months ago
parent 7ab3caa364
commit cef48cb1cb

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

@ -703,6 +703,10 @@
"customerLocation": "Customer Location",
"deliveryAvailable": "Delivery Available",
"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 UpdateUserImage = "${baseUrlServices}api/User_UpdateProfileImage";
static String GetUserImage = "${baseUrlServices}api/ProfileImage";
static String userUpdate = "${baseUrlServices}api/User_Update";
//Profile
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_selection_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:flutter/material.dart';
import 'package:mc_common_app/widgets/image_viewer/image_viewer_screen.dart';
@ -166,6 +167,7 @@ class AppRoutes {
//Chat
static const String chatView = "/chatView";
static const String updateUserDetails = "/updateUserDetails";
static const String initialRoute = splash;
static final Map<String, WidgetBuilder> routes = {
@ -185,6 +187,7 @@ class AppRoutes {
forgetPasswordMethodPage: (context) => ForgetPasswordMethodPage(ModalRoute.of(context)!.settings.arguments as String),
changeMobilePage: (context) => ChangeMobilePage(),
changeEmailPage: (context) => const ChangeEmailPage(),
updateUserDetails: (context) => const UpdateUserDetails(),
changePassword: (context) => const ChangePasswordPage(),
editAccountPage: (context) => const EditAccountPage(),
profileView: (context) => const ProfileScreen(),

@ -722,7 +722,11 @@ class CodegenLoader extends AssetLoader{
"customerLocation": "موقع العميل",
"deliveryAvailable": "التوصيل متاح",
"viewed": "تم المشاهدة",
"itemNoLongerAvailable": "لم يعد هذا العنصر متاحًا."
"itemNoLongerAvailable": "لم يعد هذا العنصر متاحًا.",
"updateUserDetails": "تحديث تفاصيل المستخدم",
"enterNewFirstName": "أدخل الاسم الأول",
"enterNewLastName": "أدخل الاسم الأخير",
"userDetailsUpdated": "يتم تحديث تفاصيل المستخدم"
};
static const Map<String,dynamic> en_US = {
"firstTimeLogIn": "First Time Log In",
@ -1429,7 +1433,11 @@ static const Map<String,dynamic> en_US = {
"customerLocation": "Customer Location",
"deliveryAvailable": "Delivery Available",
"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};
}

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

@ -72,21 +72,21 @@ class _ProfileScreenState extends State<ProfileScreen> {
decoration: BoxDecoration(
image: AppState().getUser.data!.userInfo!.userLocalImage != null
? DecorationImage(
image: FileImage(AppState().getUser.data!.userInfo!.userLocalImage!),
fit: BoxFit.cover,
)
image: FileImage(AppState().getUser.data!.userInfo!.userLocalImage!),
fit: BoxFit.cover,
)
: AppState().getUser.data!.userInfo!.userImageUrl != null
? DecorationImage(
image: CachedNetworkImageProvider(
AppState().getUser.data!.userInfo!.userImageUrl,
),
fit: BoxFit.cover,
)
: DecorationImage(
image: AssetImage(
MyAssets.icLogoWhitePng,
),
),
? DecorationImage(
image: CachedNetworkImageProvider(
AppState().getUser.data!.userInfo!.userImageUrl,
),
fit: BoxFit.cover,
)
: DecorationImage(
image: AssetImage(
MyAssets.icLogoWhitePng,
),
),
),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 7.0, sigmaY: 7.0),
@ -107,24 +107,16 @@ class _ProfileScreenState extends State<ProfileScreen> {
60.height,
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisAlignment: MainAxisAlignment.start,
children: [
"${AppState().getUser.data!.userInfo!.firstName} ${AppState().getUser.data!.userInfo!.lastName ?? ""}".toText(fontSize: 20).paddingOnly(left: 25),
Container(
height: 40,
width: 40,
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);
"${AppState().getUser.data!.userInfo!.firstName} ${AppState().getUser.data!.userInfo!.lastName ?? ""}".toText(fontSize: 20).paddingOnly(left: 25, right: 10),
MyAssets.icEdit.buildSvg(width: 15).onPress(
() async {
Navigator.pushNamed(context, AppRoutes.updateUserDetails);
},
),
],
).margin(left: 0, top: 0, right: 24, bottom: 0).onPress(() {
print("Change User Name Here");
}),
).margin(left: 0, top: 0, right: 24, bottom: 0),
Column(
children: [
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(
top: MediaQuery.of(context).size.height * 0.24,
top: MediaQuery
.of(context)
.size
.height * 0.24,
child: Container(
height: 100,
alignment: Alignment.centerLeft,
child: ClipOval(
child: AppState().getUser.data!.userInfo!.userLocalImage != null
? Image.file(
AppState().getUser.data!.userInfo!.userLocalImage!,
width: 100,
height: 100,
fit: BoxFit.fill,
)
AppState().getUser.data!.userInfo!.userLocalImage!,
width: 100,
height: 100,
fit: BoxFit.fill,
)
: CachedNetworkImage(
imageUrl: "${AppState().getUser.data!.userInfo!.userImageUrl}",
imageBuilder: (context, imageProvider) => Container(
decoration: BoxDecoration(
image: DecorationImage(
image: imageProvider,
fit: BoxFit.cover,
),
imageUrl: "${AppState().getUser.data!.userInfo!.userImageUrl}",
imageBuilder: (context, imageProvider) =>
Container(
decoration: BoxDecoration(
image: DecorationImage(
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(),
),
Positioned(
top: MediaQuery.of(context).size.height * 0.30,
right: MediaQuery.of(context).size.height * 0.03,
top: MediaQuery
.of(context)
.size
.height * 0.30,
right: MediaQuery
.of(context)
.size
.height * 0.03,
child: Container(
height: 40,
width: 40,
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(),
child: Center(child: MyAssets.icEdit.buildSvg(),),
).onPress(
() async {
() async {
await model.updateUserImage(context);
},
),
),
Positioned(
top: MediaQuery.of(context).size.height * 0.05,
left: MediaQuery.of(context).size.height * 0.03,
top: MediaQuery
.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)
.toContainer(
padding: const EdgeInsets.only(left: 5),
borderRadius: 100,
borderColor: MyColors.lightGreyEFColor,
isEnabledBorder: true,
height: 40,
width: 40,
)
padding: const EdgeInsets.only(left: 5),
borderRadius: 100,
borderColor: MyColors.lightGreyEFColor,
isEnabledBorder: true,
height: 40,
width: 40,
)
.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