123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- import 'dart:async';
- import 'package:fis_i18n/i18n.dart';
- import 'package:fis_jsonrpc/rpc.dart';
- import 'package:fis_measure/interfaces/process/standard_line/calibration.dart';
- import 'package:fis_measure/interfaces/process/workspace/application.dart';
- import 'package:fis_measure/process/workspace/measure_data_controller.dart';
- import 'package:fis_measure/process/workspace/measure_handler.dart';
- import 'package:fis_measure/utils/prompt_box.dart';
- import 'package:fis_measure/view/button_group/widget/qr_code_with_logo.dart';
- import 'package:fis_measure/view/paint/ai_patint_controller.dart';
- import 'package:fis_ui/index.dart';
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'package:url_launcher/url_launcher.dart';
- class ButtonGroup extends StatefulWidget {
- final VoidCallback capturePng;
- const ButtonGroup({
- Key? key,
- required this.capturePng,
- }) : super(key: key);
- @override
- State<ButtonGroup> createState() => _ButtonGroupState();
- }
- class _ButtonGroupState extends State<ButtonGroup> {
- double _width = 0;
- bool _isExpanded = false;
- final _key = GlobalKey();
- final application = Get.find<IApplication>();
- /// 数据
- final measureData = Get.find<MeasureDataController>();
- late final measureHandler = Get.find<MeasureHandler>();
- late final aiPatintController = Get.find<AiPatintController>();
- late bool canShowAI = [
- DiagnosisConclusionEnum.Benign,
- DiagnosisConclusionEnum.Malignant,
- DiagnosisConclusionEnum.BenignAndMalignant
- ].contains(measureData.diagnosisConclusion);
- List<Widget> buildTitleButtonList() {
- return [
- _buildTitleButton(
- FIcons.fis_quash,
- i18nBook.common.revoke.t,
- () => application.undoRecord(),
- ),
- _buildTitleButton(
- FIcons.fis_purge,
- i18nBook.measure.clear.t,
- () => application.clearRecords(),
- ),
- _buildTitleButton(
- measureHandler.fullScreenState
- ? FIcons.fis_full_screen_reduction
- : FIcons.fis_full_screen,
- measureHandler.fullScreenState
- ? i18nBook.common.cancel.t + i18nBook.measure.fullScreen.t
- : i18nBook.measure.fullScreen.t,
- () {
- measureHandler.fullScreenState = !measureHandler.fullScreenState;
- setState(() {});
- },
- ),
- _buildTitleButton(
- FIcons.fis_save,
- i18nBook.common.save.t,
- widget.capturePng,
- ),
- _buildTitleButton(
- FIcons.fis_share,
- i18nBook.remedical.share.t,
- () async {
- var itemCurrentImage = await measureData.shareImage.call(
- measureData.itemCurrentImage,
- );
- Get.dialog(_buildShareQr(itemCurrentImage));
- },
- ),
- if (application.isThirdPart) ...[
- _buildTitleButton(
- FIcons.device,
- i18nBook.remedical.calibrationLine.t,
- () {
- Get.find<IStandardLineCalibrationController>().enterEditMode();
- },
- ),
- ],
- if (canShowAI) ...[
- _buildTitleButton(
- !aiPatintController.state.isShowAi
- ? FIcons.fis_eye_display
- : FIcons.fis_eye_hidden,
- !aiPatintController.state.isShowAi
- ? i18nBook.measure.showAi.t
- : i18nBook.measure.hideAi.t,
- () {
- aiPatintController.state.isShowAi =
- !aiPatintController.state.isShowAi;
- setState(() {});
- },
- ),
- ]
- ];
- }
- @override
- Widget build(BuildContext context) {
- return Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: [
- InkWell(
- onTap: () {},
- onHover: (isHover) {
- if (!isHover) {
- setState(() {
- _width = 0;
- _isExpanded = isHover;
- });
- } else {
- setState(() {
- // application.isThirdPart ? _width = 270 : _width = 220;
- _width = buildTitleButtonList().length * 48;
- _isExpanded = isHover;
- });
- }
- },
- child: AnimatedContainer(
- duration: const Duration(milliseconds: 300),
- padding: const EdgeInsets.only(
- top: 5,
- bottom: 5,
- left: 15,
- ),
- decoration: BoxDecoration(
- borderRadius: const BorderRadius.only(
- topLeft: Radius.circular(4),
- bottomLeft: Radius.circular(4),
- ),
- color: Colors.grey.withOpacity(0.6),
- ),
- width: _width,
- height: 60,
- child: _isExpanded
- ? FutureBuilder(
- future: _showList(),
- builder: (context, snapshot) {
- if (!snapshot.hasData) {
- return const SizedBox();
- }
- return Row(
- children: buildTitleButtonList(),
- );
- },
- )
- : const SizedBox(),
- ),
- ),
- InkWell(
- onTap: () {},
- onHover: (isHover) {
- if (isHover) {
- setState(() {
- _width = buildTitleButtonList().length * 48;
- _isExpanded = isHover;
- });
- } else {
- setState(() {
- _width = 0;
- _isExpanded = isHover;
- });
- }
- },
- child: Container(
- height: 60,
- color: Colors.white,
- child: !_isExpanded
- ? const Icon(Icons.chevron_left_rounded)
- : const Icon(Icons.chevron_right_rounded),
- ),
- ),
- ],
- );
- }
- FWidget _buildShareQr(String itemCurrentImage) {
- return FSimpleDialog(
- title: FText(
- i18nBook.remedical.share.t,
- style: const TextStyle(
- color: Colors.white,
- fontSize: 18,
- ),
- ),
- isDefault: false,
- children: [
- FContainer(
- width: 360,
- child: FContainer(
- padding: const EdgeInsets.only(top: 20, bottom: 20),
- child: QRCodeWithLogo(
- itemCurrentImage,
- codeStatement: i18nBook.remedical.scanQrCodeToShareImage.t,
- operationStatement: i18nBook.remedical.copyLink.t,
- operationSuccessCallback: () =>
- {PromptBox.toast(i18nBook.remedical.copySuccess.t)},
- ),
- ),
- ),
- ],
- );
- }
- //定义方法
- void _launchURL(url) async {
- if (await canLaunch(url)) {
- await launch(url);
- } else {
- throw 'Could not launch $url';
- }
- }
- //跳转
- Future<bool> _showList() async {
- await Future.delayed(const Duration(milliseconds: 300));
- return true;
- }
- Widget _buildTitleButton(IconData icon, String title, Function onClick) {
- return Container(
- margin: const EdgeInsets.only(
- right: 10,
- ),
- child: InkWell(
- onTap: () => onClick.call(),
- child: Column(
- children: [
- Icon(
- icon,
- color: Colors.white,
- ),
- Text(
- title,
- style: const TextStyle(
- color: Colors.white,
- fontSize: 14,
- ),
- )
- ],
- ),
- ),
- );
- }
- }
|