Still working on gas refill request
parent
085674ee18
commit
ed759f5dcf
@ -0,0 +1,4 @@
|
||||
<svg width="18" height="24" viewBox="0 0 18 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M17.3077 2.8125H12.4615V2.10938C12.4615 0.946219 11.5299 0 10.3846 0H7.61538C6.47012 0 5.53846 0.946219 5.53846 2.10938V2.8125H0.692308C0.309646 2.8125 0 3.12698 0 3.51562C0 3.90427 0.309646 4.21875 0.692308 4.21875H17.3077C17.6904 4.21875 18 3.90427 18 3.51562C18 3.12698 17.6904 2.8125 17.3077 2.8125ZM6.92308 2.10938C6.92308 1.72144 7.23342 1.40625 7.61538 1.40625H10.3846C10.7666 1.40625 11.0769 1.72144 11.0769 2.10938V2.8125H6.92308V2.10938Z" fill="#D02127"/>
|
||||
<path d="M15.9231 5.625H2.07695C1.69429 5.625 1.38464 5.93948 1.38464 6.32812V23.2969C1.38464 23.6855 1.69429 24 2.07695 24H15.9231C16.3058 24 16.6154 23.6855 16.6154 23.2969V6.32812C16.6154 5.93948 16.3058 5.625 15.9231 5.625ZM5.53849 19.0312C5.53849 19.4199 5.22884 19.7344 4.84618 19.7344C4.46352 19.7344 4.15387 19.4199 4.15387 19.0312V10.5938C4.15387 10.2051 4.46352 9.89062 4.84618 9.89062C5.22884 9.89062 5.53849 10.2051 5.53849 10.5938V19.0312ZM9.69234 19.0312C9.69234 19.4199 9.38269 19.7344 9.00003 19.7344C8.61737 19.7344 8.30772 19.4199 8.30772 19.0312V10.5938C8.30772 10.2051 8.61737 9.89062 9.00003 9.89062C9.38269 9.89062 9.69234 10.2051 9.69234 10.5938V19.0312ZM13.8462 19.0312C13.8462 19.4199 13.5365 19.7344 13.1539 19.7344C12.7712 19.7344 12.4616 19.4199 12.4616 19.0312V10.5938C12.4616 10.2051 12.7712 9.89062 13.1539 9.89062C13.5365 9.89062 13.8462 10.2051 13.8462 10.5938V19.0312Z" fill="#D02127"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@ -0,0 +1,27 @@
|
||||
class AssignedEmployee {
|
||||
AssignedEmployee({
|
||||
this.id,
|
||||
this.name,
|
||||
});
|
||||
|
||||
AssignedEmployee.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
}
|
||||
String id;
|
||||
String name;
|
||||
AssignedEmployee copyWith({
|
||||
String id,
|
||||
String name,
|
||||
}) =>
|
||||
AssignedEmployee(
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
);
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['name'] = name;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
import 'package:test_sa/models/new_models/floor.dart';
|
||||
|
||||
class Building {
|
||||
Building({
|
||||
this.id,
|
||||
this.name,
|
||||
this.value,
|
||||
this.floors,
|
||||
});
|
||||
|
||||
Building.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
value = json['value'];
|
||||
if (json['floors'] != null) {
|
||||
floors = [];
|
||||
json['floors'].forEach((v) {
|
||||
floors.add(Floor.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
num id;
|
||||
String name;
|
||||
num value;
|
||||
List<Floor> floors;
|
||||
Building copyWith({
|
||||
num id,
|
||||
String name,
|
||||
num value,
|
||||
List<Floor> floors,
|
||||
}) =>
|
||||
Building(
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
value: value ?? this.value,
|
||||
floors: floors ?? this.floors,
|
||||
);
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['name'] = name;
|
||||
map['value'] = value;
|
||||
if (floors != null) {
|
||||
map['floors'] = floors.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
class Department {
|
||||
Department({
|
||||
this.id,
|
||||
this.departmentName,
|
||||
this.departmentCode,
|
||||
this.ntCode,
|
||||
});
|
||||
|
||||
Department.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
departmentName = json['departmentName'];
|
||||
departmentCode = json['departmentCode'];
|
||||
ntCode = json['ntCode'];
|
||||
}
|
||||
num id;
|
||||
String departmentName;
|
||||
String departmentCode;
|
||||
String ntCode;
|
||||
Department copyWith({
|
||||
num id,
|
||||
String departmentName,
|
||||
String departmentCode,
|
||||
String ntCode,
|
||||
}) =>
|
||||
Department(
|
||||
id: id ?? this.id,
|
||||
departmentName: departmentName ?? this.departmentName,
|
||||
departmentCode: departmentCode ?? this.departmentCode,
|
||||
ntCode: ntCode ?? this.ntCode,
|
||||
);
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['departmentName'] = departmentName;
|
||||
map['departmentCode'] = departmentCode;
|
||||
map['ntCode'] = ntCode;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
import 'package:test_sa/models/new_models/department.dart';
|
||||
|
||||
class Floor {
|
||||
Floor({
|
||||
this.id,
|
||||
this.name,
|
||||
this.value,
|
||||
this.departments,
|
||||
});
|
||||
|
||||
Floor.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
value = json['value'];
|
||||
if (json['departments'] != null) {
|
||||
departments = [];
|
||||
json['departments'].forEach((v) {
|
||||
departments.add(Department.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
num id;
|
||||
String name;
|
||||
num value;
|
||||
List<Department> departments;
|
||||
Floor copyWith({
|
||||
num id,
|
||||
String name,
|
||||
num value,
|
||||
List<Department> departments,
|
||||
}) =>
|
||||
Floor(
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
value: value ?? this.value,
|
||||
departments: departments ?? this.departments,
|
||||
);
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['name'] = name;
|
||||
map['value'] = value;
|
||||
if (departments != null) {
|
||||
map['departments'] = departments.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,225 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/enums/translation_keys.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/new_models/assigned_employee.dart';
|
||||
import 'package:test_sa/models/new_models/building.dart';
|
||||
import 'package:test_sa/models/new_models/department.dart';
|
||||
import 'package:test_sa/models/new_models/floor.dart';
|
||||
import 'package:test_sa/models/new_models/site.dart';
|
||||
|
||||
class GasRefillModel {
|
||||
GasRefillModel({
|
||||
this.id,
|
||||
this.gazRefillNo,
|
||||
this.expectedDate,
|
||||
this.expectedTime,
|
||||
this.startDate,
|
||||
this.startTime,
|
||||
this.endDate,
|
||||
this.endTime,
|
||||
this.engSignature,
|
||||
this.nurseSignature,
|
||||
this.workingHours,
|
||||
this.site,
|
||||
this.building,
|
||||
this.floor,
|
||||
this.department,
|
||||
this.assignedEmployee,
|
||||
this.status,
|
||||
this.gazRefillDetails,
|
||||
});
|
||||
|
||||
GasRefillModel.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
gazRefillNo = json['gazRefillNo'];
|
||||
expectedDate = json['expectedDate'];
|
||||
expectedTime = json['expectedTime'];
|
||||
startDate = json['startDate'];
|
||||
startTime = json['startTime'];
|
||||
endDate = json['endDate'];
|
||||
endTime = json['endTime'];
|
||||
engSignature = json['engSignature'];
|
||||
nurseSignature = json['nurseSignature'];
|
||||
workingHours = json['workingHours'];
|
||||
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;
|
||||
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;
|
||||
if (json['gazRefillDetails'] != null) {
|
||||
gazRefillDetails = [];
|
||||
json['gazRefillDetails'].forEach((v) {
|
||||
gazRefillDetails.add(GasRefillDetails.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
num id;
|
||||
String gazRefillNo;
|
||||
String expectedDate;
|
||||
String expectedTime;
|
||||
String startDate;
|
||||
String startTime;
|
||||
String endDate;
|
||||
String endTime;
|
||||
String engSignature;
|
||||
String nurseSignature;
|
||||
num workingHours;
|
||||
Site site;
|
||||
Building building;
|
||||
Floor floor;
|
||||
Department department;
|
||||
AssignedEmployee assignedEmployee;
|
||||
Lookup status;
|
||||
List<GasRefillDetails> gazRefillDetails;
|
||||
GasRefillModel copyWith({
|
||||
num id,
|
||||
String gazRefillNo,
|
||||
String expectedDate,
|
||||
String expectedTime,
|
||||
String startDate,
|
||||
String startTime,
|
||||
String endDate,
|
||||
String endTime,
|
||||
String engSignature,
|
||||
String nurseSignature,
|
||||
num workingHours,
|
||||
Site site,
|
||||
Building building,
|
||||
Floor floor,
|
||||
Department department,
|
||||
AssignedEmployee assignedEmployee,
|
||||
Lookup status,
|
||||
List<GasRefillDetails> gazRefillDetails,
|
||||
}) =>
|
||||
GasRefillModel(
|
||||
id: id ?? this.id,
|
||||
gazRefillNo: gazRefillNo ?? this.gazRefillNo,
|
||||
expectedDate: expectedDate ?? this.expectedDate,
|
||||
expectedTime: expectedTime ?? this.expectedTime,
|
||||
startDate: startDate ?? this.startDate,
|
||||
startTime: startTime ?? this.startTime,
|
||||
endDate: endDate ?? this.endDate,
|
||||
endTime: endTime ?? this.endTime,
|
||||
engSignature: engSignature ?? this.engSignature,
|
||||
nurseSignature: nurseSignature ?? this.nurseSignature,
|
||||
workingHours: workingHours ?? this.workingHours,
|
||||
site: site ?? this.site,
|
||||
building: building ?? this.building,
|
||||
floor: floor ?? this.floor,
|
||||
department: department ?? this.department,
|
||||
assignedEmployee: assignedEmployee ?? this.assignedEmployee,
|
||||
status: status ?? this.status,
|
||||
gazRefillDetails: gazRefillDetails ?? this.gazRefillDetails,
|
||||
);
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['gazRefillNo'] = gazRefillNo;
|
||||
map['expectedDate'] = expectedDate;
|
||||
map['expectedTime'] = expectedTime;
|
||||
map['startDate'] = startDate;
|
||||
map['startTime'] = startTime;
|
||||
map['endDate'] = endDate;
|
||||
map['endTime'] = endTime;
|
||||
map['engSignature'] = engSignature;
|
||||
map['nurseSignature'] = nurseSignature;
|
||||
map['workingHours'] = workingHours;
|
||||
if (site != null) {
|
||||
map['site'] = site.toJson();
|
||||
}
|
||||
if (building != null) {
|
||||
map['building'] = building.toJson();
|
||||
}
|
||||
if (floor != null) {
|
||||
map['floor'] = floor.toJson();
|
||||
}
|
||||
if (department != null) {
|
||||
map['department'] = department.toJson();
|
||||
}
|
||||
if (assignedEmployee != null) {
|
||||
map['assignedEmployee'] = assignedEmployee.toJson();
|
||||
}
|
||||
if (status != null) {
|
||||
map['status'] = status.toMap();
|
||||
}
|
||||
if (gazRefillDetails != null) {
|
||||
map['gazRefillDetails'] = gazRefillDetails.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class GasRefillDetails {
|
||||
GasRefillDetails({
|
||||
this.id,
|
||||
this.gasType,
|
||||
this.cylinderType,
|
||||
this.cylinderSize,
|
||||
this.requestedQty,
|
||||
this.deliverdQty,
|
||||
});
|
||||
|
||||
GasRefillDetails.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
gasType = json['gasType'] != null ? Lookup.fromJson(json['gasType']) : null;
|
||||
cylinderType = json['cylinderType'] != null ? Lookup.fromJson(json['cylinderType']) : null;
|
||||
cylinderSize = json['cylinderSize'] != null ? Lookup.fromJson(json['cylinderSize']) : null;
|
||||
requestedQty = json['requestedQty'];
|
||||
deliverdQty = json['deliverdQty'];
|
||||
}
|
||||
num id;
|
||||
Lookup gasType;
|
||||
Lookup cylinderType;
|
||||
Lookup cylinderSize;
|
||||
num requestedQty;
|
||||
num deliverdQty;
|
||||
GasRefillDetails copyWith({
|
||||
num id,
|
||||
Lookup gasType,
|
||||
Lookup cylinderType,
|
||||
Lookup cylinderSize,
|
||||
num requestedQty,
|
||||
num deliverdQty,
|
||||
}) =>
|
||||
GasRefillDetails(
|
||||
id: id ?? this.id,
|
||||
gasType: gasType ?? this.gasType,
|
||||
cylinderType: cylinderType ?? this.cylinderType,
|
||||
cylinderSize: cylinderSize ?? this.cylinderSize,
|
||||
requestedQty: requestedQty ?? this.requestedQty,
|
||||
deliverdQty: deliverdQty ?? this.deliverdQty,
|
||||
);
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
if (gasType != null) {
|
||||
map['gasType'] = gasType.toMap();
|
||||
}
|
||||
if (cylinderType != null) {
|
||||
map['cylinderType'] = cylinderType.toMap();
|
||||
}
|
||||
if (cylinderSize != null) {
|
||||
map['cylinderSize'] = cylinderSize.toMap();
|
||||
}
|
||||
map['requestedQty'] = requestedQty;
|
||||
map['deliverdQty'] = deliverdQty;
|
||||
return map;
|
||||
}
|
||||
|
||||
Future<bool> validate(BuildContext context) async {
|
||||
if (gasType == null) {
|
||||
await Fluttertoast.showToast(msg: "${context.translate(TranslationKeys.youHaveToSelect)} ${context.translate(TranslationKeys.gasType)}");
|
||||
return false;
|
||||
} else if (cylinderType == null) {
|
||||
await Fluttertoast.showToast(msg: "${context.translate(TranslationKeys.youHaveToSelect)} ${context.translate(TranslationKeys.cylinderType)}");
|
||||
return false;
|
||||
} else if (cylinderSize == null) {
|
||||
await Fluttertoast.showToast(msg: "${context.translate(TranslationKeys.youHaveToSelect)} ${context.translate(TranslationKeys.cylinderSize)}");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
import 'package:test_sa/models/base.dart';
|
||||
import 'package:test_sa/models/new_models/building.dart';
|
||||
|
||||
class Site extends Base {
|
||||
Site({
|
||||
this.id,
|
||||
this.custName,
|
||||
this.buildings,
|
||||
}) : super(identifier: id.toString(), name: custName);
|
||||
|
||||
Site.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
custName = json['custName'];
|
||||
if (json['buildings'] != null) {
|
||||
buildings = [];
|
||||
json['buildings'].forEach((v) {
|
||||
buildings.add(Building.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
num id;
|
||||
String custName;
|
||||
List<Building> buildings;
|
||||
Site copyWith({
|
||||
num id,
|
||||
String custName,
|
||||
List<Building> buildings,
|
||||
}) =>
|
||||
Site(
|
||||
id: id ?? this.id,
|
||||
custName: custName ?? this.custName,
|
||||
buildings: buildings ?? this.buildings,
|
||||
);
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['custName'] = custName;
|
||||
if (buildings != null) {
|
||||
map['buildings'] = buildings.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@ -1,70 +1,199 @@
|
||||
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/text_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/models/enums/translation_keys.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/new_models/gas_refill_model.dart';
|
||||
import 'package:test_sa/models/new_models/site.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/new_views/common_widgets/single_item_drop_down_menu.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_types_provider.dart';
|
||||
import 'package:test_sa/providers/gas_request_providers/site_provider.dart';
|
||||
|
||||
import '../../controllers/validator/validator.dart';
|
||||
import '../common_widgets/default_app_bar.dart';
|
||||
|
||||
class NewGasRefillRequestPage extends StatelessWidget {
|
||||
class NewGasRefillRequestPage extends StatefulWidget {
|
||||
static const String routeName = "/new_gas_refill_request_page";
|
||||
const NewGasRefillRequestPage({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<NewGasRefillRequestPage> createState() => _NewGasRefillRequestPageState();
|
||||
}
|
||||
|
||||
class _NewGasRefillRequestPageState extends State<NewGasRefillRequestPage> {
|
||||
GasRefillDetails _currentDetails;
|
||||
GasRefillModel _gasModel;
|
||||
GlobalKey<FormState> _formKey;
|
||||
TextEditingController _quantityController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_formKey = GlobalKey<FormState>();
|
||||
_currentDetails = GasRefillDetails();
|
||||
_gasModel = GasRefillModel(gazRefillDetails: []);
|
||||
_quantityController = TextEditingController();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_quantityController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: const DefaultAppBar(title: TranslationKeys.newGasRefillRequest),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
16.height,
|
||||
SingleItemDropDownMenu<Lookup, GasTypesProvider>(
|
||||
context: context,
|
||||
title: TranslationKeys.gasType,
|
||||
body: Column(
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
16.height,
|
||||
SingleItemDropDownMenu<Lookup, GasTypesProvider>(
|
||||
context: context,
|
||||
title: TranslationKeys.gasType,
|
||||
onSelect: (value) {
|
||||
_currentDetails.gasType = value;
|
||||
},
|
||||
),
|
||||
8.height,
|
||||
AppTextFormField(
|
||||
controller: _quantityController,
|
||||
labelText: TranslationKeys.quantity,
|
||||
textInputType: TextInputType.number,
|
||||
validator: (value) => Validator.hasValue(value)
|
||||
? Validator.isNumeric(value)
|
||||
? null
|
||||
: context.translate(TranslationKeys.onlyNumbers)
|
||||
: context.translate(TranslationKeys.requiredField),
|
||||
onSaved: (text) {
|
||||
_currentDetails.requestedQty = double.tryParse(text ?? "") ?? 0;
|
||||
},
|
||||
),
|
||||
8.height,
|
||||
SingleItemDropDownMenu<Lookup, CylinderTypesProvider>(
|
||||
context: context,
|
||||
title: TranslationKeys.cylinderType,
|
||||
onSelect: (value) {
|
||||
_currentDetails.cylinderType = value;
|
||||
},
|
||||
),
|
||||
8.height,
|
||||
SingleItemDropDownMenu<Lookup, CylinderSizeProvider>(
|
||||
context: context,
|
||||
title: TranslationKeys.cylinderSize,
|
||||
onSelect: (value) {
|
||||
_currentDetails.cylinderSize = value;
|
||||
},
|
||||
),
|
||||
8.height,
|
||||
SingleItemDropDownMenu<Site, SiteProvider>(
|
||||
context: context,
|
||||
title: TranslationKeys.destinationSite,
|
||||
onSelect: (value) {
|
||||
_gasModel.site = value;
|
||||
},
|
||||
),
|
||||
// 8.height,
|
||||
// SingleItemDropDownMenu<Department, DepartmentProvider>(
|
||||
// context: context,
|
||||
// title: TranslationKeys.department,
|
||||
// onSelect: (value) {
|
||||
// _formModel.department = value;
|
||||
// },
|
||||
// ),
|
||||
8.height,
|
||||
AppFilledButton(
|
||||
label: TranslationKeys.add,
|
||||
maxWidth: true,
|
||||
textColor: Colors.white,
|
||||
buttonColor: context.isDark ? AppColor.neutral60 : AppColor.neutral50,
|
||||
onPressed: _add,
|
||||
),
|
||||
24.height,
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: _gasModel.gazRefillDetails?.length,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (context, index) {
|
||||
return Card(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_gasModel.gazRefillDetails[index].gasType?.name?.heading5(context),
|
||||
8.height,
|
||||
("${context.translate(TranslationKeys.quantity)}: ${_gasModel.gazRefillDetails[index].requestedQty}").bodyText(context),
|
||||
("${context.translate(TranslationKeys.cylinderSize)}: ${_gasModel.gazRefillDetails[index].cylinderSize?.name}").bodyText(context),
|
||||
("${context.translate(TranslationKeys.cylinderType)}: ${_gasModel.gazRefillDetails[index].cylinderType?.name}").bodyText(context),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
height: 48.toScreenWidth,
|
||||
width: 48.toScreenWidth,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(100),
|
||||
border: Border.all(color: context.isDark ? AppColor.neutral50 : AppColor.neutral30),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(vertical: 12.toScreenHeight),
|
||||
child: "trash".toSvgAsset(fit: BoxFit.fitHeight, color: context.isDark ? AppColor.red40 : AppColor.red50),
|
||||
).onPress(() {
|
||||
_delete(index);
|
||||
}),
|
||||
],
|
||||
),
|
||||
const Divider().defaultStyle(context),
|
||||
("${context.translate(TranslationKeys.department)}: ${_gasModel.department?.departmentCode}").bodyText(context),
|
||||
("${context.translate(TranslationKeys.site)}: ${_gasModel.department?.departmentName}").bodyText(context),
|
||||
],
|
||||
).paddingAll(16),
|
||||
);
|
||||
},
|
||||
),
|
||||
40.height,
|
||||
],
|
||||
),
|
||||
8.height,
|
||||
const AppTextFormField(
|
||||
labelText: TranslationKeys.quantity,
|
||||
textInputType: TextInputType.number,
|
||||
),
|
||||
8.height,
|
||||
SingleItemDropDownMenu<Lookup, CylinderTypesProvider>(
|
||||
context: context,
|
||||
title: TranslationKeys.cylinderType,
|
||||
),
|
||||
8.height,
|
||||
SingleItemDropDownMenu<Lookup, CylinderSizeProvider>(
|
||||
context: context,
|
||||
title: TranslationKeys.cylinderSize,
|
||||
),
|
||||
8.height,
|
||||
// SingleItemDropDownMenu<Lookup, CylinderTypesProvider>(
|
||||
// context: context,
|
||||
// title: TranslationKeys.department,
|
||||
// ),
|
||||
// 8.height,
|
||||
// SingleItemDropDownMenu<Lookup, CylinderTypesProvider>(
|
||||
// context: context,
|
||||
// title: TranslationKeys.destinationSite,
|
||||
// ),
|
||||
// 8.height,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
floatingActionButton: AppFilledButton(
|
||||
label: TranslationKeys.submitRequest,
|
||||
maxWidth: true,
|
||||
onPressed: () {},
|
||||
),
|
||||
),
|
||||
).expanded,
|
||||
AppFilledButton(label: TranslationKeys.submitRequest, maxWidth: true, onPressed: _submit),
|
||||
],
|
||||
).paddingOnly(left: 16, right: 16, bottom: 24),
|
||||
);
|
||||
}
|
||||
|
||||
void _add() async {
|
||||
if (_formKey.currentState.validate() && await _currentDetails.validate(context)) {
|
||||
_formKey.currentState.save();
|
||||
_gasModel.gazRefillDetails.add(_currentDetails);
|
||||
_quantityController.clear();
|
||||
_currentDetails = GasRefillDetails();
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
void _delete(index) {
|
||||
_gasModel.gazRefillDetails.remove(_gasModel.gazRefillDetails[index]);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void _submit() {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/models/new_models/site.dart';
|
||||
import 'package:test_sa/providers/loading_list_notifier.dart';
|
||||
|
||||
import '../../controllers/api_routes/api_manager.dart';
|
||||
import '../../controllers/api_routes/urls.dart';
|
||||
|
||||
class SiteProvider extends LoadingListNotifier<Site> {
|
||||
@override
|
||||
Future getDate() async {
|
||||
if (loading ?? false) return -2;
|
||||
loading = true;
|
||||
notifyListeners();
|
||||
try {
|
||||
Response response = await ApiManager.instance.get(URLs.getSitesAutoComplete);
|
||||
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) => Site.fromJson(item)).toList();
|
||||
}
|
||||
loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
loading = false;
|
||||
stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue