Browse Source

样式调整,统一控件样式

master
hejl 2 months ago
parent
commit
4189e9e28b
  1. 1
      win_text_editor/lib/framework/controllers/tab_items_controller.dart
  2. 1
      win_text_editor/lib/framework/services/file_service.dart
  3. 9
      win_text_editor/lib/main.dart
  4. 2
      win_text_editor/lib/menus/app_menu.dart
  5. 5
      win_text_editor/lib/menus/menu_actions.dart
  6. 49
      win_text_editor/lib/modules/call_function/controllers/call_function_controller.dart
  7. 39
      win_text_editor/lib/modules/call_function/models/call_function.dart
  8. 103
      win_text_editor/lib/modules/call_function/services/call_function_service.dart
  9. 24
      win_text_editor/lib/modules/call_function/widgets/call_function_left_side.dart
  10. 5
      win_text_editor/lib/modules/call_function/widgets/call_function_right_side.dart
  11. 39
      win_text_editor/lib/modules/content_search/widgets/results_view.dart
  12. 80
      win_text_editor/lib/modules/content_search/widgets/search_settings.dart
  13. 4
      win_text_editor/lib/modules/data_compare/widgets/data_compare_grid.dart
  14. 24
      win_text_editor/lib/modules/data_format/widgets/grid_view.dart
  15. 3
      win_text_editor/lib/modules/memory_table/controllers/index_data_source.dart
  16. 33
      win_text_editor/lib/modules/memory_table/widgets/memory_table_left_side.dart
  17. 5
      win_text_editor/lib/modules/memory_table/widgets/memory_table_right_side.dart
  18. 4
      win_text_editor/lib/modules/module_router.dart
  19. 24
      win_text_editor/lib/modules/template_parser/widgets/grid_view.dart
  20. 5
      win_text_editor/lib/modules/template_parser/widgets/tree_view.dart
  21. 23
      win_text_editor/lib/modules/uft_component/widgets/component_grid.dart
  22. 13
      win_text_editor/lib/modules/uft_component/widgets/uft_component_left_side.dart
  23. 5
      win_text_editor/lib/modules/uft_component/widgets/uft_component_right_side.dart
  24. 31
      win_text_editor/lib/shared/components/my_checkbox.dart
  25. 16
      win_text_editor/lib/shared/components/my_grid_column.dart
  26. 5
      win_text_editor/lib/shared/components/tree_view.dart
  27. 3
      win_text_editor/lib/shared/uft_std_fields/field_data_source.dart
  28. 24
      win_text_editor/lib/shared/uft_std_fields/fields_data_grid.dart

1
win_text_editor/lib/framework/controllers/tab_items_controller.dart

@ -145,6 +145,7 @@ class TabItemsController with ChangeNotifier { @@ -145,6 +145,7 @@ class TabItemsController with ChangeNotifier {
Future<void> openOrActivateTab(String title, String type, IconData icon) async {
try {
final existingTab = _tabs.firstWhereOrNull((tab) => tab.type == type);
Logger().debug("获取活动Tab页${existingTab?.title}");
if (existingTab != null) {
setActiveTab(existingTab.id);

1
win_text_editor/lib/framework/services/file_service.dart

@ -12,7 +12,6 @@ class FileService { @@ -12,7 +12,6 @@ class FileService {
'.uftatomservice',
'.uftfactorfunction',
'.uftfactorservice',
'.uftstructure',
];
static const Map<String, String> _uftFloders = {
'.settings': '项目设置',

9
win_text_editor/lib/main.dart

@ -54,6 +54,15 @@ class MyApp extends StatelessWidget { @@ -54,6 +54,15 @@ class MyApp extends StatelessWidget {
theme: ThemeData(
useMaterial3: true, // Material 3
cardTheme: const CardTheme(color: Colors.white),
// SfDataGrid
textTheme: const TextTheme(
bodyMedium: TextStyle(fontSize: 12), //
titleMedium: TextStyle(fontSize: 14), //
),
colorScheme: const ColorScheme.light(
primary: Colors.blue, //
onPrimary: Colors.white, //
),
),
home: const AppScaffold(),
);

2
win_text_editor/lib/menus/app_menu.dart

@ -62,7 +62,7 @@ class AppMenu extends StatelessWidget { @@ -62,7 +62,7 @@ class AppMenu extends StatelessWidget {
),
const PopupMenuItem<String>(
value: MenuConstants.callFunction,
child: ListTile(leading: Icon(Icons.functions), title: Text('函数调用')),
child: ListTile(leading: Icon(Icons.functions), title: Text('功能号调用')),
),
];
}

5
win_text_editor/lib/menus/menu_actions.dart

@ -17,6 +17,7 @@ class MenuActions { @@ -17,6 +17,7 @@ class MenuActions {
MenuConstants.dataCompare: _dataCompare,
MenuConstants.memoryTable: _memoryTable,
MenuConstants.uftComponent: _uftComponent,
MenuConstants.callFunction: _callFunction,
MenuConstants.demo: _demo,
MenuConstants.exit: _exitApplication,
};
@ -56,6 +57,10 @@ class MenuActions { @@ -56,6 +57,10 @@ class MenuActions {
await _openOrActivateTab(context, "标准组件", RouterKey.uftComponent, Icons.extension);
}
static Future<void> _callFunction(BuildContext context) async {
await _openOrActivateTab(context, "功能号调用", RouterKey.callFunction, Icons.extension);
}
static Future<void> _dataFormat(BuildContext context) async {
await _openOrActivateTab(context, "数据格式化", RouterKey.dataFormat, Icons.date_range);
}

49
win_text_editor/lib/modules/call_function/controllers/call_function_controller.dart

@ -13,19 +13,26 @@ class CallFunctionController extends BaseContentController { @@ -13,19 +13,26 @@ class CallFunctionController extends BaseContentController {
String objectId = "";
String chineseName = "";
late DataGridSource fieldsSource;
late DataGridSource indexesSource;
late DataGridSource inputSource;
late DataGridSource outputSource;
final CallFunctionService _service;
final MacroTemplateService templateService = MacroTemplateService();
// CallFunction对象
late CallFunction _memoryTable;
late CallFunction _modle;
CallFunctionController() : _service = CallFunctionService(Logger()) {
//
final initialFields = [Field('1', '', '', '', false), Field('2', '', '', '', false)];
final initialFields = [Field('1', '', '', '', false)];
fieldsSource = FieldsDataSource(
inputSource = FieldsDataSource(
initialFields,
onSelectionChanged: (index, isSelected) {
updateFieldSelection(index, isSelected);
},
);
outputSource = FieldsDataSource(
initialFields,
onSelectionChanged: (index, isSelected) {
updateFieldSelection(index, isSelected);
@ -33,13 +40,17 @@ class CallFunctionController extends BaseContentController { @@ -33,13 +40,17 @@ class CallFunctionController extends BaseContentController {
);
// CallFunction
_memoryTable = CallFunction(tableName: '', columns: initialFields);
_modle = CallFunction(
functionName: '',
inputParameters: initialFields,
outputParameters: initialFields,
);
}
String? get errorMessage => _errorMessage;
// CallFunction
CallFunction get memoryTable => _memoryTable;
CallFunction get memoryTable => _modle;
void initTemplateService() {
if (!templateService.inited) {
@ -49,25 +60,29 @@ class CallFunctionController extends BaseContentController { @@ -49,25 +60,29 @@ class CallFunctionController extends BaseContentController {
String? genCodeString(List<String> macroList) {
initTemplateService();
return templateService.renderTemplate(macroList, _memoryTable.toMap());
return templateService.renderTemplate(macroList, _modle.toMap());
}
@override
Future<void> onOpenFile(String filePath) async {
Logger().info("Opening file: $filePath");
try {
final tableData = await _service.parseStructureFile(filePath);
final FunctionData functionData = await _service.parseXmlFile(filePath);
// Update controller state
tableName = tableData.tableName;
chineseName = tableData.chineseName;
objectId = tableData.objectId;
chineseName = functionData.chineseName;
objectId = functionData.objectId;
// Update data sources
(fieldsSource as FieldsDataSource).updateData(tableData.fields);
(inputSource as FieldsDataSource).updateData(functionData.inputFields);
(outputSource as FieldsDataSource).updateData(functionData.outputFields);
// CallFunction对象
_memoryTable = CallFunction(tableName: tableName, columns: tableData.fields);
_modle = CallFunction(
functionName: tableName,
inputParameters: functionData.inputFields,
outputParameters: functionData.inputFields,
);
// Clear any previous error
_errorMessage = null;
@ -83,13 +98,13 @@ class CallFunctionController extends BaseContentController { @@ -83,13 +98,13 @@ class CallFunctionController extends BaseContentController {
//
void updateFieldSelection(int index, bool isSelected) {
final fields = (fieldsSource as FieldsDataSource).data;
final fields = (inputSource as FieldsDataSource).data;
if (index >= 0 && index < fields.length) {
fields[index].isSelected = isSelected;
fieldsSource.notifyListeners();
inputSource.notifyListeners();
// CallFunction
_memoryTable.columns[index].isSelected = isSelected;
_modle.inputParameters[index].isSelected = isSelected;
notifyListeners();
}
}

39
win_text_editor/lib/modules/call_function/models/call_function.dart

@ -1,37 +1,56 @@ @@ -1,37 +1,56 @@
import 'package:win_text_editor/shared/models/std_filed.dart';
class CallFunction {
final String tableName;
final List<Field> columns;
final String functionName;
final List<Field> inputParameters;
final List<Field> outputParameters;
CallFunction({required this.tableName, required this.columns});
CallFunction({
required this.functionName,
required this.inputParameters,
required this.outputParameters,
});
List<Field> get selectFields => columns.where((field) => field.isSelected).toList();
List<Field> get selectInputFields => inputParameters.where((field) => field.isSelected).toList();
List<Field> get selectOutputFields =>
outputParameters.where((field) => field.isSelected).toList();
Map<String, dynamic> toMap() {
return {
'tableName': tableName,
'tableName': functionName,
'fields':
columns
inputParameters
.map(
(field) => {
'id': field.id,
'name': field.name,
'chineseName': field.chineseName,
'type': field.type,
'isLast': columns.indexOf(field) == columns.length - 1,
'isLast': inputParameters.indexOf(field) == inputParameters.length - 1,
},
)
.toList(),
'selectedFields':
selectFields
'selectInputFields':
selectInputFields
.map(
(field) => {
'id': field.id,
'name': field.name,
'chineseName': field.chineseName,
'type': field.type,
'isLast': selectFields.indexOf(field) == selectFields.length - 1,
'isLast': selectInputFields.indexOf(field) == selectInputFields.length - 1,
},
)
.toList(),
'selectOutputFields':
selectOutputFields
.map(
(field) => {
'id': field.id,
'name': field.name,
'chineseName': field.chineseName,
'type': field.type,
'isLast': selectInputFields.indexOf(field) == selectInputFields.length - 1,
},
)
.toList(),

103
win_text_editor/lib/modules/call_function/services/call_function_service.dart

@ -1,12 +1,10 @@ @@ -1,12 +1,10 @@
// memory_table_service.dart
import 'dart:io';
import 'package:win_text_editor/modules/memory_table/models/memory_table.dart';
import 'package:win_text_editor/shared/data/std_fields_cache.dart';
import 'package:win_text_editor/shared/models/std_filed.dart';
import 'package:win_text_editor/shared/uft_std_fields/field_data_service.dart';
import 'package:xml/xml.dart' as xml;
import 'package:path/path.dart' as path;
import 'package:win_text_editor/framework/controllers/logger.dart';
class CallFunctionService {
@ -14,11 +12,22 @@ class CallFunctionService { @@ -14,11 +12,22 @@ class CallFunctionService {
CallFunctionService(this._logger);
Future<TableData> parseStructureFile(String filePath) async {
static const Map<String, String> _functionRootTypeMap = {
'uftfunction': 'business:Function',
'uftservice': 'business:Service',
'uftatomfunction': 'business:Function',
'uftatomservice': 'business:Service',
'uftfactorfunction': 'business:FactorFunction',
'uftfactorservice': 'business:FactorService',
};
Future<FunctionData> parseXmlFile(String filePath) async {
try {
// 1. Check file extension
if (!filePath.toLowerCase().endsWith('.uftstructure')) {
throw const FormatException("文件扩展名必须是.uftstructure");
final extendFileName = filePath.toLowerCase().split('.').last;
final String? rootNodeType = _functionRootTypeMap[extendFileName];
if (rootNodeType == null) {
throw const FormatException("文件扩展名不正确!");
}
// 2. metadata stdfield.stfield
@ -35,27 +44,26 @@ class CallFunctionService { @@ -35,27 +44,26 @@ class CallFunctionService {
final content = await file.readAsString();
final document = xml.XmlDocument.parse(content);
final structureNode = document.findAllElements('structure:Structure').firstOrNull;
final rootNode = document.findAllElements(rootNodeType).firstOrNull;
if (structureNode == null) {
throw const FormatException("文件格式错误:缺少structure:Structure节点");
if (rootNode == null) {
throw const FormatException("文件格式错误:缺少支持的根节点");
}
// 4. Get basic info
final fileNameWithoutExt = path.basenameWithoutExtension(filePath);
final chineseName = structureNode.getAttribute('chineseName') ?? '';
final objectId = structureNode.getAttribute('objectId') ?? '';
final chineseName = rootNode.getAttribute('chineseName') ?? '';
final objectId = rootNode.getAttribute('objectId') ?? '';
// 5. Process properties (fields)
final properties = document.findAllElements('properties');
final fields = <Field>[];
// 5. Process inputParameters (fields)
final inputParameters = document.findAllElements('inputParameters');
final inputFields = <Field>[];
int index = 1;
for (final property in properties) {
final id = property.getAttribute('id') ?? '';
for (final parameter in inputParameters) {
final id = parameter.getAttribute('id') ?? '';
//
final stdField = StdFieldsCache.getData(id);
fields.add(
inputFields.add(
Field(
(index++).toString(), //
id, //
@ -65,41 +73,30 @@ class CallFunctionService { @@ -65,41 +73,30 @@ class CallFunctionService {
);
}
// 6. Process indexes
final indexes = document.findAllElements('indexs');
final indexList = <Index>[];
for (final indexNode in indexes) {
final name = indexNode.getAttribute('name') ?? '';
final containerType = indexNode.getAttribute('containerType');
final isPrimary = containerType == null;
final rule = containerType ?? '';
// Get all index fields
final items = indexNode.findAllElements('items');
final fieldsList =
items
.map((item) => item.getAttribute('attrname') ?? '')
.where((f) => f.isNotEmpty)
.toList();
final indexFields = fieldsList.join(',');
indexList.add(
Index(
name, //
isPrimary, //
indexFields, //
rule, //
// 6. Process outputParameters
final outputParameters = document.findAllElements('outputParameters');
final outputFields = <Field>[];
index = 1;
for (final parameter in outputParameters) {
final id = parameter.getAttribute('id') ?? '';
//
final stdField = StdFieldsCache.getData(id);
outputFields.add(
Field(
(index++).toString(), //
id, //
stdField?.chineseName ?? '', //
stdField?.dateType ?? '', //
),
);
}
return TableData(
tableName: fileNameWithoutExt,
return FunctionData(
chineseName: chineseName,
objectId: objectId,
fields: fields.isNotEmpty ? fields : FieldDataService.getDefaultFields(),
indexes: indexList.isNotEmpty ? indexList : FieldDataService.getDefaultIndexes(),
inputFields: inputFields.isNotEmpty ? inputFields : FieldDataService.getDefaultFields(),
outputFields: outputFields.isNotEmpty ? outputFields : FieldDataService.getDefaultFields(),
);
} on xml.XmlParserException catch (e) {
_logger.error("XML解析错误: ${e.message}");
@ -111,18 +108,16 @@ class CallFunctionService { @@ -111,18 +108,16 @@ class CallFunctionService {
}
}
class TableData {
final String tableName;
class FunctionData {
final String chineseName;
final String objectId;
final List<Field> fields;
final List<Index> indexes;
final List<Field> inputFields;
final List<Field> outputFields;
TableData({
required this.tableName,
FunctionData({
required this.chineseName,
required this.objectId,
required this.fields,
required this.indexes,
required this.inputFields,
required this.outputFields,
});
}

24
win_text_editor/lib/modules/call_function/widgets/call_function_left_side.dart

@ -7,13 +7,13 @@ class CallFunctionLeftSide extends StatelessWidget { @@ -7,13 +7,13 @@ class CallFunctionLeftSide extends StatelessWidget {
final CallFunctionController controller;
const CallFunctionLeftSide({super.key, required this.controller});
Widget _buildTextFieldRow(String label, String value) {
Widget _buildTextFieldRow(String label, String value, double width) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Text('$label:'),
SizedBox(
width: 200,
width: width,
child: TextField(
controller: TextEditingController(text: value),
readOnly: true,
@ -38,9 +38,8 @@ class CallFunctionLeftSide extends StatelessWidget { @@ -38,9 +38,8 @@ class CallFunctionLeftSide extends StatelessWidget {
spacing: 16,
runSpacing: 8,
children: [
_buildTextFieldRow('名称', controller.tableName),
_buildTextFieldRow('中文名', controller.chineseName),
_buildTextFieldRow('对象编号', controller.objectId),
_buildTextFieldRow('功能号', controller.objectId, 100),
_buildTextFieldRow('中文名', controller.chineseName, 350),
],
),
),
@ -49,12 +48,12 @@ class CallFunctionLeftSide extends StatelessWidget { @@ -49,12 +48,12 @@ class CallFunctionLeftSide extends StatelessWidget {
const SizedBox(height: 8),
const Padding(
padding: EdgeInsets.all(8.0),
child: Text('字段列表', style: TextStyle(fontWeight: FontWeight.bold)),
child: Text('入参', style: TextStyle(fontWeight: FontWeight.bold)),
),
Expanded(
flex: 6,
child: FieldsDataGrid(
fieldsSource: controller.fieldsSource as FieldsDataSource,
fieldsSource: controller.inputSource as FieldsDataSource,
onSelectionChanged: (index, isSelected) {
controller.updateFieldSelection(index, isSelected);
},
@ -62,7 +61,16 @@ class CallFunctionLeftSide extends StatelessWidget { @@ -62,7 +61,16 @@ class CallFunctionLeftSide extends StatelessWidget {
),
const Padding(
padding: EdgeInsets.all(8.0),
child: Text('索引列表', style: TextStyle(fontWeight: FontWeight.bold)),
child: Text('出参', style: TextStyle(fontWeight: FontWeight.bold)),
),
Expanded(
flex: 4,
child: FieldsDataGrid(
fieldsSource: controller.inputSource as FieldsDataSource,
onSelectionChanged: (index, isSelected) {
controller.updateFieldSelection(index, isSelected);
},
),
),
],
);

5
win_text_editor/lib/modules/call_function/widgets/call_function_right_side.dart

@ -101,10 +101,13 @@ class _CallFunctionRightSideState extends State<CallFunctionRightSide> { @@ -101,10 +101,13 @@ class _CallFunctionRightSideState extends State<CallFunctionRightSide> {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Checkbox(
Transform.scale(
scale: 0.75, //
child: Checkbox(
value: _selectedOperations.contains(label),
onChanged: (bool? value) => _toggleOperation(label, value),
),
),
Text(label),
],
);

39
win_text_editor/lib/modules/content_search/widgets/results_view.dart

@ -8,6 +8,7 @@ import 'dart:io'; @@ -8,6 +8,7 @@ import 'dart:io';
import 'package:win_text_editor/modules/content_search/models/search_mode.dart';
import 'package:win_text_editor/modules/content_search/models/search_result.dart';
import 'package:win_text_editor/shared/components/my_grid_column.dart';
class ResultsView extends StatelessWidget {
const ResultsView({super.key});
@ -109,23 +110,8 @@ class ResultsView extends StatelessWidget { @@ -109,23 +110,8 @@ class ResultsView extends StatelessWidget {
headerRowHeight: 32,
source: LocateDataSource(controller),
columns: [
GridColumn(
columnName: 'file',
minimumWidth: 300,
label: Container(
alignment: Alignment.center,
color: Colors.grey[200],
child: const Text('文件(行号)', style: TextStyle(fontWeight: FontWeight.bold)),
),
),
GridColumn(
columnName: 'content',
label: Container(
alignment: Alignment.center,
color: Colors.grey[200],
child: const Text('内容', style: TextStyle(fontWeight: FontWeight.bold)),
),
),
MyGridColumn(columnName: 'file', label: '文件(行号)', minimumWidth: 300),
MyGridColumn(columnName: 'content', label: '内容'),
],
selectionMode: SelectionMode.multiple,
navigationMode: GridNavigationMode.cell,
@ -146,23 +132,8 @@ class ResultsView extends StatelessWidget { @@ -146,23 +132,8 @@ class ResultsView extends StatelessWidget {
headerRowHeight: 32,
source: CountDataSource(controller),
columns: [
GridColumn(
columnName: 'keyword',
minimumWidth: 300,
label: Container(
alignment: Alignment.center,
color: Colors.grey[200],
child: const Text('关键词', style: TextStyle(fontWeight: FontWeight.bold)),
),
),
GridColumn(
columnName: 'count',
label: Container(
alignment: Alignment.center,
color: Colors.grey[200],
child: const Text('匹配数量', style: TextStyle(fontWeight: FontWeight.bold)),
),
),
MyGridColumn(columnName: 'keyword', label: '关键词', minimumWidth: 300),
MyGridColumn(columnName: 'count', label: '匹配数量'),
],
selectionMode: SelectionMode.multiple,
navigationMode: GridNavigationMode.cell,

80
win_text_editor/lib/modules/content_search/widgets/search_settings.dart

@ -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,7 +108,9 @@ class _SearchSettingsState extends State<SearchSettings> { @@ -107,7 +108,9 @@ class _SearchSettingsState extends State<SearchSettings> {
Expanded(
child: Row(
children: [
Radio<SearchMode>(
Transform.scale(
scale: 0.75,
child: Radio<SearchMode>(
value: SearchMode.locate,
groupValue: controller.searchMode,
onChanged: (value) {
@ -117,6 +120,7 @@ class _SearchSettingsState extends State<SearchSettings> { @@ -117,6 +120,7 @@ class _SearchSettingsState extends State<SearchSettings> {
}
},
),
),
const Text('定位', style: TextStyle(fontSize: 12)),
],
),
@ -124,7 +128,9 @@ class _SearchSettingsState extends State<SearchSettings> { @@ -124,7 +128,9 @@ class _SearchSettingsState extends State<SearchSettings> {
Expanded(
child: Row(
children: [
Radio<SearchMode>(
Transform.scale(
scale: 0.75,
child: Radio<SearchMode>(
value: SearchMode.count,
groupValue: controller.searchMode,
onChanged: (value) {
@ -134,22 +140,19 @@ class _SearchSettingsState extends State<SearchSettings> { @@ -134,22 +140,19 @@ class _SearchSettingsState extends State<SearchSettings> {
}
},
),
),
const Text('计数', style: TextStyle(fontSize: 12)),
],
),
),
],
),
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) {
onChanged: (value) {
controller.caseSensitive = value!;
if (value) {
controller.customRule = false;
controller.useRegex = false;
}
},
activeColor: controller.customRule ? Colors.grey : null,
),
),
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) {
onChanged: (value) {
controller.wholeWord = value!;
if (value) {
controller.customRule = false;
controller.useRegex = false;
}
},
activeColor: controller.customRule ? Colors.grey : null,
),
),
],
),
//
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) {
onChanged: (value) {
controller.useRegex = value!;
if (value) {
controller.caseSensitive = false;
controller.wholeWord = false;
controller.useRegex = value!;
controller.customRule = false;
}
},
activeColor: controller.customRule ? Colors.grey : null,
),
),
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,

4
win_text_editor/lib/modules/data_compare/widgets/data_compare_grid.dart

@ -81,7 +81,7 @@ class DataCompareGrid extends StatelessWidget { @@ -81,7 +81,7 @@ class DataCompareGrid extends StatelessWidget {
return Container(
alignment: Alignment.center,
color: color ?? Colors.grey[200],
child: Text(text, style: const TextStyle(fontWeight: FontWeight.bold)),
child: Text(text, style: const TextStyle(fontWeight: FontWeight.normal)),
);
}
@ -89,7 +89,7 @@ class DataCompareGrid extends StatelessWidget { @@ -89,7 +89,7 @@ class DataCompareGrid extends StatelessWidget {
return Container(
alignment: Alignment.center,
color: color ?? Colors.purple[50],
child: Text(text, style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16)),
child: Text(text, style: const TextStyle(fontWeight: FontWeight.normal)),
);
}
}

24
win_text_editor/lib/modules/data_format/widgets/grid_view.dart

@ -4,6 +4,7 @@ import 'package:file_picker/file_picker.dart'; @@ -4,6 +4,7 @@ import 'package:file_picker/file_picker.dart';
import 'dart:io';
import 'package:csv/csv.dart';
import 'package:win_text_editor/modules/data_format/controllers/grid_view_controller.dart';
import 'package:win_text_editor/shared/components/my_grid_column.dart';
class DataGridView extends StatefulWidget {
final GridViewController controller;
@ -148,27 +149,14 @@ class _DataGridViewState extends State<DataGridView> { @@ -148,27 +149,14 @@ class _DataGridViewState extends State<DataGridView> {
final columns = [
//
GridColumn(
columnName: '序号',
width: 60, //
label: Container(
padding: const EdgeInsets.all(8.0),
color: Colors.grey[200],
alignment: Alignment.center,
child: const Text('序号', overflow: TextOverflow.ellipsis, maxLines: 1),
),
),
MyGridColumn(columnName: '序号', label: '序号', minimumWidth: 60),
//
...headers.sublist(1).map<GridColumn>((header) {
return GridColumn(
return MyGridColumn(
columnName: header.toString(),
minimumWidth: 150, //
label: Container(
padding: const EdgeInsets.all(8.0),
color: Colors.grey[200],
alignment: Alignment.center,
child: Text(header.toString(), overflow: TextOverflow.ellipsis, maxLines: 1),
),
label: header.toString(),
minimumWidth: 150,
);
}).toList(),
];

3
win_text_editor/lib/modules/memory_table/controllers/index_data_source.dart

@ -41,6 +41,8 @@ class IndexesDataSource extends SelectableDataSource<Index> { @@ -41,6 +41,8 @@ class IndexesDataSource extends SelectableDataSource<Index> {
row.getCells().map<Widget>((cell) {
if (cell.columnName == 'select') {
return Center(
child: Transform.scale(
scale: 0.75,
child: Radio<String>(
value: index.id, // 使value
groupValue: _selectedId, // ID
@ -50,6 +52,7 @@ class IndexesDataSource extends SelectableDataSource<Index> { @@ -50,6 +52,7 @@ class IndexesDataSource extends SelectableDataSource<Index> {
notifyListeners(); //
},
),
),
);
}
return Container(

33
win_text_editor/lib/modules/memory_table/widgets/memory_table_left_side.dart

@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_datagrid/datagrid.dart';
import 'package:win_text_editor/modules/memory_table/controllers/index_data_source.dart';
import 'package:win_text_editor/modules/memory_table/controllers/memory_table_controller.dart';
import 'package:win_text_editor/shared/components/my_grid_column.dart';
import 'package:win_text_editor/shared/uft_std_fields/field_data_source.dart';
import 'package:win_text_editor/shared/uft_std_fields/fields_data_grid.dart';
@ -26,14 +27,6 @@ class MemoryTableLeftSide extends StatelessWidget { @@ -26,14 +27,6 @@ class MemoryTableLeftSide extends StatelessWidget {
);
}
Container _buildGridHeader(String text) {
return Container(
alignment: Alignment.center,
color: Colors.grey[200],
child: Text(text, style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16)),
);
}
Widget _buildIndexesDataGrid(MemoryTableController controller) {
final indexesSource = controller.indexesSource as IndexesDataSource;
@ -63,26 +56,10 @@ class MemoryTableLeftSide extends StatelessWidget { @@ -63,26 +56,10 @@ class MemoryTableLeftSide extends StatelessWidget {
),
width: 60,
),
GridColumn(
columnName: 'indexName',
label: _buildGridHeader('索引名称'),
minimumWidth: 120,
),
GridColumn(
columnName: 'isPrimary',
label: _buildGridHeader('是否主键'),
minimumWidth: 100,
),
GridColumn(
columnName: 'indexFields',
label: _buildGridHeader('索引字段'),
minimumWidth: 150,
),
GridColumn(
columnName: 'rule',
label: _buildGridHeader('规则'),
minimumWidth: 200,
),
MyGridColumn(columnName: 'indexName', label: '索引名称', minimumWidth: 120),
MyGridColumn(columnName: 'isPrimary', label: '是否主键', minimumWidth: 100),
MyGridColumn(columnName: 'indexFields', label: '索引字段', minimumWidth: 150),
MyGridColumn(columnName: 'rule', label: '规则', minimumWidth: 200),
],
onCellTap: (details) {
if (details.column.columnName == 'select') {

5
win_text_editor/lib/modules/memory_table/widgets/memory_table_right_side.dart

@ -101,10 +101,13 @@ class _MemoryTableRightSideState extends State<MemoryTableRightSide> { @@ -101,10 +101,13 @@ class _MemoryTableRightSideState extends State<MemoryTableRightSide> {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Checkbox(
Transform.scale(
scale: 0.75,
child: Checkbox(
value: _selectedOperations.contains(label),
onChanged: (bool? value) => _toggleOperation(label, value),
),
),
Text(label),
],
);

4
win_text_editor/lib/modules/module_router.dart

@ -1,6 +1,8 @@ @@ -1,6 +1,8 @@
// modules/tab_content_registry.dart
import 'package:flutter/material.dart';
import 'package:win_text_editor/framework/models/tab_model.dart';
import 'package:win_text_editor/modules/call_function/controllers/call_function_controller.dart';
import 'package:win_text_editor/modules/call_function/widgets/call_function_view.dart';
import 'package:win_text_editor/modules/data_compare/controllers/data_compare_controller.dart';
import 'package:win_text_editor/modules/data_compare/widgets/data_compare_view.dart';
import 'package:win_text_editor/modules/data_format/controllers/data_format_controller.dart';
@ -38,6 +40,7 @@ class ModuleRouter { @@ -38,6 +40,7 @@ class ModuleRouter {
RouterKey.dataCompare: (tab) => DataCompareController(),
RouterKey.memoryTable: (tab) => MemoryTableController(),
RouterKey.uftComponent: (tab) => UftComponentController(),
RouterKey.callFunction: (tab) => CallFunctionController(),
RouterKey.demo: (tab) => DemoController(),
};
@ -49,6 +52,7 @@ class ModuleRouter { @@ -49,6 +52,7 @@ class ModuleRouter {
RouterKey.dataCompare: (tab, controller) => DataCompareView(tabId: tab.id),
RouterKey.memoryTable: (tab, controller) => MemoryTableView(tabId: tab.id),
RouterKey.uftComponent: (tab, controller) => UftComponentView(tabId: tab.id),
RouterKey.callFunction: (tab, controller) => CallFunctionView(tabId: tab.id),
RouterKey.demo: (tab, controller) => DemoView(tabId: tab.id),
};

24
win_text_editor/lib/modules/template_parser/widgets/grid_view.dart

@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:syncfusion_flutter_datagrid/datagrid.dart';
import 'package:win_text_editor/modules/template_parser/controllers/grid_view_controller.dart';
import 'package:win_text_editor/shared/components/my_grid_column.dart';
import 'package:win_text_editor/shared/models/template_node.dart';
import 'package:file_picker/file_picker.dart';
import 'dart:io';
@ -110,27 +111,12 @@ class TemplateGridView extends StatelessWidget { @@ -110,27 +111,12 @@ class TemplateGridView extends StatelessWidget {
final dataSource = _TemplateItemDataSource(rows: rows, selectedNodes: selectedNodes);
//
final columns = <GridColumn>[
GridColumn(
columnName: 'index',
width: 60,
label: Container(
padding: const EdgeInsets.all(8.0),
color: Colors.grey[200],
alignment: Alignment.center,
child: const Text('序号'),
),
),
final columns = <MyGridColumn>[
MyGridColumn(columnName: 'index', minimumWidth: 60, label: '序号'),
...selectedNodes.map((node) {
return GridColumn(
return MyGridColumn(
columnName: node.path,
label: Container(
padding: const EdgeInsets.all(8.0),
alignment: Alignment.center,
color: Colors.grey[200],
child: Text(node.isAttribute ? node.name.substring(1) : node.name),
),
label: node.isAttribute ? node.name.substring(1) : node.name,
);
}).toList(),
];

5
win_text_editor/lib/modules/template_parser/widgets/tree_view.dart

@ -54,7 +54,9 @@ class TemplateTreeView extends StatelessWidget { @@ -54,7 +54,9 @@ class TemplateTreeView extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
if (templateNode.children.isEmpty) //
Checkbox(
Transform.scale(
scale: 0.75,
child: Checkbox(
value: templateNode.isChecked,
onChanged: (value) {
if (value != null) {
@ -62,6 +64,7 @@ class TemplateTreeView extends StatelessWidget { @@ -62,6 +64,7 @@ class TemplateTreeView extends StatelessWidget {
}
},
),
),
isAttribute
? const Icon(Icons.code, size: 16, color: Colors.grey)
: const Icon(Icons.label_outline, size: 18, color: Colors.blue),

23
win_text_editor/lib/modules/uft_component/widgets/component_grid.dart

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_datagrid/datagrid.dart';
import 'package:win_text_editor/modules/uft_component/controllers/component_source.dart';
import 'package:win_text_editor/shared/components/my_grid_column.dart';
class ComponentGrid extends StatefulWidget {
final ComponentSource componentsSource;
@ -15,14 +16,6 @@ class ComponentGrid extends StatefulWidget { @@ -15,14 +16,6 @@ class ComponentGrid extends StatefulWidget {
class ComponentGridState extends State<ComponentGrid> {
final DataGridController _dataGridController = DataGridController();
Container _buildGridHeader(String text) {
return Container(
alignment: Alignment.center,
color: Colors.grey[200],
child: Text(text, style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16)),
);
}
void scrollToIndex(int index) {
_dataGridController.scrollToRow(index.toDouble());
_dataGridController.selectedIndex = index;
@ -49,17 +42,9 @@ class ComponentGridState extends State<ComponentGrid> { @@ -49,17 +42,9 @@ class ComponentGridState extends State<ComponentGrid> {
columnWidthMode: ColumnWidthMode.fitByCellValue,
selectionMode: SelectionMode.single,
columns: [
GridColumn(columnName: 'id', label: _buildGridHeader('序号'), minimumWidth: 80),
GridColumn(
columnName: 'name',
label: _buildGridHeader('名称'),
minimumWidth: 120,
),
GridColumn(
columnName: 'chineseName',
label: _buildGridHeader('中文名'),
minimumWidth: 120,
),
MyGridColumn(columnName: 'id', label: '序号', minimumWidth: 80),
MyGridColumn(columnName: 'name', label: '名称', minimumWidth: 120),
MyGridColumn(columnName: 'chineseName', label: '中文名', minimumWidth: 120),
],
onSelectionChanged: (addedRows, removedRows) {
if (addedRows.isNotEmpty) {

13
win_text_editor/lib/modules/uft_component/widgets/uft_component_left_side.dart

@ -19,15 +19,15 @@ class _UftComponentLeftSideState extends State<UftComponentLeftSide> { @@ -19,15 +19,15 @@ class _UftComponentLeftSideState extends State<UftComponentLeftSide> {
final FocusNode _searchFocusNode = FocusNode(); //
Widget _buildSearchField() {
return SizedBox(
width: 400,
return Container(
padding: const EdgeInsetsDirectional.only(start: 8, end: 80),
child: TextField(
controller: _searchController,
focusNode: _searchFocusNode, //
decoration: InputDecoration(
isDense: true,
contentPadding: const EdgeInsets.all(8),
hintText: '输入名称或中文名查找',
hintText: '',
suffixIcon: IconButton(icon: const Icon(Icons.search), onPressed: _handleSearch),
),
onSubmitted: (_) => _handleSearch(), //
@ -82,14 +82,7 @@ class _UftComponentLeftSideState extends State<UftComponentLeftSide> { @@ -82,14 +82,7 @@ class _UftComponentLeftSideState extends State<UftComponentLeftSide> {
return Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(' 标准组件', style: TextStyle(fontWeight: FontWeight.bold)),
_buildSearchField(),
],
),
Expanded(
flex: 3,
child: ComponentGrid(

5
win_text_editor/lib/modules/uft_component/widgets/uft_component_right_side.dart

@ -101,10 +101,13 @@ class _UftComponentRightSideState extends State<UftComponentRightSide> { @@ -101,10 +101,13 @@ class _UftComponentRightSideState extends State<UftComponentRightSide> {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Checkbox(
Transform.scale(
scale: 0.75,
child: Checkbox(
value: _selectedOperations.contains(label),
onChanged: (bool? value) => _toggleOperation(label, value),
),
),
Text(label),
],
);

31
win_text_editor/lib/shared/components/my_checkbox.dart

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
import 'package:flutter/material.dart';
class MyCheckbox extends StatelessWidget {
final String title;
final bool value;
final ValueChanged<bool?>? onChanged;
final bool enabled = true;
const MyCheckbox({super.key, required this.title, required this.value, this.onChanged});
@override
Widget build(BuildContext context) {
return ConstrainedBox(
constraints: const BoxConstraints(minHeight: 32),
child: ListTile(
dense: true,
title: Text(title, style: const TextStyle(fontSize: 12)),
contentPadding: EdgeInsets.zero,
leading: Transform.scale(
scale: 0.75,
child: Checkbox(
value: value,
onChanged: enabled ? onChanged : null,
activeColor: enabled ? null : Colors.grey,
),
),
onTap: enabled && onChanged != null ? () => onChanged!(!value) : null,
),
);
}
}

16
win_text_editor/lib/shared/components/my_grid_column.dart

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_datagrid/datagrid.dart';
class MyGridColumn extends GridColumn {
MyGridColumn({required String columnName, double minimumWidth = 100, required String label})
: super(
columnName: columnName,
minimumWidth: minimumWidth,
label: Container(
alignment: Alignment.center,
color: Colors.grey[200],
padding: const EdgeInsets.all(2.0),
child: Text(label, style: const TextStyle(fontWeight: FontWeight.normal)),
),
);
}

5
win_text_editor/lib/shared/components/tree_view.dart

@ -206,10 +206,13 @@ class TreeNodeWidget extends StatelessWidget { @@ -206,10 +206,13 @@ class TreeNodeWidget extends StatelessWidget {
title: Text(node.name, style: Theme.of(context).textTheme.bodyMedium),
trailing:
config.showCheckboxes
? Checkbox(
? Transform.scale(
scale: 0.75,
child: Checkbox(
value: isChecked,
onChanged: onCheckChanged,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
)
: null,
),

3
win_text_editor/lib/shared/uft_std_fields/field_data_source.dart

@ -35,10 +35,13 @@ class FieldsDataSource extends SelectableDataSource<Field> { @@ -35,10 +35,13 @@ class FieldsDataSource extends SelectableDataSource<Field> {
row.getCells().map<Widget>((cell) {
if (cell.columnName == 'select') {
return Center(
child: Transform.scale(
scale: 0.75, //
child: Checkbox(
value: items[rowIndex].isSelected,
onChanged: (value) => toggleRowSelection(rowIndex, value),
),
),
);
}
return Container(

24
win_text_editor/lib/shared/uft_std_fields/fields_data_grid.dart

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_datagrid/datagrid.dart';
import 'package:win_text_editor/shared/base/base_data_source.dart';
import 'package:win_text_editor/shared/components/my_grid_column.dart';
import 'package:win_text_editor/shared/models/std_filed.dart';
import 'package:win_text_editor/shared/uft_std_fields/field_data_source.dart';
@ -32,11 +33,14 @@ class FieldsDataGrid extends StatelessWidget { @@ -32,11 +33,14 @@ class FieldsDataGrid extends StatelessWidget {
return Container(
alignment: Alignment.center,
color: Colors.grey[200],
child: Transform.scale(
scale: 0.75, //
child: Checkbox(
value: allSelected,
tristate: someSelected,
onChanged: (value) => dataSource.toggleAllSelection(value ?? false),
),
),
);
}
@ -68,22 +72,10 @@ class FieldsDataGrid extends StatelessWidget { @@ -68,22 +72,10 @@ class FieldsDataGrid extends StatelessWidget {
),
width: 60,
),
GridColumn(columnName: 'id', label: _buildGridHeader('序号'), minimumWidth: 80),
GridColumn(
columnName: 'name',
label: _buildGridHeader('名称'),
minimumWidth: 120,
),
GridColumn(
columnName: 'chineseName',
label: _buildGridHeader('中文名'),
minimumWidth: 120,
),
GridColumn(
columnName: 'type',
label: _buildGridHeader('类型'),
minimumWidth: 120,
),
MyGridColumn(columnName: 'id', label: '序号', minimumWidth: 80),
MyGridColumn(columnName: 'name', label: '名称', minimumWidth: 120),
MyGridColumn(columnName: 'chineseName', label: '中文名', minimumWidth: 120),
MyGridColumn(columnName: 'type', label: '类型', minimumWidth: 120),
],
onCellTap: (details) {
if (details.column.columnName == 'select') {

Loading…
Cancel
Save