123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- import 'package:fis_common/event/event_type.dart';
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'package:vitalapp/pages/check/examination/controller.dart';
- import 'package:vitalapp/pages/check/models/form.dart';
- // import 'package:vitalapp/pages/check/widgets/configurable_card.dart';
- import 'package:vitalapp/pages/check/widgets/new_configurable_card.dart';
- class ExaminationPage extends StatefulWidget {
- const ExaminationPage({
- Key? key,
- required this.idCard,
- required this.onSubmitEvent,
- required this.physicalExamNumber,
- this.examData,
- }) : super(key: key);
- final FEventHandler<bool> onSubmitEvent;
- final String idCard;
- final String physicalExamNumber;
- final String? examData;
- @override
- State<ExaminationPage> createState() => _ExaminationPageState();
- }
- class _ExaminationPageState extends State<ExaminationPage> {
- final controller = Get.find<ExaminationController>();
- String _cardKey = "ZZYBZK";
- FEventHandler<bool> onChangeCurrentKeyEvent = FEventHandler<bool>();
- @override
- void initState() {
- onChangeCurrentKeyEvent.addListener(changeCurrentKeyEvent);
- super.initState();
- }
- @override
- void dispose() {
- onChangeCurrentKeyEvent.removeListener(changeCurrentKeyEvent);
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- backgroundColor: const Color.fromRGBO(238, 238, 238, 1),
- body: DefaultTextStyle(
- style: TextStyle(
- fontFamily: "NotoSansSC",
- fontFamilyFallback: const ["NotoSansSC"],
- fontSize: 20.0,
- color: Colors.black,
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Stack(
- children: [
- _buildExamList(),
- ],
- ),
- Expanded(
- child: NewConfigurableCard(
- key: UniqueKey(),
- onSubmitEvent: widget.onSubmitEvent,
- onChangeCurrentKeyEvent: onChangeCurrentKeyEvent,
- cardKey: _cardKey,
- callBack: (key, templateCode, data, isMuanual) async {
- await controller.createOrUpdateExam(
- key,
- templateCode,
- data,
- isMuanual,
- );
- return true;
- },
- patientCode: widget.idCard,
- physicalExamNumber: widget.physicalExamNumber,
- ),
- ),
- ],
- ),
- ));
- }
- Widget _buildExamList() {
- return Container(
- margin: EdgeInsets.symmetric(horizontal: 16, vertical: 16),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: controller.menuList
- .map(
- (e) => InkWell(
- onTap: () {
- widget.onSubmitEvent.emit(this, false);
- _cardKey = e.value;
- setState(() {});
- },
- child: Container(
- margin: EdgeInsets.all(8),
- padding: EdgeInsets.all(8),
- width: 200,
- decoration: BoxDecoration(
- color: _cardKey == e.value ? Colors.blue : Colors.white,
- borderRadius: BorderRadius.all(
- Radius.circular(8),
- ),
- ),
- child: Text(
- e.label,
- style: TextStyle(
- fontSize: 20,
- color: _cardKey == e.value ? Colors.white : Colors.black,
- ),
- ),
- ),
- ),
- )
- .toList(),
- ),
- );
- }
- void changeCurrentKeyEvent(sender, e) {
- if (e) {
- MenuItem? currentKey = controller.menuList
- .firstWhereOrNull((element) => element.value == _cardKey);
- if (currentKey != null) {
- int currentIndex = controller.menuList.indexOf(currentKey);
- if (currentIndex < controller.menuList.length - 1) {
- widget.onSubmitEvent.emit(this, false);
- _cardKey = controller.menuList[currentIndex + 1].value;
- setState(() {});
- }
- }
- }
- }
- }
|