123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- import 'package:fis_measure/interfaces/enums/annotation.dart';
- import 'package:fis_measure/interfaces/process/workspace/application.dart';
- import 'package:fis_measure/interfaces/process/workspace/mobile_measure_view_state_controller.dart';
- import 'package:fis_measure/process/workspace/measure_handler.dart';
- import 'package:fis_measure/view/mobile_view/controller/mobile_measure_view_state_controller.dart';
- import 'package:fis_measure/view/mobile_view/widgets/animated_icon_btn.dart';
- import 'package:fis_measure/view/mobile_view/widgets/icon_btn.dart';
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- class MobileTopMenu extends StatefulWidget {
- final VoidCallback capturePng;
- const MobileTopMenu({
- Key? key,
- required this.capturePng,
- }) : super(key: key);
- @override
- State<StatefulWidget> createState() => _MobileTopMenuState();
- }
- class _MobileTopMenuState extends State<MobileTopMenu> {
- final application = Get.find<IApplication>();
- final measureHandler = Get.find<MeasureHandler>();
- final mobileMeasureStateController =
- Get.find<MobileMeasureViewStateController>();
- @override
- void initState() {
- mobileMeasureStateController.onModeChanged.addListener(_onViewModeChanged);
- super.initState();
- }
- @override
- void dispose() {
- mobileMeasureStateController.onModeChanged
- .removeListener(_onViewModeChanged);
- super.dispose();
- }
- MobileMeasureMode curMode = MobileMeasureMode.playerMode;
- void _onViewModeChanged(Object s, MobileMeasureMode mode) {
- setState(() {
- curMode = mode;
- });
- }
- @override
- Widget build(BuildContext context) {
- return Column(
- mainAxisSize: MainAxisSize.max,
- mainAxisAlignment: MainAxisAlignment.start,
- children: [
- SizedBox(
- height: 50,
- child: Container(
- padding: const EdgeInsets.only(left: 10),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.start,
- children: [
- ..._buttons(),
- ],
- ),
- ),
- ),
- ],
- );
- }
- List<Widget> _buttons() {
- switch (curMode) {
- case MobileMeasureMode.playerMode:
- return [
- _fillCustomSpace(10),
- _backBtn(),
- _fillEmptySpace(),
- _saveBtn(),
- _editBtn(),
- _shareBtn(),
- _fillCustomSpace(150)
- ];
- case MobileMeasureMode.measureMode:
- return [
- _exitBtn(),
- const Text('测量模式'),
- _fillEmptySpace(),
- _saveBtn(),
- _deleteBtn(),
- _undoBtn(),
- ];
- case MobileMeasureMode.annotationMode:
- return [
- _exitBtn(),
- const Text('注释模式'),
- _fillEmptySpace(),
- _annotationBtn(),
- _arrowBtn(),
- _saveBtn(),
- _deleteBtn(),
- _undoBtn(),
- ];
- default:
- return [Container()];
- }
- }
- Widget _saveBtn() {
- return LoadingAnimatedIconButton(
- icon: Icons.save,
- onPressed: () {
- widget.capturePng();
- },
- );
- }
- Widget _shareBtn() {
- return SingleIconButton(
- icon: Icons.share,
- onPressed: () {
- print("call 分享");
- },
- );
- }
- Widget _editBtn() {
- return SingleIconButton(
- icon: Icons.edit,
- onPressed: () {
- print("call 进入撰写报告");
- },
- );
- }
- Widget _backBtn() {
- return SingleIconButton(
- icon: Icons.arrow_back_ios_new,
- onPressed: () {
- print("call 返回");
- },
- );
- }
- Widget _exitBtn() {
- return SingleIconButton(
- icon: Icons.exit_to_app,
- onPressed: () {
- print("call 退出当前模式");
- mobileMeasureStateController.currentMode = MobileMeasureMode.playerMode;
- },
- );
- }
- Widget _annotationBtn() {
- return SingleIconButton(
- icon: Icons.abc,
- onPressed: () {
- print("call 注释模式");
- },
- );
- }
- Widget _arrowBtn() {
- // bool get isArrowMeasureAnnotationType =>
- // measureHandler.changedAnnotationType == AnnotationType.arrow;
- // TODO 原本是用于判断当前是否为箭头模式
- return SingleIconButton(
- icon: Icons.compare_arrows_rounded,
- onPressed: () {
- print("call 箭头模式");
- measureHandler.changedAnnotationType =
- AnnotationType.arrow; // TODO 原本是用于判断当前是否为箭头模式
- application.switchAnnotation(AnnotationType.arrow);
- },
- );
- }
- Widget _deleteBtn() {
- return SingleIconButton(
- icon: Icons.delete_outline,
- onPressed: () {
- application.clearRecords();
- },
- );
- }
- Widget _undoBtn() {
- return SingleIconButton(
- icon: Icons.redo,
- onPressed: () {
- application.undoRecord();
- },
- );
- }
- Widget _fillEmptySpace() {
- return Expanded(
- child: SizedBox(
- height: 1,
- width: MediaQuery.of(context).size.width,
- ),
- );
- }
- Widget _fillCustomSpace(double width) {
- return SizedBox(
- width: width,
- );
- }
- }
|