-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
2,986 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import 'package:isar/isar.dart'; | ||
|
||
part 'extension_setting.g.dart'; | ||
|
||
enum ExtensionSettingType { | ||
// 输入框 | ||
input, | ||
// 单选 | ||
radio, | ||
// 开关 | ||
toggle, | ||
} | ||
|
||
@collection | ||
class ExtensionSetting { | ||
Id id = Isar.autoIncrement; | ||
|
||
@Index(composite: [CompositeIndex('key')], unique: true) | ||
late String package; | ||
// 标题 | ||
late String title; | ||
// 键 | ||
late String key; | ||
// 值 | ||
String? value; | ||
// 默认值 | ||
late String defaultValue; | ||
// 类型 | ||
@Enumerated(EnumType.name) | ||
late ExtensionSettingType type; | ||
// 描述 | ||
String? description; | ||
// 如果是 radio 类型,这里是各项选项,且必填 , 存储为 ["key:value","key:value"] | ||
// 为啥不直接用 map,因为 isar 还不支持 map 类型 | ||
List<String>? options; | ||
|
||
static ExtensionSettingType stringToType(String type) { | ||
switch (type) { | ||
case 'input': | ||
return ExtensionSettingType.input; | ||
case 'radio': | ||
return ExtensionSettingType.radio; | ||
case 'toggle': | ||
return ExtensionSettingType.toggle; | ||
default: | ||
return ExtensionSettingType.input; | ||
} | ||
} | ||
} |
Oops, something went wrong.