You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
133 lines
5.8 KiB
Dart
133 lines
5.8 KiB
Dart
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,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
]));
|
|
}
|
|
}
|