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.
PatientApp-KKUMC/lib/pages/ErService/EdOnline/EdOnlineQuestionsPage.dart

128 lines
5.0 KiB
Dart

import 'package:diplomaticquarterapp/core/model/er/TriageQuestionsModel.dart';
import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/er/EdOnlineViewModel.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// ignore: must_be_immutable
class EdOnlineQuestionsPage extends StatefulWidget {
final HospitalsModel selectedHospital;
final Function changePageViewIndex;
List<TriageQuestionsModel> selectedQuestions;
EdOnlineQuestionsPage({Key key, this.selectedHospital,this.selectedQuestions, this.changePageViewIndex});
@override
_EdOnlineQuestionsPageState createState() => _EdOnlineQuestionsPageState();
}
class _EdOnlineQuestionsPageState extends State<EdOnlineQuestionsPage> {
@override
Widget build(BuildContext context) {
return BaseView<EdOnlineViewModel>(
onModelReady: (model) => model.getQuestions(),
builder: (_, model, w) => AppScaffold(
baseViewModel: model,
body: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Column(
children: [
...List.generate(
model.triageQuestionsModelList.length,
(index) =>
InkWell(
onTap: (){
setState(() {
if (widget.selectedQuestions
.contains(model.triageQuestionsModelList[index])) {
widget.selectedQuestions
.remove(model.triageQuestionsModelList[index]);
} else {
widget.selectedQuestions
.add(model.triageQuestionsModelList[index]);
}
});
},
child: Row(
children: [
Checkbox(
value: widget.selectedQuestions.contains(model.triageQuestionsModelList[index]),
activeColor: Colors.red[800],
onChanged: (bool newValue) {
setState(() {
if (widget.selectedQuestions
.contains(model.triageQuestionsModelList[index])) {
widget.selectedQuestions
.remove(model.triageQuestionsModelList[index]);
} else {
widget.selectedQuestions
.add(model.triageQuestionsModelList[index]);
}
});
}),
Expanded(
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Texts(
model.triageQuestionsModelList[index].question,
fontSize: 15,
),
),
),
],
),
),
),
SizedBox(height: 80,)
],
),
),
bottomSheet: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 56,
child: Row(
children: [
Expanded(
child: Container(
margin: EdgeInsets.only(left: 5,right: 5),
child: SecondaryButton(
textColor: Colors.white,
color: Theme.of(context).primaryColor,
label: TranslationBase.of(context).back.toUpperCase(),
onTap: () => widget.changePageViewIndex(1),
),
),
),
SizedBox(width: 10,),
Expanded(
child: Container(
margin: EdgeInsets.only(left: 5,right: 5),
child: SecondaryButton(
textColor: Colors.white,
color: Theme.of(context).primaryColor,
label: TranslationBase.of(context).next.toUpperCase(),
disabled: widget.selectedQuestions.isEmpty,
onTap: () => widget.changePageViewIndex(3),
),
),
),
],
),
),
),
),
);
}
}