themesGenerator top-level property

FigGenerator themesGenerator
final

主题生成器

Implementation

final FigGenerator themesGenerator = FigGenerator(
  script: ['cw', 'theme', '--list'],
  postProcess: (String output, [List<String>? tokens]) {
    // 内置主题
    final builtinThemes = <FigSuggestion>[
      FigSuggestion(
        name: 'system',
        icon: '💻',
        priority: 51,
      ),
      FigSuggestion(
        name: 'light',
        icon: 'fig://template?color=ffffff&badge=☀️',
        priority: 51,
      ),
      FigSuggestion(
        name: 'dark',
        icon: 'fig://template?color=000000&badge=🌙',
        priority: 51,
      ),
    ];

    // 处理脚本输出
    final themesFromOutput = output
        .split('\n')
        .where((name) => name.trim().isNotEmpty) // 过滤空行
        .map((name) => FigSuggestion(
              name: name.trim(),
              icon: '🎨',
            ))
        .toList();

    // 合并内置主题和从脚本获取的主题
    return themesFromOutput.followedBy(builtinThemes).toList();
  },
);