2023-02-15 03:40:12 +00:00
|
|
|
import 'package:date_time_picker/date_time_picker.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/src/widgets/framework.dart';
|
|
|
|
import 'package:flutter/src/widgets/placeholder.dart';
|
2023-02-15 08:48:34 +00:00
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
2023-02-15 03:40:12 +00:00
|
|
|
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
|
|
|
import 'package:intl/intl.dart';
|
2023-02-15 08:48:34 +00:00
|
|
|
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
|
|
|
import 'package:unit2/bloc/user/user_bloc.dart';
|
2023-02-15 03:40:12 +00:00
|
|
|
import 'package:unit2/model/profile/eligibility.dart';
|
2023-02-16 07:10:54 +00:00
|
|
|
import 'package:unit2/model/utils/eligibilities_choices.dart';
|
2023-02-15 08:48:34 +00:00
|
|
|
import '../../../../model/location/country.dart' as c;
|
2023-02-16 07:10:54 +00:00
|
|
|
import '../../../../model/location/region.dart' as r;
|
|
|
|
import '../../../../model/location/provinces.dart' as p;
|
2023-02-15 03:40:12 +00:00
|
|
|
import '../../../../theme-data.dart/btn-style.dart';
|
|
|
|
import '../../../../theme-data.dart/colors.dart';
|
|
|
|
import '../../../../theme-data.dart/form-style.dart';
|
|
|
|
import '../../../../utils/global.dart';
|
|
|
|
import '../../../../utils/text_container.dart';
|
|
|
|
|
|
|
|
class EditEligibilityScreen extends StatefulWidget {
|
|
|
|
final EligibityCert eligibityCert;
|
2023-02-15 08:48:34 +00:00
|
|
|
const EditEligibilityScreen({super.key, required this.eligibityCert});
|
2023-02-15 03:40:12 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
State<EditEligibilityScreen> createState() => _EditEligibilityScreenState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
2023-02-15 08:48:34 +00:00
|
|
|
final formKey = GlobalKey<FormBuilderState>();
|
|
|
|
bool overseas = false;
|
|
|
|
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
|
|
|
|
c.Country? selectedCountry;
|
2023-02-15 03:40:12 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-02-16 07:10:54 +00:00
|
|
|
//USERBLOC
|
2023-02-15 08:48:34 +00:00
|
|
|
return BlocBuilder<UserBloc, UserState>(
|
|
|
|
builder: (context, state) {
|
2023-02-16 07:10:54 +00:00
|
|
|
//LOGGED IN USER STATE
|
2023-02-15 08:48:34 +00:00
|
|
|
if (state is UserLoggedIn) {
|
2023-02-16 07:10:54 +00:00
|
|
|
//PROFIILE BLOC
|
2023-02-15 08:48:34 +00:00
|
|
|
return BlocBuilder<ProfileBloc, ProfileState>(
|
|
|
|
builder: (context, state) {
|
2023-02-16 07:10:54 +00:00
|
|
|
//EDIT ELIGIBILITY STATE
|
2023-02-15 08:48:34 +00:00
|
|
|
if (state is EditEligibilityState) {
|
2023-02-16 07:10:54 +00:00
|
|
|
String? region = state.eligibityCert.examAddress!
|
|
|
|
.cityMunicipality!.province!.region!.description;
|
|
|
|
String? eligibiltyTitle =
|
|
|
|
state.eligibityCert.eligibility!.title!;
|
|
|
|
String? province = state.eligibityCert.examAddress!
|
|
|
|
.cityMunicipality!.province!.description!;
|
2023-02-15 08:48:34 +00:00
|
|
|
return Center(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
vertical: 25, horizontal: 18),
|
|
|
|
child: FormBuilder(
|
|
|
|
key: formKey,
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
2023-02-15 03:40:12 +00:00
|
|
|
children: [
|
2023-02-16 07:10:54 +00:00
|
|
|
//ELIGIBILITIES DROPDOWN
|
|
|
|
FormBuilderDropdown<dynamic>(
|
|
|
|
initialValue: state.eligibityCert.eligibility,
|
|
|
|
items: state.eligibilities
|
|
|
|
.map<DropdownMenuItem<EligibilityList>>(
|
|
|
|
(EligibilityList eligibility) {
|
|
|
|
return DropdownMenuItem<EligibilityList>(
|
|
|
|
value: eligibility,
|
|
|
|
child: Text(eligibility.title));
|
|
|
|
}).toList(),
|
2023-02-15 08:48:34 +00:00
|
|
|
name: "eligibility",
|
|
|
|
decoration: normalTextFieldStyle(
|
2023-02-16 07:10:54 +00:00
|
|
|
"Eligibility", eligibiltyTitle)
|
|
|
|
.copyWith(
|
|
|
|
hintStyle: const TextStyle(
|
|
|
|
color: Colors.black,
|
|
|
|
),
|
|
|
|
labelStyle:
|
|
|
|
const TextStyle(color: Colors.black)),
|
2023-02-15 03:40:12 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
2023-02-15 08:48:34 +00:00
|
|
|
height: 20,
|
2023-02-15 03:40:12 +00:00
|
|
|
),
|
2023-02-16 07:10:54 +00:00
|
|
|
|
2023-02-15 08:48:34 +00:00
|
|
|
SizedBox(
|
|
|
|
width: screenWidth,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
2023-02-16 07:10:54 +00:00
|
|
|
//LICENSE NUMBER
|
2023-02-15 08:48:34 +00:00
|
|
|
Flexible(
|
|
|
|
flex: 1,
|
|
|
|
child: FormBuilderTextField(
|
|
|
|
name: 'license number',
|
|
|
|
initialValue:
|
|
|
|
widget.eligibityCert.licenseNumber,
|
|
|
|
decoration: normalTextFieldStyle(
|
|
|
|
"license number", "license number"),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
width: 12,
|
|
|
|
),
|
2023-02-16 07:10:54 +00:00
|
|
|
//RATING
|
2023-02-15 08:48:34 +00:00
|
|
|
Flexible(
|
|
|
|
flex: 1,
|
|
|
|
child: FormBuilderTextField(
|
|
|
|
name: 'rating',
|
|
|
|
initialValue: widget.eligibityCert.rating
|
|
|
|
.toString(),
|
|
|
|
decoration: normalTextFieldStyle(
|
|
|
|
'rating', 'rating'),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2023-02-15 03:40:12 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
2023-02-15 08:48:34 +00:00
|
|
|
height: 20,
|
2023-02-15 03:40:12 +00:00
|
|
|
),
|
2023-02-15 08:48:34 +00:00
|
|
|
SizedBox(
|
|
|
|
width: screenWidth,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
2023-02-16 07:10:54 +00:00
|
|
|
//EXAM DATE
|
2023-02-15 08:48:34 +00:00
|
|
|
Flexible(
|
|
|
|
flex: 1,
|
|
|
|
child: DateTimePicker(
|
|
|
|
firstDate: DateTime(2000),
|
|
|
|
lastDate: DateTime(2100),
|
2023-02-15 03:40:12 +00:00
|
|
|
decoration: normalTextFieldStyle(
|
2023-02-15 08:48:34 +00:00
|
|
|
"Exam date", "Exam date"),
|
2023-02-15 03:40:12 +00:00
|
|
|
initialValue: widget
|
2023-02-15 08:48:34 +00:00
|
|
|
.eligibityCert.examDate ==
|
2023-02-15 03:40:12 +00:00
|
|
|
null
|
2023-02-15 08:48:34 +00:00
|
|
|
? ''
|
|
|
|
: dteFormat2.format(
|
|
|
|
widget.eligibityCert.examDate!),
|
|
|
|
)),
|
|
|
|
const SizedBox(
|
|
|
|
width: 12,
|
|
|
|
),
|
2023-02-16 07:10:54 +00:00
|
|
|
//VALIDITY DATE
|
2023-02-15 08:48:34 +00:00
|
|
|
Flexible(
|
|
|
|
flex: 1,
|
|
|
|
child: DateTimePicker(
|
|
|
|
firstDate: DateTime(2000),
|
|
|
|
lastDate: DateTime(2100),
|
2023-02-15 03:40:12 +00:00
|
|
|
decoration: normalTextFieldStyle(
|
2023-02-15 08:48:34 +00:00
|
|
|
"Validity date", "Validity date"),
|
|
|
|
initialValue:
|
|
|
|
widget.eligibityCert.validityDate ==
|
|
|
|
null
|
|
|
|
? ''
|
|
|
|
: dteFormat2.format(widget
|
|
|
|
.eligibityCert.validityDate!),
|
2023-02-15 03:40:12 +00:00
|
|
|
),
|
2023-02-15 08:48:34 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 20,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"Placement of Examination/Confinement",
|
|
|
|
style: Theme.of(context)
|
|
|
|
.textTheme
|
|
|
|
.displaySmall!
|
|
|
|
.copyWith(fontSize: blockSizeVertical * 2),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
2023-02-16 07:10:54 +00:00
|
|
|
//OVERSEAS ADDRESS SWITCH
|
2023-02-15 08:48:34 +00:00
|
|
|
FormBuilderSwitch(
|
|
|
|
initialValue: overseas,
|
|
|
|
activeColor: second,
|
|
|
|
onChanged: (value) {
|
|
|
|
setState(() {
|
|
|
|
overseas = value!;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
decoration: normalTextFieldStyle("", ''),
|
|
|
|
name: 'overseas',
|
|
|
|
title: const Text("Overseas Address?"),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 20,
|
|
|
|
),
|
2023-02-16 07:10:54 +00:00
|
|
|
//COUNTRY DROPDOWN
|
|
|
|
|
2023-02-15 08:48:34 +00:00
|
|
|
SizedBox(
|
|
|
|
child: overseas == true
|
|
|
|
? FormBuilderDropdown<dynamic>(
|
|
|
|
items: state.countries
|
|
|
|
.map<DropdownMenuItem<c.Country>>(
|
|
|
|
(c.Country country) {
|
|
|
|
return DropdownMenuItem<c.Country>(
|
|
|
|
value: country,
|
|
|
|
child: Text(country.name!));
|
|
|
|
}).toList(),
|
|
|
|
name: 'country',
|
|
|
|
decoration: normalTextFieldStyle(
|
|
|
|
"Country", "Country"),
|
|
|
|
onChanged: (value) {
|
|
|
|
setState(() {
|
|
|
|
selectedCountry = value;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
)
|
|
|
|
: Column(
|
|
|
|
children: [
|
2023-02-16 07:10:54 +00:00
|
|
|
//REGION DROPDOWN
|
|
|
|
FormBuilderDropdown<dynamic>(
|
|
|
|
// initialValue:state.eligibityCert.examAddress!.cityMunicipality!.province!.description!,
|
2023-02-15 08:48:34 +00:00
|
|
|
decoration: normalTextFieldStyle(
|
2023-02-16 07:10:54 +00:00
|
|
|
"Region", region ??
|
|
|
|
"Region*")
|
|
|
|
.copyWith(
|
|
|
|
hintStyle: const TextStyle(
|
|
|
|
color: Colors.black,
|
|
|
|
),
|
|
|
|
labelStyle: const TextStyle(
|
|
|
|
color: Colors.black)),
|
2023-02-15 08:48:34 +00:00
|
|
|
name: 'region',
|
2023-02-16 07:10:54 +00:00
|
|
|
items: state.regions.map<
|
|
|
|
DropdownMenuItem<r.Region>>(
|
|
|
|
(r.Region region) {
|
|
|
|
return DropdownMenuItem<r.Region>(
|
|
|
|
value: region,
|
|
|
|
child: Text(
|
|
|
|
region.description!));
|
|
|
|
}).toList(),
|
2023-02-15 08:48:34 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 20,
|
|
|
|
),
|
2023-02-16 07:10:54 +00:00
|
|
|
//PROVINCE DROPDOWN
|
2023-02-15 08:48:34 +00:00
|
|
|
FormBuilderDropdown(
|
|
|
|
name: 'province',
|
2023-02-16 07:10:54 +00:00
|
|
|
items: state.provinces.map<
|
|
|
|
DropdownMenuItem<
|
|
|
|
p.Province>>(
|
|
|
|
(p.Province province) {
|
|
|
|
return DropdownMenuItem(
|
|
|
|
value: province,
|
|
|
|
child: Text(
|
|
|
|
province.description!));
|
|
|
|
}).toList(),
|
|
|
|
decoration: normalTextFieldStyle(
|
|
|
|
"Province", province)
|
|
|
|
.copyWith(
|
|
|
|
hintStyle: const TextStyle(
|
|
|
|
color: Colors.black,
|
|
|
|
),
|
|
|
|
labelStyle: const TextStyle(
|
|
|
|
color: Colors.black),
|
|
|
|
)),
|
2023-02-15 08:48:34 +00:00
|
|
|
const SizedBox(
|
|
|
|
height: 20,
|
|
|
|
),
|
|
|
|
FormBuilderDropdown(
|
|
|
|
decoration: normalTextFieldStyle(
|
|
|
|
"Municipality", "Municipality"),
|
|
|
|
name: 'municipality',
|
|
|
|
items: [],
|
|
|
|
initialValue: widget
|
|
|
|
.eligibityCert
|
|
|
|
.examAddress
|
|
|
|
?.cityMunicipality
|
|
|
|
?.description ==
|
|
|
|
null
|
|
|
|
? 'region'
|
|
|
|
: 'municipality',
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
const SizedBox(
|
|
|
|
height: 20,
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
width: screenWidth,
|
|
|
|
height: 60,
|
|
|
|
child: ElevatedButton(
|
|
|
|
style: mainBtnStyle(
|
|
|
|
primary, Colors.transparent, second),
|
|
|
|
onPressed: () {},
|
|
|
|
child: const Text(submit)),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 20,
|
|
|
|
),
|
|
|
|
]),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return Container();
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return Container();
|
|
|
|
},
|
|
|
|
);
|
2023-02-15 03:40:12 +00:00
|
|
|
}
|
2023-02-15 08:48:34 +00:00
|
|
|
}
|