diff --git a/lib/bloc/profile/profile_bloc.dart b/lib/bloc/profile/profile_bloc.dart index c778ab6..8368e9b 100644 --- a/lib/bloc/profile/profile_bloc.dart +++ b/lib/bloc/profile/profile_bloc.dart @@ -5,9 +5,6 @@ import 'package:unit2/model/profile/basic_information/primary-information.dart'; import 'package:unit2/model/profile/profileInfomation.dart'; import 'package:unit2/sevices/profile/profile_service.dart'; -import '../../model/profile/basic_info.dart'; -import '../../model/profile/basic_info.dart'; - part 'profile_event.dart'; part 'profile_state.dart'; diff --git a/lib/model/profile/basic_information/citizenship.dart b/lib/model/profile/basic_information/citizenship.dart index cddc21e..397e12d 100644 --- a/lib/model/profile/basic_information/citizenship.dart +++ b/lib/model/profile/basic_information/citizenship.dart @@ -1,9 +1,3 @@ -// To parse this JSON data, do -// -// final citizenship = citizenshipFromJson(jsonString); - -import 'package:meta/meta.dart'; -import 'dart:convert'; class Citizenship { Citizenship({ diff --git a/lib/model/profile/basic_information/contact_information.dart b/lib/model/profile/basic_information/contact_information.dart index e7f9d7a..729e7f5 100644 --- a/lib/model/profile/basic_information/contact_information.dart +++ b/lib/model/profile/basic_information/contact_information.dart @@ -48,8 +48,8 @@ class CommService { factory CommService.fromJson(Map json) => CommService( id: json["id"], - serviceType: ServiceType.fromJson(json["service_type"]), - serviceProvider: ServiceProvider.fromJson(json["service_provider"]), + serviceType: json["service_type"]==null?null: ServiceType.fromJson(json["service_type"]), + serviceProvider: json["service_provider"] == null?null: ServiceProvider.fromJson(json["service_provider"]), ); Map toJson() => { @@ -73,7 +73,7 @@ class ServiceProvider { factory ServiceProvider.fromJson(Map json) => ServiceProvider( id: json["id"], alias: json["alias"], - agency: Agency.fromJson(json["agency"]), + agency: json["agency"] == null? null: Agency.fromJson(json["agency"]), ); Map toJson() => { @@ -99,7 +99,7 @@ class Agency { factory Agency.fromJson(Map json) => Agency( id: json["id"], name: json["name"], - category: Category.fromJson(json["category"]), + category: json["category"] == null? null : Category.fromJson(json["category"]), privateEntity: json["private_entity"], ); @@ -125,7 +125,7 @@ class Category { factory Category.fromJson(Map json) => Category( id: json["id"], name: json["name"], - industryClass: IndustryClass.fromJson(json["industry_class"]), + industryClass: json["industry_class"] == null? null: IndustryClass.fromJson(json["industry_class"]), ); Map toJson() => { diff --git a/lib/model/profile/basic_information/identification_information.dart b/lib/model/profile/basic_information/identification_information.dart index 09e20fe..f0ee066 100644 --- a/lib/model/profile/basic_information/identification_information.dart +++ b/lib/model/profile/basic_information/identification_information.dart @@ -25,8 +25,8 @@ class Identification { factory Identification.fromJson(Map json) => Identification( id: json["id"], - agency: Agency.fromJson(json["agency"]), - issuedAt: IssuedAt.fromJson(json["issued_at"]), + agency:json["agency"] == null? null: Agency.fromJson(json["agency"]), + issuedAt: json["issued_at"] == null? null:IssuedAt.fromJson(json["issued_at"]), dateIssued:json["date_issued"]==null?null:DateTime.parse(json["date_issued"]), expirationDate:json["expiration_date"]==null?null:DateTime.parse(json["expiration_date"]), asPdfReference: json["as_pdf_reference"], @@ -60,7 +60,7 @@ class Agency { factory Agency.fromJson(Map json) => Agency( id: json["id"], name: json["name"], - category: Category.fromJson(json["category"]), + category: json["category"] == null? null: Category.fromJson(json["category"]), privateEntity: json["private_entity"], ); @@ -86,7 +86,7 @@ class Category { factory Category.fromJson(Map json) => Category( id: json["id"], name: json["name"], - industryClass: IndustryClass.fromJson(json["industry_class"]), + industryClass:json['industry_class'] == null? null: IndustryClass.fromJson(json["industry_class"]), ); Map toJson() => { @@ -140,10 +140,10 @@ class IssuedAt { factory IssuedAt.fromJson(Map json) => IssuedAt( id: json["id"], issuedAtClass: json["class"], - country: Country.fromJson(json["country"]), + country: json['country'] == null? null: Country.fromJson(json["country"]), barangay: json["barangay"], - addressCategory: AddressCategory.fromJson(json["address_category"]), - cityMunicipality: CityMunicipality.fromJson(json["city_municipality"]), + addressCategory: json["address_category"] == null? null: AddressCategory.fromJson(json["address_category"]), + cityMunicipality:json["city_municipality"] == null? null: CityMunicipality.fromJson(json["city_municipality"]), ); Map toJson() => { @@ -198,7 +198,7 @@ class CityMunicipality { factory CityMunicipality.fromJson(Map json) => CityMunicipality( code: json["code"], zipcode: json["zipcode"], - province: Province.fromJson(json["province"]), + province:json["province"] == null? null : Province.fromJson(json["province"]), psgcCode: json["psgc_code"], description: json["description"], ); @@ -229,7 +229,7 @@ class Province { factory Province.fromJson(Map json) => Province( code: json["code"], - region: Region.fromJson(json["region"]), + region: json["region"] == null? null:Region.fromJson(json["region"]), psgcCode: json["psgc_code"], shortname: json["shortname"], description: json["description"], diff --git a/lib/model/profile/eligibility.dart b/lib/model/profile/eligibility.dart index b67a775..5999cf4 100644 --- a/lib/model/profile/eligibility.dart +++ b/lib/model/profile/eligibility.dart @@ -33,10 +33,10 @@ class EligibityCert { factory EligibityCert.fromJson(Map json) => EligibityCert( id: json["id"], rating: json["rating"]?.toDouble(), - examDate: DateTime.parse(json["exam_date"]), + examDate: json['exam_date'] == null? null: DateTime.parse(json["exam_date"]), attachments: null, - eligibility: Eligibility.fromJson(json["eligibility"]), - examAddress: ExamAddress.fromJson(json["exam_address"]), + eligibility: json['eligibility'] == null?null: Eligibility.fromJson(json["eligibility"]), + examAddress: json['eligibilty'] == null? null: ExamAddress.fromJson(json["exam_address"]), validityDate: json["validity_date"], licenseNumber: json["license_number"], ); @@ -97,10 +97,10 @@ class ExamAddress { factory ExamAddress.fromJson(Map json) => ExamAddress( id: json["id"], examAddressClass: json["class"], - country: Country.fromJson(json["country"]), + country:json["country"] == null? null: Country.fromJson(json["country"]), barangay: json["barangay"], - addressCategory: AddressCategory.fromJson(json["address_category"]), - cityMunicipality: CityMunicipality.fromJson(json["city_municipality"]), + addressCategory: json["address_category"] == null?null: AddressCategory.fromJson(json["address_category"]), + cityMunicipality: json["city_municipality"]==null? null: CityMunicipality.fromJson(json["city_municipality"]), ); Map toJson() => { @@ -155,7 +155,7 @@ class CityMunicipality { factory CityMunicipality.fromJson(Map json) => CityMunicipality( code: json["code"], zipcode: json["zipcode"], - province: Province.fromJson(json["province"]), + province: json["province"]== null? null: Province.fromJson(json["province"]), psgcCode: json["psgc_code"], description: json["description"], ); @@ -186,7 +186,7 @@ class Province { factory Province.fromJson(Map json) => Province( code: json["code"], - region: Region.fromJson(json["region"]), + region:json["region"] == null? null: Region.fromJson(json["region"]), psgcCode: json["psgc_code"], shortname: json["shortname"], description: json["description"], diff --git a/lib/model/profile/other_information/non_acedimic_recognition.dart b/lib/model/profile/other_information/non_acedimic_recognition.dart index 119b762..0697a66 100644 --- a/lib/model/profile/other_information/non_acedimic_recognition.dart +++ b/lib/model/profile/other_information/non_acedimic_recognition.dart @@ -93,7 +93,7 @@ class IndustryClass { final int? id; final String? name; - final dynamic description; + final String? description; factory IndustryClass.fromJson(Map json) => IndustryClass( id: json["id"], diff --git a/lib/model/profile/other_information/organization_memberships.dart b/lib/model/profile/other_information/organization_memberships.dart index 7776380..150f54f 100644 --- a/lib/model/profile/other_information/organization_memberships.dart +++ b/lib/model/profile/other_information/organization_memberships.dart @@ -85,7 +85,7 @@ class IndustryClass { final int? id; final String? name; - final dynamic description; + final String? description; factory IndustryClass.fromJson(Map json) => IndustryClass( id: json["id"], diff --git a/lib/model/profile/references.dart b/lib/model/profile/references.dart index b353cec..9fda1eb 100644 --- a/lib/model/profile/references.dart +++ b/lib/model/profile/references.dart @@ -139,7 +139,7 @@ class CityMunicipality { factory CityMunicipality.fromJson(Map json) => CityMunicipality( code: json["code"], zipcode: json["zipcode"], - province: Province.fromJson(json["province"]), + province: json["province"] == null? null : Province.fromJson(json["province"]), psgcCode: json["psgc_code"], description: json["description"], ); @@ -170,7 +170,7 @@ class Province { factory Province.fromJson(Map json) => Province( code: json["code"], - region: Region.fromJson(json["region"]), + region: json["region"] == null? null : Region.fromJson(json["region"]), psgcCode: json["psgc_code"], shortname: json["shortname"], description: json["description"], diff --git a/lib/model/profile/voluntary_works.dart b/lib/model/profile/voluntary_works.dart index 4938116..267fb8d 100644 --- a/lib/model/profile/voluntary_works.dart +++ b/lib/model/profile/voluntary_works.dart @@ -28,7 +28,7 @@ class VoluntaryWork { factory VoluntaryWork.fromJson(Map json) => VoluntaryWork( agency: json["agency"] == null ? null : Agency.fromJson(json["agency"]), address: json["address"] == null ? null : Address.fromJson(json["address"]), - toDate: json["to_date"], + toDate: json["to_date"] == null? null : DateTime.parse(json['to_data']), position: json["position"] == null ? null : Position.fromJson(json["position"]), fromDate: json["from_date"] == null ? null : DateTime.parse(json["from_date"]), totalHours: json["total_hours"], @@ -277,7 +277,7 @@ class IndustryClass { final int? id; final String? name; - final dynamic description; + final String? description; factory IndustryClass.fromJson(Map json) => IndustryClass( id: json["id"], diff --git a/lib/model/profile/work_history.dart b/lib/model/profile/work_history.dart index 3fbd78d..7a1ff98 100644 --- a/lib/model/profile/work_history.dart +++ b/lib/model/profile/work_history.dart @@ -121,7 +121,7 @@ class IndustryClass { final int? id; final String? name; - final dynamic description; + final String? description; factory IndustryClass.fromJson(Map json) => IndustryClass( id: json["id"], diff --git a/lib/screens/profile/components/basic_information/address_screen.dart b/lib/screens/profile/components/basic_information/address_screen.dart index fecfa17..ffb8e61 100644 --- a/lib/screens/profile/components/basic_information/address_screen.dart +++ b/lib/screens/profile/components/basic_information/address_screen.dart @@ -4,32 +4,29 @@ import 'package:unit2/theme-data.dart/box_shadow.dart'; import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/utils/global.dart'; import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/add_leading.dart'; +import 'package:unit2/widgets/empty_data.dart'; -class AddressScreen extends StatefulWidget { +class AddressScreen extends StatelessWidget { final List addresses; const AddressScreen({super.key, required this.addresses}); - @override - State createState() => _AddressScreenState(); -} - -class _AddressScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: const Text(adressScreenTitle),centerTitle: true, backgroundColor: primary,), - body: ListView.builder( + appBar: AppBar(title: const Text(adressScreenTitle),centerTitle: true, backgroundColor: primary, actions: [AddLeading(onPressed: (){})],), + body: addresses.isNotEmpty ? ListView.builder( padding: const EdgeInsets.symmetric(vertical: 8,horizontal: 10), - itemCount: widget.addresses.length, + itemCount: addresses.length, itemBuilder: ( BuildContext context, int index){ - String? subdivision = widget.addresses[index].details??''; - String category = widget.addresses[index].address!.category!.name!; - String? barangay = widget.addresses[index].address!.barangay != null?'${widget.addresses[index].address!.barangay!.description!.toUpperCase()},':''; - String cityMunicipality = widget.addresses[index].address!.cityMunicipality!.description!; - String province = widget.addresses[index].address!.cityMunicipality!.province!.description!; - String region = widget.addresses[index].address!.cityMunicipality!.province!.region!.description!; + String? subdivision = addresses[index].details??''; + String category = addresses[index].address!.category!.name!; + String? barangay = addresses[index].address!.barangay != null?'${addresses[index].address!.barangay!.description!.toUpperCase()},':''; + String cityMunicipality = addresses[index].address!.cityMunicipality!.description!; + String province = addresses[index].address!.cityMunicipality!.province!.description!; + String region = addresses[index].address!.cityMunicipality!.province!.region!.description!; return Column(children: [ Column( @@ -54,7 +51,7 @@ class _AddressScreenState extends State { ), const SizedBox(height: 5,), ],); - }), + }):const EmptyData(message: "You don't have address added. Please click + to add."), ); } } \ No newline at end of file diff --git a/lib/screens/profile/components/basic_information/contact_information_screen.dart b/lib/screens/profile/components/basic_information/contact_information_screen.dart index e8055e6..f89c626 100644 --- a/lib/screens/profile/components/basic_information/contact_information_screen.dart +++ b/lib/screens/profile/components/basic_information/contact_information_screen.dart @@ -3,16 +3,13 @@ import 'package:unit2/model/profile/basic_information/contact_information.dart'; import 'package:unit2/theme-data.dart/box_shadow.dart'; import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/add_leading.dart'; +import 'package:unit2/widgets/empty_data.dart'; -class ContactInformationScreen extends StatefulWidget { +class ContactInformationScreen extends StatelessWidget { final List contacts; const ContactInformationScreen({super.key, required this.contacts}); - @override - State createState() => _ContactInformationScreenState(); -} - -class _ContactInformationScreenState extends State { @override Widget build(BuildContext context) { return SafeArea( @@ -21,13 +18,14 @@ class _ContactInformationScreenState extends State { title: const Text(contactScreenTitle), centerTitle: true, backgroundColor: primary, + actions: [AddLeading(onPressed: (){})], ), - body: ListView.builder( + body: contacts.isEmpty? ListView.builder( padding: const EdgeInsets.symmetric(vertical: 8,horizontal: 10), - itemCount: widget.contacts.length, + itemCount: contacts.length, itemBuilder: (BuildContext context, int index) { - String numberMail = widget.contacts[index].numbermail!; - String commService = widget.contacts[index].commService!.serviceProvider!.alias!; + String numberMail = contacts[index].numbermail!; + String commService = contacts[index].commService!.serviceProvider!.alias!; return Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, @@ -52,13 +50,13 @@ class _ContactInformationScreenState extends State { .toString(),style: Theme.of(context).textTheme.titleSmall,), ), - widget.contacts[index].active==true? const Badge(backgroundColor: Colors.green, label: Text("Active",),):const SizedBox(), + contacts[index].active==true? const Badge(backgroundColor: Colors.green, label: Text("Active",),):const SizedBox(), const SizedBox(width: 5), - widget.contacts[index].primary==true? const Badge(backgroundColor: Colors.blue, label: Text("Primary"),):const SizedBox() + contacts[index].primary==true? const Badge(backgroundColor: Colors.blue, label: Text("Primary"),):const SizedBox() ], ), const SizedBox(height: 5,), - Text(widget.contacts[index].commService! + Text(contacts[index].commService! .serviceProvider!.agency!.name .toString()), @@ -74,7 +72,7 @@ class _ContactInformationScreenState extends State { ], ); - }), + }):const EmptyData(message: "You don't have contact information added. Please click + to add"), ), ); } diff --git a/lib/screens/profile/components/basic_information/identification_information_screen.dart b/lib/screens/profile/components/basic_information/identification_information_screen.dart index e531d2a..a3584da 100644 --- a/lib/screens/profile/components/basic_information/identification_information_screen.dart +++ b/lib/screens/profile/components/basic_information/identification_information_screen.dart @@ -4,18 +4,13 @@ import 'package:unit2/theme-data.dart/box_shadow.dart'; import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/utils/global.dart'; import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/add_leading.dart'; +import 'package:unit2/widgets/empty_data.dart'; -class IdentificationsScreen extends StatefulWidget { +class IdentificationsScreen extends StatelessWidget { final List identities; const IdentificationsScreen({super.key, required this.identities}); - @override - State createState() => - _IdentificationsScreenState(); -} - -class _IdentificationsScreenState - extends State { @override Widget build(BuildContext context) { return Scaffold( @@ -23,15 +18,16 @@ class _IdentificationsScreenState title: const Text(identificationScreenTitle), centerTitle: true, backgroundColor: primary, + actions: [AddLeading(onPressed: (){})], ), - body: ListView.builder( + body:identities.isNotEmpty? ListView.builder( padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 10), - itemCount: widget.identities.length, + itemCount: identities.length, itemBuilder: (BuildContext context, int index) { - String agency = widget.identities[index].agency!.name!; - String idNumber = widget.identities[index].identificationNumber!; - bool government = widget.identities[index].agency!.privateEntity!; - String issuedAt = "${widget.identities[index].issuedAt!.cityMunicipality!.description!} ${widget.identities[index].issuedAt!.cityMunicipality!.province!.description}"; + String agency = identities[index].agency!.name!; + String idNumber = identities[index].identificationNumber!; + bool government = identities[index].agency!.privateEntity!; + String issuedAt = "${identities[index].issuedAt!.cityMunicipality!.description!} ${identities[index].issuedAt!.cityMunicipality!.province!.description}"; return Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, @@ -84,7 +80,7 @@ class _IdentificationsScreenState ), ], ); - }), + }):const EmptyData(message: "You don't have identifications added. Please click + to add."), ); } } diff --git a/lib/screens/profile/components/education_screen.dart b/lib/screens/profile/components/education_screen.dart index de6f09f..99af383 100644 --- a/lib/screens/profile/components/education_screen.dart +++ b/lib/screens/profile/components/education_screen.dart @@ -4,16 +4,13 @@ import 'package:unit2/model/profile/educational_background.dart'; import 'package:unit2/theme-data.dart/box_shadow.dart'; import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/add_leading.dart'; +import 'package:unit2/widgets/empty_data.dart'; -class EducationScreen extends StatefulWidget { +class EducationScreen extends StatelessWidget { final List educationBackgrounds; const EducationScreen({super.key, required this.educationBackgrounds}); - @override - State createState() => _EducationScreenState(); -} - -class _EducationScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( @@ -21,23 +18,24 @@ class _EducationScreenState extends State { title: const Text(educationScreenTitle), centerTitle: true, backgroundColor: primary, + actions: [AddLeading(onPressed: (){})], ), - body: ListView.builder( + body: educationBackgrounds.isNotEmpty ? ListView.builder( padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 10), - itemCount: widget.educationBackgrounds.length, + itemCount: educationBackgrounds.length, itemBuilder: (BuildContext context, int index) { - String level = widget.educationBackgrounds[index].education!.level!; - String periodFrom = widget.educationBackgrounds[index].periodFrom!; - String periodTo = widget.educationBackgrounds[index].periodTo!; + String level = educationBackgrounds[index].education!.level!; + String periodFrom = educationBackgrounds[index].periodFrom!; + String periodTo = educationBackgrounds[index].periodTo!; String? program = - widget.educationBackgrounds[index].education!.course == null + educationBackgrounds[index].education!.course == null ? null - : widget.educationBackgrounds[index].education!.course! + : educationBackgrounds[index].education!.course! .program!; List? honors = - widget.educationBackgrounds[index].honors!.toList(); + educationBackgrounds[index].honors!.toList(); String school = - widget.educationBackgrounds[index].education!.school!.name!; + educationBackgrounds[index].education!.school!.name!; return Column( children: [ Container( @@ -81,13 +79,13 @@ class _EducationScreenState extends State { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Text("$honorsText : "), + const Text("$honorsText : ",style: TextStyle(fontWeight: FontWeight.w600),), Column( children: honors .map((Honor honor) => - Text(" ${honor.name!}")) + Text(" - ${honor.name!}")) .toList(), ), ], @@ -123,7 +121,7 @@ class _EducationScreenState extends State { ), ], ); - }), + }):const EmptyData(message: "You don't have any Educational Background added. Please click + to add."), ); } } diff --git a/lib/screens/profile/components/eligibility_screen.dart b/lib/screens/profile/components/eligibility_screen.dart index 8eb7b5d..6f5148f 100644 --- a/lib/screens/profile/components/eligibility_screen.dart +++ b/lib/screens/profile/components/eligibility_screen.dart @@ -6,16 +6,13 @@ import 'package:unit2/theme-data.dart/box_shadow.dart'; import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/utils/global.dart'; import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/add_leading.dart'; +import 'package:unit2/widgets/empty_data.dart'; -class EligibiltyScreen extends StatefulWidget { +class EligibiltyScreen extends StatelessWidget { final List eligibilities; const EligibiltyScreen({super.key, required this.eligibilities}); - @override - State createState() => _EligibiltyScreenState(); -} - -class _EligibiltyScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( @@ -23,12 +20,13 @@ class _EligibiltyScreenState extends State { title: const Text(elibilityScreenTitle), centerTitle: true, backgroundColor: primary, + actions: [AddLeading(onPressed: (){})], ), - body: ListView.builder( + body: eligibilities.isNotEmpty? ListView.builder( padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 10), - itemCount: widget.eligibilities.length, + itemCount: eligibilities.length, itemBuilder: (BuildContext context, int index) { - String title = widget.eligibilities[index].eligibility!.title!; + String title = eligibilities[index].eligibility!.title!; return Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, @@ -51,20 +49,21 @@ class _EligibiltyScreenState extends State { const Divider(), const SizedBox(height: 5,), Text( - "$licenseNumber: ${widget.eligibilities[index].licenseNumber == null ? 'N/A' : widget.eligibilities[index].licenseNumber.toString()}",style: Theme.of(context).textTheme.titleSmall), + "$licenseNumber: ${eligibilities[index].licenseNumber == null ? 'N/A' : eligibilities[index].licenseNumber.toString()}",style: Theme.of(context).textTheme.titleSmall), const SizedBox(height: 3,), Text( - "$rating : ${widget.eligibilities[index].rating}.",style: Theme.of(context).textTheme.titleSmall) + "$rating : ${eligibilities[index].rating}.",style: Theme.of(context).textTheme.titleSmall) ]), ), IconButton( onPressed: () {}, icon: const Icon(Icons.more_vert,color: Colors.grey,)) ], ), - ) + ), + const SizedBox(height: 5,) ], ); - }), + }):const EmptyData(message: "You don't have any Eligibility added. Please click + to add."), ); } } diff --git a/lib/screens/profile/components/family_background_screen.dart b/lib/screens/profile/components/family_background_screen.dart index 393b2f9..2592010 100644 --- a/lib/screens/profile/components/family_background_screen.dart +++ b/lib/screens/profile/components/family_background_screen.dart @@ -71,7 +71,11 @@ class _FamilyBackgroundScreenState extends State { Text(" $fullname",style: Theme.of(context).textTheme.bodySmall,), Row( children: [ - Checkbox(value: false, onChanged: (value) {}), + Checkbox(value: false, onChanged: (value) { + setState(() { + value = !value!; + }); + }), const Text(incaseOfEmergency) ], ) diff --git a/lib/screens/profile/components/learning_and_development_screen.dart b/lib/screens/profile/components/learning_and_development_screen.dart index 78e64c9..5b53706 100644 --- a/lib/screens/profile/components/learning_and_development_screen.dart +++ b/lib/screens/profile/components/learning_and_development_screen.dart @@ -7,34 +7,33 @@ import 'package:unit2/theme-data.dart/box_shadow.dart'; import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/utils/global.dart'; import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/add_leading.dart'; +import 'package:unit2/widgets/empty_data.dart'; -class LearningAndDevelopmentScreen extends StatefulWidget { +class LearningAndDevelopmentScreen extends StatelessWidget { final List learningDevelopments; const LearningAndDevelopmentScreen({super.key, required this.learningDevelopments}); - @override - State createState() => _LearningAndDevelopmentScreenState(); -} + -class _LearningAndDevelopmentScreenState extends State { - DateFormat dteFormat2 = DateFormat.yMMMMd('en_US'); @override Widget build(BuildContext context) { + DateFormat dteFormat2 = DateFormat.yMMMMd('en_US'); return Scaffold( appBar: AppBar(title: const Text(learningAndDevelopmentScreenTitle), centerTitle: true, backgroundColor: primary, - + actions: [AddLeading(onPressed: (){})], ), - body: ListView.builder( + body: learningDevelopments.isNotEmpty? ListView.builder( padding: const EdgeInsets.symmetric(vertical: 8,horizontal: 10), - itemCount: widget.learningDevelopments.length, + itemCount: learningDevelopments.length, itemBuilder: (BuildContext context, int index){ - String training = widget.learningDevelopments[index].conductedTraining!.title!.title!; - String provider = widget.learningDevelopments[index].conductedTraining!.conductedBy!.name!; - String start = dteFormat2.format(widget.learningDevelopments[index].conductedTraining!.fromDate!); - String end = dteFormat2.format(widget.learningDevelopments[index].conductedTraining!.toDate!); - String type = widget.learningDevelopments[index].conductedTraining!.learningDevelopmentType!.title!; + String training = learningDevelopments[index].conductedTraining!.title!.title!; + String provider = learningDevelopments[index].conductedTraining!.conductedBy!.name!; + String start = dteFormat2.format(learningDevelopments[index].conductedTraining!.fromDate!); + String end = dteFormat2.format(learningDevelopments[index].conductedTraining!.toDate!); + String type = learningDevelopments[index].conductedTraining!.learningDevelopmentType!.title!; return Column( children: [ Container( @@ -65,7 +64,7 @@ class _LearningAndDevelopmentScreenState extends State nonAcademicRecognitions; const NonAcademicRecognitionScreen({super.key, required this.nonAcademicRecognitions}); - @override - State createState() => _NonAcademicRecognitionScreenState(); -} - -class _NonAcademicRecognitionScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: const Text(nonAcademicRecTitle), centerTitle: true, backgroundColor: primary,), - body: ListView.builder( + appBar: AppBar(title: const Text(nonAcademicRecTitle), centerTitle: true, backgroundColor: primary,actions: [AddLeading(onPressed: (){})],), + body: nonAcademicRecognitions.isNotEmpty?ListView.builder( padding: const EdgeInsets.symmetric(vertical: 8,horizontal: 10), - itemCount: widget.nonAcademicRecognitions.length, + itemCount: nonAcademicRecognitions.length, itemBuilder: (BuildContext context, int index){ - String award = widget.nonAcademicRecognitions[index].title!; - String presenter = widget.nonAcademicRecognitions[index].presenter!.name!; + String award = nonAcademicRecognitions[index].title!; + String presenter = nonAcademicRecognitions[index].presenter!.name!; return Column( children: [ Container( @@ -50,7 +47,7 @@ class _NonAcademicRecognitionScreenState extends State orgMemberships; const OrgMembershipsScreen({super.key, required this.orgMemberships}); - @override - State createState() => _OrgMembershipsScreenState(); -} - -class _OrgMembershipsScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( @@ -24,16 +19,17 @@ class _OrgMembershipsScreenState extends State { title: const Text(orgMembershipTitle), backgroundColor: primary, centerTitle: true, + actions: [AddLeading(onPressed: (){})], ), - body: ListView.builder( - itemCount: widget.orgMemberships.length, + body: orgMemberships.isNotEmpty? ListView.builder( + itemCount: orgMemberships.length, padding: const EdgeInsets.symmetric(vertical: 8,horizontal: 10), itemBuilder: (BuildContext context, int index) { String entity = - widget.orgMemberships[index].agency!.privateEntity == false + orgMemberships[index].agency!.privateEntity == false ? governmentText.toUpperCase() : privateText.toUpperCase(); - String agencyName = widget.orgMemberships[index].agency!.name!; + String agencyName = orgMemberships[index].agency!.name!; return Column( children: [ Container( @@ -60,7 +56,7 @@ class _OrgMembershipsScreenState extends State { const SizedBox(height: 5,), ], ); - }), + }):const EmptyData(message: "You don't have any Organization Membership added. Please click + to add."), ); } } diff --git a/lib/screens/profile/components/other_information/skills_and_hobbies_screen.dart b/lib/screens/profile/components/other_information/skills_and_hobbies_screen.dart index b00f398..cbc57e2 100644 --- a/lib/screens/profile/components/other_information/skills_and_hobbies_screen.dart +++ b/lib/screens/profile/components/other_information/skills_and_hobbies_screen.dart @@ -5,26 +5,24 @@ import 'package:unit2/model/profile/other_information/skills_and_hobbies.dart'; import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/utils/global.dart'; import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/add_leading.dart'; +import 'package:unit2/widgets/empty_data.dart'; -class SkillHobbiesScreen extends StatefulWidget { +class SkillHobbiesScreen extends StatelessWidget { final ListskillsHobbies; const SkillHobbiesScreen({super.key,required this.skillsHobbies}); - @override - State createState() => _SkillHobbiesScreenState(); -} - -class _SkillHobbiesScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text(skillAndHobbiesTitle), backgroundColor: primary, centerTitle: true, + actions: [AddLeading(onPressed: (){})], ), - body: Padding( - padding: const EdgeInsets.all(16), + body: skillsHobbies.isNotEmpty? Padding( + padding: const EdgeInsets.all(24), child: Wrap( spacing: 8, runSpacing: 8, @@ -33,7 +31,7 @@ class _SkillHobbiesScreenState extends State { verticalDirection: VerticalDirection.up, crossAxisAlignment: WrapCrossAlignment.start, direction: Axis.horizontal, - children:widget.skillsHobbies.map((SkillsHobbies sh){ + children:skillsHobbies.map((SkillsHobbies sh){ return FittedBox( child: Row( children: [ @@ -47,7 +45,7 @@ class _SkillHobbiesScreenState extends State { }).toList() ), - ), + ):const EmptyData(message: "You don't have any Skills and Hobbies added. Please click + to add"), ); } } \ No newline at end of file diff --git a/lib/screens/profile/components/references_screen.dart b/lib/screens/profile/components/references_screen.dart index 1a4e221..319fd18 100644 --- a/lib/screens/profile/components/references_screen.dart +++ b/lib/screens/profile/components/references_screen.dart @@ -5,55 +5,82 @@ import 'package:unit2/model/profile/references.dart'; import 'package:unit2/theme-data.dart/box_shadow.dart'; import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/add_leading.dart'; +import 'package:unit2/widgets/empty_data.dart'; -class ReferencesScreen extends StatefulWidget { +class ReferencesScreen extends StatelessWidget { final List references; const ReferencesScreen({super.key, required this.references}); - @override - State createState() => _ReferencesScreenState(); -} - -class _ReferencesScreenState extends State { @override Widget build(BuildContext context) { - - return Scaffold( - appBar: AppBar(title: const Text(referencesScreenTitle),centerTitle: true,backgroundColor: primary,), - body: ListView.builder( - padding: const EdgeInsets.symmetric(vertical: 8,horizontal: 10), - itemCount: widget.references.length, - itemBuilder: (BuildContext context, int index){ - String fullname = "${widget.references[index].firstName} ${widget.references[index].middleName} ${widget.references[index].lastName}"; - String addres = "${widget.references[index].address!.cityMunicipality!.description}, ${widget.references[index].address!.cityMunicipality!.province!.description}, ${widget.references[0].address!.cityMunicipality!.province!.region!.description}"; - String mobile = widget.references[index].contactNo.toString(); - return Column(children: [ - Container( - padding: const EdgeInsets.symmetric(horizontal: 12,vertical: 8), - decoration:box1(), - child: Row( - children: [ - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - - Text(fullname,style: Theme.of(context).textTheme.titleMedium!.copyWith(fontWeight: FontWeight.w500)), - const Divider(), - const SizedBox(height: 5,), - Text(addres,style: Theme.of(context).textTheme.titleSmall!.copyWith(fontWeight: FontWeight.w500)), - const SizedBox(height: 8,), - Text("${mobileOrPhone.toUpperCase()} : $mobile",style: Theme.of(context).textTheme.labelMedium!), - ],), + return Scaffold( + appBar: AppBar( + title: const Text(referencesScreenTitle), + centerTitle: true, + backgroundColor: primary, + actions: [AddLeading(onPressed: (){})], + ), + body: references.isNotEmpty? ListView.builder( + padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 10), + itemCount: references.length, + itemBuilder: (BuildContext context, int index) { + String fullname = + "${references[index].firstName} ${references[index].middleName} ${references[index].lastName}"; + String addres = + "${references[index].address!.cityMunicipality!.description}, ${references[index].address!.cityMunicipality!.province!.description}, ${references[0].address!.cityMunicipality!.province!.region!.description}"; + String mobile = references[index].contactNo.toString(); + return Column( + children: [ + Container( + padding: + const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + decoration: box1(), + child: Row( + children: [ + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(fullname, + style: Theme.of(context) + .textTheme + .titleMedium! + .copyWith(fontWeight: FontWeight.w500)), + const Divider(), + const SizedBox( + height: 5, + ), + Text(addres, + style: Theme.of(context) + .textTheme + .titleSmall! + .copyWith(fontWeight: FontWeight.w500)), + const SizedBox( + height: 8, + ), + Text("${mobileOrPhone.toUpperCase()} : $mobile", + style: + Theme.of(context).textTheme.labelMedium!), + ], + ), + ), + IconButton( + onPressed: () {}, + icon: const Icon( + Icons.more_vert, + color: Colors.grey, + )) + ], ), - IconButton(onPressed: (){}, icon: const Icon(Icons.more_vert,color: Colors.grey,)) - ], - ), - ), - const SizedBox(height: 5,), - ],); - }) , + ), + const SizedBox( + height: 5, + ), + ], + ); + }):const EmptyData(message: "You don't have any References added. Please click + to add."), ); } -} \ No newline at end of file +} diff --git a/lib/screens/profile/components/voluntary_works_screen.dart b/lib/screens/profile/components/voluntary_works_screen.dart index b6e24b7..eebdaed 100644 --- a/lib/screens/profile/components/voluntary_works_screen.dart +++ b/lib/screens/profile/components/voluntary_works_screen.dart @@ -4,64 +4,82 @@ import 'package:unit2/model/profile/voluntary_works.dart'; import 'package:unit2/theme-data.dart/box_shadow.dart'; import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/add_leading.dart'; +import 'package:unit2/widgets/empty_data.dart'; -class VolunataryWorkScreen extends StatefulWidget { +class VolunataryWorkScreen extends StatelessWidget { final List voluntaryWorks; const VolunataryWorkScreen({super.key, required this.voluntaryWorks}); - @override - State createState() => _VolunataryWorkScreenState(); -} - -class _VolunataryWorkScreenState extends State { - DateFormat dteFormat2 = DateFormat.yMMMMd('en_US'); @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar(title: const Text(voluntaryScreenTitle),backgroundColor: primary,), - body: ListView.builder( - itemCount:widget.voluntaryWorks.length , - padding: const EdgeInsets.symmetric(vertical: 8,horizontal: 10), - itemBuilder: (BuildContext context, int index){ - String position = widget.voluntaryWorks[index].position!.title!; - String agency = widget.voluntaryWorks[index].agency!.name!; - String from = dteFormat2.format(widget.voluntaryWorks[index].fromDate!); - String hours = widget.voluntaryWorks[index].totalHours.toString(); - String? to = widget.voluntaryWorks[index].toDate == null? "Present" : dteFormat2.format(widget.voluntaryWorks[index].toDate!); - return Column( - children: [ - Container( - decoration:box1(), - padding: const EdgeInsets.symmetric(horizontal: 12,vertical: 8), - child: Row( + DateFormat dteFormat2 = DateFormat.yMMMMd('en_US'); + return Scaffold( + appBar: AppBar( + title: const Text(voluntaryScreenTitle), + backgroundColor: primary, + actions: [AddLeading(onPressed: (){})], + ), + body: voluntaryWorks.isNotEmpty? ListView.builder( + itemCount: voluntaryWorks.length, + padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 10), + itemBuilder: (BuildContext context, int index) { + String position = voluntaryWorks[index].position!.title!; + String agency = voluntaryWorks[index].agency!.name!; + String from = dteFormat2.format(voluntaryWorks[index].fromDate!); + String hours = voluntaryWorks[index].totalHours.toString(); + String? to = voluntaryWorks[index].toDate == null + ? "Present" + : dteFormat2.format(voluntaryWorks[index].toDate!); + return Column( children: [ - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + Container( + decoration: box1(), + padding: + const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + child: Row( children: [ - Text(position,style: Theme.of(context).textTheme.titleMedium!.copyWith(fontWeight: FontWeight.w500),), - const SizedBox(height: 5,), - Text(agency,style: Theme.of(context).textTheme.titleSmall,), - const Divider(), - const SizedBox(height: 3,), - Text("$duration : $from to $to"), - const SizedBox(height: 5,), - Text("$numberOfHours : $hours hours"), - ]), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + position, + style: Theme.of(context) + .textTheme + .titleMedium! + .copyWith(fontWeight: FontWeight.w500), + ), + const SizedBox( + height: 5, + ), + Text( + agency, + style: Theme.of(context).textTheme.titleSmall, + ), + const Divider(), + const SizedBox( + height: 3, + ), + Text("$duration : $from to $to"), + const SizedBox( + height: 5, + ), + Text("$numberOfHours : $hours hours"), + ]), + ), + IconButton( + onPressed: () {}, icon: const Icon(Icons.more_vert)) + ], + ), + ), + const SizedBox( + height: 5, ), - IconButton(onPressed: (){}, icon: const Icon(Icons.more_vert)) ], - ), - - - ), - const SizedBox(height: 5,), - - ], - ); - - }), + ); + }):const EmptyData(message: "You don't have any Voluntary Works added. Please click + to add."), ); } -} \ No newline at end of file +} diff --git a/lib/screens/profile/components/work_history_screen.dart b/lib/screens/profile/components/work_history_screen.dart index 47d5c90..1d896dd 100644 --- a/lib/screens/profile/components/work_history_screen.dart +++ b/lib/screens/profile/components/work_history_screen.dart @@ -4,38 +4,38 @@ import 'package:unit2/model/profile/work_history.dart'; import 'package:unit2/theme-data.dart/box_shadow.dart'; import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/add_leading.dart'; +import 'package:unit2/widgets/empty_data.dart'; import '../../../utils/global.dart'; -class WorkHistoryScreen extends StatefulWidget { +class WorkHistoryScreen extends StatelessWidget { final List workExperiences; const WorkHistoryScreen({super.key, required this.workExperiences}); - @override - State createState() => _WorkHistoryScreenState(); -} + -class _WorkHistoryScreenState extends State { - DateFormat dteFormat2 = DateFormat.yMMMMd('en_US'); @override Widget build(BuildContext context) { + DateFormat dteFormat2 = DateFormat.yMMMMd('en_US'); return Scaffold( appBar: AppBar( title: const Text(workHistoryScreenTitle), backgroundColor: primary, centerTitle: true, + actions: [AddLeading(onPressed: (){})], ), - body: ListView.builder( + body: workExperiences.isNotEmpty? ListView.builder( padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 10), - itemCount: widget.workExperiences.length, + itemCount: workExperiences.length, itemBuilder: (BuildContext context, int index) { - String position = widget.workExperiences[index].position!.title!; - String agency = widget.workExperiences[index].agency!.name!; + String position = workExperiences[index].position!.title!; + String agency = workExperiences[index].agency!.name!; String from = - dteFormat2.format(widget.workExperiences[index].fromDate!); - String? to = widget.workExperiences[index].toDate == null + dteFormat2.format(workExperiences[index].fromDate!); + String? to = workExperiences[index].toDate == null ? present.toUpperCase() - : dteFormat2.format(widget.workExperiences[index].toDate!); + : dteFormat2.format(workExperiences[index].toDate!); return Column( children: [ @@ -65,7 +65,7 @@ class _WorkHistoryScreenState extends State { ), ], ); - }), + }):const EmptyData(message: "You don't have any Work History added. Please click + to add ."), ); } } diff --git a/lib/screens/unit2/login/login.dart b/lib/screens/unit2/login/login.dart index 7b6fbf5..045bcc6 100644 --- a/lib/screens/unit2/login/login.dart +++ b/lib/screens/unit2/login/login.dart @@ -8,6 +8,7 @@ import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:unit2/screens/unit2/login/components/update_required.dart'; import 'package:unit2/utils/alerts.dart'; +import 'package:unit2/utils/internet_time_out.dart'; import 'package:unit2/utils/text_container.dart'; import 'package:unit2/widgets/error_state.dart'; import '../../../bloc/user/user_bloc.dart'; @@ -319,14 +320,13 @@ class _UniT2LoginState extends State { }); } if (state is UserError) { - return ErrorState( - message: state.message, + return SomethingWentWrong( + message:onError , + onpressed:(){} , ); } if (state is InternetTimeout) { - return ErrorState( - message: state.message, - ); + return const TimeOutError(); } if (state is SplashScreen) { return const UniTSplashScreen(); diff --git a/lib/screens/unit2/login/qr_login.dart b/lib/screens/unit2/login/qr_login.dart index 0a52f5c..6be5696 100644 --- a/lib/screens/unit2/login/qr_login.dart +++ b/lib/screens/unit2/login/qr_login.dart @@ -1,14 +1,11 @@ -import 'package:flutter/cupertino.dart'; + import 'package:flutter/material.dart'; -import 'package:flutter/src/widgets/container.dart'; -import 'package:flutter/src/widgets/framework.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_svg/svg.dart'; import 'package:fluttericon/font_awesome5_icons.dart'; import 'package:unit2/theme-data.dart/btn-style.dart'; -import 'package:unit2/widgets/error_state.dart'; import 'package:unit2/widgets/wave.dart'; import '../../../bloc/user/user_bloc.dart'; import '../../../theme-data.dart/colors.dart'; @@ -186,8 +183,6 @@ class _QRLoginState extends State { ], ), ); - }if(state is UserError){ - return ErrorState(message: state.message,); } return Container(); }, diff --git a/lib/utils/internet_time_out.dart b/lib/utils/internet_time_out.dart new file mode 100644 index 0000000..b4a0359 --- /dev/null +++ b/lib/utils/internet_time_out.dart @@ -0,0 +1,54 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:unit2/theme-data.dart/btn-style.dart'; + +import '../theme-data.dart/colors.dart'; + +class TimeOutError extends StatelessWidget { + const TimeOutError({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SvgPicture.asset( + 'assets/svgs/timeout.svg', + height: 200.0, + width: 200.0, + allowDrawingOutsideViewBox: true, + ), + const SizedBox( + height: 25, + ), + const Text( + 'Connection Timeout! Pls check your internet connectivity.', + textAlign: TextAlign.center,), + + const SizedBox( + height: 25, + ), + SizedBox( + height: 50, + child: ElevatedButton.icon( + style: mainBtnStyle( + primary, Colors.transparent, primary.withOpacity(.5)), + onPressed:(){ + }, + icon: const Icon( + Icons.refresh, + color: Colors.white, + ), + label: const Text( + "try again", + style: TextStyle(color: Colors.white), + )), + ) + ], + ), + ); + } +} \ No newline at end of file diff --git a/lib/widgets/add_leading.dart b/lib/widgets/add_leading.dart new file mode 100644 index 0000000..b053d1a --- /dev/null +++ b/lib/widgets/add_leading.dart @@ -0,0 +1,13 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/src/widgets/framework.dart'; +import 'package:flutter/src/widgets/placeholder.dart'; + +class AddLeading extends StatelessWidget { + final Function() onPressed; + const AddLeading({super.key, required this.onPressed}); + + @override + Widget build(BuildContext context) { + return IconButton(onPressed: onPressed, icon: const Icon(Icons.add)); + } +} \ No newline at end of file diff --git a/lib/widgets/empty_data.dart b/lib/widgets/empty_data.dart new file mode 100644 index 0000000..78a4515 --- /dev/null +++ b/lib/widgets/empty_data.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:unit2/utils/global.dart'; + + +class EmptyData extends StatelessWidget { + final String message; + const EmptyData({Key? key, required this.message,}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 24), + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SvgPicture.asset( + 'assets/svgs/empty.svg', + height: 200.0, + width: 200.0, + allowDrawingOutsideViewBox: true, + ), + const SizedBox( + height: 20, + ), + Text( + message,style: Theme.of(context).textTheme.displaySmall!.copyWith(fontSize: blockSizeVertical * 2), + textAlign: TextAlign.center, + ), + + ], + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/widgets/error_state.dart b/lib/widgets/error_state.dart index ede9ef3..e66a523 100644 --- a/lib/widgets/error_state.dart +++ b/lib/widgets/error_state.dart @@ -1,13 +1,58 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/src/widgets/container.dart'; -import 'package:flutter/src/widgets/framework.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:unit2/theme-data.dart/btn-style.dart'; -class ErrorState extends StatelessWidget { +import '../theme-data.dart/colors.dart'; + +class SomethingWentWrong extends StatelessWidget { final String? message; - const ErrorState({super.key,this.message}); + final Function()? onpressed; + const SomethingWentWrong({Key? key, required this.message, required this.onpressed}) + : super(key: key); @override Widget build(BuildContext context) { - return Center(child: Text(message!)); + return Container( + padding: const EdgeInsets.symmetric(horizontal: 15), + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SvgPicture.asset( + 'assets/svgs/error.svg', + height: 200.0, + width: 200.0, + allowDrawingOutsideViewBox: true, + ), + const SizedBox( + height: 10, + ), + Text( + message??'', + textAlign: TextAlign.center, + ), + const SizedBox( + height: 20, + ), + SizedBox( + height: 50, + child: ElevatedButton.icon( + style: mainBtnStyle( + primary, Colors.transparent, primary.withOpacity(.5)), + onPressed: onpressed, + icon: const Icon( + Icons.refresh, + color: Colors.white, + ), + label: const Text( + "try again", + style: TextStyle(color: Colors.white), + )), + ) + ], + ), + ), + ); } } \ No newline at end of file