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

main_design2.0
zaid_daoud 1 year ago
commit ee16e35485

@ -0,0 +1,7 @@
<svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
<g opacity="0.5">
<path d="M12.5703 13.9869C12.3589 14.1982 12.0976 14.3596 11.8145 14.4541L9.07994 15.3655C8.88258 15.4314 8.67676 15.4648 8.46853 15.4648C7.95201 15.4648 7.46642 15.2637 7.10123 14.8984C6.57997 14.3771 6.40105 13.6189 6.63416 12.9197L7.54569 10.1852C7.64001 9.90203 7.80157 9.64061 8.01277 9.42942L13.919 3.52319H2.36328C1.06017 3.52319 0 4.58336 0 5.88647V19.6365C0 20.9396 1.06017 21.9997 2.36328 21.9997H16.1133C17.4164 21.9997 18.4766 20.9396 18.4766 19.6365V8.08071L12.5703 13.9869Z" fill="#163A51"/>
<path d="M8.92453 10.341C8.85376 10.4118 8.80048 10.498 8.76886 10.593L7.85732 13.3275C7.7801 13.5591 7.84039 13.8144 8.013 13.987C8.18564 14.1597 8.44096 14.22 8.67256 14.1427L11.4071 13.2312C11.5021 13.1996 11.5883 13.1463 11.659 13.0755L19.7107 5.02392L16.9762 2.28943L8.92453 10.341Z" fill="#163A51"/>
<path d="M20.4698 0.314384C20.0503 -0.10512 19.3701 -0.10512 18.9506 0.314384L17.8872 1.37782L20.6217 4.11235L21.6852 3.04891C22.1047 2.62941 22.1047 1.94926 21.6852 1.52975L20.4698 0.314384Z" fill="#163A51"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -18,6 +18,8 @@
"transferRequest" : "طلب نقل",
"serviceRequest" : "طلب خدمة",
"newServiceRequest" : "طلب خدمة جديدة",
"search": "بحث",
"filter" : "تصنيف",
"newGasRefillRequest" : "طلب إعادة تعبئة غاز جديد",
"newTransferRequest" : "طلب نقل جديد",
"submitRequest" : "تأكيد الطلب",

@ -18,6 +18,8 @@
"transferRequest" : "Transfer Request",
"serviceRequest" : "Service Request",
"newServiceRequest" : "New Service Request",
"search": "Search",
"filter": "Filter",
"newGasRefillRequest" : "New Gas Refill Request",
"newTransferRequest" : "New Transfer Request",
"submitRequest" : "Submit Request",

