|
|
|
@ -2,6 +2,7 @@ import 'dart:async';
@@ -2,6 +2,7 @@ import 'dart:async';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
import 'package:provider/provider.dart'; |
|
|
|
|
import 'package:win_text_editor/shared/components/my_checkbox.dart'; |
|
|
|
|
import 'package:win_text_editor/shared/components/text_editor.dart'; |
|
|
|
|
import 'package:win_text_editor/modules/content_search/controllers/content_search_controller.dart'; |
|
|
|
|
import 'package:win_text_editor/modules/content_search/models/search_mode.dart'; |
|
|
|
@ -15,7 +16,7 @@ class SearchSettings extends StatefulWidget {
@@ -15,7 +16,7 @@ class SearchSettings extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
class _SearchSettingsState extends State<SearchSettings> { |
|
|
|
|
Duration _elapsedTime = Duration.zero; |
|
|
|
|
Stopwatch _stopwatch = Stopwatch(); |
|
|
|
|
final Stopwatch _stopwatch = Stopwatch(); |
|
|
|
|
Timer? _updateTimer; |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@ -107,15 +108,18 @@ class _SearchSettingsState extends State<SearchSettings> {
@@ -107,15 +108,18 @@ class _SearchSettingsState extends State<SearchSettings> {
|
|
|
|
|
Expanded( |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
Radio<SearchMode>( |
|
|
|
|
value: SearchMode.locate, |
|
|
|
|
groupValue: controller.searchMode, |
|
|
|
|
onChanged: (value) { |
|
|
|
|
if (value != null) { |
|
|
|
|
controller.clearResults(); // 清除搜索结果 |
|
|
|
|
controller.searchMode = value; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
Transform.scale( |
|
|
|
|
scale: 0.75, |
|
|
|
|
child: Radio<SearchMode>( |
|
|
|
|
value: SearchMode.locate, |
|
|
|
|
groupValue: controller.searchMode, |
|
|
|
|
onChanged: (value) { |
|
|
|
|
if (value != null) { |
|
|
|
|
controller.clearResults(); // 清除搜索结果 |
|
|
|
|
controller.searchMode = value; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
const Text('定位', style: TextStyle(fontSize: 12)), |
|
|
|
|
], |
|
|
|
@ -124,15 +128,18 @@ class _SearchSettingsState extends State<SearchSettings> {
@@ -124,15 +128,18 @@ class _SearchSettingsState extends State<SearchSettings> {
|
|
|
|
|
Expanded( |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
Radio<SearchMode>( |
|
|
|
|
value: SearchMode.count, |
|
|
|
|
groupValue: controller.searchMode, |
|
|
|
|
onChanged: (value) { |
|
|
|
|
if (value != null) { |
|
|
|
|
controller.clearResults(); // 清除搜索结果 |
|
|
|
|
controller.searchMode = value; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
Transform.scale( |
|
|
|
|
scale: 0.75, |
|
|
|
|
child: Radio<SearchMode>( |
|
|
|
|
value: SearchMode.count, |
|
|
|
|
groupValue: controller.searchMode, |
|
|
|
|
onChanged: (value) { |
|
|
|
|
if (value != null) { |
|
|
|
|
controller.clearResults(); // 清除搜索结果 |
|
|
|
|
controller.searchMode = value; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
const Text('计数', style: TextStyle(fontSize: 12)), |
|
|
|
|
], |
|
|
|
@ -140,16 +147,12 @@ class _SearchSettingsState extends State<SearchSettings> {
@@ -140,16 +147,12 @@ class _SearchSettingsState extends State<SearchSettings> {
|
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
const SizedBox(height: 4), |
|
|
|
|
Visibility( |
|
|
|
|
visible: controller.searchMode == SearchMode.count, |
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
CheckboxListTile( |
|
|
|
|
dense: true, |
|
|
|
|
contentPadding: EdgeInsets.zero, |
|
|
|
|
controlAffinity: ListTileControlAffinity.leading, |
|
|
|
|
title: const Text('包含匹配数量0', style: TextStyle(fontSize: 12)), |
|
|
|
|
MyCheckbox( |
|
|
|
|
title: '包含匹配数量0', |
|
|
|
|
value: controller.includeZeroCounts, |
|
|
|
|
onChanged: |
|
|
|
|
controller.searchMode == SearchMode.count |
|
|
|
@ -162,7 +165,7 @@ class _SearchSettingsState extends State<SearchSettings> {
@@ -162,7 +165,7 @@ class _SearchSettingsState extends State<SearchSettings> {
|
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
const SizedBox(height: 8), |
|
|
|
|
const SizedBox(height: 4), |
|
|
|
|
// 匹配规则 |
|
|
|
|
const Text('匹配规则:', style: TextStyle(fontSize: 12)), |
|
|
|
|
const SizedBox(height: 4), |
|
|
|
@ -170,71 +173,52 @@ class _SearchSettingsState extends State<SearchSettings> {
@@ -170,71 +173,52 @@ class _SearchSettingsState extends State<SearchSettings> {
|
|
|
|
|
Row( |
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
|
child: CheckboxListTile( |
|
|
|
|
dense: true, |
|
|
|
|
contentPadding: EdgeInsets.zero, |
|
|
|
|
controlAffinity: ListTileControlAffinity.leading, |
|
|
|
|
title: const Text('大小写敏感', style: TextStyle(fontSize: 12)), |
|
|
|
|
child: MyCheckbox( |
|
|
|
|
title: '大小写敏感', |
|
|
|
|
value: controller.caseSensitive, |
|
|
|
|
onChanged: |
|
|
|
|
controller.customRule |
|
|
|
|
? null |
|
|
|
|
: (value) { |
|
|
|
|
controller.caseSensitive = value!; |
|
|
|
|
controller.customRule = false; |
|
|
|
|
controller.useRegex = false; |
|
|
|
|
}, |
|
|
|
|
activeColor: controller.customRule ? Colors.grey : null, |
|
|
|
|
onChanged: (value) { |
|
|
|
|
controller.caseSensitive = value!; |
|
|
|
|
if (value) { |
|
|
|
|
controller.customRule = false; |
|
|
|
|
controller.useRegex = false; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Expanded( |
|
|
|
|
child: CheckboxListTile( |
|
|
|
|
dense: true, |
|
|
|
|
contentPadding: EdgeInsets.zero, |
|
|
|
|
controlAffinity: ListTileControlAffinity.leading, |
|
|
|
|
title: const Text('全字匹配', style: TextStyle(fontSize: 12)), |
|
|
|
|
child: MyCheckbox( |
|
|
|
|
title: '全字匹配', |
|
|
|
|
value: controller.wholeWord, |
|
|
|
|
onChanged: |
|
|
|
|
controller.customRule |
|
|
|
|
? null |
|
|
|
|
: (value) { |
|
|
|
|
controller.wholeWord = value!; |
|
|
|
|
controller.customRule = false; |
|
|
|
|
controller.useRegex = false; |
|
|
|
|
}, |
|
|
|
|
activeColor: controller.customRule ? Colors.grey : null, |
|
|
|
|
onChanged: (value) { |
|
|
|
|
controller.wholeWord = value!; |
|
|
|
|
if (value) { |
|
|
|
|
controller.customRule = false; |
|
|
|
|
controller.useRegex = false; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
// 第二行复选框 |
|
|
|
|
Row( |
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
|
child: CheckboxListTile( |
|
|
|
|
dense: true, |
|
|
|
|
contentPadding: EdgeInsets.zero, |
|
|
|
|
controlAffinity: ListTileControlAffinity.leading, |
|
|
|
|
title: const Text('正则匹配', style: TextStyle(fontSize: 12)), |
|
|
|
|
child: MyCheckbox( |
|
|
|
|
title: '正则匹配', |
|
|
|
|
value: controller.useRegex, |
|
|
|
|
onChanged: |
|
|
|
|
controller.customRule |
|
|
|
|
? null |
|
|
|
|
: (value) { |
|
|
|
|
controller.caseSensitive = false; |
|
|
|
|
controller.wholeWord = false; |
|
|
|
|
controller.useRegex = value!; |
|
|
|
|
controller.customRule = false; |
|
|
|
|
}, |
|
|
|
|
activeColor: controller.customRule ? Colors.grey : null, |
|
|
|
|
onChanged: (value) { |
|
|
|
|
controller.useRegex = value!; |
|
|
|
|
if (value) { |
|
|
|
|
controller.caseSensitive = false; |
|
|
|
|
controller.wholeWord = false; |
|
|
|
|
controller.customRule = false; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Expanded( |
|
|
|
|
child: CheckboxListTile( |
|
|
|
|
dense: true, |
|
|
|
|
contentPadding: EdgeInsets.zero, |
|
|
|
|
controlAffinity: ListTileControlAffinity.leading, |
|
|
|
|
title: const Text('自定义规则', style: TextStyle(fontSize: 12)), |
|
|
|
|
child: MyCheckbox( |
|
|
|
|
title: '自定义规则', |
|
|
|
|
value: controller.customRule, |
|
|
|
|
onChanged: (value) { |
|
|
|
|
controller.customRule = value!; |
|
|
|
@ -248,7 +232,7 @@ class _SearchSettingsState extends State<SearchSettings> {
@@ -248,7 +232,7 @@ class _SearchSettingsState extends State<SearchSettings> {
|
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
const SizedBox(height: 8), |
|
|
|
|
// const SizedBox(height: 8), |
|
|
|
|
// 仅在自定义规则选中时显示的JS函数说明 |
|
|
|
|
Visibility( |
|
|
|
|
visible: controller.customRule, |
|
|
|
|