|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:test_sa/controllers/localization/localization.dart';
|
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
|
import 'package:test_sa/models/subtitle.dart';
|
|
|
|
|
import 'package:test_sa/models/visits/visit.dart';
|
|
|
|
|
import 'package:test_sa/models/visits/visits_group.dart';
|
|
|
|
|
import 'package:test_sa/views/app_style/colors.dart';
|
|
|
|
|
import 'package:test_sa/views/app_style/sizing.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/buttons/app_button.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/buttons/app_small_button.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/status/employee/engineers_mune.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/visits/visit_status.dart';
|
|
|
|
|
|
|
|
|
|
class UpdateVisitsGroupSheet extends StatefulWidget {
|
|
|
|
|
final List<Visit> visits;
|
|
|
|
|
final String title;
|
|
|
|
|
|
|
|
|
|
const UpdateVisitsGroupSheet({Key key, this.visits, this.title}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_UpdateVisitsGroupSheetState createState() => _UpdateVisitsGroupSheetState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _UpdateVisitsGroupSheetState extends State<UpdateVisitsGroupSheet> {
|
|
|
|
|
// List<Lookup> status = [
|
|
|
|
|
// Lookup(name: "Done", id: 0,),
|
|
|
|
|
// Lookup(name: "Not Yet", id: 1),
|
|
|
|
|
// Lookup(name: "On Hold", id: 2,),
|
|
|
|
|
// ];
|
|
|
|
|
//
|
|
|
|
|
// List<Lookup> taskStatus = [
|
|
|
|
|
// Lookup(name: "Passed", id: 0,),
|
|
|
|
|
// Lookup(name: "Failed", id: 1),
|
|
|
|
|
// ];
|
|
|
|
|
VisitsGroup _group = VisitsGroup();
|
|
|
|
|
|
|
|
|
|
// File _image;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
_group.visits = widget.visits;
|
|
|
|
|
//_group.date = DateTime.now();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
|
height: MediaQuery.of(context).size.height / 1.3,
|
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
|
horizontal: 16.0 * AppStyle.getScaleFactor(context),
|
|
|
|
|
vertical: 8.0 * AppStyle.getScaleFactor(context),
|
|
|
|
|
),
|
|
|
|
|
child: Stack(
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text(
|
|
|
|
|
widget.title ?? context.translation.updateVisitsGroup,
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle1,
|
|
|
|
|
textScaleFactor: AppStyle.getScaleFactor(context),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
ASmallButton(
|
|
|
|
|
text: context.translation.cancel,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 8 * AppStyle.getScaleFactor(context),
|
|
|
|
|
),
|
|
|
|
|
EngineersMenu(
|
|
|
|
|
initialValue: _group.engineer,
|
|
|
|
|
onSelect: (engineer) {
|
|
|
|
|
_group.engineer = engineer;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 8 * AppStyle.getScaleFactor(context),
|
|
|
|
|
),
|
|
|
|
|
// AOneImagePicker(
|
|
|
|
|
// image: _image,
|
|
|
|
|
// onPick: (image){
|
|
|
|
|
// _image =image;
|
|
|
|
|
// _group.image = base64Encode(image.readAsBytesSync());
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// SizedBox(height: 12 * AppStyle.getScaleFactor(context),),
|
|
|
|
|
// ATextFormField(
|
|
|
|
|
// initialValue: _group.jobSheetNumber,
|
|
|
|
|
// hintText: _subtitle.jobSheetNumber,
|
|
|
|
|
// style: Theme.of(context).textTheme.headline6,
|
|
|
|
|
// onSaved: (value){
|
|
|
|
|
// _group.jobSheetNumber = value;
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
|
|
|
|
|
// ATextFormField(
|
|
|
|
|
// initialValue: _group.workingHours,
|
|
|
|
|
// hintText: _subtitle.workingHours,
|
|
|
|
|
// style: Theme.of(context).textTheme.headline6,
|
|
|
|
|
// onSaved: (value){
|
|
|
|
|
// _group.workingHours = value;
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
|
|
|
|
|
// ATextFormField(
|
|
|
|
|
// initialValue: _group.travelingHours,
|
|
|
|
|
// hintText: _subtitle.travelingHours,
|
|
|
|
|
// style: Theme.of(context).textTheme.headline6,
|
|
|
|
|
// onSaved: (value){
|
|
|
|
|
// _group.travelingHours = value;
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
|
|
|
|
|
// Row(
|
|
|
|
|
// children: [
|
|
|
|
|
// Expanded(
|
|
|
|
|
// child: Text(
|
|
|
|
|
// "${_subtitle.date} :",
|
|
|
|
|
// style: Theme.of(context).textTheme.subtitle1,
|
|
|
|
|
// textScaleFactor: AppStyle.getScaleFactor(context),
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// ADatePicker(
|
|
|
|
|
// date: _group.date ?? DateTime.now(),
|
|
|
|
|
// onDatePicker: (date){
|
|
|
|
|
// _group.date = date;
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// // SizedBox(height: 8 * AStyling.getScaleFactor(context),),
|
|
|
|
|
// Text(
|
|
|
|
|
// "${_subtitle.status} :",
|
|
|
|
|
// style: Theme.of(context).textTheme.subtitle1,
|
|
|
|
|
// textScaleFactor: AppStyle.getScaleFactor(context),
|
|
|
|
|
// ),
|
|
|
|
|
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
|
|
|
|
|
// Center(
|
|
|
|
|
// child: Wrap(
|
|
|
|
|
// spacing: 10,
|
|
|
|
|
// runSpacing: 10,
|
|
|
|
|
// children: List.generate(
|
|
|
|
|
// status.length,
|
|
|
|
|
// (index) {
|
|
|
|
|
// bool isSelected = _group.status == status[index];
|
|
|
|
|
// return FilterItem(
|
|
|
|
|
// isSelected: isSelected,
|
|
|
|
|
// onSelected: (){
|
|
|
|
|
// if(isSelected)
|
|
|
|
|
// _group.status = null;
|
|
|
|
|
// else
|
|
|
|
|
// _group.status = status[index];
|
|
|
|
|
//
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// },
|
|
|
|
|
// status: status[index],
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// Text(
|
|
|
|
|
// "${_subtitle.taskStatus} :",
|
|
|
|
|
// style: Theme.of(context).textTheme.subtitle1,
|
|
|
|
|
// textScaleFactor: AppStyle.getScaleFactor(context),
|
|
|
|
|
// ),
|
|
|
|
|
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
|
|
|
|
|
// Center(
|
|
|
|
|
// child: Wrap(
|
|
|
|
|
// spacing: 10,
|
|
|
|
|
// runSpacing: 10,
|
|
|
|
|
// children: List.generate(
|
|
|
|
|
// taskStatus.length,
|
|
|
|
|
// (index) {
|
|
|
|
|
// bool isSelected = _group.taskStatus == taskStatus[index];
|
|
|
|
|
// return FilterItem(
|
|
|
|
|
// isSelected: isSelected,
|
|
|
|
|
// onSelected: (){
|
|
|
|
|
// if(isSelected)
|
|
|
|
|
// _group.taskStatus = null;
|
|
|
|
|
// else
|
|
|
|
|
// _group.taskStatus = taskStatus[index];
|
|
|
|
|
//
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// },
|
|
|
|
|
// status: taskStatus[index],
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 8 * AppStyle.getScaleFactor(context),
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: ListView.builder(
|
|
|
|
|
itemCount: widget.visits.length,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
Visit visit = widget.visits[index];
|
|
|
|
|
return Container(
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8),
|
|
|
|
|
margin: EdgeInsets.symmetric(vertical: 4),
|
|
|
|
|
decoration: BoxDecoration(color: AColors.primaryColor, borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: [AppStyle.boxShadow]),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text(
|
|
|
|
|
"${context.translation.sn}: " + visit.deviceSerialNumber ?? context.translation.noSerialNumberFound,
|
|
|
|
|
style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontSize: 16, fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
VisitStatusLabel(
|
|
|
|
|
visit: visit,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
AButton(
|
|
|
|
|
text: context.translation.update,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.of(context).pop(_group);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|