Ui Changes
parent
cbddd807d4
commit
09843a9625
@ -0,0 +1,29 @@
|
|||||||
|
import 'package:flutter/src/widgets/framework.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
|
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||||
|
import 'package:test_sa/extensions/context_extension.dart';
|
||||||
|
import 'package:test_sa/models/device/asset.dart';
|
||||||
|
import 'package:test_sa/models/fault_description.dart';
|
||||||
|
import 'package:test_sa/models/lookup.dart';
|
||||||
|
|
||||||
|
class InternalAuditModel {
|
||||||
|
String? id;
|
||||||
|
int? deviceId;
|
||||||
|
String? deviceArName;
|
||||||
|
String? woOrderNo;
|
||||||
|
List<String>? devicePhotos;
|
||||||
|
Lookup? auditCheckList;
|
||||||
|
String? comments;
|
||||||
|
Asset? device;
|
||||||
|
|
||||||
|
InternalAuditModel({
|
||||||
|
this.id,
|
||||||
|
this.deviceArName,
|
||||||
|
this.devicePhotos,
|
||||||
|
this.deviceId,
|
||||||
|
this.woOrderNo,
|
||||||
|
this.comments,
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,138 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:developer';
|
||||||
|
import 'dart:io';
|
||||||
|
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/generic_attachment_model.dart';
|
||||||
|
import 'package:test_sa/models/helper_data_models/workorder/work_order_helper_models.dart';
|
||||||
|
import 'package:test_sa/models/lookup.dart';
|
||||||
|
import 'package:test_sa/modules/cm_module/utilities/service_request_utils.dart';
|
||||||
|
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
||||||
|
import 'package:test_sa/modules/internal_audit_module/models/internal_audit_model.dart';
|
||||||
|
import 'package:test_sa/modules/internal_audit_module/provider/internal_audit_checklist_provider.dart';
|
||||||
|
import 'package:test_sa/modules/internal_audit_module/provider/internal_audit_provider.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_lazy_loading.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/views/widgets/equipment/asset_picker.dart';
|
||||||
|
import 'package:test_sa/views/widgets/images/multi_image_picker.dart';
|
||||||
|
import '../../../../../../new_views/common_widgets/default_app_bar.dart';
|
||||||
|
|
||||||
|
class CreateEquipmentInternalAuditForm extends StatefulWidget {
|
||||||
|
static const String id = "/create-internal-audit-view";
|
||||||
|
|
||||||
|
const CreateEquipmentInternalAuditForm({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_CreateEquipmentInternalAuditFormState createState() => _CreateEquipmentInternalAuditFormState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CreateEquipmentInternalAuditFormState extends State<CreateEquipmentInternalAuditForm> with TickerProviderStateMixin {
|
||||||
|
late TextEditingController _commentController;
|
||||||
|
final InternalAuditModel _internalAuditModel = InternalAuditModel();
|
||||||
|
final List<GenericAttachmentModel> _deviceImages = [];
|
||||||
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||||
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_commentController = TextEditingController();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_commentController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
key: _scaffoldKey,
|
||||||
|
appBar: DefaultAppBar(title: 'Equipment Internal Audit Checklist'.addTranslation),
|
||||||
|
body: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
AssetPicker(
|
||||||
|
device: _internalAuditModel.device,
|
||||||
|
borderColor: AppColor.black20,
|
||||||
|
buttonColor: AppColor.white936,
|
||||||
|
onPick: (asset) async {
|
||||||
|
_internalAuditModel.device = asset;
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
16.height,
|
||||||
|
SingleItemDropDownMenu<Lookup, InternalAuditCheckListProvider>(
|
||||||
|
context: context,
|
||||||
|
height: 56.toScreenHeight,
|
||||||
|
title: 'Internal Audit Checklist'.addTranslation,
|
||||||
|
showShadow: false,
|
||||||
|
initialValue: _internalAuditModel.auditCheckList,
|
||||||
|
backgroundColor: AppColor.fieldBgColor(context),
|
||||||
|
showAsBottomSheet: true,
|
||||||
|
onSelect: (status) {
|
||||||
|
if (status != null) {
|
||||||
|
_internalAuditModel.auditCheckList = status;
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
16.height,
|
||||||
|
AppTextFormField(
|
||||||
|
backgroundColor: AppColor.fieldBgColor(context),
|
||||||
|
labelText: 'Remarks'.addTranslation,
|
||||||
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
||||||
|
alignLabelWithHint: true,
|
||||||
|
textInputType: TextInputType.multiline,
|
||||||
|
showShadow: false,
|
||||||
|
onSaved: (text) {},
|
||||||
|
),
|
||||||
|
16.height,
|
||||||
|
AttachmentPicker(
|
||||||
|
label: context.translation.attachments,
|
||||||
|
attachment: _deviceImages,
|
||||||
|
buttonColor: AppColor.primary10,
|
||||||
|
onlyImages: false,
|
||||||
|
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.primary10),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).toShadowContainer(context),
|
||||||
|
).expanded,
|
||||||
|
FooterActionButton.footerContainer(
|
||||||
|
context: context,
|
||||||
|
child: AppFilledButton(label: context.translation.submitRequest, buttonColor: AppColor.primary10, onPressed: _submit),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _submit() async {
|
||||||
|
InternalAuditProvider internalAuditProvider = Provider.of<InternalAuditProvider>(context, listen: false);
|
||||||
|
if (_formKey.currentState!.validate()) {
|
||||||
|
_formKey.currentState!.save();
|
||||||
|
List<WorkOrderAttachments> attachement = [];
|
||||||
|
for (var item in _deviceImages) {
|
||||||
|
String fileName = ServiceRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
|
||||||
|
// attachement.add(WorkOrderAttachments(id: 0, name: fileName));
|
||||||
|
}
|
||||||
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:http/http.dart';
|
||||||
|
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||||
|
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||||
|
import 'package:test_sa/models/lookup.dart';
|
||||||
|
import 'package:test_sa/providers/loading_list_notifier.dart';
|
||||||
|
|
||||||
|
class InternalAuditCheckListProvider extends LoadingListNotifier<Lookup> {
|
||||||
|
@override
|
||||||
|
Future getData({int? id}) async {
|
||||||
|
if (loading ?? false) return -2;
|
||||||
|
loading = true;
|
||||||
|
notifyListeners();
|
||||||
|
Response response;
|
||||||
|
try {
|
||||||
|
response = await ApiManager.instance.get(URLs.getPentryTaskStatus);
|
||||||
|
} catch (error) {
|
||||||
|
loading = false;
|
||||||
|
stateCode = -1;
|
||||||
|
notifyListeners();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
stateCode = response.statusCode;
|
||||||
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||||
|
// client's request was successfully received
|
||||||
|
List listJson = json.decode(response.body)["data"];
|
||||||
|
items = listJson.map((department) => Lookup.fromJson(department)).toList();
|
||||||
|
}
|
||||||
|
loading = false;
|
||||||
|
notifyListeners();
|
||||||
|
return response.statusCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:http/http.dart';
|
||||||
|
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||||
|
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||||
|
import 'package:test_sa/models/device/asset_search.dart';
|
||||||
|
import 'package:test_sa/models/lookup.dart';
|
||||||
|
|
||||||
|
class InternalAuditProvider extends ChangeNotifier {
|
||||||
|
final pageItemNumber = 10;
|
||||||
|
final searchPageItemNumber = 10;
|
||||||
|
int pageNo = 1;
|
||||||
|
void reset() {
|
||||||
|
pageNo = 1;
|
||||||
|
stateCode = null;
|
||||||
|
}
|
||||||
|
int? stateCode;
|
||||||
|
bool isDetailLoading = false;
|
||||||
|
bool nextPage = false;
|
||||||
|
bool isNextPageLoading = false;
|
||||||
|
bool isLoading = false;
|
||||||
|
Future<int> getInternalAuditById(int id) async {
|
||||||
|
try {
|
||||||
|
isLoading = true;
|
||||||
|
notifyListeners();
|
||||||
|
//Need to replace
|
||||||
|
Response response = await ApiManager.instance.get("${URLs.getTRAFById}?id=$id");
|
||||||
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||||
|
// trafRequestDataModel = TrafRequestDataModel.fromJson(json.decode(response.body)["data"]);
|
||||||
|
}
|
||||||
|
isLoading = false;
|
||||||
|
notifyListeners();
|
||||||
|
return 0;
|
||||||
|
} catch (error) {
|
||||||
|
isLoading = false;
|
||||||
|
notifyListeners();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue