|
|
|
@ -1,4 +1,10 @@
|
|
|
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import 'package:image_cropper/image_cropper.dart';
|
|
|
|
|
|
|
|
import 'package:image_picker/image_picker.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
|
|
|
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
|
|
|
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
|
|
|
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
|
|
|
@ -42,16 +48,11 @@ class _ProfilePageState extends State<ProfilePage> {
|
|
|
|
_user = User.fromJson(_userProvider.user.toJson());
|
|
|
|
_user = User.fromJson(_userProvider.user.toJson());
|
|
|
|
_firstTime = false;
|
|
|
|
_firstTime = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Color color = context.isDark ? AppColor.neutral10 : AppColor.neutral50;
|
|
|
|
return Scaffold(
|
|
|
|
return Scaffold(
|
|
|
|
key: _scaffoldKey,
|
|
|
|
key: _scaffoldKey,
|
|
|
|
appBar: DefaultAppBar(title: context.translation.myProfile),
|
|
|
|
appBar: DefaultAppBar(title: context.translation.myProfile),
|
|
|
|
body: LoadingManager(
|
|
|
|
body: SafeArea(
|
|
|
|
isLoading: _userProvider.isLoading,
|
|
|
|
|
|
|
|
isFailedLoading: false,
|
|
|
|
|
|
|
|
stateCode: 200,
|
|
|
|
|
|
|
|
onRefresh: () async {},
|
|
|
|
|
|
|
|
child: SafeArea(
|
|
|
|
|
|
|
|
child: Card(
|
|
|
|
|
|
|
|
child: Column(
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
@ -60,35 +61,85 @@ class _ProfilePageState extends State<ProfilePage> {
|
|
|
|
width: double.infinity,
|
|
|
|
width: double.infinity,
|
|
|
|
child: Column(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
Consumer<UserProvider>(builder: (context, snapshot, _) {
|
|
|
|
width: 90,
|
|
|
|
return Stack(
|
|
|
|
height: 90,
|
|
|
|
alignment: Alignment.bottomRight,
|
|
|
|
decoration: ShapeDecoration(
|
|
|
|
children: [
|
|
|
|
image: DecorationImage(
|
|
|
|
CircleAvatar(
|
|
|
|
image: NetworkImage(
|
|
|
|
radius: 45,
|
|
|
|
(_user.profilePhotoName?.isNotEmpty ?? false)
|
|
|
|
backgroundColor: const Color(0xFFE4E5E6),
|
|
|
|
? _user.profilePhotoName
|
|
|
|
child: Padding(
|
|
|
|
: "https://www.shutterstock.com/shutterstock/photos/1714666150/display_1500/stock-photo-head-shot-portrait-close-up-smiling-confident-businessman-wearing-glasses-looking-at-camera-1714666150.jpg",
|
|
|
|
padding: const EdgeInsets.all(1), // Border radius
|
|
|
|
|
|
|
|
child: ClipOval(
|
|
|
|
|
|
|
|
child: (snapshot.user.profilePhotoName?.isNotEmpty ?? false)
|
|
|
|
|
|
|
|
? Image.network(snapshot.user.profilePhotoName)
|
|
|
|
|
|
|
|
: snapshot.profileImage != null
|
|
|
|
|
|
|
|
? Image.file(snapshot.profileImage)
|
|
|
|
|
|
|
|
: const Icon(
|
|
|
|
|
|
|
|
Icons.person,
|
|
|
|
|
|
|
|
size: 50,
|
|
|
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
shape: const OvalBorder(side: BorderSide(width: 1, color: Color(0xFFE4E5E6))),
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
CircleAvatar(
|
|
|
|
|
|
|
|
radius: 14,
|
|
|
|
|
|
|
|
backgroundColor: AppColor.primary70,
|
|
|
|
|
|
|
|
child: Padding(
|
|
|
|
|
|
|
|
padding: EdgeInsets.all(1), // Border radius
|
|
|
|
|
|
|
|
child: snapshot.isLoading
|
|
|
|
|
|
|
|
? const SizedBox(height: 16, width: 16, child: CircularProgressIndicator(color: Colors.white, strokeWidth: 2))
|
|
|
|
|
|
|
|
: Icon(Icons.upload, size: 16, color: Colors.white),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
).onPress(snapshot.isLoading
|
|
|
|
|
|
|
|
? null
|
|
|
|
|
|
|
|
: () async {
|
|
|
|
|
|
|
|
final pickedFile = await ImagePicker().pickImage(source: ImageSource.gallery, imageQuality: 70, maxWidth: 800, maxHeight: 800);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (pickedFile != null) {
|
|
|
|
|
|
|
|
CroppedFile croppedFile = await ImageCropper().cropImage(
|
|
|
|
|
|
|
|
sourcePath: pickedFile.path,
|
|
|
|
|
|
|
|
aspectRatioPresets: [CropAspectRatioPreset.square],
|
|
|
|
|
|
|
|
uiSettings: [
|
|
|
|
|
|
|
|
AndroidUiSettings(
|
|
|
|
|
|
|
|
toolbarTitle: 'ATOMS',
|
|
|
|
|
|
|
|
toolbarColor: Colors.white,
|
|
|
|
|
|
|
|
toolbarWidgetColor: color,
|
|
|
|
|
|
|
|
initAspectRatio: CropAspectRatioPreset.square,
|
|
|
|
|
|
|
|
lockAspectRatio: false,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(_user.username ?? "Eng Mahmoud").heading3(context).custom(fontWeight: FontWeight.w600),
|
|
|
|
IOSUiSettings(title: 'ATOMS'),
|
|
|
|
(_user.email ?? "context.welcome@gmail.com").heading6(context).custom(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
|
|
|
|
],
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (croppedFile != null) {
|
|
|
|
|
|
|
|
snapshot.uploadProfileImage(_user.userID, File(croppedFile.path));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
8.height,
|
|
|
|
|
|
|
|
(_user.username).heading3(context).custom(fontWeight: FontWeight.w600, color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
|
|
|
|
|
|
|
|
if ((_user.email ?? "").isNotEmpty) (_user.email ?? "").heading6(context).custom(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
24.height,
|
|
|
|
24.height,
|
|
|
|
|
|
|
|
if ((_user.phoneNumber ?? "").isNotEmpty) ...[
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
8.height,
|
|
|
|
8.height,
|
|
|
|
(_user.phoneNumber ?? "+966 433 443 344").heading5(context),
|
|
|
|
_user.phoneNumber.heading5(context),
|
|
|
|
8.height,
|
|
|
|
8.height,
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
if ((_user.extensionNo ?? "").isNotEmpty) ...[
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
8.height,
|
|
|
|
8.height,
|
|
|
|
("Ext: ${"2212"}").heading5(context),
|
|
|
|
_user.extensionNo.heading5(context),
|
|
|
|
8.height,
|
|
|
|
8.height,
|
|
|
|
|
|
|
|
],
|
|
|
|
if ((_user.departmentName?.length ?? 0) > 0) const Divider().defaultStyle(context),
|
|
|
|
if ((_user.departmentName?.length ?? 0) > 0) const Divider().defaultStyle(context),
|
|
|
|
ListView.builder(
|
|
|
|
ListView.builder(
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
@ -98,9 +149,14 @@ class _ProfilePageState extends State<ProfilePage> {
|
|
|
|
return (_user.departmentName[index] ?? "N/A").heading5(context).paddingOnly(top: 8, bottom: 8);
|
|
|
|
return (_user.departmentName[index] ?? "N/A").heading5(context).paddingOnly(top: 8, bottom: 8);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
if ((_user.clientName ?? "").isNotEmpty) ...[
|
|
|
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
|
|
|
8.height,
|
|
|
|
|
|
|
|
_user.clientName.heading5(context).custom(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
|
|
|
|
|
|
|
|
8.height,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
).paddingAll(16),
|
|
|
|
],
|
|
|
|
).paddingAll(16),
|
|
|
|
).toShadowContainer(context).paddingAll(16),
|
|
|
|
// child: Stack(
|
|
|
|
// child: Stack(
|
|
|
|
// children: [
|
|
|
|
// children: [
|
|
|
|
// Form(
|
|
|
|
// Form(
|
|
|
|
@ -256,7 +312,6 @@ class _ProfilePageState extends State<ProfilePage> {
|
|
|
|
// ],
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|