initThemeConfig method
部分代码示意如下:
cardTitleConfig.detailTextStyle.merge(
BrnTextStyle(
color: commonConfig.colorTextBase,
fontSize: commonConfig.fontSizeBase,
).merge(detailTextStyle),
);
- 以 `commonConfig` 字段为基础 merge `detailTextStyle`。
`detailTextStyle` 字段优先级高,当detailTextStyle中字段(如 color)为 null 时
会使用 `commonConfig.colorTextBase`。
- 以默认上一级配置为基础 merge 第一步的结果,当第一步中字段(如 color)为空时,
使用上一层级配置的 color (`cardTitleConfig.detailTextStyle.color`)。
Implementation
@override
void initThemeConfig(
String configId, {
BaseCommonConfig? currentLevelCommonConfig,
}) {
super.initThemeConfig(
configId,
currentLevelCommonConfig: currentLevelCommonConfig,
);
/// 用户全局组件配置
PickerConfig pickerConfig =
BaseThemeConfig.instance.getConfig(configId: configId).pickerConfig;
_backgroundColor ??= pickerConfig.backgroundColor;
_pickerHeight ??= pickerConfig.pickerHeight;
_titleHeight ??= pickerConfig.titleHeight;
_itemHeight ??= pickerConfig.itemHeight;
_dividerColor ??= pickerConfig.dividerColor;
_cornerRadius ??= pickerConfig.cornerRadius;
_titleTextStyle = pickerConfig.titleTextStyle.merge(
BaseTextStyle(
color: commonConfig.colorTextBase,
fontSize: commonConfig.fontSizeSubHead,
).merge(_titleTextStyle),
);
_cancelTextStyle = pickerConfig.cancelTextStyle
.merge(
BaseTextStyle(
color: commonConfig.colorTextBase,
fontSize: commonConfig.fontSizeSubHead,
),
)
.merge(_cancelTextStyle);
_confirmTextStyle = pickerConfig.confirmTextStyle.merge(
BaseTextStyle(
color: commonConfig.brandPrimary,
fontSize: commonConfig.fontSizeSubHead,
).merge(_confirmTextStyle),
);
_itemTextStyle = pickerConfig.itemTextStyle.merge(
BaseTextStyle(
color: commonConfig.colorTextBase,
fontSize: commonConfig.fontSizeHead,
).merge(_itemTextStyle),
);
_itemTextSelectedStyle = pickerConfig.itemTextSelectedStyle.merge(
BaseTextStyle(
color: commonConfig.brandPrimary,
fontSize: commonConfig.fontSizeHead,
).merge(_itemTextSelectedStyle),
);
}