obo
10 months ago
11 changed files with 176 additions and 32 deletions
@ -0,0 +1,62 @@
|
||||
package com.fr.widgettheme; |
||||
|
||||
import com.fr.base.theme.TemplateTheme; |
||||
import com.fr.widgettheme.theme.widget.style.MobileThemedWidgetStyle; |
||||
import com.fr.widgettheme.theme.widget.style.ThemedWidgetStyle; |
||||
|
||||
/** |
||||
* 主题样式预览终端类型 |
||||
* |
||||
* @author obo |
||||
* @since 11.0 |
||||
* Created on 2024/2/2 |
||||
*/ |
||||
public enum ThemePreviewTerminal { |
||||
|
||||
/** |
||||
* 桌面端,为默认类型 |
||||
*/ |
||||
PC(0) { |
||||
@Override |
||||
public ThemedWidgetStyle getThemeWidgetStyle(TemplateTheme theme) { |
||||
return (ThemedWidgetStyle) theme.getWidgetStyle(); |
||||
} |
||||
}, |
||||
|
||||
/** |
||||
* 移动端 |
||||
*/ |
||||
MOBILE(1) { |
||||
@Override |
||||
public ThemedWidgetStyle getThemeWidgetStyle(TemplateTheme theme) { |
||||
return (MobileThemedWidgetStyle) theme.getMobileWidgetStyle(); |
||||
} |
||||
}; |
||||
|
||||
/** |
||||
* 类型码 |
||||
*/ |
||||
final int code; |
||||
|
||||
ThemePreviewTerminal(int code) { |
||||
this.code = code; |
||||
} |
||||
|
||||
public int getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public abstract ThemedWidgetStyle getThemeWidgetStyle(TemplateTheme theme); |
||||
|
||||
/** |
||||
* 根据code获取对应的枚举 |
||||
*/ |
||||
public static ThemePreviewTerminal getTypeByCode(int code) { |
||||
for (ThemePreviewTerminal type : ThemePreviewTerminal.values()) { |
||||
if (type.code == code) { |
||||
return type; |
||||
} |
||||
} |
||||
throw new IllegalArgumentException("Invalid ThemePreviewTerminalType code :" + code); |
||||
} |
||||
} |
Loading…
Reference in new issue