Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
debuggerx01 committed Mar 14, 2022
2 parents d3dc717 + 0383e90 commit 3541ced
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 25 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@

- [x] 方案下载功能实现
- [x] 方案应用功能实现
- [ ] BugFix
- [x] BugFix
- [x] MD 编辑器中的UI文本国际化
- [x] 编写帮助说明文档
- [ ] 浅色模式界面优化
- [ ] 打包上架 Deepin/UOS 应用商店
- [x] 打包上架 Deepin/UOS 应用商店


# FAQ
Expand Down
4 changes: 2 additions & 2 deletions app/lib/models/scheme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ class Scheme {
this.name = LocaleKeys.str_new_scheme.tr();
}

SchemeTree buildSchemeTree() {
SchemeTree buildSchemeTree({String? availableGestureId}) {
var schemeTree = SchemeTree();
this.gestures!.forEach((gesture) {
this.gestures!.where((e) => e.id != availableGestureId).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;
Expand Down
56 changes: 36 additions & 20 deletions app/lib/pages/gesture_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -446,20 +446,13 @@ void saveGesturesToLocal(BuildContext context, SchemeProvider schemeProvider, Li

List<DDataCell> _buildRowCellsEditing(BuildContext context) {
var gesture = context.read<GesturePropProvider>();
var schemeTree = context.read<SchemeProvider>().buildSchemeTree();
var schemeTree = context.read<SchemeProvider>().buildSchemeTree(availableGestureId: gesture.id);
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((a, b) => a.index - b.index);
}

var availableDirection = schemeTree.nodes
.firstWhere((node) => node.fingers == gesture.fingers)
Expand All @@ -469,10 +462,6 @@ List<DDataCell> _buildRowCellsEditing(BuildContext context) {
.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(
enabled: true,
Expand All @@ -487,10 +476,28 @@ List<DDataCell> _buildRowCellsEditing(BuildContext context) {
)
.toList(),
value: gesture.fingers,
onChanged: (value) => context.read<GesturePropProvider>().setProps(
fingers: value,
editMode: true,
),
onChanged: (value) {
var gesturePropProvider = context.read<GesturePropProvider>();
Gesture? newGestureType;
GestureDirection? newDirection;
if (!schemeTree.nodes
.firstWhere((e) => e.fingers == value)
.nodes
.firstWhere((e) => e.type == gesturePropProvider.gesture)
.nodes
.firstWhere((e) => e.direction == gesturePropProvider.direction)
.available) {
var availableNode = schemeTree.nodes.firstWhere((e) => e.fingers == value).availableNode;
newGestureType = availableNode.type;
newDirection = availableNode.availableNode.direction;
}
gesturePropProvider.setProps(
fingers: value,
gesture: newGestureType ?? gesturePropProvider.gesture,
direction: newDirection ?? gesturePropProvider.direction,
editMode: true,
);
},
isExpanded: true,
),
),
Expand All @@ -511,10 +518,19 @@ List<DDataCell> _buildRowCellsEditing(BuildContext context) {
)
.toList(),
value: gesture.gesture,
onChanged: (value) => context.read<GesturePropProvider>().setProps(
gesture: value,
editMode: true,
),
onChanged: (value) {
var gesturePropProvider = context.read<GesturePropProvider>();
gesturePropProvider.setProps(
gesture: value,
direction: schemeTree.nodes
.firstWhere((node) => node.fingers == gesture.fingers)
.nodes
.firstWhere((node) => node.type == value)
.availableNode
.direction,
editMode: true,
);
},
isExpanded: true,
),
),
Expand Down
2 changes: 1 addition & 1 deletion app/lib/pages/local_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class LocalManagerState extends State<LocalManager> {
newSchemes.removeAt(index);
localSchemesProvider.setProps(schemes: newSchemes);
localSchemesProvider.remove(_selectedItemPath);
var newSelectedItem = newSchemes[(index - 1).clamp(1, newSchemes.length)];
var newSelectedItem = newSchemes[(index - 1).clamp(0, newSchemes.length)];
setState(() {
_selectedItemPath = newSelectedItem.path;
});
Expand Down

0 comments on commit 3541ced

Please sign in to comment.