238 lines
8.8 KiB
Dart
238 lines
8.8 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:flutter_progress_hud/flutter_progress_hud.dart';
|
|
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
|
import 'package:unit2/bloc/passo/class_components/class_components_bloc.dart';
|
|
import 'package:unit2/bloc/passo/property_info/property_info_bloc.dart';
|
|
import 'package:unit2/bloc/passo/unit_construct/unit_construct_bloc.dart';
|
|
import 'package:unit2/model/passo/bldg_loc.dart';
|
|
import 'package:unit2/model/passo/class_components.dart';
|
|
import 'package:unit2/model/passo/land_ref.dart';
|
|
import 'package:unit2/model/passo/property_info.dart';
|
|
import 'package:unit2/screens/passo/Building/add_building_components/additional_items.dart';
|
|
import 'package:unit2/screens/passo/Building/add_building_components/bldg_location_landref.dart';
|
|
import 'package:unit2/screens/passo/Building/add_building_components/general_description.dart';
|
|
import 'package:unit2/screens/passo/Building/add_building_components/property_appraisal.dart';
|
|
import 'package:unit2/screens/passo/Building/add_building_components/property_assessment.dart';
|
|
import 'package:unit2/screens/passo/Building/add_building_components/property_info.dart';
|
|
import 'package:unit2/screens/passo/Building/add_building_components/structural_materials.dart';
|
|
import 'package:unit2/theme-data.dart/colors.dart';
|
|
import 'package:im_stepper/stepper.dart';
|
|
|
|
GlobalKey<FormBuilderState> formKey = GlobalKey<FormBuilderState>();
|
|
|
|
class AddBuilding extends StatefulWidget {
|
|
@override
|
|
_AddBuilding createState() => _AddBuilding();
|
|
}
|
|
|
|
class _AddBuilding extends State<AddBuilding> {
|
|
int activeStep = 0; // Initial step set to 5.
|
|
int upperBound = 6;
|
|
|
|
bool saveStep1 = false;
|
|
bool saveStep2 = false;
|
|
bool saveStep3 = false;
|
|
bool saveStep4 = false;
|
|
bool saveStep5 = false;
|
|
bool saveStep6 = false;
|
|
bool saveStep7 = false;
|
|
int tempId = 0;
|
|
|
|
void onPostPropertyInfo() {
|
|
formKey.currentState?.save();
|
|
if (formKey.currentState!.value['transaction_code'].toString() != null &&
|
|
formKey.currentState!.value['owner'] != null) {
|
|
if (activeStep < upperBound && saveStep1 == false) {
|
|
setState(() {
|
|
activeStep++;
|
|
saveStep1 = true;
|
|
});
|
|
} else {
|
|
setState(() {
|
|
activeStep++;
|
|
});
|
|
}
|
|
|
|
var property_info = PropertyInfo(
|
|
id: 1,
|
|
transCode: formKey.currentState!.value['transaction_code'].toString(),
|
|
tdn: formKey.currentState!.value['arp_td'],
|
|
pin: formKey.currentState!.value['pin'],
|
|
owner: formKey.currentState!.value['owner'],
|
|
address: formKey.currentState!.value['address'],
|
|
telno: formKey.currentState!.value['tel_no'],
|
|
tin: formKey.currentState!.value['tin'],
|
|
adminUser: formKey.currentState!.value['benificiary'],
|
|
adminAddress: formKey.currentState!.value['benificiary_address'],
|
|
adminTin: formKey.currentState!.value['benificiary_tin'],
|
|
adminTelno: formKey.currentState!.value['benificiary_telno'],
|
|
assessedById: '1',
|
|
assessedByName: 'Cyril',
|
|
dateModified: DateTime.now(),
|
|
dateCreated: DateTime.now());
|
|
|
|
context
|
|
.read<PropertyInfoBloc>()
|
|
.add(AddPropertyInfo(property_info: property_info));
|
|
// _loadTempId();
|
|
}
|
|
}
|
|
|
|
void onPutBldgLandref() {
|
|
// Increment activeStep, when the next button is tapped. However, check for upper bound.
|
|
if (activeStep < upperBound && saveStep2 == false) {
|
|
setState(() {
|
|
activeStep++;
|
|
saveStep2 = true;
|
|
});
|
|
}
|
|
var bldgLocData = BldgLoc(
|
|
id: tempId,
|
|
street: formKey.currentState?.value['street'],
|
|
barangay: formKey.currentState?.value['brgy'],
|
|
municipality: formKey.currentState?.value['municipality'],
|
|
province: formKey.currentState?.value['province'],
|
|
);
|
|
var landRefData = LandRef(
|
|
id: tempId,
|
|
owner: formKey.currentState?.value['l_owner'],
|
|
cloaNo: formKey.currentState?.value['oct_tct_cloa'],
|
|
lotNo: formKey.currentState?.value['lot_no'],
|
|
tdn: formKey.currentState?.value['l_td_arp'],
|
|
area: formKey.currentState?.value['area'],
|
|
surveyNo: formKey.currentState?.value['survey_no'],
|
|
blkNo: formKey.currentState?.value['blk_no'],
|
|
);
|
|
context.read<PropertyInfoBloc>()
|
|
..add(UpdateBldgLoc(bldg_loc: bldgLocData))
|
|
..add(UpdateLandRef(land_ref: landRefData));
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
backgroundColor: primary,
|
|
centerTitle: true,
|
|
title: const Text("Building FAAS"),
|
|
),
|
|
body: ProgressHUD(
|
|
padding: const EdgeInsets.all(24),
|
|
backgroundColor: Colors.black87,
|
|
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
|
|
child: BlocConsumer<PropertyInfoBloc, PropertyInfoState>(listener: (
|
|
context,
|
|
state,
|
|
) {
|
|
if (state is PropertyInfoLoading) {
|
|
final progress = ProgressHUD.of(context);
|
|
progress!.showWithText("Please wait...");
|
|
}
|
|
if (state is PropertyInfoLoaded ||
|
|
state is PropertyInfoErrorState) {
|
|
final progress = ProgressHUD.of(context);
|
|
progress?.dismiss();
|
|
}
|
|
}, builder: (context, state) {
|
|
if (state is PropertyInfoLoaded) {
|
|
return BlocConsumer<UnitConstructBloc, UnitConstructState>(
|
|
listener: (context, state) {
|
|
// TODO: implement listener
|
|
},
|
|
builder: (context, state) {
|
|
if (state is UnitConstructLoaded) {
|
|
final unit = state.unit;
|
|
return BlocConsumer<ClassComponentsBloc,
|
|
ClassComponentsState>(
|
|
listener: (context, state) {
|
|
// TODO: implement listener
|
|
},
|
|
builder: (context, state) {
|
|
if (state is ClassComponentLoaded) {
|
|
return Column(
|
|
children: [
|
|
NumberStepper(
|
|
numbers: [1, 2, 3, 4, 5, 6, 7],
|
|
stepPadding: 5,
|
|
activeStepColor: Colors.red,
|
|
numberStyle:
|
|
const TextStyle(color: Colors.white),
|
|
activeStepBorderColor: Colors.white,
|
|
// activeStep property set to activeStep variable defined above.
|
|
activeStep: activeStep,
|
|
|
|
// This ensures step-tapping updates the activeStep.
|
|
onStepReached: (index) {
|
|
setState(() {
|
|
activeStep = index;
|
|
});
|
|
},
|
|
),
|
|
Expanded(
|
|
child: FormBuilder(
|
|
key: formKey,
|
|
|
|
// enabled: false,
|
|
onChanged: () {
|
|
formKey.currentState?.save();
|
|
|
|
print(formKey.currentState?.value.toString());
|
|
},
|
|
autovalidateMode: AutovalidateMode.disabled,
|
|
skipDisabled: true,
|
|
child: Container(
|
|
child: content(
|
|
onPostPropertyInfo, unit, state.classes),
|
|
),
|
|
)),
|
|
],
|
|
);
|
|
}
|
|
return Container();
|
|
},
|
|
);
|
|
}
|
|
return Container();
|
|
},
|
|
);
|
|
}
|
|
return Container();
|
|
})),
|
|
);
|
|
}
|
|
|
|
Widget content(handleButtonPress, unit, List<ClassComponents> classes) {
|
|
switch (activeStep) {
|
|
case 0:
|
|
return PropertyInfoPage(onPostPropertyInfo);
|
|
|
|
case 1:
|
|
return BldgLocationLandrefPage();
|
|
|
|
case 2:
|
|
return GeneralDescriptionPage(unit);
|
|
|
|
case 3:
|
|
return StructuralMaterialsPage();
|
|
|
|
case 4:
|
|
return AdditionalItemPage(unit, classes);
|
|
|
|
case 5:
|
|
return PropertyAppraisalPage();
|
|
|
|
case 6:
|
|
return PropertyAssessmentPage(onSAveAll);
|
|
|
|
default:
|
|
return Text("Property Info");
|
|
}
|
|
}
|
|
|
|
void onSAveAll() {
|
|
return Navigator.of(context).pop();
|
|
}
|
|
}
|