123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- 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_handler.dart';
- import 'package:fis_ui/index.dart';
- import 'package:flutter/material.dart';
- import 'package:get/get.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>();
- late final measureHandler = Get.find<MeasureHandler>();
- Future<bool> _showList() async {
- await Future.delayed(const Duration(milliseconds: 300));
- return true;
- }
- /// TODO 翻译
- @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;
- _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: [
- _buildTitleButton(FIcons.fis_quash, '撤销',
- () => application.undoRecord()),
- _buildTitleButton(FIcons.fis_purge, '清除',
- () => application.clearRecords()),
- _buildTitleButton(FIcons.fis_full_screen, '全屏', () {
- measureHandler.fullScreenState =
- !measureHandler.fullScreenState;
- }),
- _buildTitleButton(
- FIcons.fis_save, '保存', widget.capturePng),
- _buildTitleButton(
- FIcons.fis_share,
- '分享',
- () {
- print('分享');
- },
- ),
- application.isThirdPart
- ? _buildTitleButton(
- FIcons.device,
- '校准线',
- () {
- Get.find<
- IStandardLineCalibrationController>()
- .enterEditMode();
- },
- )
- : const SizedBox(),
- ],
- );
- })
- : const SizedBox(),
- ),
- ),
- InkWell(
- onTap: () {},
- onHover: (isHover) {
- if (isHover) {
- setState(() {
- application.isThirdPart ? _width = 270 : _width = 220;
- _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),
- ),
- ),
- ],
- );
- }
- 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,
- ),
- )
- ],
- ),
- ),
- );
- }
- }
|