You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudsolutions-atoms/lib/views/widgets/search/asset_transfer_search_dialo...

198 lines
8.0 KiB
Dart

import 'package:flutter/material.dart';
import 'package:test_sa/controllers/localization/localization.dart';
import 'package:test_sa/models/device/asset_transfer.dart';
import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/buttons/app_small_button.dart';
import 'package:test_sa/views/widgets/equipment/pick_asset.dart';
import '../../../models/device/asset_transfer_search.dart';
import '../app_text_form_field.dart';
import '../switch_button.dart';
class AssetTransferSearchDialog extends StatefulWidget {
final AssetTransfer initialSearchValue;
final bool expandedSearch;
final Function(AssetTransfer) onSearch;
const AssetTransferSearchDialog({Key key, this.initialSearchValue, this.expandedSearch, this.onSearch}) : super(key: key);
@override
AssetTransferSearchDialogState createState() => AssetTransferSearchDialogState();
}
class AssetTransferSearchDialogState extends State<AssetTransferSearchDialog> with TickerProviderStateMixin {
AssetTransferSearch _search;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
bool _isLoading = false;
@override
void initState() {
super.initState();
_search = AssetTransferSearch();
// _search.fromSearch(widget.initialSearchValue);
}
@override
Widget build(BuildContext context) {
Subtitle subtitle = AppLocalization.of(context).subtitle;
return Padding(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: ClipRRect(
borderRadius: const BorderRadius.only(topLeft: Radius.circular(15), topRight: Radius.circular(15)),
clipBehavior: Clip.antiAliasWithSaveLayer,
child: Container(
color: Colors.white,
height: MediaQuery.of(context).size.height / 1.3,
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 20),
child: Form(
key: _formKey,
child: ListView(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ASmallButton(
text: subtitle.cancel,
onPressed: () {
Navigator.of(context).pop();
},
),
ASmallButton(
text: subtitle.search,
onPressed: () {
if (!_formKey.currentState.validate()) {
return;
}
_formKey.currentState.save();
Navigator.of(context).pop(_search);
},
)
],
),
ASwitchButton(
title: "Most Recent",
value: _search.mostRecent ?? false,
onChange: (value) {
_search.mostRecent = value;
setState(() {});
},
),
SizedBox(height: 8.0 * AppStyle.getScaleFactor(context)),
PickAsset(
device: _search.asset,
onPickAsset: (device) {
_search.asset = device;
setState(() {});
},
),
SizedBox(height: 8.0 * AppStyle.getScaleFactor(context)),
ATextFormField(
initialValue: "_search.title",
hintText: subtitle.title,
style: Theme.of(context).textTheme.titleLarge,
textInputAction: TextInputAction.search,
onAction: () {
if (!_formKey.currentState.validate()) {
return;
}
_formKey.currentState.save();
Navigator.of(context).pop(_search);
},
onSaved: (value) {
// _search.title = value;
},
),
SizedBox(height: 8.0 * AppStyle.getScaleFactor(context)),
// HospitalAutoCompleteField(
// initialValue: _search?.hospital?.name,
// onSearch: (selected) async {
// _search.building = null;
// _search.floor = null;
// _search.department = null;
// _search.buildingsList = null;
// _search.floorsList = null;
// _search.departmentsList = null;
// _isLoading = true;
// setState(() {});
// await HospitalsProvider().getHospitalsListByVal(searchVal: selected?.name ?? "").then((value) {
// _search.hospital = value?.firstWhere((element) => element.name == selected.name, orElse: () => null);
// _search.buildingsList = _search.hospital?.buildings;
// });
// _isLoading = false;
// setState(() {});
// },
// ),
const SizedBox(height: 8),
// BuildingTypeMenu(
// initialValue: _search?.building,
// building: _search.buildingsList,
// enabled: !_isLoading,
// onSelect: (status) {
// _search.building = status;
// _search.floorsList = status?.floors;
// setState(() {});
// },
// ),
const SizedBox(height: 8),
// FloorTypeMenu(
// initialValue: _search?.floor,
// floors: _search.floorsList,
// enabled: !_isLoading,
// onSelect: (status) {
// _search.floor = status;
// _search.departmentsList = _search.floor?.departments;
// setState(() {});
// },
// ),
const SizedBox(height: 8),
// DepartmentTypeMenu(
// initialValue: _search?.department,
// departments: _search.departmentsList,
// enabled: !_isLoading,
// onSelect: (status) {
// _search.department = status;
// setState(() {});
// },
// ),
SizedBox(height: 8.0 * AppStyle.getScaleFactor(context)),
ATextFormField(
initialValue: "_search.room",
hintText: subtitle.room,
style: Theme.of(context).textTheme.titleLarge,
textInputAction: TextInputAction.search,
onAction: () {
if (!_formKey.currentState.validate()) {
return;
}
_formKey.currentState.save();
Navigator.of(context).pop(_search);
},
onSaved: (value) {
// _search.room = value;
},
),
SizedBox(height: 16.0 * AppStyle.getScaleFactor(context)),
// Visibility(
// visible: (_search.toMap()..remove("mostRecent"))?.isNotEmpty ?? false,
// child: Padding(
// padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
// child: AButton(
// padding: EdgeInsets.zero,
// text: subtitle.clearSearch,
// onPressed: () {
// _search = DeviceTransferSearch();
// Navigator.of(context).pop(_search);
// },
// ),
// ),
// ),
],
),
),
),
),
);
}
}