feat : image profile
This commit is contained in:
@@ -28,6 +28,20 @@ class ProfileLogic extends GetxController {
|
|||||||
Rxn<IranProvinceCityModel> selectedCity = Rxn();
|
Rxn<IranProvinceCityModel> selectedCity = Rxn();
|
||||||
|
|
||||||
GlobalKey<FormState> formKey = GlobalKey();
|
GlobalKey<FormState> formKey = GlobalKey();
|
||||||
|
ImagePicker imagePicker = ImagePicker();
|
||||||
|
Rxn<XFile> selectedImage = Rxn<XFile>();
|
||||||
|
RxnString _base64Image = RxnString();
|
||||||
|
RxBool isOnLoading = false.obs;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onInit() {
|
||||||
|
super.onInit();
|
||||||
|
ever(selectedImage, (data) async {
|
||||||
|
if (data?.path != null) {
|
||||||
|
_base64Image.value = await convertImageToBase64(data!.path);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onReady() {
|
void onReady() {
|
||||||
@@ -92,14 +106,22 @@ class ProfileLogic extends GetxController {
|
|||||||
nationalCode: nationalCodeController.text,
|
nationalCode: nationalCodeController.text,
|
||||||
nationalId: nationalIdController.text,
|
nationalId: nationalIdController.text,
|
||||||
birthday: birthDate.value?.toGregorian().toString(),
|
birthday: birthDate.value?.toGregorian().toString(),
|
||||||
|
image: _base64Image.value,
|
||||||
personType: 'self',
|
personType: 'self',
|
||||||
type: 'self_profile',
|
type: 'self_profile',
|
||||||
);
|
);
|
||||||
|
isOnLoading.value = true;
|
||||||
await safeCall(
|
await safeCall(
|
||||||
call: () async => await rootLogic.chickenRepository.updateUserProfile(
|
call: () async => await rootLogic.chickenRepository.updateUserProfile(
|
||||||
token: rootLogic.tokenService.accessToken.value!,
|
token: rootLogic.tokenService.accessToken.value!,
|
||||||
userProfile: userProfile,
|
userProfile: userProfile,
|
||||||
),
|
),
|
||||||
|
onSuccess: (result) {
|
||||||
|
isOnLoading.value = false;
|
||||||
|
},
|
||||||
|
onError: (error, stackTrace) {
|
||||||
|
isOnLoading.value = false;
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:rasadyar_auth/data/models/local/user_local/user_local_model.dart';
|
import 'package:rasadyar_auth/data/models/local/user_local/user_local_model.dart';
|
||||||
import 'package:rasadyar_auth/presentation/routes/pages.dart';
|
import 'package:rasadyar_auth/presentation/routes/pages.dart';
|
||||||
@@ -25,21 +28,49 @@ class ProfilePage extends GetView<ProfileLogic> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Row(),
|
Row(),
|
||||||
Container(
|
ObxValue(
|
||||||
width: 128.w,
|
(data) {
|
||||||
height: 128.h,
|
final status = data.value.status;
|
||||||
decoration: BoxDecoration(
|
|
||||||
shape: BoxShape.circle,
|
if (status == ResourceStatus.loading) {
|
||||||
color: AppColor.blueLightActive,
|
return Container(
|
||||||
),
|
width: 128.w,
|
||||||
child: Center(
|
height: 128.h,
|
||||||
child: Assets.vec.userSvg.svg(
|
child: Center(child: CupertinoActivityIndicator(color: AppColor
|
||||||
width: 64.w,
|
.greenNormal,)),
|
||||||
height: 64.h,
|
);
|
||||||
colorFilter: ColorFilter.mode(AppColor.whiteLight, BlendMode.srcIn),
|
}
|
||||||
),
|
|
||||||
),
|
if (status == ResourceStatus.error) {
|
||||||
),
|
return Container(
|
||||||
|
width: 128.w,
|
||||||
|
height: 128.h,
|
||||||
|
child: Center(child: Text('خطا در دریافت اطلاعات')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Default UI
|
||||||
|
return Container(
|
||||||
|
width: 128.w,
|
||||||
|
height: 128.h,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: AppColor.blueLightActive,
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: CircleAvatar(
|
||||||
|
radius: 64.w,
|
||||||
|
backgroundImage:
|
||||||
|
NetworkImage(data.value.data!.image!)
|
||||||
|
|
||||||
|
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
controller.userProfile,
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -96,16 +127,17 @@ class ProfilePage extends GetView<ProfileLogic> {
|
|||||||
|
|
||||||
Container invoiceIssuanceInformation() => Container();
|
Container invoiceIssuanceInformation() => Container();
|
||||||
|
|
||||||
Widget bankInformationWidget() => Column(
|
Widget bankInformationWidget() =>
|
||||||
spacing: 16,
|
Column(
|
||||||
children: [
|
spacing: 16,
|
||||||
itemList(title: 'نام بانک', content: 'سامان'),
|
children: [
|
||||||
itemList(title: 'نام صاحب حساب', content: 'رضا رضایی'),
|
itemList(title: 'نام بانک', content: 'سامان'),
|
||||||
itemList(title: 'شماره کارت ', content: '54154545415'),
|
itemList(title: 'نام صاحب حساب', content: 'رضا رضایی'),
|
||||||
itemList(title: 'شماره حساب', content: '62565263263652'),
|
itemList(title: 'شماره کارت ', content: '54154545415'),
|
||||||
itemList(title: 'شماره شبا', content: '62565263263652'),
|
itemList(title: 'شماره حساب', content: '62565263263652'),
|
||||||
],
|
itemList(title: 'شماره شبا', content: '62565263263652'),
|
||||||
);
|
],
|
||||||
|
);
|
||||||
|
|
||||||
Widget userProfileInformation() {
|
Widget userProfileInformation() {
|
||||||
return ObxValue((data) {
|
return ObxValue((data) {
|
||||||
@@ -120,7 +152,8 @@ class ProfilePage extends GetView<ProfileLogic> {
|
|||||||
children: [
|
children: [
|
||||||
buildRowOnTapped(
|
buildRowOnTapped(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Get.bottomSheet(userInformationBottomSheet(), isScrollControlled: true);
|
Get.bottomSheet(
|
||||||
|
userInformationBottomSheet(), isScrollControlled: true, ignoreSafeArea: false);
|
||||||
},
|
},
|
||||||
titleWidget: Column(
|
titleWidget: Column(
|
||||||
spacing: 3,
|
spacing: 3,
|
||||||
@@ -184,33 +217,34 @@ class ProfilePage extends GetView<ProfileLogic> {
|
|||||||
required String content,
|
required String content,
|
||||||
String? icon,
|
String? icon,
|
||||||
bool hasColoredBox = false,
|
bool hasColoredBox = false,
|
||||||
}) => Container(
|
}) =>
|
||||||
padding: EdgeInsets.symmetric(horizontal: 12.h, vertical: 6.h),
|
Container(
|
||||||
decoration: BoxDecoration(
|
padding: EdgeInsets.symmetric(horizontal: 12.h, vertical: 6.h),
|
||||||
color: hasColoredBox ? AppColor.greenLight : Colors.transparent,
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(8),
|
color: hasColoredBox ? AppColor.greenLight : Colors.transparent,
|
||||||
border: hasColoredBox
|
borderRadius: BorderRadius.circular(8),
|
||||||
? Border.all(width: 0.25, color: AppColor.bgDark)
|
border: hasColoredBox
|
||||||
: Border.all(width: 0, color: Colors.transparent),
|
? Border.all(width: 0.25, color: AppColor.bgDark)
|
||||||
),
|
: Border.all(width: 0, color: Colors.transparent),
|
||||||
child: Row(
|
),
|
||||||
spacing: 4,
|
child: Row(
|
||||||
children: [
|
spacing: 4,
|
||||||
if (icon != null)
|
children: [
|
||||||
Padding(
|
if (icon != null)
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
Padding(
|
||||||
child: SvgGenImage.vec(icon).svg(
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
width: 20.w,
|
child: SvgGenImage.vec(icon).svg(
|
||||||
height: 20.h,
|
width: 20.w,
|
||||||
colorFilter: ColorFilter.mode(AppColor.mediumGreyNormalActive, BlendMode.srcIn),
|
height: 20.h,
|
||||||
),
|
colorFilter: ColorFilter.mode(AppColor.mediumGreyNormalActive, BlendMode.srcIn),
|
||||||
),
|
),
|
||||||
Text(title, style: AppFonts.yekan12.copyWith(color: AppColor.mediumGreyNormalActive)),
|
),
|
||||||
Spacer(),
|
Text(title, style: AppFonts.yekan12.copyWith(color: AppColor.mediumGreyNormalActive)),
|
||||||
Text(content, style: AppFonts.yekan13.copyWith(color: AppColor.mediumGreyNormalHover)),
|
Spacer(),
|
||||||
],
|
Text(content, style: AppFonts.yekan13.copyWith(color: AppColor.mediumGreyNormalHover)),
|
||||||
),
|
],
|
||||||
);
|
),
|
||||||
|
);
|
||||||
|
|
||||||
Widget cardActionWidget({
|
Widget cardActionWidget({
|
||||||
required String title,
|
required String title,
|
||||||
@@ -238,7 +272,7 @@ class ProfilePage extends GetView<ProfileLogic> {
|
|||||||
width: 40,
|
width: 40,
|
||||||
height: 40,
|
height: 40,
|
||||||
colorFilter:
|
colorFilter:
|
||||||
color ??
|
color ??
|
||||||
ColorFilter.mode(
|
ColorFilter.mode(
|
||||||
selected ? AppColor.blueNormal : AppColor.whiteLight,
|
selected ? AppColor.blueNormal : AppColor.whiteLight,
|
||||||
BlendMode.srcIn,
|
BlendMode.srcIn,
|
||||||
@@ -260,7 +294,7 @@ class ProfilePage extends GetView<ProfileLogic> {
|
|||||||
|
|
||||||
Widget userInformationBottomSheet() {
|
Widget userInformationBottomSheet() {
|
||||||
return BaseBottomSheet(
|
return BaseBottomSheet(
|
||||||
height: 500.h,
|
height: 750.h,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
@@ -270,16 +304,6 @@ class ProfilePage extends GetView<ProfileLogic> {
|
|||||||
style: AppFonts.yekan16Bold.copyWith(color: AppColor.darkGreyDarkHover),
|
style: AppFonts.yekan16Bold.copyWith(color: AppColor.darkGreyDarkHover),
|
||||||
),
|
),
|
||||||
|
|
||||||
/*
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.all(8),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
border: Border.all(color: AppColor.darkGreyLight, width: 1),
|
|
||||||
),
|
|
||||||
child: Column(spacing: 12, children: [_provinceWidget(), _cityWidget()]),
|
|
||||||
),*/
|
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.all(8),
|
padding: EdgeInsets.all(8),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@@ -333,25 +357,75 @@ class ProfilePage extends GetView<ProfileLogic> {
|
|||||||
|
|
||||||
SizedBox(),
|
SizedBox(),
|
||||||
|
|
||||||
|
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(),
|
||||||
|
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.all(8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
border: Border.all(color: AppColor.darkGreyLight, width: 1),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
spacing: 8,
|
||||||
|
children: [
|
||||||
|
Text('عکس پروفایل',
|
||||||
|
style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal)),
|
||||||
|
ObxValue((data) {
|
||||||
|
return Container(
|
||||||
|
width: Get.width,
|
||||||
|
height: 270,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColor.lightGreyNormal,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
border: Border.all(width: 1, color: AppColor.blackLight),
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: data.value == null
|
||||||
|
? Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(30, 10, 10, 30),
|
||||||
|
child: Image.network(controller.userProfile.value.data?.image ?? '')
|
||||||
|
)
|
||||||
|
: Image.file(File(data.value!.path), fit: BoxFit.cover),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}, controller.selectedImage),
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
spacing: 16,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
RElevated(
|
RElevated(
|
||||||
|
text: 'گالری',
|
||||||
|
width: 150.w,
|
||||||
height: 40.h,
|
height: 40.h,
|
||||||
text: 'ویرایش',
|
textStyle: AppFonts.yekan20.copyWith(color: Colors.white),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await controller.updateUserProfile();
|
controller.selectedImage.value = await controller.imagePicker.pickImage(
|
||||||
controller.getUserProfile();
|
source: ImageSource.gallery,
|
||||||
Get.back();
|
imageQuality: 60,
|
||||||
|
maxWidth: 1080,
|
||||||
|
maxHeight: 720,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
SizedBox(width: 16),
|
||||||
ROutlinedElevated(
|
ROutlinedElevated(
|
||||||
|
text: 'دوربین',
|
||||||
|
width: 150.w,
|
||||||
height: 40.h,
|
height: 40.h,
|
||||||
text: 'انصراف',
|
textStyle: AppFonts.yekan20.copyWith(color: AppColor.blueNormal),
|
||||||
borderColor: AppColor.blueNormal,
|
onPressed: () async {
|
||||||
onPressed: () {
|
controller.selectedImage.value = await controller.imagePicker.pickImage(
|
||||||
Get.back();
|
source: ImageSource.camera,
|
||||||
|
imageQuality: 60,
|
||||||
|
maxWidth: 1080,
|
||||||
|
maxHeight: 720,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -359,7 +433,32 @@ class ProfilePage extends GetView<ProfileLogic> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(),
|
Row(
|
||||||
|
spacing: 16,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
ObxValue((data) {
|
||||||
|
return RElevated(
|
||||||
|
height: 40.h,
|
||||||
|
text: 'ویرایش',
|
||||||
|
isLoading: data.value,
|
||||||
|
onPressed: () async {
|
||||||
|
await controller.updateUserProfile();
|
||||||
|
controller.getUserProfile();
|
||||||
|
Get.back();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},controller.isOnLoading),
|
||||||
|
ROutlinedElevated(
|
||||||
|
height: 40.h,
|
||||||
|
text: 'انصراف',
|
||||||
|
borderColor: AppColor.blueNormal,
|
||||||
|
onPressed: () {
|
||||||
|
Get.back();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ class SalesOutOfProvinceLogic extends GetxController {
|
|||||||
RxBool isLoadingMoreAllocationsMade = false.obs;
|
RxBool isLoadingMoreAllocationsMade = false.obs;
|
||||||
Rxn<IranProvinceCityModel> selectedCity = Rxn();
|
Rxn<IranProvinceCityModel> selectedCity = Rxn();
|
||||||
|
|
||||||
//TODO add this to Di
|
|
||||||
ImagePicker imagePicker = ImagePicker();
|
|
||||||
|
|
||||||
GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||||
TextEditingController quarantineCodeController = TextEditingController();
|
TextEditingController quarantineCodeController = TextEditingController();
|
||||||
|
|||||||
Reference in New Issue
Block a user