wip: show error when scheme name conflict.
This commit is contained in:
@@ -156,7 +156,7 @@ class Scheme {
|
||||
this.gestures = [];
|
||||
this.fromMarket = false;
|
||||
this.uploaded = false;
|
||||
this.name = 'new xxx';
|
||||
this.name = LocaleKeys.str_new_scheme.tr();
|
||||
}
|
||||
|
||||
SchemeTree buildSchemeTree() {
|
||||
|
||||
@@ -274,8 +274,11 @@ class GestureEditor extends StatelessWidget {
|
||||
schemeProvider.setProps(name: val);
|
||||
var localSchemesProvider = context.read<LocalSchemesProvider>();
|
||||
if (!localSchemesProvider.schemes!.every((element) => element.scheme.name != val)) {
|
||||
/// show error info;
|
||||
'duplicate name'.sout();
|
||||
Notificator.error(
|
||||
context,
|
||||
title: LocaleKeys.info_scheme_name_conflict_title.tr(),
|
||||
description: LocaleKeys.info_scheme_name_conflict_description.tr(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
;
|
||||
|
||||
@@ -56,8 +56,7 @@ class _LocalManagerState extends State<LocalManager> {
|
||||
return _color;
|
||||
}
|
||||
|
||||
Icon _getItemIcon(Scheme scheme, String? appliedId) {
|
||||
if (scheme.id == appliedId) return Icon(Icons.done_rounded, size: 22);
|
||||
Icon _getItemIcon(Scheme scheme) {
|
||||
if (scheme.id == Uuid.NAMESPACE_NIL) return Icon(Icons.restore_rounded, size: 22);
|
||||
if (scheme.fromMarket == true) return Icon(Icons.local_grocery_store_rounded, size: 20);
|
||||
if (scheme.uploaded == true) return Icon(Icons.cloud_done_rounded, size: 18);
|
||||
@@ -159,9 +158,22 @@ class _LocalManagerState extends State<LocalManager> {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Opacity(
|
||||
opacity: context.watch<ConfigsProvider>().appliedSchemeId ==
|
||||
localSchemes[index].scheme.id
|
||||
? 1
|
||||
: 0,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 2.0),
|
||||
child: Icon(Icons.done_rounded, size: 20),
|
||||
),
|
||||
),
|
||||
Text(localSchemes[index].scheme.name ?? ''),
|
||||
_getItemIcon(localSchemes[index].scheme,
|
||||
context.watch<ConfigsProvider>().appliedSchemeId),
|
||||
],
|
||||
),
|
||||
_getItemIcon(localSchemes[index].scheme),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -204,7 +216,7 @@ class _LocalManagerState extends State<LocalManager> {
|
||||
),
|
||||
DButton.duplicate(enabled: _selectedItemPath.notNull),
|
||||
DButton.apply(
|
||||
enabled: _selectedItemPath.notNull,
|
||||
enabled: true,
|
||||
onTap: () {
|
||||
var appliedId =
|
||||
localSchemes.firstWhere((ele) => ele.path == _selectedItemPath).scheme.id!;
|
||||
|
||||
@@ -65,7 +65,8 @@
|
||||
"paste": "paste"
|
||||
},
|
||||
"str": {
|
||||
"null": "Null"
|
||||
"null": "Null",
|
||||
"new_scheme": "New gesture scheme"
|
||||
},
|
||||
"built_in_commands": {
|
||||
"ShowWorkspace": "ShowWorkspace",
|
||||
@@ -87,6 +88,10 @@
|
||||
"gesture_prop_duplicated": {
|
||||
"title": "Duplicated !",
|
||||
"description": "Now you can go to other scheme and click the paste button ~"
|
||||
},
|
||||
"scheme_name_conflict": {
|
||||
"title": "Save failed!",
|
||||
"description": "Scheme name conflict, please rename it!"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,8 @@
|
||||
"paste": "粘贴"
|
||||
},
|
||||
"str": {
|
||||
"null": "无"
|
||||
"null": "无",
|
||||
"new_scheme": "新建手势方案"
|
||||
},
|
||||
"built_in_commands": {
|
||||
"ShowWorkspace": "显示工作区",
|
||||
@@ -87,6 +88,10 @@
|
||||
"gesture_prop_duplicated": {
|
||||
"title": "复制成功!",
|
||||
"description": "现在可以去其他方案中点击粘贴按钮试试哦~"
|
||||
},
|
||||
"scheme_name_conflict": {
|
||||
"title": "保存失败!",
|
||||
"description": "方案名冲突,请重新命名!"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user