wip: show error when scheme name conflict.

pull/5/head
DebuggerX 3 years ago
parent cbaf61f70b
commit 214b06cac8

@ -156,7 +156,7 @@ class Scheme {
this.gestures = []; this.gestures = [];
this.fromMarket = false; this.fromMarket = false;
this.uploaded = false; this.uploaded = false;
this.name = 'new xxx'; this.name = LocaleKeys.str_new_scheme.tr();
} }
SchemeTree buildSchemeTree() { SchemeTree buildSchemeTree() {

@ -274,8 +274,11 @@ class GestureEditor extends StatelessWidget {
schemeProvider.setProps(name: val); schemeProvider.setProps(name: val);
var localSchemesProvider = context.read<LocalSchemesProvider>(); var localSchemesProvider = context.read<LocalSchemesProvider>();
if (!localSchemesProvider.schemes!.every((element) => element.scheme.name != val)) { if (!localSchemesProvider.schemes!.every((element) => element.scheme.name != val)) {
/// show error info; Notificator.error(
'duplicate name'.sout(); context,
title: LocaleKeys.info_scheme_name_conflict_title.tr(),
description: LocaleKeys.info_scheme_name_conflict_description.tr(),
);
return; return;
} }
; ;

@ -56,8 +56,7 @@ class _LocalManagerState extends State<LocalManager> {
return _color; return _color;
} }
Icon _getItemIcon(Scheme scheme, String? appliedId) { Icon _getItemIcon(Scheme scheme) {
if (scheme.id == appliedId) return Icon(Icons.done_rounded, size: 22);
if (scheme.id == Uuid.NAMESPACE_NIL) return Icon(Icons.restore_rounded, size: 22); 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.fromMarket == true) return Icon(Icons.local_grocery_store_rounded, size: 20);
if (scheme.uploaded == true) return Icon(Icons.cloud_done_rounded, size: 18); if (scheme.uploaded == true) return Icon(Icons.cloud_done_rounded, size: 18);
@ -159,9 +158,22 @@ class _LocalManagerState extends State<LocalManager> {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ 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 ?? ''), 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.duplicate(enabled: _selectedItemPath.notNull),
DButton.apply( DButton.apply(
enabled: _selectedItemPath.notNull, enabled: true,
onTap: () { onTap: () {
var appliedId = var appliedId =
localSchemes.firstWhere((ele) => ele.path == _selectedItemPath).scheme.id!; localSchemes.firstWhere((ele) => ele.path == _selectedItemPath).scheme.id!;

@ -65,7 +65,8 @@
"paste": "paste" "paste": "paste"
}, },
"str": { "str": {
"null": "Null" "null": "Null",
"new_scheme": "New gesture scheme"
}, },
"built_in_commands": { "built_in_commands": {
"ShowWorkspace": "ShowWorkspace", "ShowWorkspace": "ShowWorkspace",
@ -87,6 +88,10 @@
"gesture_prop_duplicated": { "gesture_prop_duplicated": {
"title": "Duplicated !", "title": "Duplicated !",
"description": "Now you can go to other scheme and click the paste button ~" "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": "粘贴" "paste": "粘贴"
}, },
"str": { "str": {
"null": "无" "null": "无",
"new_scheme": "新建手势方案"
}, },
"built_in_commands": { "built_in_commands": {
"ShowWorkspace": "显示工作区", "ShowWorkspace": "显示工作区",
@ -87,6 +88,10 @@
"gesture_prop_duplicated": { "gesture_prop_duplicated": {
"title": "复制成功!", "title": "复制成功!",
"description": "现在可以去其他方案中点击粘贴按钮试试哦~" "description": "现在可以去其他方案中点击粘贴按钮试试哦~"
},
"scheme_name_conflict": {
"title": "保存失败!",
"description": "方案名冲突,请重新命名!"
} }
} }
} }
Loading…
Cancel
Save