passo_mobile_app/lib/screens/passo/Land/add_land.dart

121 lines
3.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:im_stepper/stepper.dart';
import 'package:unit2/screens/passo/Land/add_land/land_appraisal.dart';
import 'package:unit2/screens/passo/Land/add_land/location_and_boundaries.dart';
import 'package:unit2/screens/passo/Land/add_land/other_improvements.dart';
import 'package:unit2/screens/passo/Land/add_land/property_assessment.dart';
import 'package:unit2/screens/passo/Land/add_land/property_assessment_cont.dart';
import 'package:unit2/screens/passo/Land/add_land/property_owner_info.dart';
import 'package:unit2/screens/passo/Land/add_land/value_adjustments.dart';
import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart';
GlobalKey<FormBuilderState> landKey = GlobalKey<FormBuilderState>();
class AddLand extends StatefulWidget {
@override
_AddLand createState() => _AddLand();
}
class _AddLand extends State<AddLand> {
// THE FOLLOWING TWO VARIABLES ARE REQUIRED TO CONTROL THE STEPPER.
int activeStep = 0; // Initial step set to 5.
int upperBound = 6; // upperBound MUST BE total number of icons minus 1.
void PrevBtn() {
setState(() {
activeStep--;
});
}
void NextBtn() {
setState(() {
activeStep++;
});
}
void onSAveAll() {
return Navigator.of(context).pop();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: primary,
title: const Text('Land FAAS'),
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
NumberStepper(
numbers: const [1, 2, 3, 4, 5, 6, 7],
activeStepColor: primary,
numberStyle: const TextStyle(color: Colors.white),
lineColor: primary,
// activeStep property set to activeStep variable defined above.
activeStep: activeStep,
activeStepBorderColor: Colors.white,
activeStepBorderWidth: 1,
// This ensures step-tapping updates the activeStep.
onStepReached: (index) {
setState(() {
activeStep = index;
});
},
),
Expanded(
child: FormBuilder(
key: landKey,
// enabled: false,
onChanged: () {
landKey.currentState?.save();
print(landKey.currentState?.value.toString());
},
autovalidateMode: AutovalidateMode.disabled,
skipDisabled: true,
child: Container(
child: content(PrevBtn, NextBtn, onSAveAll),
),
),
),
],
),
),
);
}
/// Returns the next button.
// Returns the content widget based on the activeStep.
Widget content(PrevBtn, NextBtn, onSAveAll) {
switch (activeStep) {
case 0:
return LandPropertyOwnerInfo(NextBtn);
case 1:
return LandLocationAndBoundaries(PrevBtn, NextBtn);
case 2:
return LandAppraisal(PrevBtn, NextBtn);
case 3:
return OtherImprovementPage(PrevBtn, NextBtn);
case 4:
return ValueAdjustmentPage(PrevBtn, NextBtn);
case 5:
return LandPropertyAssessmentPage(PrevBtn, NextBtn);
case 6:
return LandSignatories(onSAveAll);
default:
return LandPropertyOwnerInfo(NextBtn);
}
}
}