Merge remote-tracking branch 'origin/main_design2.0' into main_design2.0

# Conflicts:
#	lib/new_views/pages/land_page/requests/asset_item_view.dart
main_design2.0
nextwo 2 years ago
commit fe4b071efb

@ -46,6 +46,11 @@
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </activity>
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
<!-- Don't delete the meta-data below. <!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --> This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data <meta-data

2
ios/.gitignore vendored

@ -22,7 +22,7 @@ Flutter/Generated.xcconfig
Flutter/ephemeral/ Flutter/ephemeral/
Flutter/app.flx Flutter/app.flx
Flutter/app.zip Flutter/app.zip
Flutter/flutter_assets/ Flutter/flutterassets/
Flutter/flutter_export_environment.sh Flutter/flutter_export_environment.sh
ServiceDefinitions.json ServiceDefinitions.json
Runner/GeneratedPluginRegistrant.* Runner/GeneratedPluginRegistrant.*

@ -25,6 +25,7 @@ class URLs {
// static get login => "$_baseUrl/MobileAuth/LoginIntegration"; // mobile login // static get login => "$_baseUrl/MobileAuth/LoginIntegration"; // mobile login
static get register => "$_baseUrl/handle/create/user"; // post static get register => "$_baseUrl/handle/create/user"; // post
static get updateProfile => "$_baseUrl/update/user/profile"; // post static get updateProfile => "$_baseUrl/update/user/profile"; // post
static get updateProfileImage => "$_baseUrl/Account/ChangeImageEmployee"; // post
static get getSites => "$_baseUrl/Customer/GetCustomers"; // get static get getSites => "$_baseUrl/Customer/GetCustomers"; // get
static get getSitesAutoComplete => "$_baseUrl/Customer/GetCustomersAutoComplete"; // get static get getSitesAutoComplete => "$_baseUrl/Customer/GetCustomersAutoComplete"; // get

@ -113,16 +113,24 @@ class AssetProvider extends ChangeNotifier {
@required int hospitalId, @required int hospitalId,
String serialNumber, String serialNumber,
String number, String number,
bool addPagination = true,
}) async { }) async {
Response response; Response response;
try { try {
response = await ApiManager.instance.post(URLs.getAssets, body: { Map<String, dynamic> body = {
"pageSize": pageItemNumber, // "pageSize": pageItemNumber,
"pageNumber": devices.length ~/ pageItemNumber + 1, // "pageNumber": devices.length ~/ pageItemNumber + 1,
// "siteId": hospitalId, // "siteId": hospitalId,
if (serialNumber?.isEmpty == false) "assetSerialNumber": serialNumber, if (serialNumber?.isEmpty == false) "assetSerialNumber": serialNumber,
if (number?.isEmpty == false) "assetNo": number, if (number?.isEmpty == false) "assetNo": number,
}); };
if (addPagination) {
body["pageSize"] = pageItemNumber;
body["pageNumber"] = devices.length ~/ pageItemNumber + 1;
}
response = await ApiManager.instance.post(URLs.getAssets, body: body);
// response = await get( // response = await get(
// Uri.parse("$host${URLs.getEquipment}?siteId=$hospitalId" // Uri.parse("$host${URLs.getEquipment}?siteId=$hospitalId"
// "${serialNumber?.isEmpty == false ? "&assetSerialNumber=$serialNumber" :""}" // "${serialNumber?.isEmpty == false ? "&assetSerialNumber=$serialNumber" :""}"

@ -186,6 +186,7 @@ class RegularVisitsProvider extends ChangeNotifier {
body["id"] = visit.id; body["id"] = visit.id;
body["assetId"] = visit.deviceId; body["assetId"] = visit.deviceId;
body["ppmScheduleId"] = visit.ppmScheduleId; body["ppmScheduleId"] = visit.ppmScheduleId;
body["assignedEmployeeId"] = user.userName;
// body["token"] = user.token; // body["token"] = user.token;
// body["vChecklists"]?.addAll({}); // body["vChecklists"]?.addAll({});
// body["vCalibrationTools"]?.addAll({"visitId": visit.id,}); // body["vCalibrationTools"]?.addAll({"visitId": visit.id,});

@ -1,4 +1,5 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:http/http.dart'; import 'package:http/http.dart';
@ -19,7 +20,11 @@ class UserProvider extends ChangeNotifier {
// contain user data // contain user data
// when user not login or register _user = null // when user not login or register _user = null
User _user; User _user;
User get user => _user; User get user => _user;
File profileImage;
set user(User user) { set user(User user) {
_user = user; _user = user;
ApiManager.instance.user = user; ApiManager.instance.user = user;
@ -29,7 +34,9 @@ class UserProvider extends ChangeNotifier {
// when login or register in-process _login = true // when login or register in-process _login = true
// when login or register is done or not start = false // when login or register is done or not start = false
bool _loading = false; bool _loading = false;
bool get isLoading => _loading; bool get isLoading => _loading;
set isLoading(bool isLoading) { set isLoading(bool isLoading) {
_loading = isLoading; _loading = isLoading;
notifyListeners(); notifyListeners();
@ -53,6 +60,7 @@ class UserProvider extends ChangeNotifier {
if (response.statusCode >= 200 && response.statusCode < 300) { if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received // client's request was successfully received
_user = User.fromJson(jsonDecode(response.body)); _user = User.fromJson(jsonDecode(response.body));
_user.profilePhotoName = URLs.getFileUrl(_user.profilePhotoName);
ApiManager.instance.user = _user; ApiManager.instance.user = _user;
notifyListeners(); notifyListeners();
return response.statusCode; return response.statusCode;
@ -106,51 +114,69 @@ class UserProvider extends ChangeNotifier {
return response.statusCode; return response.statusCode;
} }
/// sign up with User object; Future<int> uploadProfileImage(String userId, File image) async {
/// return -2 if request in progress if (_loading == true) return -2;
/// return -1 if error happen when sending request _loading = true;
/// return state code if request complete may be 200, 404 or 403 notifyListeners();
/// for more details about state codes check http state manager Response response;
/// lib\controllers\http_status_manger\http_status_manger.dart try {
// Future<int> updateProfile({ Map<String, dynamic> body = {
// @required String host, "userId": userId,
// @required User user, "imageEmployee": "${image.path.split("/").last}|${base64Encode(image.readAsBytesSync())}",
// }) async { };
// if (_loading == true) return -2; response = await ApiManager.instance.post(URLs.updateProfileImage, body: body);
// _loading = true; if (response.statusCode >= 200 && response.statusCode < 300) {
// notifyListeners(); profileImage = image;
// Response response; }
// _loading = false;
// Map<String, dynamic> jsonObject = {}; notifyListeners();
// jsonObject["uid"] = user.id; return response.statusCode;
// jsonObject["token"] = user.token; } catch (error) {
// if (user.departmentId != _user.departmentId) jsonObject["department"] = user.departmentId; _loading = false;
// // if (user.whatsApp != _user.whatsApp) jsonObject["whatsapp"] = user.whatsApp; notifyListeners();
// if (user.phoneNumber != _user.phoneNumber) jsonObject["phone"] = user.phoneNumber; return -1;
// try { }
// response = response = await ApiManager.instance.post( }
// URLs.login,
// body: jsonObject, // Future<int> updateProfile({
// ); // @required String host,
// } catch (error) { // @required User user,
// _loading = false; // }) async {
// notifyListeners(); // if (_loading == true) return -2;
// return -1; // _loading = true;
// } // notifyListeners();
// // Response response;
// _loading = false; //
// notifyListeners(); // Map<String, dynamic> jsonObject = {};
// // jsonObject["uid"] = user.id;
// if (response.statusCode >= 200 && response.statusCode < 300) { // jsonObject["token"] = user.token;
// // client's request was successfully received // if (user.departmentId != _user.departmentId) jsonObject["department"] = user.departmentId;
// _user = User.fromJson(jsonDecode(utf8.decode(response.bodyBytes))[0]); // // if (user.whatsApp != _user.whatsApp) jsonObject["whatsapp"] = user.whatsApp;
// _user.clientId = user.clientId; // if (user.phoneNumber != _user.phoneNumber) jsonObject["phone"] = user.phoneNumber;
// _user.clientName = user.clientName; // try {
// _user.departmentName = user.departmentName; // response = response = await ApiManager.instance.post(
// _user.departmentId = user.departmentId; // URLs.login,
// notifyListeners(); // body: jsonObject,
// return response.statusCode; // );
// } // } catch (error) {
// return response.statusCode; // _loading = false;
// } // notifyListeners();
// return -1;
// }
//
// _loading = false;
// notifyListeners();
//
// if (response.statusCode >= 200 && response.statusCode < 300) {
// // client's request was successfully received
// _user = User.fromJson(jsonDecode(utf8.decode(response.bodyBytes))[0]);
// _user.clientId = user.clientId;
// _user.clientName = user.clientName;
// _user.departmentName = user.departmentName;
// _user.departmentId = user.departmentId;
// notifyListeners();
// return response.statusCode;
// }
// return response.statusCode;
// }
} }

@ -29,7 +29,7 @@ class Hospital {
} }
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() {
return {'id': id, 'customerCode': customerCode, 'custName': name, "buildings": buildings}; return {'id': id, 'customerCode': customerCode, 'custName': name, "buildings": []};
} }
} }

@ -21,9 +21,11 @@ class Building extends Base {
}); });
} }
} }
num id; num id;
num value; num value;
List<Floor> floors; List<Floor> floors;
Building copyWith({ Building copyWith({
num id, num id,
String name, String name,
@ -36,14 +38,18 @@ class Building extends Base {
value: value ?? this.value, value: value ?? this.value,
floors: floors ?? this.floors, floors: floors ?? this.floors,
); );
Map<String, dynamic> toJson() {
Map<String, dynamic> toJson({bool addFloor = true}) {
final map = <String, dynamic>{}; final map = <String, dynamic>{};
map['id'] = id; map['id'] = id;
map['name'] = name; map['name'] = name;
map['value'] = value; map['value'] = value;
if (floors != null) { if(addFloor) {
map['floors'] = floors.map((v) => v.toJson()).toList(); if (floors != null) {
map['floors'] = floors.map((v) => v.toJson()).toList();
}
} }
return map; return map;
} }
} }

@ -21,9 +21,11 @@ class Floor extends Base {
}); });
} }
} }
num id; num id;
num value; num value;
List<Department> departments; List<Department> departments;
Floor copyWith({ Floor copyWith({
num id, num id,
String name, String name,
@ -36,14 +38,16 @@ class Floor extends Base {
value: value ?? this.value, value: value ?? this.value,
departments: departments ?? this.departments, departments: departments ?? this.departments,
); );
Map<String, dynamic> toJson() {
Map<String, dynamic> toJson({bool addDepartments = true}) {
final map = <String, dynamic>{}; final map = <String, dynamic>{};
map['id'] = id; map['id'] = id;
map['name'] = name; map['name'] = name;
map['value'] = value; map['value'] = value;
if (departments != null) { if (addDepartments)
map['departments'] = departments.map((v) => v.toJson()).toList(); if (departments != null) {
} map['departments'] = departments.map((v) => v.toJson()).toList();
return map; }
return map;
} }
} }

@ -157,13 +157,13 @@ class GasRefillModel {
map['nurseSignature'] = nurseSignature; map['nurseSignature'] = nurseSignature;
map['workingHours'] = workingHours; map['workingHours'] = workingHours;
if (site != null) { if (site != null) {
map['site'] = site.toJson(); map['site'] = site.toJson(addBuildings: false);
} }
if (building != null) { if (building != null) {
map['building'] = building.toJson(); map['building'] = building.toJson(addFloor: false);
} }
if (floor != null) { if (floor != null) {
map['floor'] = floor.toJson(); map['floor'] = floor.toJson(addDepartments: false);
} }
if (department != null) { if (department != null) {
map['department'] = department.toJson(); map['department'] = department.toJson();

@ -20,9 +20,11 @@ class Site extends Base {
}); });
} }
} }
num id; num id;
String custName; String custName;
List<Building> buildings; List<Building> buildings;
Site copyWith({ Site copyWith({
num id, num id,
String custName, String custName,
@ -33,13 +35,19 @@ class Site extends Base {
custName: custName ?? this.custName, custName: custName ?? this.custName,
buildings: buildings ?? this.buildings, buildings: buildings ?? this.buildings,
); );
Map<String, dynamic> toJson() {
Map<String, dynamic> toJson({bool addBuildings = true}) {
final map = <String, dynamic>{}; final map = <String, dynamic>{};
map['id'] = id; map['id'] = id;
map['custName'] = custName; map['custName'] = custName;
if (buildings != null) { if (addBuildings) {
map['buildings'] = buildings.map((v) => v.toJson()).toList(); if (buildings != null) {
map['buildings'] = buildings.map((v) => v.toJson()).toList();
}
} else {
map['buildings'] = [];
} }
return map; return map;
} }
} }

@ -283,8 +283,8 @@ class ServiceReport {
if (reason != null) { if (reason != null) {
map['reason'] = reason.toJson(); map['reason'] = reason.toJson();
} }
map['startofWorkTime'] = startofWorkTime; map['startofWorkTime'] = timer.startAt.toString();
map['endofWorkTime'] = endofWorkTime; map['endofWorkTime'] = timer.endAt.toString();
map['workingHours'] = workingHours; map['workingHours'] = workingHours;
map['travelingHours'] = travelingHours; map['travelingHours'] = travelingHours;
map['travelingExpenses'] = travelingExpenses; map['travelingExpenses'] = travelingExpenses;

@ -27,6 +27,7 @@ class User {
String securityStamp; String securityStamp;
String concurrencyStamp; String concurrencyStamp;
String phoneNumber; String phoneNumber;
String extensionNo;
bool phoneNumberConfirmed; bool phoneNumberConfirmed;
bool twoFactorEnabled; bool twoFactorEnabled;
dynamic lockoutEnd; dynamic lockoutEnd;
@ -139,6 +140,7 @@ class User {
map['securityStamp'] = securityStamp; map['securityStamp'] = securityStamp;
map['concurrencyStamp'] = concurrencyStamp; map['concurrencyStamp'] = concurrencyStamp;
map['phoneNumber'] = phoneNumber; map['phoneNumber'] = phoneNumber;
map['extensionNo'] = extensionNo;
map['phoneNumberConfirmed'] = phoneNumberConfirmed; map['phoneNumberConfirmed'] = phoneNumberConfirmed;
map['twoFactorEnabled'] = twoFactorEnabled; map['twoFactorEnabled'] = twoFactorEnabled;
map['lockoutEnd'] = lockoutEnd; map['lockoutEnd'] = lockoutEnd;
@ -188,6 +190,7 @@ class User {
securityStamp = json['securityStamp']; securityStamp = json['securityStamp'];
concurrencyStamp = json['concurrencyStamp']; concurrencyStamp = json['concurrencyStamp'];
phoneNumber = json['phoneNumber']; phoneNumber = json['phoneNumber'];
extensionNo = json['extensionNo'];
phoneNumberConfirmed = json['phoneNumberConfirmed']; phoneNumberConfirmed = json['phoneNumberConfirmed'];
twoFactorEnabled = json['twoFactorEnabled']; twoFactorEnabled = json['twoFactorEnabled'];
lockoutEnd = json['lockoutEnd']; lockoutEnd = json['lockoutEnd'];

@ -33,39 +33,44 @@ class AppDrawer extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Container( Consumer<UserProvider>(builder: (context, snapshot, _) {
width: 90, return CircleAvatar(
height: 90, radius: 45,
decoration: ShapeDecoration( backgroundColor: const Color(0xFFE4E5E6),
image: DecorationImage( child: Padding(
image: NetworkImage( padding: const EdgeInsets.all(1), // Border radius
(userProvider.user?.profilePhotoName?.isNotEmpty) ?? false child: ClipOval(
? userProvider.user.profilePhotoName child: (snapshot.user.profilePhotoName?.isNotEmpty ?? false)
: "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", ? 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))), );
), }).onPress(() => Navigator.of(context).pushNamed(ProfilePage.id)),
).onPress(() => Navigator.of(context).pushNamed(ProfilePage.id)),
const Icon(Icons.clear).onPress(() => Navigator.of(context).pop()) const Icon(Icons.clear).onPress(() => Navigator.of(context).pop())
], ],
), ),
8.height, 8.height,
(userProvider.user?.username ?? "Eng Mahmoud").heading3(context).custom(fontWeight: FontWeight.w600), userProvider.user.username.heading3(context).custom(fontWeight: FontWeight.w600),
(userProvider.user?.email ?? "context.welcome@gmail.com").heading6(context).custom(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), if ((userProvider.user?.email ?? "").isNotEmpty) (userProvider.user?.email).heading6(context).custom(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
18.height, 18.height,
1.divider, 1.divider,
ListView( ListView(
// "settings" : " Settings", // "settings" : " Settings",
// "ReportBug " : "Report a bug", // "ReportBug " : "Report a bug",
// "whatsNew" : "What's New", // "whatsNew" : "What's New",
// "logout" : "Logout" // "logout" : "Logout"
// "settings" : " الاعدادات", // "settings" : " الاعدادات",
// "ReportBug " "ابلاغ عن خطا", // "ReportBug " "ابلاغ عن خطا",
// "whatsNew" : "ماهو الجديد", // "whatsNew" : "ماهو الجديد",
// "logout" : "خروج" // "logout" : "خروج"
padding: const EdgeInsets.only(top: 24), padding: const EdgeInsets.only(top: 24),
children: [ children: [
drawerItem("drawer_notification", context.translation.notifications, context).onPress(() => Navigator.of(context).pushNamed(NotificationsPage.id)), drawerItem("drawer_notification", context.translation.notifications, context).onPress(() => Navigator.of(context).pushNamed(NotificationsPage.id)),
@ -114,7 +119,7 @@ class AppDrawer extends StatelessWidget {
); );
} }
Widget drawerItem(String icon, String title, BuildContext context,{Color color}) { Widget drawerItem(String icon, String title, BuildContext context, {Color color}) {
return Row( return Row(
children: [ children: [
SvgPicture.asset( SvgPicture.asset(
@ -126,7 +131,9 @@ class AppDrawer extends StatelessWidget {
16.width, 16.width,
Text( Text(
title, title,
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50,), style: AppTextStyles.heading6.copyWith(
color: context.isDark ? AppColor.neutral10 : AppColor.neutral50,
),
), ),
], ],
); );

@ -32,7 +32,7 @@ class AppFilledButton extends StatelessWidget {
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
color: buttonColor ?? Theme.of(context).primaryColor, color: buttonColor ?? Theme.of(context).primaryColor,
), ),
child: loading ? const CircularProgressIndicator(color: Colors.white) : label.heading6(context).custom(color: textColor ?? (context.isDark ? AppColor.neutral60 : Colors.white)), child: label.heading6(context).custom(color: textColor ?? (context.isDark ? AppColor.neutral60 : Colors.white)),
).onPress(onPressed); ).onPress(onPressed);
} }
} }

@ -47,20 +47,26 @@ class _DashboardPageState extends State<DashboardPage> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Container( Consumer<UserProvider>(builder: (context, snapshot, _) {
width: 48, return CircleAvatar(
height: 48, radius: 24,
decoration: const ShapeDecoration( backgroundColor: const Color(0xFFE4E5E6),
image: DecorationImage( child: Padding(
image: NetworkImage( padding: const EdgeInsets.all(1), // Border radius
"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"), child: ClipOval(
fit: BoxFit.cover, child: (snapshot.user.profilePhotoName?.isNotEmpty ?? false)
), ? Image.network(snapshot.user.profilePhotoName)
shape: OvalBorder( : snapshot.profileImage != null
side: BorderSide(width: 1, color: Color(0xFFE4E5E6)), ? Image.file(snapshot.profileImage)
: const Icon(
Icons.person,
size: 24,
color: Colors.white,
),
),
), ),
), );
).onPress(widget.onDrawerPress), }).onPress(widget.onDrawerPress),
Stack( Stack(
alignment: Alignment.topRight, alignment: Alignment.topRight,
children: [ children: [

@ -7,7 +7,9 @@ import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/all_requests_and_count_model.dart'; import 'package:test_sa/models/all_requests_and_count_model.dart';
import 'package:test_sa/models/device/asset.dart'; import 'package:test_sa/models/device/asset.dart';
import 'package:test_sa/models/device/asset_transfer.dart';
import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/pages/device_transfer/device_transfer_details.dart';
import 'package:test_sa/views/widgets/requests/request_status.dart'; import 'package:test_sa/views/widgets/requests/request_status.dart';
import '../../../../models/device/asset_transfer.dart'; import '../../../../models/device/asset_transfer.dart';
@ -31,12 +33,12 @@ class AssetItemView extends StatelessWidget {
if(request.priority != null) if(request.priority != null)
StatusLabel(label: request.priority??"", textColor: AColors.getRequestStatusTextColorByName(request.priority), backgroundColor: AColors.getRequestStatusColorByName(request.priority)), StatusLabel(label: request.priority??"", textColor: AColors.getRequestStatusTextColorByName(request.priority), backgroundColor: AColors.getRequestStatusColorByName(request.priority)),
8.width, 8.width,
if(request.status != null) //if(request.status != null)
StatusLabel( // StatusLabel(
label: request.status??"", // label: request.status??",
textColor: AColors.getRequestStatusTextColorByName(request.status), // textColor: AColors.getRequestStatusTextColorByName(request.status),
backgroundColor: AColors.getRequestStatusColorByName(request.status), // backgroundColor: AColors.getRequestStatusColorByName(request.status),
), // ),
1.width.expanded, 1.width.expanded,
Text(request.date?.toServiceRequestCardFormat ?? "", textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))), Text(request.date?.toServiceRequestCardFormat ?? "", textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))),
], ],

