Gesture editor logic done. #4

Merged
debuggerx merged 6 commits from dev into master 4 years ago

@ -8,6 +8,109 @@ import 'package:uuid/uuid.dart';
typedef OnEditEnd(GestureProp prop); typedef OnEditEnd(GestureProp prop);
class _TreeNode<T> {
late List<T> nodes;
bool get fullFiled => nodes.every((element) => (element as _TreeNode).fullFiled);
T get availableNode => nodes.firstWhere((element) => !(element as _TreeNode).fullFiled);
}
class GestureDirectionNode extends _TreeNode {
GestureDirection direction;
bool available = true;
GestureDirectionNode({required this.direction});
@override
get fullFiled => !available;
get availableNode => null;
}
class SchemeGestureNode extends _TreeNode<GestureDirectionNode> {
Gesture type;
SchemeGestureNode({required this.type}) {
switch (type) {
case Gesture.tap:
nodes = [GestureDirectionNode(direction: GestureDirection.none)];
break;
case Gesture.swipe:
nodes = [
GestureDirectionNode(direction: GestureDirection.up),
GestureDirectionNode(direction: GestureDirection.down),
GestureDirectionNode(direction: GestureDirection.left),
GestureDirectionNode(direction: GestureDirection.right),
];
break;
case Gesture.pinch:
nodes = [
GestureDirectionNode(direction: GestureDirection.pinch_in),
GestureDirectionNode(direction: GestureDirection.pinch_out),
];
}
}
}
class SchemeTreeNode extends _TreeNode<SchemeGestureNode> {
int fingers;
SchemeTreeNode({required this.fingers});
@override
List<SchemeGestureNode> nodes = [
SchemeGestureNode(type: Gesture.tap),
SchemeGestureNode(type: Gesture.swipe),
SchemeGestureNode(type: Gesture.pinch),
];
}
class SchemeTree extends _TreeNode<SchemeTreeNode> {
@override
List<SchemeTreeNode> nodes = [
SchemeTreeNode(fingers: 3),
SchemeTreeNode(fingers: 4),
SchemeTreeNode(fingers: 5),
];
@override
String toString() => '''
3:
tap: ${nodes[0].nodes[0].nodes[0].available}
swipe:
: ${nodes[0].nodes[1].nodes[0].available}
: ${nodes[0].nodes[1].nodes[1].available}
: ${nodes[0].nodes[1].nodes[2].available}
: ${nodes[0].nodes[1].nodes[3].available}
pinch:
in: ${nodes[0].nodes[2].nodes[0].available}
out:${nodes[0].nodes[2].nodes[1].available}
4:
tap: ${nodes[1].nodes[0].nodes[0].available}
swipe:
: ${nodes[1].nodes[1].nodes[0].available}
: ${nodes[1].nodes[1].nodes[1].available}
: ${nodes[1].nodes[1].nodes[2].available}
: ${nodes[1].nodes[1].nodes[3].available}
pinch:
in: ${nodes[1].nodes[2].nodes[0].available}
out:${nodes[1].nodes[2].nodes[1].available}
5:
tap: ${nodes[2].nodes[0].nodes[0].available}
swipe:
: ${nodes[2].nodes[1].nodes[0].available}
: ${nodes[2].nodes[1].nodes[1].available}
: ${nodes[2].nodes[1].nodes[2].available}
: ${nodes[2].nodes[1].nodes[3].available}
pinch:
in: ${nodes[2].nodes[2].nodes[0].available}
out:${nodes[2].nodes[2].nodes[1].available}
''';
}
@ProviderModel(copyable: true) @ProviderModel(copyable: true)
class Scheme { class Scheme {
@ProviderModelProp() @ProviderModelProp()
@ -41,6 +144,16 @@ class Scheme {
Scheme.create({this.name, this.description, this.gestures}) { Scheme.create({this.name, this.description, this.gestures}) {
this.id = Uuid().v1(); this.id = Uuid().v1();
} }
SchemeTree buildSchemeTree() {
var schemeTree = SchemeTree();
this.gestures!.forEach((gesture) {
var schemeTreeNode = schemeTree.nodes.firstWhere((ele) => ele.fingers == gesture.fingers);
var schemeGestureNode = schemeTreeNode.nodes.firstWhere((element) => element.type == gesture.gesture);
schemeGestureNode.nodes.firstWhere((element) => element.direction == gesture.direction).available = false;
});
return schemeTree;
}
} }
enum Gesture { enum Gesture {

@ -1,10 +1,11 @@
import 'package:dde_gesture_manager/extensions.dart'; import 'package:dde_gesture_manager/extensions.dart';
import 'package:dde_gesture_manager/models/content_layout.provider.dart';
import 'package:dde_gesture_manager/models/scheme.provider.dart';
import 'package:dde_gesture_manager/pages/gesture_editor.dart'; import 'package:dde_gesture_manager/pages/gesture_editor.dart';
import 'package:dde_gesture_manager/pages/local_manager.dart'; import 'package:dde_gesture_manager/pages/local_manager.dart';
import 'package:dde_gesture_manager/pages/market.dart'; import 'package:dde_gesture_manager/pages/market.dart';
import 'package:flutter/material.dart';
import 'package:dde_gesture_manager/models/content_layout.provider.dart';
import 'package:dde_gesture_manager/utils/helper.dart'; import 'package:dde_gesture_manager/utils/helper.dart';
import 'package:flutter/material.dart';
class Content extends StatefulWidget { class Content extends StatefulWidget {
const Content({Key? key}) : super(key: key); const Content({Key? key}) : super(key: key);
@ -13,6 +14,10 @@ class Content extends StatefulWidget {
_ContentState createState() => _ContentState(); _ContentState createState() => _ContentState();
} }
class CopiedGesturePropProvider extends GesturePropProvider {
CopiedGesturePropProvider.empty() : super.empty();
}
class _ContentState extends State<Content> { class _ContentState extends State<Content> {
double? preWindowWidth; double? preWindowWidth;
@ -21,10 +26,17 @@ class _ContentState extends State<Content> {
var windowWidth = MediaQuery.of(context).size.width; var windowWidth = MediaQuery.of(context).size.width;
var preferredPanelsStatus = H.getPreferredPanelsStatus(windowWidth); var preferredPanelsStatus = H.getPreferredPanelsStatus(windowWidth);
var widthChanged = preWindowWidth != null && preWindowWidth != windowWidth; var widthChanged = preWindowWidth != null && preWindowWidth != windowWidth;
var widget = ChangeNotifierProvider( var widget = MultiProvider(
providers: [
ChangeNotifierProvider(
create: (context) => ContentLayoutProvider() create: (context) => ContentLayoutProvider()
..localManagerOpened = preferredPanelsStatus.localManagerPanelOpened ..localManagerOpened = preferredPanelsStatus.localManagerPanelOpened
..marketOpened = preferredPanelsStatus.marketPanelOpened, ..marketOpened = preferredPanelsStatus.marketPanelOpened,
),
ChangeNotifierProvider(
create: (context) => CopiedGesturePropProvider.empty(),
),
],
builder: (context, child) { builder: (context, child) {
if (widthChanged && mounted) { if (widthChanged && mounted) {
Future.microtask( Future.microtask(

@ -5,6 +5,7 @@ import 'package:dde_gesture_manager/models/content_layout.provider.dart';
import 'package:dde_gesture_manager/models/scheme.dart'; import 'package:dde_gesture_manager/models/scheme.dart';
import 'package:dde_gesture_manager/models/scheme.provider.dart'; import 'package:dde_gesture_manager/models/scheme.provider.dart';
import 'package:dde_gesture_manager/models/settings.provider.dart'; import 'package:dde_gesture_manager/models/settings.provider.dart';
import 'package:dde_gesture_manager/pages/content.dart';
import 'package:dde_gesture_manager/utils/helper.dart'; import 'package:dde_gesture_manager/utils/helper.dart';
import 'package:dde_gesture_manager/utils/keyboard_mapper.dart'; import 'package:dde_gesture_manager/utils/keyboard_mapper.dart';
import 'package:dde_gesture_manager/widgets/dde_button.dart'; import 'package:dde_gesture_manager/widgets/dde_button.dart';
@ -13,6 +14,7 @@ import 'package:dde_gesture_manager/widgets/table_cell_shortcut_listener.dart';
import 'package:dde_gesture_manager/widgets/table_cell_text_field.dart'; import 'package:dde_gesture_manager/widgets/table_cell_text_field.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:uuid/uuid.dart';
const double _headingRowHeight = 56; const double _headingRowHeight = 56;
const double _scrollBarWidth = 14; const double _scrollBarWidth = 14;
@ -152,7 +154,86 @@ class GestureEditor extends StatelessWidget {
), ),
), ),
), ),
Container(height: 10), Builder(builder: (context) {
var gesturePropProvider = context.watch<GesturePropProvider>();
var copiedGesturePropProvider = context.watch<CopiedGesturePropProvider>();
var schemeTree = schemeProvider.buildSchemeTree();
return Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
DButton.add(
enabled: !gesturePropProvider.editMode! && !schemeTree.fullFiled,
onTap: () {
var schemeProvider = context.read<SchemeProvider>();
context.read<SchemeProvider>().setProps(
gestures: [
...?schemeProvider.gestures,
H.getNextAvailableGestureProp(schemeProvider.buildSchemeTree())!,
]..sort());
},
),
DButton.delete(
enabled: gesturePropProvider != GestureProp.empty() && !gesturePropProvider.editMode!,
onTap: () {
var schemeProvider = context.read<SchemeProvider>();
var index = schemeProvider.gestures?.indexWhere((e) => e.id == gesturePropProvider.id);
var newGestures = [
...?schemeProvider.gestures?..removeAt(index!),
];
context.read<SchemeProvider>().setProps(gestures: newGestures);
if (newGestures.length > 0)
gesturePropProvider.copyFrom(
newGestures[(index ?? 0) > newGestures.length - 1 ? newGestures.length - 1 : index ?? 0]
..editMode = false);
},
),
DButton.duplicate(
enabled: gesturePropProvider != GestureProp.empty() && !gesturePropProvider.editMode!,
onTap: () {
var schemeProvider = context.read<SchemeProvider>();
context.read<CopiedGesturePropProvider>().copyFrom(
schemeProvider.gestures!.firstWhere((element) => element.id == gesturePropProvider.id));
/// todo: give some info to UI.
},
),
DButton.paste(
enabled: copiedGesturePropProvider != CopiedGesturePropProvider.empty() &&
!gesturePropProvider.editMode! &&
!schemeTree.fullFiled,
onTap: () {
var schemeTree = context.read<SchemeProvider>().buildSchemeTree();
late GestureProp newGestureProp;
if (schemeTree.nodes
.firstWhere((e) => e.fingers == copiedGesturePropProvider.fingers)
.nodes
.firstWhere((e) => e.type == copiedGesturePropProvider.gesture)
.nodes
.firstWhere((e) => e.direction == copiedGesturePropProvider.direction)
.available) {
newGestureProp = GestureProp.empty()..copyFrom(copiedGesturePropProvider);
} else {
newGestureProp = H.getNextAvailableGestureProp(schemeProvider.buildSchemeTree())!;
newGestureProp.type = copiedGesturePropProvider.type;
newGestureProp.command = copiedGesturePropProvider.command;
newGestureProp.remark = copiedGesturePropProvider.remark;
}
newGestureProp.id = Uuid().v1();
context.read<SchemeProvider>().setProps(
gestures: [
...?schemeProvider.gestures,
newGestureProp,
]..sort());
},
),
]
.map((e) => Padding(
padding: const EdgeInsets.only(top: 3.0, right: 10.0, bottom: 8.0),
child: e,
))
.toList(),
);
}),
Container( Container(
height: 300, height: 300,
decoration: BoxDecoration( decoration: BoxDecoration(
@ -202,16 +283,45 @@ List<DDataRow> _buildDataRows(List<GestureProp>? gestures, BuildContext context)
} }
}, },
selected: selected, selected: selected,
cells: editing ? _buildRowCellsEditing(context, gesture) : _buildRowCellsNormal(context, selected, gesture), cells: editing ? _buildRowCellsEditing(context) : _buildRowCellsNormal(context, selected, gesture),
); );
}).toList(); }).toList();
List<DDataCell> _buildRowCellsEditing(BuildContext context, GestureProp gesture) => [ List<DDataCell> _buildRowCellsEditing(BuildContext context) {
var gesture = context.read<GesturePropProvider>();
var schemeTree = context.read<SchemeProvider>().buildSchemeTree();
var availableFingers = schemeTree.nodes.where((node) => !node.fullFiled).map((e) => e.fingers);
if (!availableFingers.contains(gesture.fingers)) {
availableFingers = [...availableFingers, gesture.fingers!]..sort();
}
var availableGestures = schemeTree.nodes
.firstWhere((node) => node.fingers == gesture.fingers)
.nodes
.where((node) => !node.fullFiled)
.map((e) => e.type);
if (!availableGestures.any((type) => type == gesture.gesture)) {
availableGestures = [...availableGestures, gesture.gesture!]..sort();
}
var availableDirection = schemeTree.nodes
.firstWhere((node) => node.fingers == gesture.fingers)
.nodes
.firstWhere((node) => node.type == gesture.gesture)
.nodes
.where((node) => !node.fullFiled)
.map((e) => e.direction);
if (!availableDirection.any((direction) => direction == gesture.direction)) {
availableDirection = [...availableDirection, gesture.direction!]..sort((a, b) => a.index - b.index);
}
return [
DButton.dropdown( DButton.dropdown(
enabled: true, enabled: true,
child: DropdownButton<int>( child: DropdownButton<int>(
icon: Icon(Icons.keyboard_arrow_down_rounded), icon: Icon(Icons.keyboard_arrow_down_rounded),
items: [3, 4, 5] items: availableFingers
.map( .map(
(e) => DropdownMenuItem<int>( (e) => DropdownMenuItem<int>(
child: Text('$e'), child: Text('$e'),
@ -219,7 +329,7 @@ List<DDataCell> _buildRowCellsEditing(BuildContext context, GestureProp gesture)
), ),
) )
.toList(), .toList(),
value: context.watch<GesturePropProvider>().fingers, value: gesture.fingers,
onChanged: (value) => context.read<GesturePropProvider>().setProps( onChanged: (value) => context.read<GesturePropProvider>().setProps(
fingers: value, fingers: value,
editMode: true, editMode: true,
@ -229,10 +339,10 @@ List<DDataCell> _buildRowCellsEditing(BuildContext context, GestureProp gesture)
), ),
DButton.dropdown( DButton.dropdown(
enabled: true, enabled: true,
width: 60.0, width: 100.0,
child: DropdownButton<Gesture>( child: DropdownButton<Gesture>(
icon: Icon(Icons.keyboard_arrow_down_rounded), icon: Icon(Icons.keyboard_arrow_down_rounded),
items: Gesture.values items: availableGestures
.map( .map(
(e) => DropdownMenuItem<Gesture>( (e) => DropdownMenuItem<Gesture>(
child: Text( child: Text(
@ -243,7 +353,7 @@ List<DDataCell> _buildRowCellsEditing(BuildContext context, GestureProp gesture)
), ),
) )
.toList(), .toList(),
value: context.watch<GesturePropProvider>().gesture, value: gesture.gesture,
onChanged: (value) => context.read<GesturePropProvider>().setProps( onChanged: (value) => context.read<GesturePropProvider>().setProps(
gesture: value, gesture: value,
editMode: true, editMode: true,
@ -256,7 +366,7 @@ List<DDataCell> _buildRowCellsEditing(BuildContext context, GestureProp gesture)
width: 100.0, width: 100.0,
child: DropdownButton<GestureDirection>( child: DropdownButton<GestureDirection>(
icon: Icon(Icons.keyboard_arrow_down_rounded), icon: Icon(Icons.keyboard_arrow_down_rounded),
items: GestureDirection.values items: availableDirection
.map( .map(
(e) => DropdownMenuItem<GestureDirection>( (e) => DropdownMenuItem<GestureDirection>(
child: Text( child: Text(
@ -267,7 +377,7 @@ List<DDataCell> _buildRowCellsEditing(BuildContext context, GestureProp gesture)
), ),
) )
.toList(), .toList(),
value: context.watch<GesturePropProvider>().direction, value: gesture.direction,
onChanged: (value) => context.read<GesturePropProvider>().setProps( onChanged: (value) => context.read<GesturePropProvider>().setProps(
direction: value, direction: value,
editMode: true, editMode: true,
@ -291,7 +401,7 @@ List<DDataCell> _buildRowCellsEditing(BuildContext context, GestureProp gesture)
), ),
) )
.toList(), .toList(),
value: context.watch<GesturePropProvider>().type, value: gesture.type,
onChanged: (value) => context.read<GesturePropProvider>().setProps( onChanged: (value) => context.read<GesturePropProvider>().setProps(
type: value, type: value,
command: '', command: '',
@ -310,6 +420,7 @@ List<DDataCell> _buildRowCellsEditing(BuildContext context, GestureProp gesture)
), ),
), ),
].map((e) => DDataCell(e)).toList(); ].map((e) => DDataCell(e)).toList();
}
Widget _buildCommandCellsEditing(BuildContext context) { Widget _buildCommandCellsEditing(BuildContext context) {
var gesture = context.read<GesturePropProvider>(); var gesture = context.read<GesturePropProvider>();
@ -414,9 +525,13 @@ List<DDataCell> _buildRowCellsNormal(BuildContext context, bool selected, Gestur
}, },
).toList(), ).toList(),
) )
: (gesture.type == GestureType.built_in
? Text(
('${LocaleKeys.built_in_commands}.${(builtInCommands.contains(gesture.command) ? gesture.command : builtInCommands.first)!}')
.tr())
: Text( : Text(
gesture.command ?? '', gesture.command ?? '',
), )),
Text( Text(
gesture.remark ?? '', gesture.remark ?? '',
), ),

@ -28,7 +28,7 @@ class _HomePageState extends State<HomePage> {
"direction": "down", "direction": "down",
"fingers": 3, "fingers": 3,
"type": "shortcut", "type": "shortcut",
"command": "ctrl+w", "command": "Control_L+w",
"remark": "close current page." "remark": "close current page."
}, },
{ {
@ -36,7 +36,7 @@ class _HomePageState extends State<HomePage> {
"direction": "up", "direction": "up",
"fingers": 3, "fingers": 3,
"type": "shortcut", "type": "shortcut",
"command": "ctrl+alt+t", "command": "Control_L+Alt_L+t",
"remark": "reopen last closed page." "remark": "reopen last closed page."
}, },
{ {
@ -44,7 +44,7 @@ class _HomePageState extends State<HomePage> {
"direction": "in", "direction": "in",
"fingers": 4, "fingers": 4,
"type": "shortcut", "type": "shortcut",
"command": "ctrl+alt+f", "command": "Control_L+Alt_L+f",
"remark": "search files." "remark": "search files."
}, },
{ {

@ -2,6 +2,7 @@ import 'package:dde_gesture_manager/constants/constants.dart';
import 'package:dde_gesture_manager/extensions.dart'; import 'package:dde_gesture_manager/extensions.dart';
import 'package:dde_gesture_manager/models/content_layout.provider.dart'; import 'package:dde_gesture_manager/models/content_layout.provider.dart';
import 'package:dde_gesture_manager/models/local_schemes_provider.dart'; import 'package:dde_gesture_manager/models/local_schemes_provider.dart';
import 'package:dde_gesture_manager/models/scheme.dart';
import 'package:dde_gesture_manager/models/scheme.provider.dart'; import 'package:dde_gesture_manager/models/scheme.provider.dart';
import 'package:dde_gesture_manager/models/settings.provider.dart'; import 'package:dde_gesture_manager/models/settings.provider.dart';
import 'package:dde_gesture_manager/widgets/dde_button.dart'; import 'package:dde_gesture_manager/widgets/dde_button.dart';
@ -111,6 +112,7 @@ class _LocalManagerState extends State<LocalManager> {
setState(() { setState(() {
_selectedIndex = index; _selectedIndex = index;
}); });
context.read<GesturePropProvider>().copyFrom(GestureProp.empty());
}, },
child: MouseRegion( child: MouseRegion(
cursor: SystemMouseCursors.click, cursor: SystemMouseCursors.click,

@ -1,9 +1,10 @@
import 'package:dde_gesture_manager/constants/constants.dart';
import 'package:dde_gesture_manager/extensions.dart';
import 'package:dde_gesture_manager/models/content_layout.provider.dart'; import 'package:dde_gesture_manager/models/content_layout.provider.dart';
import 'package:dde_gesture_manager/models/scheme.dart'; import 'package:dde_gesture_manager/models/scheme.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:dde_gesture_manager/constants/constants.dart'; import 'package:uuid/uuid.dart';
import 'package:dde_gesture_manager/extensions.dart';
class H { class H {
H._(); H._();
@ -105,6 +106,18 @@ class H {
var rgba = list.map<int>((e) => int.parse(e) ~/ 257).toList(); var rgba = list.map<int>((e) => int.parse(e) ~/ 257).toList();
return Color.fromARGB(rgba[3], rgba[0], rgba[1], rgba[2]); return Color.fromARGB(rgba[3], rgba[0], rgba[1], rgba[2]);
} }
static GestureProp? getNextAvailableGestureProp(SchemeTree tree) {
var gestureProp = GestureProp.empty()
..id = Uuid().v1()
..type = GestureType.built_in
..command = builtInCommands.first;
if (tree.fullFiled) return null;
gestureProp.fingers = tree.availableNode.fingers;
gestureProp.gesture = tree.availableNode.availableNode.type;
gestureProp.direction = tree.availableNode.availableNode.availableNode.direction;
return gestureProp;
}
} }
class PreferredPanelsStatus { class PreferredPanelsStatus {

@ -33,7 +33,7 @@ class DButton extends StatefulWidget {
key: key, key: key,
width: width, width: width,
height: height, height: height,
onTap: onTap, onTap: enabled ? onTap : null,
child: Tooltip( child: Tooltip(
child: Opacity(opacity: enabled ? 1 : 0.4, child: const Icon(Icons.add, size: 18)), child: Opacity(opacity: enabled ? 1 : 0.4, child: const Icon(Icons.add, size: 18)),
message: LocaleKeys.operation_add.tr(), message: LocaleKeys.operation_add.tr(),
@ -50,7 +50,7 @@ class DButton extends StatefulWidget {
key: key, key: key,
width: width, width: width,
height: height, height: height,
onTap: onTap, onTap: enabled ? onTap : null,
child: Tooltip( child: Tooltip(
child: Opacity(opacity: enabled ? 1 : 0.4, child: const Icon(Icons.remove, size: 18)), child: Opacity(opacity: enabled ? 1 : 0.4, child: const Icon(Icons.remove, size: 18)),
message: LocaleKeys.operation_delete.tr(), message: LocaleKeys.operation_delete.tr(),
@ -67,7 +67,7 @@ class DButton extends StatefulWidget {
key: key, key: key,
width: width, width: width,
height: height, height: height,
onTap: onTap, onTap: enabled ? onTap : null,
child: Tooltip( child: Tooltip(
child: Opacity(opacity: enabled ? 1 : 0.4, child: const Icon(Icons.check, size: 18)), child: Opacity(opacity: enabled ? 1 : 0.4, child: const Icon(Icons.check, size: 18)),
message: LocaleKeys.operation_apply.tr(), message: LocaleKeys.operation_apply.tr(),
@ -84,12 +84,29 @@ class DButton extends StatefulWidget {
key: key, key: key,
width: width, width: width,
height: height, height: height,
onTap: onTap, onTap: enabled ? onTap : null,
child: Tooltip( child: Tooltip(
child: Opacity(opacity: enabled ? 1 : 0.4, child: const Icon(Icons.copy_rounded, size: 18)), child: Opacity(opacity: enabled ? 1 : 0.4, child: const Icon(Icons.copy_rounded, size: 18)),
message: LocaleKeys.operation_duplicate.tr(), message: LocaleKeys.operation_duplicate.tr(),
)); ));
factory DButton.paste({
Key? key,
required enabled,
GestureTapCallback? onTap,
height = defaultButtonHeight * .7,
width = defaultButtonHeight * .7,
}) =>
DButton(
key: key,
width: width,
height: height,
onTap: enabled ? onTap : null,
child: Tooltip(
child: Opacity(opacity: enabled ? 1 : 0.4, child: const Icon(Icons.paste_rounded, size: 18)),
message: LocaleKeys.operation_paste.tr(),
));
factory DButton.dropdown({ factory DButton.dropdown({
Key? key, Key? key,
width = 60.0, width = 60.0,

@ -1,6 +1,7 @@
import 'package:dde_gesture_manager/constants/constants.dart'; import 'package:dde_gesture_manager/constants/constants.dart';
import 'package:dde_gesture_manager/models/settings.provider.dart'; import 'package:dde_gesture_manager/models/settings.provider.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class TableCellTextField extends StatefulWidget { class TableCellTextField extends StatefulWidget {
@ -21,7 +22,9 @@ class TableCellTextField extends StatefulWidget {
class _TableCellTextFieldState extends State<TableCellTextField> { class _TableCellTextFieldState extends State<TableCellTextField> {
final FocusNode _focusNode = FocusNode( final FocusNode _focusNode = FocusNode(
onKeyEvent: (_, __) => KeyEventResult.skipRemainingHandlers, onKeyEvent: (_, evt) => [LogicalKeyboardKey.backspace].contains(evt.logicalKey)
? KeyEventResult.ignored
: KeyEventResult.skipRemainingHandlers,
); );
final TextEditingController _controller = TextEditingController(); final TextEditingController _controller = TextEditingController();

@ -24,7 +24,7 @@ dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.2
window_manager: ^0.0.3 window_manager: ^0.0.5
localstorage: ^4.0.0+1 localstorage: ^4.0.0+1
shared_preferences: ^2.0.7 shared_preferences: ^2.0.7
xdg_directories: 0.2.0 xdg_directories: 0.2.0

@ -49,7 +49,7 @@
"gestures": { "gestures": {
"swipe": "swipe", "swipe": "swipe",
"pinch": "pinch", "pinch": "pinch",
"tap": "pinch" "tap": "tap"
}, },
"types": { "types": {
"built_in": "built-in", "built_in": "built-in",
@ -61,7 +61,8 @@
"add": "Add", "add": "Add",
"delete": "delete", "delete": "delete",
"duplicate": "duplicate", "duplicate": "duplicate",
"apply": "apply" "apply": "apply",
"paste": "paste"
}, },
"str": { "str": {
"null": "Null" "null": "Null"

@ -61,7 +61,8 @@
"add": "新增", "add": "新增",
"delete": "删除", "delete": "删除",
"duplicate": "复制", "duplicate": "复制",
"apply": "应用" "apply": "应用",
"paste": "粘贴"
}, },
"str": { "str": {
"null": "无" "null": "无"

Loading…
Cancel
Save