Files
CloudHome-Ops/lib/models/store_theme.dart

75 lines
1.8 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/material.dart';
/// 门店主题/皮肤枚举。
///
/// 仅定义「id + 名称 + 主色」,UI 统一引用 [id](`themeId`),不硬编码颜色。
/// 当前为前端占位实现(纯色块 + 名称),后续可扩展为内置占位图。
enum StoreTheme {
/// 经典(默认)。
classic,
/// 海洋蓝。
ocean,
/// 森林绿。
forest,
/// 日落橙。
sunset,
/// 极简灰。
mono;
/// 主题 id(小写字符串,用于网络传输与本地缓存)。
String get id => name;
/// 主题中文名称。
String get label {
switch (this) {
case StoreTheme.classic:
return '经典';
case StoreTheme.ocean:
return '海洋蓝';
case StoreTheme.forest:
return '森林绿';
case StoreTheme.sunset:
return '日落橙';
case StoreTheme.mono:
return '极简灰';
}
}
/// 主题主色(用于色块预览与模拟主页头部)。
Color get primary {
switch (this) {
case StoreTheme.classic:
return const Color(0xFF1565C0);
case StoreTheme.ocean:
return const Color(0xFF00838F);
case StoreTheme.forest:
return const Color(0xFF2E7D32);
case StoreTheme.sunset:
return const Color(0xFFE65100);
case StoreTheme.mono:
return const Color(0xFF455A64);
}
}
}
/// 内置主题清单与查询工具。
class StoreThemePresets {
StoreThemePresets._();
/// 全部内置主题(顺序即展示顺序)。
static const List<StoreTheme> all = StoreTheme.values;
/// 按 id 查询主题;找不到返回 null。
static StoreTheme? byId(String? id) {
if (id == null || id.isEmpty) return null;
for (final theme in all) {
if (theme.id == id) return theme;
}
return null;
}
}