new Api models and provider added
parent
667e12a548
commit
f257fbadfa
@ -0,0 +1,3 @@
|
||||
<svg width="19" height="17" viewBox="0 0 19 17" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M17.2188 17H1.78125C0.79748 17 0 16.0486 0 14.875V2.125C0 0.95138 0.79748 0 1.78125 0H17.2188C18.2025 0 19 0.95138 19 2.125V14.875C19 16.0486 18.2025 17 17.2188 17ZM4.15625 2.47917C3.00853 2.47917 2.07812 3.58912 2.07812 4.95833C2.07812 6.32754 3.00853 7.4375 4.15625 7.4375C5.30397 7.4375 6.23438 6.32754 6.23438 4.95833C6.23438 3.58912 5.30397 2.47917 4.15625 2.47917ZM2.375 14.1667H16.625V9.20833L13.3774 5.33397C13.2035 5.12652 12.9215 5.12652 12.7476 5.33397L7.71875 11.3333L5.65862 8.87564C5.48473 8.66818 5.20277 8.66818 5.02884 8.87564L2.375 12.0417V14.1667Z" fill="#3B3D4A"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 697 B |
@ -0,0 +1,186 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
import 'base_step_delegate.dart';
|
||||
typedef OnStepReached = void Function(int index);
|
||||
|
||||
enum StepShape { circle, rRectangle }
|
||||
|
||||
enum BorderType { normal, dotted }
|
||||
|
||||
class BaseStep extends StatelessWidget {
|
||||
const BaseStep({
|
||||
Key key,
|
||||
@required this.step,
|
||||
@required this.isActive,
|
||||
@required this.isFinished,
|
||||
@required this.isAlreadyReached,
|
||||
@required this.radius,
|
||||
@required this.isUnreached,
|
||||
@required this.activeStepBackgroundColor,
|
||||
@required this.unreachedBackgroundColor,
|
||||
@required this.activeStepBorderColor,
|
||||
@required this.unreachedBorderColor,
|
||||
@required this.activeTextColor,
|
||||
@required this.activeIconColor,
|
||||
@required this.unreachedTextColor,
|
||||
@required this.unreachedIconColor,
|
||||
@required this.padding,
|
||||
@required this.stepRadius,
|
||||
@required this.showStepBorder,
|
||||
@required this.lineLength,
|
||||
@required this.enabled,
|
||||
}) : super(key: key);
|
||||
final StepModel step;
|
||||
final bool isActive;
|
||||
final bool isUnreached;
|
||||
final bool isFinished;
|
||||
final bool isAlreadyReached ;
|
||||
final double radius;
|
||||
final Color activeStepBackgroundColor;
|
||||
final Color unreachedBackgroundColor;
|
||||
final Color activeStepBorderColor;
|
||||
final Color unreachedBorderColor;
|
||||
final Color activeTextColor;
|
||||
final Color activeIconColor;
|
||||
final Color unreachedTextColor;
|
||||
final Color unreachedIconColor;
|
||||
final double padding;
|
||||
final double stepRadius;
|
||||
final bool showStepBorder;
|
||||
final double lineLength;
|
||||
final bool enabled;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: (radius * 2) + (padding ?? 0),
|
||||
height: radius * 2.5 + 25,
|
||||
child: CustomMultiChildLayout(
|
||||
delegate: BaseStepDelegate(
|
||||
stepRadius: radius,
|
||||
topTitle: step.topTitle,
|
||||
direction: Axis.horizontal),
|
||||
children: [
|
||||
LayoutId(
|
||||
id: BaseStepElem.step,
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
borderRadius: BorderRadius.circular(stepRadius ?? 0),
|
||||
child: Container(
|
||||
width: radius * 2,
|
||||
height: radius * 2,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: _handleColor(context, isFinished, isActive,
|
||||
isAlreadyReached)),
|
||||
alignment: Alignment.center,
|
||||
child: _buildIcon(context),
|
||||
),
|
||||
)),
|
||||
LayoutId(
|
||||
id: BaseStepElem.title, child: _buildStepTitle(context))
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Color _handleColor(BuildContext context, bool isFinished, bool isActive,
|
||||
bool isAlreadyReached) {
|
||||
if (isActive) {
|
||||
return activeStepBackgroundColor ?? Colors.transparent;
|
||||
} else {
|
||||
if (isFinished) {
|
||||
return AppColor.primary10;
|
||||
} else if (isAlreadyReached) {
|
||||
return AppColor.primary10;
|
||||
} else {
|
||||
return unreachedBackgroundColor ?? Colors.transparent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Color _handleTitleColor(BuildContext context, bool isFinished, bool isActive,
|
||||
bool isAlreadyReached) {
|
||||
if (isActive) {
|
||||
return activeTextColor ?? Theme.of(context).colorScheme.primary;
|
||||
} else {
|
||||
if (isFinished) {
|
||||
return Colors.transparent;
|
||||
} else if (isAlreadyReached) {
|
||||
return Colors.transparent;
|
||||
} else {
|
||||
return unreachedTextColor ?? Colors.grey.shade400;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Widget _buildStepTitle(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: (radius * 4.5) +
|
||||
(padding ?? 0),
|
||||
child: step.customTitle ??
|
||||
Text(
|
||||
step.title ?? '',
|
||||
maxLines: 3,
|
||||
textAlign: TextAlign.center,
|
||||
softWrap: false,
|
||||
overflow: TextOverflow.visible,
|
||||
style: Theme.of(context).textTheme.bodyMedium.copyWith(
|
||||
color: _handleTitleColor(
|
||||
context, isFinished, isActive, isAlreadyReached),
|
||||
height: 1,
|
||||
// fontSize: radius * 0.45,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
SizedBox _buildIcon(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: radius * 2,
|
||||
height: radius * 2,
|
||||
child: Center(
|
||||
child: step.customStep ??
|
||||
Icon(
|
||||
isActive && step.activeIcon != null
|
||||
? step.activeIcon.icon
|
||||
: isFinished && step.finishIcon != null
|
||||
? step.finishIcon.icon
|
||||
: step.icon.icon,
|
||||
size: radius * 0.9,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
class StepModel {
|
||||
final Icon icon;
|
||||
final Icon finishIcon;
|
||||
final Icon activeIcon;
|
||||
final Widget customStep;
|
||||
final String title;
|
||||
final Widget customTitle;
|
||||
final String lineText;
|
||||
final Widget customLineWidget;
|
||||
final bool topTitle;
|
||||
final bool enabled;
|
||||
const StepModel({
|
||||
this.icon,
|
||||
this.finishIcon,
|
||||
this.activeIcon,
|
||||
this.title,
|
||||
this.lineText,
|
||||
this.customStep,
|
||||
this.customTitle,
|
||||
this.customLineWidget,
|
||||
this.topTitle = false,
|
||||
this.enabled = true,
|
||||
}) : assert(icon != null || customStep != null);
|
||||
}
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum BaseStepElem { step, title }
|
||||
|
||||
class BaseStepDelegate extends MultiChildLayoutDelegate {
|
||||
final double stepRadius;
|
||||
final Axis direction;
|
||||
final bool topTitle;
|
||||
|
||||
BaseStepDelegate({
|
||||
@required this.stepRadius,
|
||||
@required this.direction,
|
||||
this.topTitle = false,
|
||||
});
|
||||
|
||||
@override
|
||||
void performLayout(Size size) {
|
||||
assert(hasChild(BaseStepElem.step));
|
||||
|
||||
layoutChild(
|
||||
BaseStepElem.step,
|
||||
BoxConstraints.loose(
|
||||
size), // This just says that the child cannot be bigger than the whole layout.
|
||||
);
|
||||
|
||||
positionChild(
|
||||
BaseStepElem.step,
|
||||
Offset(
|
||||
(size.width - 2 * stepRadius) / 2,
|
||||
direction == Axis.horizontal
|
||||
? 0
|
||||
: (size.height - 2 * stepRadius) / 2));
|
||||
|
||||
if (hasChild(BaseStepElem.title)) {
|
||||
final Size titleSize = layoutChild(
|
||||
BaseStepElem.title,
|
||||
const BoxConstraints(),
|
||||
);
|
||||
|
||||
Offset titleOffset = Offset(-titleSize.width / 2 + (size.width / 2),
|
||||
topTitle ? -(stepRadius + titleSize.height) : (stepRadius * 2.35));
|
||||
|
||||
positionChild(BaseStepElem.title, titleOffset);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRelayout(BaseStepDelegate oldDelegate) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class EasyLine extends StatelessWidget {
|
||||
final double length;
|
||||
final double width;
|
||||
final Color color;
|
||||
final double thickness;
|
||||
final double spacing;
|
||||
final LineType lineType;
|
||||
final Axis axis;
|
||||
|
||||
const EasyLine({
|
||||
key,
|
||||
this.length = 50.0,
|
||||
this.color = Colors.grey,
|
||||
this.thickness = 3,
|
||||
this.spacing = 3.0,
|
||||
this.width = 2.0,
|
||||
this.lineType = LineType.normal,
|
||||
this.axis = Axis.horizontal,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: axis == Axis.horizontal
|
||||
? length
|
||||
: thickness,
|
||||
height: axis == Axis.vertical
|
||||
? length : thickness,
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.circular(100),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum LineType {
|
||||
normal,
|
||||
dotted,
|
||||
dashed,
|
||||
}
|
||||
class LineStyle {
|
||||
final Color defaultLineColor;
|
||||
final Color unreachedLineColor;
|
||||
final Color activeLineColor;
|
||||
final Color finishedLineColor;
|
||||
final double lineLength;
|
||||
final double lineThickness;
|
||||
final double lineWidth;
|
||||
final double lineSpace;
|
||||
final LineType lineType;
|
||||
final LineType unreachedLineType;
|
||||
final Color progressColor;
|
||||
final double progress;
|
||||
const LineStyle({
|
||||
Key key,
|
||||
this.lineType = LineType.dotted,
|
||||
this.defaultLineColor,
|
||||
this.unreachedLineColor,
|
||||
this.activeLineColor,
|
||||
this.finishedLineColor,
|
||||
this.lineLength = 40,
|
||||
this.lineWidth = 4,
|
||||
this.lineThickness = 1,
|
||||
this.lineSpace = 5,
|
||||
this.unreachedLineType,
|
||||
this.progressColor,
|
||||
this.progress,
|
||||
}) : assert(
|
||||
progressColor == null || progress != null,
|
||||
'progress should be defined to use progressColor',
|
||||
),
|
||||
assert(
|
||||
progress == null || (progress >= 0 && progress <= 1),
|
||||
'progress value should be between 0 and 1',
|
||||
);
|
||||
}
|
||||
@ -0,0 +1,289 @@
|
||||
library easy_stepper;
|
||||
import 'dart:math';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
import 'components/base_step.dart';
|
||||
import 'components/custom_line.dart';
|
||||
class CustomStepper extends StatefulWidget {
|
||||
final List<StepModel> steps;
|
||||
final OnStepReached onStepReached;
|
||||
final Color unreachedStepBackgroundColor;
|
||||
final Color unreachedStepTextColor;
|
||||
final Color unreachedStepIconColor;
|
||||
final Color unreachedStepBorderColor;
|
||||
final BorderType unreachedStepBorderType;
|
||||
final Color activeStepBackgroundColor;
|
||||
final Color activeStepTextColor;
|
||||
final Color activeStepIconColor;
|
||||
final Color activeStepBorderColor;
|
||||
final BorderType activeStepBorderType;
|
||||
final Color finishedStepBackgroundColor;
|
||||
final Color finishedStepBorderColor;
|
||||
final Color finishedStepTextColor;
|
||||
final Color finishedStepIconColor;
|
||||
final BorderType finishedStepBorderType;
|
||||
final double stepRadius;
|
||||
final int activeStep;
|
||||
final int maxReachedStep;
|
||||
final Set<int> reachedSteps;
|
||||
final AlignmentGeometry alignment;
|
||||
final double internalPadding;
|
||||
final EdgeInsetsGeometry padding;
|
||||
final bool titlesAreLargerThanSteps;
|
||||
final Curve stepAnimationCurve;
|
||||
final Duration stepAnimationDuration;
|
||||
final double borderThickness;
|
||||
final StepShape stepShape;
|
||||
final double stepBorderRadius;
|
||||
final bool showStepBorder;
|
||||
final bool showScrollbar;
|
||||
final bool fitWidth;
|
||||
final LineStyle lineStyle;
|
||||
|
||||
const CustomStepper({
|
||||
Key key,
|
||||
@required this.activeStep,
|
||||
@required this.steps,
|
||||
this.reachedSteps,
|
||||
this.maxReachedStep,
|
||||
this.onStepReached,
|
||||
this.unreachedStepBackgroundColor,
|
||||
this.unreachedStepTextColor,
|
||||
this.unreachedStepIconColor,
|
||||
this.unreachedStepBorderColor,
|
||||
this.activeStepTextColor,
|
||||
this.activeStepIconColor=AppColor.primary10,
|
||||
this.activeStepBackgroundColor=AppColor.primary10,
|
||||
this.activeStepBorderColor=AppColor.primary10,
|
||||
this.finishedStepBackgroundColor=AppColor.primary10,
|
||||
this.finishedStepBorderColor,
|
||||
this.finishedStepIconColor,
|
||||
this.stepRadius = 20,
|
||||
this.alignment = Alignment.center,
|
||||
this.fitWidth = true,
|
||||
this.showScrollbar = false,
|
||||
this.padding=EdgeInsetsDirectional.zero,
|
||||
this.titlesAreLargerThanSteps = false,
|
||||
this.internalPadding = 8,
|
||||
this.stepAnimationCurve = Curves.linear,
|
||||
this.stepAnimationDuration = const Duration(seconds: 1),
|
||||
this.borderThickness = 1,
|
||||
this.stepShape = StepShape.circle,
|
||||
this.stepBorderRadius,
|
||||
this.unreachedStepBorderType,
|
||||
this.activeStepBorderType,
|
||||
this.finishedStepBorderType,
|
||||
this.showStepBorder = false,
|
||||
this.lineStyle, this.finishedStepTextColor,
|
||||
}) : assert(maxReachedStep == null || reachedSteps == null,
|
||||
'only "maxReachedStep" or "reachedSteps" allowed'),
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
State<CustomStepper> createState() => _CustomStepperState();
|
||||
}
|
||||
|
||||
class _CustomStepperState extends State<CustomStepper> {
|
||||
ScrollController _scrollController;
|
||||
int _selectedIndex;
|
||||
LineStyle lineStyle;
|
||||
EdgeInsetsGeometry _padding;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
lineStyle = widget.lineStyle ?? const LineStyle();
|
||||
_selectedIndex = widget.activeStep;
|
||||
_scrollController = ScrollController();
|
||||
|
||||
_padding = const EdgeInsetsDirectional.all(10);
|
||||
if (widget.steps.any((element) => element.topTitle)) {
|
||||
_padding = _padding.add(const EdgeInsetsDirectional.only(top: 45));
|
||||
}
|
||||
if (widget.titlesAreLargerThanSteps) {
|
||||
_padding = _padding.add(EdgeInsetsDirectional.symmetric(
|
||||
horizontal: lineStyle.lineLength / 2));
|
||||
}
|
||||
if (widget.padding != null) {
|
||||
_padding.add(widget.padding);
|
||||
}
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(CustomStepper oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
|
||||
// Verify that the active step falls within a valid range.
|
||||
if (widget.activeStep >= 0 && widget.activeStep < widget.steps.length) {
|
||||
_selectedIndex = widget.activeStep;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_scrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// Controls the step scrolling.
|
||||
void _afterLayout(_) {
|
||||
for (int i = 0; i < widget.steps.length; i++) {
|
||||
_scrollController.animateTo(
|
||||
i *
|
||||
((widget.stepRadius * 2) +
|
||||
widget.internalPadding +
|
||||
lineStyle.lineLength),
|
||||
duration: widget.stepAnimationDuration,
|
||||
curve: widget.stepAnimationCurve,
|
||||
);
|
||||
|
||||
if (_selectedIndex == i) break;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
lineStyle = widget.lineStyle ?? const LineStyle();
|
||||
|
||||
return Align(
|
||||
alignment: widget.alignment,
|
||||
child: NotificationListener<OverscrollIndicatorNotification>(
|
||||
onNotification: (OverscrollIndicatorNotification overscroll) {
|
||||
overscroll.disallowIndicator();
|
||||
return false;
|
||||
},
|
||||
child: FittedBox(
|
||||
fit: widget.fitWidth ? BoxFit.fitWidth : BoxFit.none,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: _buildEasySteps(),
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _buildEasySteps() {
|
||||
return List.generate(widget.steps.length, (index) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
_buildStep(index),
|
||||
_buildLine(index, Axis.horizontal),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
BaseStep _buildStep(int index) {
|
||||
final step = widget.steps[index];
|
||||
return BaseStep(
|
||||
step: step,
|
||||
radius: widget.stepRadius,
|
||||
isActive: index == widget.activeStep,
|
||||
isFinished: widget.reachedSteps != null
|
||||
? index < widget.activeStep && widget.reachedSteps.contains(index)
|
||||
: index < widget.activeStep,
|
||||
isUnreached: index > widget.activeStep,
|
||||
isAlreadyReached: widget.reachedSteps != null
|
||||
? widget.reachedSteps.contains(index)
|
||||
: widget.maxReachedStep != null
|
||||
? index <= widget.maxReachedStep
|
||||
: false,
|
||||
activeStepBackgroundColor: widget.activeStepBackgroundColor,
|
||||
activeStepBorderColor: widget.activeStepBorderColor,
|
||||
activeTextColor: widget.activeStepTextColor,
|
||||
activeIconColor: widget.activeStepIconColor,
|
||||
unreachedBackgroundColor: widget.unreachedStepBackgroundColor,
|
||||
unreachedBorderColor: widget.unreachedStepBorderColor,
|
||||
unreachedTextColor: widget.unreachedStepTextColor,
|
||||
unreachedIconColor: widget.unreachedStepIconColor,
|
||||
padding: max(widget.internalPadding, 0),
|
||||
stepRadius: widget.stepBorderRadius,
|
||||
showStepBorder: widget.showStepBorder,
|
||||
lineLength: lineStyle.lineLength,
|
||||
enabled: widget.steps[index].enabled,
|
||||
);
|
||||
}
|
||||
|
||||
// BorderType _handleBorderType(int index) {
|
||||
// if (index == widget.activeStep) {
|
||||
// //Active Step
|
||||
// return widget.activeStepBorderType ?? widget.defaultStepBorderType;
|
||||
// } else if (index > widget.activeStep) {
|
||||
// //Unreached Step
|
||||
// return widget.unreachedStepBorderType ?? widget.defaultStepBorderType;
|
||||
// } else if (index < widget.activeStep) {
|
||||
// //Finished Step
|
||||
// return widget.finishedStepBorderType ?? widget.defaultStepBorderType;
|
||||
// } else {
|
||||
// return widget.defaultStepBorderType;
|
||||
// }
|
||||
// }
|
||||
|
||||
Color _getLineColor(int index) {
|
||||
Color preferredColor;
|
||||
if (index == widget.activeStep) {
|
||||
//Active Step
|
||||
preferredColor = lineStyle.activeLineColor;
|
||||
} else if (index > widget.activeStep) {
|
||||
//Unreached Step
|
||||
preferredColor = lineStyle.unreachedLineColor;
|
||||
} else if (index < widget.activeStep) {
|
||||
//Finished Step
|
||||
preferredColor = lineStyle.finishedLineColor;
|
||||
}
|
||||
|
||||
return preferredColor ??
|
||||
lineStyle.defaultLineColor ??
|
||||
Theme.of(context).colorScheme.primary;
|
||||
}
|
||||
|
||||
Widget _buildLine(int index, Axis axis) {
|
||||
return index < widget.steps.length - 1
|
||||
? Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: axis == Axis.horizontal
|
||||
? (widget.stepRadius - lineStyle.lineThickness)
|
||||
: 0,
|
||||
),
|
||||
child: _buildBaseLine(index, axis),
|
||||
),
|
||||
if (axis == Axis.horizontal &&
|
||||
widget.steps[index].lineText != null) ...[
|
||||
const SizedBox(height: 5),
|
||||
SizedBox(
|
||||
width: lineStyle.lineLength,
|
||||
child: widget.steps[index].customLineWidget ??
|
||||
Text(
|
||||
widget.steps[index].lineText,
|
||||
maxLines: 3,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
)
|
||||
: const Offstage();
|
||||
}
|
||||
|
||||
EasyLine _buildBaseLine(int index, Axis axis) {
|
||||
return EasyLine(
|
||||
length: lineStyle.lineLength,
|
||||
color: _getLineColor(index),
|
||||
thickness: lineStyle.lineThickness,
|
||||
spacing: lineStyle.lineSpace,
|
||||
width: lineStyle.lineWidth,
|
||||
axis: axis,
|
||||
lineType:
|
||||
index > widget.activeStep - 1 && lineStyle.unreachedLineType != null
|
||||
? lineStyle.unreachedLineType
|
||||
: lineStyle.lineType,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,142 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/enums/user_types.dart';
|
||||
import 'package:test_sa/models/new_models/dashboardCount.dart';
|
||||
import 'package:test_sa/models/new_models/dashboard_detail.dart';
|
||||
|
||||
class DashBoardProvider extends ChangeNotifier {
|
||||
bool isAllCountLoading = false;
|
||||
bool isLoading = false;
|
||||
bool _isDetailLoading = false;
|
||||
|
||||
int _status =0;
|
||||
|
||||
|
||||
int get status => _status;
|
||||
|
||||
set status(int value) {
|
||||
_status = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
int _currentListIndex = 0;
|
||||
|
||||
int get currentListIndex => _currentListIndex;
|
||||
|
||||
set currentListIndex(int value) {
|
||||
_currentListIndex = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
int stateCode;
|
||||
|
||||
DashboardCount dashboardCount;
|
||||
|
||||
DashboardDetail _requestDetailList;
|
||||
|
||||
DashboardDetail get requestDetailList => _requestDetailList;
|
||||
|
||||
set requestDetailList(DashboardDetail value) {
|
||||
_requestDetailList = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
final pageItemNumber = 10;
|
||||
int pageNum = 1;
|
||||
bool nextPage = true;
|
||||
|
||||
void reset() {
|
||||
pageNum = 1;
|
||||
nextPage = true;
|
||||
stateCode = null;
|
||||
}
|
||||
|
||||
|
||||
Future<int> getDashBoardCount({@required UsersTypes usersType}) async {
|
||||
isAllCountLoading = true;
|
||||
String url='';
|
||||
if(usersType==UsersTypes.engineer){
|
||||
url = URLs.engineerDashboardCountUrl;
|
||||
}
|
||||
if(usersType==UsersTypes.nurse){
|
||||
url=URLs.nurseDashboardCountUrl;
|
||||
}
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.postWithOutBody(url);
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
dashboardCount = DashboardCount.fromJson(json.decode(response.body));
|
||||
}
|
||||
notifyListeners();
|
||||
isAllCountLoading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
isAllCountLoading = false;
|
||||
stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<int> getRequestDetail({bool showLoader = true,UsersTypes usersType, int status}) async {
|
||||
isDetailLoading =showLoader;
|
||||
Response response;
|
||||
String url='';
|
||||
if(usersType==UsersTypes.engineer){
|
||||
url = URLs.engineerDashboardDetailsUrl;
|
||||
}
|
||||
if(usersType==UsersTypes.nurse){
|
||||
url=URLs.nurseDashboardDetailsUrl;
|
||||
}
|
||||
try {
|
||||
Map<String, dynamic> body = {
|
||||
"statusValue": status,
|
||||
"pageNumber": pageNum,
|
||||
"pageSize" : pageItemNumber,
|
||||
};
|
||||
response = await ApiManager.instance.post(url, body: body);
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
if (requestDetailList == null) {
|
||||
requestDetailList = DashboardDetail.fromJson(json.decode(response.body));
|
||||
isDetailLoading = false;
|
||||
notifyListeners();
|
||||
} else {
|
||||
requestDetailList.data.addAll(DashboardDetail.fromJson(json.decode(response.body)["data"][0]).data);
|
||||
isDetailLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
if (requestDetailList.data.length >= pageItemNumber) {
|
||||
nextPage = true;
|
||||
} else {
|
||||
nextPage = false;
|
||||
}
|
||||
notifyListeners();
|
||||
} else {
|
||||
requestDetailList = null;
|
||||
}
|
||||
isDetailLoading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
isDetailLoading = false;
|
||||
stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool get isDetailLoading => _isDetailLoading;
|
||||
|
||||
set isDetailLoading(bool value) {
|
||||
_isDetailLoading = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
enum UsersTypes {
|
||||
engineer, // 0
|
||||
normal_user, // 1
|
||||
nurse, // 1
|
||||
}
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
class FixRemotely {
|
||||
int workOrderId;
|
||||
DateTime startDate;
|
||||
DateTime endDate;
|
||||
int workingHour;
|
||||
String comment;
|
||||
|
||||
FixRemotely({
|
||||
this.workOrderId,
|
||||
this.startDate,
|
||||
this.endDate,
|
||||
this.workingHour,
|
||||
this.comment,
|
||||
});
|
||||
|
||||
factory FixRemotely.fromJson(Map<String, dynamic> json) {
|
||||
return FixRemotely(
|
||||
workOrderId: json['workOrderId'],
|
||||
startDate: DateTime.parse(json['startDate']),
|
||||
endDate: DateTime.parse(json['endDate']),
|
||||
workingHour: json['workingHour'],
|
||||
comment: json['comment'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'workOrderId': workOrderId,
|
||||
'startDate': startDate.toIso8601String(),
|
||||
'endDate': endDate.toIso8601String(),
|
||||
'workingHour': workingHour,
|
||||
'comment': comment,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
class NeedVisit {
|
||||
int workOrderId;
|
||||
DateTime visitDate;
|
||||
String comment;
|
||||
|
||||
NeedVisit({
|
||||
this.workOrderId,
|
||||
this.visitDate,
|
||||
this.comment,
|
||||
});
|
||||
|
||||
factory NeedVisit.fromJson(Map<String, dynamic> json) {
|
||||
return NeedVisit(
|
||||
workOrderId: json['workOrderId'],
|
||||
visitDate: DateTime.parse(json['visitDate']),
|
||||
comment: json['comment'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'workOrderId': workOrderId,
|
||||
'visitDate': visitDate.toIso8601String(),
|
||||
'comment': comment,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
class NurseActionModel {
|
||||
int workOrderId;
|
||||
String feedback;
|
||||
String signatureNurse;
|
||||
|
||||
NurseActionModel({
|
||||
this.workOrderId,
|
||||
this.feedback,
|
||||
this.signatureNurse,
|
||||
});
|
||||
|
||||
factory NurseActionModel.fromJson(Map<String, dynamic> json) {
|
||||
return NurseActionModel(
|
||||
workOrderId: json['workOrderId'],
|
||||
feedback: json['feedback'],
|
||||
signatureNurse: json['signatureNurse'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'workOrderId': workOrderId,
|
||||
'feedback': feedback,
|
||||
'signatureNurse': signatureNurse,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
class DashboardCount {
|
||||
Data data;
|
||||
String message;
|
||||
String title;
|
||||
String innerMessage;
|
||||
int responseCode;
|
||||
bool isSuccess;
|
||||
|
||||
DashboardCount(
|
||||
{this.data,
|
||||
this.message,
|
||||
this.title,
|
||||
this.innerMessage,
|
||||
this.responseCode,
|
||||
this.isSuccess});
|
||||
|
||||
DashboardCount.fromJson(Map<String, dynamic> json) {
|
||||
data = json['data'] != null ? Data.fromJson(json['data']) : null;
|
||||
message = json['message'];
|
||||
title = json['title'];
|
||||
innerMessage = json['innerMessage'];
|
||||
responseCode = json['responseCode'];
|
||||
isSuccess = json['isSuccess'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data.toJson();
|
||||
}
|
||||
data['message'] = message;
|
||||
data['title'] = title;
|
||||
data['innerMessage'] = innerMessage;
|
||||
data['responseCode'] = responseCode;
|
||||
data['isSuccess'] = isSuccess;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
int countOpen;
|
||||
int countInprogress;
|
||||
int countComplete;
|
||||
int countAcknowledge;
|
||||
int countHighPriority;
|
||||
int countOverdue;
|
||||
|
||||
Data(
|
||||
{this.countOpen,
|
||||
this.countInprogress,
|
||||
this.countComplete,
|
||||
this.countAcknowledge,
|
||||
this.countHighPriority,
|
||||
this.countOverdue});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
countOpen = json['countOpen']??0;
|
||||
countInprogress = json['countInprogress']??0;
|
||||
countComplete = json['countComplete']??0;
|
||||
countAcknowledge = json['countAcknowledge']??0;
|
||||
countHighPriority = json['countHighPriority']??0;
|
||||
countOverdue = json['countOverdue']??0;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['countOpen'] = countOpen;
|
||||
data['countInprogress'] = countInprogress;
|
||||
data['countComplete'] = countComplete;
|
||||
data['countAcknowledge'] = countAcknowledge;
|
||||
data['countHighPriority'] = countHighPriority;
|
||||
data['countOverdue'] = countOverdue;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,140 @@
|
||||
class DashboardDetail {
|
||||
List<Data> data;
|
||||
int totalRows;
|
||||
String message;
|
||||
String title;
|
||||
String innerMessage;
|
||||
int responseCode;
|
||||
bool isSuccess;
|
||||
|
||||
DashboardDetail(
|
||||
{this.data,
|
||||
this.totalRows,
|
||||
this.message,
|
||||
this.title,
|
||||
this.innerMessage,
|
||||
this.responseCode,
|
||||
this.isSuccess});
|
||||
|
||||
DashboardDetail.fromJson(Map<String, dynamic> json) {
|
||||
if (json['data'] != null) {
|
||||
data = <Data>[];
|
||||
json['data'].forEach((v) {
|
||||
data.add(Data.fromJson(v));
|
||||
});
|
||||
}
|
||||
totalRows = json['totalRows'];
|
||||
message = json['message'];
|
||||
title = json['title'];
|
||||
innerMessage = json['innerMessage'];
|
||||
responseCode = json['responseCode'];
|
||||
isSuccess = json['isSuccess'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data.map((v) => v.toJson()).toList();
|
||||
}
|
||||
data['totalRows'] = totalRows;
|
||||
data['message'] = message;
|
||||
data['title'] = title;
|
||||
data['innerMessage'] = innerMessage;
|
||||
data['responseCode'] = responseCode;
|
||||
data['isSuccess'] = isSuccess;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
int id;
|
||||
String typeTransaction;
|
||||
String transactionDate;
|
||||
String statusName;
|
||||
String priorityName;
|
||||
bool isHighPriority;
|
||||
String assetName;
|
||||
String assetNumber;
|
||||
String requestTypeName;
|
||||
String requestNo;
|
||||
|
||||
Data(
|
||||
{this.id,
|
||||
this.typeTransaction,
|
||||
this.transactionDate,
|
||||
this.statusName,
|
||||
this.priorityName,
|
||||
this.isHighPriority,
|
||||
this.assetName,
|
||||
this.assetNumber,
|
||||
this.requestTypeName,
|
||||
this.requestNo});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
typeTransaction = json['typeTransaction'];
|
||||
transactionDate = json['transactionDate'];
|
||||
statusName = json['statusName'];
|
||||
priorityName = json['priorityName'];
|
||||
isHighPriority = json['isHighPriority'];
|
||||
assetName = json['assetName'];
|
||||
assetNumber = json['assetNumber'];
|
||||
requestTypeName = json['requestTypeName'];
|
||||
requestNo = json['requestNo'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['typeTransaction'] = typeTransaction;
|
||||
data['transactionDate'] = transactionDate;
|
||||
data['statusName'] = statusName;
|
||||
data['priorityName'] = priorityName;
|
||||
data['isHighPriority'] = isHighPriority;
|
||||
data['assetName'] = assetName;
|
||||
data['assetNumber'] = assetNumber;
|
||||
data['requestTypeName'] = requestTypeName;
|
||||
data['requestNo'] = requestNo;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
class CommonResponseModel{
|
||||
bool data;
|
||||
String message;
|
||||
String title;
|
||||
String innerMessage;
|
||||
int responseCode;
|
||||
bool isSuccess;
|
||||
|
||||
CommonResponseModel({
|
||||
this.data,
|
||||
this.message,
|
||||
this.title,
|
||||
this.innerMessage,
|
||||
this.responseCode,
|
||||
this.isSuccess,
|
||||
});
|
||||
|
||||
factory CommonResponseModel.fromJson(Map<String, dynamic> json) {
|
||||
return CommonResponseModel(
|
||||
data: json['data'],
|
||||
message: json['message'] ?? '',
|
||||
title: json['title'],
|
||||
innerMessage: json['innerMessage'],
|
||||
responseCode: json['responseCode'],
|
||||
isSuccess: json['isSuccess'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'data': data,
|
||||
'message': message,
|
||||
'title': title,
|
||||
'innerMessage': innerMessage,
|
||||
'responseCode': responseCode,
|
||||
'isSuccess': isSuccess,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,834 @@
|
||||
class WorkOrderDetail {
|
||||
WorkOrder data;
|
||||
String message;
|
||||
String title;
|
||||
String innerMessage;
|
||||
int responseCode;
|
||||
bool isSuccess;
|
||||
|
||||
WorkOrderDetail({
|
||||
this.data,
|
||||
this.message,
|
||||
this.title,
|
||||
this.innerMessage,
|
||||
this.responseCode,
|
||||
this.isSuccess,
|
||||
});
|
||||
|
||||
factory WorkOrderDetail.fromJson(Map<String, dynamic> json) {
|
||||
return WorkOrderDetail(
|
||||
data: WorkOrder.fromJson(json['data']),
|
||||
message: json['message'],
|
||||
title: json['title'],
|
||||
innerMessage: json['innerMessage'],
|
||||
responseCode: json['responseCode'],
|
||||
isSuccess: json['isSuccess'],
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'data': data?.toJson(),
|
||||
'message': message,
|
||||
'title': title,
|
||||
'innerMessage': innerMessage,
|
||||
'responseCode': responseCode,
|
||||
'isSuccess': isSuccess,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class WorkOrder {
|
||||
String workOrderNo;
|
||||
WorkOrderCreatedBy workOrderCreatedBy;
|
||||
DateTime requestedDate;
|
||||
Asset asset;
|
||||
AssetGroup assetGroup;
|
||||
Manufacturer manufacturer;
|
||||
Model model;
|
||||
AssetNDModel assetNDModel;
|
||||
Site site;
|
||||
Building building;
|
||||
Floor floor;
|
||||
Department department;
|
||||
dynamic room;
|
||||
AssetType assetType;
|
||||
AssignedEmployee assignedEmployee;
|
||||
dynamic lastActivityStatus;
|
||||
Status status;
|
||||
NextStep nextStep;
|
||||
dynamic assetVerificationType;
|
||||
List<WorkOrderContactPerson> workOrderContactPerson;
|
||||
EquipmentStatus equipmentStatus;
|
||||
Priority priority;
|
||||
RequestedThrough requestedThrough;
|
||||
TypeOfRequest typeofRequest;
|
||||
dynamic loanAvailablity;
|
||||
dynamic assetLoan;
|
||||
dynamic safety;
|
||||
ProblemDescription problemDescription;
|
||||
String comments;
|
||||
String voiceNote;
|
||||
List<dynamic> workOrderAttachments;
|
||||
dynamic returnToService;
|
||||
dynamic serviceType;
|
||||
dynamic failureReasone;
|
||||
dynamic solution;
|
||||
dynamic totalWorkingHours;
|
||||
List<WorkOrderHistory> workOrderHistory;
|
||||
List<dynamic> activityMaintenances;
|
||||
List<dynamic> activitySpareParts;
|
||||
List<dynamic> activityAssetToBeRetireds;
|
||||
|
||||
WorkOrder({
|
||||
this.workOrderNo,
|
||||
this.workOrderCreatedBy,
|
||||
this.requestedDate,
|
||||
this.asset,
|
||||
this.assetGroup,
|
||||
this.manufacturer,
|
||||
this.model,
|
||||
this.assetNDModel,
|
||||
this.site,
|
||||
this.building,
|
||||
this.floor,
|
||||
this.department,
|
||||
this.room,
|
||||
this.assetType,
|
||||
this.assignedEmployee,
|
||||
this.lastActivityStatus,
|
||||
this.status,
|
||||
this.nextStep,
|
||||
this.assetVerificationType,
|
||||
this.workOrderContactPerson,
|
||||
this.equipmentStatus,
|
||||
this.priority,
|
||||
this.requestedThrough,
|
||||
this.typeofRequest,
|
||||
this.loanAvailablity,
|
||||
this.assetLoan,
|
||||
this.safety,
|
||||
this.problemDescription,
|
||||
this.comments,
|
||||
this.voiceNote,
|
||||
this.workOrderAttachments,
|
||||
this.returnToService,
|
||||
this.serviceType,
|
||||
this.failureReasone,
|
||||
this.solution,
|
||||
this.totalWorkingHours,
|
||||
this.workOrderHistory,
|
||||
this.activityMaintenances,
|
||||
this.activitySpareParts,
|
||||
this.activityAssetToBeRetireds,
|
||||
});
|
||||
|
||||
factory WorkOrder.fromJson(Map<String, dynamic> json) {
|
||||
return WorkOrder(
|
||||
workOrderNo: json['workOrderNo'],
|
||||
workOrderCreatedBy: WorkOrderCreatedBy.fromJson(json['workOrderCreatedBy']),
|
||||
requestedDate: DateTime.parse(json['requestedDate']),
|
||||
asset: Asset.fromJson(json['asset']),
|
||||
assetGroup: AssetGroup.fromJson(json['assetGroup']),
|
||||
manufacturer: Manufacturer.fromJson(json['manufacturer']),
|
||||
model: Model.fromJson(json['model']),
|
||||
assetNDModel: AssetNDModel.fromJson(json['assetNDModel']),
|
||||
site: Site.fromJson(json['site']),
|
||||
building: Building.fromJson(json['building']),
|
||||
floor: Floor.fromJson(json['floor']),
|
||||
department: Department.fromJson(json['department']),
|
||||
room: json['room'],
|
||||
assetType: AssetType.fromJson(json['assetType']),
|
||||
assignedEmployee: AssignedEmployee.fromJson(json['assignedEmployee']),
|
||||
lastActivityStatus: json['lastActivityStatus'],
|
||||
status: Status.fromJson(json['status']),
|
||||
nextStep: NextStep.fromJson(json['nextStep']),
|
||||
assetVerificationType: json['assetVerificationType'],
|
||||
workOrderContactPerson: (json['workOrderContactPerson'] as List)
|
||||
.map((i) => WorkOrderContactPerson.fromJson(i))
|
||||
.toList(),
|
||||
equipmentStatus: EquipmentStatus.fromJson(json['equipmentStatus']),
|
||||
priority: Priority.fromJson(json['priority']),
|
||||
requestedThrough: RequestedThrough.fromJson(json['requestedThrough']),
|
||||
typeofRequest: TypeOfRequest.fromJson(json['typeofRequest']),
|
||||
loanAvailablity: json['loanAvailablity'],
|
||||
assetLoan: json['assetLoan'],
|
||||
safety: json['safety'],
|
||||
problemDescription: ProblemDescription.fromJson(json['problemDescription']),
|
||||
comments: json['comments'],
|
||||
voiceNote: json['voiceNote'],
|
||||
workOrderAttachments: json['workOrderAttachments'] as List,
|
||||
returnToService: json['returnToService'],
|
||||
serviceType: json['serviceType'],
|
||||
failureReasone: json['failureReasone'],
|
||||
solution: json['solution'],
|
||||
totalWorkingHours: json['totalWorkingHours'],
|
||||
workOrderHistory: (json['workOrderHistory'] as List)
|
||||
.map((i) => WorkOrderHistory.fromJson(i))
|
||||
.toList(),
|
||||
activityMaintenances: json['activityMaintenances'] as List,
|
||||
activitySpareParts: json['activitySpareParts'] as List,
|
||||
activityAssetToBeRetireds: json['activityAssetToBeRetireds'] as List,
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'workOrderNo': workOrderNo,
|
||||
'workOrderCreatedBy': workOrderCreatedBy.toJson(),
|
||||
'requestedDate': requestedDate.toIso8601String(),
|
||||
'asset': asset.toJson(),
|
||||
'assetGroup': assetGroup.toJson(),
|
||||
'manufacturer': manufacturer.toJson(),
|
||||
'model': model.toJson(),
|
||||
'assetNDModel': assetNDModel.toJson(),
|
||||
'site': site.toJson(),
|
||||
'building': building.toJson(),
|
||||
'floor': floor.toJson(),
|
||||
'department': department.toJson(),
|
||||
'room': room,
|
||||
'assetType': assetType.toJson(),
|
||||
'assignedEmployee': assignedEmployee.toJson(),
|
||||
'lastActivityStatus': lastActivityStatus,
|
||||
'status': status.toJson(),
|
||||
'nextStep': nextStep.toJson(),
|
||||
'assetVerificationType': assetVerificationType,
|
||||
'workOrderContactPerson': workOrderContactPerson.map((i) => i.toJson()).toList(),
|
||||
'equipmentStatus': equipmentStatus.toJson(),
|
||||
'priority': priority.toJson(),
|
||||
'requestedThrough': requestedThrough.toJson(),
|
||||
'typeofRequest': typeofRequest.toJson(),
|
||||
'loanAvailablity': loanAvailablity,
|
||||
'assetLoan': assetLoan,
|
||||
'safety': safety,
|
||||
'problemDescription': problemDescription.toJson(),
|
||||
'comments': comments,
|
||||
'voiceNote': voiceNote,
|
||||
'workOrderAttachments': workOrderAttachments,
|
||||
'returnToService': returnToService,
|
||||
'serviceType': serviceType,
|
||||
'failureReasone': failureReasone,
|
||||
'solution': solution,
|
||||
'totalWorkingHours': totalWorkingHours,
|
||||
'workOrderHistory': workOrderHistory.map((i) => i.toJson()).toList(),
|
||||
'activityMaintenances': activityMaintenances,
|
||||
'activitySpareParts': activitySpareParts,
|
||||
'activityAssetToBeRetireds': activityAssetToBeRetireds,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class WorkOrderCreatedBy {
|
||||
String id;
|
||||
String userName;
|
||||
|
||||
WorkOrderCreatedBy({this.id, this.userName});
|
||||
|
||||
factory WorkOrderCreatedBy.fromJson(Map<String, dynamic> json) {
|
||||
return WorkOrderCreatedBy(
|
||||
id: json['id'],
|
||||
userName: json['userName'],
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'userName': userName,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class Asset {
|
||||
int id;
|
||||
String assetNumber;
|
||||
|
||||
Asset({this.id, this.assetNumber});
|
||||
|
||||
factory Asset.fromJson(Map<String, dynamic> json) {
|
||||
return Asset(
|
||||
id: json['id'],
|
||||
assetNumber: json['assetNumber'],
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'assetNumber': assetNumber,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class AssetGroup {
|
||||
int id;
|
||||
String name;
|
||||
|
||||
AssetGroup({this.id, this.name});
|
||||
|
||||
factory AssetGroup.fromJson(Map<String, dynamic> json) {
|
||||
return AssetGroup(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Manufacturer {
|
||||
int id;
|
||||
String name;
|
||||
|
||||
Manufacturer({this.id, this.name});
|
||||
|
||||
factory Manufacturer.fromJson(Map<String, dynamic> json) {
|
||||
return Manufacturer(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class Model {
|
||||
int id;
|
||||
String name;
|
||||
|
||||
Model({this.id, this.name});
|
||||
|
||||
factory Model.fromJson(Map<String, dynamic> json) {
|
||||
return Model(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class AssetNDModel {
|
||||
int id;
|
||||
String name;
|
||||
|
||||
AssetNDModel({this.id, this.name});
|
||||
|
||||
factory AssetNDModel.fromJson(Map<String, dynamic> json) {
|
||||
return AssetNDModel(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class Site {
|
||||
int id;
|
||||
String siteName;
|
||||
|
||||
Site({this.id, this.siteName});
|
||||
|
||||
factory Site.fromJson(Map<String, dynamic> json) {
|
||||
return Site(
|
||||
id: json['id'],
|
||||
siteName: json['siteName'],
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'siteName': siteName,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class Building {
|
||||
int id;
|
||||
String name;
|
||||
int value;
|
||||
|
||||
Building({this.id, this.name, this.value});
|
||||
|
||||
factory Building.fromJson(Map<String, dynamic> json) {
|
||||
return Building(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
value: json['value'],
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'value': value,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class Floor {
|
||||
int id;
|
||||
String name;
|
||||
int value;
|
||||
|
||||
Floor({this.id, this.name, this.value});
|
||||
|
||||
factory Floor.fromJson(Map<String, dynamic> json) {
|
||||
return Floor(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
value: json['value'],
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'value': value,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class Department {
|
||||
int id;
|
||||
String name;
|
||||
|
||||
Department({this.id, this.name});
|
||||
|
||||
factory Department.fromJson(Map<String, dynamic> json) {
|
||||
return Department(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class AssetType {
|
||||
int id;
|
||||
String name;
|
||||
int value;
|
||||
|
||||
AssetType({this.id, this.name, this.value});
|
||||
|
||||
factory AssetType.fromJson(Map<String, dynamic> json) {
|
||||
return AssetType(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
value: json['value'],
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'value': value,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class AssignedEmployee {
|
||||
String id;
|
||||
String userName;
|
||||
|
||||
AssignedEmployee({this.id, this.userName});
|
||||
|
||||
factory AssignedEmployee.fromJson(Map<String, dynamic> json) {
|
||||
return AssignedEmployee(
|
||||
id: json['id'],
|
||||
userName: json['userName'],
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'userName': userName,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class Status {
|
||||
int id;
|
||||
String name;
|
||||
int value;
|
||||
|
||||
Status({this.id, this.name, this.value});
|
||||
|
||||
factory Status.fromJson(Map<String, dynamic> json) {
|
||||
return Status(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
value: json['value'],
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'value': value,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class NextStep {
|
||||
int id;
|
||||
String name;
|
||||
int value;
|
||||
|
||||
NextStep({this.id, this.name, this.value});
|
||||
|
||||
factory NextStep.fromJson(Map<String, dynamic> json) {
|
||||
return NextStep(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
value: json['value'],
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'value': value,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class WorkOrderContactPerson {
|
||||
int id;
|
||||
String name;
|
||||
String employeeId;
|
||||
String position;
|
||||
String extension;
|
||||
String email;
|
||||
String mobilePhone;
|
||||
ContactUser contactUser;
|
||||
|
||||
WorkOrderContactPerson({
|
||||
this.id,
|
||||
this.name,
|
||||
this.employeeId,
|
||||
this.position,
|
||||
this.extension,
|
||||
this.email,
|
||||
this.mobilePhone,
|
||||
this.contactUser,
|
||||
});
|
||||
|
||||
factory WorkOrderContactPerson.fromJson(Map<String, dynamic> json) {
|
||||
return WorkOrderContactPerson(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
employeeId: json['employeeId'],
|
||||
position: json['position'],
|
||||
extension: json['extension'],
|
||||
email: json['email'],
|
||||
mobilePhone: json['mobilePhone'],
|
||||
contactUser: ContactUser.fromJson(json['contactUser']),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'employeeId': employeeId,
|
||||
'position': position,
|
||||
'extension': extension,
|
||||
'email': email,
|
||||
'mobilePhone': mobilePhone,
|
||||
'contactUser': contactUser.toJson(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class ContactUser {
|
||||
String id;
|
||||
String userName;
|
||||
|
||||
ContactUser({
|
||||
this.id,
|
||||
this.userName,
|
||||
});
|
||||
|
||||
factory ContactUser.fromJson(Map<String, dynamic> json) {
|
||||
return ContactUser(
|
||||
id: json['id'],
|
||||
userName: json['userName'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'userName': userName,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class EquipmentStatus {
|
||||
int id;
|
||||
String name;
|
||||
int value;
|
||||
|
||||
EquipmentStatus({this.id, this.name, this.value});
|
||||
|
||||
factory EquipmentStatus.fromJson(Map<String, dynamic> json) {
|
||||
return EquipmentStatus(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
value: json['value'],
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'value': value,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class Priority {
|
||||
int id;
|
||||
String name;
|
||||
int value;
|
||||
|
||||
Priority({this.id, this.name, this.value});
|
||||
|
||||
factory Priority.fromJson(Map<String, dynamic> json) {
|
||||
return Priority(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
value: json['value'],
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'value': value,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class RequestedThrough {
|
||||
int id;
|
||||
String name;
|
||||
|
||||
RequestedThrough({this.id, this.name});
|
||||
|
||||
factory RequestedThrough.fromJson(Map<String, dynamic> json) {
|
||||
return RequestedThrough(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class TypeOfRequest {
|
||||
int id;
|
||||
String name;
|
||||
|
||||
TypeOfRequest({this.id, this.name});
|
||||
|
||||
factory TypeOfRequest.fromJson(Map<String, dynamic> json) {
|
||||
return TypeOfRequest(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class ProblemDescription {
|
||||
int id;
|
||||
String name;
|
||||
|
||||
ProblemDescription({this.id, this.name});
|
||||
|
||||
factory ProblemDescription.fromJson(Map<String, dynamic> json) {
|
||||
return ProblemDescription(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class WorkOrderHistory {
|
||||
int id;
|
||||
WorkOrderStatus workOrderStatus;
|
||||
dynamic activityStatus; // Since activityStatus is null, it's dynamic
|
||||
String date;
|
||||
HistoryUser user;
|
||||
Step step;
|
||||
dynamic fixRemotelyStartTime; // Since it's null, it's dynamic
|
||||
dynamic fixRemotelyEndTime; // Since it's null, it's dynamic
|
||||
dynamic fixRemotelyWorkingHours; // Since it's null, it's dynamic
|
||||
String comments;
|
||||
dynamic needAVisitDateTime; // Since it's null, it's dynamic
|
||||
|
||||
WorkOrderHistory({
|
||||
this.id,
|
||||
this.workOrderStatus,
|
||||
this.activityStatus,
|
||||
this.date,
|
||||
this.user,
|
||||
this.step,
|
||||
this.fixRemotelyStartTime,
|
||||
this.fixRemotelyEndTime,
|
||||
this.fixRemotelyWorkingHours,
|
||||
this.comments,
|
||||
this.needAVisitDateTime,
|
||||
});
|
||||
|
||||
factory WorkOrderHistory.fromJson(Map<String, dynamic> json) {
|
||||
return WorkOrderHistory(
|
||||
id: json['id'],
|
||||
workOrderStatus: WorkOrderStatus.fromJson(json['workorderStatus']),
|
||||
activityStatus: json['activityStatus'],
|
||||
date: json['date'],
|
||||
user: HistoryUser.fromJson(json['user']),
|
||||
step: Step.fromJson(json['step']),
|
||||
fixRemotelyStartTime: json['fixRemotlyStartTime'],
|
||||
fixRemotelyEndTime: json['fixRemotlyEndTime'],
|
||||
fixRemotelyWorkingHours: json['fixRemotlyWorkingHours'],
|
||||
comments: json['comments'] ?? "",
|
||||
needAVisitDateTime: json['needAVisitDateTime'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'workorderStatus': workOrderStatus.toJson(),
|
||||
'activityStatus': activityStatus,
|
||||
'date': date,
|
||||
'user': user.toJson(),
|
||||
'step': step.toJson(),
|
||||
'fixRemotelyStartTime': fixRemotelyStartTime,
|
||||
'fixRemotelyEndTime': fixRemotelyEndTime,
|
||||
'fixRemotelyWorkingHours': fixRemotelyWorkingHours,
|
||||
'comments': comments,
|
||||
'needAVisitDateTime': needAVisitDateTime,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class WorkOrderStatus {
|
||||
int id;
|
||||
String name;
|
||||
int value;
|
||||
|
||||
WorkOrderStatus({
|
||||
this.id,
|
||||
this.name,
|
||||
this.value,
|
||||
});
|
||||
|
||||
factory WorkOrderStatus.fromJson(Map<String, dynamic> json) {
|
||||
return WorkOrderStatus(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
value: json['value'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'value': value,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class HistoryUser {
|
||||
String id;
|
||||
String userName;
|
||||
|
||||
HistoryUser({
|
||||
this.id,
|
||||
this.userName,
|
||||
});
|
||||
|
||||
factory HistoryUser.fromJson(Map<String, dynamic> json) {
|
||||
return HistoryUser(
|
||||
id: json['id'],
|
||||
userName: json['userName'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'userName': userName,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class Step {
|
||||
int id;
|
||||
String name;
|
||||
int value;
|
||||
|
||||
Step({
|
||||
this.id,
|
||||
this.name,
|
||||
this.value,
|
||||
});
|
||||
|
||||
factory Step.fromJson(Map<String, dynamic> json) {
|
||||
return Step(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
value: json['value'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'value': value,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,450 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/string_extensions.dart';
|
||||
import 'package:test_sa/models/helper_data_models/workorder/fix_remotely_model.dart';
|
||||
import 'package:test_sa/models/helper_data_models/workorder/need_visit_model.dart';
|
||||
import 'package:test_sa/models/helper_data_models/workorder/nurse_action_model.dart';
|
||||
import 'package:test_sa/models/new_models/dashboard_detail.dart';
|
||||
import 'package:test_sa/models/new_models/workOrderDetail.dart';
|
||||
import 'package:test_sa/models/service_request/service_report.dart';
|
||||
import 'package:test_sa/models/service_request/service_request.dart';
|
||||
import 'package:test_sa/models/service_request/spare_parts.dart';
|
||||
import 'package:test_sa/models/service_request/supp_engineer_work_orders.dart';
|
||||
import 'package:test_sa/models/service_request/supplier_engineer_model.dart';
|
||||
import '../../../models/service_request/wo_call_request.dart';
|
||||
import '../../../models/user.dart';
|
||||
import '../../../new_views/common_widgets/app_lazy_loading.dart';
|
||||
|
||||
class RequestDetailProvider extends ChangeNotifier {
|
||||
final pageItemNumber = 10;
|
||||
void reset() {
|
||||
nextPage = true;
|
||||
stateCode = null;
|
||||
}
|
||||
|
||||
|
||||
bool _isLoading = false;
|
||||
|
||||
bool get isLoading => _isLoading;
|
||||
|
||||
set isLoading(bool value) {
|
||||
_isLoading = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
WorkOrderDetail _currentWorkOrder;
|
||||
FixRemotely _fixRemotelyModel;
|
||||
NeedVisit _needVisitModel;
|
||||
NurseActionModel _nurseActionModel;
|
||||
|
||||
|
||||
NurseActionModel get nurseActionModel => _nurseActionModel;
|
||||
|
||||
set nurseActionModel(NurseActionModel value) {
|
||||
_nurseActionModel = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
NeedVisit get needVisitModel => _needVisitModel;
|
||||
|
||||
set needVisitModel(NeedVisit value) {
|
||||
_needVisitModel = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
FixRemotely get fixRemotelyModel => _fixRemotelyModel;
|
||||
|
||||
set fixRemotelyModel(FixRemotely value) {
|
||||
_fixRemotelyModel = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
WorkOrderDetail get currentWorkOrder => _currentWorkOrder;
|
||||
|
||||
set currentWorkOrder(WorkOrderDetail value) {
|
||||
_currentWorkOrder = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
int stateCode;
|
||||
// true if there is next page in product list and false if not
|
||||
bool nextPage = true;
|
||||
TimeOfDay _selectedTime ;
|
||||
|
||||
TimeOfDay get selectedTime => _selectedTime;
|
||||
|
||||
set selectedTime(TimeOfDay value) {
|
||||
_selectedTime = value;
|
||||
notifyListeners();
|
||||
} // list of user requests
|
||||
|
||||
SparePartsWorkOrders _initialSelectedSparePart = SparePartsWorkOrders();
|
||||
int _selectedListIndex = 0;
|
||||
|
||||
int get selectedListIndex => _selectedListIndex;
|
||||
|
||||
set selectedListIndex(int value) {
|
||||
_selectedListIndex = value;
|
||||
notifyListeners();
|
||||
}
|
||||
//getWorkOrderById......
|
||||
Future<WorkOrderDetail> getWorkOrderById({@required String id}) async {
|
||||
try {
|
||||
isLoading = true;
|
||||
final response = await ApiManager.instance.get(URLs.getWorkOrderByIdUrl+"?workOrderId=$id");
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
currentWorkOrder = WorkOrderDetail.fromJson(json.decode(response.body));
|
||||
notifyListeners();
|
||||
isLoading = false;
|
||||
return currentWorkOrder;
|
||||
}
|
||||
isLoading= false;
|
||||
notifyListeners();
|
||||
return null;
|
||||
}
|
||||
catch (e) {
|
||||
log("getSubWorkOrderDetails [error] : $e");
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
//engineerAcceptWorkOrder......
|
||||
Future<CommonResponseModel> engineerAcceptWorkOrder({@required String id}) async {
|
||||
try {
|
||||
final body = {
|
||||
"workOrderId": id,
|
||||
};
|
||||
isLoading = true;
|
||||
final response = await ApiManager.instance.post(URLs.engineerAcceptUrl,body: body);
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
CommonResponseModel commonResponseModel = CommonResponseModel.fromJson(json.decode(response.body));
|
||||
print('response of Engineer accept workorder ${commonResponseModel.toJson()}');
|
||||
notifyListeners();
|
||||
isLoading = false;
|
||||
return commonResponseModel;
|
||||
}
|
||||
isLoading= false;
|
||||
notifyListeners();
|
||||
return CommonResponseModel();
|
||||
}
|
||||
catch (e) {
|
||||
log("engineer accept [error] : $e");
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
return CommonResponseModel();
|
||||
}
|
||||
}
|
||||
//engineerRejectWorkOrder......
|
||||
Future<CommonResponseModel> engineerRejectWorkOrder({@required String id,String feedBack}) async {
|
||||
try {
|
||||
final body = {
|
||||
"workOrderId": id,
|
||||
"feedback": feedBack,
|
||||
};
|
||||
isLoading = true;
|
||||
final response = await ApiManager.instance.post(URLs.engineerRejectUrl,body: body);
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
CommonResponseModel commonResponseModel = CommonResponseModel.fromJson(json.decode(response.body));
|
||||
print('response of Engineer reject workorder ${commonResponseModel.toJson()}');
|
||||
notifyListeners();
|
||||
isLoading = false;
|
||||
return commonResponseModel;
|
||||
}
|
||||
isLoading= false;
|
||||
notifyListeners();
|
||||
return CommonResponseModel();
|
||||
}
|
||||
catch (e) {
|
||||
log("engineer accept [error] : $e");
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
return CommonResponseModel();
|
||||
}
|
||||
}
|
||||
//engineerFixRemotelyWorkOrder......
|
||||
Future<CommonResponseModel> engineerFixRemotely() async {
|
||||
try {
|
||||
isLoading = true;
|
||||
final response = await ApiManager.instance.post(URLs.engineerFixRemotlyUrl,body: fixRemotelyModel.toJson());
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
CommonResponseModel commonResponseModel = CommonResponseModel.fromJson(json.decode(response.body));
|
||||
print('response of Engineer fixremotely workorder ${commonResponseModel.toJson()}');
|
||||
notifyListeners();
|
||||
isLoading = false;
|
||||
return commonResponseModel;
|
||||
}
|
||||
isLoading= false;
|
||||
notifyListeners();
|
||||
return CommonResponseModel();
|
||||
}
|
||||
catch (e) {
|
||||
log("engineer accept [error] : $e");
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
return CommonResponseModel();
|
||||
}
|
||||
}
|
||||
//engineerNeedAVisitWorkOrder......
|
||||
Future<CommonResponseModel> engineerNeedVisit() async {
|
||||
try {
|
||||
isLoading = true;
|
||||
final response = await ApiManager.instance.post(URLs.engineerNeedVisitUrl,body: needVisitModel.toJson());
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
CommonResponseModel commonResponseModel = CommonResponseModel.fromJson(json.decode(response.body));
|
||||
print('response of Engineer fixremotely workorder ${commonResponseModel.toJson()}');
|
||||
notifyListeners();
|
||||
isLoading = false;
|
||||
return commonResponseModel;
|
||||
}
|
||||
isLoading= false;
|
||||
notifyListeners();
|
||||
return CommonResponseModel();
|
||||
}
|
||||
catch (e) {
|
||||
log("engineer accept [error] : $e");
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
return CommonResponseModel();
|
||||
}
|
||||
}
|
||||
//assignEngineerToWorkOrder......
|
||||
Future<CommonResponseModel> assignEngineerWorkOrder({@required String workOrderId,@required String engineerId}) async {
|
||||
try {
|
||||
final body = {
|
||||
"workOrderId": workOrderId,
|
||||
"assignedEngineerId": engineerId,
|
||||
};
|
||||
isLoading = true;
|
||||
final response = await ApiManager.instance.post(URLs.assignEngineerToWorkOrderUrl,body: body);
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
CommonResponseModel commonResponseModel = CommonResponseModel.fromJson(json.decode(response.body));
|
||||
print('response of Engineer assignEngineer workorder ${commonResponseModel.toJson()}');
|
||||
notifyListeners();
|
||||
isLoading = false;
|
||||
return commonResponseModel;
|
||||
}
|
||||
isLoading= false;
|
||||
notifyListeners();
|
||||
return CommonResponseModel();
|
||||
}
|
||||
catch (e) {
|
||||
log("engineer accept [error] : $e");
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
return CommonResponseModel();
|
||||
}
|
||||
}
|
||||
//Nurse confirm reopen
|
||||
Future<CommonResponseModel> nurseReopen() async {
|
||||
try {
|
||||
isLoading = true;
|
||||
final response = await ApiManager.instance.post(URLs.nurseConfirmReopenUrl,body: nurseActionModel.toJson());
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
CommonResponseModel commonResponseModel = CommonResponseModel.fromJson(json.decode(response.body));
|
||||
print('response of nurse confirmreopen workorder ${commonResponseModel.toJson()}');
|
||||
notifyListeners();
|
||||
isLoading = false;
|
||||
return commonResponseModel;
|
||||
}
|
||||
isLoading= false;
|
||||
notifyListeners();
|
||||
return CommonResponseModel();
|
||||
}
|
||||
catch (e) {
|
||||
log("engineer accept [error] : $e");
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
return CommonResponseModel();
|
||||
}
|
||||
}
|
||||
//Nurse confirm close
|
||||
Future<CommonResponseModel> nurseClose() async {
|
||||
try {
|
||||
isLoading = true;
|
||||
final response = await ApiManager.instance.post(URLs.nurseConfirmCloseUrl,body: nurseActionModel.toJson());
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
CommonResponseModel commonResponseModel = CommonResponseModel.fromJson(json.decode(response.body));
|
||||
print('response of nurse confirmreopen workorder ${commonResponseModel.toJson()}');
|
||||
notifyListeners();
|
||||
isLoading = false;
|
||||
return commonResponseModel;
|
||||
}
|
||||
isLoading= false;
|
||||
notifyListeners();
|
||||
return CommonResponseModel();
|
||||
}
|
||||
catch (e) {
|
||||
log("engineer accept [error] : $e");
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
return CommonResponseModel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<int> updateRequest({@required User user, @required ServiceRequest request}) async {
|
||||
isLoading = true;
|
||||
notifyListeners();
|
||||
Map<String, dynamic> serviceRequest = await getWorkOrderById(id: request.id) ?? "";
|
||||
final List callSiteContacts = (serviceRequest['callSiteContactPerson'] as List);
|
||||
final Map<String, dynamic> callSiteContactPerson = callSiteContacts.isEmpty ? {} : callSiteContacts[0];
|
||||
Response response;
|
||||
try {
|
||||
if ((request.audio ?? "").isNotEmpty) {
|
||||
request.audio = request.audio.substring(request.audio.indexOf("=") + 1, request.audio.length);
|
||||
}
|
||||
} catch (ex) {}
|
||||
|
||||
var body = {
|
||||
"id": request.id,
|
||||
"callNo": serviceRequest['callNo'],
|
||||
"callCreatedBy": serviceRequest['callCreatedBy'],
|
||||
"requestedDate": request.date ?? "",
|
||||
"requestedTime": request.date ?? "",
|
||||
"priority": request.priority?.toJson(),
|
||||
"defectType": request.defectType?.toJson(),
|
||||
"typeofRequest": request.type?.toJson(),
|
||||
"requestedThrough": request.requestedThrough?.toJson(),
|
||||
"voiceNote": request.audio,
|
||||
"assets": request.deviceId == null ? [] : [request.deviceId],
|
||||
"attachmentsCallRequest": (request.devicePhotos?.isNotEmpty ?? false) ? request.devicePhotos?.map((e) => {"name": e.getFileName})?.toList() : [],
|
||||
"assignedEmployee": {
|
||||
"id": request.engineerId,
|
||||
"name": request.engineerName,
|
||||
},
|
||||
"callSiteContactPerson": [
|
||||
{
|
||||
"id": callSiteContactPerson['id'] ?? 0,
|
||||
"employeeCode": callSiteContactPerson['employeeCode'],
|
||||
"name": callSiteContactPerson['name'] ?? user.userName,
|
||||
"telephone": callSiteContactPerson['telephone'] ?? user.phoneNumber,
|
||||
"job": callSiteContactPerson['job'],
|
||||
"email": callSiteContactPerson['email'] ?? user.email,
|
||||
"land": callSiteContactPerson['land'],
|
||||
"contactUserId": user.userID,
|
||||
},
|
||||
],
|
||||
"callComments": request.callComments,
|
||||
"noofFollowup": 0,
|
||||
"status": request.statusId == null
|
||||
? null
|
||||
: {
|
||||
"id": request.statusId,
|
||||
"name": request.statusLabel,
|
||||
"value": request.statusValue,
|
||||
},
|
||||
"callLastSituation": null,
|
||||
"firstAction": request.firstAction?.toJson(),
|
||||
"loanAvailablity": request.loanAvailability?.toJson(),
|
||||
"comments": request.comments,
|
||||
"firstActionDate": request.visitDate,
|
||||
"visitDate": request.visitDate,
|
||||
"startDate": request.startDate,
|
||||
"endDate": request.endDate,
|
||||
"workingHours": request.workingHours,
|
||||
"callReview": null,
|
||||
"reviewComment": null,
|
||||
//"reviewComment": request.reviewComment,
|
||||
};
|
||||
try {
|
||||
response = await ApiManager.instance.put(
|
||||
URLs.updateRequestDate,
|
||||
body: body,
|
||||
);
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// request.engineerName = employee.name;
|
||||
notifyListeners();
|
||||
}
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
Future<int> createServiceReport(BuildContext context, {@required ServiceReport report, @required User user, @required ServiceRequest request}) async {
|
||||
Response response;
|
||||
try {
|
||||
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
||||
final body = report.toJson();
|
||||
final callRequest = CallRequest(id: num.tryParse(request?.id ?? "")).toJson();
|
||||
final contactPerson = [
|
||||
{
|
||||
"id": 0,
|
||||
// "employeeCode": "",
|
||||
"name": user.userName,
|
||||
"telephone": user.phoneNumber,
|
||||
// "job": "",
|
||||
"email": user.email,
|
||||
// "land": "",
|
||||
"contactUserId": user.userID,
|
||||
}
|
||||
];
|
||||
body.update("contactPersonWorkOrders", (value) => contactPerson, ifAbsent: () => contactPerson);
|
||||
body.update("callRequest", (value) => callRequest, ifAbsent: () => callRequest);
|
||||
response = await ApiManager.instance.post(URLs.createServiceReport, body: body);
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
reset();
|
||||
notifyListeners();
|
||||
Fluttertoast.showToast(msg: context.translation.successfulRequestMessage);
|
||||
Navigator.of(context).pop();
|
||||
} else {
|
||||
Fluttertoast.showToast(msg: "${context.translation.failedToCompleteRequest}: ${json.decode(response.body)['message']}");
|
||||
}
|
||||
Navigator.pop(context);
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
Navigator.pop(context);
|
||||
print(error);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
Future<SuppEngineerWorkOrders> addSupplierEngineer(SupplierEngineer supplierEngineer) async {
|
||||
isLoading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
SuppEngineerWorkOrders res;
|
||||
try {
|
||||
response = await ApiManager.instance.post(URLs.addSupplierEngineer, body: supplierEngineer.toJson());
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
res = SuppEngineerWorkOrders.fromJson(json.decode(response.body)["data"]);
|
||||
}
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
return res;
|
||||
} catch (error) {
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
SparePartsWorkOrders get initialSelectedSparePart => _initialSelectedSparePart;
|
||||
|
||||
set initialSelectedSparePart(SparePartsWorkOrders value) {
|
||||
_initialSelectedSparePart = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,263 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/parts_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/service_requests_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/status_drop_down/report/service_report_fault_description_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/status_drop_down/report/service_report_last_calls_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/status_drop_down/report/service_types_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/controllers/validator/validator.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/models/device/asset.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/service_request/search_work_order.dart';
|
||||
import 'package:test_sa/models/service_request/service_report.dart';
|
||||
import 'package:test_sa/models/service_request/spare_parts.dart';
|
||||
import 'package:test_sa/models/service_request/supp_engineer_work_orders.dart';
|
||||
import 'package:test_sa/models/service_request/supplier_details.dart';
|
||||
import 'package:test_sa/models/service_request/wo_call_request.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
import 'package:test_sa/new_views/common_widgets/app_text_form_field.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/service_request_providers/equipment_status_provider.dart';
|
||||
import 'package:test_sa/providers/work_order/reason_provider.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
|
||||
|
||||
|
||||
class AssetConditionView extends StatefulWidget {
|
||||
static const id = "/CreateSubWorkOrder";
|
||||
final SearchWorkOrder workOrder;
|
||||
|
||||
const AssetConditionView({this.workOrder, Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AssetConditionView> createState() => _AssetConditionViewState();
|
||||
}
|
||||
|
||||
class _AssetConditionViewState extends State<AssetConditionView> {
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
SearchWorkOrder _subWorkOrders;
|
||||
ServiceReport _serviceReport;
|
||||
PartsProvider _partsProvider;
|
||||
List<SparePart> _spareParts = [];
|
||||
bool _isLoading = false;
|
||||
bool _showVendorFields = false;
|
||||
SuppEngineerWorkOrders engineer;
|
||||
SupplierDetails initialSupplier;
|
||||
final TextEditingController _workPreformedController = TextEditingController();
|
||||
final TextEditingController _partQtyController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_subWorkOrders = SearchWorkOrder(
|
||||
assignedEmployee: widget?.workOrder?.callRequest?.assignedEmployee,
|
||||
callRequest: CallRequest(id: widget?.workOrder?.callRequest?.id),
|
||||
currentSituation: null,
|
||||
supplier: null,
|
||||
// parentWOId: widget.workOrder.id,
|
||||
);
|
||||
getData();
|
||||
_serviceReport = ServiceReport();
|
||||
// _isLoading = true;
|
||||
super.initState();
|
||||
// if (context.mounted) {
|
||||
// Provider.of<ServiceReportAssistantsEmployeeProvider>(context, listen: false).reset();
|
||||
// Provider.of<ReasonProvider>(context, listen: false).reset();
|
||||
// Provider.of<ReasonProvider>(context, listen: false).serviceRequestId = widget.workOrder.callRequest.id.toString();
|
||||
// }
|
||||
}
|
||||
|
||||
ServiceStatusProvider assetTypesProvider;
|
||||
CallRequest _callRequestForWorkOrder;
|
||||
|
||||
void getData() async {
|
||||
ReasonProvider reasonProvider = Provider.of<ReasonProvider>(context,listen: false);
|
||||
ServiceRequestsProvider serviceRequestsProvider = Provider.of<ServiceRequestsProvider>(context,listen: false);
|
||||
_spareParts = await Provider.of<PartsProvider>(context,listen: false).getPartsList(assetId: serviceRequestsProvider.currentSelectedRequest.deviceId);
|
||||
|
||||
// _serviceReport = serviceRequestsProvider.currentSelectedRequest;
|
||||
// Provider.of<RequestedThroughProvider>(context).getDate();
|
||||
// Provider.of<TypeOfRequestProvider>(context).getDate();
|
||||
reasonProvider.serviceRequestId = serviceRequestsProvider.currentSelectedRequest.id;
|
||||
reasonProvider.getDate();
|
||||
// Provider.of<PriorityProvider>(context).getDate();
|
||||
// Provider.of<EquipmentStatusProvider>(context).getDate();
|
||||
}
|
||||
Future getAssetType() async {
|
||||
Provider.of<ServiceReportLastCallsProvider>(context, listen: false).reset();
|
||||
final serviceRequestProvider = Provider.of<ServiceRequestsProvider>(context);
|
||||
Provider.of<ServiceRequestFaultDescriptionProvider>(context, listen: false).reset();
|
||||
assetTypesProvider = Provider.of<ServiceStatusProvider>(context, listen: false);
|
||||
_callRequestForWorkOrder = await serviceRequestProvider.getCallRequestForWorkOrder(callId: widget.workOrder?.callRequest?.id?.toString());
|
||||
if (_subWorkOrders?.parentWOId != null) {
|
||||
final subWoDetails = await serviceRequestProvider.getSubWorkOrderDetails(parentId: _subWorkOrders?.parentWOId.toString());
|
||||
_subWorkOrders.copyDetails(subWoDetails);
|
||||
_serviceReport.equipmentStatus = subWoDetails.equipmentStatus;
|
||||
_serviceReport.reason = subWoDetails.reason;
|
||||
initialSupplier = subWoDetails.supplier;
|
||||
_serviceReport.faultDescription = subWoDetails.faultDescription;
|
||||
_subWorkOrders.visitDate = subWoDetails.visitDate;
|
||||
_subWorkOrders.sparePartsWorkOrders = subWoDetails.sparePartsWorkOrders;
|
||||
}
|
||||
await assetTypesProvider.getTypes();
|
||||
_subWorkOrders?.assetType = assetTypesProvider.statuses?.firstWhere(
|
||||
(element) => element.value == _callRequestForWorkOrder?.assetType,
|
||||
orElse: () => null,
|
||||
);
|
||||
if (checkVendorFieldsVisibility(_subWorkOrders.calllastSituation)) {
|
||||
if (_subWorkOrders.suppEngineerWorkOrders?.isNotEmpty ?? false) {
|
||||
engineer = _subWorkOrders.suppEngineerWorkOrders?.last;
|
||||
engineer?.id = engineer?.supplierContactId;
|
||||
}
|
||||
_subWorkOrders.supplier ??= SupplierDetails(id: _subWorkOrders?.supplier?.id);
|
||||
}
|
||||
_spareParts = await _partsProvider.getPartsList(assetId: widget.workOrder?.callRequest?.asset?.id);
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
Asset loanAvailabilityAsset;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_workPreformedController?.dispose();
|
||||
_partQtyController?.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final user = Provider.of<UserProvider>(context).user;
|
||||
// final isCurrentUserIsAssistantEmp = (user.userID != widget.workOrder.assignedEmployee?.id);
|
||||
// if (isCurrentUserIsAssistantEmp) {
|
||||
// // _subWorkOrders.assistantEmployees = [widget.workOrder.assistantEmployees?.first?.copyWith(id: 0)];
|
||||
// _subWorkOrders.assistantEmployees = [AssistantEmployees(id: 0, user: AssignedEmployee(id: user.userID, name: user.username))];
|
||||
// } else {}
|
||||
// if (_callRequestForWorkOrder == null) {
|
||||
// _partsProvider = Provider.of<PartsProvider>(context);
|
||||
// // getAssetType();
|
||||
// }
|
||||
|
||||
bool disablePart = _subWorkOrders.calllastSituation?.value == 12;
|
||||
|
||||
return Consumer<ServiceRequestsProvider>(
|
||||
builder: (context, serviceRequestProvider,child) {
|
||||
return SafeArea(
|
||||
child: _isLoading
|
||||
? const ALoading()
|
||||
: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth),
|
||||
child: Column(
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SingleItemDropDownMenu<Lookup, ReasonProvider>(
|
||||
context: context,
|
||||
title: context.translation.reason,
|
||||
initialValue: _subWorkOrders.reason,
|
||||
onSelect: (value) {
|
||||
if (value != null) {
|
||||
_subWorkOrders.reason = value;
|
||||
}
|
||||
},
|
||||
),
|
||||
8.height,
|
||||
SingleItemDropDownMenu<Lookup, EquipmentStatusProvider>(
|
||||
context: context,
|
||||
title: context.translation.equipmentStatus,
|
||||
initialValue: _subWorkOrders.equipmentStatus,
|
||||
onSelect: (value) {
|
||||
if (value != null) {
|
||||
_subWorkOrders.equipmentStatus = value;
|
||||
}
|
||||
},
|
||||
),
|
||||
8.height,
|
||||
SingleItemDropDownMenu<SparePart, NullableLoadingProvider>(
|
||||
context: context,
|
||||
title: context.translation.partNo,
|
||||
staticData: _spareParts,
|
||||
showShadow: true,
|
||||
initialValue: serviceRequestProvider.initialSelectedSparePart.sparePart,
|
||||
backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.white10,
|
||||
onSelect: (part) {
|
||||
serviceRequestProvider.initialSelectedSparePart = SparePartsWorkOrders(id: 0, sparePart: part, qty: 0);
|
||||
},
|
||||
),
|
||||
// AppTextFormField(
|
||||
// controller: _partQtyController,
|
||||
// labelText: context.translation.quantity,
|
||||
// textInputType: TextInputType.number,
|
||||
// contentPadding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 20.toScreenHeight),
|
||||
// showWithoutDecoration: true,
|
||||
// backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90,
|
||||
// enable: serviceRequestProvider.initialSelectedSparePart != null && serviceRequestProvider.initialSelectedSparePart.sparePart?.id != null,
|
||||
// validator: (value) => value == null || value.isEmpty
|
||||
// ? context.translation.requiredField
|
||||
// : Validator.isNumeric(value)
|
||||
// ? null
|
||||
// : context.translation.onlyNumbers,
|
||||
// onSaved: (text) {
|
||||
// serviceRequestProvider.initialSelectedSparePart.qty = num.tryParse(text ?? "");
|
||||
// },
|
||||
// ),
|
||||
15.height,
|
||||
],
|
||||
),
|
||||
),),]),
|
||||
));
|
||||
}
|
||||
);
|
||||
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
|
||||
bool checkVendorFieldsVisibility(Lookup callsLastSituation) {
|
||||
bool result = (initialSupplier?.suppliername?.isNotEmpty ?? false) ||
|
||||
(callsLastSituation?.name?.toLowerCase()?.contains("under repair-vendor") ?? false) ||
|
||||
(callsLastSituation?.name?.toLowerCase()?.contains("waiting for vendor") ?? false);
|
||||
setState(() {
|
||||
_showVendorFields = result;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<bool> validate() async {
|
||||
if (_subWorkOrders.reason == null) {
|
||||
Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.reason}");
|
||||
return false;
|
||||
} else if (_subWorkOrders.equipmentStatus == null) {
|
||||
Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.equipmentStatus}");
|
||||
return false;
|
||||
} else if (_subWorkOrders.calllastSituation == null) {
|
||||
Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.callLastSituation}");
|
||||
return false;
|
||||
} else if (_showVendorFields && _subWorkOrders.suppEngineerWorkOrders == null) {
|
||||
Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.supplierEngineer}");
|
||||
return false;
|
||||
} else if (_showVendorFields && (_subWorkOrders.supplier.suppliername == null || _subWorkOrders.supplier.suppliername.isEmpty)) {
|
||||
Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.supplier}");
|
||||
return false;
|
||||
} else if (_subWorkOrders.calllastSituation.value == 12 && (_subWorkOrders.sparePartsWorkOrders == null || _subWorkOrders.sparePartsWorkOrders.isEmpty)) {
|
||||
Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.partNo}");
|
||||
return false;
|
||||
} else if (_subWorkOrders?.timer?.startAt == null) {
|
||||
await Fluttertoast.showToast(msg: "Working Hours Required");
|
||||
return false;
|
||||
} else if (_subWorkOrders?.timer?.endAt == null) {
|
||||
await Fluttertoast.showToast(msg: "Please Stop The Timer");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/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/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/text_extensions.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
import 'package:test_sa/views/widgets/images/multi_image_picker.dart';
|
||||
|
||||
class AttachmentView extends StatelessWidget {
|
||||
const AttachmentView({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//TODO user the same form key everywhere....
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
final List<File> _files = [];
|
||||
return Consumer<ServiceRequestsProvider>(builder: (context, serviceRequestProvider, child) {
|
||||
serviceRequestProvider.currentSelectedRequest.visitDate = '';
|
||||
return Form(
|
||||
key: _formKey,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
MultiFilesPicker(
|
||||
label: context.translation.attachImage,
|
||||
buttonHeight: 108.toScreenHeight,
|
||||
buttonIcon: 'image_icon'?.toSvgAsset(),
|
||||
files: _files,
|
||||
onlyImages: true,
|
||||
),
|
||||
16.height,
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,120 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/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/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/string_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/models/timer_model.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/time_picker.dart';
|
||||
import 'package:test_sa/views/widgets/timer/app_timer.dart';
|
||||
|
||||
class TimeDurationView extends StatelessWidget {
|
||||
const TimeDurationView({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//TODO user the same form key everywhere....
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
return Consumer<ServiceRequestsProvider>(
|
||||
builder: (context, serviceRequestProvider,child) {
|
||||
serviceRequestProvider.currentSelectedRequest.visitDate = '';
|
||||
return Form(
|
||||
key: _formKey,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
ADatePicker(
|
||||
label: context.translation.visitDate,
|
||||
hideShadow: true,
|
||||
withIcon: false,
|
||||
hint: context.translation.select,
|
||||
height: 70.toScreenHeight,
|
||||
date: DateTime.tryParse(serviceRequestProvider.currentSelectedRequest.visitDate ?? ""),
|
||||
formatDateWithTime: true,
|
||||
onDatePicker: (selectedDate) {
|
||||
if (selectedDate != null) {
|
||||
showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.now(),
|
||||
).then((selectedTime) {
|
||||
// Handle the selected date and time here.
|
||||
if (selectedTime != null) {
|
||||
DateTime selectedDateTime = DateTime(
|
||||
selectedDate.year,
|
||||
selectedDate.month,
|
||||
selectedDate.day,
|
||||
selectedTime.hour,
|
||||
selectedTime.minute,
|
||||
);
|
||||
if (selectedDateTime != null) {
|
||||
serviceRequestProvider.currentSelectedRequest.visitDate = selectedDateTime?.toIso8601String();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
8.height,
|
||||
ATimePicker(
|
||||
label: context.translation.startTime,
|
||||
hint: context.translation.select,
|
||||
withIcon: false,
|
||||
withBorder: false,
|
||||
height: 70.toScreenHeight,
|
||||
time: serviceRequestProvider.selectedTime,
|
||||
onTimePicker: (selectedTime) {
|
||||
if (selectedTime != null) {
|
||||
print('time selected $selectedTime');
|
||||
serviceRequestProvider.selectedTime = selectedTime;
|
||||
}
|
||||
},
|
||||
),
|
||||
8.height,
|
||||
ATimePicker(
|
||||
label: context.translation.endTime,
|
||||
hint: context.translation.select,
|
||||
withIcon: false,
|
||||
withBorder: false,
|
||||
height: 70.toScreenHeight,
|
||||
time: serviceRequestProvider.selectedTime,
|
||||
onTimePicker: (selectedTime) {
|
||||
if (selectedTime != null) {
|
||||
print('time selected $selectedTime');
|
||||
serviceRequestProvider.selectedTime = selectedTime;
|
||||
}
|
||||
},
|
||||
),
|
||||
8.height,
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 70.toScreenHeight,
|
||||
child: AppTimer(
|
||||
label: context.translation.workingHours,
|
||||
timer: TimerModel(),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.background(context),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
// boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)],
|
||||
),
|
||||
// enabled: serviceRequestProvider.currentSelectedRequest.date == null,
|
||||
enabled: true,
|
||||
onChange: (timer) async {
|
||||
print('timer i got is ${timer.toString()}');
|
||||
return true;
|
||||
},
|
||||
),
|
||||
|
||||
),
|
||||
16.height,
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,242 @@
|
||||
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/custom_line.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/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/text_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/common_widgets/app_filled_button.dart';
|
||||
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
||||
import 'package:test_sa/service_request_latest/views/forms/work_order/components/asset_conditon_view.dart';
|
||||
import 'package:test_sa/service_request_latest/views/forms/work_order/components/attachments_view.dart';
|
||||
import 'package:test_sa/service_request_latest/views/forms/work_order/components/time_duration_view.dart';
|
||||
|
||||
class WorkOrderFormView extends StatefulWidget {
|
||||
|
||||
const WorkOrderFormView({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_WorkOrderFormViewState createState() => _WorkOrderFormViewState();
|
||||
}
|
||||
|
||||
class _WorkOrderFormViewState extends State<WorkOrderFormView> {
|
||||
int currentStep = 0;
|
||||
int activeStep = 0;
|
||||
int reachedStep = 0;
|
||||
int upperBound = 2;
|
||||
final formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
getInitialData();
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Future<void> getInitialData() async {
|
||||
// ListingVm listingVm = Provider.of<ListingVm>(context, listen: false);
|
||||
// listingVm.listingPropertyType = widget.arguments['listingType'];
|
||||
// if (widget.arguments['formType'] == AppConstants.addListing) {
|
||||
// listingVm.landLordModel = LandLordModel();
|
||||
// listingVm.listing['propertyType'] = widget.arguments['listingType'];
|
||||
// if (listingVm.listing['propertyType'] == AppConstants.sell) {
|
||||
// listingVm.listingParameter = 'sellParameter';
|
||||
// listingVm.listing[listingVm.listingParameter] =
|
||||
// SellParameter().toJson();
|
||||
// listingVm.listing[listingVm.listingParameter]?['ownerDocs'] = [];
|
||||
// }
|
||||
// if (listingVm.listing['propertyType'] == AppConstants.rent) {
|
||||
// listingVm.listingParameter = 'rentParameter';
|
||||
// listingVm.listing[listingVm.listingParameter] =
|
||||
// RentParameter().toJson();
|
||||
// listingVm.listing[listingVm.listingParameter]?['ownerDocs'] = [];
|
||||
// }
|
||||
// } else if (widget.arguments['formType'] == AppConstants.editListing) {
|
||||
// if (listingVm.listing['propertyType'] == AppConstants.sell) {
|
||||
// listingVm.listingParameter = 'sellParameter';
|
||||
// }
|
||||
// if (listingVm.listing['propertyType'] == AppConstants.rent) {
|
||||
// listingVm.listingParameter = 'rentParameter';
|
||||
// }
|
||||
// if (widget.arguments['isDuplicate'] == true) {
|
||||
// FormUtils.setDuplicateValues(
|
||||
// listingVm: listingVm, listType: widget.arguments['listingType']);
|
||||
// }
|
||||
// listingVm.formLocationController.clear();
|
||||
// listingVm.formCommunityInitialValue =
|
||||
// await FormUtils.setLocation(listingVm.listing, context);
|
||||
// listingVm.formLocationController.text =
|
||||
// listingVm.formCommunityInitialValue ?? '';
|
||||
//
|
||||
// listingVm.formAvailabilityDate =
|
||||
// listingVm.listing[listingVm.listingParameter]['availabilityDate'] ??
|
||||
// '';
|
||||
// listingVm.formBuildYearDate =
|
||||
// listingVm.listing[listingVm.listingParameter]['buildYear'] ?? '';
|
||||
//
|
||||
// listingVm.listing['photos'] ??= [];
|
||||
// listingVm.listing[listingVm.listingParameter]['ownerDocs'] ??= [];
|
||||
// }
|
||||
// GeneralUtil.initilizePortalsSwitch(listingVm: listingVm);
|
||||
// listingVm.getTenantExtent();
|
||||
// await listingVm.getRegion();
|
||||
// if (listingVm.listing[listingVm.listingParameter]
|
||||
// ['propertyFinderLocation'] !=
|
||||
// null) {
|
||||
// await listingVm.getPropertyFinderLocationList(
|
||||
// searchQuery: listingVm.listing[listingVm.listingParameter]
|
||||
// ['propertyFinderLocation']);
|
||||
// }
|
||||
// await listingVm.getWaterMarkImage();
|
||||
// await listingVm.getDeveloper();
|
||||
// await GeneralUtil.loadPortalsLocationsData(listingVm);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColor.neutral100,
|
||||
appBar: DefaultAppBar(title: context.translation.createWorkOrder),
|
||||
body: Column(
|
||||
children: [
|
||||
16.height,
|
||||
CustomStepper(
|
||||
activeStep: activeStep,
|
||||
lineStyle: LineStyle(
|
||||
activeLineColor: AppColor.primary10,
|
||||
finishedLineColor: AppColor.primary10,
|
||||
defaultLineColor: AppColor.white40,
|
||||
lineThickness: 1,
|
||||
lineLength: 93.toScreenWidth,
|
||||
lineType: LineType.normal,
|
||||
),
|
||||
internalPadding: 2.toScreenWidth,
|
||||
steps: [
|
||||
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: 2, stepIndex: 3), customTitle: customStepLabel(index: 1, label: context.translation.attachmentsAcknowledge)),
|
||||
],
|
||||
onStepReached: (index) => setState(() => activeStep = index),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.symmetric(horizontal: 16.toScreenWidth, vertical: 25.toScreenHeight),
|
||||
child: getStepWidget(),
|
||||
)),
|
||||
bottomContainerWidget(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget bottomContainerWidget() {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth,vertical: 16.toScreenHeight),
|
||||
color: AppColor.white10,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
AppFilledButton(
|
||||
label: context.translation.cancel,
|
||||
loading: false,
|
||||
buttonColor: AppColor.white60,
|
||||
textColor: AppColor.black10,
|
||||
onPressed: () async {
|
||||
Navigator.pop(context);
|
||||
// await snapshot.updateRequest(user: userProvider.user, request: serviceRequestProvider.serviceRequest);
|
||||
// Navigator.pop(context, true);
|
||||
},
|
||||
).expanded,
|
||||
12.width,
|
||||
AppFilledButton(
|
||||
label: context.translation.next,
|
||||
buttonColor: AppColor.primary10,
|
||||
loading: false,
|
||||
onPressed: () {
|
||||
_incrementActiveStep();
|
||||
//TODO move to next step..
|
||||
},
|
||||
).expanded,
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
void _incrementActiveStep() {
|
||||
setState(() {
|
||||
++activeStep;
|
||||
if (reachedStep < activeStep) {
|
||||
reachedStep = activeStep;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _navigateNext(ServiceRequestsProvider serviceRequestsProvider) async {
|
||||
if (activeStep < upperBound) {
|
||||
switch (activeStep) {
|
||||
case 0:
|
||||
// await _navigateNextStep(listingVm);
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
_incrementActiveStep();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Your onPressed code
|
||||
|
||||
Widget customStepWidget({@required int index, @required int stepIndex}) {
|
||||
return CircleAvatar(
|
||||
backgroundColor: activeStep >= index ? AppColor.primary10 : AppColor.background(context),
|
||||
child: activeStep > index
|
||||
? Icon(
|
||||
Icons.done,
|
||||
color: AppColor.white10,
|
||||
size: 26.toScreenHeight,
|
||||
)
|
||||
: activeStep == index
|
||||
? Text(
|
||||
'0$stepIndex',
|
||||
style: const TextStyle(fontWeight: FontWeight.w500, color: AppColor.white10),
|
||||
textAlign: TextAlign.center,
|
||||
)
|
||||
: Text(
|
||||
'0$stepIndex',
|
||||
style: const TextStyle(color: AppColor.black20),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget customStepLabel({@required String label, @required int index}) {
|
||||
return Column(
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
textAlign: TextAlign.center,
|
||||
style: AppTextStyles.bodyText2.copyWith(color: AppColor.black20),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// Returns the previous button.
|
||||
|
||||
Widget getStepWidget() {
|
||||
switch (activeStep) {
|
||||
case 0:
|
||||
return const TimeDurationView();
|
||||
case 1:
|
||||
return const AssetConditionView();
|
||||
case 2:
|
||||
return const AttachmentView();
|
||||
default:
|
||||
return const SizedBox();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue