Skip to content

Commit

Permalink
模型选择页面样式优化
Browse files Browse the repository at this point in the history
  • Loading branch information
mylxsw committed Apr 22, 2024
1 parent d6b6f90 commit 34d349b
Show file tree
Hide file tree
Showing 10 changed files with 664 additions and 153 deletions.
3 changes: 3 additions & 0 deletions lib/helper/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class ModelAggregate {
tag: e.tag,
avatarUrl: e.avatarUrl,
supportVision: e.supportVision,
tagTextColor: e.tagTextColor,
tagBgColor: e.tagBgColor,
isNew: e.isNew,
),
)
.toList());
Expand Down
13 changes: 13 additions & 0 deletions lib/lang/lang.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ mixin AppLocale {
static const String customHomeModels = 'custom-home-models';
static const String userApiKeys = "user-api-keys";

static const String others = 'others';
static const String recentlyUsed = 'recently-used';
static const String visionTag = 'vision-tag';
static const String newTag = 'new-tag';

static const Map<String, dynamic> zh = {
required: '必填',
systemInfo: '系统信息',
Expand Down Expand Up @@ -398,6 +403,10 @@ mixin AppLocale {
discover: '绘玩',
customHomeModels: '常用模型',
userApiKeys: 'API Keys',
others: '其它',
recentlyUsed: '最近使用',
visionTag: '视觉',
newTag: '新',
};

static const Map<String, dynamic> en = {
Expand Down Expand Up @@ -607,6 +616,10 @@ mixin AppLocale {
discover: 'Discover',
customHomeModels: 'Favorite Models',
userApiKeys: 'API Keys',
others: 'Others',
recentlyUsed: 'Recently Used',
visionTag: 'Vision',
newTag: 'New',
};
}

Expand Down
118 changes: 108 additions & 10 deletions lib/page/admin/models_add.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class _AdminModelCreatePageState extends State<AdminModelCreatePage> {
final TextEditingController inputPriceController = TextEditingController();
final TextEditingController outputPriceController = TextEditingController();
final TextEditingController promptController = TextEditingController();
final TextEditingController categoryController = TextEditingController();

/// 用于控制是否显示高级选项
bool showAdvancedOptions = false;
Expand All @@ -68,6 +69,14 @@ class _AdminModelCreatePageState extends State<AdminModelCreatePage> {
String? avatarUrl;
List<String> avatarPresets = [];

/// 是否是上新
bool isNew = false;

/// Tag
final TextEditingController tagController = TextEditingController();
String? tagTextColor;
String? tagBgColor;

// 模型渠道
List<AdminChannel> modelChannels = [];
// 选择的渠道
Expand All @@ -83,6 +92,8 @@ class _AdminModelCreatePageState extends State<AdminModelCreatePage> {
inputPriceController.dispose();
outputPriceController.dispose();
promptController.dispose();
categoryController.dispose();
tagController.dispose();

super.dispose();
}
Expand Down Expand Up @@ -153,6 +164,15 @@ class _AdminModelCreatePageState extends State<AdminModelCreatePage> {
maxLength: 100,
showCounter: false,
),
EnhancedTextField(
labelText: '厂商',
customColors: customColors,
controller: categoryController,
textAlignVertical: TextAlignVertical.top,
hintText: '请输入厂商名称(可选)',
maxLength: 100,
showCounter: false,
),
EnhancedTextField(
labelText: '名称',
customColors: customColors,
Expand Down Expand Up @@ -433,19 +453,51 @@ class _AdminModelCreatePageState extends State<AdminModelCreatePage> {
maxLength: 100,
showCounter: false,
),
EnhancedTextField(
labelText: '标签',
customColors: customColors,
controller: tagController,
textAlignVertical: TextAlignVertical.top,
hintText: '请输入标签',
maxLength: 100,
showCounter: false,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
'启用',
style: TextStyle(fontSize: 16),
Row(
children: [
const Text(
'视觉',
style: TextStyle(fontSize: 16),
),
const SizedBox(width: 5),
InkWell(
onTap: () {
showBeautyDialog(
context,
type: QuickAlertType.info,
text: '当前模型是否支持视觉能力。',
confirmBtnText:
AppLocale.gotIt.getString(context),
showCancelBtn: false,
);
},
child: Icon(
Icons.help_outline,
size: 16,
color: customColors.weakLinkColor
?.withAlpha(150),
),
),
],
),
CupertinoSwitch(
activeColor: customColors.linkColor,
value: modelEnabled,
value: supportVision,
onChanged: (value) {
setState(() {
modelEnabled = value;
supportVision = value;
});
},
),
Expand All @@ -454,16 +506,39 @@ class _AdminModelCreatePageState extends State<AdminModelCreatePage> {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
'视觉能力',
style: TextStyle(fontSize: 16),
Row(
children: [
const Text(
'上新',
style: TextStyle(fontSize: 16),
),
const SizedBox(width: 5),
InkWell(
onTap: () {
showBeautyDialog(
context,
type: QuickAlertType.info,
text: '是否在模型旁边展示“新”标识,告知用户这是一个新模型。',
confirmBtnText:
AppLocale.gotIt.getString(context),
showCancelBtn: false,
);
},
child: Icon(
Icons.help_outline,
size: 16,
color: customColors.weakLinkColor
?.withAlpha(150),
),
),
],
),
CupertinoSwitch(
activeColor: customColors.linkColor,
value: supportVision,
value: isNew,
onChanged: (value) {
setState(() {
supportVision = value;
isNew = value;
});
},
),
Expand Down Expand Up @@ -510,6 +585,24 @@ class _AdminModelCreatePageState extends State<AdminModelCreatePage> {
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
'启用',
style: TextStyle(fontSize: 16),
),
CupertinoSwitch(
activeColor: customColors.linkColor,
value: modelEnabled,
onChanged: (value) {
setState(() {
modelEnabled = value;
});
},
),
],
),
EnhancedTextField(
labelPosition: LabelPosition.top,
labelText: '系统提示语',
Expand Down Expand Up @@ -620,6 +713,11 @@ class _AdminModelCreatePageState extends State<AdminModelCreatePage> {
prompt: promptController.text,
vision: supportVision,
restricted: restricted,
tag: tagController.text,
tagTextColor: tagTextColor,
tagBgColor: tagBgColor,
category: categoryController.text,
isNew: isNew,
),
status: modelEnabled ? 1 : 2,
providers: ps,
Expand Down
Loading

0 comments on commit 34d349b

Please sign in to comment.