Merge branch 'refs/heads/design_3.0_rota_module' into design_3.0_demo_module

# Conflicts:
#	lib/controllers/api_routes/urls.dart
design_3.0_demo_module
Sikander Saleem 23 hours ago
commit 71dfcde5a1

@ -4,14 +4,14 @@ class URLs {
static const String appReleaseBuildNumber = "33"; static const String appReleaseBuildNumber = "33";
// static const host1 = "https://atomsm.hmg.com"; // production url // static const host1 = "https://atomsm.hmg.com"; // production url
// static const host1 = "https://atomsmdev.hmg.com"; // local DEV url static const host1 = "https://atomsmdev.hmg.com"; // local DEV url
static const host1 = "https://atomsmuat.hmg.com"; // local UAT url // static const host1 = "https://atomsmuat.hmg.com"; // local UAT url
// static String _baseUrl = "$_host/mobile"; // static final String _baseUrl = "$_host/mobile"; // host local UAT
static final String _baseUrl = "$_host/v2/mobile"; // new V2 apis static final String _baseUrl = "$_host/v2/mobile"; // new V2 apis
// static final String _baseUrl = "$_host/v3/mobile"; // for asset delivery module
// static final String _baseUrl = "$_host/mobile"; // host local UAT and for internal audit dev // static final String _baseUrl = "$_host/mobile"; // host local UAT and for internal audit dev
// static final String _baseUrl = "$_host/v3/mobile"; // v3 for production CM,PM,TM // static final String _baseUrl = "$_host/v3/mobile"; // v3 for production CM,PM,TM
// static final String _baseUrl = "$_host/v4/mobile"; // v4 for Demo module
// static final String _baseUrl = "$_host/v5/mobile"; // v5 for data segregation // static final String _baseUrl = "$_host/v5/mobile"; // v5 for data segregation
// static final String _baseUrl = "$_host/v6/mobile"; // for asset delivery module // static final String _baseUrl = "$_host/v6/mobile"; // for asset delivery module
@ -49,6 +49,7 @@ class URLs {
static get sendForgetPasswordOtp => "$_baseUrl/Account/SendForgotPasswordOtp"; // send OTP. static get sendForgetPasswordOtp => "$_baseUrl/Account/SendForgotPasswordOtp"; // send OTP.
static get sendForgetPasswordValidateOtp => "$_baseUrl/Account/SendForgotPasswordValidateOtp"; // validate OTP. static get sendForgetPasswordValidateOtp => "$_baseUrl/Account/SendForgotPasswordValidateOtp"; // validate OTP.
static get updateNewPassword => "$_baseUrl/Account/UpdatenewPassword"; // validate OTP. static get updateNewPassword => "$_baseUrl/Account/UpdatenewPassword"; // validate OTP.
static get getUserRota => "$_baseUrl/Account/GetUserRota"; // validate OTP.
// 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

@ -15,6 +15,7 @@ import 'package:test_sa/models/new_models/update_password.dart';
import 'package:test_sa/models/new_models/verify_otp_model.dart'; import 'package:test_sa/models/new_models/verify_otp_model.dart';
import 'package:test_sa/models/site_contact_info_model.dart'; import 'package:test_sa/models/site_contact_info_model.dart';
import 'package:test_sa/models/user.dart'; import 'package:test_sa/models/user.dart';
import 'package:test_sa/models/user_rota_model.dart';
import 'package:test_sa/new_views/swipe_module/models/swipe_model.dart'; import 'package:test_sa/new_views/swipe_module/models/swipe_model.dart';
import 'package:test_sa/new_views/swipe_module/models/swipe_transaction_history.dart'; import 'package:test_sa/new_views/swipe_module/models/swipe_transaction_history.dart';
import 'package:test_sa/new_views/swipe_module/models/swipe_transaction_model.dart'; import 'package:test_sa/new_views/swipe_module/models/swipe_transaction_model.dart';
@ -46,7 +47,9 @@ class UserProvider extends ChangeNotifier {
bool get isNurse => user!.type == UsersTypes.normal_user; bool get isNurse => user!.type == UsersTypes.normal_user;
bool get isAssessor => user!.type == UsersTypes.assessor || user!.type == UsersTypes.assessorTl; bool get isAssessor => user!.type == UsersTypes.assessor || user!.type == UsersTypes.assessorTl;
bool get isQualityUser => user!.type == UsersTypes.qualityUser; bool get isQualityUser => user!.type == UsersTypes.qualityUser;
bool get isCommissioningEngineer => user!.type == UsersTypes.commissioningEngineer; bool get isCommissioningEngineer => user!.type == UsersTypes.commissioningEngineer;
VerifyOtpModel _verifyOtpModel = VerifyOtpModel(); VerifyOtpModel _verifyOtpModel = VerifyOtpModel();
@ -443,6 +446,34 @@ class UserProvider extends ChangeNotifier {
} }
} }
Future<UserRotaModel?> getUserTodayRota(String startDate, String endDate) async {
Response response;
try {
response = await ApiManager.instance.get(URLs.getUserRota + "?fromDate=$startDate&toDate=$endDate");
if (response.statusCode >= 200 && response.statusCode < 300) {
List dataList = json.decode(response.body);
return UserRotaModel.fromJson(dataList.first);
}
return null;
} catch (error) {
return null;
}
}
Future<List<UserRotaModel>> getUserMonthlyRota(String startDate, String endDate) async {
Response response;
try {
response = await ApiManager.instance.get(URLs.getUserRota + "?fromDate=$startDate&toDate=$endDate");
if (response.statusCode >= 200 && response.statusCode < 300) {
List dataList = json.decode(response.body);
return dataList.map((e) => UserRotaModel.fromJson(e)).toList();
}
return [];
} catch (error) {
return [];
}
}
Future<int> getSwipeTransactionHistory({required String userId, required DateTime dateFrom, required DateTime dateTo}) async { Future<int> getSwipeTransactionHistory({required String userId, required DateTime dateFrom, required DateTime dateTo}) async {
isLoading = true; isLoading = true;
notifyListeners(); notifyListeners();

@ -14,6 +14,8 @@ extension BuildContextExtension on BuildContext {
bool get isDark => Provider.of<SettingProvider>(this).theme == "dark"; bool get isDark => Provider.of<SettingProvider>(this).theme == "dark";
bool get isDarkNotListen => Provider.of<SettingProvider>(this, listen: false).theme == "dark";
bool get isAr => Provider.of<SettingProvider>(this).language == "ar"; bool get isAr => Provider.of<SettingProvider>(this).language == "ar";
SettingProvider get settingProvider => Provider.of<SettingProvider>(this, listen: false); SettingProvider get settingProvider => Provider.of<SettingProvider>(this, listen: false);

@ -6,6 +6,11 @@ extension StringExtensions on String {
void get showToast => Fluttertoast.showToast(msg: this); void get showToast => Fluttertoast.showToast(msg: this);
String get toTime {
DateTime dateTime = DateFormat("HH:mm:ss").parse(this);
return DateFormat('hh:mm a').format(dateTime);
}
String get chatMsgTime { String get chatMsgTime {
DateTime dateTime = DateTime.parse(this).toLocal(); DateTime dateTime = DateTime.parse(this).toLocal();
return DateFormat('hh:mm a').format(dateTime); return DateFormat('hh:mm a').format(dateTime);

@ -186,5 +186,5 @@ extension WidgetExtensions on Widget {
} }
extension DividerExtension on Divider { extension DividerExtension on Divider {
Divider defaultStyle(BuildContext context) => Divider(thickness: 1, color: context.isDark ? AppColor.neutral20 : AppColor.neutral30); Divider defaultStyle(BuildContext context) => Divider(thickness: 1, color: context.isDarkNotListen ? AppColor.neutral20 : AppColor.neutral30);
} }

@ -0,0 +1,108 @@
class UserRotaModel {
String? employeeNumber;
String? scheduleDate;
String? shiftName;
String? breakTime;
String? shiftActualStartDatetime;
String? shTActualStartTime;
String? shiftActualEndDateTime;
String? shTActualEndTime;
String? approvedStartDatetime;
String? approvedStartTime;
String? approvedStartReasonDesc;
String? approvedEndDatetime;
String? approvedEndTime;
String? approvedEndReasonDesc;
String? remarks;
String? leaveTypeCode;
String? leaveDescription;
int? assetGroupId;
String? assetGroupName;
int? id;
String? createdBy;
String? createdDate;
String? modifiedBy;
String? modifiedDate;
UserRotaModel(
{this.employeeNumber,
this.scheduleDate,
this.shiftName,
this.breakTime,
this.shiftActualStartDatetime,
this.shTActualStartTime,
this.shiftActualEndDateTime,
this.shTActualEndTime,
this.approvedStartDatetime,
this.approvedStartTime,
this.approvedStartReasonDesc,
this.approvedEndDatetime,
this.approvedEndTime,
this.approvedEndReasonDesc,
this.remarks,
this.leaveTypeCode,
this.leaveDescription,
this.assetGroupId,
this.assetGroupName,
this.id,
this.createdBy,
this.createdDate,
this.modifiedBy,
this.modifiedDate});
UserRotaModel.fromJson(Map<String, dynamic> json) {
employeeNumber = json['employeeNumber'];
scheduleDate = json['scheduleDate'];
shiftName = json['shiftName'];
breakTime = json['break'];
shiftActualStartDatetime = json['shiftActualStartDatetime'];
shTActualStartTime = json['shTActualStartTime'];
shiftActualEndDateTime = json['shiftActualEndDateTime'];
shTActualEndTime = json['shTActualEndTime'];
approvedStartDatetime = json['approvedStartDatetime'];
approvedStartTime = json['approvedStartTime'];
approvedStartReasonDesc = json['approvedStartReasonDesc'];
approvedEndDatetime = json['approvedEndDatetime'];
approvedEndTime = json['approvedEndTime'];
approvedEndReasonDesc = json['approvedEndReasonDesc'];
remarks = json['remarks'];
leaveTypeCode = json['leaveTypeCode'];
leaveDescription = json['leaveDescription'];
assetGroupId = json['assetGroupId'];
assetGroupName = json['assetGroupName'];
id = json['id'];
createdBy = json['createdBy'];
createdDate = json['createdDate'];
modifiedBy = json['modifiedBy'];
modifiedDate = json['modifiedDate'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['employeeNumber'] = this.employeeNumber;
data['scheduleDate'] = this.scheduleDate;
data['shiftName'] = this.shiftName;
data['break'] = this.breakTime;
data['shiftActualStartDatetime'] = this.shiftActualStartDatetime;
data['shTActualStartTime'] = this.shTActualStartTime;
data['shiftActualEndDateTime'] = this.shiftActualEndDateTime;
data['shTActualEndTime'] = this.shTActualEndTime;
data['approvedStartDatetime'] = this.approvedStartDatetime;
data['approvedStartTime'] = this.approvedStartTime;
data['approvedStartReasonDesc'] = this.approvedStartReasonDesc;
data['approvedEndDatetime'] = this.approvedEndDatetime;
data['approvedEndTime'] = this.approvedEndTime;
data['approvedEndReasonDesc'] = this.approvedEndReasonDesc;
data['remarks'] = this.remarks;
data['leaveTypeCode'] = this.leaveTypeCode;
data['leaveDescription'] = this.leaveDescription;
data['assetGroupId'] = this.assetGroupId;
data['assetGroupName'] = this.assetGroupName;
data['id'] = this.id;
data['createdBy'] = this.createdBy;
data['createdDate'] = this.createdDate;
data['modifiedBy'] = this.modifiedBy;
data['modifiedDate'] = this.modifiedDate;
return data;
}
}

@ -10,22 +10,24 @@ import '../app_style/app_color.dart';
class AppDashedButton extends StatelessWidget { class AppDashedButton extends StatelessWidget {
final String title; final String title;
final VoidCallback onPressed; final VoidCallback onPressed;
double? width;
double? height; double? height;
Color? buttonColor; Color? buttonColor;
Widget? icon; Widget? icon;
EdgeInsets? padding;
AppDashedButton({required this.title, required this.onPressed, Key? key, this.height, this.icon, this.buttonColor}) : super(key: key); AppDashedButton({required this.title, required this.onPressed, Key? key, this.height, this.icon, this.buttonColor, this.padding, this.width}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
width: double.infinity, width: width ?? double.infinity,
height: height, height: height,
padding: EdgeInsets.symmetric(horizontal: 2.toScreenWidth), padding: padding ?? EdgeInsets.symmetric(horizontal: 2.toScreenWidth),
decoration: BoxDecoration(color: AppColor.background(context), borderRadius: BorderRadius.circular(10)), decoration: BoxDecoration(color: AppColor.background(context), borderRadius: BorderRadius.circular(10)),
child: DottedBorder( child: DottedBorder(
strokeWidth: 1, strokeWidth: 1,
padding: EdgeInsets.symmetric(vertical: 16.toScreenHeight, horizontal: 16.toScreenWidth), padding: padding ?? EdgeInsets.symmetric(vertical: 16.toScreenHeight, horizontal: 16.toScreenWidth),
color: context.isDark ? AppColor.primary40 : buttonColor ?? AppColor.black20, color: context.isDark ? AppColor.primary40 : buttonColor ?? AppColor.black20,
dashPattern: const [4, 3], dashPattern: const [4, 3],
radius: const Radius.circular(10), radius: const Radius.circular(10),

@ -3,18 +3,23 @@ import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:image_cropper/image_cropper.dart'; import 'package:image_cropper/image_cropper.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:table_calendar/table_calendar.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';
import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/user.dart'; import 'package:test_sa/models/user.dart';
import 'package:test_sa/models/user_rota_model.dart';
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
import 'package:test_sa/new_views/common_widgets/app_dashed_button.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart'; import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
import 'package:test_sa/views/pages/user/update_user_contact_info_bottomsheet.dart'; import 'package:test_sa/views/pages/user/update_user_contact_info_bottomsheet.dart';
import '../../../new_views/app_style/app_color.dart'; import '../../../new_views/app_style/app_color.dart';
class ProfilePage extends StatefulWidget { class ProfilePage extends StatefulWidget {
@ -28,20 +33,28 @@ class ProfilePage extends StatefulWidget {
class _ProfilePageState extends State<ProfilePage> { class _ProfilePageState extends State<ProfilePage> {
late UserProvider _userProvider; late UserProvider _userProvider;
late SettingProvider _settingProvider; late DateTime _initialDate, _firstDate, _lastDate;
late double _width;
late double _height;
User _user = User(); User _user = User();
bool _firstTime = true; bool _firstTime = true;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>(); final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
bool isTodayRota = true;
@override
void initState() {
super.initState();
_initialDate = DateTime.now();
_firstDate = DateTime.utc(2010, 10, 16);
_lastDate = DateTime.utc(2030, 3, 14);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
_userProvider = Provider.of<UserProvider>(context); _userProvider = Provider.of<UserProvider>(context);
_settingProvider = Provider.of<SettingProvider>(context); // _settingProvider = Provider.of<SettingProvider>(context);
_width = MediaQuery.of(context).size.width; // _width = MediaQuery.of(context).size.width;
_height = MediaQuery.of(context).size.height; // _height = MediaQuery.of(context).size.height;
if (_firstTime) { if (_firstTime) {
_user = User.fromJsonCons(_userProvider.user!.toJson()); _user = User.fromJsonCons(_userProvider.user!.toJson());
@ -51,8 +64,9 @@ class _ProfilePageState extends State<ProfilePage> {
return Scaffold( return Scaffold(
key: _scaffoldKey, key: _scaffoldKey,
appBar: DefaultAppBar(title: context.translation.myProfile), appBar: DefaultAppBar(title: context.translation.myProfile),
body: SafeArea( body: Column(
child: ListView( children: [
ListView(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
children: [ children: [
Column( Column(
@ -86,41 +100,41 @@ class _ProfilePageState extends State<ProfilePage> {
), ),
), ),
), ),
CircleAvatar( // CircleAvatar(
radius: 14, // radius: 14,
backgroundColor: AppColor.primary70, // backgroundColor: AppColor.primary70,
child: Padding( // child: Padding(
padding: const EdgeInsets.all(1), // Border radius // padding: const EdgeInsets.all(1), // Border radius
child: snapshot.isLoading // child: snapshot.isLoading
? const SizedBox(height: 16, width: 16, child: CircularProgressIndicator(color: Colors.white, strokeWidth: 2)) // ? const SizedBox(height: 16, width: 16, child: CircularProgressIndicator(color: Colors.white, strokeWidth: 2))
: const Icon(Icons.upload, size: 16, color: Colors.white), // : const Icon(Icons.upload, size: 16, color: Colors.white),
), // ),
).onPress(snapshot.isLoading // ).onPress(snapshot.isLoading
? null // ? null
: () async { // : () async {
final pickedFile = await ImagePicker().pickImage(source: ImageSource.gallery, imageQuality: 70, maxWidth: 800, maxHeight: 800); // final pickedFile = await ImagePicker().pickImage(source: ImageSource.gallery, imageQuality: 70, maxWidth: 800, maxHeight: 800);
//
if (pickedFile != null) { // if (pickedFile != null) {
CroppedFile? croppedFile = await ImageCropper().cropImage( // CroppedFile? croppedFile = await ImageCropper().cropImage(
sourcePath: pickedFile.path, // sourcePath: pickedFile.path,
aspectRatio: CropAspectRatio(ratioX: 1, ratioY: 1), // aspectRatio: CropAspectRatio(ratioX: 1, ratioY: 1),
uiSettings: [ // uiSettings: [
AndroidUiSettings( // AndroidUiSettings(
toolbarTitle: 'ATOMS', // toolbarTitle: 'ATOMS',
toolbarColor: Colors.white, // toolbarColor: Colors.white,
toolbarWidgetColor: color, // toolbarWidgetColor: color,
initAspectRatio: CropAspectRatioPreset.square, // initAspectRatio: CropAspectRatioPreset.square,
lockAspectRatio: false, // lockAspectRatio: false,
), // ),
IOSUiSettings(title: 'ATOMS'), // IOSUiSettings(title: 'ATOMS'),
], // ],
); // );
if (croppedFile != null) { // if (croppedFile != null) {
await snapshot.uploadProfileImage(_user.userID!, File(croppedFile.path)); // await snapshot.uploadProfileImage(_user.userID!, File(croppedFile.path));
Provider.of<SettingProvider>(context, listen: false).setUser(_userProvider.user!); // Provider.of<SettingProvider>(context, listen: false).setUser(_userProvider.user!);
} // }
} // }
}), // }),
], ],
); );
}), }),
@ -142,7 +156,6 @@ class _ProfilePageState extends State<ProfilePage> {
'${context.translation.extensionNo}: ${_user.extensionNo ?? "-"}', '${context.translation.extensionNo}: ${_user.extensionNo ?? "-"}',
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
), ),
// if ((_user.phoneNumber ?? "").isNotEmpty) ...[ // if ((_user.phoneNumber ?? "").isNotEmpty) ...[
// const Divider().defaultStyle(context), // const Divider().defaultStyle(context),
// 8.height, // 8.height,
@ -160,8 +173,12 @@ class _ProfilePageState extends State<ProfilePage> {
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
itemCount: _user.departmentName?.length ?? 0, itemCount: _user.departmentName?.length ?? 0,
shrinkWrap: true, shrinkWrap: true,
padding: EdgeInsets.zero,
itemBuilder: (context, index) { itemBuilder: (context, index) {
return (_user.departmentName![index] ?? "N/A").heading5(context).paddingOnly(top: 8, bottom: 8); return Text(
_user.departmentName![index] ?? "N/A",
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
).paddingOnly(top: 2, bottom: 2);
}, },
), ),
if ((_user.clientName ?? "").isNotEmpty) ...[ if ((_user.clientName ?? "").isNotEmpty) ...[
@ -170,10 +187,89 @@ class _ProfilePageState extends State<ProfilePage> {
_user.clientName!.heading5(context).custom(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50), _user.clientName!.heading5(context).custom(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
8.height, 8.height,
], ],
Selector<UserProvider, bool>(
selector: (_, myModel) => myModel.isLoading, // Selects only the userName
builder: (_, isLoading, __) {
return AppDashedButton(
title: isLoading ? "Uploading..." : "Update Image",
height: 50,
width: MediaQuery.sizeOf(context).width / 2,
padding: EdgeInsets.all(4),
icon: isLoading
? const SizedBox(height: 16, width: 16, child: CircularProgressIndicator(color: AppColor.primary10, strokeWidth: 2))
: 'attachment_icon'.toSvgAsset(height: 24, width: 24),
buttonColor: AppColor.primary10,
onPressed: () async {
if (isLoading) return;
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,
aspectRatio: CropAspectRatio(ratioX: 1, ratioY: 1),
uiSettings: [
AndroidUiSettings(
toolbarTitle: 'ATOMS',
toolbarColor: Colors.white,
toolbarWidgetColor: color,
initAspectRatio: CropAspectRatioPreset.square,
lockAspectRatio: false,
),
IOSUiSettings(title: 'ATOMS'),
],
);
if (croppedFile != null) {
await context.userProvider.uploadProfileImage(_user.userID!, File(croppedFile.path));
Provider.of<SettingProvider>(context, listen: false).setUser(_userProvider.user!);
}
}
},
).center;
})
], ],
).toShadowContainer(context), ).toShadowContainer(context),
16.height, if (context.settingProvider.isUserFlowMedical)
AppFilledButton( Container(
margin: const EdgeInsets.only(top: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Rota Details",
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
),
8.width,
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: AppColor.primary10,
),
child: Text(
isTodayRota ? "Monthly " : "Today",
style: AppTextStyles.bodyText2.copyWith(color: Colors.white),
),
).onPress(() => setState(() {
_initialDate = DateTime.now();
isTodayRota = !isTodayRota;
})),
],
),
(isTodayRota ? todayRotaWidget() : monthRotaWidget())
],
).toShadowContainer(context),
),
],
).expanded,
FooterActionButton.footerContainer(
context: context,
child: AppFilledButton(
label: "Update Information", label: "Update Information",
buttonColor: context.isDark ? AppColor.primary10 : AppColor.neutral50, buttonColor: context.isDark ? AppColor.primary10 : AppColor.neutral50,
onPressed: () { onPressed: () {
@ -193,164 +289,207 @@ class _ProfilePageState extends State<ProfilePage> {
), ),
title: "Update Information"); title: "Update Information");
}, },
),
) )
], ],
), ),
// child: Stack( );
// children: [ }
// Form(
// key: _formKey, Widget todayRotaWidget() {
// child: ListView( final DateFormat fmt = DateFormat('MM-dd-yyyy');
// children: [ final String startStr = fmt.format(_initialDate);
// //AppNameBar(),
// Hero( return FutureBuilder<UserRotaModel?>(
// tag: "logo", future: _userProvider.getUserTodayRota(startStr, startStr),
// child: Image( builder: (context, snapshot) {
// height: _height / 4, bool isLoading = snapshot.connectionState == ConnectionState.waiting;
// image: AssetImage("assets/images/logo.png"), if ((!isLoading && (snapshot.hasError || !snapshot.hasData))) {
// ), return const SizedBox();
// ), }
// Container(
// padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16), return rotaDetailsWidget(isLoading, snapshot.data);
// margin: EdgeInsets.symmetric(horizontal: 16), },
// decoration: BoxDecoration(color: AColors.primaryColor, borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: [ );
// BoxShadow( }
// color: AColors.grey,
// offset: Offset(0, -1), Widget monthRotaWidget() {
// ) final DateTime startOfMonth = DateTime(_initialDate.year, _initialDate.month, 1);
// ]), final DateTime endOfMonth = DateTime(_initialDate.year, _initialDate.month + 1, 0);
// child: Column(
// children: [ final DateFormat fmt = DateFormat('MM-dd-yyyy');
// ATextFormField( final String startStr = fmt.format(startOfMonth);
// initialValue: _user.userName, final String endStr = fmt.format(endOfMonth);
// hintText: context.translation.name,
// enable: false, return FutureBuilder<List<UserRotaModel>>(
// prefixIconData: Icons.account_circle, future: _userProvider.getUserMonthlyRota(startStr, endStr),
// style: Theme.of(context).textTheme.headline6, builder: (context, snapshot) {
// validator: (value) => Validator.hasValue(value) ? null : context.translation.nameValidateMessage, bool isLoading = snapshot.connectionState == ConnectionState.waiting;
// onSaved: (value) { if ((!isLoading && (snapshot.hasError || !snapshot.hasData))) {
// _user.userName = value; return const SizedBox();
// }, }
// ),
// SizedBox( return TableCalendar(
// height: 8, firstDay: _firstDate,
// ), lastDay: _lastDate,
// ATextFormField( focusedDay: _initialDate,
// initialValue: _user.email, calendarFormat: CalendarFormat.month,
// hintText: context.translation.email, weekendDays: const [],
// enable: false, rowHeight: 45,
// prefixIconData: Icons.email, pageJumpingEnabled: true,
// textInputType: TextInputType.emailAddress, pageAnimationEnabled: true,
// style: Theme.of(context).textTheme.headline6, availableGestures: AvailableGestures.none,
// validator: (value) => Validator.isEmail(value) ? null : context.translation.emailValidateMessage, onPageChanged: (dateTime) {
// onSaved: (value) { _initialDate = dateTime;
// _user.email = value; setState(() {});
// }, },
// ), onDaySelected: (selectedDate, focusDate) {
// SizedBox( final List<UserRotaModel> matches = snapshot.data?.where((e) {
// height: 8, final dt = DateTime.tryParse(e.scheduleDate ?? '');
// ), return dt != null && isSameDay(dt, selectedDate);
// AbsorbPointer( }).toList() ??
// child: HospitalButton( [];
// hospital: Hospital(name: _user.clientName, id: _user.clientId),
// onHospitalPick: (hospital) { final UserRotaModel? rota = matches.isNotEmpty ? matches.first : null;
// _user.clientName = hospital.name;
// _user.clientId = hospital.id; if (rota == null) {
// setState(() {}); "No details found".showToast;
// }, return;
// ), }
// ),
// SizedBox( context.showBottomSheet(rotaDetailsWidget(isLoading, rota), title: "Rota Details".addTranslation);
// height: 8, },
// ), calendarBuilders: CalendarBuilders(
// // DepartmentButton( markerBuilder: (context, date, eventsOnDay) {
// // department: Department(name: _user.departmentName, id: _user.departmentId), if (isLoading) return null;
// // onDepartmentPick: (department) { final List<UserRotaModel> matches = snapshot.data?.where((e) {
// // _user.departmentName = department.name; final dt = DateTime.tryParse(e.scheduleDate ?? '');
// // _user.departmentId = department.id; return dt != null && isSameDay(dt, date);
// // setState(() {}); }).toList() ??
// // }, [];
// // ),
// SizedBox( final UserRotaModel? rota = matches.isNotEmpty ? matches.first : null;
// height: 8,
// ), if (rota == null) return null;
// ATextFormField( return Container(
// initialValue: _user.phoneNumber, width: 6,
// hintText: context.translation.phoneNumber, height: 6,
// style: Theme.of(context).textTheme.headline6, margin: const EdgeInsets.symmetric(horizontal: 1, vertical: 4),
// prefixIconData: Icons.phone_android, decoration: BoxDecoration(
// validator: (value) => Validator.isPhoneNumber(value) ? null : context.translation.phoneNumberValidateMessage, color: rota.leaveTypeCode == "ANNUAL"
// textInputType: TextInputType.phone, ? AppColor.red30
// onSaved: (value) { : rota.leaveTypeCode == "HOLIDAY"
// _user.phoneNumber = value; ? AppColor.green15
// }, : AppColor.primary10,
// ), shape: BoxShape.circle),
// SizedBox( );
// height: 8, },
// ), dowBuilder: (context, dateTime) {
// // ATextFormField( final day = DateFormat("EE", context.isAr ? "ar" : "en").format(dateTime).toUpperCase();
// // initialValue: _user.whatsApp, return Align(alignment: Alignment.center, child: day.bodyText(context).custom(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50));
// // hintText: context.translation.whatsApp, },
// // style: Theme.of(context).textTheme.headline6, defaultBuilder: (_cxt, dateTime, _) {
// // prefixIconData: FontAwesomeIcons.whatsapp, final day = DateFormat("d").format(dateTime);
// // prefixIconSize: 36, if (isLoading) {
// // validator: (value) => return const SizedBox(height: 36, width: 36).toShimmer(isShow: isLoading, context: _cxt);
// // Validator.isPhoneNumber(value) ? null : context.translation.phoneNumberValidateMessage, } else {
// // textInputType: TextInputType.phone, null;
// // onSaved: (value){ }
// // _user.whatsApp = value; },
// // }, ),
// // ), // eventLoader: (day) {
// ], // print("eventLoader:$day");
// ), // return [];
// ),
// 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),
// // ));
// // }
// }, // },
daysOfWeekHeight: 35.toScreenHeight,
headerStyle: HeaderStyle(
leftChevronVisible: true,
rightChevronVisible: true,
formatButtonVisible: false,
titleCentered: true,
titleTextStyle: AppTextStyles.bodyText,
headerPadding: const EdgeInsets.all(0),
),
calendarStyle: CalendarStyle(
isTodayHighlighted: false,
todayDecoration: const BoxDecoration(color: AppColor.primary10, shape: BoxShape.circle),
defaultTextStyle: AppTextStyles.bodyText,
defaultDecoration: BoxDecoration(shape: BoxShape.circle, color: context.isDark ? AppColor.neutral50 : AppColor.neutral30),
),
).paddingOnly(top: 16);
},
);
}
Widget rotaDetailsWidget(bool isLoading, UserRotaModel? userRota) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 16.height,
if (isLoading) ...[
Text(
'Shift Start Time Time',
style: AppTextStyles.bodyText.copyWith(color: context.isDarkNotListen ? AppColor.neutral10 : AppColor.neutral120),
).toShimmer(context: context, isShow: isLoading),
4.height,
Text(
'Shift Actual Actual Start Time',
style: AppTextStyles.bodyText.copyWith(color: context.isDarkNotListen ? AppColor.neutral10 : AppColor.neutral120),
).toShimmer(context: context, isShow: isLoading)
] else
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
// Text(
// 'Site: ${_user.clientName ?? "-"}',
// style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
// ), // ),
// ), Text(
// ), 'Shift Name: ${userRota!.shiftName ?? "-"}',
// SizedBox( style: AppTextStyles.bodyText.copyWith(color: context.isDarkNotListen ? AppColor.neutral10 : AppColor.neutral120),
// height: 32, ),
// ), Text(
// ], 'Break: ${userRota.breakTime ?? "-"}',
// ), style: AppTextStyles.bodyText.copyWith(color: context.isDarkNotListen ? AppColor.neutral10 : AppColor.neutral120),
// ),
// ABackButton(),
// ],
// ),
), ),
if (userRota.leaveTypeCode?.isNotEmpty ?? false)
SizedBox(
width: double.infinity,
child: Column(children: [
8.height,
Text(
userRota.leaveTypeCode ?? "",
style: AppTextStyles.heading6.copyWith(color: context.isDarkNotListen ? AppColor.neutral10 : AppColor.neutral120, fontWeight: FontWeight.w600),
),
Text(
userRota.leaveDescription ?? "",
style: AppTextStyles.bodyText.copyWith(color: context.isDarkNotListen ? AppColor.neutral10 : AppColor.neutral120),
),
]),
)
else ...[
Text(
'Shift Start Time: ${userRota.shiftName?.split('-').first.trim() ?? "-"}',
style: AppTextStyles.bodyText.copyWith(color: context.isDarkNotListen ? AppColor.neutral10 : AppColor.neutral120),
),
Text(
'Shift End Time: ${userRota.shiftName?.split('-').last.trim() ?? "-"}',
style: AppTextStyles.bodyText.copyWith(color: context.isDarkNotListen ? AppColor.neutral10 : AppColor.neutral120),
),
const Divider().defaultStyle(context),
Text(
'Swipe In: ${userRota.shTActualStartTime?.toTime ?? "-"}',
style: AppTextStyles.bodyText.copyWith(color: context.isDarkNotListen ? AppColor.neutral10 : AppColor.neutral120),
),
Text(
'Swipe Out: ${userRota.shTActualEndTime?.toTime ?? "-"}',
style: AppTextStyles.bodyText.copyWith(color: context.isDarkNotListen ? AppColor.neutral10 : AppColor.neutral120),
),
],
],
),
],
); );
} }
} }

Loading…
Cancel
Save