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. 9
      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. 136
      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. 19
      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. 9
      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. 17
      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. 15
      win_text_editor/lib/modules/uft_component/widgets/uft_component_left_side.dart
  23. 9
      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. 11
      win_text_editor/lib/shared/components/tree_view.dart
  27. 9
      win_text_editor/lib/shared/uft_std_fields/field_data_source.dart
  28. 32
      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 {
Future<void> openOrActivateTab(String title, String type, IconData icon) async { Future<void> openOrActivateTab(String title, String type, IconData icon) async {
try { try {
final existingTab = _tabs.firstWhereOrNull((tab) => tab.type == type); final existingTab = _tabs.firstWhereOrNull((tab) => tab.type == type);
Logger().debug("获取活动Tab页${existingTab?.title}");
if (existingTab != null) { if (existingTab != null) {
setActiveTab(existingTab.id); setActiveTab(existingTab.id);

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

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

9
win_text_editor/lib/main.dart

@ -54,6 +54,15 @@ class MyApp extends StatelessWidget {
theme: ThemeData( theme: ThemeData(
useMaterial3: true, // Material 3 useMaterial3: true, // Material 3
cardTheme: const CardTheme(color: Colors.white), 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(), home: const AppScaffold(),
); );

2
win_text_editor/lib/menus/app_menu.dart

@ -62,7 +62,7 @@ class AppMenu extends StatelessWidget {
), ),
const PopupMenuItem<String>( const PopupMenuItem<String>(
value: MenuConstants.callFunction, 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 {
MenuConstants.dataCompare: _dataCompare, MenuConstants.dataCompare: _dataCompare,
MenuConstants.memoryTable: _memoryTable, MenuConstants.memoryTable: _memoryTable,
MenuConstants.uftComponent: _uftComponent, MenuConstants.uftComponent: _uftComponent,
MenuConstants.callFunction: _callFunction,
MenuConstants.demo: _demo, MenuConstants.demo: _demo,
MenuConstants.exit: _exitApplication, MenuConstants.exit: _exitApplication,
}; };
@ -56,6 +57,10 @@ class MenuActions {
await _openOrActivateTab(context, "标准组件", RouterKey.uftComponent, Icons.extension); 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 { static Future<void> _dataFormat(BuildContext context) async {
await _openOrActivateTab(context, "数据格式化", RouterKey.dataFormat, Icons.date_range); 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 {
String objectId = ""; String objectId = "";
String chineseName = ""; String chineseName = "";
late DataGridSource fieldsSource; late DataGridSource inputSource;
late DataGridSource indexesSource; late DataGridSource outputSource;
final CallFunctionService _service; final CallFunctionService _service;
final MacroTemplateService templateService = MacroTemplateService(); final MacroTemplateService templateService = MacroTemplateService();
// CallFunction对象 // CallFunction对象
late CallFunction _memoryTable; late CallFunction _modle;
CallFunctionController() : _service = CallFunctionService(Logger()) { 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, initialFields,
onSelectionChanged: (index, isSelected) { onSelectionChanged: (index, isSelected) {
updateFieldSelection(index, isSelected); updateFieldSelection(index, isSelected);
@ -33,13 +40,17 @@ class CallFunctionController extends BaseContentController {
); );
// CallFunction // CallFunction
_memoryTable = CallFunction(tableName: '', columns: initialFields); _modle = CallFunction(
functionName: '',
inputParameters: initialFields,
outputParameters: initialFields,
);
} }
String? get errorMessage => _errorMessage; String? get errorMessage => _errorMessage;
// CallFunction // CallFunction
CallFunction get memoryTable => _memoryTable; CallFunction get memoryTable => _modle;
void initTemplateService() { void initTemplateService() {
if (!templateService.inited) { if (!templateService.inited) {
@ -49,25 +60,29 @@ class CallFunctionController extends BaseContentController {
String? genCodeString(List<String> macroList) { String? genCodeString(List<String> macroList) {
initTemplateService(); initTemplateService();
return templateService.renderTemplate(macroList, _memoryTable.toMap()); return templateService.renderTemplate(macroList, _modle.toMap());
} }
@override @override
Future<void> onOpenFile(String filePath) async { Future<void> onOpenFile(String filePath) async {
Logger().info("Opening file: $filePath"); Logger().info("Opening file: $filePath");
try { try {
final tableData = await _service.parseStructureFile(filePath); final FunctionData functionData = await _service.parseXmlFile(filePath);
// Update controller state // Update controller state
tableName = tableData.tableName; chineseName = functionData.chineseName;
chineseName = tableData.chineseName; objectId = functionData.objectId;
objectId = tableData.objectId;
// Update data sources // Update data sources
(fieldsSource as FieldsDataSource).updateData(tableData.fields); (inputSource as FieldsDataSource).updateData(functionData.inputFields);
(outputSource as FieldsDataSource).updateData(functionData.outputFields);
// CallFunction对象 // CallFunction对象
_memoryTable = CallFunction(tableName: tableName, columns: tableData.fields); _modle = CallFunction(
functionName: tableName,
inputParameters: functionData.inputFields,
outputParameters: functionData.inputFields,
);
// Clear any previous error // Clear any previous error
_errorMessage = null; _errorMessage = null;
@ -83,13 +98,13 @@ class CallFunctionController extends BaseContentController {
// //
void updateFieldSelection(int index, bool isSelected) { void updateFieldSelection(int index, bool isSelected) {
final fields = (fieldsSource as FieldsDataSource).data; final fields = (inputSource as FieldsDataSource).data;
if (index >= 0 && index < fields.length) { if (index >= 0 && index < fields.length) {
fields[index].isSelected = isSelected; fields[index].isSelected = isSelected;
fieldsSource.notifyListeners(); inputSource.notifyListeners();
// CallFunction // CallFunction
_memoryTable.columns[index].isSelected = isSelected; _modle.inputParameters[index].isSelected = isSelected;
notifyListeners(); notifyListeners();
} }
} }

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

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

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

@ -1,12 +1,10 @@
// memory_table_service.dart // memory_table_service.dart
import 'dart:io'; 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/data/std_fields_cache.dart';
import 'package:win_text_editor/shared/models/std_filed.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:win_text_editor/shared/uft_std_fields/field_data_service.dart';
import 'package:xml/xml.dart' as xml; import 'package:xml/xml.dart' as xml;
import 'package:path/path.dart' as path;
import 'package:win_text_editor/framework/controllers/logger.dart'; import 'package:win_text_editor/framework/controllers/logger.dart';
class CallFunctionService { class CallFunctionService {
@ -14,11 +12,22 @@ class CallFunctionService {
CallFunctionService(this._logger); 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 { try {
// 1. Check file extension // 1. Check file extension
if (!filePath.toLowerCase().endsWith('.uftstructure')) { final extendFileName = filePath.toLowerCase().split('.').last;
throw const FormatException("文件扩展名必须是.uftstructure"); final String? rootNodeType = _functionRootTypeMap[extendFileName];
if (rootNodeType == null) {
throw const FormatException("文件扩展名不正确!");
} }
// 2. metadata stdfield.stfield // 2. metadata stdfield.stfield
@ -35,27 +44,26 @@ class CallFunctionService {
final content = await file.readAsString(); final content = await file.readAsString();
final document = xml.XmlDocument.parse(content); final document = xml.XmlDocument.parse(content);
final structureNode = document.findAllElements('structure:Structure').firstOrNull; final rootNode = document.findAllElements(rootNodeType).firstOrNull;
if (structureNode == null) { if (rootNode == null) {
throw const FormatException("文件格式错误:缺少structure:Structure节点"); throw const FormatException("文件格式错误:缺少支持的根节点");
} }
// 4. Get basic info // 4. Get basic info
final fileNameWithoutExt = path.basenameWithoutExtension(filePath); final chineseName = rootNode.getAttribute('chineseName') ?? '';
final chineseName = structureNode.getAttribute('chineseName') ?? ''; final objectId = rootNode.getAttribute('objectId') ?? '';
final objectId = structureNode.getAttribute('objectId') ?? '';
// 5. Process properties (fields) // 5. Process inputParameters (fields)
final properties = document.findAllElements('properties'); final inputParameters = document.findAllElements('inputParameters');
final fields = <Field>[]; final inputFields = <Field>[];
int index = 1; int index = 1;
for (final property in properties) { for (final parameter in inputParameters) {
final id = property.getAttribute('id') ?? ''; final id = parameter.getAttribute('id') ?? '';
// //
final stdField = StdFieldsCache.getData(id); final stdField = StdFieldsCache.getData(id);
fields.add( inputFields.add(
Field( Field(
(index++).toString(), // (index++).toString(), //
id, // id, //
@ -65,41 +73,30 @@ class CallFunctionService {
); );
} }
// 6. Process indexes // 6. Process outputParameters
final indexes = document.findAllElements('indexs'); final outputParameters = document.findAllElements('outputParameters');
final indexList = <Index>[]; final outputFields = <Field>[];
index = 1;
for (final indexNode in indexes) {
final name = indexNode.getAttribute('name') ?? ''; for (final parameter in outputParameters) {
final containerType = indexNode.getAttribute('containerType'); final id = parameter.getAttribute('id') ?? '';
final isPrimary = containerType == null; //
final rule = containerType ?? ''; final stdField = StdFieldsCache.getData(id);
outputFields.add(
// Get all index fields Field(
final items = indexNode.findAllElements('items'); (index++).toString(), //
final fieldsList = id, //
items stdField?.chineseName ?? '', //
.map((item) => item.getAttribute('attrname') ?? '') stdField?.dateType ?? '', //
.where((f) => f.isNotEmpty)
.toList();
final indexFields = fieldsList.join(',');
indexList.add(
Index(
name, //
isPrimary, //
indexFields, //
rule, //
), ),
); );
} }
return TableData( return FunctionData(
tableName: fileNameWithoutExt,
chineseName: chineseName, chineseName: chineseName,
objectId: objectId, objectId: objectId,
fields: fields.isNotEmpty ? fields : FieldDataService.getDefaultFields(), inputFields: inputFields.isNotEmpty ? inputFields : FieldDataService.getDefaultFields(),
indexes: indexList.isNotEmpty ? indexList : FieldDataService.getDefaultIndexes(), outputFields: outputFields.isNotEmpty ? outputFields : FieldDataService.getDefaultFields(),
); );
} on xml.XmlParserException catch (e) { } on xml.XmlParserException catch (e) {
_logger.error("XML解析错误: ${e.message}"); _logger.error("XML解析错误: ${e.message}");
@ -111,18 +108,16 @@ class CallFunctionService {
} }
} }
class TableData { class FunctionData {
final String tableName;
final String chineseName; final String chineseName;
final String objectId; final String objectId;
final List<Field> fields; final List<Field> inputFields;
final List<Index> indexes; final List<Field> outputFields;
TableData({ FunctionData({
required this.tableName,
required this.chineseName, required this.chineseName,
required this.objectId, required this.objectId,
required this.fields, required this.inputFields,
required this.indexes, 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 {
final CallFunctionController controller; final CallFunctionController controller;
const CallFunctionLeftSide({super.key, required this.controller}); const CallFunctionLeftSide({super.key, required this.controller});
Widget _buildTextFieldRow(String label, String value) { Widget _buildTextFieldRow(String label, String value, double width) {
return Row( return Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text('$label:'), Text('$label:'),
SizedBox( SizedBox(
width: 200, width: width,
child: TextField( child: TextField(
controller: TextEditingController(text: value), controller: TextEditingController(text: value),
readOnly: true, readOnly: true,
@ -38,9 +38,8 @@ class CallFunctionLeftSide extends StatelessWidget {
spacing: 16, spacing: 16,
runSpacing: 8, runSpacing: 8,
children: [ children: [
_buildTextFieldRow('名称', controller.tableName), _buildTextFieldRow('功能号', controller.objectId, 100),
_buildTextFieldRow('中文名', controller.chineseName), _buildTextFieldRow('中文名', controller.chineseName, 350),
_buildTextFieldRow('对象编号', controller.objectId),
], ],
), ),
), ),
@ -49,12 +48,12 @@ class CallFunctionLeftSide extends StatelessWidget {
const SizedBox(height: 8), const SizedBox(height: 8),
const Padding( const Padding(
padding: EdgeInsets.all(8.0), padding: EdgeInsets.all(8.0),
child: Text('字段列表', style: TextStyle(fontWeight: FontWeight.bold)), child: Text('入参', style: TextStyle(fontWeight: FontWeight.bold)),
), ),
Expanded( Expanded(
flex: 6, flex: 6,
child: FieldsDataGrid( child: FieldsDataGrid(
fieldsSource: controller.fieldsSource as FieldsDataSource, fieldsSource: controller.inputSource as FieldsDataSource,
onSelectionChanged: (index, isSelected) { onSelectionChanged: (index, isSelected) {
controller.updateFieldSelection(index, isSelected); controller.updateFieldSelection(index, isSelected);
}, },
@ -62,7 +61,16 @@ class CallFunctionLeftSide extends StatelessWidget {
), ),
const Padding( const Padding(
padding: EdgeInsets.all(8.0), 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);
},
),
), ),
], ],
); );

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

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

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

@ -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_mode.dart';
import 'package:win_text_editor/modules/content_search/models/search_result.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 { class ResultsView extends StatelessWidget {
const ResultsView({super.key}); const ResultsView({super.key});
@ -109,23 +110,8 @@ class ResultsView extends StatelessWidget {
headerRowHeight: 32, headerRowHeight: 32,
source: LocateDataSource(controller), source: LocateDataSource(controller),
columns: [ columns: [
GridColumn( MyGridColumn(columnName: 'file', label: '文件(行号)', minimumWidth: 300),
columnName: 'file', MyGridColumn(columnName: 'content', label: '内容'),
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)),
),
),
], ],
selectionMode: SelectionMode.multiple, selectionMode: SelectionMode.multiple,
navigationMode: GridNavigationMode.cell, navigationMode: GridNavigationMode.cell,
@ -146,23 +132,8 @@ class ResultsView extends StatelessWidget {
headerRowHeight: 32, headerRowHeight: 32,
source: CountDataSource(controller), source: CountDataSource(controller),
columns: [ columns: [
GridColumn( MyGridColumn(columnName: 'keyword', label: '关键词', minimumWidth: 300),
columnName: 'keyword', MyGridColumn(columnName: 'count', label: '匹配数量'),
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)),
),
),
], ],
selectionMode: SelectionMode.multiple, selectionMode: SelectionMode.multiple,
navigationMode: GridNavigationMode.cell, navigationMode: GridNavigationMode.cell,

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

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

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

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

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

@ -41,14 +41,17 @@ class IndexesDataSource extends SelectableDataSource<Index> {
row.getCells().map<Widget>((cell) { row.getCells().map<Widget>((cell) {
if (cell.columnName == 'select') { if (cell.columnName == 'select') {
return Center( return Center(
child: Radio<String>( child: Transform.scale(
value: index.id, // 使value scale: 0.75,
groupValue: _selectedId, // ID child: Radio<String>(
onChanged: (String? value) { value: index.id, // 使value
_selectedId = value; groupValue: _selectedId, // ID
toggleRowSelection(rowIndex, value != null); onChanged: (String? value) {
notifyListeners(); // _selectedId = value;
}, toggleRowSelection(rowIndex, value != null);
notifyListeners(); //
},
),
), ),
); );
} }

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

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_datagrid/datagrid.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/index_data_source.dart';
import 'package:win_text_editor/modules/memory_table/controllers/memory_table_controller.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/field_data_source.dart';
import 'package:win_text_editor/shared/uft_std_fields/fields_data_grid.dart'; import 'package:win_text_editor/shared/uft_std_fields/fields_data_grid.dart';
@ -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) { Widget _buildIndexesDataGrid(MemoryTableController controller) {
final indexesSource = controller.indexesSource as IndexesDataSource; final indexesSource = controller.indexesSource as IndexesDataSource;
@ -63,26 +56,10 @@ class MemoryTableLeftSide extends StatelessWidget {
), ),
width: 60, width: 60,
), ),
GridColumn( MyGridColumn(columnName: 'indexName', label: '索引名称', minimumWidth: 120),
columnName: 'indexName', MyGridColumn(columnName: 'isPrimary', label: '是否主键', minimumWidth: 100),
label: _buildGridHeader('索引名称'), MyGridColumn(columnName: 'indexFields', label: '索引字段', minimumWidth: 150),
minimumWidth: 120, MyGridColumn(columnName: 'rule', label: '规则', minimumWidth: 200),
),
GridColumn(
columnName: 'isPrimary',
label: _buildGridHeader('是否主键'),
minimumWidth: 100,
),
GridColumn(
columnName: 'indexFields',
label: _buildGridHeader('索引字段'),
minimumWidth: 150,
),
GridColumn(
columnName: 'rule',
label: _buildGridHeader('规则'),
minimumWidth: 200,
),
], ],
onCellTap: (details) { onCellTap: (details) {
if (details.column.columnName == 'select') { if (details.column.columnName == 'select') {

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

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

4
win_text_editor/lib/modules/module_router.dart

@ -1,6 +1,8 @@
// modules/tab_content_registry.dart // modules/tab_content_registry.dart
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:win_text_editor/framework/models/tab_model.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/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_compare/widgets/data_compare_view.dart';
import 'package:win_text_editor/modules/data_format/controllers/data_format_controller.dart'; import 'package:win_text_editor/modules/data_format/controllers/data_format_controller.dart';
@ -38,6 +40,7 @@ class ModuleRouter {
RouterKey.dataCompare: (tab) => DataCompareController(), RouterKey.dataCompare: (tab) => DataCompareController(),
RouterKey.memoryTable: (tab) => MemoryTableController(), RouterKey.memoryTable: (tab) => MemoryTableController(),
RouterKey.uftComponent: (tab) => UftComponentController(), RouterKey.uftComponent: (tab) => UftComponentController(),
RouterKey.callFunction: (tab) => CallFunctionController(),
RouterKey.demo: (tab) => DemoController(), RouterKey.demo: (tab) => DemoController(),
}; };
@ -49,6 +52,7 @@ class ModuleRouter {
RouterKey.dataCompare: (tab, controller) => DataCompareView(tabId: tab.id), RouterKey.dataCompare: (tab, controller) => DataCompareView(tabId: tab.id),
RouterKey.memoryTable: (tab, controller) => MemoryTableView(tabId: tab.id), RouterKey.memoryTable: (tab, controller) => MemoryTableView(tabId: tab.id),
RouterKey.uftComponent: (tab, controller) => UftComponentView(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), 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';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:syncfusion_flutter_datagrid/datagrid.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/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:win_text_editor/shared/models/template_node.dart';
import 'package:file_picker/file_picker.dart'; import 'package:file_picker/file_picker.dart';
import 'dart:io'; import 'dart:io';
@ -110,27 +111,12 @@ class TemplateGridView extends StatelessWidget {
final dataSource = _TemplateItemDataSource(rows: rows, selectedNodes: selectedNodes); final dataSource = _TemplateItemDataSource(rows: rows, selectedNodes: selectedNodes);
// //
final columns = <GridColumn>[ final columns = <MyGridColumn>[
GridColumn( MyGridColumn(columnName: 'index', minimumWidth: 60, label: '序号'),
columnName: 'index',
width: 60,
label: Container(
padding: const EdgeInsets.all(8.0),
color: Colors.grey[200],
alignment: Alignment.center,
child: const Text('序号'),
),
),
...selectedNodes.map((node) { ...selectedNodes.map((node) {
return GridColumn( return MyGridColumn(
columnName: node.path, columnName: node.path,
label: Container( label: node.isAttribute ? node.name.substring(1) : node.name,
padding: const EdgeInsets.all(8.0),
alignment: Alignment.center,
color: Colors.grey[200],
child: Text(node.isAttribute ? node.name.substring(1) : node.name),
),
); );
}).toList(), }).toList(),
]; ];

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

@ -54,13 +54,16 @@ class TemplateTreeView extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
if (templateNode.children.isEmpty) // if (templateNode.children.isEmpty) //
Checkbox( Transform.scale(
value: templateNode.isChecked, scale: 0.75,
onChanged: (value) { child: Checkbox(
if (value != null) { value: templateNode.isChecked,
controller.toggleNodeCheck(templateNode); onChanged: (value) {
} if (value != null) {
}, controller.toggleNodeCheck(templateNode);
}
},
),
), ),
isAttribute isAttribute
? const Icon(Icons.code, size: 16, color: Colors.grey) ? const Icon(Icons.code, size: 16, color: Colors.grey)

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

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_datagrid/datagrid.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/modules/uft_component/controllers/component_source.dart';
import 'package:win_text_editor/shared/components/my_grid_column.dart';
class ComponentGrid extends StatefulWidget { class ComponentGrid extends StatefulWidget {
final ComponentSource componentsSource; final ComponentSource componentsSource;
@ -15,14 +16,6 @@ class ComponentGrid extends StatefulWidget {
class ComponentGridState extends State<ComponentGrid> { class ComponentGridState extends State<ComponentGrid> {
final DataGridController _dataGridController = DataGridController(); 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) { void scrollToIndex(int index) {
_dataGridController.scrollToRow(index.toDouble()); _dataGridController.scrollToRow(index.toDouble());
_dataGridController.selectedIndex = index; _dataGridController.selectedIndex = index;
@ -49,17 +42,9 @@ class ComponentGridState extends State<ComponentGrid> {
columnWidthMode: ColumnWidthMode.fitByCellValue, columnWidthMode: ColumnWidthMode.fitByCellValue,
selectionMode: SelectionMode.single, selectionMode: SelectionMode.single,
columns: [ columns: [
GridColumn(columnName: 'id', label: _buildGridHeader('序号'), minimumWidth: 80), MyGridColumn(columnName: 'id', label: '序号', minimumWidth: 80),
GridColumn( MyGridColumn(columnName: 'name', label: '名称', minimumWidth: 120),
columnName: 'name', MyGridColumn(columnName: 'chineseName', label: '中文名', minimumWidth: 120),
label: _buildGridHeader('名称'),
minimumWidth: 120,
),
GridColumn(
columnName: 'chineseName',
label: _buildGridHeader('中文名'),
minimumWidth: 120,
),
], ],
onSelectionChanged: (addedRows, removedRows) { onSelectionChanged: (addedRows, removedRows) {
if (addedRows.isNotEmpty) { if (addedRows.isNotEmpty) {

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

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

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

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

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

@ -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 @@
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)),
),
);
}

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

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

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

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

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

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

Loading…
Cancel
Save