Merge branch 'refs/heads/design_3.0_TM_Module' into design_3.0_task_module_new_merge
# Conflicts: # lib/modules/cm_module/service_request_detail_provider.dart # lib/new_views/pages/land_page/land_page.dart # lib/views/pages/device_transfer/update_device_transfer.dartdesign_3.0_TM_Module_snagsFix
commit
ca1ff5892e
@ -0,0 +1,291 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/string_extensions.dart';
|
||||
import 'package:test_sa/extensions/text_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/models/new_models/work_order_detail_model.dart';
|
||||
import 'package:test_sa/modules/cm_module/service_request_detail_provider.dart';
|
||||
import 'package:test_sa/modules/cm_module/utilities/service_request_utils.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
||||
import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
|
||||
import 'package:test_sa/views/widgets/date_and_time/date_picker.dart';
|
||||
import 'package:test_sa/views/widgets/status/report/service_report_assistant_employee_menu.dart';
|
||||
|
||||
class AssistantEmployeeList extends StatefulWidget {
|
||||
final List<AssistantEmployeesModel>? assistantEmployeeList;
|
||||
final ValueChanged<List<AssistantEmployeesModel>>? onListChanged;
|
||||
final double? cardPadding;
|
||||
final dynamic assetId;
|
||||
|
||||
const AssistantEmployeeList({
|
||||
super.key,
|
||||
this.assistantEmployeeList,
|
||||
this.onListChanged,
|
||||
required this.assetId,
|
||||
this.cardPadding,
|
||||
});
|
||||
|
||||
@override
|
||||
State<AssistantEmployeeList> createState() => _AssistantEmployeeListState();
|
||||
}
|
||||
|
||||
class _AssistantEmployeeListState extends State<AssistantEmployeeList> {
|
||||
late List<AssistantEmployeesModel> _list;
|
||||
late List<TextEditingController> _controllers;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_list = List<AssistantEmployeesModel>.from(widget.assistantEmployeeList ?? []);
|
||||
_controllers = _list.map((e) => TextEditingController(text: e.workingHours?.toString() ?? '')).toList();
|
||||
}
|
||||
|
||||
void _addNewEntry() {
|
||||
setState(() {
|
||||
_list.add(AssistantEmployeesModel());
|
||||
_controllers.add(TextEditingController());
|
||||
});
|
||||
widget.onListChanged?.call(_list);
|
||||
}
|
||||
|
||||
void _removeEntry(int index) {
|
||||
setState(() {
|
||||
_list.removeAt(index);
|
||||
_controllers.removeAt(index);
|
||||
});
|
||||
widget.onListChanged?.call(_list);
|
||||
}
|
||||
|
||||
void _updateModel(int index, void Function(AssistantEmployeesModel model) updateList) {
|
||||
setState(() {
|
||||
updateList(_list[index]);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isReadOnly = Provider.of<ServiceRequestDetailProvider>(context, listen: false).isReadOnlyRequest;
|
||||
return ListView.builder(
|
||||
itemCount: _list.length + 1,
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: EdgeInsets.all(widget.cardPadding ?? 16),
|
||||
itemBuilder: (context, index) {
|
||||
if (index == _list.length) {
|
||||
return Visibility(
|
||||
visible: !isReadOnly,
|
||||
child: AppFilledButton(
|
||||
label: "Add Assistant Employee".addTranslation,
|
||||
maxWidth: true,
|
||||
textColor: AppColor.black10,
|
||||
buttonColor: context.isDark ? AppColor.neutral60 : AppColor.white10,
|
||||
icon: Icon(Icons.add_circle, color: AppColor.blueStatus(context)),
|
||||
showIcon: true,
|
||||
onPressed: _addNewEntry,
|
||||
),
|
||||
);
|
||||
}
|
||||
return EmployeeCard(
|
||||
model: _list[index],
|
||||
assetId: widget.assetId,
|
||||
index: index,
|
||||
isReadOnly: isReadOnly,
|
||||
onUpdate: (updateList) => _updateModel(index, updateList),
|
||||
onRemove: () => _removeEntry(index),
|
||||
workingHoursController: _controllers[index],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class EmployeeCard extends StatelessWidget {
|
||||
final AssistantEmployeesModel model;
|
||||
final int index;
|
||||
final bool isReadOnly;
|
||||
final dynamic assetId;
|
||||
|
||||
final void Function(void Function(AssistantEmployeesModel model)) onUpdate;
|
||||
final VoidCallback onRemove;
|
||||
final TextEditingController workingHoursController;
|
||||
|
||||
const EmployeeCard({
|
||||
super.key,
|
||||
required this.model,
|
||||
required this.assetId,
|
||||
required this.index,
|
||||
required this.isReadOnly,
|
||||
required this.onUpdate,
|
||||
required this.onRemove,
|
||||
required this.workingHoursController,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final requestedDate = Provider.of<ServiceRequestDetailProvider>(context, listen: false).currentWorkOrder?.data?.requestedDate;
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
context.translation.assistantEmployee.bodyText(context).custom(color: AppColor.black20),
|
||||
if (!isReadOnly)
|
||||
Container(
|
||||
height: 32,
|
||||
width: 32,
|
||||
padding: const EdgeInsets.all(6),
|
||||
child: "trash".toSvgAsset(height: 20, width: 20),
|
||||
).onPress(onRemove),
|
||||
],
|
||||
),
|
||||
8.height,
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
ServiceReportAssistantEmployeeMenu(
|
||||
title: context.translation.select,
|
||||
backgroundColor: AppColor.neutral100,
|
||||
assetId: assetId,
|
||||
initialValue: model.employee,
|
||||
onSelect: (employee) {
|
||||
if (employee != null) {
|
||||
onUpdate((model) {
|
||||
model.employee = employee.copyWith(id: 0);
|
||||
model.user = AssignedEmployee(
|
||||
userId: employee.user?.id,
|
||||
userName: employee.user?.name,
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
8.height,
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ADatePicker(
|
||||
label: context.translation.startTime,
|
||||
hideShadow: true,
|
||||
backgroundColor: AppColor.neutral100,
|
||||
date: model.startDate,
|
||||
formatDateWithTime: true,
|
||||
from: requestedDate,
|
||||
onDatePicker: (selectedDate) {
|
||||
showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.now(),
|
||||
).then((selectedTime) {
|
||||
if (selectedTime != null) {
|
||||
final selectedDateTime = DateTime(
|
||||
selectedDate.year,
|
||||
selectedDate.month,
|
||||
selectedDate.day,
|
||||
selectedTime.hour,
|
||||
selectedTime.minute,
|
||||
);
|
||||
|
||||
if (requestedDate != null && selectedDateTime.isBefore(requestedDate)) {
|
||||
"Start time is before the request time.".showToast;
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedDateTime.isAfter(DateTime.now())) {
|
||||
"Start time is after the current time".showToast;
|
||||
return;
|
||||
}
|
||||
|
||||
onUpdate((model) {
|
||||
model.startDate = selectedDateTime;
|
||||
ServiceRequestUtils.calculateAndAssignWorkingHours(
|
||||
startTime: model.startDate,
|
||||
endTime: model.endDate,
|
||||
workingHoursController: workingHoursController,
|
||||
updateModel: (hours) => model.workingHours = hours,
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
).expanded,
|
||||
8.width,
|
||||
ADatePicker(
|
||||
label: context.translation.endTime,
|
||||
hideShadow: true,
|
||||
backgroundColor: AppColor.neutral100,
|
||||
date: model.endDate,
|
||||
formatDateWithTime: true,
|
||||
from: requestedDate,
|
||||
onDatePicker: (selectedDate) {
|
||||
showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.now(),
|
||||
).then((selectedTime) {
|
||||
if (selectedTime != null) {
|
||||
final endDateTime = DateTime(
|
||||
selectedDate.year,
|
||||
selectedDate.month,
|
||||
selectedDate.day,
|
||||
selectedTime.hour,
|
||||
selectedTime.minute,
|
||||
);
|
||||
|
||||
if (!endDateTime.isBefore(DateTime.now())) {
|
||||
"Please select a time before the current time.".showToast;
|
||||
return;
|
||||
}
|
||||
|
||||
if (model.startDate == null || !endDateTime.isAfter(model.startDate!)) {
|
||||
"End date must be after start date".showToast;
|
||||
return;
|
||||
}
|
||||
|
||||
onUpdate((model) {
|
||||
model.endDate = endDateTime;
|
||||
ServiceRequestUtils.calculateAndAssignWorkingHours(
|
||||
startTime: model.startDate,
|
||||
endTime: model.endDate,
|
||||
workingHoursController: workingHoursController,
|
||||
updateModel: (hours) => model.workingHours = hours,
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
).expanded,
|
||||
],
|
||||
),
|
||||
8.height,
|
||||
AppTextFormField(
|
||||
labelText: context.translation.workingHours,
|
||||
backgroundColor: AppColor.neutral80,
|
||||
controller: workingHoursController,
|
||||
suffixIcon: "clock".toSvgAsset(width: 20, color: context.isDark ? AppColor.neutral10 : null).paddingOnly(end: 16),
|
||||
textAlign: TextAlign.center,
|
||||
enable: false,
|
||||
showShadow: false,
|
||||
labelStyle: AppTextStyles.textFieldLabelStyle,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
8.height,
|
||||
AppTextFormField(
|
||||
initialValue: model.technicalComment,
|
||||
labelText: context.translation.technicalComment,
|
||||
backgroundColor: AppColor.neutral100,
|
||||
showShadow: false,
|
||||
labelStyle: AppTextStyles.textFieldLabelStyle,
|
||||
alignLabelWithHint: true,
|
||||
textInputType: TextInputType.multiline,
|
||||
onChange: (value) => onUpdate((model) => model.technicalComment = value),
|
||||
// onSaved: (value) => onUpdate((model) => model.technicalComment = value),
|
||||
),
|
||||
8.height,
|
||||
],
|
||||
)
|
||||
],
|
||||
).toShadowContainer(context, paddingObject: const EdgeInsets.symmetric(horizontal: 16, vertical: 12)).paddingOnly(bottom: 12);
|
||||
}
|
||||
}
|
||||
@ -1,217 +1,217 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/notification/firebase_notification_manger.dart';
|
||||
import 'package:test_sa/controllers/notification/notification_manger.dart';
|
||||
import 'package:test_sa/controllers/providers/api/all_requests_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/notifications_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/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/text_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
import 'package:test_sa/dashboard_latest/widgets/progress_fragment.dart';
|
||||
import 'package:test_sa/dashboard_latest/widgets/recent_activites_fragment.dart';
|
||||
import 'package:test_sa/dashboard_latest/widgets/requests_fragment.dart';
|
||||
import 'package:test_sa/views/pages/user/notifications/notifications_page.dart';
|
||||
|
||||
class DashboardPage extends StatefulWidget {
|
||||
final VoidCallback onDrawerPress;
|
||||
|
||||
const DashboardPage({Key? key,required this.onDrawerPress}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<DashboardPage> createState() => _DashboardPageState();
|
||||
}
|
||||
|
||||
class _DashboardPageState extends State<DashboardPage> {
|
||||
int _currentPage = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
getAllRequests();
|
||||
}
|
||||
|
||||
void getAllRequests() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
Provider.of<AllRequestsProvider>(context, listen: false).getRequests();
|
||||
Provider.of<NotificationsProvider>(context, listen: false).getSystemNotifications(user: Provider.of<UserProvider>(context, listen: false).user!, resetProvider: true);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
bool isFCM = true;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (isFCM) {
|
||||
FirebaseNotificationManger.initialized(context);
|
||||
NotificationManger.initialisation((notificationDetails) {
|
||||
FirebaseNotificationManger.handleMessage(context, json.decode(notificationDetails.payload!));
|
||||
}, (id, title, body, payload) async {});
|
||||
|
||||
isFCM = false;
|
||||
}
|
||||
final User user = Provider.of<UserProvider>(context, listen: false).user!;
|
||||
final setting = Provider.of<SettingProvider>(context, listen: false);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
automaticallyImplyLeading: false,
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
titleSpacing: 0,
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Consumer<UserProvider>(builder: (context, snapshot, _) {
|
||||
return CircleAvatar(
|
||||
radius: 24,
|
||||
backgroundColor: context.isDark ? AppColor.neutral50 : AppColor.neutral40,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(1), // Border radius
|
||||
child: ClipOval(
|
||||
child: snapshot.profileImage != null
|
||||
? Image.file(snapshot.profileImage!)
|
||||
: (snapshot.user?.profilePhotoName?.isNotEmpty ?? false)
|
||||
? Image.network(snapshot.user!.profilePhotoName!)
|
||||
: const Icon(Icons.person, size: 24, color: Colors.white),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).onPress(widget.onDrawerPress),
|
||||
const Spacer(),
|
||||
Container(
|
||||
padding: const EdgeInsets.fromLTRB(12, 6, 6, 6),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
color: AppColor.background(context),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x07000000),
|
||||
blurRadius: 14,
|
||||
offset: Offset(0, 0),
|
||||
spreadRadius: 0,
|
||||
)
|
||||
],
|
||||
),
|
||||
child: DropdownButton<AssetGroup>(
|
||||
value: setting.assetGroup,
|
||||
//iconSize: 24,
|
||||
isDense: true,
|
||||
icon: const Icon(Icons.keyboard_arrow_down),
|
||||
elevation: 8,
|
||||
// dropdownColor: Colors.amber,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
style: TextStyle(color: Theme.of(context).primaryColor),
|
||||
underline: const SizedBox.shrink(),
|
||||
onChanged: (newValue) {
|
||||
if (setting.assetGroup != newValue) {
|
||||
Provider.of<SettingProvider>(context, listen: false).setAssetGroup(newValue);
|
||||
setState(() {});
|
||||
getAllRequests();
|
||||
}
|
||||
},
|
||||
items: user.assetGroups!.map<DropdownMenuItem<AssetGroup>>((value) {
|
||||
return DropdownMenuItem<AssetGroup>(
|
||||
value: value,
|
||||
child: Text(
|
||||
value.name ?? "",
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
16.width,
|
||||
Stack(
|
||||
alignment: Alignment.topRight,
|
||||
children: [
|
||||
Icon(Icons.notifications, color: context.isDark ? AppColor.neutral30 : AppColor.neutral20, size: 30).paddingOnly(top: 6, end: 0),
|
||||
// todo @sikander will add count for unread notifications
|
||||
// Positioned(
|
||||
// top: 0,
|
||||
// right: 0,
|
||||
// child: Container(
|
||||
// padding: const EdgeInsets.all(4),
|
||||
// decoration: const ShapeDecoration(
|
||||
// color: Color(0xFFD02127),
|
||||
// shape: CircleBorder(),
|
||||
// ),
|
||||
// child: Text("", style: AppTextStyles.bodyText),
|
||||
// ),
|
||||
// )
|
||||
],
|
||||
).onPress(() {
|
||||
Navigator.of(context).pushNamed(NotificationsPage.id);
|
||||
}),
|
||||
],
|
||||
).paddingOnly(start: 16, end: 16),
|
||||
),
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
context.translation.welcome,
|
||||
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
|
||||
),
|
||||
Text(
|
||||
user.username ?? "",
|
||||
style: AppTextStyles.heading2.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50, fontWeight: FontWeight.w600),
|
||||
),
|
||||
24.height,
|
||||
Row(
|
||||
children: [
|
||||
indicatorView(0),
|
||||
3.width,
|
||||
indicatorView(1),
|
||||
3.width,
|
||||
indicatorView(2),
|
||||
10.width,
|
||||
"0${_currentPage + 1}/03".tinyFont(context).custom(fontWeight: FontWeight.w500, color: context.isDark ? AppColor.neutral30 : AppColor.neutral60),
|
||||
],
|
||||
),
|
||||
],
|
||||
).paddingOnly(start: 16, end: 16, top: 8, bottom: 8),
|
||||
PageView(
|
||||
onPageChanged: (index) => setState(() => _currentPage = index),
|
||||
children: [
|
||||
const RequestsFragment(),
|
||||
ProgressFragment(),
|
||||
const RecentActivitiesFragment(),
|
||||
],
|
||||
).expanded,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget indicatorView(int index) {
|
||||
bool isActive = _currentPage == index;
|
||||
|
||||
return AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 250),
|
||||
width: (isActive ? 30 : 12).toScreenWidth,
|
||||
height: 9.toScreenHeight,
|
||||
decoration: BoxDecoration(
|
||||
color: isActive
|
||||
? AppColor.greenStatus(context)
|
||||
: context.isDark
|
||||
? AppColor.neutral20
|
||||
: AppColor.neutral40,
|
||||
borderRadius: BorderRadius.circular(8)),
|
||||
);
|
||||
}
|
||||
}
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
// import 'package:test_sa/controllers/notification/firebase_notification_manger.dart';
|
||||
// import 'package:test_sa/controllers/notification/notification_manger.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/all_requests_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/notifications_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/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/extensions/int_extensions.dart';
|
||||
// import 'package:test_sa/extensions/text_extensions.dart';
|
||||
// import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
// import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
// import 'package:test_sa/dashboard_latest/widgets/progress_fragment.dart';
|
||||
// import 'package:test_sa/dashboard_latest/widgets/recent_activites_fragment.dart';
|
||||
// import 'package:test_sa/dashboard_latest/widgets/requests_fragment.dart';
|
||||
// import 'package:test_sa/views/pages/user/notifications/notifications_page.dart';
|
||||
//
|
||||
// class DashboardPage extends StatefulWidget {
|
||||
// final VoidCallback onDrawerPress; //todo @delete
|
||||
//
|
||||
// const DashboardPage({Key? key,required this.onDrawerPress}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// State<DashboardPage> createState() => _DashboardPageState();
|
||||
// }
|
||||
//
|
||||
// class _DashboardPageState extends State<DashboardPage> {
|
||||
// int _currentPage = 0;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// getAllRequests();
|
||||
// }
|
||||
//
|
||||
// void getAllRequests() {
|
||||
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// Provider.of<AllRequestsProvider>(context, listen: false).getRequests();
|
||||
// Provider.of<NotificationsProvider>(context, listen: false).getSystemNotifications(user: Provider.of<UserProvider>(context, listen: false).user!, resetProvider: true);
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void dispose() {
|
||||
// super.dispose();
|
||||
// }
|
||||
//
|
||||
// bool isFCM = true;
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// if (isFCM) {
|
||||
// FirebaseNotificationManger.initialized(context);
|
||||
// NotificationManger.initialisation((notificationDetails) {
|
||||
// FirebaseNotificationManger.handleMessage(context, json.decode(notificationDetails.payload!));
|
||||
// }, (id, title, body, payload) async {});
|
||||
//
|
||||
// isFCM = false;
|
||||
// }
|
||||
// final User user = Provider.of<UserProvider>(context, listen: false).user!;
|
||||
// final setting = Provider.of<SettingProvider>(context, listen: false);
|
||||
// return Scaffold(
|
||||
// appBar: AppBar(
|
||||
// automaticallyImplyLeading: false,
|
||||
// backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
// titleSpacing: 0,
|
||||
// title: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
// children: [
|
||||
// Consumer<UserProvider>(builder: (context, snapshot, _) {
|
||||
// return CircleAvatar(
|
||||
// radius: 24,
|
||||
// backgroundColor: context.isDark ? AppColor.neutral50 : AppColor.neutral40,
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(1), // Border radius
|
||||
// child: ClipOval(
|
||||
// child: snapshot.profileImage != null
|
||||
// ? Image.file(snapshot.profileImage!)
|
||||
// : (snapshot.user?.profilePhotoName?.isNotEmpty ?? false)
|
||||
// ? Image.network(snapshot.user!.profilePhotoName!)
|
||||
// : const Icon(Icons.person, size: 24, color: Colors.white),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }).onPress(widget.onDrawerPress),
|
||||
// const Spacer(),
|
||||
// Container(
|
||||
// padding: const EdgeInsets.fromLTRB(12, 6, 6, 6),
|
||||
// decoration: BoxDecoration(
|
||||
// borderRadius: BorderRadius.circular(8),
|
||||
// color: AppColor.background(context),
|
||||
// boxShadow: const [
|
||||
// BoxShadow(
|
||||
// color: Color(0x07000000),
|
||||
// blurRadius: 14,
|
||||
// offset: Offset(0, 0),
|
||||
// spreadRadius: 0,
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// child: DropdownButton<AssetGroup>(
|
||||
// value: setting.assetGroup,
|
||||
// //iconSize: 24,
|
||||
// isDense: true,
|
||||
// icon: const Icon(Icons.keyboard_arrow_down),
|
||||
// elevation: 8,
|
||||
// // dropdownColor: Colors.amber,
|
||||
// borderRadius: BorderRadius.circular(8),
|
||||
// style: TextStyle(color: Theme.of(context).primaryColor),
|
||||
// underline: const SizedBox.shrink(),
|
||||
// onChanged: (newValue) {
|
||||
// if (setting.assetGroup != newValue) {
|
||||
// Provider.of<SettingProvider>(context, listen: false).setAssetGroup(newValue);
|
||||
// setState(() {});
|
||||
// getAllRequests();
|
||||
// }
|
||||
// },
|
||||
// items: user.assetGroups!.map<DropdownMenuItem<AssetGroup>>((value) {
|
||||
// return DropdownMenuItem<AssetGroup>(
|
||||
// value: value,
|
||||
// child: Text(
|
||||
// value.name ?? "",
|
||||
// style: Theme.of(context).textTheme.bodyLarge,
|
||||
// ),
|
||||
// );
|
||||
// }).toList(),
|
||||
// ),
|
||||
// ),
|
||||
// 16.width,
|
||||
// Stack(
|
||||
// alignment: Alignment.topRight,
|
||||
// children: [
|
||||
// Icon(Icons.notifications, color: context.isDark ? AppColor.neutral30 : AppColor.neutral20, size: 30).paddingOnly(top: 6, end: 0),
|
||||
// // todo @sikander will add count for unread notifications
|
||||
// // Positioned(
|
||||
// // top: 0,
|
||||
// // right: 0,
|
||||
// // child: Container(
|
||||
// // padding: const EdgeInsets.all(4),
|
||||
// // decoration: const ShapeDecoration(
|
||||
// // color: Color(0xFFD02127),
|
||||
// // shape: CircleBorder(),
|
||||
// // ),
|
||||
// // child: Text("", style: AppTextStyles.bodyText),
|
||||
// // ),
|
||||
// // )
|
||||
// ],
|
||||
// ).onPress(() {
|
||||
// Navigator.of(context).pushNamed(NotificationsPage.id);
|
||||
// }),
|
||||
// ],
|
||||
// ).paddingOnly(start: 16, end: 16),
|
||||
// ),
|
||||
// body: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: [
|
||||
// Text(
|
||||
// context.translation.welcome,
|
||||
// style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
|
||||
// ),
|
||||
// Text(
|
||||
// user.username ?? "",
|
||||
// style: AppTextStyles.heading2.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50, fontWeight: FontWeight.w600),
|
||||
// ),
|
||||
// 24.height,
|
||||
// Row(
|
||||
// children: [
|
||||
// indicatorView(0),
|
||||
// 3.width,
|
||||
// indicatorView(1),
|
||||
// 3.width,
|
||||
// indicatorView(2),
|
||||
// 10.width,
|
||||
// "0${_currentPage + 1}/03".tinyFont(context).custom(fontWeight: FontWeight.w500, color: context.isDark ? AppColor.neutral30 : AppColor.neutral60),
|
||||
// ],
|
||||
// ),
|
||||
// ],
|
||||
// ).paddingOnly(start: 16, end: 16, top: 8, bottom: 8),
|
||||
// PageView(
|
||||
// onPageChanged: (index) => setState(() => _currentPage = index),
|
||||
// children: [
|
||||
// const RequestsFragment(),
|
||||
// ProgressFragment(),
|
||||
// const RecentActivitiesFragment(),
|
||||
// ],
|
||||
// ).expanded,
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// Widget indicatorView(int index) {
|
||||
// bool isActive = _currentPage == index;
|
||||
//
|
||||
// return AnimatedContainer(
|
||||
// duration: const Duration(milliseconds: 250),
|
||||
// width: (isActive ? 30 : 12).toScreenWidth,
|
||||
// height: 9.toScreenHeight,
|
||||
// decoration: BoxDecoration(
|
||||
// color: isActive
|
||||
// ? AppColor.greenStatus(context)
|
||||
// : context.isDark
|
||||
// ? AppColor.neutral20
|
||||
// : AppColor.neutral40,
|
||||
// borderRadius: BorderRadius.circular(8)),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -0,0 +1,69 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/text_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
||||
|
||||
class LocalAuthFailedDialog extends StatelessWidget {
|
||||
final String? title;
|
||||
final String? message;
|
||||
final String? okTitle;
|
||||
final String? retryBtnText;
|
||||
final String? loginBtnText;
|
||||
final VoidCallback onRetry;
|
||||
final VoidCallback onLogin;
|
||||
|
||||
const LocalAuthFailedDialog(
|
||||
{Key? key, this.title, this.message = "Authentication Failed, Please try again or login", this.okTitle, required this.onRetry, required this.onLogin, this.retryBtnText, this.loginBtnText})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
backgroundColor: Colors.white,
|
||||
shape: const RoundedRectangleBorder(),
|
||||
insetPadding: const EdgeInsets.only(left: 21, right: 21),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 20, right: 20, top: 18, bottom: 28),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text(
|
||||
"Confirm",
|
||||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.w600, color: Colors.black87, height: 35 / 24, letterSpacing: -0.96),
|
||||
).paddingOnly(top: 16, bottom: 8),
|
||||
message != null ? message!.heading5(context).custom(color: AppColor.neutral50) : const SizedBox(),
|
||||
28.height,
|
||||
Column(
|
||||
children: [
|
||||
AppFilledButton(
|
||||
label: retryBtnText ?? "Retry",
|
||||
fontSize: 18,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
onRetry();
|
||||
},
|
||||
buttonColor: AppColor.primary90,
|
||||
),
|
||||
16.height,
|
||||
AppFilledButton(
|
||||
label: loginBtnText ?? "Login",
|
||||
buttonColor: Colors.white54,
|
||||
textColor: AppColor.black10,
|
||||
height: 42,
|
||||
showBorder: true,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
onLogin();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/text_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
||||
|
||||
class SingleBtnDialog extends StatelessWidget {
|
||||
final String? title;
|
||||
final String? message;
|
||||
final String? okTitle;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
const SingleBtnDialog({Key? key, this.title, this.message, this.okTitle, this.onTap}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
backgroundColor: Colors.white,
|
||||
shape: const RoundedRectangleBorder(),
|
||||
insetPadding: const EdgeInsets.only(left: 21, right: 21),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 20, right: 20, top: 18, bottom: 28),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
title ?? "Confirm",
|
||||
style: const TextStyle(fontSize: 24, fontWeight: FontWeight.w600, color: Colors.black87, height: 35 / 24, letterSpacing: -0.96),
|
||||
).paddingOnly(top: 16),
|
||||
message != null ? message!.heading5(context).custom(color: AppColor.neutral70) : const SizedBox(),
|
||||
28.height,
|
||||
AppFilledButton(
|
||||
label: okTitle ?? "OK",
|
||||
height: 46,
|
||||
onPressed: onTap ?? () => Navigator.pop(context),
|
||||
textColor: Colors.white,
|
||||
//color: Ap.green,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/providers/loading_list_notifier.dart';
|
||||
|
||||
import '../../controllers/api_routes/api_manager.dart';
|
||||
import '../../controllers/api_routes/urls.dart';
|
||||
import '../../models/lookup.dart';
|
||||
|
||||
class WoFrameProvider extends LoadingListNotifier<Lookup> {
|
||||
@override
|
||||
Future getDate() async {
|
||||
if (loading == true) return -2;
|
||||
loading = true;
|
||||
notifyListeners();
|
||||
try {
|
||||
Response response = await ApiManager.instance.get(URLs.getWoFrames);
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
|
||||
}
|
||||
loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
loading = false;
|
||||
stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/string_extensions.dart';
|
||||
import 'package:test_sa/extensions/text_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/models/new_models/work_order_detail_model.dart';
|
||||
import 'package:test_sa/modules/cm_module/utilities/service_request_utils.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
|
||||
class TotalWorkingTimeDetailBottomSheet extends StatelessWidget {
|
||||
final List<ActivityMaintenanceTimers> activityMaintenanceTimers;
|
||||
|
||||
const TotalWorkingTimeDetailBottomSheet({Key? key, this.activityMaintenanceTimers = const []}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: MediaQuery.of(context).size.height * 0.5,
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: 40.toScreenWidth,
|
||||
height: 5.toScreenHeight,
|
||||
decoration: BoxDecoration(color: AppColor.neutral40, borderRadius: BorderRadius.circular(30)),
|
||||
),
|
||||
8.height,
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Text(
|
||||
"Total Working Time",
|
||||
style: AppTextStyles.heading3.copyWith(fontWeight: FontWeight.w600, color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
||||
),
|
||||
),
|
||||
ListView.separated(
|
||||
itemCount: activityMaintenanceTimers.length,
|
||||
separatorBuilder: (cxt, index) => const Divider().defaultStyle(context),
|
||||
padding: const EdgeInsets.only(top: 16, bottom: 16),
|
||||
itemBuilder: (cxt, index) {
|
||||
int totalWorkingHours = DateTime.parse(activityMaintenanceTimers[index].endTime!).difference(DateTime.parse(activityMaintenanceTimers[index].startTime!)).inSeconds;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
text: "From: ",
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: context.isDark ? null : AppColor.neutral20, fontWeight: FontWeight.w500),
|
||||
children: [TextSpan(text: activityMaintenanceTimers[index].startTime!.toServiceRequestDetailsFormat, style: Theme.of(context).textTheme.bodySmall)])),
|
||||
4.height,
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
text: "To: ",
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: context.isDark ? null : AppColor.neutral20, fontWeight: FontWeight.w500),
|
||||
children: [TextSpan(text: activityMaintenanceTimers[index].endTime!.toServiceRequestDetailsFormat, style: Theme.of(context).textTheme.bodySmall)])),
|
||||
4.height,
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
text: "Duration: ",
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: context.isDark ? null : AppColor.neutral20, fontWeight: FontWeight.w500),
|
||||
children: [TextSpan(text: " ${ServiceRequestUtils.formatTimerDuration(totalWorkingHours.round())}", style: Theme.of(context).textTheme.bodySmall)])),
|
||||
],
|
||||
);
|
||||
}).expanded,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TimerModel {
|
||||
int? id;
|
||||
String? startTime;
|
||||
String? endTime;
|
||||
dynamic workingHours;
|
||||
|
||||
TimerModel({this.id, this.startTime, this.endTime, this.workingHours});
|
||||
|
||||
TimerModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
startTime = json['startTime'];
|
||||
endTime = json['endTime'];
|
||||
workingHours = json['workingHours'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['startTime'] = startTime;
|
||||
data['endTime'] = endTime;
|
||||
data['workingHours'] = workingHours;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue