assign area using purok
parent
f73f8a03e1
commit
6dd9216af7
|
@ -36,7 +36,7 @@ class MyApp extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
_appRouter = AppRouter();
|
||||
final mediaQueryData =
|
||||
MediaQueryData.fromView(WidgetsBinding.instance.window);
|
||||
MediaQueryData.fromWindow(WidgetsBinding.instance.window);
|
||||
screenWidth = mediaQueryData.size.width;
|
||||
screenHeight = mediaQueryData.size.height;
|
||||
blockSizeHorizontal = screenWidth / 100;
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
// To parse this JSON data, do
|
||||
//
|
||||
// final purok = purokFromJson(jsonString);
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:unit2/model/location/barangay.dart';
|
||||
|
||||
Purok purokFromJson(String str) => Purok.fromJson(json.decode(str));
|
||||
|
||||
String purokToJson(Purok data) => json.encode(data.toJson());
|
||||
|
||||
class Purok {
|
||||
final String code;
|
||||
final String description;
|
||||
final Barangay barangay;
|
||||
|
||||
Purok({
|
||||
required this.code,
|
||||
required this.description,
|
||||
required this.barangay,
|
||||
});
|
||||
|
||||
factory Purok.fromJson(Map<String, dynamic> json) => Purok(
|
||||
code: json["code"],
|
||||
description: json["description"],
|
||||
barangay: Barangay.fromJson(json["barangay"]),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"code": code,
|
||||
"description": description,
|
||||
"barangay": barangay.toJson(),
|
||||
};
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import 'barangay_assign_area.dart';
|
||||
|
||||
class Purok {
|
||||
class PassCheckPurok {
|
||||
final String? purokid;
|
||||
final String? purokdesc;
|
||||
final BaragayAssignArea? brgy;
|
||||
|
@ -10,7 +10,7 @@ class Purok {
|
|||
final bool? writelock;
|
||||
final dynamic recordsignature;
|
||||
|
||||
Purok({
|
||||
PassCheckPurok({
|
||||
required this.purokid,
|
||||
required this.purokdesc,
|
||||
required this.brgy,
|
||||
|
@ -19,7 +19,7 @@ class Purok {
|
|||
required this.recordsignature,
|
||||
});
|
||||
|
||||
factory Purok.fromJson(Map<String, dynamic> json) => Purok(
|
||||
factory PassCheckPurok.fromJson(Map<String, dynamic> json) => PassCheckPurok(
|
||||
purokid: json["purokid"],
|
||||
purokdesc: json["purokdesc"],
|
||||
brgy: json["brgy"]==null?null:BaragayAssignArea.fromJson(json["brgy"]),
|
||||
|
|
|
@ -16,12 +16,14 @@ import 'package:unit2/bloc/user/user_bloc.dart';
|
|||
import 'package:unit2/model/location/barangay.dart';
|
||||
import 'package:unit2/model/location/city.dart';
|
||||
import 'package:unit2/model/location/provinces.dart';
|
||||
import 'package:unit2/model/location/purok.dart';
|
||||
import 'package:unit2/model/location/region.dart';
|
||||
import 'package:unit2/model/login_data/user_info/assigned_area.dart';
|
||||
import 'package:unit2/model/profile/assigned_area.dart';
|
||||
import 'package:unit2/model/rbac/rbac.dart';
|
||||
import 'package:unit2/model/rbac/rbac_station.dart';
|
||||
import 'package:unit2/model/roles/pass_check/agency_area_type.dart';
|
||||
import 'package:unit2/model/roles/pass_check/purok_assign_area.dart';
|
||||
import 'package:unit2/model/roles/pass_check/station_assign_area.dart';
|
||||
import 'package:unit2/model/utils/agency.dart';
|
||||
import 'package:unit2/model/utils/category.dart';
|
||||
|
@ -57,6 +59,7 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
bool provinceAsyncCall = false;
|
||||
bool cityAsyncCall = false;
|
||||
bool barangayAsyncCall = false;
|
||||
bool purokAsyncCall = false;
|
||||
List<UserAssignedArea> userAssignedAreas = [];
|
||||
final bloc = BlocProvider.of<AssignAreaBloc>(context);
|
||||
int? areaTypeId;
|
||||
|
@ -72,6 +75,7 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
List<Province> provinces = [];
|
||||
List<CityMunicipality> cities = [];
|
||||
List<Barangay> barangays = [];
|
||||
List<Purok> puroks = [];
|
||||
Province? selectedProvince;
|
||||
CityMunicipality? selectedMunicipality;
|
||||
Barangay? selectedBarangay;
|
||||
|
@ -152,6 +156,44 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
//// purok
|
||||
} else if (e.name!.toLowerCase() ==
|
||||
"purok president") {
|
||||
try {
|
||||
areaType = "purok";
|
||||
areaTypeId = 2;
|
||||
setState(() {
|
||||
provinceAsyncCall = true;
|
||||
});
|
||||
provinces = await LocationUtils
|
||||
.instance
|
||||
.getProvinces(regionCode: "16");
|
||||
setState(() {
|
||||
provinceAsyncCall = false;
|
||||
cityAsyncCall = true;
|
||||
});
|
||||
cities = await LocationUtils.instance
|
||||
.getCities(
|
||||
code: provinces[0].code!);
|
||||
setState(() {
|
||||
cityAsyncCall = false;
|
||||
barangayAsyncCall = true;
|
||||
});
|
||||
barangays = await LocationUtils
|
||||
.instance
|
||||
.getBarangay(
|
||||
code: cities[0].code!);
|
||||
setState(() {
|
||||
barangayAsyncCall = false;
|
||||
purokAsyncCall = true;
|
||||
});
|
||||
puroks = await LocationUtils.instance
|
||||
.getPurok(
|
||||
barangay: barangays[0].code!);
|
||||
setState(() {
|
||||
purokAsyncCall = false;
|
||||
});
|
||||
} catch (e) {
|
||||
bloc.add(CallErrorState(
|
||||
message: e.toString()));
|
||||
}
|
||||
//// station
|
||||
} else if (e.name!.toLowerCase() == "qr code scanner" ||
|
||||
e.name!.toLowerCase() ==
|
||||
|
@ -185,7 +227,6 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
bloc.add(CallErrorState(
|
||||
message: e.toString()));
|
||||
}
|
||||
|
||||
//// agency-------------------------------
|
||||
} else if (e.name!.toLowerCase() ==
|
||||
"establishment point-person" ||
|
||||
|
@ -227,16 +268,13 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
itemHeight: 100,
|
||||
suggestions: agencies
|
||||
.map((Agency agency) =>
|
||||
SearchFieldListItem(
|
||||
agency.name!,
|
||||
SearchFieldListItem(agency.name!,
|
||||
item: agency,
|
||||
child: ListTile(
|
||||
title:
|
||||
AutoSizeText(
|
||||
title: AutoSizeText(
|
||||
agency.name!
|
||||
.toUpperCase(),
|
||||
minFontSize:
|
||||
12,
|
||||
minFontSize: 12,
|
||||
),
|
||||
subtitle: Text(agency
|
||||
.privateEntity ==
|
||||
|
@ -248,18 +286,13 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
: ""),
|
||||
)))
|
||||
.toList(),
|
||||
validator: FormBuilderValidators
|
||||
.required(
|
||||
errorText:
|
||||
"This field is required"),
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
searchInputDecoration:
|
||||
normalTextFieldStyle(
|
||||
"Agency *", "")
|
||||
normalTextFieldStyle("Agency *", "")
|
||||
.copyWith(
|
||||
suffixIcon:
|
||||
GestureDetector(
|
||||
onTap: () => agencyFocusNode
|
||||
.unfocus(),
|
||||
suffixIcon: GestureDetector(
|
||||
onTap: () => agencyFocusNode.unfocus(),
|
||||
child: const Icon(
|
||||
Icons.arrow_drop_down,
|
||||
),
|
||||
|
@ -267,13 +300,12 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
////agency suggestion tap
|
||||
onSuggestionTap: (agency) {
|
||||
setState(() {
|
||||
areaId = agency.item!.id
|
||||
.toString();
|
||||
areaId = agency.item!.id.toString();
|
||||
agencyFocusNode.unfocus();
|
||||
});
|
||||
},
|
||||
emptyWidget: const Text(
|
||||
"No Result Found.."))
|
||||
emptyWidget:
|
||||
const Text("No Result Found.."))
|
||||
//// station ------------------------------------------------
|
||||
: areaType == "station"
|
||||
? SizedBox(
|
||||
|
@ -285,7 +317,8 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
child: SizedBox(
|
||||
height: 100,
|
||||
child: ModalProgressHUD(
|
||||
inAsyncCall: agencyAsyncCall,
|
||||
inAsyncCall:
|
||||
agencyAsyncCall,
|
||||
child: SearchField(
|
||||
controller:
|
||||
agencyController,
|
||||
|
@ -295,31 +328,39 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
focusNode:
|
||||
agencyFocusNode,
|
||||
itemHeight: 100,
|
||||
suggestions:
|
||||
agencies
|
||||
.map((Agency agency) => SearchFieldListItem(
|
||||
suggestions: agencies
|
||||
.map((Agency
|
||||
agency) =>
|
||||
SearchFieldListItem(
|
||||
agency
|
||||
.name!,
|
||||
item:
|
||||
agency,
|
||||
child:
|
||||
ListTile(
|
||||
title: AutoSizeText(
|
||||
agency.name!.toUpperCase(),
|
||||
minFontSize: 12,
|
||||
title:
|
||||
AutoSizeText(
|
||||
agency
|
||||
.name!
|
||||
.toUpperCase(),
|
||||
minFontSize:
|
||||
12,
|
||||
),
|
||||
subtitle: Text(agency.privateEntity == true
|
||||
subtitle: Text(agency.privateEntity ==
|
||||
true
|
||||
? "Private"
|
||||
: agency.privateEntity == false
|
||||
? "Government"
|
||||
: ""),
|
||||
)))
|
||||
.toList(),
|
||||
validator: FormBuilderValidators
|
||||
validator:
|
||||
FormBuilderValidators
|
||||
.required(
|
||||
errorText:
|
||||
"This field is required"),
|
||||
searchInputDecoration: normalTextFieldStyle(
|
||||
searchInputDecoration:
|
||||
normalTextFieldStyle(
|
||||
"Agency *",
|
||||
"")
|
||||
.copyWith(
|
||||
|
@ -328,8 +369,7 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
onTap: () =>
|
||||
agencyFocusNode
|
||||
.unfocus(),
|
||||
child:
|
||||
const Icon(
|
||||
child: const Icon(
|
||||
Icons
|
||||
.arrow_drop_down,
|
||||
),
|
||||
|
@ -342,8 +382,7 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
.unfocus();
|
||||
});
|
||||
},
|
||||
emptyWidget:
|
||||
const Text(
|
||||
emptyWidget: const Text(
|
||||
"No Result Found..")),
|
||||
),
|
||||
),
|
||||
|
@ -354,36 +393,31 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 75,
|
||||
child:
|
||||
ModalProgressHUD(
|
||||
color: Colors
|
||||
.transparent,
|
||||
child: ModalProgressHUD(
|
||||
color: Colors.transparent,
|
||||
inAsyncCall:
|
||||
stationAsyncCall,
|
||||
child: FormBuilderDropdown<
|
||||
child:
|
||||
FormBuilderDropdown<
|
||||
RbacStation>(
|
||||
decoration: normalTextFieldStyle(
|
||||
decoration:
|
||||
normalTextFieldStyle(
|
||||
"Station",
|
||||
"Station"),
|
||||
name:
|
||||
"parent-stations",
|
||||
items: stations
|
||||
.isEmpty
|
||||
name: "parent-stations",
|
||||
items: stations.isEmpty
|
||||
? []
|
||||
: stations
|
||||
.map(
|
||||
(e) {
|
||||
: stations.map((e) {
|
||||
return DropdownMenuItem(
|
||||
value:
|
||||
e,
|
||||
child:
|
||||
Text(e.stationName!),
|
||||
value: e,
|
||||
child: Text(e
|
||||
.stationName!),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged:
|
||||
(RbacStation?
|
||||
e) {},
|
||||
validator: FormBuilderValidators
|
||||
(RbacStation? e) {},
|
||||
validator:
|
||||
FormBuilderValidators
|
||||
.required(
|
||||
errorText:
|
||||
"This field is required"),
|
||||
|
@ -397,6 +431,190 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
)
|
||||
//// barangay ------------------------------------------------------------
|
||||
: areaType == 'barangay'
|
||||
? SizedBox(
|
||||
height: 300,
|
||||
child: Column(
|
||||
children: [
|
||||
//// PROVINCE DROPDOWN
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 60,
|
||||
child: ModalProgressHUD(
|
||||
color:
|
||||
Colors.transparent,
|
||||
inAsyncCall:
|
||||
provinceAsyncCall,
|
||||
child: DropdownButtonFormField<
|
||||
Province?>(
|
||||
autovalidateMode:
|
||||
AutovalidateMode
|
||||
.onUserInteraction,
|
||||
validator: (value) =>
|
||||
value == null
|
||||
? 'required'
|
||||
: null,
|
||||
isExpanded: true,
|
||||
// value: selectedProvince,
|
||||
onChanged: (Province?
|
||||
province) async {
|
||||
setState(() {
|
||||
selectedProvince =
|
||||
province;
|
||||
cityAsyncCall =
|
||||
true;
|
||||
});
|
||||
cities = await LocationUtils
|
||||
.instance
|
||||
.getCities(
|
||||
code: provinces[
|
||||
0]
|
||||
.code!);
|
||||
setState(() {
|
||||
cityAsyncCall =
|
||||
false;
|
||||
barangayAsyncCall =
|
||||
true;
|
||||
});
|
||||
barangays = await LocationUtils
|
||||
.instance
|
||||
.getBarangay(
|
||||
code: cities[
|
||||
0]
|
||||
.code!);
|
||||
setState(() {
|
||||
barangayAsyncCall =
|
||||
false;
|
||||
});
|
||||
},
|
||||
items: provinces
|
||||
.isEmpty
|
||||
? []
|
||||
: provinces.map<
|
||||
DropdownMenuItem<
|
||||
Province>>((Province
|
||||
province) {
|
||||
return DropdownMenuItem(
|
||||
value:
|
||||
province,
|
||||
child:
|
||||
FittedBox(
|
||||
child:
|
||||
Text(province.description!),
|
||||
));
|
||||
}).toList(),
|
||||
decoration:
|
||||
normalTextFieldStyle(
|
||||
"Province*",
|
||||
"Province")),
|
||||
),
|
||||
),
|
||||
),
|
||||
//// CITIES DROPDOWN
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 60,
|
||||
child: ModalProgressHUD(
|
||||
color: Colors.white,
|
||||
inAsyncCall:
|
||||
cityAsyncCall,
|
||||
child:
|
||||
DropdownButtonFormField<
|
||||
CityMunicipality>(
|
||||
validator:
|
||||
FormBuilderValidators
|
||||
.required(
|
||||
errorText:
|
||||
"This field is required"),
|
||||
isExpanded: true,
|
||||
onChanged:
|
||||
(CityMunicipality?
|
||||
city) async {
|
||||
setState(() {
|
||||
selectedMunicipality =
|
||||
city;
|
||||
barangayAsyncCall =
|
||||
true;
|
||||
});
|
||||
barangays = await LocationUtils
|
||||
.instance
|
||||
.getBarangay(
|
||||
code: selectedMunicipality!
|
||||
.code!);
|
||||
setState(() {
|
||||
barangayAsyncCall =
|
||||
false;
|
||||
});
|
||||
},
|
||||
decoration:
|
||||
normalTextFieldStyle(
|
||||
"Municipality*",
|
||||
"Municipality"),
|
||||
// value: selectedMunicipality,
|
||||
items: cities.isEmpty
|
||||
? []
|
||||
: cities.map<
|
||||
DropdownMenuItem<
|
||||
CityMunicipality>>(
|
||||
(CityMunicipality
|
||||
c) {
|
||||
return DropdownMenuItem(
|
||||
value: c,
|
||||
child: Text(
|
||||
c.description!));
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
////Barangay
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 60,
|
||||
child: ModalProgressHUD(
|
||||
color: Colors.white,
|
||||
inAsyncCall:
|
||||
barangayAsyncCall,
|
||||
child:
|
||||
DropdownButtonFormField<
|
||||
Barangay>(
|
||||
isExpanded: true,
|
||||
onChanged: (Barangay?
|
||||
baragay) {
|
||||
areaId =
|
||||
baragay!.code;
|
||||
},
|
||||
decoration:
|
||||
normalTextFieldStyle(
|
||||
"Barangay*",
|
||||
"Barangay"),
|
||||
// value: selectedBarangay,
|
||||
validator:
|
||||
FormBuilderValidators
|
||||
.required(
|
||||
errorText:
|
||||
"This field is required"),
|
||||
items: barangays
|
||||
.isEmpty
|
||||
? []
|
||||
: barangays.map<
|
||||
DropdownMenuItem<
|
||||
Barangay>>((Barangay
|
||||
barangay) {
|
||||
return DropdownMenuItem(
|
||||
value:
|
||||
barangay,
|
||||
child: Text(
|
||||
barangay
|
||||
.description!));
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
))
|
||||
: //// Purok ------------------------------------------------------------
|
||||
areaType == 'purok'
|
||||
? SizedBox(
|
||||
height: 300,
|
||||
child: Column(
|
||||
|
@ -416,8 +634,8 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
autovalidateMode:
|
||||
AutovalidateMode
|
||||
.onUserInteraction,
|
||||
validator: (value) => value ==
|
||||
null
|
||||
validator: (value) =>
|
||||
value == null
|
||||
? 'required'
|
||||
: null,
|
||||
isExpanded:
|
||||
|
@ -426,8 +644,7 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
onChanged:
|
||||
(Province?
|
||||
province) async {
|
||||
setState(
|
||||
() {
|
||||
setState(() {
|
||||
selectedProvince =
|
||||
province;
|
||||
cityAsyncCall =
|
||||
|
@ -435,9 +652,10 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
});
|
||||
cities = await LocationUtils
|
||||
.instance
|
||||
.getCities(code: provinces[0].code!);
|
||||
setState(
|
||||
() {
|
||||
.getCities(
|
||||
code:
|
||||
provinces[0].code!);
|
||||
setState(() {
|
||||
cityAsyncCall =
|
||||
false;
|
||||
barangayAsyncCall =
|
||||
|
@ -445,21 +663,37 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
});
|
||||
barangays = await LocationUtils
|
||||
.instance
|
||||
.getBarangay(code: cities[0].code!);
|
||||
setState(
|
||||
() {
|
||||
.getBarangay(
|
||||
code:
|
||||
cities[0].code!);
|
||||
setState(() {
|
||||
barangayAsyncCall =
|
||||
false;
|
||||
purokAsyncCall =
|
||||
true;
|
||||
});
|
||||
puroks = await LocationUtils
|
||||
.instance
|
||||
.getPurok(
|
||||
barangay:
|
||||
barangays[0].code!);
|
||||
setState(() {
|
||||
purokAsyncCall =
|
||||
false;
|
||||
});
|
||||
},
|
||||
items: provinces
|
||||
.isEmpty
|
||||
? []
|
||||
: provinces.map<DropdownMenuItem<Province>>((Province
|
||||
: provinces.map<
|
||||
DropdownMenuItem<
|
||||
Province>>((Province
|
||||
province) {
|
||||
return DropdownMenuItem(
|
||||
value: province,
|
||||
child: FittedBox(
|
||||
value:
|
||||
province,
|
||||
child:
|
||||
FittedBox(
|
||||
child: Text(province.description!),
|
||||
));
|
||||
}).toList(),
|
||||
|
@ -475,22 +709,20 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
height: 60,
|
||||
child:
|
||||
ModalProgressHUD(
|
||||
color: Colors
|
||||
.white,
|
||||
color: Colors.white,
|
||||
inAsyncCall:
|
||||
cityAsyncCall,
|
||||
child: DropdownButtonFormField<
|
||||
CityMunicipality>(
|
||||
validator: FormBuilderValidators.required(
|
||||
validator: FormBuilderValidators
|
||||
.required(
|
||||
errorText:
|
||||
"This field is required"),
|
||||
isExpanded:
|
||||
true,
|
||||
isExpanded: true,
|
||||
onChanged:
|
||||
(CityMunicipality?
|
||||
city) async {
|
||||
setState(
|
||||
() {
|
||||
setState(() {
|
||||
selectedMunicipality =
|
||||
city;
|
||||
barangayAsyncCall =
|
||||
|
@ -499,13 +731,24 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
barangays = await LocationUtils
|
||||
.instance
|
||||
.getBarangay(
|
||||
code: selectedMunicipality!.code!);
|
||||
setState(
|
||||
() {
|
||||
code: selectedMunicipality!
|
||||
.code!);
|
||||
setState(() {
|
||||
barangayAsyncCall =
|
||||
false;
|
||||
purokAsyncCall = true;
|
||||
});
|
||||
puroks = await LocationUtils
|
||||
.instance
|
||||
.getPurok(
|
||||
barangay:
|
||||
barangays[0].code!);
|
||||
|
||||
setState((){
|
||||
purokAsyncCall = false;
|
||||
});
|
||||
},
|
||||
|
||||
decoration: normalTextFieldStyle(
|
||||
"Municipality*",
|
||||
"Municipality"),
|
||||
|
@ -515,11 +758,14 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
? []
|
||||
: cities.map<
|
||||
DropdownMenuItem<
|
||||
CityMunicipality>>((CityMunicipality
|
||||
CityMunicipality>>(
|
||||
(CityMunicipality
|
||||
c) {
|
||||
return DropdownMenuItem(
|
||||
value: c,
|
||||
child: Text(c.description!));
|
||||
value:
|
||||
c,
|
||||
child:
|
||||
Text(c.description!));
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
|
@ -527,32 +773,49 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
),
|
||||
////Barangay
|
||||
Expanded(
|
||||
|
||||
child: SizedBox(
|
||||
height: 60,
|
||||
child:
|
||||
ModalProgressHUD(
|
||||
color: Colors
|
||||
.white,
|
||||
color: Colors.white,
|
||||
inAsyncCall:
|
||||
barangayAsyncCall,
|
||||
child: DropdownButtonFormField<
|
||||
child:
|
||||
DropdownButtonFormField<
|
||||
Barangay>(
|
||||
isExpanded:
|
||||
true,
|
||||
|
||||
isExpanded: true,
|
||||
onChanged:
|
||||
(Barangay?
|
||||
baragay) {
|
||||
baragay)async {
|
||||
areaId =
|
||||
baragay!
|
||||
.code;
|
||||
|
||||
setState((){
|
||||
purokAsyncCall= true;
|
||||
});
|
||||
puroks = await LocationUtils
|
||||
.instance
|
||||
.getPurok(
|
||||
barangay:
|
||||
barangays[0].code!);
|
||||
setState((){
|
||||
purokAsyncCall = false;
|
||||
});
|
||||
},
|
||||
decoration: normalTextFieldStyle(
|
||||
decoration:
|
||||
normalTextFieldStyle(
|
||||
"Barangay*",
|
||||
"Barangay"),
|
||||
// value: selectedBarangay,
|
||||
validator: FormBuilderValidators.required(
|
||||
validator: FormBuilderValidators
|
||||
.required(
|
||||
errorText:
|
||||
"This field is required"),
|
||||
|
||||
|
||||
items: barangays
|
||||
.isEmpty
|
||||
? []
|
||||
|
@ -561,8 +824,60 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
|||
Barangay>>((Barangay
|
||||
barangay) {
|
||||
return DropdownMenuItem(
|
||||
value: barangay,
|
||||
child: Text(barangay.description!));
|
||||
value:
|
||||
barangay,
|
||||
child:
|
||||
Text(barangay.description!));
|
||||
}).toList(),
|
||||
|
||||
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
////Purok
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 60,
|
||||
child:
|
||||
ModalProgressHUD(
|
||||
color: Colors.white,
|
||||
inAsyncCall:
|
||||
purokAsyncCall,
|
||||
child:
|
||||
DropdownButtonFormField<
|
||||
Purok>(
|
||||
isExpanded: true,
|
||||
onChanged:
|
||||
(Purok?
|
||||
purok) {
|
||||
areaId =
|
||||
purok!.code;
|
||||
},
|
||||
decoration:
|
||||
normalTextFieldStyle(
|
||||
"Purok*",
|
||||
"Parangay"),
|
||||
// value: selectedBarangay,
|
||||
validator: FormBuilderValidators
|
||||
.required(
|
||||
errorText:
|
||||
"This field is required"),
|
||||
items: puroks
|
||||
.isEmpty
|
||||
? []
|
||||
: puroks.map<
|
||||
DropdownMenuItem<
|
||||
Purok>>((Purok
|
||||
purok) {
|
||||
return DropdownMenuItem(
|
||||
value:
|
||||
purok,
|
||||
child:
|
||||
Text(purok.description));
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -109,7 +109,7 @@ class _UniT2LoginState extends State<UniT2Login> {
|
|||
}, builder: (context, state) {
|
||||
if (state is VersionLoaded) {
|
||||
return Builder(builder: (context) {
|
||||
if (state.versionInfo!.version != state.apkVersion) {
|
||||
if (state.versionInfo?.version != state.apkVersion) {
|
||||
return SizedBox(
|
||||
child: SingleChildScrollView(
|
||||
child: Stack(
|
||||
|
|
|
@ -116,9 +116,9 @@ class PassCheckServices {
|
|||
}
|
||||
////PUROK
|
||||
if (assignRoleAreaType.areaTypeName.toLowerCase() == 'purok') {
|
||||
List<Purok> assignedArea = [];
|
||||
List<PassCheckPurok> assignedArea = [];
|
||||
data['data'][0]['assigned_area'].forEach((var element) {
|
||||
Purok purok = Purok.fromJson(element['area']);
|
||||
PassCheckPurok purok = PassCheckPurok.fromJson(element['area']);
|
||||
assignedArea.add(purok);
|
||||
});
|
||||
statusResponse = assignedArea;
|
||||
|
|
|
@ -6,6 +6,7 @@ import 'package:unit2/model/location/city.dart';
|
|||
import 'package:unit2/model/location/country.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:unit2/model/location/provinces.dart';
|
||||
import 'package:unit2/model/location/purok.dart';
|
||||
import 'package:unit2/utils/request.dart';
|
||||
import 'package:unit2/utils/urls.dart';
|
||||
|
||||
|
@ -91,6 +92,7 @@ class LocationUtils {
|
|||
try {
|
||||
http.Response response = await Request.instance
|
||||
.getRequest(path: path, param: {}, headers: headers);
|
||||
if (response.statusCode == 200) {
|
||||
Map data = jsonDecode(response.body);
|
||||
if (data['data'] != null) {
|
||||
data['data'].forEach((var city) {
|
||||
|
@ -98,6 +100,7 @@ class LocationUtils {
|
|||
cities.add(cityMun);
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
throw (e.toString());
|
||||
}
|
||||
|
@ -110,6 +113,7 @@ class LocationUtils {
|
|||
try {
|
||||
http.Response response = await Request.instance
|
||||
.getRequest(path: path, param: {}, headers: headers);
|
||||
if (response.statusCode == 200) {
|
||||
Map data = jsonDecode(response.body);
|
||||
if (data['data'] != null) {
|
||||
data['data'].forEach((var city) {
|
||||
|
@ -117,16 +121,40 @@ class LocationUtils {
|
|||
barangays.add(barangay);
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
throw (e.toString());
|
||||
}
|
||||
return barangays;
|
||||
}
|
||||
|
||||
Future<List<Purok>> getPurok({required String barangay}) async {
|
||||
List<Purok> puroks = [];
|
||||
String path = Url.instance.getPurok() + barangay;
|
||||
try {
|
||||
http.Response response = await Request.instance
|
||||
.getRequest(path: path, param: {}, headers: headers);
|
||||
if (response.statusCode == 200) {
|
||||
Map data = jsonDecode(response.body);
|
||||
if (data['data'] != null) {
|
||||
data['data'].forEach((var purok) {
|
||||
Purok newPurok = Purok.fromJson(purok);
|
||||
puroks.add(newPurok);
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
throw (e.toString());
|
||||
}
|
||||
return puroks;
|
||||
}
|
||||
|
||||
Future<List<AddressCategory>> getAddressCategory() async {
|
||||
List<AddressCategory> categories = [];
|
||||
String path = Url.instance.getAddressCategory();
|
||||
try {
|
||||
http.Response response = await Request.instance.getRequest(path: path,param: {},headers:headers );
|
||||
http.Response response = await Request.instance
|
||||
.getRequest(path: path, param: {}, headers: headers);
|
||||
Map data = jsonDecode(response.body);
|
||||
if (data['data'] != null) {
|
||||
data['data'].forEach((var cat) {
|
||||
|
@ -139,6 +167,4 @@ class LocationUtils {
|
|||
throw e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -343,6 +343,9 @@ class Url {
|
|||
String getBarangays() {
|
||||
return "/api/web_app/location/barangay/";
|
||||
}
|
||||
String getPurok(){
|
||||
return "/api/web_app/location/purok/";
|
||||
}
|
||||
|
||||
String getAddressCategory() {
|
||||
return "/api/jobnet_app/address_categories/";
|
||||
|
|
Loading…
Reference in New Issue