@ -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,220 +48,269 @@ 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, child: Column(
isFailedLoading: false, mainAxisSize: MainAxisSize.min,
stateCode: 200, crossAxisAlignment: CrossAxisAlignment.start,
onRefresh: () async {}, children: [
child: SafeArea( SizedBox(
child: Card( width: double.infinity,
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, children: [
crossAxisAlignment: CrossAxisAlignment.start, Consumer<UserProvider>(builder: (context, snapshot, _) {
children: [ return Stack(
SizedBox( alignment: Alignment.bottomRight,
width: double.infinity, children: [
child: Column( CircleAvatar(
children: [ radius: 45,
Container( backgroundColor: const Color(0xFFE4E5E6),
width: 90, child: Padding(
height: 90, padding: const EdgeInsets.all(1), // Border radius
decoration: ShapeDecoration( child: ClipOval(
image: DecorationImage( child: (snapshot.user.profilePhotoName?.isNotEmpty ?? false)
image: NetworkImage( ? Image.network(snapshot.user.profilePhotoName)
(_user.profilePhotoName?.isNotEmpty ?? false) : snapshot.profileImage != null
? _user.profilePhotoName ? Image.file(snapshot.profileImage)
: "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", : const Icon(
Icons.person,
size: 50,
color: Colors.white,
),
), ),
fit: BoxFit.cover,
), ),
shape: const OvalBorder(side: BorderSide(width: 1, color: Color(0xFFE4E5E6))),
), ),
), CircleAvatar(
(_user.username ?? "Eng Mahmoud").heading3(context).custom(fontWeight: FontWeight.w600), radius: 14,
(_user.email ?? "context.welcome@gmail.com").heading6(context).custom(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), backgroundColor: AppColor.primary70,
], child: Padding(
), padding: EdgeInsets.all(1), // Border radius
), child: snapshot.isLoading
24.height, ? const SizedBox(height: 16, width: 16, child: CircularProgressIndicator(color: Colors.white, strokeWidth: 2))
const Divider().defaultStyle(context), : Icon(Icons.upload, size: 16, color: Colors.white),
8.height, ),
(_user.phoneNumber ?? "+966 433 443 344").heading5(context), ).onPress(snapshot.isLoading
8.height, ? null
const Divider().defaultStyle(context), : () async {
8.height, final pickedFile = await ImagePicker().pickImage(source: ImageSource.gallery, imageQuality: 70, maxWidth: 800, maxHeight: 800);
("Ext: ${"2212"}").heading5(context),
8.height, if (pickedFile != null) {
if ((_user.departmentName?.length ?? 0) > 0) const Divider().defaultStyle(context), CroppedFile croppedFile = await ImageCropper().cropImage(
ListView.builder( sourcePath: pickedFile.path,
physics: const NeverScrollableScrollPhysics(), aspectRatioPresets: [CropAspectRatioPreset.square],
itemCount: _user.departmentName?.length ?? 0, uiSettings: [
shrinkWrap: true, AndroidUiSettings(
itemBuilder: (context, index) { toolbarTitle: 'ATOMS',
return (_user.departmentName[index] ?? "N/A").heading5(context).paddingOnly(top: 8, bottom: 8); toolbarColor: Colors.white,
}, toolbarWidgetColor: color,
), initAspectRatio: CropAspectRatioPreset.square,
], lockAspectRatio: false,
).paddingAll(16), ),
).paddingAll(16), IOSUiSettings(title: 'ATOMS'),
// child: Stack( ],
// children: [ );
// Form(
// key: _formKey, if (croppedFile != null) {
// child: ListView( snapshot.uploadProfileImage(_user.userID, File(croppedFile.path));
// children: [ }
// //AppNameBar(), }
// Hero( }),
// tag: "logo", ],
// child: Image( );
// height: _height / 4, }),
// image: AssetImage("assets/images/logo.png"), 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),
// Container( ],
// padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16), ),
// margin: EdgeInsets.symmetric(horizontal: 16), ),
// decoration: BoxDecoration(color: AColors.primaryColor, borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: [ 24.height,
// BoxShadow( if ((_user.phoneNumber ?? "").isNotEmpty) ...[
// color: AColors.grey, const Divider().defaultStyle(context),
// offset: Offset(0, -1), 8.height,
// ) _user.phoneNumber.heading5(context),
// ]), 8.height,
// child: Column( ],
// children: [ if ((_user.extensionNo ?? "").isNotEmpty) ...[
// ATextFormField( const Divider().defaultStyle(context),
// initialValue: _user.userName, 8.height,
// hintText: context.translation.name, _user.extensionNo.heading5(context),
// enable: false, 8.height,
// prefixIconData: Icons.account_circle, ],
// style: Theme.of(context).textTheme.headline6, if ((_user.departmentName?.length ?? 0) > 0) const Divider().defaultStyle(context),
// validator: (value) => Validator.hasValue(value) ? null : context.translation.nameValidateMessage, ListView.builder(
// onSaved: (value) { physics: const NeverScrollableScrollPhysics(),
// _user.userName = value; itemCount: _user.departmentName?.length ?? 0,
// }, shrinkWrap: true,
// ), itemBuilder: (context, index) {
// SizedBox( return (_user.departmentName[index] ?? "N/A").heading5(context).paddingOnly(top: 8, bottom: 8);
// height: 8, },
// ), ),
// ATextFormField( if ((_user.clientName ?? "").isNotEmpty) ...[
// initialValue: _user.email, const Divider().defaultStyle(context),
// hintText: context.translation.email, 8.height,
// enable: false, _user.clientName.heading5(context).custom(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
// prefixIconData: Icons.email, 8.height,
// textInputType: TextInputType.emailAddress, ],
// style: Theme.of(context).textTheme.headline6, ],
// validator: (value) => Validator.isEmail(value) ? null : context.translation.emailValidateMessage, ).toShadowContainer(context).paddingAll(16),
// onSaved: (value) { // child: Stack(
// _user.email = value; // children: [
// }, // Form(
// ), // key: _formKey,
// SizedBox( // child: ListView(
// height: 8, // children: [
// ), // //AppNameBar(),
// AbsorbPointer( // Hero(
// child: HospitalButton( // tag: "logo",
// hospital: Hospital(name: _user.clientName, id: _user.clientId), // child: Image(
// onHospitalPick: (hospital) { // height: _height / 4,
// _user.clientName = hospital.name; // image: AssetImage("assets/images/logo.png"),
// _user.clientId = hospital.id; // ),
// setState(() {}); // ),
// }, // Container(
// ), // padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16),
// ), // margin: EdgeInsets.symmetric(horizontal: 16),
// SizedBox( // decoration: BoxDecoration(color: AColors.primaryColor, borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: [
// height: 8, // BoxShadow(
// ), // color: AColors.grey,
// // DepartmentButton( // offset: Offset(0, -1),
// // department: Department(name: _user.departmentName, id: _user.departmentId), // )
// // onDepartmentPick: (department) { // ]),
// // _user.departmentName = department.name; // child: Column(
// // _user.departmentId = department.id; // children: [
// // setState(() {}); // ATextFormField(
// // }, // initialValue: _user.userName,
// // ), // hintText: context.translation.name,
// SizedBox( // enable: false,
// height: 8, // prefixIconData: Icons.account_circle,
// ), // style: Theme.of(context).textTheme.headline6,
// ATextFormField( // validator: (value) => Validator.hasValue(value) ? null : context.translation.nameValidateMessage,
// initialValue: _user.phoneNumber, // onSaved: (value) {
// hintText: context.translation.phoneNumber, // _user.userName = value;
// style: Theme.of(context).textTheme.headline6, // },
// prefixIconData: Icons.phone_android, // ),
// validator: (value) => Validator.isPhoneNumber(value) ? null : context.translation.phoneNumberValidateMessage, // SizedBox(
// textInputType: TextInputType.phone, // height: 8,
// onSaved: (value) { // ),
// _user.phoneNumber = value; // ATextFormField(
// }, // initialValue: _user.email,
// ), // hintText: context.translation.email,
// SizedBox( // enable: false,
// height: 8, // prefixIconData: Icons.email,
// ), // textInputType: TextInputType.emailAddress,
// // ATextFormField( // style: Theme.of(context).textTheme.headline6,
// // initialValue: _user.whatsApp, // validator: (value) => Validator.isEmail(value) ? null : context.translation.emailValidateMessage,
// // hintText: context.translation.whatsApp, // onSaved: (value) {
// // style: Theme.of(context).textTheme.headline6, // _user.email = value;
// // prefixIconData: FontAwesomeIcons.whatsapp, // },
// // prefixIconSize: 36, // ),
// // validator: (value) => // SizedBox(
// // Validator.isPhoneNumber(value) ? null : context.translation.phoneNumberValidateMessage, // height: 8,
// // textInputType: TextInputType.phone, // ),
// // onSaved: (value){ // AbsorbPointer(
// // _user.whatsApp = value; // child: HospitalButton(
// // }, // hospital: Hospital(name: _user.clientName, id: _user.clientId),
// // ), // onHospitalPick: (hospital) {
// ], // _user.clientName = hospital.name;
// ), // _user.clientId = hospital.id;
// ), // setState(() {});
// SizedBox( // },
// height: 16, // ),
// ), // ),
// Center( // SizedBox(
// child: SizedBox( // height: 8,
// height: _width / 8, // ),
// width: _width / 1.2, // // DepartmentButton(
// child: AButton( // // department: Department(name: _user.departmentName, id: _user.departmentId),
// text: context.translation.update, // // onDepartmentPick: (department) {
// onPressed: () async { // // _user.departmentName = department.name;
// // if (!_formKey.currentState.validate()) return; // // _user.departmentId = department.id;
// // _formKey.currentState.save(); // // setState(() {});
// // if (_user.departmentId == null) { // // },
// // ScaffoldMessenger.of(context).showSnackBar(SnackBar( // // ),
// // content: Text(context.translation.unitRequired), // SizedBox(
// // )); // height: 8,
// // return; // ),
// // } // ATextFormField(
// // int status = await _userProvider.updateProfile( // initialValue: _user.phoneNumber,
// // user: _user, // hintText: context.translation.phoneNumber,
// // host: _settingProvider.host, // style: Theme.of(context).textTheme.headline6,
// // ); // prefixIconData: Icons.phone_android,
// // if (status >= 200 && status < 300) { // validator: (value) => Validator.isPhoneNumber(value) ? null : context.translation.phoneNumberValidateMessage,
// // _settingProvider.setUser(_userProvider.user); // textInputType: TextInputType.phone,
// // ScaffoldMessenger.of(context).showSnackBar(SnackBar( // onSaved: (value) {
// // content: Text(context.translation.requestCompleteSuccessfully), // _user.phoneNumber = value;
// // )); // },
// // } else { // ),
// // String errorMessage = HttpStatusManger.getStatusMessage(status: status, subtitle: context.translation); // SizedBox(
// // ScaffoldMessenger.of(context).showSnackBar(SnackBar( // height: 8,
// // content: Text(errorMessage), // ),
// // )); // // ATextFormField(
// // } // // initialValue: _user.whatsApp,
// }, // // hintText: context.translation.whatsApp,
// ), // // style: Theme.of(context).textTheme.headline6,
// ), // // prefixIconData: FontAwesomeIcons.whatsapp,
// ), // // prefixIconSize: 36,
// SizedBox( // // validator: (value) =>
// height: 32, // // Validator.isPhoneNumber(value) ? null : context.translation.phoneNumberValidateMessage,
// ), // // textInputType: TextInputType.phone,
// ], // // onSaved: (value){
// ), // // _user.whatsApp = value;
// ), // // },
// ABackButton(), // // ),
// ], // ],
// ), // ),
), // ),
// SizedBox(
// height: 16,
// ),
// Center(
// child: SizedBox(
// height: _width / 8,
// width: _width / 1.2,
// child: AButton(
// text: context.translation.update,
// onPressed: () async {
// // if (!_formKey.currentState.validate()) return;
// // _formKey.currentState.save();
// // if (_user.departmentId == null) {
// // ScaffoldMessenger.of(context).showSnackBar(SnackBar(
// // content: Text(context.translation.unitRequired),
// // ));
// // return;
// // }
// // int status = await _userProvider.updateProfile(
// // user: _user,
// // host: _settingProvider.host,
// // );
// // if (status >= 200 && status < 300) {
// // _settingProvider.setUser(_userProvider.user);
// // ScaffoldMessenger.of(context).showSnackBar(SnackBar(
// // content: Text(context.translation.requestCompleteSuccessfully),
// // ));
// // } else {
// // String errorMessage = HttpStatusManger.getStatusMessage(status: status, subtitle: context.translation);
// // ScaffoldMessenger.of(context).showSnackBar(SnackBar(
// // content: Text(errorMessage),
// // ));
// // }
// },
// ),
// ),
// ),
// SizedBox(
// height: 32,
// ),
// ],
// ),
// ),
// ABackButton(),
// ],
// ),
), ),
); );
} }

@ -170,7 +170,8 @@ class _SingleDevicePickerState extends State<SingleDevicePicker> {
return AssetItemListView( return AssetItemListView(
device: _searchableList[itemIndex], device: _searchableList[itemIndex],
onPressed: (device) { onPressed: (device) {
Navigator.of(context).pushNamed(AssetDetailPage.id, arguments: device.id); Navigator.of(context).pop(device);
// Navigator.of(context).pushNamed(AssetDetailPage.id, arguments: device.id);
}, },
); );
}, },

@ -82,6 +82,7 @@ class _AutoCompleteDeviceNumberFieldState extends State<AutoCompleteDeviceNumber
user: _userProvider.user, user: _userProvider.user,
hospitalId: widget.hospitalId, hospitalId: widget.hospitalId,
number: vale, number: vale,
addPagination: false
); );
}, },
itemBuilder: (context, device) { itemBuilder: (context, device) {

@ -565,6 +565,30 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.3.0" version: "3.3.0"
image_cropper:
dependency: "direct main"
description:
name: image_cropper
sha256: "710ab4b7953e9ce1d27d833f741e5f8f3afb0b0ba3556dc0b844741b5f55c2b3"
url: "https://pub.dev"
source: hosted
version: "3.0.3"
image_cropper_for_web:
dependency: transitive
description:
name: image_cropper_for_web
sha256: "09e93a8ec0435adcaa23622ac090442872f18145d70b9ff605ffedcf97d56255"
url: "https://pub.dev"
source: hosted
version: "1.0.3"
image_cropper_platform_interface:
dependency: transitive
description:
name: image_cropper_platform_interface
sha256: "62349e3aab63873ea9b9ab9f69d036ab8a0d74b3004beec4303981386cb9273f"
url: "https://pub.dev"
source: hosted
version: "3.0.3"
image_picker: image_picker:
dependency: "direct main" dependency: "direct main"
description: description:

@ -74,6 +74,7 @@ dependencies:
flutter_advanced_switch: ^3.0.1 flutter_advanced_switch: ^3.0.1
pie_chart: ^5.3.2 pie_chart: ^5.3.2
table_calendar: ^3.0.8 table_calendar: ^3.0.8
image_cropper: ^3.0.3
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

Loading…
Cancel
Save