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/device/asset.dart'; import 'package:test_sa/models/lookup.dart'; import 'package:test_sa/models/new_models/traf_department.dart'; import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart'; import 'package:test_sa/modules/traf_module/asset_auto_complete_field.dart'; import 'package:test_sa/modules/traf_module/traf_request_detail_page.dart'; import 'package:test_sa/modules/traf_module/update_traf_request_page.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/default_app_bar.dart'; import 'package:test_sa/new_views/common_widgets/multiple_item_drop_down_menu.dart'; import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart'; import 'package:test_sa/providers/loading_list_notifier.dart'; import 'package:test_sa/providers/lookups/department_lookup_provider.dart'; import 'package:test_sa/providers/lookups/request_type_lookup_provider.dart'; import 'package:test_sa/providers/lookups/yes_no_lookup_provider.dart'; import 'package:test_sa/views/widgets/equipment/asset_picker.dart'; import 'traf_request_model.dart'; class CreateTRAFRequestPage extends StatefulWidget { static const String id = "/create-TRAF"; CreateTRAFRequestPage({Key? key}) : super(key: key); @override _CreateTRAFRequestPageState createState() { return _CreateTRAFRequestPageState(); } } class _CreateTRAFRequestPageState extends State { final GlobalKey _formKey = GlobalKey(); bool _acknowledgement = false; Asset? asset; Lookup? requestType; Lookup? isUsedSolelyOrShared; Lookup? otherServicesEffects; Lookup? useInCombination; TrafRequestDataModel? trafRequest; List abc = []; List departments = []; @override void initState() { super.initState(); trafRequest = TrafRequestDataModel(); resetProviders(); } void resetProviders() { Provider.of(context, listen: false).reset(); // Provider.of(context, listen: false).reset(); } @override void dispose() { super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( appBar: const DefaultAppBar(title: "TRAF Request"), body: Form( key: _formKey, child: Column( children: [ ListView(padding: const EdgeInsets.all(16), children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // SingleItemDropDownMenu( // context: context, // height: 56.toScreenHeight, // title: context.translation.taskType, // showShadow: false, // backgroundColor: AppColor.fieldBgColor(context), // showAsBottomSheet: true, // initialValue: selectedType, // onSelect: (type) {}, // ), SingleItemDropDownMenu( context: context, showAsBottomSheet: true, backgroundColor: AppColor.neutral100, showShadow: false, title: context.translation.requestType, initialValue: requestType, onSelect: (value) { requestType = value; trafRequest?.requestTypeId = value?.value; setState(() {}); }, ), if (requestType?.value == 1) ...[ 12.height, AssetAutoCompleteField( clearAfterPick: false, byName: true, initialValue: "", onPick: (part) { // model.partCatalogItem = PartCatalogItem(id: part.sparePart?.id, partNumber: part.sparePart?.partNo, partName: part.sparePart?.partName, oracleCode: part.sparePart?.oracleCode); // setState(() {}); }, ), ], if (requestType?.value == 2) ...[ 12.height, AssetPicker( device: asset, editable: false, showLoading: false, borderColor: AppColor.black20, backgroundColor: AppColor.white936, onPick: (asset) async { this.asset = asset; setState(() {}); // pendingAssetServiceRequest = null; // _serviceRequest.device = asset; // await checkAssetForPendingServiceRequest(asset.id!.toInt()); // if (pendingAssetServiceRequest != null && pendingAssetServiceRequest!.details!.isNotEmpty) { // showPendingRequestBottomSheet(); // } }, ), ], 12.height, Text( "Request Details", style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50, fontWeight: FontWeight.w600), ), 12.height, AppTextFormField( initialValue: "", labelText: "How would the requested technology solve the current situation and/or serve the purpose?", backgroundColor: AppColor.fieldBgColor(context), labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), floatingLabelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), showShadow: false, makeMultiLinesNull: true, onChange: (value) { trafRequest?.purposeAnswer = value; }, ), 12.height, AppTextFormField( initialValue: "", labelText: "What is the current practice?", backgroundColor: AppColor.fieldBgColor(context), labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), showShadow: false, makeMultiLinesNull: true, onChange: (value) { trafRequest?.currentPractise = value; }, ), 12.height, AppTextFormField( initialValue: "", makeMultiLinesNull: true, labelText: "Census Q1", backgroundColor: AppColor.fieldBgColor(context), labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), showShadow: false, textInputType: TextInputType.number, onChange: (value) { trafRequest?.censusQ1 = int.tryParse(value); }, ), 12.height, AppTextFormField( initialValue: "", makeMultiLinesNull: true, labelText: "Census Q2", backgroundColor: AppColor.fieldBgColor(context), labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), showShadow: false, textInputType: TextInputType.number, onChange: (value) { trafRequest?.censusQ2 = int.tryParse(value); }, ), 12.height, AppTextFormField( initialValue: "", makeMultiLinesNull: true, labelText: "Census Q3", backgroundColor: AppColor.fieldBgColor(context), labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), showShadow: false, textInputType: TextInputType.number, onChange: (value) { trafRequest?.censusQ3 = int.tryParse(value); }, ), 12.height, AppTextFormField( initialValue: "", makeMultiLinesNull: true, labelText: "Census Q4", backgroundColor: AppColor.fieldBgColor(context), labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), showShadow: false, textInputType: TextInputType.number, onChange: (value) { trafRequest?.censusQ4 = int.tryParse(value); }, ), 12.height, SingleItemDropDownMenu( context: context, showAsBottomSheet: true, backgroundColor: AppColor.neutral100, showShadow: false, height: 80, title: "List down names & contact information of users going to use the technology & specify if they are part-time or full time?", initialValue: isUsedSolelyOrShared, onSelect: (value) { // isUsedSolelyOrShared = value; setState(() {}); }, ), 12.height, SingleItemDropDownMenu( context: context, showAsBottomSheet: true, backgroundColor: AppColor.neutral100, showShadow: false, height: 80, title: "Is the requesting department going to use the technology solely or shared with other departments?", initialValue: isUsedSolelyOrShared, onSelect: (value) { isUsedSolelyOrShared = value; trafRequest?.usingSolelyOrSharedId = value?.value; if (isUsedSolelyOrShared?.value != 1) { departments = []; Provider.of(context, listen: false).reset(); } setState(() {}); }, ), if (isUsedSolelyOrShared?.value == 1) ...[ 12.height, MultipleItemDropDownMenu( context: context, showAsBottomSheet: true, backgroundColor: AppColor.neutral100, showShadow: false, showCancel: true, requestById: context.userProvider.user?.clientId, title: "Please specify departments and relations", initialValue: departments, onSelect: (value) { departments = value ?? []; // setState(() { // // }); }, ), ], 12.height, SingleItemDropDownMenu( context: context, showAsBottomSheet: true, backgroundColor: AppColor.neutral100, showShadow: false, height: 80, title: "Would other services be effected by acquiring the new equipment?", initialValue: otherServicesEffects, onSelect: (value) { otherServicesEffects = value; trafRequest?.isEffectedId = value?.value; setState(() {}); }, ), if (otherServicesEffects?.value == 1) ...[ 12.height, AppTextFormField( initialValue: "", // makeMultiLinesNull: true, textInputType: TextInputType.multiline, alignLabelWithHint: true, labelText: "List down these services and stat how would it be effected", backgroundColor: AppColor.fieldBgColor(context), labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), showShadow: false, onChange: (value) { trafRequest?.effectedServices = value; }, ), ], 12.height, SingleItemDropDownMenu( context: context, showAsBottomSheet: true, backgroundColor: AppColor.neutral100, showShadow: false, height: 80, title: "Is the equipment going to be used with combination of other equipment to accomplish a specific procedure?", initialValue: useInCombination, onSelect: (value) { useInCombination = value; trafRequest?.isCombinationId = value?.value; setState(() {}); }, ), if (useInCombination?.value == 1) ...[ 12.height, AppTextFormField( initialValue: "", textInputType: TextInputType.multiline, alignLabelWithHint: true, labelText: "kindly describe in detail", backgroundColor: AppColor.fieldBgColor(context), labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), showShadow: false, onChange: (value) { trafRequest?.usedWithCombination = value; }, ), ] // 23.height, // AttachmentPicker( // label: context.translation.attachImage, // attachment: attachments, // buttonColor: AppColor.black10, // onlyImages: false, // buttonIcon: 'image-plus'.toSvgAsset(color: context.isDark ? AppColor.primary10 : AppColor.neutral120), // //verify this if not required delete this .. // onChange: (attachments) { // attachments = attachments; // setState(() {}); // }, // ), ], ).toShadowContainer(context, padding: 12, borderRadius: 20), 16.height, Row( children: [ Checkbox( value: _acknowledgement, visualDensity: const VisualDensity(horizontal: -4.0, vertical: -4.0), activeColor: AppColor.blueStatus(context), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, onChanged: (value) { setState(() { _acknowledgement = value!; }); }), 12.width, "I acknowledge the information filled above is correct".addTranslation.bodyText(context).custom(color: context.isDark ? AppColor.primary50 : AppColor.neutral120).expanded, ], ), ]).expanded, FooterActionButton.footerContainer( context: context, child: AppFilledButton( buttonColor: AppColor.primary10, label: context.translation.submitRequest, onPressed: _acknowledgement ? _submit : null, // buttonColor: AppColor.primary10, ), ), ], ), ), ); } void _submit() { Navigator.push(context, MaterialPageRoute(builder: (context) => TrafRequestDetailPage(trafId: 27))); } }