|
|
|
|
@ -35,12 +35,12 @@ class UpdatePpm extends StatefulWidget {
|
|
|
|
|
State<UpdatePpm> createState() => _UpdatePpmState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _UpdatePpmState extends State<UpdatePpm> with SingleTickerProviderStateMixin {
|
|
|
|
|
class _UpdatePpmState extends State<UpdatePpm> with TickerProviderStateMixin {
|
|
|
|
|
late PlanPreventiveVisit _planPreventiveVisit;
|
|
|
|
|
|
|
|
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
|
|
|
|
|
|
late TabController _tabController;
|
|
|
|
|
TabController? _tabController;
|
|
|
|
|
late PpmProvider ppmProvider;
|
|
|
|
|
|
|
|
|
|
_onSubmit({required int status}) async {
|
|
|
|
|
@ -79,15 +79,28 @@ class _UpdatePpmState extends State<UpdatePpm> with SingleTickerProviderStateMix
|
|
|
|
|
void initState() {
|
|
|
|
|
ppmProvider = Provider.of<PpmProvider>(context, listen: false);
|
|
|
|
|
_planPreventiveVisit = widget.planPreventiveVisit;
|
|
|
|
|
_tabController = TabController(length: ppmProvider.totalTabs, vsync: this);
|
|
|
|
|
initTabs(_planPreventiveVisit.typeOfService);
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void initTabs(typeOfService) {
|
|
|
|
|
if (typeOfService == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (typeOfService?.id == 66) {
|
|
|
|
|
ppmProvider.totalTabs = 4;
|
|
|
|
|
} else {
|
|
|
|
|
ppmProvider.totalTabs = 3;
|
|
|
|
|
}
|
|
|
|
|
_tabController?.dispose;
|
|
|
|
|
_tabController = TabController(length: ppmProvider.totalTabs, vsync: this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int tabIndex = 0;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
_tabController.dispose();
|
|
|
|
|
_tabController?.dispose();
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -127,7 +140,7 @@ class _UpdatePpmState extends State<UpdatePpm> with SingleTickerProviderStateMix
|
|
|
|
|
onTap: (index) {
|
|
|
|
|
tabIndex = index;
|
|
|
|
|
if (tabIndex == 0) {
|
|
|
|
|
_tabController.animateTo(0);
|
|
|
|
|
_tabController?.animateTo(0);
|
|
|
|
|
}
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
@ -139,7 +152,11 @@ class _UpdatePpmState extends State<UpdatePpm> with SingleTickerProviderStateMix
|
|
|
|
|
),
|
|
|
|
|
TabBarView(
|
|
|
|
|
children: [
|
|
|
|
|
WoInfoForm(planPreventiveVisit: _planPreventiveVisit),
|
|
|
|
|
WoInfoForm(
|
|
|
|
|
planPreventiveVisit: _planPreventiveVisit,
|
|
|
|
|
onTypeOfServiceChange: (selectedTypeOfService) {
|
|
|
|
|
initTabs(selectedTypeOfService);
|
|
|
|
|
}),
|
|
|
|
|
TabBarView(
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
controller: _tabController,
|
|
|
|
|
@ -174,14 +191,14 @@ class _UpdatePpmState extends State<UpdatePpm> with SingleTickerProviderStateMix
|
|
|
|
|
_onSubmit(status: 1);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (_tabController.index == 3) {
|
|
|
|
|
if (ppmProvider.totalTabs == _tabController!.index + 1) {
|
|
|
|
|
_onSubmit(status: 1);
|
|
|
|
|
} else {
|
|
|
|
|
_tabController.animateTo(_tabController.index + 1);
|
|
|
|
|
_tabController?.animateTo(_tabController!.index + 1);
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
label: tabIndex == 0 ? "Complete".addTranslation : (_tabController.index == 3 ? "Complete".addTranslation : context.translation.next),
|
|
|
|
|
label: tabIndex == 0 ? "Complete".addTranslation : ((ppmProvider.totalTabs == _tabController!.index + 1) ? "Complete".addTranslation : context.translation.next),
|
|
|
|
|
).expanded,
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context, showShadow: false, borderRadius: 0),
|
|
|
|
|
|