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/ppm_search_bar.dart

335 lines
12 KiB
Dart

import 'package:flutter/material.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/ppm/ppm_search.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/titles/app_sub_title.dart';
import '../switch_button.dart';
class PpmSearchDialog extends StatefulWidget {
final PpmSearch initialSearchValue;
final bool expandedSearch;
final Function(PpmSearch) onSearch;
const PpmSearchDialog({Key key, this.initialSearchValue, this.expandedSearch, this.onSearch}) : super(key: key);
@override
_PpmSearchDialogState createState() => _PpmSearchDialogState();
}
class _PpmSearchDialogState extends State<PpmSearchDialog> with TickerProviderStateMixin {
PpmSearch _search;
List<Lookup> status = [
Lookup(
name: "Done",
id: 0,
),
Lookup(name: "Not Yet", id: 1),
Lookup(
name: "On Hold",
id: 2,
),
];
List<Lookup> contactStatus = [
// Lookup(name: "Hospital Employee", value: "H",),
// Lookup(name: "Under Warranty", value: "CW"),
// Lookup(name: "Under Maintenance Contract", value: "CC",),
];
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
@override
void initState() {
super.initState();
_search = PpmSearch();
/// todo : working
// _search.fromSearch(widget.initialSearchValue);
}
@override
Widget build(BuildContext context) {
DateTime today = DateTime.now();
return SizedBox(
height: MediaQuery.of(context).size.height / 1.3,
child: Form(
key: _formKey,
child: ListView(
// shrinkWrap: true,
// physics: const ClampingScrollPhysics(),
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ASmallButton(
text: context.translation.cancel,
onPressed: () {
Navigator.of(context).pop();
},
),
ASmallButton(
text: context.translation.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),
),
// ATextFormField(
// initialValue: _search.deviceNumber,
// hintText: context.translation.assetNumber,
// style: Theme.of(context).textTheme.headline6,
// textInputAction: TextInputAction.search,
// onAction: () {
// if (!_formKey.currentState.validate()) {
// return;
// }
// _formKey.currentState.save();
// Navigator.of(context).pop(_search);
// },
// onSaved: (value) {
// _search.deviceNumber = value;
// },
// ),
// SizedBox(
// height: 8.0 * AppStyle.getScaleFactor(context),
// ),
// ATextFormField(
// initialValue: _search.deviceName,
// hintText: context.translation.assetName,
// style: Theme.of(context).textTheme.headline6,
// textInputAction: TextInputAction.search,
// onAction: () {
// if (!_formKey.currentState.validate()) {
// return;
// }
// _formKey.currentState.save();
// Navigator.of(context).pop(_search);
// },
// onSaved: (value) {
// _search.deviceName = value;
// },
// ),
// SizedBox(
// height: 8.0 * AppStyle.getScaleFactor(context),
// ),
// ATextFormField(
// initialValue: _search.deviceSerialNumber,
// hintText: context.translation.serialNumber,
// style: Theme.of(context).textTheme.headline6,
// textInputAction: TextInputAction.search,
// onAction: () {
// if (!_formKey.currentState.validate()) {
// return;
// }
// _formKey.currentState.save();
// Navigator.of(context).pop(_search);
// },
// onSaved: (value) {
// _search.deviceSerialNumber = value;
// },
// ),
// SizedBox(
// height: 8.0 * AppStyle.getScaleFactor(context),
// ),
// HospitalAutoCompleteField(
// initialValue: _search.hospital?.name,
// // onSave: (value){
// // _search.hospital = value;
// // },
// onSearch: (value) {
// _search.hospital = value;
// Navigator.of(context).pop(_search);
// },
// ),
// // SizedBox(height: 8.0 * AppStyle.getScaleFactor(context),),
// // ATextFormField(
// // initialValue: _search.brand,
// // hintText: _subtitle.brand,
// // style: Theme.of(context).textTheme.headline6,
// // textInputAction: TextInputAction.search,
// // onAction: (){
// // if(!_formKey.currentState.validate()) {
// // return;
// // }
// // _formKey.currentState.save();
// // Navigator.of(context).pop(_search);
// // },
// // onSaved: (value){
// // _search.brand = value;
// // },
// // ),
// SizedBox(
// height: 8.0 * AppStyle.getScaleFactor(context),
// ),
// AutoCompleteModelField(
// initialValue: _search.model,
// onPick: (lookup) {
// _search.model = lookup;
// Navigator.of(context).pop(_search);
// },
// ),
// // ATextFormField(
// // initialValue: _search.model,
// // hintText: _subtitle.model,
// // style: Theme.of(context).textTheme.headline6,
// // textInputAction: TextInputAction.search,
// // onAction: (){
// // if(!_formKey.currentState.validate()) {
// // return;
// // }
// // _formKey.currentState.save();
// // Navigator.of(context).pop(_search);
// // },
// // onSaved: (value){
// // _search.model = value;
// // },
// // ),
// SizedBox(
// height: 8.0 * AppStyle.getScaleFactor(context),
// ),
// ASubTitle(context.translation.status),
// SizedBox(
// height: 4.0 * AppStyle.getScaleFactor(context),
// ),
// PentryVisitsStatusMenu(
// initialValue: _search.statusValue,
// onSelect: (status) {
// _search.statusValue = status;
// },
// ),
// Wrap(
// spacing: 10,
// runSpacing: 10,
// children: List.generate(
// status.length,
// (index) {
// bool isSelected = _search.statusValue == status[index].id;
// return FilterItem(
// isSelected: isSelected,
// onSelected: (){
// if(isSelected) {
// _search.statusValue = null;
// } else {
// _search.statusValue = status[index].id;
// }
//
// setState(() {});
// },
// status: status[index],
// );
// }
//
// ),
// ),
SizedBox(
height: 8.0 * AppStyle.getScaleFactor(context),
),
ASubTitle(context.translation.contactStatus),
SizedBox(
height: 4.0 * AppStyle.getScaleFactor(context),
),
// AssignedToMenu(
// initialValue: _search.contactStatus,
// onSelect: (status) {
// _search.contactStatus = status;
// },
// ),
// Wrap(
// spacing: 10,
// runSpacing: 10,
// children: List.generate(
// contactStatus.length,
// (index) {
// bool isSelected = _search.contactStatus == contactStatus[index];
// return FilterItem(
// isSelected: isSelected,
// onSelected: (){
// if(isSelected) {
// _search.contactStatus = null;
// } else {
// _search.contactStatus = contactStatus[index];
// }
//
// setState(() {});
// },
// status: contactStatus[index],
// );
// }
//
// ),
// ),
SizedBox(
height: 8.0 * AppStyle.getScaleFactor(context),
),
ASubTitle(context.translation.actualDate),
SizedBox(
height: 4.0 * AppStyle.getScaleFactor(context),
),
// FromToDateBar(
// from: _search.actualDateFrom,
// to: _search.actualDateTo,
// onPickFrom: (date) {
// _search.actualDateFrom = date;
// },
// onPickTo: (date) {
// _search.actualDateTo = date;
// },
// ),
// SizedBox(
// height: 8.0 * AppStyle.getScaleFactor(context),
// ),
// ASubTitle(context.translation.expectDate),
// SizedBox(
// height: 4.0 * AppStyle.getScaleFactor(context),
// ),
// FromToDateBar(
// from: _search.expectedDateFrom ?? DateTime(today.year, today.month, 1),
// to: _search.expectedDateTo ?? DateTime(today.year, (today.month + 1).clamp(1, 12), today.month == 12 ? 31 : 0),
// onPickFrom: (date) {
// _search.expectedDateFrom = date;
// },
// onPickTo: (date) {
// _search.expectedDateTo = date;
// },
// ),
// Visibility(
// visible: _search.toMap().isNotEmpty,
// child: Padding(
// padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
// child: AButton(
// padding: EdgeInsets.zero,
// text: context.translation.clearSearch,
// onPressed: () {
// _search = VisitsSearch();
// Navigator.of(context).pop(_search);
// },
// ),
// ),
// ),
],
),
),
);
}
}