feat: 添加自动化任务(automation_jobs)功能模块
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
const Map<String, String> _toolNameZhMap = {
|
||||
'calendar.read': '读取日程',
|
||||
'calendar.write': '写入日程',
|
||||
'calendar.share': '共享日程',
|
||||
'user.lookup': '查找联系人',
|
||||
'memory.write': '写入记忆',
|
||||
'memory.forget': '清理记忆',
|
||||
};
|
||||
|
||||
const Map<String, String> _toolNameAliases = {
|
||||
'calendar_read': 'calendar.read',
|
||||
'calendar_write': 'calendar.write',
|
||||
'calendar_share': 'calendar.share',
|
||||
'user_lookup': 'user.lookup',
|
||||
'memory_write': 'memory.write',
|
||||
'memory_forget': 'memory.forget',
|
||||
};
|
||||
|
||||
const List<String> automationToolOptions = [
|
||||
'calendar.read',
|
||||
'calendar.write',
|
||||
'calendar.share',
|
||||
'user.lookup',
|
||||
'memory.write',
|
||||
'memory.forget',
|
||||
];
|
||||
|
||||
String localizeToolName(String rawName) {
|
||||
final normalized = rawName.trim().toLowerCase();
|
||||
if (normalized.isEmpty) {
|
||||
return rawName;
|
||||
}
|
||||
final canonical = _toolNameAliases[normalized] ?? normalized;
|
||||
return _toolNameZhMap[canonical] ?? rawName;
|
||||
}
|
||||
@@ -6,7 +6,7 @@ class AppToggleSwitch extends StatelessWidget {
|
||||
const AppToggleSwitch({
|
||||
super.key,
|
||||
required this.value,
|
||||
required this.onChanged,
|
||||
this.onChanged,
|
||||
this.activeBackgroundColor,
|
||||
this.inactiveBackgroundColor,
|
||||
this.activeBorderColor,
|
||||
@@ -14,7 +14,7 @@ class AppToggleSwitch extends StatelessWidget {
|
||||
});
|
||||
|
||||
final bool value;
|
||||
final ValueChanged<bool> onChanged;
|
||||
final ValueChanged<bool>? onChanged;
|
||||
final Color? activeBackgroundColor;
|
||||
final Color? inactiveBackgroundColor;
|
||||
final Color? activeBorderColor;
|
||||
@@ -23,32 +23,35 @@ class AppToggleSwitch extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () => onChanged(!value),
|
||||
child: Container(
|
||||
width: AppSpacing.xxl + AppSpacing.xl,
|
||||
height: AppSpacing.xl + AppSpacing.xs,
|
||||
padding: const EdgeInsets.all(AppSpacing.xs / 2),
|
||||
decoration: BoxDecoration(
|
||||
color: value
|
||||
? (activeBackgroundColor ?? AppColors.blue100)
|
||||
: (inactiveBackgroundColor ?? AppColors.surfaceTertiary),
|
||||
borderRadius: BorderRadius.circular(AppRadius.full),
|
||||
border: Border.all(
|
||||
onTap: onChanged == null ? null : () => onChanged!(!value),
|
||||
child: Opacity(
|
||||
opacity: onChanged == null ? 0.55 : 1,
|
||||
child: Container(
|
||||
width: AppSpacing.xxl + AppSpacing.xl,
|
||||
height: AppSpacing.xl + AppSpacing.xs,
|
||||
padding: const EdgeInsets.all(AppSpacing.xs / 2),
|
||||
decoration: BoxDecoration(
|
||||
color: value
|
||||
? (activeBorderColor ?? AppColors.blue300)
|
||||
: (inactiveBorderColor ?? AppColors.borderSecondary),
|
||||
? (activeBackgroundColor ?? AppColors.blue100)
|
||||
: (inactiveBackgroundColor ?? AppColors.surfaceTertiary),
|
||||
borderRadius: BorderRadius.circular(AppRadius.full),
|
||||
border: Border.all(
|
||||
color: value
|
||||
? (activeBorderColor ?? AppColors.blue300)
|
||||
: (inactiveBorderColor ?? AppColors.borderSecondary),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: AnimatedAlign(
|
||||
duration: const Duration(milliseconds: 150),
|
||||
alignment: value ? Alignment.centerRight : Alignment.centerLeft,
|
||||
child: Container(
|
||||
width: AppSpacing.lg + AppSpacing.xs,
|
||||
height: AppSpacing.lg + AppSpacing.xs,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.white,
|
||||
borderRadius: BorderRadius.circular(AppRadius.full),
|
||||
border: Border.all(color: AppColors.borderSecondary),
|
||||
child: AnimatedAlign(
|
||||
duration: const Duration(milliseconds: 150),
|
||||
alignment: value ? Alignment.centerRight : Alignment.centerLeft,
|
||||
child: Container(
|
||||
width: AppSpacing.lg + AppSpacing.xs,
|
||||
height: AppSpacing.lg + AppSpacing.xs,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.white,
|
||||
borderRadius: BorderRadius.circular(AppRadius.full),
|
||||
border: Border.all(color: AppColors.borderSecondary),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user