initThemeConfig method

  1. @override
void initThemeConfig(
  1. String configId, {
  2. BaseCommonConfig? currentLevelCommonConfig,
})
override

按优先级,打平 【Bruno 内置配置】 < 【用户全局的默认配置】 < 【用户特殊配置】 < 【临时组件配置】

举例: ① 尝试获取最近的配置 topRadius 若配不为 null,直接使用该配置. ② topRadius 若为 null,尝试使用 全局配置中的配置 dialogConfig. ③ 如果全局配置中的配置同样为 null 则根据 configId 取出全局配置。 ④ 如果没有配置 configId 的全局配置,则使用 Bruno 默认的配置

Implementation

@override
void initThemeConfig(
  String configId, {
  BaseCommonConfig? currentLevelCommonConfig,
}) {
  super.initThemeConfig(
    configId,
    currentLevelCommonConfig: currentLevelCommonConfig,
  );

  /// 用户全局组件配置
  DialogConfig dialogConfig =
      BaseThemeConfig.instance.getConfig(configId: configId).dialogConfig;

  _dialogWidth ??= dialogConfig.dialogWidth;
  _radius ??= commonConfig.radiusLg;
  _titlePaddingSm ??= EdgeInsets.only(
    left: commonConfig.hSpacingXxl,
    right: commonConfig.hSpacingXxl,
    top: dialogConfig.titlePaddingSm.top,
    bottom: dialogConfig.titlePaddingSm.bottom,
  );
  _titlePaddingLg ??= EdgeInsets.only(
    left: commonConfig.hSpacingXxl,
    right: commonConfig.hSpacingXxl,
    top: dialogConfig.titlePaddingLg.top,
    bottom: dialogConfig.titlePaddingLg.bottom,
  );
  _iconPadding ??= EdgeInsets.only(
    left: dialogConfig.iconPadding.left,
    top: commonConfig.vSpacingXxl,
    right: dialogConfig.iconPadding.right,
    bottom: dialogConfig.iconPadding.bottom,
  );
  _titleTextStyle = dialogConfig.titleTextStyle.merge(
    BaseTextStyle(
      color: commonConfig.colorTextBase,
      fontSize: commonConfig.fontSizeHead,
    ).merge(_titleTextStyle),
  );
  _contentTextStyle = dialogConfig.contentTextStyle.merge(
    BaseTextStyle(
      color: commonConfig.colorTextImportant,
      fontSize: commonConfig.fontSizeBase,
    ).merge(_contentTextStyle),
  );
  _warningTextStyle = dialogConfig.warningTextStyle.merge(
    BaseTextStyle(
      color: commonConfig.brandError,
      fontSize: commonConfig.fontSizeBase,
    ).merge(_warningTextStyle),
  );
  _mainActionTextStyle = dialogConfig.mainActionTextStyle.merge(
    BaseTextStyle(
      color: commonConfig.brandPrimary,
      fontSize: commonConfig.fontSizeSubHead,
    ).merge(_mainActionTextStyle),
  );
  _assistActionsTextStyle = dialogConfig.assistActionsTextStyle.merge(
    BaseTextStyle(
      color: commonConfig.colorTextBase,
      fontSize: commonConfig.fontSizeSubHead,
    ).merge(_assistActionsTextStyle),
  );
  _contentPaddingSm ??= EdgeInsets.only(
    left: commonConfig.hSpacingXl,
    right: commonConfig.hSpacingXl,
    top: dialogConfig.contentPaddingSm.top,
    bottom: dialogConfig.contentPaddingSm.bottom,
  );
  _contentPaddingSm ??= EdgeInsets.only(
    left: commonConfig.hSpacingXl,
    right: commonConfig.hSpacingXl,
    top: dialogConfig.contentPaddingLg.top,
    bottom: dialogConfig.contentPaddingLg.bottom,
  );
  _warningPaddingSm ??= EdgeInsets.only(
    left: commonConfig.hSpacingXl,
    right: commonConfig.hSpacingXl,
    top: dialogConfig.warningPaddingSm.top,
    bottom: dialogConfig.warningPaddingSm.bottom,
  );
  _warningPaddingLg ??= EdgeInsets.only(
    left: commonConfig.hSpacingXl,
    right: commonConfig.hSpacingXl,
    top: dialogConfig.warningPaddingLg.top,
    bottom: dialogConfig.warningPaddingLg.bottom,
  );
  _titleTextAlign ??= dialogConfig.titleTextAlign;
  _contentTextAlign ??= dialogConfig.contentTextAlign;
  _warningTextAlign ??= dialogConfig.warningTextAlign;
  _mainActionBackgroundColor ??= commonConfig.fillBase;
  _assistActionsBackgroundColor ??= commonConfig.fillBase;
  _bottomHeight ??= dialogConfig.bottomHeight;
  _dividerPadding ??= dialogConfig.dividerPadding;
  _backgroundColor ??= commonConfig.fillBase;
}