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.
197 lines
8.6 KiB
Dart
197 lines
8.6 KiB
Dart
import 'package:diplomaticquarterapp/core/enum/viewstate.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/theme/colors.dart';
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
|
import 'package:diplomaticquarterapp/widgets/buttons/custom_text_button.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: Container(
|
|
margin: EdgeInsets.only(bottom: 10.0),
|
|
child: Row(
|
|
children: [
|
|
Checkbox(
|
|
value: widget.selectedQuestions.contains(model.triageQuestionsModelList[index]),
|
|
activeColor: Color(0xffD02127),
|
|
tristate: false,
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
onChanged: (bool newValue) {
|
|
setState(() {
|
|
if (widget.selectedQuestions.contains(model.triageQuestionsModelList[index])) {
|
|
widget.selectedQuestions.remove(model.triageQuestionsModelList[index]);
|
|
} else {
|
|
widget.selectedQuestions.add(model.triageQuestionsModelList[index]);
|
|
}
|
|
});
|
|
}),
|
|
SizedBox(width: 6),
|
|
Expanded(
|
|
child: Text(
|
|
model.triageQuestionsModelList[index].question,
|
|
overflow: TextOverflow.clip,
|
|
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 120,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
bottomSheet: Container(
|
|
color: CustomColors.appBackgroudGreyColor,
|
|
child: Container(
|
|
color: CustomColors.appBackgroudGreyColor,
|
|
margin: EdgeInsets.all(14),
|
|
height: 45.0,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: <Widget>[
|
|
Expanded(
|
|
flex: 1,
|
|
child: ButtonTheme(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(10.0),
|
|
),
|
|
height: 45.0,
|
|
child: CustomTextButton(
|
|
backgroundColor: Color(0xffc5272d),
|
|
disabledForegroundColor: Color(0xFFbcc2c4).withOpacity(0.38),
|
|
disabledBackgroundColor: Color(0xFFbcc2c4).withOpacity(0.12),
|
|
elevation: 0,
|
|
onPressed: () {
|
|
widget.changePageViewIndex(0);
|
|
},
|
|
child: Text(TranslationBase.of(context).back, style: TextStyle(fontSize: 16.0, color: Colors.white)),
|
|
),
|
|
),
|
|
),
|
|
mWidth(7),
|
|
Expanded(
|
|
flex: 1,
|
|
child: ButtonTheme(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(10.0),
|
|
),
|
|
height: 45.0,
|
|
child: CustomTextButton(
|
|
backgroundColor: CustomColors.green,
|
|
disabledForegroundColor: Color(0xFFbcc2c4).withOpacity(0.38),
|
|
disabledBackgroundColor: Color(0xFFbcc2c4).withOpacity(0.12),
|
|
elevation: 0,
|
|
onPressed: widget.selectedQuestions.isEmpty
|
|
? null
|
|
: () {
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
model
|
|
.saveQuestionsInformation(
|
|
chiefComplaint: "", notes: "", selectedQuestions: widget.selectedQuestions, projectId: widget.selectedHospital.iD, selectedTime: DateTime.now())
|
|
.then((value) {
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
if (model.state == ViewState.ErrorLocal)
|
|
AppToast.showErrorToast(message: model.error);
|
|
else {
|
|
widget.changePageViewIndex(4);
|
|
}
|
|
}).catchError((onError) {
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
AppToast.showErrorToast(message: onError.toString());
|
|
});
|
|
// widget.changePageViewIndex(4);
|
|
},
|
|
child: Text(TranslationBase.of(context).next, style: TextStyle(fontSize: 16.0, color: Colors.white)),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
// 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),
|
|
// ),
|
|
// ),
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// ),
|
|
// ),
|
|
),
|
|
);
|
|
}
|
|
}
|