export type ScaleTextSizeType = 'base' | 'mini' | 'large';
export class StyleFit {
private static scaleTextSize: ScaleTextSizeType = 'base'; // base标准 mini小字体 large大字体
static init() {
PreferencesUtil.getString("scale_text_size").then(value => {
if (value == "") {
StyleFit.scaleTextSize = "base";
} else {
StyleFit.scaleTextSize = value as ScaleTextSizeType;
}
})
}
static setScaleTextSize(value: ScaleTextSizeType) {
StyleFit.scaleTextSize = value;
PreferencesUtil.putSync("scale_text_size", value);
}
// 获取当前字体大小样式
static getScaleTextStyle() {
let style = 1;
if (StyleFit.scaleTextSize == "mini") {
style = 0.8;
} else if (StyleFit.scaleTextSize == "base") {
style = 1;
} else if (StyleFit.scaleTextSize == "large") {
style = 1.25;
}
return style;
}
}
评论