123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- import 'package:fis_i18n/i18n.dart';
- import 'package:fis_measure/interfaces/enums/operate.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_data_helper.dart';
- import 'package:fis_measure/process/workspace/measure_handler.dart';
- import 'package:fis_measure/utils/prompt_box.dart';
- import 'package:fis_ui/index.dart';
- import 'package:fis_ui/interface/interactive_container.dart';
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- class LeftSelectInput extends FStatefulWidget implements FInteractiveContainer {
- @override
- final String pageName = 'LeftSelectInput';
- final bool? isLab;
- const LeftSelectInput({
- super.key,
- this.isLab = false,
- });
- @override
- FState<LeftSelectInput> createState() => _LeftSelectInputState();
- }
- class _LeftSelectInputState extends FState<LeftSelectInput> {
- late final application = Get.find<IApplication>();
- /// 数据
- late final measureData = Get.find<MeasureDataController>();
- late final measureHandler = Get.find<MeasureHandler>();
- String annotationItem = '';
- /// 按钮颜色
- static const buttonColor = Color(0xFF11234F);
- /// 添加操作后更新注释
- void getAnnotationList() async {
- List<String> annotationList = [];
- var measureCommentItemResult =
- await MeasureDataHelper.getCommentsByApplicationAsync(
- application.applicationName,
- application.categoryName,
- );
- measureData.measureCommentItemResult =
- measureCommentItemResult?.commentItems ?? [];
- measureCommentItemResult?.commentItems?.forEach((element) {
- annotationList.add(element.text ?? '');
- });
- measureData.annotationList = annotationList;
- }
- /// 添加操作后更新注释
- void resetUserCommentsAsync() async {
- var resetUserCommentsResult =
- await MeasureDataHelper.resetUserCommentsAsync(
- application.applicationName,
- application.categoryName,
- );
- if (resetUserCommentsResult ?? false) {
- PromptBox.toast(i18nBook.auth.toast4ResetSuccess.t);
- getAnnotationList();
- }
- }
- @override
- FWidget build(BuildContext context) {
- return FContainer(
- padding: const EdgeInsets.only(
- left: 15,
- right: 15,
- bottom: 5,
- ),
- child: FRow(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- FBorderInput(
- height: 38,
- hintSize: 16,
- contentSize: 16,
- maxLength: 20,
- fillColor: widget.isLab! ? const Color(0xFF1b1d23) : Colors.white,
- textStyle: TextStyle(
- color: widget.isLab! ? Colors.white : const Color(0xff2c77e5),
- ),
- borderColor: widget.isLab!
- ? const Color(0xFF8f98b2)
- : const Color.fromARGB(255, 187, 180, 180),
- suffixIcon: FMaterial(
- color: Colors.transparent,
- child: FIconButton(
- name: "pleaseAddCcomment",
- onPressed: () async {
- //判断添加的注释不为空
- if (annotationItem.isEmpty ||
- annotationItem.replaceAll(" ", "").isEmpty) {
- PromptBox.toast(i18nBook.measure.annotationCannotBeEmpty.t);
- } else {
- var result = await measureData.addAnnotation(
- application,
- annotationItem,
- );
- if (result ?? false) {
- measureHandler.currOperateType =
- MeasureOperateType.measure;
- measureHandler.currOperateType =
- MeasureOperateType.annotation;
- getAnnotationList();
- }
- }
- },
- icon: FIcon(
- Icons.add,
- color: widget.isLab! ? Colors.white : const Color(0xff2c77e5),
- ),
- businessParent: widget,
- ),
- ),
- hintText: i18nBook.measure.AddCcomment.t,
- onChanged: (value) {
- annotationItem = value;
- },
- ),
- const FSizedBox(width: 5),
- FTextTooltip(
- position: DisplayPosition.left,
- textStyle: const TextStyle(fontSize: 14, color: Colors.white),
- height: 32,
- message: i18nBook.measure.resetToDefaultAnnotation.t,
- margin: const EdgeInsets.only(right: 10),
- decoration: BoxDecoration(
- color: const Color.fromARGB(255, 238, 105, 95),
- borderRadius: BorderRadius.circular(4),
- ),
- child: FSizedBox(
- width: 40,
- height: 40,
- child: FElevatedButton(
- style: ButtonStyle(
- padding: const MaterialStatePropertyAll(EdgeInsets.all(0)),
- backgroundColor: MaterialStateProperty.all(
- widget.isLab! ? buttonColor : Colors.grey),
- ),
- child: const FIcon(Icons.restart_alt),
- onPressed: resetUserCommentsAsync,
- businessParent: widget,
- name: "resetUserCommentsAsync"),
- ),
- ),
- ],
- ),
- );
- }
- }
|