You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.8 KiB

package com.example.datacollect.util;
/**
* UI 颜色常量类
*
* 【修改位置提示】
* 只需修改 THEME_MODE 常量即可切换亮色/暗色主题
* THEME_MODE = false -> 亮色主题
* THEME_MODE = true -> 暗色主题
*/
public class UIConstants {
/** 主题模式开关:false = 亮色主题,true = 暗色主题 */
public static final boolean THEME_MODE = true;
/** 亮色主题 - 背景色 */
public static final String LIGHT_BG_COLOR = "#FFFFFF";
/** 亮色主题 - 前景色(文字) */
public static final String LIGHT_FG_COLOR = "#000000";
/** 亮色主题 - 按钮色 */
public static final String LIGHT_BUTTON_COLOR = "#007BFF";
/** 暗色主题 - 背景色 */
public static final String DARK_BG_COLOR = "#1E1E1E";
/** 暗色主题 - 前景色(文字) */
public static final String DARK_FG_COLOR = "#E0E0E0";
/** 暗色主题 - 按钮色 */
public static final String DARK_BUTTON_COLOR = "#0D6EFD";
/** 根据主题模式获取背景色 */
public static String getBackgroundColor() {
return THEME_MODE ? DARK_BG_COLOR : LIGHT_BG_COLOR;
}
/** 根据主题模式获取前景色 */
public static String getForegroundColor() {
return THEME_MODE ? DARK_FG_COLOR : LIGHT_FG_COLOR;
}
/** 根据主题模式获取按钮色 */
public static String getButtonColor() {
return THEME_MODE ? DARK_BUTTON_COLOR : LIGHT_BUTTON_COLOR;
}
/** 打印当前主题配置 */
public static void printCurrentTheme() {
System.out.println("===== UI 主题配置 =====");
System.out.println("当前模式: " + (THEME_MODE ? "暗色主题" : "亮色主题"));
System.out.println("背景色: " + getBackgroundColor());
System.out.println("前景色: " + getForegroundColor());
System.out.println("按钮色: " + getButtonColor());
System.out.println("======================");
}
public static void main(String[] args) {
printCurrentTheme();
}
}
/*
* =============================================================================
* 使用说明
* =============================================================================
*
* 1. 找到 UIConstants.java 文件
* 路径:com.example.datacollect.util.UIConstants
*
* 2. 修改主题开关(只需改这一行):
* public static final boolean THEME_MODE = true; // true = 暗色, false = 亮色
*
* 3. 所有 UI 颜色会自动切换:
* - 亮色模式: 白色背景 + 黑色文字 + 蓝色按钮
* - 暗色模式: 深灰背景 + 浅灰文字 + 亮蓝按钮
*
* 4. 在其他类中使用:
* String bgColor = UIConstants.getBackgroundColor();
* String fgColor = UIConstants.getForegroundColor();
*
* =============================================================================
*/