sorting done, covid inprogress
parent
366429f083
commit
873b2a1591
@ -0,0 +1,33 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
class CovidQuestionnaireModel {
|
||||||
|
int? id;
|
||||||
|
String? questionEn;
|
||||||
|
String? questionAr;
|
||||||
|
int? ans;
|
||||||
|
|
||||||
|
CovidQuestionnaireModel({
|
||||||
|
this.id,
|
||||||
|
this.questionEn,
|
||||||
|
this.questionAr,
|
||||||
|
this.ans,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory CovidQuestionnaireModel.fromRawJson(String str) => CovidQuestionnaireModel.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String toRawJson() => json.encode(toJson());
|
||||||
|
|
||||||
|
factory CovidQuestionnaireModel.fromJson(Map<String, dynamic> json) => CovidQuestionnaireModel(
|
||||||
|
id: json["id"],
|
||||||
|
questionEn: json["questionEN"],
|
||||||
|
questionAr: json["questionAR"],
|
||||||
|
ans: json["ans"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"id": id,
|
||||||
|
"questionEN": questionEn,
|
||||||
|
"questionAR": questionAr,
|
||||||
|
"ans": ans,
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -0,0 +1,283 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
|
||||||
|
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
||||||
|
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
||||||
|
import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_view_model.dart';
|
||||||
|
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
||||||
|
import 'package:hmg_patient_app_new/theme/colors.dart';
|
||||||
|
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
|
||||||
|
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
|
||||||
|
import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart';
|
||||||
|
import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import 'covid_19_questionnaire.dart';
|
||||||
|
|
||||||
|
class Covid19LandingPage extends StatefulWidget {
|
||||||
|
const Covid19LandingPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<Covid19LandingPage> createState() => _Covid19LandingPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Covid19LandingPageState extends State<Covid19LandingPage> {
|
||||||
|
|
||||||
|
late HabibWalletViewModel habibWalletVM;
|
||||||
|
int? _selectedBranchIndex;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
habibWalletVM = Provider.of<HabibWalletViewModel>(context, listen: false);
|
||||||
|
scheduleMicrotask(() {
|
||||||
|
getProjectList();
|
||||||
|
});
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppColors.bgScaffoldColor,
|
||||||
|
body: Column(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: CollapsingListView(
|
||||||
|
title: "COVID-19",
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.all(24.w),
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Container(
|
||||||
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||||||
|
color: AppColors.whiteColor,
|
||||||
|
borderRadius: 24.r,
|
||||||
|
hasShadow: false,
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.all(20.h),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
"Get the results in Few Hours"
|
||||||
|
.toText18(
|
||||||
|
color: AppColors.textColor,
|
||||||
|
weight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
SizedBox(height: 16.h),
|
||||||
|
LocaleKeys.covid_info
|
||||||
|
.tr()
|
||||||
|
.toText14(
|
||||||
|
color: AppColors.greyTextColor,
|
||||||
|
weight: FontWeight.w400,
|
||||||
|
height: 1.6,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||||||
|
color: AppColors.whiteColor,
|
||||||
|
// borderRadius: 24.r,
|
||||||
|
hasShadow: true,
|
||||||
|
customBorder: BorderRadius.only(topLeft:Radius.circular(24.r) , topRight:Radius.circular(24.r))
|
||||||
|
),
|
||||||
|
child: SizedBox(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
CustomButton(
|
||||||
|
text: "SelectLocation".needTranslation,
|
||||||
|
onPressed: () {
|
||||||
|
_showBranchBottomSheet(context);
|
||||||
|
},
|
||||||
|
backgroundColor: AppColors.primaryRedColor,
|
||||||
|
borderColor: AppColors.primaryRedColor,
|
||||||
|
textColor: AppColors.whiteColor,
|
||||||
|
fontSize: 16.f,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
borderRadius: 12.r,
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 10.w),
|
||||||
|
height: 50.h,
|
||||||
|
iconSize: 18.h,
|
||||||
|
).paddingSymmetrical(16.h, 24.w),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
void _showBranchBottomSheet(BuildContext context, ) {
|
||||||
|
// Set first branch as selected by default
|
||||||
|
setState(() {
|
||||||
|
_selectedBranchIndex = 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
showCommonBottomSheet(
|
||||||
|
|
||||||
|
context,
|
||||||
|
title: "Select Branch".needTranslation,
|
||||||
|
height: ResponsiveExtension.screenHeight * 0.651,
|
||||||
|
child: StatefulBuilder(
|
||||||
|
builder: (context, setBottomSheetState) {
|
||||||
|
return Consumer<HabibWalletViewModel>(
|
||||||
|
builder: (context, habibWalletVM, child) {
|
||||||
|
|
||||||
|
final hospitals = habibWalletVM.advancePaymentHospitals;
|
||||||
|
if (hospitals.isEmpty) {
|
||||||
|
return const Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.all(16.0),
|
||||||
|
child: Text('No branches available'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child:Container(
|
||||||
|
margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 12.h, bottom: 24.h),
|
||||||
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||||||
|
color: AppColors.whiteColor,
|
||||||
|
hasShadow: true,
|
||||||
|
customBorder: BorderRadius.only(
|
||||||
|
topLeft: Radius.circular(24.r),
|
||||||
|
topRight: Radius.circular(24.r),
|
||||||
|
),
|
||||||
|
), child: ListView.separated(
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const BouncingScrollPhysics(),
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final branch = hospitals[index];
|
||||||
|
final isSelected = _selectedBranchIndex == index;
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
setBottomSheetState(() {
|
||||||
|
_selectedBranchIndex = index;
|
||||||
|
});
|
||||||
|
setState(() {
|
||||||
|
_selectedBranchIndex = index;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 16.h),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
// Radio button
|
||||||
|
Container(
|
||||||
|
width: 20.w,
|
||||||
|
height: 20.h,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
border: Border.all(
|
||||||
|
color: isSelected
|
||||||
|
? AppColors.primaryRedColor
|
||||||
|
: AppColors.greyTextColor.withValues(alpha: 0.3),
|
||||||
|
width: 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: isSelected
|
||||||
|
? Center(
|
||||||
|
child: Container(
|
||||||
|
width: 10.w,
|
||||||
|
height: 10.h,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: AppColors.primaryRedColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
SizedBox(width: 12.w),
|
||||||
|
// Branch details
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
|
||||||
|
SizedBox(height: 4.h),
|
||||||
|
(branch.desciption ?? 'Unknown').toText14(
|
||||||
|
color: AppColors.textColor,
|
||||||
|
weight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Location icon
|
||||||
|
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
separatorBuilder: (context, index) => SizedBox(height: 12.h),
|
||||||
|
itemCount: hospitals.length,
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
// Next button
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 16.h),
|
||||||
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||||||
|
color: AppColors.whiteColor,
|
||||||
|
hasShadow: true,
|
||||||
|
customBorder: BorderRadius.only(
|
||||||
|
topLeft: Radius.circular(24.r),
|
||||||
|
topRight: Radius.circular(24.r),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: SafeArea(
|
||||||
|
top: false,
|
||||||
|
child: CustomButton(
|
||||||
|
text: "Next".needTranslation,
|
||||||
|
onPressed: (){
|
||||||
|
|
||||||
|
Navigator.of(context)
|
||||||
|
.push(
|
||||||
|
CustomPageRoute(
|
||||||
|
page: Covid19Questionnaire(selectedHospital: hospitals[_selectedBranchIndex!],),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
},
|
||||||
|
backgroundColor: _selectedBranchIndex != null
|
||||||
|
? AppColors.primaryRedColor
|
||||||
|
: AppColors.greyTextColor.withValues(alpha: 0.3),
|
||||||
|
borderColor: _selectedBranchIndex != null
|
||||||
|
? AppColors.primaryRedColor
|
||||||
|
: AppColors.greyTextColor.withValues(alpha: 0.3),
|
||||||
|
textColor: AppColors.whiteColor,
|
||||||
|
fontSize: 16.f,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
borderRadius: 12.r,
|
||||||
|
height: 56.h,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
getProjectList() async{
|
||||||
|
await habibWalletVM.getProjectsList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,132 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
|
||||||
|
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
||||||
|
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
||||||
|
import 'package:hmg_patient_app_new/features/hmg_services/hmg_services_view_model.dart';
|
||||||
|
import 'package:hmg_patient_app_new/features/hmg_services/models/ui_models/covid_questionnare_model.dart';
|
||||||
|
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/hospital_model.dart';
|
||||||
|
import 'package:hmg_patient_app_new/theme/colors.dart';
|
||||||
|
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
|
||||||
|
import 'package:hmg_patient_app_new/widgets/CustomSwitch.dart';
|
||||||
|
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
|
||||||
|
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class Covid19Questionnaire extends StatefulWidget {
|
||||||
|
final HospitalsModel selectedHospital;
|
||||||
|
const Covid19Questionnaire({super.key, required this.selectedHospital});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<Covid19Questionnaire> createState() => _Covid19QuestionnaireState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Covid19QuestionnaireState extends State<Covid19Questionnaire> {
|
||||||
|
late HmgServicesViewModel hmgServicesViewModel;
|
||||||
|
List<CovidQuestionnaireModel> qaList = [];
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
hmgServicesViewModel = Provider.of<HmgServicesViewModel>(context, listen: false);
|
||||||
|
scheduleMicrotask(() {
|
||||||
|
setState(() {
|
||||||
|
qaList = hmgServicesViewModel.getQuestionsFromJson();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _toggleAnswer(int index, bool value) {
|
||||||
|
setState(() {
|
||||||
|
qaList[index].ans = value ? 1 : 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppColors.bgScaffoldColor,
|
||||||
|
body: Column(children: [
|
||||||
|
Expanded(
|
||||||
|
child: CollapsingListView(
|
||||||
|
title: "COVID-19",
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.all(24.w),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Container(
|
||||||
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||||||
|
color: AppColors.whiteColor,
|
||||||
|
borderRadius: 24.r,
|
||||||
|
hasShadow: false,
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.all(20.h),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
"Please answer below questionnaire:".toText14(
|
||||||
|
color: AppColors.textColor,
|
||||||
|
weight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
SizedBox(height: 20.h),
|
||||||
|
// Question list
|
||||||
|
ListView.separated(
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
itemCount: qaList.length,
|
||||||
|
separatorBuilder: (context, index) => SizedBox(height: 16.h),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final question = qaList[index];
|
||||||
|
final isAnswerYes = question.ans == 1;
|
||||||
|
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: (question.questionEn ?? '').toText14(
|
||||||
|
color: AppColors.textColor,
|
||||||
|
weight: FontWeight.w400,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(width: 12.w),
|
||||||
|
CustomSwitch(
|
||||||
|
value: isAnswerYes,
|
||||||
|
onChanged: (value) => _toggleAnswer(index, value),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 16.h),
|
||||||
|
// Next button
|
||||||
|
CustomButton(
|
||||||
|
text: "Next".needTranslation,
|
||||||
|
onPressed: () {
|
||||||
|
// Handle next action
|
||||||
|
},
|
||||||
|
backgroundColor: AppColors.primaryRedColor,
|
||||||
|
borderColor: AppColors.primaryRedColor,
|
||||||
|
textColor: AppColors.whiteColor,
|
||||||
|
fontSize: 16.f,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
borderRadius: 12.r,
|
||||||
|
height: 56.h,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue