123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:get/get.dart';
- import 'package:vitalapp/components/button.dart';
- import 'package:vitalapp/pages/medical/views/table_input_dialog/widgets/table_element_row.dart';
- import 'package:vitalapp/pages/medical/views/table_input_dialog/widgets/table_title.dart';
- import 'index.dart';
- class TableInputDialog extends GetView<TableInputDialogController> {
- TableInputDialog(
- {Key? key,
- required this.tableDataConfig,
- required this.title,
- this.physicalExamNumber,
- this.keyValue})
- : super(key: key);
-
- final List<TableElementConfig> tableDataConfig;
-
- final String title;
- String? physicalExamNumber;
- String? keyValue;
-
- Widget _buildView() {
- const designWidth = 1280.0;
- final width = Get.width;
- final scale = width / designWidth;
- return Container(
- width: Get.width * 0.9 / scale,
- height: 240 * 3,
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(10),
- ),
- clipBehavior: Clip.antiAlias,
- child: Column(
- children: [
- _buildHead(),
- _buildTableTitle(),
- Expanded(
- child: _buildBody(),
- ),
- _buildBottom(),
- ],
- ),
- );
- }
- @override
- Widget build(BuildContext context) {
- return GetBuilder<TableInputDialogController>(
- init: TableInputDialogController(tableDataConfig: tableDataConfig),
- builder: (context) {
- return Dialog(
- child: _buildView(),
- );
- },
- );
- }
-
- Widget _buildHead() {
- return SizedBox(
- height: 40,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 15),
- child: Text(
- title,
- style: const TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 10),
- child: IconButton(
- onPressed: () => Get.back(),
- icon: const Icon(
- Icons.close,
- size: 30,
- ),
- ),
- ),
- ],
- ),
- );
- }
- Widget _buildTableTitle() {
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 10),
- child: TableTitle(),
- );
- }
- Widget _buildBody() {
- final ScrollController scrollController = ScrollController();
- return RawKeyboardListener(
- focusNode: FocusNode(),
- onKey: (RawKeyEvent value) {
- if (value is RawKeyDownEvent) {
- if (value.logicalKey == LogicalKeyboardKey.arrowUp) {
- controller.focusPre();
- } else if (value.logicalKey == LogicalKeyboardKey.arrowDown ||
- value.logicalKey == LogicalKeyboardKey.enter) {
- controller.focusNext();
- }
- }
- },
- child: Scrollbar(
- thumbVisibility: true,
- thickness: 10,
- radius: const Radius.circular(10),
- controller: scrollController,
- child: SingleChildScrollView(
- controller: scrollController,
- padding: const EdgeInsets.only(left: 10, right: 10, bottom: 10),
- physics: const BouncingScrollPhysics(),
- child: Column(
- children: [
- for (var item in controller.tableData)
- TableElementRow(
- elementName: item.config.name,
- unit: item.config.unit,
- textController: item.textController,
- focusNode: item.focusNode,
- ),
- ],
- ),
- ),
- ),
- );
- }
- Widget _buildBottom() {
- return Container(
- height: 50,
- padding: EdgeInsets.symmetric(vertical: 5),
- color: Colors.grey[200],
- child: Row(
-
- children: [
- Expanded(
- child: Container(),
- ),
- VButton(
- onTap: () {
- controller.onConfirm(physicalExamNumber, keyValue);
- },
- child: const Text('提交'),
- ),
- Expanded(
- child: Align(
- alignment: Alignment.centerRight,
- child: Padding(
- padding: const EdgeInsets.only(right: 20),
- child: Text(
- "Enter 或 ⬆ ⬇ 键可切换项目",
- style: TextStyle(
- color: Colors.black38,
- fontSize: 10,
- ),
- ),
- ),
- ),
- ),
- ],
- ),
- );
- }
- }
|