timer improvements
parent
407c913002
commit
f3f09d1eb2
@ -1,119 +1,119 @@
|
|||||||
|
//
|
||||||
import 'package:flutter/material.dart';
|
// import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
// import 'package:provider/provider.dart';
|
||||||
import 'package:test_sa/controllers/providers/api/service_requests_provider.dart';
|
// import 'package:test_sa/controllers/providers/api/service_requests_provider.dart';
|
||||||
import 'package:test_sa/extensions/context_extension.dart';
|
// import 'package:test_sa/extensions/context_extension.dart';
|
||||||
import 'package:test_sa/extensions/int_extensions.dart';
|
// import 'package:test_sa/extensions/int_extensions.dart';
|
||||||
import 'package:test_sa/models/timer_model.dart';
|
// import 'package:test_sa/models/timer_model.dart';
|
||||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
// import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||||
import 'package:test_sa/views/widgets/date_and_time/date_picker.dart';
|
// import 'package:test_sa/views/widgets/date_and_time/date_picker.dart';
|
||||||
import 'package:test_sa/views/widgets/date_and_time/time_picker.dart';
|
// import 'package:test_sa/views/widgets/date_and_time/time_picker.dart';
|
||||||
import 'package:test_sa/views/widgets/timer/app_timer.dart';
|
// import 'package:test_sa/views/widgets/timer/app_timer.dart';
|
||||||
|
//
|
||||||
class TimeDurationView extends StatelessWidget {
|
// class TimeDurationView extends StatelessWidget {
|
||||||
const TimeDurationView({Key ?key}) : super(key: key);
|
// const TimeDurationView({Key ?key}) : super(key: key);
|
||||||
|
//
|
||||||
@override
|
// @override
|
||||||
Widget build(BuildContext context) {
|
// Widget build(BuildContext context) { todo @delete
|
||||||
//TODO user the same form key everywhere....
|
// //TODO user the same form key everywhere....
|
||||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
// final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||||
return Consumer<ServiceRequestsProvider>(
|
// return Consumer<ServiceRequestsProvider>(
|
||||||
builder: (context, serviceRequestProvider,child) {
|
// builder: (context, serviceRequestProvider,child) {
|
||||||
serviceRequestProvider.currentSelectedRequest?.visitDate = '';
|
// serviceRequestProvider.currentSelectedRequest?.visitDate = '';
|
||||||
return Form(
|
// return Form(
|
||||||
key: _formKey,
|
// key: _formKey,
|
||||||
child: SingleChildScrollView(
|
// child: SingleChildScrollView(
|
||||||
child: Column(
|
// child: Column(
|
||||||
children: [
|
// children: [
|
||||||
ADatePicker(
|
// ADatePicker(
|
||||||
label: context.translation.visitDate,
|
// label: context.translation.visitDate,
|
||||||
hideShadow: true,
|
// hideShadow: true,
|
||||||
withIcon: false,
|
// withIcon: false,
|
||||||
hint: context.translation.select,
|
// hint: context.translation.select,
|
||||||
height: 70.toScreenHeight,
|
// height: 70.toScreenHeight,
|
||||||
date: DateTime.tryParse(serviceRequestProvider.currentSelectedRequest?.visitDate ?? ""),
|
// date: DateTime.tryParse(serviceRequestProvider.currentSelectedRequest?.visitDate ?? ""),
|
||||||
formatDateWithTime: true,
|
// formatDateWithTime: true,
|
||||||
onDatePicker: (selectedDate) {
|
// onDatePicker: (selectedDate) {
|
||||||
if (selectedDate != null) {
|
// if (selectedDate != null) {
|
||||||
showTimePicker(
|
// showTimePicker(
|
||||||
context: context,
|
// context: context,
|
||||||
initialTime: TimeOfDay.now(),
|
// initialTime: TimeOfDay.now(),
|
||||||
).then((selectedTime) {
|
// ).then((selectedTime) {
|
||||||
// Handle the selected date and time here.
|
// // Handle the selected date and time here.
|
||||||
if (selectedTime != null) {
|
// if (selectedTime != null) {
|
||||||
DateTime ? selectedDateTime = DateTime(
|
// DateTime ? selectedDateTime = DateTime(
|
||||||
selectedDate.year,
|
// selectedDate.year,
|
||||||
selectedDate.month,
|
// selectedDate.month,
|
||||||
selectedDate.day,
|
// selectedDate.day,
|
||||||
selectedTime.hour,
|
// selectedTime.hour,
|
||||||
selectedTime.minute,
|
// selectedTime.minute,
|
||||||
);
|
// );
|
||||||
serviceRequestProvider.currentSelectedRequest?.visitDate = selectedDateTime?.toIso8601String();
|
// serviceRequestProvider.currentSelectedRequest?.visitDate = selectedDateTime?.toIso8601String();
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
8.height,
|
// 8.height,
|
||||||
ATimePicker(
|
// ATimePicker(
|
||||||
label: context.translation.startTime,
|
// label: context.translation.startTime,
|
||||||
hint: context.translation.select,
|
// hint: context.translation.select,
|
||||||
withIcon: false,
|
// withIcon: false,
|
||||||
withBorder: false,
|
// withBorder: false,
|
||||||
height: 70.toScreenHeight,
|
// height: 70.toScreenHeight,
|
||||||
time: serviceRequestProvider.selectedTime,
|
// time: serviceRequestProvider.selectedTime,
|
||||||
onTimePicker: (selectedTime) {
|
// onTimePicker: (selectedTime) {
|
||||||
if (selectedTime != null) {
|
// if (selectedTime != null) {
|
||||||
print('time selected $selectedTime');
|
// print('time selected $selectedTime');
|
||||||
serviceRequestProvider.selectedTime = selectedTime;
|
// serviceRequestProvider.selectedTime = selectedTime;
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
8.height,
|
// 8.height,
|
||||||
ATimePicker(
|
// ATimePicker(
|
||||||
label: context.translation.endTime,
|
// label: context.translation.endTime,
|
||||||
hint: context.translation.select,
|
// hint: context.translation.select,
|
||||||
withIcon: false,
|
// withIcon: false,
|
||||||
withBorder: false,
|
// withBorder: false,
|
||||||
height: 70.toScreenHeight,
|
// height: 70.toScreenHeight,
|
||||||
time: serviceRequestProvider.selectedTime,
|
// time: serviceRequestProvider.selectedTime,
|
||||||
onTimePicker: (selectedTime) {
|
// onTimePicker: (selectedTime) {
|
||||||
if (selectedTime != null) {
|
// if (selectedTime != null) {
|
||||||
print('time selected $selectedTime');
|
// print('time selected $selectedTime');
|
||||||
serviceRequestProvider.selectedTime = selectedTime;
|
// serviceRequestProvider.selectedTime = selectedTime;
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
8.height,
|
// 8.height,
|
||||||
SizedBox(
|
// SizedBox(
|
||||||
width: double.infinity,
|
// width: double.infinity,
|
||||||
height: 70.toScreenHeight,
|
// height: 70.toScreenHeight,
|
||||||
child: AppTimer(
|
// child: AppTimer(
|
||||||
label: context.translation.workingHours,
|
// label: context.translation.workingHours,
|
||||||
timer: TimerModel(),
|
// timer: TimerModel(),
|
||||||
onPick: (TimerModel ?value){
|
// onPick: (TimerModel ?value){
|
||||||
|
//
|
||||||
},
|
// },
|
||||||
decoration: BoxDecoration(
|
// decoration: BoxDecoration(
|
||||||
color: AppColor.background(context),
|
// color: AppColor.background(context),
|
||||||
borderRadius: BorderRadius.circular(10),
|
// borderRadius: BorderRadius.circular(10),
|
||||||
// boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)],
|
// // boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)],
|
||||||
),
|
// ),
|
||||||
// enabled: serviceRequestProvider.currentSelectedRequest.date == null,
|
// // enabled: serviceRequestProvider.currentSelectedRequest.date == null,
|
||||||
enabled: true,
|
// enabled: true,
|
||||||
onChange: (timer) async {
|
// onChange: (timer) async {
|
||||||
print('timer i got is ${timer.toString()}');
|
// print('timer i got is ${timer.toString()}');
|
||||||
return true;
|
// return true;
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
|
//
|
||||||
),
|
// ),
|
||||||
16.height,
|
// 16.height,
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|||||||
@ -1,180 +1,180 @@
|
|||||||
import 'package:flutter/material.dart';
|
// import 'package:flutter/material.dart';
|
||||||
import 'package:test_sa/common_widgets/stapper_widget/components/base_step.dart';
|
// import 'package:test_sa/common_widgets/stapper_widget/components/base_step.dart';
|
||||||
import 'package:test_sa/common_widgets/stapper_widget/components/custom_line.dart';
|
// import 'package:test_sa/common_widgets/stapper_widget/components/custom_line.dart';
|
||||||
import 'package:test_sa/common_widgets/stapper_widget/custom_stepper.dart';
|
// import 'package:test_sa/common_widgets/stapper_widget/custom_stepper.dart';
|
||||||
import 'package:test_sa/controllers/providers/api/service_requests_provider.dart';
|
// import 'package:test_sa/controllers/providers/api/service_requests_provider.dart';
|
||||||
import 'package:test_sa/extensions/context_extension.dart';
|
// import 'package:test_sa/extensions/context_extension.dart';
|
||||||
import 'package:test_sa/extensions/int_extensions.dart';
|
// import 'package:test_sa/extensions/int_extensions.dart';
|
||||||
import 'package:test_sa/extensions/text_extensions.dart';
|
// import 'package:test_sa/extensions/text_extensions.dart';
|
||||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
// import 'package:test_sa/extensions/widget_extensions.dart';
|
||||||
import 'package:test_sa/new_views/app_style/app_color.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_filled_button.dart';
|
||||||
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
// import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
||||||
|
//
|
||||||
import 'components/asset_conditon_view.dart';
|
// import 'components/asset_conditon_view.dart';
|
||||||
import 'components/attachments_view.dart';
|
// import 'components/attachments_view.dart';
|
||||||
import 'components/time_duration_view.dart';
|
// import 'components/time_duration_view.dart';
|
||||||
|
//
|
||||||
class WorkOrderFormView extends StatefulWidget {
|
// class WorkOrderFormView extends StatefulWidget {
|
||||||
const WorkOrderFormView({Key? key}) : super(key: key);
|
// const WorkOrderFormView({Key? key}) : super(key: key);
|
||||||
|
//
|
||||||
@override
|
// @override
|
||||||
_WorkOrderFormViewState createState() => _WorkOrderFormViewState();
|
// _WorkOrderFormViewState createState() => _WorkOrderFormViewState();
|
||||||
}
|
// }
|
||||||
|
// todo @delete
|
||||||
class _WorkOrderFormViewState extends State<WorkOrderFormView> {
|
// class _WorkOrderFormViewState extends State<WorkOrderFormView> {
|
||||||
int currentStep = 0;
|
// int currentStep = 0;
|
||||||
int activeStep = 0;
|
// int activeStep = 0;
|
||||||
int reachedStep = 0;
|
// int reachedStep = 0;
|
||||||
int upperBound = 2;
|
// int upperBound = 2;
|
||||||
final formKey = GlobalKey<FormState>();
|
// final formKey = GlobalKey<FormState>();
|
||||||
|
//
|
||||||
@override
|
// @override
|
||||||
void initState() {
|
// void initState() {
|
||||||
super.initState();
|
// super.initState();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@override
|
// @override
|
||||||
Widget build(BuildContext context) {
|
// Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
// return Scaffold(
|
||||||
backgroundColor: AppColor.neutral100,
|
// backgroundColor: AppColor.neutral100,
|
||||||
appBar: DefaultAppBar(title: context.translation.createWorkOrder),
|
// appBar: DefaultAppBar(title: context.translation.createWorkOrder),
|
||||||
body: Column(
|
// body: Column(
|
||||||
children: [
|
// children: [
|
||||||
16.height,
|
// 16.height,
|
||||||
CustomStepper(
|
// CustomStepper(
|
||||||
activeStep: activeStep,
|
// activeStep: activeStep,
|
||||||
lineStyle: LineStyle(
|
// lineStyle: LineStyle(
|
||||||
activeLineColor: AppColor.primary10,
|
// activeLineColor: AppColor.primary10,
|
||||||
finishedLineColor: AppColor.primary10,
|
// finishedLineColor: AppColor.primary10,
|
||||||
defaultLineColor: AppColor.white40,
|
// defaultLineColor: AppColor.white40,
|
||||||
lineThickness: 1,
|
// lineThickness: 1,
|
||||||
lineLength: 93.toScreenWidth,
|
// lineLength: 93.toScreenWidth,
|
||||||
lineType: LineType.normal,
|
// lineType: LineType.normal,
|
||||||
),
|
// ),
|
||||||
internalPadding: 2.toScreenWidth,
|
// internalPadding: 2.toScreenWidth,
|
||||||
steps: [
|
// steps: [
|
||||||
StepModel(customStep: customStepWidget(index: 0, stepIndex: 1), customTitle: customStepLabel(index: 1, label: context.translation.timeAndDuration)),
|
// StepModel(customStep: customStepWidget(index: 0, stepIndex: 1), customTitle: customStepLabel(index: 1, label: context.translation.timeAndDuration)),
|
||||||
StepModel(customStep: customStepWidget(index: 1, stepIndex: 2), customTitle: customStepLabel(index: 1, label: context.translation.assetsCondition)),
|
// StepModel(customStep: customStepWidget(index: 1, stepIndex: 2), customTitle: customStepLabel(index: 1, label: context.translation.assetsCondition)),
|
||||||
StepModel(customStep: customStepWidget(index: 2, stepIndex: 3), customTitle: customStepLabel(index: 1, label: context.translation.attachmentsAcknowledge)),
|
// StepModel(customStep: customStepWidget(index: 2, stepIndex: 3), customTitle: customStepLabel(index: 1, label: context.translation.attachmentsAcknowledge)),
|
||||||
],
|
// ],
|
||||||
onStepReached: (index) => setState(() => activeStep = index),
|
// onStepReached: (index) => setState(() => activeStep = index),
|
||||||
),
|
// ),
|
||||||
Expanded(
|
// Expanded(
|
||||||
child: Padding(
|
// child: Padding(
|
||||||
padding: EdgeInsetsDirectional.symmetric(horizontal: 16.toScreenWidth, vertical: 25.toScreenHeight),
|
// padding: EdgeInsetsDirectional.symmetric(horizontal: 16.toScreenWidth, vertical: 25.toScreenHeight),
|
||||||
child: getStepWidget(),
|
// child: getStepWidget(),
|
||||||
)),
|
// )),
|
||||||
bottomContainerWidget(),
|
// bottomContainerWidget(),
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Widget bottomContainerWidget() {
|
// Widget bottomContainerWidget() {
|
||||||
return Container(
|
// return Container(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 16.toScreenHeight),
|
// padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 16.toScreenHeight),
|
||||||
color: AppColor.white10,
|
// color: AppColor.white10,
|
||||||
child: Row(
|
// child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
// children: [
|
||||||
AppFilledButton(
|
// AppFilledButton(
|
||||||
label: context.translation.cancel,
|
// label: context.translation.cancel,
|
||||||
loading: false,
|
// loading: false,
|
||||||
buttonColor: AppColor.white60,
|
// buttonColor: AppColor.white60,
|
||||||
textColor: AppColor.black10,
|
// textColor: AppColor.black10,
|
||||||
onPressed: () async {
|
// onPressed: () async {
|
||||||
Navigator.pop(context);
|
// Navigator.pop(context);
|
||||||
// await snapshot.updateRequest(user: userProvider.user, request: serviceRequestProvider.serviceRequest);
|
// // await snapshot.updateRequest(user: userProvider.user, request: serviceRequestProvider.serviceRequest);
|
||||||
// Navigator.pop(context, true);
|
// // Navigator.pop(context, true);
|
||||||
},
|
// },
|
||||||
).expanded,
|
// ).expanded,
|
||||||
12.width,
|
// 12.width,
|
||||||
AppFilledButton(
|
// AppFilledButton(
|
||||||
label: context.translation.next,
|
// label: context.translation.next,
|
||||||
buttonColor: AppColor.primary10,
|
// buttonColor: AppColor.primary10,
|
||||||
loading: false,
|
// loading: false,
|
||||||
onPressed: () {
|
// onPressed: () {
|
||||||
_incrementActiveStep();
|
// _incrementActiveStep();
|
||||||
//TODO move to next step..
|
// //TODO move to next step..
|
||||||
},
|
// },
|
||||||
).expanded,
|
// ).expanded,
|
||||||
],
|
// ],
|
||||||
));
|
// ));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
void _incrementActiveStep() {
|
// void _incrementActiveStep() {
|
||||||
setState(() {
|
// setState(() {
|
||||||
++activeStep;
|
// ++activeStep;
|
||||||
if (reachedStep < activeStep) {
|
// if (reachedStep < activeStep) {
|
||||||
reachedStep = activeStep;
|
// reachedStep = activeStep;
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Future<void> _navigateNext(ServiceRequestsProvider serviceRequestsProvider) async {
|
// Future<void> _navigateNext(ServiceRequestsProvider serviceRequestsProvider) async {
|
||||||
if (activeStep < upperBound) {
|
// if (activeStep < upperBound) {
|
||||||
switch (activeStep) {
|
// switch (activeStep) {
|
||||||
case 0:
|
// case 0:
|
||||||
// await _navigateNextStep(listingVm);
|
// // await _navigateNextStep(listingVm);
|
||||||
break;
|
// break;
|
||||||
case 1:
|
// case 1:
|
||||||
break;
|
// break;
|
||||||
case 2:
|
// case 2:
|
||||||
_incrementActiveStep();
|
// _incrementActiveStep();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// Your onPressed code
|
// // Your onPressed code
|
||||||
|
//
|
||||||
Widget customStepWidget({required int index, required int stepIndex}) {
|
// Widget customStepWidget({required int index, required int stepIndex}) {
|
||||||
return CircleAvatar(
|
// return CircleAvatar(
|
||||||
backgroundColor: activeStep >= index ? AppColor.primary10 : AppColor.background(context),
|
// backgroundColor: activeStep >= index ? AppColor.primary10 : AppColor.background(context),
|
||||||
child: activeStep > index
|
// child: activeStep > index
|
||||||
? Icon(
|
// ? Icon(
|
||||||
Icons.done,
|
// Icons.done,
|
||||||
color: AppColor.white10,
|
// color: AppColor.white10,
|
||||||
size: 26.toScreenHeight,
|
// size: 26.toScreenHeight,
|
||||||
)
|
// )
|
||||||
: activeStep == index
|
// : activeStep == index
|
||||||
? Text(
|
// ? Text(
|
||||||
'0$stepIndex',
|
// '0$stepIndex',
|
||||||
style: const TextStyle(fontWeight: FontWeight.w500, color: AppColor.white10),
|
// style: const TextStyle(fontWeight: FontWeight.w500, color: AppColor.white10),
|
||||||
textAlign: TextAlign.center,
|
// textAlign: TextAlign.center,
|
||||||
)
|
// )
|
||||||
: Text(
|
// : Text(
|
||||||
'0$stepIndex',
|
// '0$stepIndex',
|
||||||
style: const TextStyle(color: AppColor.black20),
|
// style: const TextStyle(color: AppColor.black20),
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Widget customStepLabel({required String label, required int index}) {
|
// Widget customStepLabel({required String label, required int index}) {
|
||||||
return Column(
|
// return Column(
|
||||||
children: [
|
// children: [
|
||||||
Text(
|
// Text(
|
||||||
label,
|
// label,
|
||||||
textAlign: TextAlign.center,
|
// textAlign: TextAlign.center,
|
||||||
style: AppTextStyles.bodyText2.copyWith(color: AppColor.black20),
|
// style: AppTextStyles.bodyText2.copyWith(color: AppColor.black20),
|
||||||
),
|
// ),
|
||||||
],
|
// ],
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/// Returns the previous button.
|
// /// Returns the previous button.
|
||||||
|
//
|
||||||
Widget getStepWidget() {
|
// Widget getStepWidget() {
|
||||||
switch (activeStep) {
|
// switch (activeStep) {
|
||||||
case 0:
|
// case 0:
|
||||||
return const TimeDurationView();
|
// return const TimeDurationView();
|
||||||
case 1:
|
// case 1:
|
||||||
return AssetConditionView();
|
// return AssetConditionView();
|
||||||
case 2:
|
// case 2:
|
||||||
return AttachmentView();
|
// return AttachmentView();
|
||||||
default:
|
// default:
|
||||||
return const SizedBox();
|
// return const SizedBox();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|||||||
Loading…
Reference in New Issue