@ -39,7 +39,7 @@ class GasRefillProvider extends ChangeNotifier {
bool nextPage = true;
// list of user requests
List<GasRefillModel> items;
List<gasModel.GasRefillModel> items;
// when requests in-process _loading = true
// done _loading = true
@ -71,7 +71,7 @@ class GasRefillProvider extends ChangeNotifier {
if (stateCode >= 200 && stateCode < 300) {
// client's request was successfully received
List requestsListJson = json.decode(response.body)["data"];
List<GasRefillModel> itemsPage = requestsListJson.map((request) => GasRefillModel.fromJson(request)).toList();
List<gasModel.GasRefillModel> itemsPage = requestsListJson.map((request) => gasModel.GasRefillModel.fromJson(request)).toList();
items ??= [];
items.addAll(itemsPage);
notifyListeners();
@ -128,15 +128,15 @@ class GasRefillProvider extends ChangeNotifier {
Future<int> updateModel({
@required String host,
@required User user,
@required GasRefillModel oldModel,
@required GasRefillModel newModel,
@required gasModel.GasRefillModel oldModel,
@required gasModel.GasRefillModel newModel,
}) async {
Map<String, dynamic> body = {
"id": newModel.id,
"gazRefillNo": newModel.title ?? "",
"gazRefillNo": newModel.gazRefillNo ?? "",
"status": newModel.status.toJson(),
//"expectedDate": newModel.expectedDate?.toIso8601String(),
"expectedTime": newModel.expectedDate?.toIso8601String(),
"expectedTime": newModel.expectedDate,
if (timer?.startAt != null) "startDate": timer.startAt.toIso8601String(),
if (timer?.startAt != null) "startTime": timer.startAt.toIso8601String(),
if (timer?.endAt != null) "endDate": timer.endAt.toIso8601String(),
@ -148,17 +148,17 @@ class GasRefillProvider extends ChangeNotifier {
"building": building?.toJson(includeFloors: false),
"floor": floor?.toJson(includeDepartments: false),
"department": department?.toJson(),
"engSignature": newModel.signatureEngineer,
"nurseSignature": newModel.signatureNurse,
"engSignature": newModel.engSignature,
"nurseSignature": newModel.nurseSignature,
};
body["gazRefillDetails"] = newModel.details
body["gazRefillDetails"] = newModel.gazRefillDetails
.map((model) => {
"gasType": model.type.toJson(),
"gasType": model.gasType.toJson(),
"cylinderSize": model.cylinderSize.toJson(),
"cylinderType": model.cylinderType.toJson(),
"requestedQty": model.requestedQuantity,
"deliverdQty": model.deliveredQuantity,
"requestedQty": model.requestedQty,
"deliverdQty": model.deliverdQty,
})
.toList();
log(body.toString());

@ -253,6 +253,8 @@
"Serial No" : "الرقم التسلسلي",
"device" : "الجهاز",
"pickAsset" : "إختر جهاز",
"filter" : "تصنيف",
"pickAsset" : "إختر جهاز",
"firstAction" : "First Action",
"priority" : "الأولوية",
"equipmentStatus" : "حالة المعدات",
@ -260,6 +262,10 @@
"callComments" : "تعليقات الطلب",
"comments" : "تعليقات",
"recordVoice" : "تسجيل صوت",
"gasRefillDetails" : "تفاصيل اعادة تعبئة غاز",
"updateRequest" : "تعديل الطلب",
"gasRefill" : "اعادة تعبئة غاز",
"recordVoice" : "تسجيل صوت",
"receiverName" : "اسم المستلم",
"receiverDetails" : "تفاصيل المستلم",
"requestedThrough" : "الطلب عبر",

@ -253,6 +253,8 @@
"serialNo" : "Serial No",
"device" : "Device",
"pickAsset" : "Pick Asset",
"filter" : "Filter",
"pickAsset" : "Pick Asset",
"firstAction" : "First Action",
"workOrder" : "Work Orders",
"viewWorkOrder" : "View All Work Order",
@ -265,6 +267,10 @@
"callComments" : "Call Comments",
"comments": "Comments",
"recordVoice" : "Record Voice",
"gasRefillDetails" : "Gas Refill Details",
"updateRequest" : "Update Request",
"gasRefill" : "Gas Refill",
"recordVoice" : "Record Voice",
"assetDetails" : "Asset Details",
"receiverName" : "Receiver Name",
"receiverDetails" : "Receiver Details",

@ -20,7 +20,6 @@ import 'package:test_sa/controllers/providers/api/status_drop_down/employee/assi
import 'package:test_sa/controllers/providers/api/status_drop_down/employee/engineers_provider.dart';
import 'package:test_sa/controllers/providers/api/status_drop_down/gas_refill/gas_cylinder_size_provider.dart';
import 'package:test_sa/controllers/providers/api/status_drop_down/gas_refill/gas_cylinder_type_provider.dart';
import 'package:test_sa/controllers/providers/api/status_drop_down/gas_refill/gas_status_provider.dart';
import 'package:test_sa/controllers/providers/api/status_drop_down/pentry/pentry_status_provider.dart';
import 'package:test_sa/controllers/providers/api/status_drop_down/pentry/pentry_task_status_provider.dart';
import 'package:test_sa/controllers/providers/api/status_drop_down/pentry/pentry_visit_status_provider.dart';
@ -50,6 +49,7 @@ import 'package:test_sa/new_views/pages/splash_page.dart';
import 'package:test_sa/providers/department_provider.dart';
import 'package:test_sa/providers/gas_request_providers/cylinder_size_provider.dart';
import 'package:test_sa/providers/gas_request_providers/cylinder_type_provider.dart';
import 'package:test_sa/providers/gas_request_providers/gas_status_provider.dart';
import 'package:test_sa/providers/gas_request_providers/gas_types_provider.dart';
import 'package:test_sa/providers/gas_request_providers/site_provider.dart';
import 'package:test_sa/providers/loading_list_notifier.dart';

@ -18,6 +18,8 @@ enum TranslationKeys {
transferRequest,
serviceRequest,
newServiceRequest,
search,
filter,
newGasRefillRequest,
newTransferRequest,
submitRequest,

@ -1,4 +1,5 @@
import 'dart:developer';
import 'dart:typed_data';
import 'package:flutter/cupertino.dart';
import 'package:fluttertoast/fluttertoast.dart';
@ -30,6 +31,8 @@ class GasRefillModel {
this.assignedEmployee,
this.status,
this.gazRefillDetails,
this.localEngineerSignature,
this.localNurseSignature
});
GasRefillModel.fromJson(dynamic json) {
@ -47,7 +50,6 @@ class GasRefillModel {
site = json['site'] != null ? Site.fromJson(json['site']) : null;
building = json['building'] != null ? Building.fromJson(json['building']) : null;
floor = json['floor'] != null ? Floor.fromJson(json['floor']) : null;
log(json['department']);
department = json['department'] != null ? Department.fromJson(json['department']) : null;
assignedEmployee = json['assignedEmployee'] != null ? AssignedEmployee.fromJson(json['assignedEmployee']) : null;
status = json['status'] != null ? Lookup.fromJson(json['status']) : null;
@ -77,6 +79,8 @@ class GasRefillModel {
AssignedEmployee assignedEmployee;
Lookup status;
List<GasRefillDetails> gazRefillDetails;
Uint8List localNurseSignature;
Uint8List localEngineerSignature;
GasRefillModel copyWith({
num id,
@ -172,6 +176,27 @@ class GasRefillModel {
}
return true;
}
fromGasRefillModel(GasRefillModel model) {
id = model.id;
//userId = model.userId;
site = model.site;
gazRefillNo = model.gazRefillNo;
status = Lookup.fromStatus(model.status);
gazRefillDetails = model.gazRefillDetails;
building = model.building;
floor = model.floor;
department = model.department;
startDate = model.startDate;
endDate = model.endDate;
expectedDate = model.expectedDate;
assignedEmployee = model.assignedEmployee;
localEngineerSignature = model.localEngineerSignature;
localNurseSignature = model.localNurseSignature;
engSignature = model.engSignature;
nurseSignature = model.nurseSignature;
workingHours = model.workingHours;
}
}
class GasRefillDetails {
@ -182,6 +207,7 @@ class GasRefillDetails {
this.cylinderSize,
this.requestedQty,
this.deliverdQty,
this.selectedForEditing
});
GasRefillDetails.fromJson(dynamic json) {
@ -199,6 +225,7 @@ class GasRefillDetails {
Lookup cylinderSize;
num requestedQty;
num deliverdQty;
bool selectedForEditing;
GasRefillDetails copyWith({
num id,

@ -0,0 +1,36 @@
import 'package:flutter/material.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import '../../models/enums/translation_keys.dart';
class AppSearchField extends StatefulWidget {
final Function(String) onChanged;
final Function(String) onSubmitted;
const AppSearchField({Key key, this.onChanged, this.onSubmitted}) : super(key: key);
@override
State<AppSearchField> createState() => _AppSearchFieldState();
}
class _AppSearchFieldState extends State<AppSearchField> {
@override
Widget build(BuildContext context) {
return TextField(
onChanged: widget.onChanged,
onSubmitted: widget.onSubmitted,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.search, color: AppColor.neutral20,),
hintText: context.translation.search,
hintStyle: TextStyle(
fontSize: Theme.of(context).textTheme.bodySmall.fontSize
),
filled: true,
fillColor: AppColor.neutral30,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide: BorderSide.none,
)),
);
}
}

@ -0,0 +1,23 @@
import 'package:flutter/material.dart';
class AppTabBar extends StatelessWidget {
const AppTabBar({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return TabBar(
tabs:[
Tab(
icon: Icon(Icons.cloud_outlined),
),
Tab(
icon: Icon(Icons.beach_access_sharp),
),
Tab(
icon: Icon(Icons.brightness_5_sharp),
),
],
);
}
}

@ -26,6 +26,7 @@ class AppTextFormField extends StatefulWidget {
final TextInputAction textInputAction;
final VoidCallback onAction;
final Color backgroundColor;
final bool alignLabelWithHint;
const AppTextFormField({
Key key,
@ -50,6 +51,7 @@ class AppTextFormField extends StatefulWidget {
this.textInputAction,
this.onAction,
this.backgroundColor,
this.alignLabelWithHint
}) : super(key: key);
@override
@ -80,13 +82,14 @@ class _AppTextFormFieldState extends State<AppTextFormField> {
onChanged: widget.onChange,
obscureText: widget.obscureText ?? false,
keyboardType: widget.textInputType,
maxLines: widget.textInputType == TextInputType.multiline ? null : 1,
maxLines: widget.textInputType == TextInputType.multiline ? 4 : 1,
obscuringCharacter: "*",
controller: widget.controller,
textInputAction: widget.textInputType == TextInputType.multiline ? null : widget.textInputAction ?? TextInputAction.next,
onEditingComplete: widget.onAction ?? () => FocusScope.of(context).nextFocus(),
style: AppTextStyle.body1?.copyWith(fontWeight: FontWeight.w500),
decoration: InputDecoration(
alignLabelWithHint: widget.alignLabelWithHint,
border: border,
disabledBorder: border,
focusedBorder: border,

@ -45,7 +45,7 @@ class _SingleItemDropDownMenuState<T extends Base, X extends LoadingListNotifier
final result = (X == NullableLoadingProvider ? widget.staticData : provider.items)?.where((element) {
return element == widget.initialValue;
});
if (result.isNotEmpty) _selectedItem = result.first;
if (result?.isNotEmpty??false) _selectedItem = result.first;
if (widget.onSelect != null && (widget.initialValue?.identifier ?? "") != (_selectedItem?.identifier ?? "")) {
widget.onSelect(_selectedItem);
}
@ -64,7 +64,7 @@ class _SingleItemDropDownMenuState<T extends Base, X extends LoadingListNotifier
final result = (X == NullableLoadingProvider ? widget.staticData : provider.items)?.where((element) {
return element == widget.initialValue;
});
if (result.isNotEmpty) {
if (result?.isNotEmpty??false) {
_selectedItem = result.first;
} else {
_selectedItem = null;

@ -5,7 +5,7 @@ import 'package:flutter/services.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/new_views/pages/land_page/home_app_bar.dart';
import 'package:test_sa/new_views/pages/land_page/my_assets_page.dart';
import 'package:test_sa/new_views/pages/land_page/my_requests_page.dart';
import 'package:test_sa/new_views/pages/land_page/my_request/my_requests_page.dart';
import '../../common_widgets/app_bottom_nav_bar.dart';
import '../../common_widgets/app_drawer.dart';
@ -24,6 +24,7 @@ class LandPage extends StatefulWidget {
class _LandPageState extends State<LandPage> {
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
int currentPageIndex = 0;
bool showAppbar =true;
final List<Widget> _pages = const <Widget>[
DashboardPage(),
MyRequestsPage(),
@ -53,11 +54,8 @@ class _LandPageState extends State<LandPage> {
},
child: Scaffold(
key: _scaffoldKey,
appBar: HomeAppBar(scaffoldKey: _scaffoldKey),
body: Padding(
padding: EdgeInsetsDirectional.only(start: 16.toScreenWidth, end: 11.toScreenHeight),
child: _pages[currentPageIndex],
),
appBar: showAppbar?HomeAppBar(scaffoldKey: _scaffoldKey): null,
body: _pages[currentPageIndex],
drawer: const AppDrawer(),
floatingActionButton: const AppFloatingActionButton(),
bottomNavigationBar: AppBottomNavigationBar(
@ -74,6 +72,16 @@ class _LandPageState extends State<LandPage> {
setState(() {
currentPageIndex = index;
});
if(index == 1){
setState(() {
showAppbar =false;
});
}else{
setState(() {
showAppbar =true;
});
}
}
},
),

@ -0,0 +1,52 @@
import 'package:flutter/material.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/enums/translation_keys.dart';
import '../../../app_style/app_color.dart';
import '../../../common_widgets/app_search_field.dart';
class MyRequestsPage extends StatelessWidget {
const MyRequestsPage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leadingWidth: 0,
title: Padding(
padding: const EdgeInsets.only(bottom: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(child: SizedBox(
height: 50,
child: AppSearchField())),
SizedBox(width: 20,),
Text(context.translation.filter, style: TextStyle(
color: AppColor.primary50,
fontSize: Theme.of(context).textTheme.bodySmall.fontSize,
fontWeight: FontWeight.w500
),)
],
),
),
),
body: TabBarView(
children: const <Widget>[
Center(
child: Text(""),
),
Center(
child: Text(""),
),
Center(
child: Text(""),
),
],
),
);
}
}

@ -1,14 +0,0 @@
import 'package:flutter/material.dart';
class MyRequestsPage extends StatelessWidget {
const MyRequestsPage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const Scaffold(
body: Center(
child: Text("My Requests"),
),
);
}
}

@ -0,0 +1,34 @@
import 'dart:convert';
import 'package:http/http.dart';
import '../../controllers/api_routes/api_manager.dart';
import '../../controllers/api_routes/urls.dart';
import '../../models/lookup.dart';
import '../loading_list_notifier.dart';
class GasStatusProvider extends LoadingListNotifier<Lookup> {
@override
Future getDate() async {
if (loading ?? false) return -2;
loading = true;
notifyListeners();
try {
Response response = await ApiManager.instance.get(URLs.getGasStatus);
stateCode = response.statusCode;
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
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;
}
}
}

@ -1,82 +1,46 @@
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:intl/intl.dart';
import 'package:flutter_svg/svg.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/controllers/api_routes/http_status_manger.dart';
import 'package:test_sa/controllers/localization/localization.dart';
import 'package:test_sa/controllers/providers/api/gas_refill_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/models/gas_refill/gas_refill_model.dart';
import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/pages/user/gas_refill/request_gas_refill.dart';
import 'package:test_sa/views/widgets/buttons/app_back_button.dart';
import 'package:test_sa/views/widgets/buttons/app_button.dart';
import 'package:test_sa/views/widgets/buttons/app_icon_button.dart';
import 'package:test_sa/views/widgets/gas_refill/gas_refill_update_details_item.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
import 'package:test_sa/views/widgets/requests/info_row.dart';
import 'package:test_sa/views/widgets/requests/request_status.dart';
import 'package:test_sa/views/widgets/status/gas_refill/gas_status.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
import '../../../../extensions/text_extensions.dart';
import '../../../../models/enums/user_types.dart';
import '../../../../models/new_models/gas_refill_model.dart';
import '../../../../new_views/app_style/app_color.dart';
import '../../../../new_views/common_widgets/default_app_bar.dart';
import '../../../app_style/colors.dart';
class GasRefillDetails extends StatefulWidget {
class GasRefillDetailsPage extends StatefulWidget {
GasRefillModel model;
GasRefillDetails({Key key, this.model}) : super(key: key);
GasRefillDetailsPage({Key key, this.model}) : super(key: key);
@override
State<GasRefillDetails> createState() => _GasRefillDetailsState();
State<GasRefillDetailsPage> createState() => _GasRefillDetailsPageState();
}
class _GasRefillDetailsState extends State<GasRefillDetails> {
GasRefillModel _model = GasRefillModel();
class _GasRefillDetailsPageState extends State<GasRefillDetailsPage> {
GasRefillModel _model = GasRefillModel(gazRefillDetails: []);
bool _enableEdit = false;
bool _validate = false;
UserProvider _userProvider;
SettingProvider _settingProvider;
GasRefillProvider _gasRefillProvider;
bool _isLoading = false;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
_update() async {
_validate = true;
if (!_formKey.currentState.validate()) {
setState(() {});
return false;
}
_formKey.currentState.save();
_isLoading = true;
setState(() {});
int status = await _gasRefillProvider.updateModel(user: _userProvider.user, host: _settingProvider.host, newModel: _model, oldModel: widget.model);
_isLoading = false;
setState(() {});
if (status >= 200 && status < 300) {
Fluttertoast.showToast(
msg: context.translation.successfulRequestMessage,
);
_enableEdit = false;
_validate = false;
//Navigator.of(context).pop();
} else {
String errorMessage = HttpStatusManger.getStatusMessage(status: status, subtitle: context.translation);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(errorMessage),
));
}
}
@override
void initState() {
_model?.fromGasRefillModel(widget.model);
_model.fromGasRefillModel(widget.model);
super.initState();
}
@ -84,9 +48,9 @@ class _GasRefillDetailsState extends State<GasRefillDetails> {
Widget build(BuildContext context) {
_userProvider = Provider.of<UserProvider>(context);
_settingProvider = Provider.of<SettingProvider>(context);
_gasRefillProvider = Provider.of<GasRefillProvider>(context);
return Scaffold(
appBar: DefaultAppBar(title: context.translation.gasRefillDetails),
key: _scaffoldKey,
body: SafeArea(
child: Form(
@ -98,34 +62,71 @@ class _GasRefillDetailsState extends State<GasRefillDetails> {
onRefresh: () async {},
child: Column(
children: [
Container(
color: Theme.of(context).colorScheme.primary,
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
child: Row(
children: [
ABackButton(
onPressed: () {
Navigator.of(context).pop(_model);
},
informationCard()
],
),
),
),
),
Expanded(
child: Center(
child: Text(
"Gas Refill Request",
style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic),
);
}
Widget informationCard() {
return Container(
decoration: ShapeDecoration(
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
shadows: const [BoxShadow(color: Color(0x07000000), blurRadius: 14, offset: Offset(0, 0), spreadRadius: 0)],
),
child: Column(
children: [
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
/// TBD
//StatusLabel(
//label: item.priority.name,
//id: serviceRequest.priority.id,
//textColor: AColors.getPriorityStatusTextColor(serviceRequest.priority.id),
//backgroundColor: AColors.getPriorityStatusColor(serviceRequest.priority.id)
//),
8.width,
StatusLabel(
label: widget.model.status?.name??"",
textColor: AColors.getRequestStatusTextColor(widget.model.status?.value??0),
backgroundColor: AColors.getRequestStatusColor(widget.model.status?.value??0)),
8.height,
Text(context.translation.gasRefillRequest, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))),
],
),
1.width.expanded,
if (_userProvider.user.type == UsersTypes.engineer)
AIconButton(
iconData: /*_enableEdit ? Icons.cancel :*/ Icons.edit,
color: Theme.of(context).colorScheme.onPrimary,
buttonSize: 42,
backgroundColor: AColors.green,
onPressed: (widget.model.status?.value ?? 0) == 2
CircleAvatar(
radius: 25,
backgroundColor: AppColor.neutral30,
child: CircleAvatar(
radius: 24,
backgroundColor: Colors.white,
child: Padding(
padding: const EdgeInsets.only(left: 3.0),
child: SvgPicture.asset('assets/images/update.svg'),
),
),
).onPress(
(widget.model.status?.value ?? 0) == 2
? null
: () async {
// _enableEdit = !_enableEdit;
:
() async {
_enableEdit = !_enableEdit;
_model?.fromGasRefillModel(widget.model);
// setState(() {});
Navigator.push(
@ -141,124 +142,103 @@ class _GasRefillDetailsState extends State<GasRefillDetails> {
}
});
setState(() {});
},
),
const SizedBox(
width: 16,
)
},),
],
),
),
Expanded(
child: SingleChildScrollView(
padding: EdgeInsets.all(16 * AppStyle.getScaleFactor(context)),
child: Column(
8.height,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RequestInfoRow(
title: "Gas Refill No",
info: _model.title,
),
RequestInfoRow(
title: context.translation.hospital,
info: _model.clientName,
),
RequestInfoRow(
title: "Building",
info: _model.building?.name,
),
RequestInfoRow(
title: "Floor",
info: _model.floor?.name,
),
RequestInfoRow(
title: "Department",
info: _model.department?.departmentName,
),
RequestInfoRow(
title: context.translation.startDate,
info: _model.startDate == null ? null : "${DateFormat.yMd().format(_model.startDate)} ${DateFormat.Hms().format(_model.startDate)}",
),
RequestInfoRow(
title: context.translation.endDate,
info: _model.endDate == null ? null : "${DateFormat.yMd().format(_model.endDate)} ${DateFormat.Hms().format(_model.endDate)}",
),
_enableEdit
? Column(
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
height: 8,
Text(
'Gas Request:',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
ASubTitle(context.translation.status),
if (_validate && _model.status == null)
ASubTitle(
context.translation.requiredWord,
color: Colors.red,
Text(
'Cylinder Size: ${widget.model.gazRefillDetails[0].cylinderSize.value}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
const SizedBox(
height: 4,
Text(
'Site: ${widget.model.site.name}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
GasStatusMenu(
initialValue: _model.status,
onSelect: (status) {
_model.status = status;
},
)
],
)
: Row(
children: [
Expanded(
child: Text(
"${context.translation.status} : ",
style: Theme.of(context).textTheme.subtitle2,
textScaleFactor: AppStyle.getScaleFactor(context),
),
),
if (_model.status?.id != null) StatusLabel(label: _model.status.name, backgroundColor: AColors.getGasStatusColor(_model.status.id)),
Text(widget.model.startDate?.toServiceRequestCardFormat??"", textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))),
],
),
const SizedBox(
height: 8,
8.height,
const Divider(color: Color(0xFFEAF1F4), height: 1, thickness: 1),
8.height,
Text(
'Request Quantity: ${widget.model.gazRefillDetails[0].requestedQty}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
const ASubTitle("Gas Requests"),
const SizedBox(
height: 8,
),
ListView.builder(
shrinkWrap: true,
physics: const ClampingScrollPhysics(),
itemCount: _model.details.length,
itemBuilder: (context, index) {
final details = _model.details[index];
return GasRefillUpdateDetailsItem(
details: details,
validate: _validate,
enableEdit: _enableEdit,
);
}),
if (_enableEdit)
Column(
children: [
const SizedBox(
height: 16,
),
AButton(
text: context.translation.update,
onPressed: _update,
Text(
'Delivered Quantity: ${widget.model.gazRefillDetails[0].deliverdQty}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
8.height,
],
).paddingAll(16),
/// TBD
(_userProvider.user.type == UsersTypes.normal_user
? Container(
height: 50,
padding: const EdgeInsets.only(left: 16, right: 16),
alignment: Alignment.center,
width: double.infinity,
decoration: const ShapeDecoration(
color: Color(0xFFEAF1F4),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(20),
bottomRight: Radius.circular(20),
),
],
),
),
child: Row(
children: [
Text(
'Comment here...',
style: AppTextStyles.heading6.copyWith(
color: AppColor.neutral50.withOpacity(.6),
),
).expanded,
SvgPicture.asset("assets/images/comment_send.svg", width: 24 * AppStyle.getScaleFactor(context), height: 24 * AppStyle.getScaleFactor(context), color: AppColor.primary70),
],
),
)
: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Divider(color: Color(0xFFEAF1F4), height: 1, thickness: 1),
16.height,
Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'View Comments',
style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF4A8DB7)),
),
4.width,
const Icon(
Icons.arrow_forward,
color: Color(0xFF4A8DB7),
size: 14,
)
],
),
],
).paddingOnly(bottom: 16, start: 16, end: 16))
.onPress(() {
}),
],
),
),
);
).paddingAll(16);
}
}

@ -9,10 +9,9 @@ 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/validator/validator.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/gas_refill/gas_refill_details.dart';
import 'package:test_sa/models/gas_refill/gas_refill_model.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/models/timer_model.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/app_text_form_field.dart';
@ -29,10 +28,14 @@ import 'package:test_sa/views/widgets/status/gas_refill/gas_status.dart';
import 'package:test_sa/views/widgets/status/gas_refill/gas_type.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
import '../../../../controllers/localization/localization.dart';
import '../../../../controllers/providers/api/hospitals_provider.dart';
import '../../../widgets/e_signature/e_signature.dart';
import '../../../widgets/timer/app_timer.dart';
import '../../../../extensions/text_extensions.dart';
import '../../../../models/new_models/gas_refill_model.dart';
import '../../../../new_views/common_widgets/app_text_form_field.dart';
import '../../../../new_views/common_widgets/default_app_bar.dart';
import '../../../../new_views/common_widgets/single_item_drop_down_menu.dart';
import '../../../../providers/gas_request_providers/gas_status_provider.dart';
class RequestGasRefill extends StatefulWidget {
static const String id = "/request-gas-refill";
@ -52,9 +55,11 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
SettingProvider _settingProvider;
GasRefillProvider _gasRefillProvider;
GasRefillDetails _currentDetails = GasRefillDetails();
final TextEditingController _requestedQuantityController = TextEditingController();
final TextEditingController _deliveredQuantityController = TextEditingController();
GasRefillModel _formModel = GasRefillModel(details: []);
final TextEditingController _commentController = TextEditingController();
final TextEditingController _workingHoursController = TextEditingController();
GasRefillModel _formModel = GasRefillModel(gazRefillDetails: []);
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final GlobalKey _DetailsKey = GlobalKey<FormState>();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
@ -73,26 +78,27 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
if (mounted) super.setState(() {});
}
_onSubmit() async {
if (_formModel.details.isEmpty) {
if (!_addNewModel()) return;
_onSubmit(BuildContext context) async {
if (_formModel.gazRefillDetails.isEmpty) {
if (!(await _addNewModel(context))) return;
}
_isLoading = true;
setState(() {});
if (widget.gasRefillModel != null) {
if (!_formModel.validate()) {
_isLoading = false;
setState(() {});
return;
}
}
if (_gasRefillProvider.department?.name == null) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text("Select department")));
_isLoading = false;
//_isLoading = true;
setState(() {});
return;
}
// if (widget.gasRefillModel != null) {
// if (!(await _formModel.validate(context))) {
// _isLoading = false;
// setState(() {});
// return;
// }
// }
//if(!(_formKey.currentState.validate())) return;
// if (_gasRefillProvider.department?.name == null) {
// ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text("Select department")));
// _isLoading = false;
// setState(() {});
// return;
// }
int status = widget.gasRefillModel == null
? null /*await _gasRefillProvider.createModel(
@ -105,7 +111,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
oldModel: widget.gasRefillModel,
newModel: _formModel,
);
_isLoading = false;
//_isLoading = false;
setState(() {});
if (status >= 200 && status < 300) {
Fluttertoast.showToast(
@ -121,23 +127,24 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
}
}
bool _addNewModel() {
Future<bool> _addNewModel(BuildContext context) async {
_validate = true;
if (!_formKey.currentState.validate()) {
setState(() {});
return false;
}
_formKey.currentState.save();
if (!_currentDetails.validate()) {
if (!(await _currentDetails.validate(context))) {
setState(() {});
return false;
}
_formModel.details.insert(0, _currentDetails);
_formModel.gazRefillDetails.insert(0, _currentDetails);
_validate = false;
Scrollable.ensureVisible(_DetailsKey.currentContext);
_requestedQuantityController.clear();
_deliveredQuantityController.clear();
_workingHoursController.clear();
_commentController.clear();
_currentDetails = GasRefillDetails();
setState(() {});
return true;
@ -145,8 +152,9 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
@override
void dispose() {
_requestedQuantityController.dispose();
_deliveredQuantityController.dispose();
_commentController.dispose();
_workingHoursController.dispose();
super.dispose();
}
@ -162,10 +170,10 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
if (_firstTime) {
String _clientName;
if (widget.gasRefillModel != null) {
_formModel.status = widget.gasRefillModel?.status ?? Lookup(value: 0);
_gasRefillProvider.expectedDateTime = _formModel.expectedDate;
_gasRefillProvider.timer = TimerModel(startAt: widget.gasRefillModel?.startDate, endAt: widget.gasRefillModel?.endDate);
_clientName = _formModel.clientName;
//_formModel.status = widget.gasRefillModel?.status ?? Lookup(value: 0);
_gasRefillProvider.expectedDateTime = DateTime.tryParse(_formModel.expectedDate??"");
_gasRefillProvider.timer = TimerModel(startAt: DateTime.tryParse(widget.gasRefillModel?.startDate??""), endAt: DateTime.tryParse(widget.gasRefillModel?.endDate??""));
_clientName = _formModel.site.custName;
} else {
_gasRefillProvider.timer = null;
_clientName = _userProvider.user?.clientName;
@ -181,6 +189,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
});
}
return Scaffold(
appBar: DefaultAppBar(title: context.translation.updateRequest),
key: _scaffoldKey,
body: Form(
key: _formKey,
@ -191,379 +200,92 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
stateCode: 200,
onRefresh: () async {},
child: SingleChildScrollView(
padding: EdgeInsets.all(12 * AppStyle.getScaleFactor(context)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"${widget.gasRefillModel == null ? "Request" : "Update"} Gas Refill",
style: Theme.of(context).textTheme.headline5.copyWith(color: Theme.of(context).primaryColor, fontSize: 28, fontWeight: FontWeight.bold),
),
),
),
// const SizedBox(height: 4,),
// ASubTitle(context.translation.title),
// if(_validate && _formModel.title == null)
// ASubTitle(context.translation.requiredWord,color: Colors.red,),
// SizedBox(height: 4,),
// ATextFormField(
// initialValue: _formModel?.title,
// textAlign: TextAlign.center,
// style: Theme.of(context).textTheme.subtitle1,
// textInputType: TextInputType.text,
// onSaved: (value){
// _formModel.title = value;
// },
// ),
// const SizedBox(height: 8,),
ASubTitle(context.translation.status),
if (_validate && _formModel.status == null)
ASubTitle(
context.translation.requiredWord,
color: Colors.red,
),
const SizedBox(
height: 4,
),
GasStatusMenu(
initialValue: _formModel.status ?? Lookup(value: 0),
enabled: widget.gasRefillModel != null,
onSelect: (status) {
_formModel.status = status;
},
),
const SizedBox(
height: 8,
),
Divider(
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(
height: 4,
),
HospitalAutoCompleteField(
enabled: false,
initialValue: _gasRefillProvider.hospital?.name,
// onSave: (value){
// _search.hospital = value;
// },
onSearch: (value) {
_gasRefillProvider.hospital = value;
_gasRefillProvider.building = null;
_gasRefillProvider.floor = null;
_gasRefillProvider.department = null;
setState(() {});
},
),
const SizedBox(
height: 8,
),
BuildingTypeMenu(
initialValue: _gasRefillProvider?.building,
building: _gasRefillProvider?.hospital?.buildings,
loading: _firstTime,
enabled: widget.gasRefillModel == null,
onSelect: (status) {
_gasRefillProvider.building = status;
setState(() {});
},
),
const SizedBox(height: 8),
FloorTypeMenu(
initialValue: _gasRefillProvider?.floor,
floors: _gasRefillProvider?.building?.floors,
enabled: widget.gasRefillModel == null,
loading: _firstTime,
onSelect: (status) {
_gasRefillProvider.floor = status;
setState(() {});
},
),
const SizedBox(height: 8),
DepartmentTypeMenu(
initialValue: _gasRefillProvider?.department,
departments: _gasRefillProvider?.floor?.departments,
loading: _firstTime,
enabled: widget.gasRefillModel == null,
onSelect: (status) {
_gasRefillProvider.department = status;
setState(() {});
},
),
const SizedBox(height: 8),
if (widget.gasRefillModel != null) ASubTitle(context.translation.workingHours),
if (widget.gasRefillModel != null) const SizedBox(height: 8),
if (widget.gasRefillModel != null)
Row(
Column(
children: [
Expanded(
child: AppTimer(
timer: _gasRefillProvider.timer,
onChange: (timer) async {
_gasRefillProvider.timer = timer;
_formModel.workingHours = num.tryParse((((timer?.durationInSecond ?? 0) / 60) / 60)?.toStringAsFixed(2) ?? "0");
_formModel.startDate = timer.startAt;
_formModel.endDate = timer.endAt;
return true;
},
Container(
width: MediaQuery.of(context).size.width,
decoration: ShapeDecoration(
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
shadows: const [BoxShadow(color: Color(0x07000000), blurRadius: 14, offset: Offset(0, 0), spreadRadius: 0)],
),
],
),
//const SizedBox(height: 8),
// if (_userProvider.user?.type == UsersTypes.normal_user || widget.gasRefillModel != null)
// Column(
// crossAxisAlignment: CrossAxisAlignment.stretch,
// children: [
// const ASubTitle("Expected Date"),
// SizedBox(
// height: 8 * AppStyle.getScaleFactor(context),
// ),
// ADateTimePicker(
// date: _gasRefillProvider.expectedDateTime,
// from: DateTime.now().subtract(const Duration(days: 365)),
// to: DateTime.now().add(const Duration(days: 365)),
// onDateTimePicker: (date) {
// _gasRefillProvider.expectedDateTime = date;
// _formModel.expectedDate = _gasRefillProvider.expectedDateTime;
// setState(() {});
// },
// ),
// ],
// ),
// if (_userProvider.user?.type == UsersTypes.engineer)
// Column(
// children: [
// Row(
// children: [
// Expanded(
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.stretch,
// children: [
// const ASubTitle("Start of Work"),
// SizedBox(
// height: 8 * AppStyle.getScaleFactor(context),
// ),
// ADateTimePicker(
// date: _gasRefillProvider.startDate,
// from: DateTime.now().subtract(const Duration(days: 365)),
// to: DateTime.now().add(const Duration(days: 365)),
// onDateTimePicker: (date) {
// _gasRefillProvider.startDate = date;
// setState(() {});
// },
// ),
// ],
// ),
// ),
// const SizedBox(width: 8),
// Expanded(
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.stretch,
// children: [
// const ASubTitle("End of Work"),
// SizedBox(
// height: 8 * AppStyle.getScaleFactor(context),
// ),
// ADateTimePicker(
// date: _gasRefillProvider.endDate,
// from: DateTime.now().subtract(const Duration(days: 365)),
// to: DateTime.now().add(const Duration(days: 365)),
// onDateTimePicker: (date) {
// _gasRefillProvider.endDate = date;
// setState(() {});
// },
// ),
// ],
// ),
// ),
// ],
// ),
// const SizedBox(height: 8),
// ASubTitle(context.translation.workingHours),
// const SizedBox(height: 4),
// ATextFormField(
// initialValue: null,
// textAlign: TextAlign.center,
// hintText: _gasRefillProvider.startDate == null
// ? "0"
// : ((_gasRefillProvider.endDate?.difference(_gasRefillProvider.startDate)?.inMinutes ?? 0) / 60)?.toStringAsFixed(2)?.toString() ?? "0",
// enable: false,
// style: Theme.of(context).textTheme.subtitle1,
// validator: (value) => Validator.isNumeric(value) ? null : context.translation.requiredWord,
// textInputType: TextInputType.number,
// onSaved: (value) {
// // _serviceReport.workHours = value;
// },
// ),
// ],
// ),
if (widget.gasRefillModel == null)
Column(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 8),
Divider(color: Theme.of(context).colorScheme.primary),
const SizedBox(height: 4),
const ASubTitle("Gas Type"),
if (_validate && _currentDetails.type == null) ASubTitle(context.translation.requiredWord, color: Colors.red),
const SizedBox(height: 4),
GasTypeMenu(
initialValue: _currentDetails.type,
onSelect: (status) {
_currentDetails.type = status;
},
Text(context.translation.gasRefill, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))),
8.height,
Text(
'Gas Request:',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
const SizedBox(height: 8),
const ASubTitle("Cylinder Size"),
if (_validate && _currentDetails.cylinderSize == null)
ASubTitle(
context.translation.requiredWord,
color: Colors.red,
Text(
'Cylinder Size: ${widget.gasRefillModel.gazRefillDetails[0].cylinderSize.value}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
const SizedBox(
height: 4,
Text(
'Request Quantity: ${widget.gasRefillModel.gazRefillDetails[0].requestedQty}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
GasCylinderSizeMenu(
initialValue: _currentDetails.cylinderSize,
onSelect: (status) {
_currentDetails.cylinderSize = status;
},
),
const SizedBox(
height: 8,
),
const ASubTitle("Cylinder Type"),
if (_validate && _currentDetails.cylinderSize == null)
ASubTitle(
context.translation.requiredWord,
color: Colors.red,
Text(
'Site: ${widget.gasRefillModel.site.name}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
const SizedBox(
height: 4,
],
).paddingAll(16),
),
GasCylinderTypesMenu(
initialValue: _currentDetails.cylinderType,
onSelect: (status) {
_currentDetails.cylinderType = status;
12.height,
AppTextFormField(
labelText: context.translation.workingHours,
onSaved:(value){
_formModel?.workingHours = double.tryParse(value);
},
),
const SizedBox(
height: 8,
),
ASubTitle(context.translation.requestedQuantity),
if (_validate && _currentDetails?.requestedQuantity == null)
ASubTitle(
context.translation.requiredWord,
color: Colors.red,
),
SizedBox(
height: 4,
),
ATextFormField(
initialValue: (_currentDetails?.requestedQuantity ?? "").toString(),
textAlign: TextAlign.center,
controller: _requestedQuantityController,
style: Theme.of(context).textTheme.subtitle1,
validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
textInputType: TextInputType.number,
onChange: (value) {
_currentDetails?.requestedQuantity = double.tryParse(value);
},
),
if (widget.gasRefillModel != null) const SizedBox(height: 16),
if (widget.gasRefillModel != null) ASubTitle(context.translation.deliveredQuantity),
if (widget.gasRefillModel != null && _validate && _currentDetails?.deliveredQuantity == null)
ASubTitle(
context.translation.requiredWord,
color: Colors.red,
),
if (widget.gasRefillModel != null) const SizedBox(height: 4),
if (widget.gasRefillModel != null)
ATextFormField(
initialValue: (_currentDetails?.deliveredQuantity ?? "").toString(),
textAlign: TextAlign.center,
controller: _deliveredQuantityController,
style: Theme.of(context).textTheme.subtitle1,
controller: _workingHoursController,
validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
textInputType: TextInputType.number,
onChange: (value) {
_currentDetails?.deliveredQuantity = double.tryParse(value);
},
),
const SizedBox(height: 16),
AButton(
text: context.translation.add,
onPressed: _addNewModel,
),
],
),
const SizedBox(height: 16),
if (_formModel.details.isNotEmpty) const ASubTitle("Gas Requests"),
ListView.builder(
key: _DetailsKey,
shrinkWrap: true,
physics: const ClampingScrollPhysics(),
itemCount: _formModel.details.length,
itemBuilder: (context, index) {
final model = _formModel.details[index];
return GasRefillCreateDetailsItem(
isUpdate: widget.gasRefillModel != null,
model: model,
onPressed: () {
if (widget.gasRefillModel != null) {
model.selectedForEditing = !(model.selectedForEditing ?? false);
}
if (widget.gasRefillModel == null) {
_formModel.details.remove(model);
}
setState(() {});
},
);
}),
if (widget.gasRefillModel != null) const SizedBox(height: 16),
if (widget.gasRefillModel != null) const ASubTitle("Nurse Signature"),
if (widget.gasRefillModel != null)
ESignature(
oldSignature: _formModel.signatureNurse,
newSignature: _formModel.localNurseSignature,
onChange: (signature) {
if (signature == null || signature.isEmpty) {
return;
}
_formModel.localNurseSignature = signature;
_formModel.signatureNurse = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
12.height,
SingleItemDropDownMenu<Lookup,GasStatusProvider >(
context: context,
title: context.translation.reportStatus,
initialValue: _formModel.status,
onSelect: (value) {
_formModel.status=value;
},
),
if (widget.gasRefillModel != null)
const SizedBox(
height: 8,
12.height,
AppTextFormField(
labelText: context.translation.deliveredQuantity,
onSaved:(value){
_currentDetails?.deliverdQty = double.tryParse(value);
},
textInputType: TextInputType.number,
controller: _deliveredQuantityController,
validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
),
if (widget.gasRefillModel != null) const ASubTitle("Engineer Signature"),
if (widget.gasRefillModel != null)
ESignature(
oldSignature: _formModel.signatureEngineer,
newSignature: _formModel.localEngineerSignature,
onChange: (signature) {
if (signature == null || signature.isEmpty) {
return;
}
_formModel.localEngineerSignature = signature;
_formModel.signatureEngineer = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
12.height,
/// TBD
AppTextFormField(
labelText: context.translation.comments,
textInputType: TextInputType.multiline,
alignLabelWithHint: true,
controller: _commentController,
onSaved: (value){
},
),
const SizedBox(height: 16),
],
).paddingAll(16),
AButton(
text: widget.gasRefillModel == null ? context.translation.submit : context.translation.update,
onPressed: _onSubmit,
),
const SizedBox(height: 100)
onPressed:()async{_onSubmit.call(context);},
).paddingAll(16),
],
),
),
)
),
),
),

@ -1,16 +1,15 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/controllers/localization/localization.dart';
import 'package:test_sa/controllers/providers/api/gas_refill_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/models/subtitle.dart';
import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/widgets/buttons/app_back_button.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/views/widgets/gas_refill/gas_refill_list.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
import '../../../widgets/switch_button.dart';
import '../../../../new_views/common_widgets/default_app_bar.dart';
class TrackGasRefillPage extends StatefulWidget {
static const String id = "/track-gas-refill";
@ -31,13 +30,13 @@ class _TrackGasRefillPageState extends State<TrackGasRefillPage> with TickerProv
Widget build(BuildContext context) {
if (_gasRefillProvider == null) {
_gasRefillProvider = Provider.of<GasRefillProvider>(context);
//_gasRefillProvider?.isLoading = false;
_gasRefillProvider.reset();
}
_userProvider = Provider.of<UserProvider>(context);
_settingProvider = Provider.of<SettingProvider>(context);
return Scaffold(
appBar: DefaultAppBar(title: context.translation.gasRefillRequest),
body: SafeArea(
child: LoadingManager(
isLoading: _gasRefillProvider.isLoading,
@ -55,46 +54,6 @@ class _TrackGasRefillPageState extends State<TrackGasRefillPage> with TickerProv
children: [
Column(
children: [
Container(
color: AColors.white,
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
child: Column(
children: [
Row(
children: [
const ABackButton(),
Expanded(
child: Center(
child: Text(
"Gas Refill Requests",
style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.grey3A, fontStyle: FontStyle.italic),
),
),
),
const SizedBox(
width: 48,
)
],
),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ASwitchButton(
title: "Most Recent",
value: mostRecent,
onChange: (value) async {
mostRecent = value;
_gasRefillProvider.reset();
await _gasRefillProvider.getRequests(
user: _userProvider.user,
host: _settingProvider.host,
mostRecent: mostRecent,
);
},
),
),
Expanded(
child: GasRefillList(
nextPage: _gasRefillProvider.nextPage,

@ -1,10 +1,9 @@
import 'package:flutter/material.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/gas_refill/gas_refill_details.dart';
import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/widgets/app_text_form_field.dart';
import '../../../controllers/localization/localization.dart';
import '../../../models/new_models/gas_refill_model.dart';
import '../buttons/app_button.dart';
import '../titles/app_sub_title.dart';
@ -38,23 +37,23 @@ class _GasRefillCreateDetailsItemState extends State<GasRefillCreateDetailsItem>
children: [
Row(
children: [
Expanded(child: Text(widget.model.type.name)),
Expanded(child: Text(widget.model.gasType.name)),
IconButton(onPressed: widget.onPressed, color: widget.isUpdate ? AColors.cyan : AColors.red, icon: Icon(widget.isUpdate ? Icons.edit : Icons.delete))
],
),
Wrap(
spacing: 10,
children: [
Text("Quantity: ${widget.model.requestedQuantity.toStringAsFixed(0)}"),
Text("Quantity: ${widget.model.requestedQty.toStringAsFixed(0)}"),
Text("Cylinder Size: ${widget.model.cylinderSize.name}"),
Text("Cylinder Type: ${widget.model.cylinderType.name}"),
],
),
if (widget.model.deliveredQuantity != null)
if (widget.model.deliverdQty != null)
Row(
children: [
const Text("Delivered Quantity: "),
Text(widget.model.deliveredQuantity.toStringAsFixed(0)),
Text(widget.model.deliverdQty.toStringAsFixed(0)),
],
),
if (startEditing) const SizedBox(height: 16),
@ -62,16 +61,16 @@ class _GasRefillCreateDetailsItemState extends State<GasRefillCreateDetailsItem>
if (startEditing) const SizedBox(height: 4),
if (startEditing)
ATextFormField(
initialValue: widget.model.deliveredQuantity?.toString() ?? "0",
initialValue: widget.model.deliverdQty?.toString() ?? "0",
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleMedium,
// validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
textInputType: TextInputType.number,
onSaved: (value) {
if (value.isNotEmpty) {
widget.model.deliveredQuantity = double.tryParse(value);
widget.model.deliverdQty = double.tryParse(value);
} else {
widget.model.deliveredQuantity = 0;
widget.model.deliverdQty = 0;
}
},
),

@ -1,10 +1,14 @@
import 'package:flutter/material.dart';
import 'package:test_sa/controllers/localization/localization.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/gas_refill/gas_refill_model.dart';
import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/requests/request_status.dart';
import '../../../extensions/text_extensions.dart';
import '../../../models/new_models/gas_refill_model.dart';
import '../../app_style/colors.dart';
import '../requests/request_status.dart';
class GasRefillItem extends StatelessWidget {
final int index;
@ -15,20 +19,17 @@ class GasRefillItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
Color itemColor = index % 2 == 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
Color onItemColor = index % 2 != 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
backgroundColor: itemColor,
backgroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)),
),
),
//padding: EdgeInsets.symmetric(vertical: 8,horizontal: 8),
onPressed: () {
onPressed(item);
},
@ -36,75 +37,116 @@ class GasRefillItem extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
item.title ?? "-----",
style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold),
),
Row(
children: [
Expanded(
child: Text(
context.translation.hospital,
style: Theme.of(context).textTheme.titleSmall.copyWith(
color: onItemColor,
),
),
),
if (item.clientName != null)
Text(
item.clientName,
style: Theme.of(context).textTheme.titleSmall.copyWith(
color: onItemColor,
),
),
/// TBD
// StatusLabel(
// label: ,
// id: ,
// textColor: AColors.getPriorityStatusTextColor(),
// backgroundColor: AColors.getPriorityStatusColor()),
8.width,
StatusLabel(label: item.status.name, textColor: AColors.getRequestStatusTextColor(item.status.value), backgroundColor: AColors.getRequestStatusColor(item.status.value)),
1.width.expanded,
Text(item.startDate != null ?item.startDate.toServiceRequestCardFormat:"", textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))),
],
),
Divider(color: onItemColor),
Row(
children: [
Expanded(
child: Text(context.translation.status, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
),
if (item.status?.id != null) StatusLabel(label: item.status.name, backgroundColor: AColors.getGasStatusColor(item.status.id)),
],
8.height,
Text(context.translation.gasRefillRequest, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))),
Text(
'Gas Type: ${item.gazRefillDetails[0].gasType.name}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
if (item?.expectedDate != null) Divider(color: onItemColor),
if (item?.expectedDate != null)
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("Expected Date", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
Text(item.expectedDate.toIso8601String().split("T").first, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
],
Text(
'${context.translation.site}: ${item.site.name}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
if (item?.details?.isNotEmpty ?? false) Divider(color: onItemColor),
8.height,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
if (item?.details?.isNotEmpty ?? false) Text("Gas Type", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: item.details
.map(
(gas) => gas?.type?.name?.isNotEmpty ?? false
? Text(gas?.type?.name, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor))
: const SizedBox.shrink(),
)
.toList(),
Text(
'View Details',
style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF4A8DB7)),
),
4.width,
const Icon(
Icons.arrow_forward,
color: Color(0xFF4A8DB7),
size: 14,
)
],
),
],
),
),
],
),
// Row(
// children: [
// Expanded(
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(
// item.title ?? "-----",
// style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold),
// ),
// Row(
// children: [
// Expanded(
// child: Text(
// subtitle.hospital,
// style: Theme.of(context).textTheme.titleSmall.copyWith(
// color: onItemColor,
// ),
// ),
// ),
// if (item.clientName != null)
// Text(
// item.clientName,
// style: Theme.of(context).textTheme.titleSmall.copyWith(
// color: onItemColor,
// ),
// ),
// ],
// ),
// Divider(color: onItemColor),
// Row(
// children: [
// Expanded(
// child: Text(subtitle.status, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
// ),
// if (item.status?.id != null) StatusLabel(label: item.status.name, color: AColors.getGasStatusColor(item.status.id)),
// ],
// ),
// if (item?.expectedDate != null) Divider(color: onItemColor),
// if (item?.expectedDate != null)
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Text("Expected Date", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
// Text(item.expectedDate.toIso8601String().split("T").first, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
// ],
// ),
// if (item?.details?.isNotEmpty ?? false) Divider(color: onItemColor),
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// if (item?.details?.isNotEmpty ?? false) Text("Gas Type", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
// Column(
// crossAxisAlignment: CrossAxisAlignment.end,
// children: item.details
// .map(
// (gas) => gas?.type?.name?.isNotEmpty ?? false
// ? Text(gas?.type?.name, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor))
// : const SizedBox.shrink(),
// )
// .toList(),
// )
// ],
// ),
// ],
// ),
// ),
// ],
// ),
],
),
),

@ -1,13 +1,12 @@
import 'package:flutter/material.dart';
import 'package:test_sa/controllers/localization/localization.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/gas_refill/gas_refill_model.dart';
import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/pages/user/gas_refill/gas_refill_details.dart';
import 'package:test_sa/views/widgets/gas_refill/gas_refill_item.dart';
import 'package:test_sa/views/widgets/loaders/lazy_loading.dart';
import 'package:test_sa/views/widgets/loaders/no_item_found.dart';
import '../../../models/new_models/gas_refill_model.dart';
class GasRefillList extends StatefulWidget {
final List<GasRefillModel> items;
final bool nextPage;
@ -22,7 +21,7 @@ class GasRefillList extends StatefulWidget {
class _GasRefillListState extends State<GasRefillList> {
@override
Widget build(BuildContext context) {
if (widget.items.length == 0) {
if (widget.items.isEmpty) {
return NoItemFound(
message: context.translation.noServiceRequestFound,
);
@ -40,7 +39,7 @@ class _GasRefillListState extends State<GasRefillList> {
item: widget.items[itemIndex],
onPressed: (model) {
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => GasRefillDetails(
builder: (_) => GasRefillDetailsPage(
model: model,
))).then((value) {
model=value;

@ -1,14 +1,13 @@
import 'package:flutter/material.dart';
import 'package:test_sa/controllers/localization/localization.dart';
import 'package:test_sa/controllers/validator/validator.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/gas_refill/gas_refill_details.dart';
import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/widgets/app_text_form_field.dart';
import 'package:test_sa/views/widgets/requests/info_row.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
import 'package:test_sa/views/widgets/titles/app_title.dart';
import '../../../models/new_models/gas_refill_model.dart';
class GasRefillUpdateDetailsItem extends StatelessWidget {
final GasRefillDetails details;
final bool enableEdit;
@ -22,21 +21,21 @@ class GasRefillUpdateDetailsItem extends StatelessWidget {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ATitle(details.type.name),
ATitle(details.gasType.name),
RequestInfoRow(
title: "Cylinder Size",
info: details.cylinderSize.name,
),
RequestInfoRow(
title: "Requested Quantity",
info: details.requestedQuantity.toStringAsFixed(0),
info: details.deliverdQty?.toStringAsFixed(0)??"",
),
enableEdit
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(context.translation.quantity),
if (validate && details.deliveredQuantity == null)
if (validate && details.deliverdQty == null)
ASubTitle(
context.translation.requiredWord,
color: Colors.red,
@ -45,20 +44,20 @@ class GasRefillUpdateDetailsItem extends StatelessWidget {
height: 4,
),
ATextFormField(
initialValue: (details.deliveredQuantity ?? "").toString(),
initialValue: (details.deliverdQty ?? "").toString(),
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1,
validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
textInputType: TextInputType.number,
onSaved: (value) {
details.deliveredQuantity = double.tryParse(value);
details.deliverdQty = double.tryParse(value);
},
),
],
)
: RequestInfoRow(
title: "Delivered Quantity",
info: details.deliveredQuantity?.toStringAsFixed(0),
info: details.deliverdQty?.toStringAsFixed(0),
),
//SizedBox(height: 16,)
],

Loading…
Cancel
Save