diff --git a/example/ios/Podfile b/example/ios/Podfile index b30a428b..0ee4a537 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -35,7 +35,7 @@ end target 'Runner' do use_frameworks! use_modular_headers! - + # Flutter Pod copied_flutter_dir = File.join(__dir__, 'Flutter') diff --git a/example/lib/sample/components/form/items_example/title_select_example.dart b/example/lib/sample/components/form/items_example/title_select_example.dart index 698237bf..9fe73327 100644 --- a/example/lib/sample/components/form/items_example/title_select_example.dart +++ b/example/lib/sample/components/form/items_example/title_select_example.dart @@ -47,7 +47,7 @@ class TitleSelectInputState extends State { title: _list[0], hint: "请输入", controller: controller, - inputFormatters: [FilteringTextInputFormatter(RegExp('[0-9"]'))], + inputFormatters: [FilteringTextInputFormatter.digitsOnly], selectedIndex: -1, selectList: _list, onTip: () { diff --git a/example/lib/sample/theme/config_test_utils.dart b/example/lib/sample/theme/config_test_utils.dart index f91dd885..0d741da6 100644 --- a/example/lib/sample/theme/config_test_utils.dart +++ b/example/lib/sample/theme/config_test_utils.dart @@ -158,16 +158,6 @@ class TestConfigUtils { titleMaxLength: 20, titleStyle: BrnTextStyle(color: Color(0xff222222), fontWeight: FontWeight.w600, fontSize: 24), actionsStyle: BrnTextStyle(color: Color(0xFF3072F6), fontWeight: FontWeight.w600, fontSize: 18), - flexibleSpace: Container( - width: double.infinity, - height: MediaQueryData.fromWindow(window).padding.top + 57, - decoration: BoxDecoration( - gradient: LinearGradient(colors: [ - Color(0xfffafafa), - Color(0xfff5f5f5), - ], begin: Alignment.topCenter, end: Alignment.bottomCenter), - ), - ), ); static BrnButtonConfig defaultButtonConfig = BrnButtonConfig( diff --git a/lib/src/components/navbar/brn_appbar.dart b/lib/src/components/navbar/brn_appbar.dart index be1d1efc..23e426c6 100644 --- a/lib/src/components/navbar/brn_appbar.dart +++ b/lib/src/components/navbar/brn_appbar.dart @@ -276,12 +276,12 @@ class BrnAppBar extends PreferredSize { .merge(_defaultConfig); Widget flexibleSpace; - if (_defaultConfig.flexibleSpace != null) { + if (this.flexibleSpace != null) { flexibleSpace = Container( height: _defaultConfig.appBarHeight + MediaQueryData.fromWindow(window)?.padding?.top ?? 0, - child: _defaultConfig.flexibleSpace, + child: this.flexibleSpace, ); } diff --git a/lib/src/components/sugsearch/brn_search_text.dart b/lib/src/components/sugsearch/brn_search_text.dart index 98656f3c..421cb5a2 100644 --- a/lib/src/components/sugsearch/brn_search_text.dart +++ b/lib/src/components/sugsearch/brn_search_text.dart @@ -271,7 +271,7 @@ class _SearchTextState extends State { child: GestureDetector( onTap: () { if (widget.onTextClear != null) { - bool isIntercept = widget.onTextClear!() ?? false; + bool isIntercept = widget.onTextClear!(); if (isIntercept) return; } textEditingController!.clear(); diff --git a/lib/src/theme/base/brn_base_config.dart b/lib/src/theme/base/brn_base_config.dart index c339629d..ebbcf3a7 100644 --- a/lib/src/theme/base/brn_base_config.dart +++ b/lib/src/theme/base/brn_base_config.dart @@ -49,6 +49,5 @@ abstract class BrnBaseConfig { _currentLevelCommonConfig ?? BrnThemeConfigurator.instance .getConfig(configId: configId) - .commonConfig ?? - BrnDefaultConfigUtils.defaultCommonConfig; + .commonConfig; } diff --git a/lib/src/theme/base/brn_default_config_utils.dart b/lib/src/theme/base/brn_default_config_utils.dart index 92e6f5b0..66861fb3 100644 --- a/lib/src/theme/base/brn_default_config_utils.dart +++ b/lib/src/theme/base/brn_default_config_utils.dart @@ -42,12 +42,15 @@ class BrnDefaultConfigUtils { buttonConfig: defaultButtonConfig, actionSheetConfig: defaultActionSheetConfig, pickerConfig: defaultPickerConfig, - enhanceNumberCardConfig: defaultNumberInfoConfig, + enhanceNumberCardConfig: defaultEnhanceNumberInfoConfig, tabBarConfig: defaultTabBarConfig, selectionConfig: defaultSelectionConfig, galleryDetailConfig: defaultGalleryDetailConfig, ); + + + /// 全局默认配置 static BrnCommonConfig defaultCommonConfig = BrnCommonConfig( /// 主题色相关 @@ -119,29 +122,29 @@ class BrnDefaultConfigUtils { /// 文本字号 /// /// 特殊数据展示,DIN Condensed数字字体,用于强吸引 - fontSizeDIN: 28, + fontSizeDIN: 28.0, /// 标题字体 /// 名称/页面大标题 - fontSizeHeadLg: 22, + fontSizeHeadLg: 22.0, /// 标题字体 /// 内容模块标题/一级标题 - fontSizeHead: 18, + fontSizeHead: 18.0, /// 子标题字体 /// 标题/录入文字/大按钮文字/二级标题 - fontSizeSubHead: 16, + fontSizeSubHead: 16.0, /// 基础字体 /// 内容副文本/普通说明文字 - fontSizeBase: 14, + fontSizeBase: 14.0, /// 辅助字体-普通 - fontSizeCaption: 12, + fontSizeCaption: 12.0, ///辅助字体-小 - fontSizeCaptionSm: 11, + fontSizeCaptionSm: 11.0, /// 圆角尺寸 radiusXs: 2.0, @@ -151,31 +154,31 @@ class BrnDefaultConfigUtils { /// 边框尺寸 borderWidthSm: 0.5, - borderWidthMd: 1, - borderWidthLg: 2, + borderWidthMd: 1.0, + borderWidthLg: 2.0, /// 水平间距 - hSpacingXs: 8, - hSpacingSm: 12, - hSpacingMd: 16, - hSpacingLg: 20, - hSpacingXl: 24, - hSpacingXxl: 42, + hSpacingXs: 8.0, + hSpacingSm: 12.0, + hSpacingMd: 16.0, + hSpacingLg: 20.0, + hSpacingXl: 24.0, + hSpacingXxl: 42.0, /// 垂直间距 - vSpacingXs: 4, - vSpacingSm: 8, - vSpacingMd: 12, - vSpacingLg: 14, - vSpacingXl: 16, - vSpacingXxl: 28, + vSpacingXs: 4.0, + vSpacingSm: 8.0, + vSpacingMd: 12.0, + vSpacingLg: 14.0, + vSpacingXl: 16.0, + vSpacingXxl: 28.0, /// 图标大小 - iconSizeXxs: 8, - iconSizeXs: 12, - iconSizeSm: 14, - iconSizeMd: 16, - iconSizeLg: 32, + iconSizeXxs: 8.0, + iconSizeXs: 12.0, + iconSizeSm: 14.0, + iconSizeMd: 16.0, + iconSizeLg: 32.0, ); ///******** 以下是子配置项 ********/// @@ -207,7 +210,7 @@ class BrnDefaultConfigUtils { fontSize: defaultCommonConfig.fontSizeSubHead, ), optionsMiddlePadding: EdgeInsets.only( - left: defaultCommonConfig.hSpacingMd ?? 0, + left: defaultCommonConfig.hSpacingMd, ), optionTextStyle: BrnTextStyle( height: 1.3, @@ -220,20 +223,20 @@ class BrnDefaultConfigUtils { fontSize: defaultCommonConfig.fontSizeSubHead, ), formPadding: EdgeInsets.only( - left: 0, - top: defaultCommonConfig.vSpacingLg ?? 0, - right: defaultCommonConfig.hSpacingLg ?? 0, - bottom: defaultCommonConfig.vSpacingLg ?? 0, + left: 0.0, + top: defaultCommonConfig.vSpacingLg , + right: defaultCommonConfig.hSpacingLg , + bottom: defaultCommonConfig.vSpacingLg, ), titlePaddingSm: EdgeInsets.only(left: 10), - titlePaddingLg: EdgeInsets.only(left: defaultCommonConfig.hSpacingLg ?? 0), + titlePaddingLg: EdgeInsets.only(left: defaultCommonConfig.hSpacingLg), subTitlePadding: EdgeInsets.only( - left: defaultCommonConfig.hSpacingLg ?? 0, - top: defaultCommonConfig.vSpacingXs ?? 0, + left: defaultCommonConfig.hSpacingLg, + top: defaultCommonConfig.vSpacingXs, ), errorPadding: EdgeInsets.only( - left: defaultCommonConfig.hSpacingLg ?? 0, - top: defaultCommonConfig.vSpacingXs ?? 0, + left: defaultCommonConfig.hSpacingLg, + top: defaultCommonConfig.vSpacingXs, ), disableTextStyle: BrnTextStyle( color: defaultCommonConfig.colorTextDisabled, @@ -247,18 +250,18 @@ class BrnDefaultConfigUtils { /// Dialog默认配置 static BrnDialogConfig defaultDialogConfig = BrnDialogConfig( - dialogWidth: 300, + dialogWidth: 300.0, radius: defaultCommonConfig.radiusLg, - iconPadding: EdgeInsets.only(top: defaultCommonConfig.vSpacingXxl ?? 0), + iconPadding: EdgeInsets.only(top: defaultCommonConfig.vSpacingXxl), titlePaddingSm: EdgeInsets.only( - top: 12, - left: defaultCommonConfig.hSpacingXxl ?? 0, - right: defaultCommonConfig.hSpacingXxl ?? 0, + top: 12.0, + left: defaultCommonConfig.hSpacingXxl, + right: defaultCommonConfig.hSpacingXxl, ), titlePaddingLg: EdgeInsets.only( - top: 28, - left: defaultCommonConfig.hSpacingXxl ?? 0, - right: defaultCommonConfig.hSpacingXxl ?? 0, + top: 28.0, + left: defaultCommonConfig.hSpacingXxl, + right: defaultCommonConfig.hSpacingXxl, ), titleTextStyle: BrnTextStyle( fontWeight: FontWeight.w600, @@ -267,14 +270,14 @@ class BrnDefaultConfigUtils { ), titleTextAlign: TextAlign.center, contentPaddingSm: EdgeInsets.only( - top: 8, - left: defaultCommonConfig.hSpacingXl ?? 0, - right: defaultCommonConfig.hSpacingXl ?? 0, + top: 8.0, + left: defaultCommonConfig.hSpacingXl, + right: defaultCommonConfig.hSpacingXl, ), contentPaddingLg: EdgeInsets.only( - top: 28, - left: defaultCommonConfig.hSpacingXl ?? 0, - right: defaultCommonConfig.hSpacingXl ?? 0, + top: 28.0, + left: defaultCommonConfig.hSpacingXl, + right: defaultCommonConfig.hSpacingXl, ), contentTextStyle: BrnTextStyle( fontSize: defaultCommonConfig.fontSizeBase, @@ -283,14 +286,14 @@ class BrnDefaultConfigUtils { ), contentTextAlign: TextAlign.center, warningPaddingSm: EdgeInsets.only( - top: 6, - left: defaultCommonConfig.hSpacingXl ?? 0, - right: defaultCommonConfig.hSpacingXl ?? 0, + top: 6.0, + left: defaultCommonConfig.hSpacingXl, + right: defaultCommonConfig.hSpacingXl, ), warningPaddingLg: EdgeInsets.only( - top: 28, - left: defaultCommonConfig.hSpacingXl ?? 0, - right: defaultCommonConfig.hSpacingXl ?? 0, + top: 28.0, + left: defaultCommonConfig.hSpacingXl, + right: defaultCommonConfig.hSpacingXl, ), warningTextAlign: TextAlign.center, warningTextStyle: BrnTextStyle( @@ -298,7 +301,7 @@ class BrnDefaultConfigUtils { color: defaultCommonConfig.brandError, decoration: TextDecoration.none, ), - dividerPadding: EdgeInsets.only(top: 28), + dividerPadding: EdgeInsets.only(top: 28.0), mainActionTextStyle: BrnTextStyle( color: defaultCommonConfig.brandPrimary, fontWeight: FontWeight.w600, @@ -320,7 +323,7 @@ class BrnDefaultConfigUtils { titleWithHeightTextStyle: BrnTextStyle( color: defaultCommonConfig.colorTextBase, fontSize: defaultCommonConfig.fontSizeHead, - height: 25 / 18, + height: 25.0 / 18.0, fontWeight: FontWeight.w600, ), titleTextStyle: BrnTextStyle( @@ -341,8 +344,8 @@ class BrnDefaultConfigUtils { fontSize: defaultCommonConfig.fontSizeBase, ), cardTitlePadding: EdgeInsets.only( - top: defaultCommonConfig.vSpacingXl ?? 0, - bottom: defaultCommonConfig.vSpacingMd ?? 0, + top: defaultCommonConfig.vSpacingXl, + bottom: defaultCommonConfig.vSpacingMd, ), alignment: PlaceholderAlignment.middle, cardBackgroundColor: defaultCommonConfig.fillBase, @@ -373,8 +376,8 @@ class BrnDefaultConfigUtils { color: defaultCommonConfig.colorTextBaseInverse, fontSize: defaultCommonConfig.fontSizeSubHead, ), - singleMinWidth: 160, - doubleMinWidth: 120, + singleMinWidth: 160.0, + doubleMinWidth: 120.0, ); /// 标签配置 @@ -391,11 +394,12 @@ class BrnDefaultConfigUtils { tagBackgroundColor: defaultCommonConfig.fillBody, selectedTagBackgroundColor: defaultCommonConfig.brandPrimary, tagRadius: defaultCommonConfig.radiusXs, - tagHeight: 34, - tagWidth: 75, - tagMinWidth: 75, + tagHeight: 34.0, + tagWidth: 75.0, + tagMinWidth: 75.0, ); + /// 导航栏配置 static BrnAppBarConfig defaultAppBarConfig = BrnAppBarConfig( backgroundColor: Colors.white, @@ -418,7 +422,7 @@ class BrnDefaultConfigUtils { fontWeight: FontWeight.w600, ), titleMaxLength: BrnAppBarTheme.maxLength, - leftAndRightPadding: 20, + leftAndRightPadding: 20.0, itemSpacing: BrnAppBarTheme.iconMargin, titlePadding: EdgeInsets.zero, iconSize: BrnAppBarTheme.iconSize, @@ -449,9 +453,9 @@ class BrnDefaultConfigUtils { /// 内容信息(一列)配置 static BrnPairRichInfoGridConfig defaultPairRichInfoGridConfig = BrnPairRichInfoGridConfig( - rowSpacing: 4, - itemSpacing: 2, - itemHeight: 20, + rowSpacing: 4.0, + itemSpacing: 2.0, + itemHeight: 20.0, keyTextStyle: BrnTextStyle( color: defaultCommonConfig.colorTextSecondary, fontSize: defaultCommonConfig.fontSizeBase, @@ -472,12 +476,12 @@ class BrnDefaultConfigUtils { /// 按钮配置 static BrnButtonConfig defaultButtonConfig = BrnButtonConfig( - bigButtonRadius: 6, - bigButtonHeight: 48, - bigButtonFontSize: 16, - smallButtonRadius: 4, - smallButtonHeight: 32, - smallButtonFontSize: 14, + bigButtonRadius: 6.0, + bigButtonHeight: 48.0, + bigButtonFontSize: 16.0, + smallButtonRadius: 4.0, + smallButtonHeight: 32.0, + smallButtonFontSize: 14.0, configId: BRUNO_CONFIG_ID, ); @@ -522,8 +526,8 @@ class BrnDefaultConfigUtils { fontSize: defaultCommonConfig.fontSizeSubHead, fontWeight: FontWeight.w600, ), - titlePadding: EdgeInsets.symmetric(horizontal: 60, vertical: 16), - contentPadding: EdgeInsets.symmetric(horizontal: 60, vertical: 12), + titlePadding: EdgeInsets.symmetric(horizontal: 60.0, vertical: 16.0), + contentPadding: EdgeInsets.symmetric(horizontal: 60.0, vertical: 12.0), ); static BrnPickerConfig defaultPickerConfig = BrnPickerConfig( @@ -559,13 +563,13 @@ class BrnDefaultConfigUtils { ); /// 数字增强信息配置 - static BrnEnhanceNumberCardConfig defaultNumberInfoConfig = + static BrnEnhanceNumberCardConfig defaultEnhanceNumberInfoConfig = BrnEnhanceNumberCardConfig( - runningSpace: 16, - itemRunningSpace: 8, - titleTextStyle: BrnTextStyle(fontSize: 28, fontWeight: FontWeight.w600), + runningSpace: 16.0, + itemRunningSpace: 8.0, + titleTextStyle: BrnTextStyle(fontSize: 28.0, fontWeight: FontWeight.w600), descTextStyle: BrnTextStyle( - fontSize: 12, + fontSize: 12.0, color: defaultCommonConfig.colorTextSecondary, ), dividerWidth: 0.5, @@ -573,9 +577,10 @@ class BrnDefaultConfigUtils { /// TabBar配置 static BrnTabBarConfig defaultTabBarConfig = BrnTabBarConfig( - tabHeight: 50, - indicatorHeight: 2, - indicatorWidth: 24, + backgroundColor: Colors.white, + tabHeight: 50.0, + indicatorHeight: 2.0, + indicatorWidth: 24.0, labelStyle: BrnTextStyle( color: defaultCommonConfig.brandPrimary, fontSize: defaultCommonConfig.fontSizeSubHead, @@ -591,15 +596,15 @@ class BrnDefaultConfigUtils { color: defaultCommonConfig.colorTextBase, fontSize: defaultCommonConfig.fontSizeCaption, ), - tagNormalBgColor: defaultCommonConfig.brandPrimary?.withAlpha(0x14), + tagNormalBgColor: defaultCommonConfig.brandPrimary.withAlpha(0x14), tagSelectedTextStyle: BrnTextStyle( color: defaultCommonConfig.brandPrimary, fontSize: defaultCommonConfig.fontSizeCaption, ), tagSelectedBgColor: defaultCommonConfig.fillBody, - tagSpacing: 12, + tagSpacing: 12.0, preLineTagCount: 4, - tagHeight: 32, + tagHeight: 32.0, ); /// 筛选项配置 @@ -625,7 +630,7 @@ class BrnDefaultConfigUtils { tagRadius: defaultCommonConfig.radiusSm, tagNormalBackgroundColor: defaultCommonConfig.fillBody, tagSelectedBackgroundColor: - defaultCommonConfig.brandPrimary?.withOpacity(0.12), + defaultCommonConfig.brandPrimary.withOpacity(0.12), rangeTitleTextStyle: BrnTextStyle( color: defaultCommonConfig.colorTextBase, fontSize: defaultCommonConfig.fontSizeSubHead, @@ -708,7 +713,7 @@ class BrnDefaultConfigUtils { appbarBackgroundColor: Colors.black, appbarBrightness: Brightness.dark, tabBarUnSelectedLabelStyle: BrnTextStyle( - fontSize: 16, + fontSize: 16.0, color: Color(0XFFCCCCCC), ), tabBarLabelStyle: BrnTextStyle( diff --git a/lib/src/theme/brn_theme_configurator.dart b/lib/src/theme/brn_theme_configurator.dart index 999b03a3..392030cb 100644 --- a/lib/src/theme/brn_theme_configurator.dart +++ b/lib/src/theme/brn_theme_configurator.dart @@ -5,9 +5,19 @@ const String BRUNO_CONFIG_ID = 'BRUNO_CONFIG_ID'; const String GLOBAL_CONFIG_ID = 'GLOBAL_CONFIG_ID'; class BrnThemeConfigurator { - BrnThemeConfigurator._(); - static late final BrnThemeConfigurator instance = BrnThemeConfigurator._(); + BrnThemeConfigurator._(){ + _checkAndInitBrunoConfig(); + } + + static BrnThemeConfigurator? _instance; + + static get instance { + if (null == _instance) { + _instance = BrnThemeConfigurator._(); + } + return _instance!; + } Map globalConfig = {}; @@ -16,12 +26,10 @@ class BrnThemeConfigurator { BrnAllThemeConfig? allThemeConfig, { String configId = GLOBAL_CONFIG_ID, }) { - // 先赋值默认配置 - _checkAndInitBrunoConfig(); // 打平内部字段 if (allThemeConfig != null) { // 赋值传入配置 - instance.globalConfig[configId] = allThemeConfig + globalConfig[configId] = allThemeConfig ..initThemeConfig(configId); } } @@ -31,7 +39,6 @@ class BrnThemeConfigurator { /// 2、若获取的为 null,则使用默认的全局配置。 /// 3、若没有配置 GLOBAL_CONFIG_ID ,则使用 BRUNO 的配置。 BrnAllThemeConfig getConfig({String configId = GLOBAL_CONFIG_ID}) { - _checkAndInitBrunoConfig(); BrnAllThemeConfig? allThemeConfig = globalConfig[configId] ?? globalConfig[GLOBAL_CONFIG_ID] ?? diff --git a/lib/src/theme/configs/brn_abnormal_state_config.dart b/lib/src/theme/configs/brn_abnormal_state_config.dart index 805dc1ad..67b829ff 100644 --- a/lib/src/theme/configs/brn_abnormal_state_config.dart +++ b/lib/src/theme/configs/brn_abnormal_state_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -6,16 +7,24 @@ import 'package:bruno/src/theme/configs/brn_common_config.dart'; /// 描述: 空页面配置类 class BrnAbnormalStateConfig extends BrnBaseConfig { BrnAbnormalStateConfig({ - this.titleTextStyle, - this.contentTextStyle, - this.operateTextStyle, - this.btnRadius, - this.singleTextStyle, - this.doubleTextStyle, - this.singleMinWidth, - this.doubleMinWidth, + BrnTextStyle? titleTextStyle, + BrnTextStyle? contentTextStyle, + BrnTextStyle? operateTextStyle, + double? btnRadius, + BrnTextStyle? singleTextStyle, + BrnTextStyle? doubleTextStyle, + double? singleMinWidth, + double? doubleMinWidth, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _titleTextStyle = titleTextStyle, + _contentTextStyle = contentTextStyle, + _operateTextStyle = operateTextStyle, + _btnRadius = btnRadius, + _singleTextStyle = singleTextStyle, + _doubleTextStyle = doubleTextStyle, + _singleMinWidth = singleMinWidth, + _doubleMinWidth = doubleMinWidth, + super(configId: configId); /// 文案区域标题 /// @@ -24,7 +33,7 @@ class BrnAbnormalStateConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? titleTextStyle; + BrnTextStyle? _titleTextStyle; /// 文案区域内容 /// @@ -32,7 +41,7 @@ class BrnAbnormalStateConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextHint], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? contentTextStyle; + BrnTextStyle? _contentTextStyle; /// 操作区域文本样式 /// @@ -40,11 +49,11 @@ class BrnAbnormalStateConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.brandPrimary], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? operateTextStyle; + BrnTextStyle? _operateTextStyle; /// 圆角 /// default value is [BrnCommonConfig.radiusSm] - double? btnRadius; + double? _btnRadius; /// 单按钮文本样式 /// @@ -52,7 +61,7 @@ class BrnAbnormalStateConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBaseInverse], /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? singleTextStyle; + BrnTextStyle? _singleTextStyle; /// 双按钮文本样式 /// @@ -60,15 +69,46 @@ class BrnAbnormalStateConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.brandPrimary], /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? doubleTextStyle; + BrnTextStyle? _doubleTextStyle; /// 单按钮的按钮最小宽度 /// 默认值为 160 - double? singleMinWidth; + double? _singleMinWidth; /// 多按钮的按钮最小宽度 /// 默认值为 120 - double? doubleMinWidth; + double? _doubleMinWidth; + + BrnTextStyle get titleTextStyle => + _titleTextStyle ?? + BrnDefaultConfigUtils.defaultAbnormalStateConfig.titleTextStyle; + + BrnTextStyle get contentTextStyle => + _contentTextStyle ?? + BrnDefaultConfigUtils.defaultAbnormalStateConfig.contentTextStyle; + + BrnTextStyle get operateTextStyle => + _operateTextStyle ?? + BrnDefaultConfigUtils.defaultAbnormalStateConfig.operateTextStyle; + + double get btnRadius => + _btnRadius ?? BrnDefaultConfigUtils.defaultAbnormalStateConfig.btnRadius; + + BrnTextStyle get singleTextStyle => + _singleTextStyle ?? + BrnDefaultConfigUtils.defaultAbnormalStateConfig.singleTextStyle; + + BrnTextStyle get doubleTextStyle => + _doubleTextStyle ?? + BrnDefaultConfigUtils.defaultAbnormalStateConfig.doubleTextStyle; + + double get singleMinWidth => + _singleMinWidth ?? + BrnDefaultConfigUtils.defaultAbnormalStateConfig.singleMinWidth; + + double get doubleMinWidth => + _doubleMinWidth ?? + BrnDefaultConfigUtils.defaultAbnormalStateConfig.doubleMinWidth; @override void initThemeConfig( @@ -81,43 +121,43 @@ class BrnAbnormalStateConfig extends BrnBaseConfig { ); /// 用户全局组件配置 - BrnAbnormalStateConfig? abnormalStateConfig = BrnThemeConfigurator.instance + BrnAbnormalStateConfig abnormalStateConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .abnormalStateConfig; - titleTextStyle = abnormalStateConfig?.titleTextStyle?.merge( + _titleTextStyle = abnormalStateConfig.titleTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(titleTextStyle), + ).merge(_titleTextStyle), ); - contentTextStyle = abnormalStateConfig?.contentTextStyle?.merge( + _contentTextStyle = abnormalStateConfig.contentTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextHint, fontSize: commonConfig.fontSizeSubHead, - ).merge(contentTextStyle), + ).merge(_contentTextStyle), ); - operateTextStyle = abnormalStateConfig?.operateTextStyle?.merge( + _operateTextStyle = abnormalStateConfig.operateTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeBase, - ).merge(operateTextStyle), + ).merge(_operateTextStyle), ); - singleTextStyle = abnormalStateConfig?.singleTextStyle?.merge( + _singleTextStyle = abnormalStateConfig.singleTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBaseInverse, fontSize: commonConfig.fontSizeSubHead, - ).merge(singleTextStyle), + ).merge(_singleTextStyle), ); - doubleTextStyle = abnormalStateConfig?.doubleTextStyle?.merge( + _doubleTextStyle = abnormalStateConfig.doubleTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeSubHead, - ).merge(doubleTextStyle), + ).merge(_doubleTextStyle), ); - btnRadius ??= abnormalStateConfig?.btnRadius; - singleMinWidth ??= abnormalStateConfig?.singleMinWidth; - doubleMinWidth ??= abnormalStateConfig?.doubleMinWidth; + _btnRadius ??= abnormalStateConfig._btnRadius; + _singleMinWidth ??= abnormalStateConfig._singleMinWidth; + _doubleMinWidth ??= abnormalStateConfig._doubleMinWidth; } BrnAbnormalStateConfig copyWith({ @@ -131,33 +171,28 @@ class BrnAbnormalStateConfig extends BrnBaseConfig { double? doubleMinWidth, }) { return BrnAbnormalStateConfig( - titleTextStyle: titleTextStyle ?? this.titleTextStyle, - contentTextStyle: contentTextStyle ?? this.contentTextStyle, - operateTextStyle: operateTextStyle ?? this.operateTextStyle, - btnRadius: btnRadius ?? this.btnRadius, - singleTextStyle: singleTextStyle ?? this.singleTextStyle, - doubleTextStyle: doubleTextStyle ?? this.doubleTextStyle, - singleMinWidth: singleMinWidth ?? this.singleMinWidth, - doubleMinWidth: doubleMinWidth ?? this.doubleMinWidth, + titleTextStyle: titleTextStyle ?? _titleTextStyle, + contentTextStyle: contentTextStyle ?? _contentTextStyle, + operateTextStyle: operateTextStyle ?? _operateTextStyle, + btnRadius: btnRadius ?? _btnRadius, + singleTextStyle: singleTextStyle ?? _singleTextStyle, + doubleTextStyle: doubleTextStyle ?? _doubleTextStyle, + singleMinWidth: singleMinWidth ?? _singleMinWidth, + doubleMinWidth: doubleMinWidth ?? _doubleMinWidth, ); } BrnAbnormalStateConfig merge(BrnAbnormalStateConfig? other) { if (other == null) return this; return copyWith( - titleTextStyle: - titleTextStyle?.merge(other.titleTextStyle) ?? other.titleTextStyle, - contentTextStyle: contentTextStyle?.merge(other.contentTextStyle) ?? - other.contentTextStyle, - operateTextStyle: operateTextStyle?.merge(other.operateTextStyle) ?? - other.operateTextStyle, - btnRadius: other.btnRadius, - singleTextStyle: singleTextStyle?.merge(other.singleTextStyle) ?? - other.singleTextStyle, - doubleTextStyle: doubleTextStyle?.merge(other.doubleTextStyle) ?? - other.doubleTextStyle, - singleMinWidth: other.singleMinWidth, - doubleMinWidth: other.doubleMinWidth, + titleTextStyle: titleTextStyle.merge(other._titleTextStyle), + contentTextStyle: contentTextStyle.merge(other._contentTextStyle), + operateTextStyle: operateTextStyle.merge(other._operateTextStyle), + btnRadius: other._btnRadius, + singleTextStyle: singleTextStyle.merge(other._singleTextStyle), + doubleTextStyle: doubleTextStyle.merge(other._doubleTextStyle), + singleMinWidth: other._singleMinWidth, + doubleMinWidth: other._doubleMinWidth, ); } } diff --git a/lib/src/theme/configs/brn_action_sheet_config.dart b/lib/src/theme/configs/brn_action_sheet_config.dart index 6b975ac3..b383cf94 100644 --- a/lib/src/theme/configs/brn_action_sheet_config.dart +++ b/lib/src/theme/configs/brn_action_sheet_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -9,23 +10,34 @@ class BrnActionSheetConfig extends BrnBaseConfig { /// 遵循外部主题配置 /// 默认为 [BrnDefaultConfigUtils.defaultActionSheetConfig] BrnActionSheetConfig({ - this.titleStyle, - this.itemTitleStyle, - this.itemTitleStyleLink, - this.itemTitleStyleAlert, - this.itemDescStyle, - this.itemDescStyleLink, - this.itemDescStyleAlert, - this.cancelStyle, - this.topRadius, - this.contentPadding, - this.titlePadding, + BrnTextStyle? titleStyle, + BrnTextStyle? itemTitleStyle, + BrnTextStyle? itemTitleStyleLink, + BrnTextStyle? itemTitleStyleAlert, + BrnTextStyle? itemDescStyle, + BrnTextStyle? itemDescStyleLink, + BrnTextStyle? itemDescStyleAlert, + BrnTextStyle? cancelStyle, + double? topRadius, + EdgeInsets? contentPadding, + EdgeInsets? titlePadding, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _titleStyle = titleStyle, + _itemTitleStyle = itemTitleStyle, + _itemTitleStyleLink = itemTitleStyleLink, + _itemTitleStyleAlert = itemTitleStyleAlert, + _itemDescStyle = itemDescStyle, + _itemDescStyleLink = itemDescStyleLink, + _itemDescStyleAlert = itemDescStyleAlert, + _cancelStyle = cancelStyle, + _topRadius = topRadius, + _contentPadding = contentPadding, + _titlePadding = titlePadding, + super(configId: configId); /// ActionSheet 的顶部圆角 /// 默认值为 [BrnCommonConfig.radiusLg] - double? topRadius; + double? _topRadius; /// 标题样式 /// @@ -33,7 +45,7 @@ class BrnActionSheetConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextSecondary], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? titleStyle; + BrnTextStyle? _titleStyle; /// 元素标题默认样式 /// @@ -41,7 +53,7 @@ class BrnActionSheetConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize:[BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? itemTitleStyle; + BrnTextStyle? _itemTitleStyle; /// 元素标题链接样式 /// @@ -50,7 +62,7 @@ class BrnActionSheetConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? itemTitleStyleLink; + BrnTextStyle? _itemTitleStyleLink; /// 元素警示项标题样式 /// @@ -59,7 +71,7 @@ class BrnActionSheetConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeBase], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? itemTitleStyleAlert; + BrnTextStyle? _itemTitleStyleAlert; /// 元素描述默认样式 /// @@ -68,7 +80,7 @@ class BrnActionSheetConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeCaption], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? itemDescStyle; + BrnTextStyle? _itemDescStyle; /// 元素标题描述链接样式 /// @@ -77,7 +89,7 @@ class BrnActionSheetConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeCaption], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? itemDescStyleLink; + BrnTextStyle? _itemDescStyleLink; /// 元素警示项标题描述样式 /// @@ -86,7 +98,7 @@ class BrnActionSheetConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeCaption], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? itemDescStyleAlert; + BrnTextStyle? _itemDescStyleAlert; /// 取消按钮样式 /// @@ -95,17 +107,59 @@ class BrnActionSheetConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? cancelStyle; + BrnTextStyle? _cancelStyle; /// 内容左右间距 /// /// EdgeInsets.symmetric(horizontal: 60, vertical: 12) - EdgeInsets? contentPadding; + EdgeInsets? _contentPadding; /// 标题左右间距 /// /// EdgeInsets.symmetric(horizontal: 60, vertical: 16) - EdgeInsets? titlePadding; + EdgeInsets? _titlePadding; + + double get topRadius => + _topRadius ?? BrnDefaultConfigUtils.defaultActionSheetConfig.topRadius; + + BrnTextStyle get titleStyle => + _titleStyle ?? BrnDefaultConfigUtils.defaultActionSheetConfig.titleStyle; + + BrnTextStyle get itemTitleStyle => + _itemTitleStyle ?? + BrnDefaultConfigUtils.defaultActionSheetConfig.itemTitleStyle; + + BrnTextStyle get itemTitleStyleLink => + _itemTitleStyleLink ?? + BrnDefaultConfigUtils.defaultActionSheetConfig.itemTitleStyleLink; + + BrnTextStyle get itemTitleStyleAlert => + _itemTitleStyleAlert ?? + BrnDefaultConfigUtils.defaultActionSheetConfig.itemTitleStyleAlert; + + BrnTextStyle get itemDescStyle => + _itemDescStyle ?? + BrnDefaultConfigUtils.defaultActionSheetConfig.itemDescStyle; + + BrnTextStyle get itemDescStyleLink => + _itemDescStyleLink ?? + BrnDefaultConfigUtils.defaultActionSheetConfig.itemDescStyleLink; + + BrnTextStyle get itemDescStyleAlert => + _itemDescStyleAlert ?? + BrnDefaultConfigUtils.defaultActionSheetConfig.itemDescStyleAlert; + + BrnTextStyle get cancelStyle => + _cancelStyle ?? + BrnDefaultConfigUtils.defaultActionSheetConfig.cancelStyle; + + EdgeInsets get contentPadding => + _contentPadding ?? + BrnDefaultConfigUtils.defaultActionSheetConfig.contentPadding; + + EdgeInsets get titlePadding => + _titlePadding ?? + BrnDefaultConfigUtils.defaultActionSheetConfig.titlePadding; @override void initThemeConfig( @@ -118,61 +172,61 @@ class BrnActionSheetConfig extends BrnBaseConfig { ); /// 用户全局组件配置 - BrnActionSheetConfig? actionSheetConfig = BrnThemeConfigurator.instance + BrnActionSheetConfig actionSheetConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .actionSheetConfig; - titlePadding ??= actionSheetConfig?.titlePadding; - contentPadding ??= actionSheetConfig?.contentPadding; - titleStyle = actionSheetConfig?.titleStyle?.merge( + _titlePadding ??= actionSheetConfig.titlePadding; + _contentPadding ??= actionSheetConfig.contentPadding; + _titleStyle = actionSheetConfig.titleStyle.merge( BrnTextStyle( color: commonConfig.colorTextSecondary, fontSize: commonConfig.fontSizeBase, - ).merge(titleStyle), + ).merge(_titleStyle), ); - itemTitleStyle = actionSheetConfig?.itemTitleStyle?.merge( + _itemTitleStyle = actionSheetConfig.itemTitleStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(itemTitleStyle), + ).merge(_itemTitleStyle), ); - itemTitleStyleLink = actionSheetConfig?.itemTitleStyleLink?.merge( + _itemTitleStyleLink = actionSheetConfig.itemTitleStyleLink.merge( BrnTextStyle( color: commonConfig.colorLink, fontSize: commonConfig.fontSizeSubHead, - ).merge(itemTitleStyleLink), + ).merge(_itemTitleStyleLink), ); - itemTitleStyleAlert = actionSheetConfig?.itemTitleStyleAlert?.merge( + _itemTitleStyleAlert = actionSheetConfig.itemTitleStyleAlert.merge( BrnTextStyle( color: commonConfig.brandError, fontSize: commonConfig.fontSizeBase, - ).merge(itemTitleStyleAlert), + ).merge(_itemTitleStyleAlert), ); - itemDescStyle = actionSheetConfig?.itemDescStyle?.merge( + _itemDescStyle = actionSheetConfig.itemDescStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeCaption, - ).merge(itemDescStyle), + ).merge(_itemDescStyle), ); - itemDescStyleLink = actionSheetConfig?.itemDescStyleLink?.merge( + _itemDescStyleLink = actionSheetConfig.itemDescStyleLink.merge( BrnTextStyle( color: commonConfig.colorLink, fontSize: commonConfig.fontSizeCaption, - ).merge(itemDescStyleLink), + ).merge(_itemDescStyleLink), ); - itemDescStyleAlert = actionSheetConfig?.itemDescStyleAlert?.merge( + _itemDescStyleAlert = actionSheetConfig.itemDescStyleAlert.merge( BrnTextStyle( color: commonConfig.brandError, fontSize: commonConfig.fontSizeCaption, - ).merge(itemDescStyleAlert), + ).merge(_itemDescStyleAlert), ); - cancelStyle = actionSheetConfig?.cancelStyle?.merge( + _cancelStyle = actionSheetConfig.cancelStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(cancelStyle), + ).merge(_cancelStyle), ); - topRadius ??= commonConfig.radiusLg; + _topRadius ??= commonConfig.radiusLg; } BrnActionSheetConfig copyWith({ @@ -189,41 +243,34 @@ class BrnActionSheetConfig extends BrnBaseConfig { EdgeInsets? titlePadding, }) { return BrnActionSheetConfig( - titleStyle: titleStyle ?? this.titleStyle, - itemTitleStyle: itemTitleStyle ?? this.itemTitleStyle, - itemTitleStyleLink: itemTitleStyleLink ?? this.itemTitleStyleLink, - itemTitleStyleAlert: itemTitleStyleAlert ?? this.itemTitleStyleAlert, - itemDescStyle: itemDescStyle ?? this.itemDescStyle, - itemDescStyleLink: itemDescStyleLink ?? this.itemDescStyleLink, - itemDescStyleAlert: itemDescStyleAlert ?? this.itemDescStyleAlert, - cancelStyle: cancelStyle ?? this.cancelStyle, - topRadius: topRadius ?? this.topRadius, - contentPadding: contentPadding ?? this.contentPadding, - titlePadding: titlePadding ?? this.titlePadding, + titleStyle: titleStyle ?? _titleStyle, + itemTitleStyle: itemTitleStyle ?? _itemTitleStyle, + itemTitleStyleLink: itemTitleStyleLink ?? _itemTitleStyleLink, + itemTitleStyleAlert: itemTitleStyleAlert ?? _itemTitleStyleAlert, + itemDescStyle: itemDescStyle ?? _itemDescStyle, + itemDescStyleLink: itemDescStyleLink ?? _itemDescStyleLink, + itemDescStyleAlert: itemDescStyleAlert ?? _itemDescStyleAlert, + cancelStyle: cancelStyle ?? _cancelStyle, + topRadius: topRadius ?? _topRadius, + contentPadding: contentPadding ?? _contentPadding, + titlePadding: titlePadding ?? _titlePadding, ); } BrnActionSheetConfig merge(BrnActionSheetConfig? other) { if (other == null) return this; return copyWith( - titleStyle: titleStyle?.merge(other.titleStyle) ?? other.titleStyle, - itemTitleStyle: - itemTitleStyle?.merge(other.itemTitleStyle) ?? other.itemTitleStyle, - itemTitleStyleLink: itemTitleStyleLink?.merge(other.itemTitleStyleLink) ?? - other.itemTitleStyleLink, - itemTitleStyleAlert: - itemTitleStyleAlert?.merge(other.itemTitleStyleAlert) ?? - other.itemTitleStyleAlert, - itemDescStyle: - itemDescStyle?.merge(other.itemDescStyle) ?? other.itemDescStyle, - itemDescStyleLink: itemDescStyleLink?.merge(other.itemDescStyleLink) ?? - other.itemDescStyleLink, - itemDescStyleAlert: itemDescStyleAlert?.merge(other.itemDescStyleAlert) ?? - other.itemDescStyleAlert, - cancelStyle: cancelStyle?.merge(other.cancelStyle) ?? other.cancelStyle, - topRadius: other.topRadius, - contentPadding: other.contentPadding, - titlePadding: other.titlePadding, + titleStyle: titleStyle.merge(other._titleStyle), + itemTitleStyle: itemTitleStyle.merge(other._itemTitleStyle), + itemTitleStyleLink: itemTitleStyleLink.merge(other._itemTitleStyleLink), + itemTitleStyleAlert: itemTitleStyleAlert.merge(other._itemTitleStyleAlert), + itemDescStyle: itemDescStyle.merge(other._itemDescStyle), + itemDescStyleLink: itemDescStyleLink.merge(other._itemDescStyleLink), + itemDescStyleAlert: itemDescStyleAlert.merge(other._itemDescStyleAlert), + cancelStyle: cancelStyle.merge(other._cancelStyle), + topRadius: other._topRadius, + contentPadding: other._contentPadding, + titlePadding: other._titlePadding, ); } } diff --git a/lib/src/theme/configs/brn_all_config.dart b/lib/src/theme/configs/brn_all_config.dart index 5d5712ff..fe244f36 100644 --- a/lib/src/theme/configs/brn_all_config.dart +++ b/lib/src/theme/configs/brn_all_config.dart @@ -1,3 +1,4 @@ +import 'package:bruno/bruno.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_abnormal_state_config.dart'; import 'package:bruno/src/theme/configs/brn_action_sheet_config.dart'; @@ -24,119 +25,199 @@ import 'package:bruno/src/theme/configs/brn_tag_config.dart'; /// 当没有配置组件的特定属性时使用上一级特定配置 class BrnAllThemeConfig { BrnAllThemeConfig({ - required this.commonConfig, - this.appBarConfig, - this.buttonConfig, - this.dialogConfig, - this.formItemConfig, - this.cardTitleConfig, - this.abnormalStateConfig, - this.tagConfig, - this.pairInfoTableConfig, - this.pairRichInfoGridConfig, - this.actionSheetConfig, - this.pickerConfig, - this.enhanceNumberCardConfig, - this.tabBarConfig, - this.selectionConfig, - this.galleryDetailConfig, + BrnCommonConfig? commonConfig, + BrnAppBarConfig? appBarConfig, + BrnButtonConfig? buttonConfig, + BrnDialogConfig? dialogConfig, + BrnFormItemConfig? formItemConfig, + BrnCardTitleConfig? cardTitleConfig, + BrnAbnormalStateConfig? abnormalStateConfig, + BrnTagConfig? tagConfig, + BrnPairInfoTableConfig? pairInfoTableConfig, + BrnPairRichInfoGridConfig? pairRichInfoGridConfig, + BrnActionSheetConfig? actionSheetConfig, + BrnPickerConfig? pickerConfig, + BrnEnhanceNumberCardConfig? enhanceNumberCardConfig, + BrnTabBarConfig? tabBarConfig, + BrnSelectionConfig? selectionConfig, + BrnGalleryDetailConfig? galleryDetailConfig, String configId = GLOBAL_CONFIG_ID, - }); - - BrnCommonConfig? commonConfig; - BrnAppBarConfig? appBarConfig; - BrnButtonConfig? buttonConfig; - BrnDialogConfig? dialogConfig; - BrnCardTitleConfig? cardTitleConfig; - BrnAbnormalStateConfig? abnormalStateConfig; - BrnTagConfig? tagConfig; - BrnPairInfoTableConfig? pairInfoTableConfig; - BrnPairRichInfoGridConfig? pairRichInfoGridConfig; - BrnActionSheetConfig? actionSheetConfig; - BrnPickerConfig? pickerConfig; - BrnEnhanceNumberCardConfig? enhanceNumberCardConfig; - BrnTabBarConfig? tabBarConfig; - BrnFormItemConfig? formItemConfig; - BrnSelectionConfig? selectionConfig; - BrnGalleryDetailConfig? galleryDetailConfig; + }) : _commonConfig = commonConfig, + _appBarConfig = appBarConfig, + _buttonConfig = buttonConfig, + _dialogConfig = dialogConfig, + _formItemConfig = formItemConfig, + _cardTitleConfig = cardTitleConfig, + _abnormalStateConfig = abnormalStateConfig, + _tagConfig = tagConfig, + _pairInfoTableConfig = pairInfoTableConfig, + _pairRichInfoGridConfig = pairRichInfoGridConfig, + _actionSheetConfig = actionSheetConfig, + _pickerConfig = pickerConfig, + _enhanceNumberCardConfig = enhanceNumberCardConfig, + _tabBarConfig = tabBarConfig, + _selectionConfig = selectionConfig, + _galleryDetailConfig = galleryDetailConfig; + + BrnCommonConfig? _commonConfig; + + BrnCommonConfig get commonConfig => + _commonConfig ?? BrnDefaultConfigUtils.defaultCommonConfig; + + BrnAppBarConfig? _appBarConfig; + + BrnAppBarConfig get appBarConfig => + _appBarConfig ?? BrnDefaultConfigUtils.defaultAppBarConfig; + + BrnButtonConfig? _buttonConfig; + + BrnButtonConfig get buttonConfig => + _buttonConfig ?? BrnDefaultConfigUtils.defaultButtonConfig; + + BrnDialogConfig? _dialogConfig; + + BrnDialogConfig get dialogConfig => + _dialogConfig ?? BrnDefaultConfigUtils.defaultDialogConfig; + + BrnCardTitleConfig? _cardTitleConfig; + + BrnCardTitleConfig get cardTitleConfig => + _cardTitleConfig ?? BrnDefaultConfigUtils.defaultCardTitleConfig; + + BrnAbnormalStateConfig? _abnormalStateConfig; + + BrnAbnormalStateConfig get abnormalStateConfig => + _abnormalStateConfig ?? BrnDefaultConfigUtils.defaultAbnormalStateConfig; + + BrnTagConfig? _tagConfig; + + BrnTagConfig get tagConfig => + _tagConfig ?? BrnDefaultConfigUtils.defaultTagConfig; + + BrnPairInfoTableConfig? _pairInfoTableConfig; + + BrnPairInfoTableConfig get pairInfoTableConfig => + _pairInfoTableConfig ?? BrnDefaultConfigUtils.defaultPairInfoTableConfig; + + BrnPairRichInfoGridConfig? _pairRichInfoGridConfig; + + BrnPairRichInfoGridConfig get pairRichInfoGridConfig => + _pairRichInfoGridConfig ?? + BrnDefaultConfigUtils.defaultPairRichInfoGridConfig; + + BrnActionSheetConfig? _actionSheetConfig; + + BrnActionSheetConfig get actionSheetConfig => + _actionSheetConfig ?? BrnDefaultConfigUtils.defaultActionSheetConfig; + + BrnPickerConfig? _pickerConfig; + + BrnPickerConfig get pickerConfig => + _pickerConfig ?? BrnDefaultConfigUtils.defaultPickerConfig; + + BrnEnhanceNumberCardConfig? _enhanceNumberCardConfig; + + BrnEnhanceNumberCardConfig get enhanceNumberCardConfig => + _enhanceNumberCardConfig ?? + BrnDefaultConfigUtils.defaultEnhanceNumberInfoConfig; + + BrnTabBarConfig? _tabBarConfig; + + BrnTabBarConfig get tabBarConfig => + _tabBarConfig ?? BrnDefaultConfigUtils.defaultTabBarConfig; + + BrnFormItemConfig? _formItemConfig; + + BrnFormItemConfig get formItemConfig => + _formItemConfig ?? BrnDefaultConfigUtils.defaultFormItemConfig; + + BrnSelectionConfig? _selectionConfig; + + BrnSelectionConfig get selectionConfig => + _selectionConfig ?? BrnDefaultConfigUtils.defaultSelectionConfig; + + BrnGalleryDetailConfig? _galleryDetailConfig; + + BrnGalleryDetailConfig get galleryDetailConfig => + _galleryDetailConfig ?? BrnDefaultConfigUtils.defaultGalleryDetailConfig; void initThemeConfig(String configId) { - this.commonConfig ??= BrnCommonConfig(); - this.appBarConfig ??= BrnAppBarConfig(); - this.buttonConfig ??= BrnButtonConfig(); - this.dialogConfig ??= BrnDialogConfig(); - this.formItemConfig ??= BrnFormItemConfig(); - this.cardTitleConfig ??= BrnCardTitleConfig(); - this.abnormalStateConfig ??= BrnAbnormalStateConfig(); - this.tagConfig ??= BrnTagConfig(); - this.appBarConfig ??= BrnAppBarConfig(); - this.pairInfoTableConfig ??= BrnPairInfoTableConfig(); - this.pairRichInfoGridConfig ??= BrnPairRichInfoGridConfig(); - this.actionSheetConfig ??= BrnActionSheetConfig(); - this.pickerConfig ??= BrnPickerConfig(); - this.enhanceNumberCardConfig ??= BrnEnhanceNumberCardConfig(); - this.tabBarConfig ??= BrnTabBarConfig(); - this.selectionConfig ??= BrnSelectionConfig(); - this.galleryDetailConfig ??= BrnGalleryDetailConfig(); - - commonConfig?.initThemeConfig(configId); - appBarConfig?.initThemeConfig( + this._commonConfig ??= BrnCommonConfig(); + this._appBarConfig ??= BrnAppBarConfig(); + this._buttonConfig ??= BrnButtonConfig(); + this._dialogConfig ??= BrnDialogConfig(); + this._formItemConfig ??= BrnFormItemConfig(); + this._cardTitleConfig ??= BrnCardTitleConfig(); + this._abnormalStateConfig ??= BrnAbnormalStateConfig(); + this._tagConfig ??= BrnTagConfig(); + this._appBarConfig ??= BrnAppBarConfig(); + this._pairInfoTableConfig ??= BrnPairInfoTableConfig(); + this._pairRichInfoGridConfig ??= BrnPairRichInfoGridConfig(); + this._actionSheetConfig ??= BrnActionSheetConfig(); + this._pickerConfig ??= BrnPickerConfig(); + this._enhanceNumberCardConfig ??= BrnEnhanceNumberCardConfig(); + this._tabBarConfig ??= BrnTabBarConfig(); + this._selectionConfig ??= BrnSelectionConfig(); + this._galleryDetailConfig ??= BrnGalleryDetailConfig(); + + commonConfig.initThemeConfig(configId); + appBarConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - buttonConfig?.initThemeConfig( + buttonConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - dialogConfig?.initThemeConfig( + dialogConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - formItemConfig?.initThemeConfig( + formItemConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - cardTitleConfig?.initThemeConfig( + cardTitleConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - abnormalStateConfig?.initThemeConfig( + abnormalStateConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - tagConfig?.initThemeConfig( + tagConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - pairInfoTableConfig?.initThemeConfig( + pairInfoTableConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - pairRichInfoGridConfig?.initThemeConfig( + pairRichInfoGridConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - selectionConfig?.initThemeConfig( + selectionConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - actionSheetConfig?.initThemeConfig( + actionSheetConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - pickerConfig?.initThemeConfig( + pickerConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - enhanceNumberCardConfig?.initThemeConfig( + enhanceNumberCardConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - tabBarConfig?.initThemeConfig( + tabBarConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - galleryDetailConfig?.initThemeConfig( + galleryDetailConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); diff --git a/lib/src/theme/configs/brn_appbar_config.dart b/lib/src/theme/configs/brn_appbar_config.dart index fbcf1479..a220c951 100644 --- a/lib/src/theme/configs/brn_appbar_config.dart +++ b/lib/src/theme/configs/brn_appbar_config.dart @@ -2,6 +2,7 @@ import 'package:bruno/src/components/navbar/brn_appbar_theme.dart'; import 'package:bruno/src/constants/brn_asset_constants.dart'; import 'package:bruno/src/constants/brn_strings_constants.dart'; import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -15,106 +16,130 @@ class BrnAppBarConfig extends BrnBaseConfig { /// BrnAppBar 主题配置,遵循外部主题配置 /// 默认为 [BrnDefaultConfigUtils.defaultAppBarConfig] BrnAppBarConfig({ - this.backgroundColor, - this.appBarHeight, - this.leadIconBuilder, - this.titleStyle, - this.actionsStyle, - this.titleMaxLength, - this.leftAndRightPadding, - this.itemSpacing, - this.titlePadding, - this.iconSize, - this.flexibleSpace, - this.systemUiOverlayStyle, + Color? backgroundColor, + double? appBarHeight, + BrnWidgetBuilder? leadIconBuilder, + BrnTextStyle? titleStyle, + BrnTextStyle? actionsStyle, + int? titleMaxLength, + double? leftAndRightPadding, + double? itemSpacing, + EdgeInsets? titlePadding, + double? iconSize, + SystemUiOverlayStyle? systemUiOverlayStyle, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _backgroundColor = backgroundColor, + _appBarHeight = appBarHeight, + _leadIconBuilder = leadIconBuilder, + _titleStyle = titleStyle, + _actionsStyle = actionsStyle, + _titleMaxLength = titleMaxLength, + _leftAndRightPadding = leftAndRightPadding, + _itemSpacing = itemSpacing, + _titlePadding = titlePadding, + _iconSize = iconSize, + _systemUiOverlayStyle = systemUiOverlayStyle, + super(configId: configId); BrnAppBarConfig.dark({ - this.backgroundColor, - this.appBarHeight, - this.leadIconBuilder, - this.titleStyle, - this.actionsStyle, - this.titleMaxLength, - this.leftAndRightPadding, - this.itemSpacing, - this.titlePadding, - this.iconSize, - this.flexibleSpace, - this.systemUiOverlayStyle, + double? appBarHeight, + int? titleMaxLength, + double? leftAndRightPadding, + double? itemSpacing, + EdgeInsets? titlePadding, + double? iconSize, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId) { - backgroundColor = Color(0xff2E313B); - leadIconBuilder = () => Image.asset( - BrnAsset.ICON_BACK_WHITE, - package: BrnStrings.flutterPackageName, - width: BrnAppBarTheme.iconSize, - height: BrnAppBarTheme.iconSize, - fit: BoxFit.fitHeight, - ); - titleStyle = BrnTextStyle( + }) : _appBarHeight = appBarHeight, + _titleMaxLength = titleMaxLength, + _leftAndRightPadding = leftAndRightPadding, + _itemSpacing = itemSpacing, + _titlePadding = titlePadding, + _iconSize = iconSize, + super(configId: configId) { + _backgroundColor = Color(0xff2E313B); + _leadIconBuilder = () => Image.asset( + BrnAsset.ICON_BACK_WHITE, + package: BrnStrings.flutterPackageName, + width: BrnAppBarTheme.iconSize, + height: BrnAppBarTheme.iconSize, + fit: BoxFit.fitHeight, + ); + _titleStyle = BrnTextStyle( fontSize: BrnAppBarTheme.titleFontSize, fontWeight: FontWeight.w600, color: BrnAppBarTheme.darkTextColor, ); - actionsStyle = BrnTextStyle( + _actionsStyle = BrnTextStyle( color: BrnAppBarTheme.darkTextColor, fontSize: BrnAppBarTheme.actionFontSize, fontWeight: FontWeight.w600, ); - systemUiOverlayStyle = SystemUiOverlayStyle.light; + _systemUiOverlayStyle = SystemUiOverlayStyle.light; } BrnAppBarConfig.light({ - this.backgroundColor, - this.appBarHeight, - this.leadIconBuilder, - this.titleStyle, - this.actionsStyle, - this.titleMaxLength, - this.leftAndRightPadding, - this.itemSpacing, - this.titlePadding, - this.iconSize, - this.flexibleSpace, - this.systemUiOverlayStyle, + double? appBarHeight, + int? titleMaxLength, + double? leftAndRightPadding, + double? itemSpacing, + EdgeInsets? titlePadding, + double? iconSize, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId) { - backgroundColor = Colors.white; - leadIconBuilder = () => Image.asset( - BrnAsset.ICON_BACK_BLACK, - package: BrnStrings.flutterPackageName, - width: BrnAppBarTheme.iconSize, - height: BrnAppBarTheme.iconSize, - fit: BoxFit.fitHeight, - ); - titleStyle = BrnTextStyle( + }) : _appBarHeight = appBarHeight, + _titleMaxLength = titleMaxLength, + _leftAndRightPadding = leftAndRightPadding, + _itemSpacing = itemSpacing, + _titlePadding = titlePadding, + _iconSize = iconSize, + super(configId: configId) { + _backgroundColor = Colors.white; + _leadIconBuilder = () => Image.asset( + BrnAsset.ICON_BACK_BLACK, + package: BrnStrings.flutterPackageName, + width: BrnAppBarTheme.iconSize, + height: BrnAppBarTheme.iconSize, + fit: BoxFit.fitHeight, + ); + _titleStyle = BrnTextStyle( fontSize: BrnAppBarTheme.titleFontSize, fontWeight: FontWeight.w600, color: BrnAppBarTheme.lightTextColor, ); - actionsStyle = BrnTextStyle( + _actionsStyle = BrnTextStyle( color: BrnAppBarTheme.lightTextColor, fontSize: BrnAppBarTheme.actionFontSize, fontWeight: FontWeight.w600, ); - systemUiOverlayStyle = SystemUiOverlayStyle.dark; + _systemUiOverlayStyle = SystemUiOverlayStyle.dark; } /// AppBar 的背景色 - Color? backgroundColor; + Color? _backgroundColor; + + Color get backgroundColor => + _backgroundColor ?? + BrnDefaultConfigUtils.defaultAppBarConfig.backgroundColor; /// AppBar 的高度 - double? appBarHeight; + double? _appBarHeight; + + double get appBarHeight => + _appBarHeight ?? BrnDefaultConfigUtils.defaultAppBarConfig.appBarHeight; /// 返回按钮的child widget,一般为Image - BrnWidgetBuilder? leadIconBuilder; + BrnWidgetBuilder? _leadIconBuilder; + + BrnWidgetBuilder get leadIconBuilder => + _leadIconBuilder ?? + BrnDefaultConfigUtils.defaultAppBarConfig.leadIconBuilder; /// 标题样式,仅当直接 title 设置为 String 生效 /// /// **注意**:`fontSize` 必须传大小,否则报错 - BrnTextStyle? titleStyle; + BrnTextStyle? _titleStyle; + + BrnTextStyle get titleStyle => + _titleStyle ?? BrnDefaultConfigUtils.defaultAppBarConfig.titleStyle; /// 右侧文字按钮样式,仅当直接actions里面元素为BrnTextAction类型生效 /// @@ -125,58 +150,78 @@ class BrnAppBarConfig extends BrnBaseConfig { /// fontSize: BrnAppBarTheme.actionFontSize, /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? actionsStyle; + BrnTextStyle? _actionsStyle; + + BrnTextStyle get actionsStyle => + _actionsStyle ?? BrnDefaultConfigUtils.defaultAppBarConfig.actionsStyle; /// AppBar title 的最大字符数 8 - int? titleMaxLength; + int? _titleMaxLength; + + int get titleMaxLength => + _titleMaxLength ?? + BrnDefaultConfigUtils.defaultAppBarConfig.titleMaxLength; /// 左右边距 - double? leftAndRightPadding; + double? _leftAndRightPadding; + + double get leftAndRightPadding => + _leftAndRightPadding ?? + BrnDefaultConfigUtils.defaultAppBarConfig.leftAndRightPadding; /// 元素间间距 - double? itemSpacing; + double? _itemSpacing; + + double get itemSpacing => + _itemSpacing ?? BrnDefaultConfigUtils.defaultAppBarConfig.itemSpacing; /// title的padding - EdgeInsets? titlePadding; + EdgeInsets? _titlePadding; + + EdgeInsets get titlePadding => + _titlePadding ?? BrnDefaultConfigUtils.defaultAppBarConfig.titlePadding; /// leadIcon 宽高,需要相同 /// 默认为 20 - double? iconSize; + double? _iconSize; - /// [AppBar] 中 flexibleSpace - Widget? flexibleSpace; + double get iconSize => + _iconSize ?? BrnDefaultConfigUtils.defaultAppBarConfig.iconSize; /// statusBar 样式 /// 默认为 [SystemUiOverlayStyle.dark] - SystemUiOverlayStyle? systemUiOverlayStyle; + SystemUiOverlayStyle? _systemUiOverlayStyle; + + SystemUiOverlayStyle get systemUiOverlayStyle => + _systemUiOverlayStyle ?? + BrnDefaultConfigUtils.defaultAppBarConfig.systemUiOverlayStyle; @override void initThemeConfig( - String configId, { - BrnCommonConfig? currentLevelCommonConfig, - }) { + String configId, { + BrnCommonConfig? currentLevelCommonConfig, + }) { super.initThemeConfig( configId, currentLevelCommonConfig: currentLevelCommonConfig, ); /// 用户全局组件配置 - BrnAppBarConfig? appbarConfig = BrnThemeConfigurator.instance + BrnAppBarConfig appbarConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .appBarConfig; - this.backgroundColor ??= appbarConfig?.backgroundColor; - this.appBarHeight ??= appbarConfig?.appBarHeight; - this.leadIconBuilder ??= appbarConfig?.leadIconBuilder; - this.titleStyle = appbarConfig?.titleStyle?.merge(titleStyle); - this.actionsStyle = appbarConfig?.actionsStyle?.merge(actionsStyle); - this.titleMaxLength ??= appbarConfig?.titleMaxLength; - this.leftAndRightPadding ??= appbarConfig?.leftAndRightPadding; - this.itemSpacing ??= appbarConfig?.itemSpacing; - this.titlePadding ??= appbarConfig?.titlePadding; - this.iconSize ??= appbarConfig?.iconSize; - this.flexibleSpace ??= appbarConfig?.flexibleSpace; - this.systemUiOverlayStyle ??= appbarConfig?.systemUiOverlayStyle; + _backgroundColor ??= appbarConfig._backgroundColor; + _appBarHeight ??= appbarConfig._appBarHeight; + _leadIconBuilder ??= appbarConfig._leadIconBuilder; + _titleStyle = appbarConfig.titleStyle.merge(_titleStyle); + _actionsStyle = appbarConfig.actionsStyle.merge(_actionsStyle); + _titleMaxLength ??= appbarConfig._titleMaxLength; + _leftAndRightPadding ??= appbarConfig._leftAndRightPadding; + _itemSpacing ??= appbarConfig._itemSpacing; + _titlePadding ??= appbarConfig._titlePadding; + _iconSize ??= appbarConfig._iconSize; + _systemUiOverlayStyle ??= appbarConfig._systemUiOverlayStyle; } BrnAppBarConfig copyWith({ @@ -190,41 +235,37 @@ class BrnAppBarConfig extends BrnBaseConfig { double? itemSpacing, EdgeInsets? titlePadding, double? iconSize, - Widget? flexibleSpace, SystemUiOverlayStyle? systemUiOverlayStyle, }) { return BrnAppBarConfig( - backgroundColor: backgroundColor ?? this.backgroundColor, - appBarHeight: appBarHeight ?? this.appBarHeight, - leadIconBuilder: leadIconBuilder ?? this.leadIconBuilder, - titleStyle: titleStyle ?? this.titleStyle, - actionsStyle: actionsStyle ?? this.actionsStyle, - titleMaxLength: titleMaxLength ?? this.titleMaxLength, - leftAndRightPadding: leftAndRightPadding ?? this.leftAndRightPadding, - itemSpacing: itemSpacing ?? this.itemSpacing, - titlePadding: titlePadding ?? this.titlePadding, - iconSize: iconSize ?? this.iconSize, - flexibleSpace: flexibleSpace ?? this.flexibleSpace, - systemUiOverlayStyle: systemUiOverlayStyle ?? this.systemUiOverlayStyle, + backgroundColor: backgroundColor ?? _backgroundColor, + appBarHeight: appBarHeight ?? _appBarHeight, + leadIconBuilder: leadIconBuilder ?? _leadIconBuilder, + titleStyle: titleStyle ?? _titleStyle, + actionsStyle: actionsStyle ?? _actionsStyle, + titleMaxLength: titleMaxLength ?? _titleMaxLength, + leftAndRightPadding: leftAndRightPadding ?? _leftAndRightPadding, + itemSpacing: itemSpacing ?? _itemSpacing, + titlePadding: titlePadding ?? _titlePadding, + iconSize: iconSize ?? _iconSize, + systemUiOverlayStyle: systemUiOverlayStyle ?? _systemUiOverlayStyle, ); } BrnAppBarConfig merge(BrnAppBarConfig? other) { if (other == null) return this; return copyWith( - backgroundColor: other.backgroundColor, - appBarHeight: other.appBarHeight, - leadIconBuilder: other.leadIconBuilder, - titleStyle: titleStyle?.merge(other.titleStyle) ?? other.titleStyle, - actionsStyle: - actionsStyle?.merge(other.actionsStyle) ?? other.actionsStyle, - titleMaxLength: other.titleMaxLength, - leftAndRightPadding: other.leftAndRightPadding, - itemSpacing: other.itemSpacing, - titlePadding: other.titlePadding, - iconSize: other.iconSize, - flexibleSpace: other.flexibleSpace, - systemUiOverlayStyle: other.systemUiOverlayStyle, + backgroundColor: other._backgroundColor, + appBarHeight: other._appBarHeight, + leadIconBuilder: other._leadIconBuilder, + titleStyle: titleStyle.merge(other._titleStyle), + actionsStyle: actionsStyle.merge(other._actionsStyle), + titleMaxLength: other._titleMaxLength, + leftAndRightPadding: other._leftAndRightPadding, + itemSpacing: other._itemSpacing, + titlePadding: other._titlePadding, + iconSize: other._iconSize, + systemUiOverlayStyle: other._systemUiOverlayStyle, ); } } diff --git a/lib/src/theme/configs/brn_button_config.dart b/lib/src/theme/configs/brn_button_config.dart index 7dafe47a..d6e29919 100644 --- a/lib/src/theme/configs/brn_button_config.dart +++ b/lib/src/theme/configs/brn_button_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -7,32 +8,62 @@ class BrnButtonConfig extends BrnBaseConfig { /// 遵循外部主题配置 /// 默认为 [BrnDefaultConfigUtils.defaultButtonConfig] BrnButtonConfig({ - this.bigButtonRadius, - this.bigButtonHeight, - this.bigButtonFontSize, - this.smallButtonRadius, - this.smallButtonHeight, - this.smallButtonFontSize, + double? bigButtonRadius, + double? bigButtonHeight, + double? bigButtonFontSize, + double? smallButtonRadius, + double? smallButtonHeight, + double? smallButtonFontSize, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _bigButtonRadius = bigButtonRadius, + _bigButtonHeight = bigButtonHeight, + _bigButtonFontSize = bigButtonFontSize, + _smallButtonRadius = smallButtonRadius, + _smallButtonHeight = smallButtonHeight, + _smallButtonFontSize = smallButtonFontSize, + super(configId: configId); /// 默认为 6 - double? bigButtonRadius; + double? _bigButtonRadius; + + double get bigButtonRadius => + _bigButtonRadius ?? + BrnDefaultConfigUtils.defaultButtonConfig.bigButtonRadius; /// 默认为 48 - double? bigButtonHeight; + double? _bigButtonHeight; + + double get bigButtonHeight => + _bigButtonHeight ?? + BrnDefaultConfigUtils.defaultButtonConfig.bigButtonHeight; /// 默认为 16 - double? bigButtonFontSize; + double? _bigButtonFontSize; + + double get bigButtonFontSize => + _bigButtonFontSize ?? + BrnDefaultConfigUtils.defaultButtonConfig.bigButtonFontSize; /// 默认为 4 - double? smallButtonRadius; + double? _smallButtonRadius; + + double get smallButtonRadius => + _smallButtonRadius ?? + BrnDefaultConfigUtils.defaultButtonConfig.smallButtonRadius; /// 默认为 32 - double? smallButtonHeight; + double? _smallButtonHeight; + + double get smallButtonHeight => + _smallButtonHeight ?? + BrnDefaultConfigUtils.defaultButtonConfig.smallButtonHeight; /// 默认为 14 - double? smallButtonFontSize; + double? _smallButtonFontSize; + + double get smallButtonFontSize => + _smallButtonFontSize ?? + BrnDefaultConfigUtils.defaultButtonConfig.smallButtonFontSize; @override void initThemeConfig( @@ -44,16 +75,16 @@ class BrnButtonConfig extends BrnBaseConfig { currentLevelCommonConfig: currentLevelCommonConfig, ); - BrnButtonConfig? userConfig = BrnThemeConfigurator.instance + BrnButtonConfig userConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .buttonConfig; - bigButtonRadius ??= userConfig?.bigButtonRadius; - bigButtonHeight ??= userConfig?.bigButtonHeight; - bigButtonFontSize ??= userConfig?.bigButtonFontSize; - smallButtonRadius ??= userConfig?.smallButtonRadius; - smallButtonHeight ??= userConfig?.smallButtonHeight; - smallButtonFontSize ??= userConfig?.smallButtonFontSize; + _bigButtonRadius ??= userConfig._bigButtonRadius; + _bigButtonHeight ??= userConfig._bigButtonHeight; + _bigButtonFontSize ??= userConfig._bigButtonFontSize; + _smallButtonRadius ??= userConfig._smallButtonRadius; + _smallButtonHeight ??= userConfig._smallButtonHeight; + _smallButtonFontSize ??= userConfig._smallButtonFontSize; } BrnButtonConfig copyWith({ @@ -65,24 +96,24 @@ class BrnButtonConfig extends BrnBaseConfig { double? smallButtonFontSize, }) { return BrnButtonConfig( - bigButtonRadius: bigButtonRadius ?? this.bigButtonRadius, - bigButtonHeight: bigButtonHeight ?? this.bigButtonHeight, - bigButtonFontSize: bigButtonFontSize ?? this.bigButtonFontSize, - smallButtonRadius: smallButtonRadius ?? this.smallButtonRadius, - smallButtonHeight: smallButtonHeight ?? this.smallButtonHeight, - smallButtonFontSize: smallButtonFontSize ?? this.smallButtonFontSize, + bigButtonRadius: bigButtonRadius ?? _bigButtonRadius, + bigButtonHeight: bigButtonHeight ?? _bigButtonHeight, + bigButtonFontSize: bigButtonFontSize ?? _bigButtonFontSize, + smallButtonRadius: smallButtonRadius ?? _smallButtonRadius, + smallButtonHeight: smallButtonHeight ?? _smallButtonHeight, + smallButtonFontSize: smallButtonFontSize ?? _smallButtonFontSize, ); } BrnButtonConfig merge(BrnButtonConfig? other) { if (other == null) return this; return copyWith( - bigButtonRadius: other.bigButtonRadius, - bigButtonHeight: other.bigButtonHeight, - bigButtonFontSize: other.bigButtonFontSize, - smallButtonRadius: other.smallButtonRadius, - smallButtonHeight: other.smallButtonHeight, - smallButtonFontSize: other.smallButtonFontSize, + bigButtonRadius: other._bigButtonRadius, + bigButtonHeight: other._bigButtonHeight, + bigButtonFontSize: other._bigButtonFontSize, + smallButtonRadius: other._smallButtonRadius, + smallButtonHeight: other._smallButtonHeight, + smallButtonFontSize: other._smallButtonFontSize, ); } } diff --git a/lib/src/theme/configs/brn_card_title_config.dart b/lib/src/theme/configs/brn_card_title_config.dart index 84cc2242..95ea6a70 100644 --- a/lib/src/theme/configs/brn_card_title_config.dart +++ b/lib/src/theme/configs/brn_card_title_config.dart @@ -1,3 +1,4 @@ +import 'package:bruno/bruno.dart'; import 'package:bruno/src/theme/base/brn_base_config.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; @@ -7,16 +8,24 @@ import 'package:flutter/material.dart'; /// 卡片标题 配置类 class BrnCardTitleConfig extends BrnBaseConfig { BrnCardTitleConfig({ - this.titleWithHeightTextStyle, - this.detailTextStyle, - this.accessoryTextStyle, - this.cardTitlePadding, - this.titleTextStyle, - this.subtitleTextStyle, - this.alignment, - this.cardBackgroundColor, + BrnTextStyle? titleWithHeightTextStyle, + BrnTextStyle? detailTextStyle, + BrnTextStyle? accessoryTextStyle, + EdgeInsets? cardTitlePadding, + BrnTextStyle? titleTextStyle, + BrnTextStyle? subtitleTextStyle, + PlaceholderAlignment? alignment, + Color? cardBackgroundColor, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _titleWithHeightTextStyle = titleWithHeightTextStyle, + _detailTextStyle = detailTextStyle, + _accessoryTextStyle = accessoryTextStyle, + _cardTitlePadding = cardTitlePadding, + _titleTextStyle = titleTextStyle, + _subtitleTextStyle = subtitleTextStyle, + _alignment = alignment, + _cardBackgroundColor = cardBackgroundColor, + super(configId: configId); /// 标题外边距间距 /// @@ -24,7 +33,11 @@ class BrnCardTitleConfig extends BrnBaseConfig { /// top: [BrnCommonConfig.vSpacingXl], /// bottom: [BrnCommonConfig.vSpacingMd], /// ) - EdgeInsets? cardTitlePadding; + EdgeInsets? _cardTitlePadding; + + EdgeInsets get cardTitlePadding => + _cardTitlePadding ?? + BrnDefaultConfigUtils.defaultCardTitleConfig.cardTitlePadding; /// 标题文本样式 /// @@ -34,7 +47,11 @@ class BrnCardTitleConfig extends BrnBaseConfig { /// fontWeight: FontWeight.w600, /// height: 25 / 18, /// ) - BrnTextStyle? titleWithHeightTextStyle; + BrnTextStyle? _titleWithHeightTextStyle; + + BrnTextStyle get titleWithHeightTextStyle => + _titleWithHeightTextStyle ?? + BrnDefaultConfigUtils.defaultCardTitleConfig.titleWithHeightTextStyle; /// 标题文本样式 /// @@ -43,7 +60,11 @@ class BrnCardTitleConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? titleTextStyle; + BrnTextStyle? _titleTextStyle; + + BrnTextStyle get titleTextStyle => + _titleTextStyle ?? + BrnDefaultConfigUtils.defaultCardTitleConfig.titleTextStyle; /// 标题右边的副标题文本样式 /// @@ -51,7 +72,11 @@ class BrnCardTitleConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextSecondary], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? subtitleTextStyle; + BrnTextStyle? _subtitleTextStyle; + + BrnTextStyle get subtitleTextStyle => + _subtitleTextStyle ?? + BrnDefaultConfigUtils.defaultCardTitleConfig.subtitleTextStyle; /// 详情文本样式 /// @@ -59,7 +84,11 @@ class BrnCardTitleConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? detailTextStyle; + BrnTextStyle? _detailTextStyle; + + BrnTextStyle get detailTextStyle => + _detailTextStyle ?? + BrnDefaultConfigUtils.defaultCardTitleConfig.detailTextStyle; /// 辅助文本样式 /// @@ -67,15 +96,26 @@ class BrnCardTitleConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextSecondary], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? accessoryTextStyle; + BrnTextStyle? _accessoryTextStyle; + + BrnTextStyle get accessoryTextStyle => + _accessoryTextStyle ?? + BrnDefaultConfigUtils.defaultCardTitleConfig.accessoryTextStyle; /// 对齐方式 /// 默认为 [PlaceholderAlignment.middle] - PlaceholderAlignment? alignment; + PlaceholderAlignment? _alignment; + + PlaceholderAlignment get alignment => + _alignment ?? BrnDefaultConfigUtils.defaultCardTitleConfig.alignment; /// 卡片背景 /// 默认为 [BrnCommonConfig.fillBase] - Color? cardBackgroundColor; + Color? _cardBackgroundColor; + + Color get cardBackgroundColor => + _cardBackgroundColor ?? + BrnDefaultConfigUtils.defaultCardTitleConfig.cardBackgroundColor; /// cardTitleConfig 获取逻辑详见 [BrnThemeConfigurator.getConfig] 方法 @override @@ -88,48 +128,48 @@ class BrnCardTitleConfig extends BrnBaseConfig { currentLevelCommonConfig: currentLevelCommonConfig, ); - BrnCardTitleConfig? cardTitleConfig = BrnThemeConfigurator.instance + BrnCardTitleConfig cardTitleConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .cardTitleConfig; - cardBackgroundColor ??= commonConfig.fillBase; - cardTitlePadding ??= EdgeInsets.only( - left: cardTitleConfig?.cardTitlePadding?.left ?? 0, - top: commonConfig.vSpacingXl ?? 0, - right: cardTitleConfig?.cardTitlePadding?.right ?? 0, - bottom: commonConfig.vSpacingMd ?? 0, + _cardBackgroundColor ??= commonConfig.fillBase; + _cardTitlePadding ??= EdgeInsets.only( + left: cardTitleConfig.cardTitlePadding.left, + top: commonConfig.vSpacingXl, + right: cardTitleConfig.cardTitlePadding.right, + bottom: commonConfig.vSpacingMd, ); - titleWithHeightTextStyle = cardTitleConfig?.titleWithHeightTextStyle?.merge( + _titleWithHeightTextStyle = cardTitleConfig.titleWithHeightTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeHead, - ).merge(titleWithHeightTextStyle), + ).merge(_titleWithHeightTextStyle), ); - titleTextStyle = cardTitleConfig?.titleTextStyle?.merge( + _titleTextStyle = cardTitleConfig.titleTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeHead, - ).merge(titleTextStyle), + ).merge(_titleTextStyle), ); - subtitleTextStyle = cardTitleConfig?.subtitleTextStyle?.merge( + _subtitleTextStyle = cardTitleConfig.subtitleTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeBase, - ).merge(subtitleTextStyle), + ).merge(_subtitleTextStyle), ); - accessoryTextStyle = cardTitleConfig?.accessoryTextStyle?.merge( + _accessoryTextStyle = cardTitleConfig.accessoryTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextSecondary, fontSize: commonConfig.fontSizeHead, - ).merge(accessoryTextStyle), + ).merge(_accessoryTextStyle), ); - detailTextStyle = cardTitleConfig?.detailTextStyle?.merge( + _detailTextStyle = cardTitleConfig.detailTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeBase, - ).merge(detailTextStyle), + ).merge(_detailTextStyle), ); - alignment ??= cardTitleConfig?.alignment; + _alignment ??= cardTitleConfig._alignment; } BrnCardTitleConfig copyWith({ @@ -143,35 +183,30 @@ class BrnCardTitleConfig extends BrnBaseConfig { Color? cardBackgroundColor, }) { return BrnCardTitleConfig( - cardTitlePadding: cardTitlePadding ?? this.cardTitlePadding, + cardTitlePadding: cardTitlePadding ?? _cardTitlePadding, titleWithHeightTextStyle: - titleWithHeightTextStyle ?? this.titleWithHeightTextStyle, - titleTextStyle: titleTextStyle ?? this.titleTextStyle, - subtitleTextStyle: subtitleTextStyle ?? this.subtitleTextStyle, - detailTextStyle: detailTextStyle ?? this.detailTextStyle, - accessoryTextStyle: accessoryTextStyle ?? this.accessoryTextStyle, - alignment: alignment ?? this.alignment, - cardBackgroundColor: cardBackgroundColor ?? this.cardBackgroundColor, + titleWithHeightTextStyle ?? _titleWithHeightTextStyle, + titleTextStyle: titleTextStyle ?? _titleTextStyle, + subtitleTextStyle: subtitleTextStyle ?? _subtitleTextStyle, + detailTextStyle: detailTextStyle ?? _detailTextStyle, + accessoryTextStyle: accessoryTextStyle ?? _accessoryTextStyle, + alignment: alignment ?? _alignment, + cardBackgroundColor: cardBackgroundColor ?? _cardBackgroundColor, ); } BrnCardTitleConfig merge(BrnCardTitleConfig? other) { if (other == null) return this; return copyWith( - cardTitlePadding: other.cardTitlePadding, + cardTitlePadding: other._cardTitlePadding, titleWithHeightTextStyle: - titleWithHeightTextStyle?.merge(other.titleWithHeightTextStyle) ?? - other.titleWithHeightTextStyle, - titleTextStyle: - titleTextStyle?.merge(other.titleTextStyle) ?? other.titleTextStyle, - subtitleTextStyle: subtitleTextStyle?.merge(other.subtitleTextStyle) ?? - other.subtitleTextStyle, - detailTextStyle: detailTextStyle?.merge(other.detailTextStyle) ?? - other.detailTextStyle, - accessoryTextStyle: accessoryTextStyle?.merge(other.accessoryTextStyle) ?? - other.accessoryTextStyle, - alignment: other.alignment, - cardBackgroundColor: other.cardBackgroundColor, + titleWithHeightTextStyle.merge(other._titleWithHeightTextStyle), + titleTextStyle: titleTextStyle.merge(other._titleTextStyle), + subtitleTextStyle: subtitleTextStyle.merge(other._subtitleTextStyle), + detailTextStyle: detailTextStyle.merge(other._detailTextStyle), + accessoryTextStyle: accessoryTextStyle.merge(other._accessoryTextStyle), + alignment: other._alignment, + cardBackgroundColor: other._cardBackgroundColor, ); } } diff --git a/lib/src/theme/configs/brn_common_config.dart b/lib/src/theme/configs/brn_common_config.dart index c5b1e887..1e433123 100644 --- a/lib/src/theme/configs/brn_common_config.dart +++ b/lib/src/theme/configs/brn_common_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:flutter/painting.dart'; @@ -6,114 +7,216 @@ import 'package:flutter/painting.dart'; /// 配置属性:色值、字体大小、间距、圆角 class BrnCommonConfig extends BrnBaseConfig { BrnCommonConfig({ - this.brandPrimary, - this.brandPrimaryTap, - this.brandSuccess, - this.brandWarning, - this.brandError, - this.brandImportant, - this.brandImportantValue, - this.brandAuxiliary, - this.colorTextBase, - this.colorTextImportant, - this.colorTextBaseInverse, - this.colorTextSecondary, - this.colorTextDisabled, - this.colorTextHint, - this.colorLink, - this.fillBase, - this.fillBody, - this.fillMask, - this.borderColorBase, - this.dividerColorBase, - this.fontSizeDIN, - this.fontSizeHeadLg, - this.fontSizeBase, - this.fontSizeHead, - this.fontSizeSubHead, - this.fontSizeCaption, - this.fontSizeCaptionSm, - this.radiusXs, - this.radiusSm, - this.radiusMd, - this.radiusLg, - this.borderWidthSm, - this.borderWidthMd, - this.borderWidthLg, - this.hSpacingXs, - this.hSpacingSm, - this.hSpacingMd, - this.hSpacingLg, - this.hSpacingXl, - this.hSpacingXxl, - this.vSpacingXs, - this.vSpacingSm, - this.vSpacingMd, - this.vSpacingLg, - this.vSpacingXl, - this.vSpacingXxl, - this.iconSizeXxs, - this.iconSizeXs, - this.iconSizeSm, - this.iconSizeMd, - this.iconSizeLg, + Color? brandPrimary, + Color? brandPrimaryTap, + Color? brandSuccess, + Color? brandWarning, + Color? brandError, + Color? brandImportant, + Color? brandImportantValue, + Color? brandAuxiliary, + Color? colorTextBase, + Color? colorTextImportant, + Color? colorTextBaseInverse, + Color? colorTextSecondary, + Color? colorTextDisabled, + Color? colorTextHint, + Color? colorLink, + Color? fillBase, + Color? fillBody, + Color? fillMask, + Color? borderColorBase, + Color? dividerColorBase, + double? fontSizeDIN, + double? fontSizeHeadLg, + double? fontSizeBase, + double? fontSizeHead, + double? fontSizeSubHead, + double? fontSizeCaption, + double? fontSizeCaptionSm, + double? radiusXs, + double? radiusSm, + double? radiusMd, + double? radiusLg, + double? borderWidthSm, + double? borderWidthMd, + double? borderWidthLg, + double? hSpacingXs, + double? hSpacingSm, + double? hSpacingMd, + double? hSpacingLg, + double? hSpacingXl, + double? hSpacingXxl, + double? vSpacingXs, + double? vSpacingSm, + double? vSpacingMd, + double? vSpacingLg, + double? vSpacingXl, + double? vSpacingXxl, + double? iconSizeXxs, + double? iconSizeXs, + double? iconSizeSm, + double? iconSizeMd, + double? iconSizeLg, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _brandPrimary = brandPrimary, + _brandPrimaryTap = brandPrimaryTap, + _brandSuccess = brandSuccess, + _brandWarning = brandWarning, + _brandError = brandError, + _brandImportant = brandImportant, + _brandImportantValue = brandImportantValue, + _brandAuxiliary = brandAuxiliary, + _colorTextBase = colorTextBase, + _colorTextImportant = colorTextImportant, + _colorTextBaseInverse = colorTextBaseInverse, + _colorTextSecondary = colorTextSecondary, + _colorTextDisabled = colorTextDisabled, + _colorTextHint = colorTextHint, + _colorLink = colorLink, + _fillBase = fillBase, + _fillBody = fillBody, + _fillMask = fillMask, + _borderColorBase = borderColorBase, + _dividerColorBase = dividerColorBase, + _fontSizeDIN = fontSizeDIN, + _fontSizeHeadLg = fontSizeHeadLg, + _fontSizeBase = fontSizeBase, + _fontSizeHead = fontSizeHead, + _fontSizeSubHead = fontSizeSubHead, + _fontSizeCaption = fontSizeCaption, + _fontSizeCaptionSm = fontSizeCaptionSm, + _radiusXs = radiusXs, + _radiusSm = radiusSm, + _radiusMd = radiusMd, + _radiusLg = radiusLg, + _borderWidthSm = borderWidthSm, + _borderWidthMd = borderWidthMd, + _borderWidthLg = borderWidthLg, + _hSpacingXs = hSpacingXs, + _hSpacingSm = hSpacingSm, + _hSpacingMd = hSpacingMd, + _hSpacingLg = hSpacingLg, + _hSpacingXl = hSpacingXl, + _hSpacingXxl = hSpacingXxl, + _vSpacingXs = vSpacingXs, + _vSpacingSm = vSpacingSm, + _vSpacingMd = vSpacingMd, + _vSpacingLg = vSpacingLg, + _vSpacingXl = vSpacingXl, + _vSpacingXxl = vSpacingXxl, + _iconSizeXxs = iconSizeXxs, + _iconSizeXs = iconSizeXs, + _iconSizeSm = iconSizeSm, + _iconSizeMd = iconSizeMd, + _iconSizeLg = iconSizeLg, + super(configId: configId); BrnCommonConfig.autoFlatConfig({ - this.brandPrimary, - this.brandPrimaryTap, - this.brandSuccess, - this.brandWarning, - this.brandError, - this.brandImportant, - this.brandImportantValue, - this.brandAuxiliary, - this.colorTextBase, - this.colorTextImportant, - this.colorTextBaseInverse, - this.colorTextSecondary, - this.colorTextDisabled, - this.colorTextHint, - this.colorLink, - this.fillBase, - this.fillBody, - this.fillMask, - this.borderColorBase, - this.dividerColorBase, - this.fontSizeDIN, - this.fontSizeHeadLg, - this.fontSizeBase, - this.fontSizeHead, - this.fontSizeSubHead, - this.fontSizeCaption, - this.fontSizeCaptionSm, - this.radiusXs, - this.radiusSm, - this.radiusMd, - this.radiusLg, - this.borderWidthSm, - this.borderWidthMd, - this.borderWidthLg, - this.hSpacingXs, - this.hSpacingSm, - this.hSpacingMd, - this.hSpacingLg, - this.hSpacingXl, - this.hSpacingXxl, - this.vSpacingXs, - this.vSpacingSm, - this.vSpacingMd, - this.vSpacingLg, - this.vSpacingXl, - this.vSpacingXxl, - this.iconSizeXxs, - this.iconSizeXs, - this.iconSizeSm, - this.iconSizeMd, - this.iconSizeLg, + Color? brandPrimary, + Color? brandPrimaryTap, + Color? brandSuccess, + Color? brandWarning, + Color? brandError, + Color? brandImportant, + Color? brandImportantValue, + Color? brandAuxiliary, + Color? colorTextBase, + Color? colorTextImportant, + Color? colorTextBaseInverse, + Color? colorTextSecondary, + Color? colorTextDisabled, + Color? colorTextHint, + Color? colorLink, + Color? fillBase, + Color? fillBody, + Color? fillMask, + Color? borderColorBase, + Color? dividerColorBase, + double? fontSizeDIN, + double? fontSizeHeadLg, + double? fontSizeBase, + double? fontSizeHead, + double? fontSizeSubHead, + double? fontSizeCaption, + double? fontSizeCaptionSm, + double? radiusXs, + double? radiusSm, + double? radiusMd, + double? radiusLg, + double? borderWidthSm, + double? borderWidthMd, + double? borderWidthLg, + double? hSpacingXs, + double? hSpacingSm, + double? hSpacingMd, + double? hSpacingLg, + double? hSpacingXl, + double? hSpacingXxl, + double? vSpacingXs, + double? vSpacingSm, + double? vSpacingMd, + double? vSpacingLg, + double? vSpacingXl, + double? vSpacingXxl, + double? iconSizeXxs, + double? iconSizeXs, + double? iconSizeSm, + double? iconSizeMd, + double? iconSizeLg, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId, autoFlatConfig: true); + }) : _brandPrimary = brandPrimary, + _brandPrimaryTap = brandPrimaryTap, + _brandSuccess = brandSuccess, + _brandWarning = brandWarning, + _brandError = brandError, + _brandImportant = brandImportant, + _brandImportantValue = brandImportantValue, + _brandAuxiliary = brandAuxiliary, + _colorTextBase = colorTextBase, + _colorTextImportant = colorTextImportant, + _colorTextBaseInverse = colorTextBaseInverse, + _colorTextSecondary = colorTextSecondary, + _colorTextDisabled = colorTextDisabled, + _colorTextHint = colorTextHint, + _colorLink = colorLink, + _fillBase = fillBase, + _fillBody = fillBody, + _fillMask = fillMask, + _borderColorBase = borderColorBase, + _dividerColorBase = dividerColorBase, + _fontSizeDIN = fontSizeDIN, + _fontSizeHeadLg = fontSizeHeadLg, + _fontSizeBase = fontSizeBase, + _fontSizeHead = fontSizeHead, + _fontSizeSubHead = fontSizeSubHead, + _fontSizeCaption = fontSizeCaption, + _fontSizeCaptionSm = fontSizeCaptionSm, + _radiusXs = radiusXs, + _radiusSm = radiusSm, + _radiusMd = radiusMd, + _radiusLg = radiusLg, + _borderWidthSm = borderWidthSm, + _borderWidthMd = borderWidthMd, + _borderWidthLg = borderWidthLg, + _hSpacingXs = hSpacingXs, + _hSpacingSm = hSpacingSm, + _hSpacingMd = hSpacingMd, + _hSpacingLg = hSpacingLg, + _hSpacingXl = hSpacingXl, + _hSpacingXxl = hSpacingXxl, + _vSpacingXs = vSpacingXs, + _vSpacingSm = vSpacingSm, + _vSpacingMd = vSpacingMd, + _vSpacingLg = vSpacingLg, + _vSpacingXl = vSpacingXl, + _vSpacingXxl = vSpacingXxl, + _iconSizeXxs = iconSizeXxs, + _iconSizeXs = iconSizeXs, + _iconSizeSm = iconSizeSm, + _iconSizeMd = iconSizeMd, + _iconSizeLg = iconSizeLg, + super(configId: configId, autoFlatConfig: true); /// 基本单位 static const double hd = 1; @@ -126,86 +229,86 @@ class BrnCommonConfig extends BrnBaseConfig { /// 品牌色 /// 默认为 Color(0xFF0984F9) - Color? brandPrimary; + Color? _brandPrimary; /// 主题色按下效果 /// 默认为 Color(0x190984F9) - Color? brandPrimaryTap; + Color? _brandPrimaryTap; /// 成功色 /// 默认为 Color(0xFF00AE66) - Color? brandSuccess; + Color? _brandSuccess; /// 警告色 /// 默认为 Color(0xFFFAAD14) - Color? brandWarning; + Color? _brandWarning; /// 失败色 /// 默认为 Color(0xFFFA3F3F) - Color? brandError; + Color? _brandError; /// 重要-多用于红点色 /// 默认为 Color(0xFFFA3F3F) - Color? brandImportant; + Color? _brandImportant; /// 重要数值色 /// 默认为 Color(0xFFFF5722) - Color? brandImportantValue; + Color? _brandImportantValue; /// 辅助色 /// 默认为 Color(0xFF44C2FF) - Color? brandAuxiliary; + Color? _brandAuxiliary; /// 文本色相关 /// /// 基础文字纯黑色 /// 默认为 Color(0xFF222222) - Color? colorTextBase; + Color? _colorTextBase; /// 基础文字重要色 /// 默认为 Color(0xFF666666) - Color? colorTextImportant; + Color? _colorTextImportant; /// 基础文字-反色 /// 默认为 Color(0xFFFFFFFF) - Color? colorTextBaseInverse; + Color? _colorTextBaseInverse; /// 辅助文字色 /// 默认为 Color(0xFF999999) - Color? colorTextSecondary; + Color? _colorTextSecondary; /// 失效或不可更改文字色 /// 默认为 Color(0xFF999999) - Color? colorTextDisabled; + Color? _colorTextDisabled; /// 文本框提示暗文文字色 /// 默认为 Color(0xFFCCCCCC) - Color? colorTextHint; + Color? _colorTextHint; /// 跟随主题色[brandPrimary] - Color? colorLink; + Color? _colorLink; /// 背景色相关 /// /// 组件背景色 /// 默认为 Color(0xFFFFFFFF) - Color? fillBase; + Color? _fillBase; /// 页面背景色 /// 默认为 Color(0xFFF8F8F8) - Color? fillBody; + Color? _fillBody; /// 遮罩背景 /// 默认为 Color(0x99000000) - Color? fillMask; + Color? _fillMask; /// 边框色 /// 默认为 Color(0xFFF0F0F0) - Color? borderColorBase; + Color? _borderColorBase; /// 分割线色 /// 默认为 Color(0xFFF0F0F0) - Color? dividerColorBase; + Color? _dividerColorBase; /////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////// 尺寸 ///////////////////////////////////// @@ -215,113 +318,280 @@ class BrnCommonConfig extends BrnBaseConfig { /// /// 特殊数据展示,DIN Condensed数字字体,用于强吸引 /// 默认为 28 - double? fontSizeDIN; + double? _fontSizeDIN; /// 标题字体 /// 名称/页面大标题 /// 默认为 22 - double? fontSizeHeadLg; + double? _fontSizeHeadLg; /// 标题字体 /// 内容模块标题/一级标题 /// 默认为 18 - double? fontSizeHead; + double? _fontSizeHead; /// 子标题字体 /// 标题/录入文字/大按钮文字/二级标题 /// 默认为 16 - double? fontSizeSubHead; + double? _fontSizeSubHead; /// 基础字体 /// 内容副文本/普通说明文字 /// 默认为 14 - double? fontSizeBase; + double? _fontSizeBase; /// 辅助字体-普通 /// 默认为 12 - double? fontSizeCaption; + double? _fontSizeCaption; ///辅助字体-小 /// 默认为 11 - double? fontSizeCaptionSm; + double? _fontSizeCaptionSm; /// 圆角尺寸 /// 默认为 2.0 - double? radiusXs; + double? _radiusXs; /// 默认为 4.0 - double? radiusSm; + double? _radiusSm; /// 默认为 6.0 - double? radiusMd; + double? _radiusMd; /// 默认为 8.0 - double? radiusLg; + double? _radiusLg; /// 边框尺寸 /// /// 默认为 0.5 - double? borderWidthSm; + double? _borderWidthSm; /// 默认为 1 - double? borderWidthMd; + double? _borderWidthMd; /// 默认为 2 - double? borderWidthLg; + double? _borderWidthLg; /// 水平间距 /// 默认为 8 - double? hSpacingXs; + double? _hSpacingXs; /// 默认为 12 - double? hSpacingSm; + double? _hSpacingSm; /// 默认为 16 - double? hSpacingMd; + double? _hSpacingMd; /// 默认为 20 - double? hSpacingLg; + double? _hSpacingLg; /// 默认为 24 - double? hSpacingXl; + double? _hSpacingXl; /// 默认为 42 - double? hSpacingXxl; + double? _hSpacingXxl; /// 垂直间距 /// 默认为 4 - double? vSpacingXs; + double? _vSpacingXs; /// 默认为 8 - double? vSpacingSm; + double? _vSpacingSm; /// 默认为 12 - double? vSpacingMd; + double? _vSpacingMd; /// 默认为 14 - double? vSpacingLg; + double? _vSpacingLg; /// 默认为 16 - double? vSpacingXl; + double? _vSpacingXl; /// 默认为 28 - double? vSpacingXxl; + double? _vSpacingXxl; /// 图标尺寸 /// 默认为 8 - double? iconSizeXxs; + double? _iconSizeXxs; /// 默认为 12 - double? iconSizeXs; + double? _iconSizeXs; /// 默认为 14 - double? iconSizeSm; + double? _iconSizeSm; /// 默认为 16 - double? iconSizeMd; + double? _iconSizeMd; /// 默认为 32 - double? iconSizeLg; + double? _iconSizeLg; + + Color get brandPrimary => + _brandPrimary ?? BrnDefaultConfigUtils.defaultCommonConfig.brandPrimary; + + Color get brandPrimaryTap => + _brandPrimaryTap ?? + BrnDefaultConfigUtils.defaultCommonConfig.brandPrimaryTap; + + Color get brandSuccess => + _brandSuccess ?? BrnDefaultConfigUtils.defaultCommonConfig.brandSuccess; + + Color get brandWarning => + _brandWarning ?? BrnDefaultConfigUtils.defaultCommonConfig.brandWarning; + + Color get brandError => + _brandError ?? BrnDefaultConfigUtils.defaultCommonConfig.brandError; + + Color get brandImportant => + _brandImportant ?? + BrnDefaultConfigUtils.defaultCommonConfig.brandImportant; + + Color get brandImportantValue => + _brandImportantValue ?? + BrnDefaultConfigUtils.defaultCommonConfig.brandImportantValue; + + Color get brandAuxiliary => + _brandAuxiliary ?? + BrnDefaultConfigUtils.defaultCommonConfig.brandAuxiliary; + + Color get colorTextBase => + _colorTextBase ?? BrnDefaultConfigUtils.defaultCommonConfig.colorTextBase; + + Color get colorTextImportant => + _colorTextImportant ?? + BrnDefaultConfigUtils.defaultCommonConfig.colorTextImportant; + + Color get colorTextBaseInverse => + _colorTextBaseInverse ?? + BrnDefaultConfigUtils.defaultCommonConfig.colorTextBaseInverse; + + Color get colorTextSecondary => + _colorTextSecondary ?? + BrnDefaultConfigUtils.defaultCommonConfig.colorTextSecondary; + + Color get colorTextDisabled => + _colorTextDisabled ?? + BrnDefaultConfigUtils.defaultCommonConfig.colorTextDisabled; + + Color get colorTextHint => + _colorTextHint ?? BrnDefaultConfigUtils.defaultCommonConfig.colorTextHint; + + Color get colorLink => + _colorLink ?? BrnDefaultConfigUtils.defaultCommonConfig.colorLink; + + Color get fillBase => + _fillBase ?? BrnDefaultConfigUtils.defaultCommonConfig.fillBase; + + Color get fillBody => + _fillBody ?? BrnDefaultConfigUtils.defaultCommonConfig.fillBody; + + Color get fillMask => + _fillMask ?? BrnDefaultConfigUtils.defaultCommonConfig.fillMask; + + Color get borderColorBase => + _borderColorBase ?? + BrnDefaultConfigUtils.defaultCommonConfig.borderColorBase; + + Color get dividerColorBase => + _dividerColorBase ?? + BrnDefaultConfigUtils.defaultCommonConfig.dividerColorBase; + + double get fontSizeDIN => + _fontSizeDIN ?? BrnDefaultConfigUtils.defaultCommonConfig.fontSizeDIN; + + double get fontSizeHeadLg => + _fontSizeHeadLg ?? + BrnDefaultConfigUtils.defaultCommonConfig.fontSizeHeadLg; + + double get fontSizeHead => + _fontSizeHead ?? BrnDefaultConfigUtils.defaultCommonConfig.fontSizeHead; + + double get fontSizeSubHead => + _fontSizeSubHead ?? + BrnDefaultConfigUtils.defaultCommonConfig.fontSizeSubHead; + + double get fontSizeBase => + _fontSizeBase ?? BrnDefaultConfigUtils.defaultCommonConfig.fontSizeBase; + + double get fontSizeCaption => + _fontSizeCaption ?? + BrnDefaultConfigUtils.defaultCommonConfig.fontSizeCaption; + + double get fontSizeCaptionSm => + _fontSizeCaptionSm ?? + BrnDefaultConfigUtils.defaultCommonConfig.fontSizeCaptionSm; + + double get radiusXs => + _radiusXs ?? BrnDefaultConfigUtils.defaultCommonConfig.radiusXs; + + double get radiusSm => + _radiusSm ?? BrnDefaultConfigUtils.defaultCommonConfig.radiusSm; + + double get radiusMd => + _radiusMd ?? BrnDefaultConfigUtils.defaultCommonConfig.radiusMd; + + double get radiusLg => + _radiusLg ?? BrnDefaultConfigUtils.defaultCommonConfig.radiusLg; + + double get borderWidthSm => + _borderWidthSm ?? BrnDefaultConfigUtils.defaultCommonConfig.borderWidthSm; + + double get borderWidthMd => + _borderWidthMd ?? BrnDefaultConfigUtils.defaultCommonConfig.borderWidthMd; + + double get borderWidthLg => + _borderWidthLg ?? BrnDefaultConfigUtils.defaultCommonConfig.borderWidthLg; + + double get hSpacingXs => + _hSpacingXs ?? BrnDefaultConfigUtils.defaultCommonConfig.hSpacingXs; + + double get hSpacingSm => + _hSpacingSm ?? BrnDefaultConfigUtils.defaultCommonConfig.hSpacingSm; + + double get hSpacingMd => + _hSpacingMd ?? BrnDefaultConfigUtils.defaultCommonConfig.hSpacingMd; + + double get hSpacingLg => + _hSpacingLg ?? BrnDefaultConfigUtils.defaultCommonConfig.hSpacingLg; + + double get hSpacingXl => + _hSpacingXl ?? BrnDefaultConfigUtils.defaultCommonConfig.hSpacingXl; + + double get hSpacingXxl => + _hSpacingXxl ?? BrnDefaultConfigUtils.defaultCommonConfig.hSpacingXxl; + + double get vSpacingXs => + _vSpacingXs ?? BrnDefaultConfigUtils.defaultCommonConfig.vSpacingXs; + + double get vSpacingSm => + _vSpacingSm ?? BrnDefaultConfigUtils.defaultCommonConfig.vSpacingSm; + + double get vSpacingMd => + _vSpacingMd ?? BrnDefaultConfigUtils.defaultCommonConfig.vSpacingMd; + + double get vSpacingLg => + _vSpacingLg ?? BrnDefaultConfigUtils.defaultCommonConfig.vSpacingLg; + + double get vSpacingXl => + _vSpacingXl ?? BrnDefaultConfigUtils.defaultCommonConfig.vSpacingXl; + + double get vSpacingXxl => + _vSpacingXxl ?? BrnDefaultConfigUtils.defaultCommonConfig.vSpacingXxl; + + double get iconSizeXxs => + _iconSizeXxs ?? BrnDefaultConfigUtils.defaultCommonConfig.iconSizeXxs; + + double get iconSizeXs => + _iconSizeXs ?? BrnDefaultConfigUtils.defaultCommonConfig.iconSizeXs; + + double get iconSizeSm => + _iconSizeSm ?? BrnDefaultConfigUtils.defaultCommonConfig.iconSizeSm; + + double get iconSizeMd => + _iconSizeMd ?? BrnDefaultConfigUtils.defaultCommonConfig.iconSizeMd; + + double get iconSizeLg => + _iconSizeLg ?? BrnDefaultConfigUtils.defaultCommonConfig.iconSizeLg; /// 优先级 [GLOBAL_CONFIG_ID] 获取配置 > [BRUNO_CONFIG_ID] 获取配置 @override @@ -335,56 +605,56 @@ class BrnCommonConfig extends BrnBaseConfig { ); /// 获取合适的 完整配置(BrnAllConfig) - this.colorTextBase ??= commonConfig.colorTextBase; - this.colorTextImportant ??= commonConfig.colorTextImportant; - this.colorTextBaseInverse ??= commonConfig.colorTextBaseInverse; - this.colorTextSecondary ??= commonConfig.colorTextSecondary; - this.colorTextHint ??= commonConfig.colorTextHint; - this.colorTextDisabled ??= commonConfig.colorTextDisabled; - this.brandAuxiliary ??= commonConfig.brandAuxiliary; - this.colorLink ??= commonConfig.colorLink; - this.fillBase ??= commonConfig.fillBase; - this.fillBody ??= commonConfig.fillBody; - this.fillMask ??= commonConfig.fillMask; - this.brandPrimary ??= commonConfig.brandPrimary; - this.brandPrimaryTap ??= commonConfig.brandPrimaryTap; - this.brandSuccess ??= commonConfig.brandSuccess; - this.brandWarning ??= commonConfig.brandWarning; - this.brandError ??= commonConfig.brandError; - this.brandImportant ??= commonConfig.brandImportant; - this.brandImportantValue ??= commonConfig.brandImportantValue; - this.borderColorBase ??= commonConfig.borderColorBase; - this.dividerColorBase ??= commonConfig.dividerColorBase; - this.fontSizeDIN ??= commonConfig.fontSizeDIN; - this.fontSizeHeadLg ??= commonConfig.fontSizeHeadLg; - this.fontSizeBase ??= commonConfig.fontSizeBase; - this.fontSizeHead ??= commonConfig.fontSizeHead; - this.fontSizeSubHead ??= commonConfig.fontSizeSubHead; - this.fontSizeCaption ??= commonConfig.fontSizeCaption; - this.fontSizeCaptionSm ??= commonConfig.fontSizeCaptionSm; - this.radiusXs ??= commonConfig.radiusXs; - this.radiusSm ??= commonConfig.radiusSm; - this.radiusMd ??= commonConfig.radiusMd; - this.radiusLg ??= commonConfig.radiusLg; - this.borderWidthSm ??= commonConfig.borderWidthSm; - this.borderWidthMd ??= commonConfig.borderWidthMd; - this.borderWidthLg ??= commonConfig.borderWidthLg; - this.hSpacingXs ??= commonConfig.hSpacingXs; - this.hSpacingSm ??= commonConfig.hSpacingSm; - this.hSpacingMd ??= commonConfig.hSpacingMd; - this.hSpacingLg ??= commonConfig.hSpacingLg; - this.hSpacingXl ??= commonConfig.hSpacingXl; - this.hSpacingXxl ??= commonConfig.hSpacingXxl; - this.vSpacingXs ??= commonConfig.vSpacingXs; - this.vSpacingSm ??= commonConfig.vSpacingSm; - this.vSpacingMd ??= commonConfig.vSpacingMd; - this.vSpacingLg ??= commonConfig.vSpacingLg; - this.vSpacingXl ??= commonConfig.vSpacingXl; - this.vSpacingXxl ??= commonConfig.vSpacingXxl; - this.iconSizeXxs ??= commonConfig.iconSizeXxs; - this.iconSizeXs ??= commonConfig.iconSizeXs; - this.iconSizeSm ??= commonConfig.iconSizeSm; - this.iconSizeMd ??= commonConfig.iconSizeMd; - this.iconSizeLg ??= commonConfig.iconSizeLg; + _colorTextBase ??= commonConfig._colorTextBase; + _colorTextImportant ??= commonConfig._colorTextImportant; + _colorTextBaseInverse ??= commonConfig._colorTextBaseInverse; + _colorTextSecondary ??= commonConfig._colorTextSecondary; + _colorTextHint ??= commonConfig._colorTextHint; + _colorTextDisabled ??= commonConfig._colorTextDisabled; + _brandAuxiliary ??= commonConfig._brandAuxiliary; + _colorLink ??= commonConfig._colorLink; + _fillBase ??= commonConfig._fillBase; + _fillBody ??= commonConfig._fillBody; + _fillMask ??= commonConfig._fillMask; + _brandPrimary ??= commonConfig._brandPrimary; + _brandPrimaryTap ??= commonConfig._brandPrimaryTap; + _brandSuccess ??= commonConfig._brandSuccess; + _brandWarning ??= commonConfig._brandWarning; + _brandError ??= commonConfig._brandError; + _brandImportant ??= commonConfig._brandImportant; + _brandImportantValue ??= commonConfig._brandImportantValue; + _borderColorBase ??= commonConfig._borderColorBase; + _dividerColorBase ??= commonConfig._dividerColorBase; + _fontSizeDIN ??= commonConfig._fontSizeDIN; + _fontSizeHeadLg ??= commonConfig._fontSizeHeadLg; + _fontSizeBase ??= commonConfig._fontSizeBase; + _fontSizeHead ??= commonConfig._fontSizeHead; + _fontSizeSubHead ??= commonConfig._fontSizeSubHead; + _fontSizeCaption ??= commonConfig._fontSizeCaption; + _fontSizeCaptionSm ??= commonConfig._fontSizeCaptionSm; + _radiusXs ??= commonConfig._radiusXs; + _radiusSm ??= commonConfig._radiusSm; + _radiusMd ??= commonConfig._radiusMd; + _radiusLg ??= commonConfig._radiusLg; + _borderWidthSm ??= commonConfig._borderWidthSm; + _borderWidthMd ??= commonConfig._borderWidthMd; + _borderWidthLg ??= commonConfig._borderWidthLg; + _hSpacingXs ??= commonConfig._hSpacingXs; + _hSpacingSm ??= commonConfig._hSpacingSm; + _hSpacingMd ??= commonConfig._hSpacingMd; + _hSpacingLg ??= commonConfig._hSpacingLg; + _hSpacingXl ??= commonConfig._hSpacingXl; + _hSpacingXxl ??= commonConfig._hSpacingXxl; + _vSpacingXs ??= commonConfig._vSpacingXs; + _vSpacingSm ??= commonConfig._vSpacingSm; + _vSpacingMd ??= commonConfig._vSpacingMd; + _vSpacingLg ??= commonConfig._vSpacingLg; + _vSpacingXl ??= commonConfig._vSpacingXl; + _vSpacingXxl ??= commonConfig._vSpacingXxl; + _iconSizeXxs ??= commonConfig._iconSizeXxs; + _iconSizeXs ??= commonConfig._iconSizeXs; + _iconSizeSm ??= commonConfig._iconSizeSm; + _iconSizeMd ??= commonConfig._iconSizeMd; + _iconSizeLg ??= commonConfig._iconSizeLg; } } diff --git a/lib/src/theme/configs/brn_dialog_config.dart b/lib/src/theme/configs/brn_dialog_config.dart index 75b949fb..cab28d71 100644 --- a/lib/src/theme/configs/brn_dialog_config.dart +++ b/lib/src/theme/configs/brn_dialog_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -7,43 +8,74 @@ import 'package:flutter/material.dart'; /// 描述: Dialog 弹框主配置类 class BrnDialogConfig extends BrnBaseConfig { BrnDialogConfig({ - this.dialogWidth, - this.radius, - this.iconPadding, - this.titlePaddingSm, - this.titlePaddingLg, - this.titleTextStyle, - this.titleTextAlign, - this.contentPaddingSm, - this.contentPaddingLg, - this.contentTextStyle, - this.contentTextAlign, - this.warningPaddingSm, - this.warningPaddingLg, - this.warningTextStyle, - this.warningTextAlign, - this.dividerPadding, - this.mainActionTextStyle, - this.assistActionsTextStyle, - this.mainActionBackgroundColor, - this.assistActionsBackgroundColor, - this.bottomHeight, - this.backgroundColor, + double? dialogWidth, + double? radius, + EdgeInsets? iconPadding, + EdgeInsets? titlePaddingSm, + EdgeInsets? titlePaddingLg, + BrnTextStyle? titleTextStyle, + TextAlign? titleTextAlign, + EdgeInsets? contentPaddingSm, + EdgeInsets? contentPaddingLg, + BrnTextStyle? contentTextStyle, + TextAlign? contentTextAlign, + EdgeInsets? warningPaddingSm, + EdgeInsets? warningPaddingLg, + BrnTextStyle? warningTextStyle, + TextAlign? warningTextAlign, + EdgeInsets? dividerPadding, + BrnTextStyle? mainActionTextStyle, + BrnTextStyle? assistActionsTextStyle, + Color? mainActionBackgroundColor, + Color? assistActionsBackgroundColor, + double? bottomHeight, + Color? backgroundColor, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _dialogWidth = dialogWidth, + _radius = radius, + _iconPadding = iconPadding, + _titlePaddingSm = titlePaddingSm, + _titlePaddingLg = titlePaddingLg, + _titleTextStyle = titleTextStyle, + _titleTextAlign = titleTextAlign, + _contentPaddingSm = contentPaddingSm, + _contentPaddingLg = contentPaddingLg, + _contentTextStyle = contentTextStyle, + _contentTextAlign = contentTextAlign, + _warningPaddingSm = warningPaddingSm, + _warningPaddingLg = warningPaddingLg, + _warningTextStyle = warningTextStyle, + _warningTextAlign = warningTextAlign, + _dividerPadding = dividerPadding, + _mainActionTextStyle = mainActionTextStyle, + _assistActionsTextStyle = assistActionsTextStyle, + _mainActionBackgroundColor = mainActionBackgroundColor, + _assistActionsBackgroundColor = assistActionsBackgroundColor, + _bottomHeight = bottomHeight, + _backgroundColor = backgroundColor, + super(configId: configId); /// Dialog 宽度 /// 默认为 300 - double? dialogWidth; + double? _dialogWidth; + + double get dialogWidth => + _dialogWidth ?? BrnDefaultConfigUtils.defaultDialogConfig.dialogWidth; /// Dialog 四周圆角 /// 默认为 [BrnCommonConfig.radiusLg] - double? radius; + double? _radius; + + double get radius => + _radius ?? BrnDefaultConfigUtils.defaultDialogConfig.radius; /// Dialog icon 距离顶部的边距 /// /// EdgeInsets.only(top: [BrnCommonConfig.vSpacingXxl]) - EdgeInsets? iconPadding; + EdgeInsets? _iconPadding; + + EdgeInsets get iconPadding => + _iconPadding ?? BrnDefaultConfigUtils.defaultDialogConfig.iconPadding; /// title 在顶部有 icon 时的边距 /// @@ -52,7 +84,11 @@ class BrnDialogConfig extends BrnBaseConfig { /// left: [BrnCommonConfig.hSpacingXxl], /// right: [BrnCommonConfig.hSpacingXxl], /// ) - EdgeInsets? titlePaddingSm; + EdgeInsets? _titlePaddingSm; + + EdgeInsets get titlePaddingSm => + _titlePaddingSm ?? + BrnDefaultConfigUtils.defaultDialogConfig.titlePaddingSm; /// title 当顶部无 icon 时的边距 /// @@ -61,7 +97,11 @@ class BrnDialogConfig extends BrnBaseConfig { /// left: [BrnCommonConfig.hSpacingXxl], /// right: [BrnCommonConfig.hSpacingXxl], /// ) - EdgeInsets? titlePaddingLg; + EdgeInsets? _titlePaddingLg; + + EdgeInsets get titlePaddingLg => + _titlePaddingLg ?? + BrnDefaultConfigUtils.defaultDialogConfig.titlePaddingLg; /// title 标题样式 /// @@ -70,11 +110,19 @@ class BrnDialogConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? titleTextStyle; + BrnTextStyle? _titleTextStyle; + + BrnTextStyle get titleTextStyle => + _titleTextStyle ?? + BrnDefaultConfigUtils.defaultDialogConfig.titleTextStyle; /// 标题的文字对齐 /// 默认为 [TextAlign.center] - TextAlign? titleTextAlign; + TextAlign? _titleTextAlign; + + TextAlign get titleTextAlign => + _titleTextAlign ?? + BrnDefaultConfigUtils.defaultDialogConfig.titleTextAlign; /// content 当顶部有 title 或者 icon 时的边距 /// @@ -83,7 +131,11 @@ class BrnDialogConfig extends BrnBaseConfig { /// left: [BrnCommonConfig.hSpacingXl], /// right: [BrnCommonConfig.hSpacingXl], /// ) - EdgeInsets? contentPaddingSm; + EdgeInsets? _contentPaddingSm; + + EdgeInsets get contentPaddingSm => + _contentPaddingSm ?? + BrnDefaultConfigUtils.defaultDialogConfig.contentPaddingSm; /// content 当顶部无 title 或者 icon 时的边距 /// @@ -92,7 +144,11 @@ class BrnDialogConfig extends BrnBaseConfig { /// left: [BrnCommonConfig.hSpacingXl], /// right: [BrnCommonConfig.hSpacingXl], /// ) - EdgeInsets? contentPaddingLg; + EdgeInsets? _contentPaddingLg; + + EdgeInsets get contentPaddingLg => + _contentPaddingLg ?? + BrnDefaultConfigUtils.defaultDialogConfig.contentPaddingLg; /// message 内容样式 /// @@ -100,11 +156,19 @@ class BrnDialogConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextImportant], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? contentTextStyle; + BrnTextStyle? _contentTextStyle; + + BrnTextStyle get contentTextStyle => + _contentTextStyle ?? + BrnDefaultConfigUtils.defaultDialogConfig.contentTextStyle; /// 内容文字的对齐 /// 默认为 [TextAlign.center] - TextAlign? contentTextAlign; + TextAlign? _contentTextAlign; + + TextAlign get contentTextAlign => + _contentTextAlign ?? + BrnDefaultConfigUtils.defaultDialogConfig.contentTextAlign; /// warning 当顶部有 title/icon/content 时的边距 /// @@ -113,7 +177,11 @@ class BrnDialogConfig extends BrnBaseConfig { /// left: [BrnCommonConfig.hSpacingXl], /// right: [BrnCommonConfig.hSpacingXl], /// ) - EdgeInsets? warningPaddingSm; + EdgeInsets? _warningPaddingSm; + + EdgeInsets get warningPaddingSm => + _warningPaddingSm ?? + BrnDefaultConfigUtils.defaultDialogConfig.warningPaddingSm; /// warning 当顶部无 title/icon/content 时的边距 /// @@ -122,7 +190,11 @@ class BrnDialogConfig extends BrnBaseConfig { /// left: [BrnCommonConfig.hSpacingXl], /// right: [BrnCommonConfig.hSpacingXl], /// ) - EdgeInsets? warningPaddingLg; + EdgeInsets? _warningPaddingLg; + + EdgeInsets get warningPaddingLg => + _warningPaddingLg ?? + BrnDefaultConfigUtils.defaultDialogConfig.warningPaddingLg; /// 警告样式 /// @@ -130,16 +202,28 @@ class BrnDialogConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.brandError], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? warningTextStyle; + BrnTextStyle? _warningTextStyle; + + BrnTextStyle get warningTextStyle => + _warningTextStyle ?? + BrnDefaultConfigUtils.defaultDialogConfig.warningTextStyle; /// 警示文案文字的对齐 /// 默认为 [TextAlign.center] - TextAlign? warningTextAlign; + TextAlign? _warningTextAlign; + + TextAlign get warningTextAlign => + _warningTextAlign ?? + BrnDefaultConfigUtils.defaultDialogConfig.warningTextAlign; /// action 顶部 divider 的上方边距 /// /// EdgeInsets.only(top: 28) - EdgeInsets? dividerPadding; + EdgeInsets? _dividerPadding; + + EdgeInsets get dividerPadding => + _dividerPadding ?? + BrnDefaultConfigUtils.defaultDialogConfig.dividerPadding; /// 主色调按钮样式 /// @@ -148,11 +232,19 @@ class BrnDialogConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? mainActionTextStyle; + BrnTextStyle? _mainActionTextStyle; + + BrnTextStyle get mainActionTextStyle => + _mainActionTextStyle ?? + BrnDefaultConfigUtils.defaultDialogConfig.mainActionTextStyle; /// 主色调按钮的背景 /// 默认为 [BrnCommonConfig.fillBase] - Color? mainActionBackgroundColor; + Color? _mainActionBackgroundColor; + + Color get mainActionBackgroundColor => + _mainActionBackgroundColor ?? + BrnDefaultConfigUtils.defaultDialogConfig.mainActionBackgroundColor; /// 其他按钮的样式(超2个时按钮样式) /// BrnTextStyle( @@ -160,19 +252,34 @@ class BrnDialogConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? assistActionsTextStyle; + BrnTextStyle? _assistActionsTextStyle; + + BrnTextStyle get assistActionsTextStyle => + _assistActionsTextStyle ?? + BrnDefaultConfigUtils.defaultDialogConfig.assistActionsTextStyle; /// 其他按钮的背景 /// 默认为 [BrnCommonConfig.fillBase] - Color? assistActionsBackgroundColor; + Color? _assistActionsBackgroundColor; + + Color get assistActionsBackgroundColor => + _assistActionsBackgroundColor ?? + BrnDefaultConfigUtils.defaultDialogConfig.assistActionsBackgroundColor; /// 底部按钮高度 /// 默认为 44.0 - double? bottomHeight; + double? _bottomHeight; + + double get bottomHeight => + _bottomHeight ?? BrnDefaultConfigUtils.defaultDialogConfig.bottomHeight; /// Dialog背景 /// 默认为 [BrnCommonConfig.fillBase] - Color? backgroundColor; + Color? _backgroundColor; + + Color get backgroundColor => + _backgroundColor ?? + BrnDefaultConfigUtils.defaultDialogConfig.backgroundColor; /// 按优先级,打平 【Bruno 内置配置】 < 【用户全局的默认配置】 < 【用户特殊配置】 < 【临时组件配置】 /// @@ -192,92 +299,92 @@ class BrnDialogConfig extends BrnBaseConfig { ); /// 用户全局组件配置 - BrnDialogConfig? dialogConfig = BrnThemeConfigurator.instance + BrnDialogConfig dialogConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .dialogConfig; - dialogWidth ??= dialogConfig?.dialogWidth; - radius ??= commonConfig.radiusLg; - titlePaddingSm ??= EdgeInsets.only( - left: commonConfig.hSpacingXxl ?? 0, - right: commonConfig.hSpacingXxl ?? 0, - top: dialogConfig?.titlePaddingSm?.top ?? 0, - bottom: dialogConfig?.titlePaddingSm?.bottom ?? 0, + _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 ?? 0, - right: commonConfig.hSpacingXxl ?? 0, - top: dialogConfig?.titlePaddingLg?.top ?? 0, - bottom: dialogConfig?.titlePaddingLg?.bottom ?? 0, + _titlePaddingLg ??= EdgeInsets.only( + left: commonConfig.hSpacingXxl, + right: commonConfig.hSpacingXxl, + top: dialogConfig.titlePaddingLg.top, + bottom: dialogConfig.titlePaddingLg.bottom, ); - iconPadding ??= EdgeInsets.only( - left: dialogConfig?.iconPadding?.left ?? 0, - top: commonConfig.vSpacingXxl ?? 0, - right: dialogConfig?.iconPadding?.right ?? 0, - bottom: dialogConfig?.iconPadding?.bottom ?? 0, + _iconPadding ??= EdgeInsets.only( + left: dialogConfig.iconPadding.left, + top: commonConfig.vSpacingXxl, + right: dialogConfig.iconPadding.right, + bottom: dialogConfig.iconPadding.bottom, ); - titleTextStyle = dialogConfig?.titleTextStyle?.merge( + _titleTextStyle = dialogConfig.titleTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeHead, - ).merge(titleTextStyle), + ).merge(_titleTextStyle), ); - contentTextStyle = dialogConfig?.contentTextStyle?.merge( + _contentTextStyle = dialogConfig.contentTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextImportant, fontSize: commonConfig.fontSizeBase, - ).merge(contentTextStyle), + ).merge(_contentTextStyle), ); - warningTextStyle = dialogConfig?.warningTextStyle?.merge( + _warningTextStyle = dialogConfig.warningTextStyle.merge( BrnTextStyle( color: commonConfig.brandError, fontSize: commonConfig.fontSizeBase, - ).merge(warningTextStyle), + ).merge(_warningTextStyle), ); - mainActionTextStyle = dialogConfig?.mainActionTextStyle?.merge( + _mainActionTextStyle = dialogConfig.mainActionTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeSubHead, - ).merge(mainActionTextStyle), + ).merge(_mainActionTextStyle), ); - assistActionsTextStyle = dialogConfig?.assistActionsTextStyle?.merge( + _assistActionsTextStyle = dialogConfig.assistActionsTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(assistActionsTextStyle), + ).merge(_assistActionsTextStyle), ); - contentPaddingSm ??= EdgeInsets.only( - left: commonConfig.hSpacingXl ?? 0, - right: commonConfig.hSpacingXl ?? 0, - top: dialogConfig?.contentPaddingSm?.top ?? 0, - bottom: dialogConfig?.contentPaddingSm?.bottom ?? 0, + _contentPaddingSm ??= EdgeInsets.only( + left: commonConfig.hSpacingXl, + right: commonConfig.hSpacingXl, + top: dialogConfig.contentPaddingSm.top, + bottom: dialogConfig.contentPaddingSm.bottom, ); - contentPaddingSm ??= EdgeInsets.only( - left: commonConfig.hSpacingXl ?? 0, - right: commonConfig.hSpacingXl ?? 0, - top: dialogConfig?.contentPaddingLg?.top ?? 0, - bottom: dialogConfig?.contentPaddingLg?.bottom ?? 0, + _contentPaddingSm ??= EdgeInsets.only( + left: commonConfig.hSpacingXl, + right: commonConfig.hSpacingXl, + top: dialogConfig.contentPaddingLg.top, + bottom: dialogConfig.contentPaddingLg.bottom, ); - warningPaddingSm ??= EdgeInsets.only( - left: commonConfig.hSpacingXl ?? 0, - right: commonConfig.hSpacingXl ?? 0, - top: dialogConfig?.warningPaddingSm?.top ?? 0, - bottom: dialogConfig?.warningPaddingSm?.bottom ?? 0, + _warningPaddingSm ??= EdgeInsets.only( + left: commonConfig.hSpacingXl, + right: commonConfig.hSpacingXl, + top: dialogConfig.warningPaddingSm.top, + bottom: dialogConfig.warningPaddingSm.bottom, ); - warningPaddingLg ??= EdgeInsets.only( - left: commonConfig.hSpacingXl ?? 0, - right: commonConfig.hSpacingXl ?? 0, - top: dialogConfig?.warningPaddingLg?.top ?? 0, - bottom: dialogConfig?.warningPaddingLg?.bottom ?? 0, + _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; + _titleTextAlign ??= dialogConfig.titleTextAlign; + _contentTextAlign ??= dialogConfig.contentTextAlign; + _warningTextAlign ??= dialogConfig.warningTextAlign; + _mainActionBackgroundColor ??= commonConfig.fillBase; + _assistActionsBackgroundColor ??= commonConfig.fillBase; + _bottomHeight ??= dialogConfig.bottomHeight; + _dividerPadding ??= dialogConfig.dividerPadding; + _backgroundColor ??= commonConfig.fillBase; } BrnDialogConfig copyWith({ @@ -305,66 +412,60 @@ class BrnDialogConfig extends BrnBaseConfig { Color? backgroundColor, }) { return BrnDialogConfig( - dialogWidth: dialogWidth ?? this.dialogWidth, - radius: radius ?? this.radius, - iconPadding: iconPadding ?? this.iconPadding, - titlePaddingSm: titlePaddingSm ?? this.titlePaddingSm, - titlePaddingLg: titlePaddingLg ?? this.titlePaddingLg, - titleTextStyle: titleTextStyle ?? this.titleTextStyle, - titleTextAlign: titleTextAlign ?? this.titleTextAlign, - contentPaddingSm: contentPaddingSm ?? this.contentPaddingSm, - contentPaddingLg: contentPaddingLg ?? this.contentPaddingLg, - contentTextStyle: contentTextStyle ?? this.contentTextStyle, - contentTextAlign: contentTextAlign ?? this.contentTextAlign, - warningPaddingSm: warningPaddingSm ?? this.warningPaddingSm, - warningPaddingLg: warningPaddingLg ?? this.warningPaddingLg, - warningTextStyle: warningTextStyle ?? this.warningTextStyle, - warningTextAlign: warningTextAlign ?? this.warningTextAlign, - dividerPadding: dividerPadding ?? this.dividerPadding, - mainActionTextStyle: mainActionTextStyle ?? this.mainActionTextStyle, - assistActionsTextStyle: - assistActionsTextStyle ?? this.assistActionsTextStyle, + dialogWidth: dialogWidth ?? _dialogWidth, + radius: radius ?? _radius, + iconPadding: iconPadding ?? _iconPadding, + titlePaddingSm: titlePaddingSm ?? _titlePaddingSm, + titlePaddingLg: titlePaddingLg ?? _titlePaddingLg, + titleTextStyle: titleTextStyle ?? _titleTextStyle, + titleTextAlign: titleTextAlign ?? _titleTextAlign, + contentPaddingSm: contentPaddingSm ?? _contentPaddingSm, + contentPaddingLg: contentPaddingLg ?? _contentPaddingLg, + contentTextStyle: contentTextStyle ?? _contentTextStyle, + contentTextAlign: contentTextAlign ?? _contentTextAlign, + warningPaddingSm: warningPaddingSm ?? _warningPaddingSm, + warningPaddingLg: warningPaddingLg ?? _warningPaddingLg, + warningTextStyle: warningTextStyle ?? _warningTextStyle, + warningTextAlign: warningTextAlign ?? _warningTextAlign, + dividerPadding: dividerPadding ?? _dividerPadding, + mainActionTextStyle: mainActionTextStyle ?? _mainActionTextStyle, + assistActionsTextStyle: assistActionsTextStyle ?? _assistActionsTextStyle, mainActionBackgroundColor: - mainActionBackgroundColor ?? this.mainActionBackgroundColor, + mainActionBackgroundColor ?? _mainActionBackgroundColor, assistActionsBackgroundColor: - assistActionsBackgroundColor ?? this.assistActionsBackgroundColor, - bottomHeight: bottomHeight ?? this.bottomHeight, - backgroundColor: backgroundColor ?? this.backgroundColor, + assistActionsBackgroundColor ?? _assistActionsBackgroundColor, + bottomHeight: bottomHeight ?? _bottomHeight, + backgroundColor: backgroundColor ?? _backgroundColor, ); } BrnDialogConfig merge(BrnDialogConfig? other) { if (other == null) return this; return copyWith( - dialogWidth: other.dialogWidth, - radius: other.radius, - iconPadding: other.iconPadding, - titlePaddingSm: other.titlePaddingSm, - titlePaddingLg: other.titlePaddingLg, - titleTextStyle: - titleTextStyle?.merge(other.titleTextStyle) ?? other.titleTextStyle, - titleTextAlign: other.titleTextAlign, - contentPaddingSm: other.contentPaddingSm, - contentPaddingLg: other.contentPaddingLg, - contentTextStyle: contentTextStyle?.merge(other.contentTextStyle) ?? - other.contentTextStyle, - contentTextAlign: other.contentTextAlign, - warningPaddingSm: other.warningPaddingSm, - warningPaddingLg: other.warningPaddingLg, - warningTextStyle: warningTextStyle?.merge(other.warningTextStyle) ?? - other.warningTextStyle, - warningTextAlign: other.warningTextAlign, - dividerPadding: other.dividerPadding, + dialogWidth: other._dialogWidth, + radius: other._radius, + iconPadding: other._iconPadding, + titlePaddingSm: other._titlePaddingSm, + titlePaddingLg: other._titlePaddingLg, + titleTextStyle: titleTextStyle.merge(other._titleTextStyle), + titleTextAlign: other._titleTextAlign, + contentPaddingSm: other._contentPaddingSm, + contentPaddingLg: other._contentPaddingLg, + contentTextStyle: contentTextStyle.merge(other._contentTextStyle), + contentTextAlign: other._contentTextAlign, + warningPaddingSm: other._warningPaddingSm, + warningPaddingLg: other._warningPaddingLg, + warningTextStyle: warningTextStyle.merge(other._warningTextStyle), + warningTextAlign: other._warningTextAlign, + dividerPadding: other._dividerPadding, mainActionTextStyle: - mainActionTextStyle?.merge(other.mainActionTextStyle) ?? - other.mainActionTextStyle, + mainActionTextStyle.merge(other._mainActionTextStyle), assistActionsTextStyle: - assistActionsTextStyle?.merge(other.assistActionsTextStyle) ?? - other.assistActionsTextStyle, - mainActionBackgroundColor: other.mainActionBackgroundColor, - assistActionsBackgroundColor: other.assistActionsBackgroundColor, - bottomHeight: other.bottomHeight, - backgroundColor: other.backgroundColor, + assistActionsTextStyle.merge(other._assistActionsTextStyle), + mainActionBackgroundColor: other._mainActionBackgroundColor, + assistActionsBackgroundColor: other._assistActionsBackgroundColor, + bottomHeight: other._bottomHeight, + backgroundColor: other._backgroundColor, ); } } diff --git a/lib/src/theme/configs/brn_enhance_number_card_config.dart b/lib/src/theme/configs/brn_enhance_number_card_config.dart index 8e710f8b..12c261aa 100644 --- a/lib/src/theme/configs/brn_enhance_number_card_config.dart +++ b/lib/src/theme/configs/brn_enhance_number_card_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -6,25 +7,50 @@ import 'package:bruno/src/theme/configs/brn_common_config.dart'; /// 强化数字展示组件配置 class BrnEnhanceNumberCardConfig extends BrnBaseConfig { /// 遵循外部主题配置 - /// 默认为 [BrnDefaultConfigUtils.defaultNumberInfoConfig] + /// 默认为 [BrnDefaultConfigUtils.defaultEnhanceNumberInfoConfig] BrnEnhanceNumberCardConfig({ - this.runningSpace, - this.itemRunningSpace, - this.titleTextStyle, - this.descTextStyle, - this.dividerWidth, + double? runningSpace, + double? itemRunningSpace, + BrnTextStyle? titleTextStyle, + BrnTextStyle? descTextStyle, + double? dividerWidth, String configId: GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _runningSpace = runningSpace, + _itemRunningSpace = itemRunningSpace, + _titleTextStyle = titleTextStyle, + _descTextStyle = descTextStyle, + _dividerWidth = dividerWidth, + super(configId: configId); /// 如果超过一行,行间距 - double? runningSpace; + double? _runningSpace; + + double get runningSpace => + _runningSpace ?? + BrnDefaultConfigUtils.defaultEnhanceNumberInfoConfig.runningSpace; /// Item的上半部分和下半部分的间距 - double? itemRunningSpace; - double? dividerWidth; + double? _itemRunningSpace; + + double get itemRunningSpace => + _itemRunningSpace ?? + BrnDefaultConfigUtils.defaultEnhanceNumberInfoConfig.itemRunningSpace; + + double? _dividerWidth; + + double get dividerWidth => + _dividerWidth ?? + BrnDefaultConfigUtils.defaultEnhanceNumberInfoConfig.dividerWidth; + BrnTextStyle? _titleTextStyle; + + BrnTextStyle get titleTextStyle => + _titleTextStyle ?? + BrnDefaultConfigUtils.defaultEnhanceNumberInfoConfig.titleTextStyle; + BrnTextStyle? _descTextStyle; - BrnTextStyle? titleTextStyle; - BrnTextStyle? descTextStyle; + BrnTextStyle get descTextStyle => + _descTextStyle ?? + BrnDefaultConfigUtils.defaultEnhanceNumberInfoConfig.descTextStyle; @override void initThemeConfig( @@ -36,18 +62,18 @@ class BrnEnhanceNumberCardConfig extends BrnBaseConfig { currentLevelCommonConfig: currentLevelCommonConfig, ); - BrnEnhanceNumberCardConfig? userConfig = BrnThemeConfigurator.instance + BrnEnhanceNumberCardConfig userConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .enhanceNumberCardConfig; - runningSpace ??= userConfig?.runningSpace; - itemRunningSpace ??= userConfig?.itemRunningSpace; - dividerWidth ??= userConfig?.dividerWidth; - titleTextStyle = userConfig?.titleTextStyle?.merge( - BrnTextStyle(color: commonConfig.colorTextBase).merge(titleTextStyle), + _runningSpace ??= userConfig._runningSpace; + _itemRunningSpace ??= userConfig._itemRunningSpace; + _dividerWidth ??= userConfig._dividerWidth; + _titleTextStyle = userConfig.titleTextStyle.merge( + BrnTextStyle(color: commonConfig.colorTextBase).merge(_titleTextStyle), ); - descTextStyle = userConfig?.descTextStyle?.merge( - BrnTextStyle(color: commonConfig.colorTextSecondary).merge(descTextStyle), + _descTextStyle = userConfig.descTextStyle.merge( + BrnTextStyle(color: commonConfig.colorTextSecondary).merge(_descTextStyle), ); } @@ -59,24 +85,22 @@ class BrnEnhanceNumberCardConfig extends BrnBaseConfig { BrnTextStyle? descTextStyle, }) { return BrnEnhanceNumberCardConfig( - runningSpace: runningSpace ?? this.runningSpace, - itemRunningSpace: itemRunningSpace ?? this.itemRunningSpace, - dividerWidth: dividerWidth ?? this.dividerWidth, - titleTextStyle: titleTextStyle ?? this.titleTextStyle, - descTextStyle: descTextStyle ?? this.descTextStyle, + runningSpace: runningSpace ?? _runningSpace, + itemRunningSpace: itemRunningSpace ?? _itemRunningSpace, + dividerWidth: dividerWidth ?? _dividerWidth, + titleTextStyle: titleTextStyle ?? _titleTextStyle, + descTextStyle: descTextStyle ?? _descTextStyle, ); } BrnEnhanceNumberCardConfig merge(BrnEnhanceNumberCardConfig? other) { if (other == null) return this; return copyWith( - runningSpace: other.runningSpace, - itemRunningSpace: other.itemRunningSpace, - dividerWidth: other.dividerWidth, - titleTextStyle: - titleTextStyle?.merge(other.titleTextStyle) ?? other.titleTextStyle, - descTextStyle: - descTextStyle?.merge(other.descTextStyle) ?? other.descTextStyle, + runningSpace: other._runningSpace, + itemRunningSpace: other._itemRunningSpace, + dividerWidth: other._dividerWidth, + titleTextStyle: titleTextStyle.merge(other._titleTextStyle), + descTextStyle: descTextStyle.merge(other._descTextStyle), ); } } diff --git a/lib/src/theme/configs/brn_form_config.dart b/lib/src/theme/configs/brn_form_config.dart index 210e3e95..0a932215 100644 --- a/lib/src/theme/configs/brn_form_config.dart +++ b/lib/src/theme/configs/brn_form_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -9,24 +10,40 @@ class BrnFormItemConfig extends BrnBaseConfig { /// 遵循全局配置 /// 默认为 [BrnDefaultConfigUtils.defaultFormItemConfig] BrnFormItemConfig({ - this.titleTextStyle, - this.subTitleTextStyle, - this.errorTextStyle, - this.hintTextStyle, - this.contentTextStyle, - this.formPadding, - this.titlePaddingSm, - this.titlePaddingLg, - this.optionsMiddlePadding, - this.subTitlePadding, - this.errorPadding, - this.disableTextStyle, - this.tipsTextStyle, - this.headTitleTextStyle, - this.optionTextStyle, - this.optionSelectedTextStyle, + BrnTextStyle? titleTextStyle, + BrnTextStyle? subTitleTextStyle, + BrnTextStyle? errorTextStyle, + BrnTextStyle? hintTextStyle, + BrnTextStyle? contentTextStyle, + EdgeInsets? formPadding, + EdgeInsets? titlePaddingSm, + EdgeInsets? titlePaddingLg, + EdgeInsets? optionsMiddlePadding, + EdgeInsets? subTitlePadding, + EdgeInsets? errorPadding, + BrnTextStyle? disableTextStyle, + BrnTextStyle? tipsTextStyle, + BrnTextStyle? headTitleTextStyle, + BrnTextStyle? optionTextStyle, + BrnTextStyle? optionSelectedTextStyle, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _titleTextStyle = titleTextStyle, + _subTitleTextStyle = subTitleTextStyle, + _errorTextStyle = errorTextStyle, + _hintTextStyle = hintTextStyle, + _contentTextStyle = contentTextStyle, + _formPadding = formPadding, + _titlePaddingSm = titlePaddingSm, + _titlePaddingLg = titlePaddingLg, + _optionsMiddlePadding = optionsMiddlePadding, + _subTitlePadding = subTitlePadding, + _errorPadding = errorPadding, + _disableTextStyle = disableTextStyle, + _tipsTextStyle = tipsTextStyle, + _headTitleTextStyle = headTitleTextStyle, + _optionTextStyle = optionTextStyle, + _optionSelectedTextStyle = optionSelectedTextStyle, + super(configId: configId); BrnFormItemConfig.generatorFromConfigId(String configId) { initThemeConfig(configId); @@ -38,7 +55,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeHead], /// ) - BrnTextStyle? headTitleTextStyle; + BrnTextStyle? _headTitleTextStyle; /// 左侧标题文本样式 /// @@ -46,7 +63,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? titleTextStyle; + BrnTextStyle? _titleTextStyle; /// 左侧辅助文本样式 /// @@ -54,7 +71,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextSecondary], /// fontSize: [BrnCommonConfig.fontSizeCaption], /// ) - BrnTextStyle? subTitleTextStyle; + BrnTextStyle? _subTitleTextStyle; /// 左侧 Error 文本样式 /// @@ -62,7 +79,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.brandError], /// fontSize: [BrnCommonConfig.fontSizeCaption], /// ) - BrnTextStyle? errorTextStyle; + BrnTextStyle? _errorTextStyle; /// 右侧 输入、选择提示文本样式 /// @@ -70,7 +87,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextHint], /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? hintTextStyle; + BrnTextStyle? _hintTextStyle; /// 右侧 主要内容样式 /// @@ -78,7 +95,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? contentTextStyle; + BrnTextStyle? _contentTextStyle; /// 表单项 当有星号标识 上下右边距 /// @@ -88,22 +105,22 @@ class BrnFormItemConfig extends BrnBaseConfig { /// right: [BrnCommonConfig.hSpacingLg], /// bottom: [BrnCommonConfig.vSpacingLg], /// ) - EdgeInsets? formPadding; + EdgeInsets? _formPadding; /// 表单项 当有星号标识 左边距 /// /// EdgeInsets.only(left: 10) - EdgeInsets? titlePaddingSm; + EdgeInsets? _titlePaddingSm; /// 表单项 当无星号标识 左右边距 /// /// EdgeInsets.only(left: [BrnCommonConfig.hSpacingLg]) - EdgeInsets? titlePaddingLg; + EdgeInsets? _titlePaddingLg; /// 选项之间间距 单选 or 多选 /// /// EdgeInsets.only(left: [BrnCommonConfig.hSpacingMd]) - EdgeInsets? optionsMiddlePadding; + EdgeInsets? _optionsMiddlePadding; /// 选项普通文本样式 /// @@ -112,7 +129,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// height: 1.3, /// ) - BrnTextStyle? optionTextStyle; + BrnTextStyle? _optionTextStyle; /// 选项选中文本样式 /// @@ -121,7 +138,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// height: 1.3, /// ) - BrnTextStyle? optionSelectedTextStyle; + BrnTextStyle? _optionSelectedTextStyle; /// 子标题 左上间距 /// @@ -129,7 +146,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// left: [BrnCommonConfig.hSpacingLg], /// top: [BrnCommonConfig.vSpacingXs], /// ) - EdgeInsets? subTitlePadding; + EdgeInsets? _subTitlePadding; /// error提示 左上间距 /// @@ -137,7 +154,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// left: [BrnCommonConfig.hSpacingLg], /// top: [BrnCommonConfig.vSpacingXs], /// ) - EdgeInsets? errorPadding; + EdgeInsets? _errorPadding; /// 不可修改内容展示 /// @@ -145,7 +162,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextDisabled], /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? disableTextStyle; + BrnTextStyle? _disableTextStyle; /// 提示文本样式 /// @@ -153,7 +170,69 @@ class BrnFormItemConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextSecondary], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? tipsTextStyle; + BrnTextStyle? _tipsTextStyle; + + BrnTextStyle get headTitleTextStyle => + _headTitleTextStyle ?? + BrnDefaultConfigUtils.defaultFormItemConfig.headTitleTextStyle; + + BrnTextStyle get titleTextStyle => + _titleTextStyle ?? + BrnDefaultConfigUtils.defaultFormItemConfig.titleTextStyle; + + BrnTextStyle get subTitleTextStyle => + _subTitleTextStyle ?? + BrnDefaultConfigUtils.defaultFormItemConfig.subTitleTextStyle; + + BrnTextStyle get errorTextStyle => + _errorTextStyle ?? + BrnDefaultConfigUtils.defaultFormItemConfig.errorTextStyle; + + BrnTextStyle get hintTextStyle => + _hintTextStyle ?? + BrnDefaultConfigUtils.defaultFormItemConfig.hintTextStyle; + + BrnTextStyle get contentTextStyle => + _contentTextStyle ?? + BrnDefaultConfigUtils.defaultFormItemConfig.contentTextStyle; + + EdgeInsets get formPadding => + _formPadding ?? BrnDefaultConfigUtils.defaultFormItemConfig.formPadding; + + EdgeInsets get titlePaddingSm => + _titlePaddingSm ?? + BrnDefaultConfigUtils.defaultFormItemConfig.titlePaddingSm; + + EdgeInsets get titlePaddingLg => + _titlePaddingLg ?? + BrnDefaultConfigUtils.defaultFormItemConfig.titlePaddingLg; + + EdgeInsets get optionsMiddlePadding => + _optionsMiddlePadding ?? + BrnDefaultConfigUtils.defaultFormItemConfig.optionsMiddlePadding; + + BrnTextStyle get optionTextStyle => + _optionTextStyle ?? + BrnDefaultConfigUtils.defaultFormItemConfig.optionTextStyle; + + BrnTextStyle get optionSelectedTextStyle => + _optionSelectedTextStyle ?? + BrnDefaultConfigUtils.defaultFormItemConfig.optionSelectedTextStyle; + + EdgeInsets get subTitlePadding => + _subTitlePadding ?? + BrnDefaultConfigUtils.defaultFormItemConfig.subTitlePadding; + + EdgeInsets get errorPadding => + _errorPadding ?? BrnDefaultConfigUtils.defaultFormItemConfig.errorPadding; + + BrnTextStyle get disableTextStyle => + _disableTextStyle ?? + BrnDefaultConfigUtils.defaultFormItemConfig.disableTextStyle; + + BrnTextStyle get tipsTextStyle => + _tipsTextStyle ?? + BrnDefaultConfigUtils.defaultFormItemConfig.tipsTextStyle; /// 举例: /// ① 尝试获取最近的配置 [topRadius] 若配不为 null,直接使用该配置. @@ -171,91 +250,91 @@ class BrnFormItemConfig extends BrnBaseConfig { ); /// 用户全局form组件配置 - BrnFormItemConfig? formItemThemeData = BrnThemeConfigurator.instance + BrnFormItemConfig formItemThemeData = BrnThemeConfigurator.instance .getConfig(configId: configId) .formItemConfig; - titlePaddingSm ??= formItemThemeData?.titlePaddingSm; - titlePaddingLg ??= formItemThemeData?.titlePaddingLg; - optionSelectedTextStyle = formItemThemeData?.optionSelectedTextStyle?.merge( + _titlePaddingSm ??= formItemThemeData.titlePaddingSm; + _titlePaddingLg ??= formItemThemeData.titlePaddingLg; + _optionSelectedTextStyle = formItemThemeData.optionSelectedTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeSubHead, - ).merge(optionSelectedTextStyle), + ).merge(_optionSelectedTextStyle), ); - optionTextStyle = formItemThemeData?.optionTextStyle?.merge( + _optionTextStyle = formItemThemeData.optionTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(optionTextStyle), + ).merge(_optionTextStyle), ); - headTitleTextStyle = formItemThemeData?.headTitleTextStyle?.merge( + _headTitleTextStyle = formItemThemeData.headTitleTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeHead, - ).merge(headTitleTextStyle), + ).merge(_headTitleTextStyle), ); - errorPadding ??= EdgeInsets.only( - left: commonConfig.hSpacingLg ?? 0, - right: formItemThemeData?.errorPadding?.right ?? 0, - top: commonConfig.vSpacingXs ?? 0, - bottom: formItemThemeData?.errorPadding?.bottom ?? 0, + _errorPadding ??= EdgeInsets.only( + left: commonConfig.hSpacingLg, + right: formItemThemeData.errorPadding.right, + top: commonConfig.vSpacingXs, + bottom: formItemThemeData.errorPadding.bottom, ); - subTitlePadding ??= EdgeInsets.only( - left: commonConfig.hSpacingLg ?? 0, - right: formItemThemeData?.subTitlePadding?.right ?? 0, - top: commonConfig.vSpacingXs ?? 0, - bottom: formItemThemeData?.subTitlePadding?.bottom ?? 0, + _subTitlePadding ??= EdgeInsets.only( + left: commonConfig.hSpacingLg, + right: formItemThemeData.subTitlePadding.right, + top: commonConfig.vSpacingXs, + bottom: formItemThemeData.subTitlePadding.bottom, ); - formPadding ??= EdgeInsets.only( - left: formItemThemeData?.formPadding?.left ?? 0, - right: commonConfig.hSpacingLg ?? 0, - top: commonConfig.vSpacingLg ?? 0, - bottom: commonConfig.vSpacingLg ?? 0, + _formPadding ??= EdgeInsets.only( + left: formItemThemeData.formPadding.left, + right: commonConfig.hSpacingLg, + top: commonConfig.vSpacingLg, + bottom: commonConfig.vSpacingLg, ); - tipsTextStyle = formItemThemeData?.tipsTextStyle?.merge( + _tipsTextStyle = formItemThemeData.tipsTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextSecondary, fontSize: commonConfig.fontSizeBase, - ).merge(tipsTextStyle), + ).merge(_tipsTextStyle), ); - disableTextStyle = formItemThemeData?.disableTextStyle?.merge( + _disableTextStyle = formItemThemeData.disableTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextDisabled, fontSize: commonConfig.fontSizeSubHead, - ).merge(disableTextStyle), + ).merge(_disableTextStyle), ); - contentTextStyle = formItemThemeData?.contentTextStyle?.merge( + _contentTextStyle = formItemThemeData.contentTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(contentTextStyle), + ).merge(_contentTextStyle), ); - hintTextStyle = formItemThemeData?.hintTextStyle?.merge( + _hintTextStyle = formItemThemeData.hintTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextHint, fontSize: commonConfig.fontSizeSubHead, - ).merge(hintTextStyle), + ).merge(_hintTextStyle), ); - titleTextStyle = formItemThemeData?.titleTextStyle?.merge( + _titleTextStyle = formItemThemeData.titleTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(titleTextStyle), + ).merge(_titleTextStyle), ); - subTitleTextStyle = formItemThemeData?.subTitleTextStyle?.merge( + _subTitleTextStyle = formItemThemeData.subTitleTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextSecondary, fontSize: commonConfig.fontSizeCaption, - ).merge(subTitleTextStyle), + ).merge(_subTitleTextStyle), ); - errorTextStyle = formItemThemeData?.errorTextStyle?.merge( + _errorTextStyle = formItemThemeData.errorTextStyle.merge( BrnTextStyle( color: commonConfig.brandError, fontSize: commonConfig.fontSizeCaption, - ).merge(errorTextStyle), + ).merge(_errorTextStyle), ); - optionsMiddlePadding ??= formItemThemeData?.optionsMiddlePadding; + _optionsMiddlePadding ??= formItemThemeData.optionsMiddlePadding; } BrnFormItemConfig copyWith({ @@ -277,56 +356,46 @@ class BrnFormItemConfig extends BrnBaseConfig { BrnTextStyle? optionSelectedTextStyle, }) { return BrnFormItemConfig( - titleTextStyle: titleTextStyle ?? this.titleTextStyle, - subTitleTextStyle: subTitleTextStyle ?? this.subTitleTextStyle, - errorTextStyle: errorTextStyle ?? this.errorTextStyle, - hintTextStyle: hintTextStyle ?? this.hintTextStyle, - contentTextStyle: contentTextStyle ?? this.contentTextStyle, - formPadding: formPadding ?? this.formPadding, - titlePaddingSm: titlePaddingSm ?? this.titlePaddingSm, - titlePaddingLg: titlePaddingLg ?? this.titlePaddingLg, - optionsMiddlePadding: optionsMiddlePadding ?? this.optionsMiddlePadding, - subTitlePadding: subTitlePadding ?? this.subTitlePadding, - errorPadding: errorPadding ?? this.errorPadding, - disableTextStyle: disableTextStyle ?? this.disableTextStyle, - tipsTextStyle: tipsTextStyle ?? this.tipsTextStyle, - headTitleTextStyle: headTitleTextStyle ?? this.headTitleTextStyle, - optionTextStyle: optionTextStyle ?? this.optionTextStyle, + titleTextStyle: titleTextStyle ?? _titleTextStyle, + subTitleTextStyle: subTitleTextStyle ?? _subTitleTextStyle, + errorTextStyle: errorTextStyle ?? _errorTextStyle, + hintTextStyle: hintTextStyle ?? _hintTextStyle, + contentTextStyle: contentTextStyle ?? _contentTextStyle, + formPadding: formPadding ?? _formPadding, + titlePaddingSm: titlePaddingSm ?? _titlePaddingSm, + titlePaddingLg: titlePaddingLg ?? _titlePaddingLg, + optionsMiddlePadding: optionsMiddlePadding ?? _optionsMiddlePadding, + subTitlePadding: subTitlePadding ?? _subTitlePadding, + errorPadding: errorPadding ?? _errorPadding, + disableTextStyle: disableTextStyle ?? _disableTextStyle, + tipsTextStyle: tipsTextStyle ?? _tipsTextStyle, + headTitleTextStyle: headTitleTextStyle ?? _headTitleTextStyle, + optionTextStyle: optionTextStyle ?? _optionTextStyle, optionSelectedTextStyle: - optionSelectedTextStyle ?? this.optionSelectedTextStyle, + optionSelectedTextStyle ?? _optionSelectedTextStyle, ); } BrnFormItemConfig merge(BrnFormItemConfig? other) { if (other == null) return this; return copyWith( - titleTextStyle: - titleTextStyle?.merge(other.titleTextStyle) ?? other.titleTextStyle, - subTitleTextStyle: subTitleTextStyle?.merge(other.subTitleTextStyle) ?? - other.subTitleTextStyle, - errorTextStyle: - errorTextStyle?.merge(other.errorTextStyle) ?? other.errorTextStyle, - hintTextStyle: - hintTextStyle?.merge(other.hintTextStyle) ?? other.hintTextStyle, - contentTextStyle: contentTextStyle?.merge(other.contentTextStyle) ?? - other.contentTextStyle, - formPadding: other.formPadding, - titlePaddingSm: other.titlePaddingSm, - titlePaddingLg: other.titlePaddingLg, - optionsMiddlePadding: other.optionsMiddlePadding, - subTitlePadding: other.subTitlePadding, - errorPadding: other.errorPadding, - disableTextStyle: disableTextStyle?.merge(other.disableTextStyle) ?? - other.disableTextStyle, - tipsTextStyle: - tipsTextStyle?.merge(other.tipsTextStyle) ?? other.tipsTextStyle, - headTitleTextStyle: headTitleTextStyle?.merge(other.headTitleTextStyle) ?? - other.headTitleTextStyle, - optionTextStyle: optionTextStyle?.merge(other.optionTextStyle) ?? - other.optionTextStyle, + titleTextStyle: titleTextStyle.merge(other._titleTextStyle), + subTitleTextStyle: subTitleTextStyle.merge(other._subTitleTextStyle), + errorTextStyle: errorTextStyle.merge(other._errorTextStyle), + hintTextStyle: hintTextStyle.merge(other._hintTextStyle), + contentTextStyle: contentTextStyle.merge(other._contentTextStyle), + formPadding: other._formPadding, + titlePaddingSm: other._titlePaddingSm, + titlePaddingLg: other._titlePaddingLg, + optionsMiddlePadding: other._optionsMiddlePadding, + subTitlePadding: other._subTitlePadding, + errorPadding: other._errorPadding, + disableTextStyle: disableTextStyle.merge(other._disableTextStyle), + tipsTextStyle: tipsTextStyle.merge(other._tipsTextStyle), + headTitleTextStyle: headTitleTextStyle.merge(other._headTitleTextStyle), + optionTextStyle: optionTextStyle.merge(other._optionTextStyle), optionSelectedTextStyle: - optionSelectedTextStyle?.merge(other.optionSelectedTextStyle) ?? - other.optionSelectedTextStyle, + optionSelectedTextStyle.merge(other._optionSelectedTextStyle), ); } } diff --git a/lib/src/theme/configs/brn_gallery_detail_config.dart b/lib/src/theme/configs/brn_gallery_detail_config.dart index 2dcbd9cb..b7155350 100644 --- a/lib/src/theme/configs/brn_gallery_detail_config.dart +++ b/lib/src/theme/configs/brn_gallery_detail_config.dart @@ -1,5 +1,6 @@ import 'package:bruno/src/components/navbar/brn_appbar_theme.dart'; import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -10,86 +11,73 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { /// 遵循全局配置 /// 默认为 [BrnDefaultConfigUtils.defaultGalleryDetailConfig] BrnGalleryDetailConfig({ - this.appbarTitleStyle, - this.appbarActionStyle, - this.appbarBackgroundColor, - this.appbarBrightness, - this.tabBarUnSelectedLabelStyle, - this.tabBarLabelStyle, - this.tabBarBackgroundColor, - this.pageBackgroundColor, - this.bottomBackgroundColor, - this.titleStyle, - this.contentStyle, - this.actionStyle, - this.iconColor, + BrnTextStyle? appbarTitleStyle, + BrnTextStyle? appbarActionStyle, + Color? appbarBackgroundColor, + Brightness? appbarBrightness, + BrnTextStyle? tabBarUnSelectedLabelStyle, + BrnTextStyle? tabBarLabelStyle, + Color? tabBarBackgroundColor, + Color? pageBackgroundColor, + Color? bottomBackgroundColor, + BrnTextStyle? titleStyle, + BrnTextStyle? contentStyle, + BrnTextStyle? actionStyle, + Color? iconColor, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _appbarTitleStyle = appbarTitleStyle, + _appbarActionStyle = appbarActionStyle, + _appbarBackgroundColor = appbarBackgroundColor, + _appbarBrightness = appbarBrightness, + _tabBarUnSelectedLabelStyle = tabBarUnSelectedLabelStyle, + _tabBarLabelStyle = tabBarLabelStyle, + _tabBarBackgroundColor = tabBarBackgroundColor, + _pageBackgroundColor = pageBackgroundColor, + _bottomBackgroundColor = bottomBackgroundColor, + _titleStyle = titleStyle, + _contentStyle = contentStyle, + _actionStyle = actionStyle, + _iconColor = iconColor, + super(configId: configId); /// 黑色主题 BrnGalleryDetailConfig.dark({ - this.appbarTitleStyle, - this.appbarActionStyle, - this.appbarBackgroundColor, - this.appbarBrightness, - this.tabBarUnSelectedLabelStyle, - this.tabBarLabelStyle, - this.tabBarBackgroundColor, - this.pageBackgroundColor, - this.bottomBackgroundColor, - this.titleStyle, - this.contentStyle, - this.actionStyle, - this.iconColor, String configId = GLOBAL_CONFIG_ID, }) : super(configId: configId) { - appbarTitleStyle = BrnTextStyle(color: commonConfig.colorTextBaseInverse); - appbarActionStyle = BrnTextStyle(color: BrnAppBarTheme.lightTextColor); - appbarBackgroundColor = Colors.black; - appbarBrightness = Brightness.dark; - tabBarUnSelectedLabelStyle = BrnTextStyle(color: Color(0XFFCCCCCC)); - tabBarLabelStyle = BrnTextStyle(color: commonConfig.colorTextBaseInverse); - tabBarBackgroundColor = Colors.black; - pageBackgroundColor = Colors.black; - bottomBackgroundColor = Color(0X88000000); - titleStyle = BrnTextStyle(color: commonConfig.colorTextBaseInverse); - contentStyle = BrnTextStyle(color: Color(0xFFCCCCCC)); - actionStyle = BrnTextStyle(color: commonConfig.colorTextBaseInverse); - iconColor = Colors.white; + _appbarTitleStyle = BrnTextStyle(color: commonConfig.colorTextBaseInverse); + _appbarActionStyle = BrnTextStyle(color: BrnAppBarTheme.lightTextColor); + _appbarBackgroundColor = Colors.black; + _appbarBrightness = Brightness.dark; + _tabBarUnSelectedLabelStyle = BrnTextStyle(color: Color(0XFFCCCCCC)); + _tabBarLabelStyle = BrnTextStyle(color: commonConfig.colorTextBaseInverse); + _tabBarBackgroundColor = Colors.black; + _pageBackgroundColor = Colors.black; + _bottomBackgroundColor = Color(0X88000000); + _titleStyle = BrnTextStyle(color: commonConfig.colorTextBaseInverse); + _contentStyle = BrnTextStyle(color: Color(0xFFCCCCCC)); + _actionStyle = BrnTextStyle(color: commonConfig.colorTextBaseInverse); + _iconColor = Colors.white; } /// 白色主题 BrnGalleryDetailConfig.light({ - this.appbarTitleStyle, - this.appbarActionStyle, - this.appbarBackgroundColor, - this.appbarBrightness, - this.tabBarUnSelectedLabelStyle, - this.tabBarLabelStyle, - this.tabBarBackgroundColor, - this.pageBackgroundColor, - this.bottomBackgroundColor, - this.titleStyle, - this.contentStyle, - this.actionStyle, - this.iconColor, String configId = GLOBAL_CONFIG_ID, }) : super(configId: configId) { - appbarTitleStyle = BrnTextStyle(color: commonConfig.colorTextBase); - appbarActionStyle = BrnTextStyle(color: commonConfig.colorTextBase); - appbarBackgroundColor = commonConfig.fillBody; - appbarBrightness = Brightness.light; - tabBarUnSelectedLabelStyle = BrnTextStyle( + _appbarTitleStyle = BrnTextStyle(color: commonConfig.colorTextBase); + _appbarActionStyle = BrnTextStyle(color: commonConfig.colorTextBase); + _appbarBackgroundColor = commonConfig.fillBody; + _appbarBrightness = Brightness.light; + _tabBarUnSelectedLabelStyle = BrnTextStyle( color: commonConfig.colorTextBase, ); - tabBarLabelStyle = BrnTextStyle(color: commonConfig.brandPrimary); - tabBarBackgroundColor = commonConfig.fillBody; - pageBackgroundColor = commonConfig.fillBody; - bottomBackgroundColor = commonConfig.fillBody?.withOpacity(.85); - titleStyle = BrnTextStyle(color: commonConfig.colorTextBase); - contentStyle = BrnTextStyle(color: commonConfig.colorTextBase); - actionStyle = BrnTextStyle(color: commonConfig.colorTextSecondary); - iconColor = commonConfig.colorTextSecondary; + _tabBarLabelStyle = BrnTextStyle(color: commonConfig.brandPrimary); + _tabBarBackgroundColor = commonConfig.fillBody; + _pageBackgroundColor = commonConfig.fillBody; + _bottomBackgroundColor = commonConfig.fillBody.withOpacity(.85); + _titleStyle = BrnTextStyle(color: commonConfig.colorTextBase); + _contentStyle = BrnTextStyle(color: commonConfig.colorTextBase); + _actionStyle = BrnTextStyle(color: commonConfig.colorTextSecondary); + _iconColor = commonConfig.colorTextSecondary; } /// appbar brightness待定 @@ -101,7 +89,7 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? appbarTitleStyle; + BrnTextStyle? _appbarTitleStyle; /// 右侧操作区域文案样式 /// @@ -110,15 +98,15 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { /// fontSize: BrnAppBarTheme.actionFontSize, /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? appbarActionStyle; + BrnTextStyle? _appbarActionStyle; /// appBar 背景色 /// 默认为 Colors.black - Color? appbarBackgroundColor; + Color? _appbarBackgroundColor; /// appbar brightness /// 默认为 [Brightness.dark] - Brightness? appbarBrightness; + Brightness? _appbarBrightness; /// tabBar 标题普通样式 /// @@ -126,7 +114,7 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { /// color: Colors.red, /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? tabBarUnSelectedLabelStyle; + BrnTextStyle? _tabBarUnSelectedLabelStyle; /// tabBar 标题选中样式 /// @@ -135,19 +123,19 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? tabBarLabelStyle; + BrnTextStyle? _tabBarLabelStyle; /// tabBar 背景色 /// 默认为 Colors.black - Color? tabBarBackgroundColor; + Color? _tabBarBackgroundColor; /// 页面 背景色 /// 默认为 Colors.black - Color? pageBackgroundColor; + Color? _pageBackgroundColor; /// 底部内容区域的背景色 /// 默认为 Color(0x88000000) - Color? bottomBackgroundColor; + Color? _bottomBackgroundColor; /// 标题文案样式 /// @@ -156,7 +144,7 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? titleStyle; + BrnTextStyle? _titleStyle; /// 内容文案样式 /// @@ -164,7 +152,7 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { /// color: Color(0xFFCCCCCC), /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? contentStyle; + BrnTextStyle? _contentStyle; /// 右侧展开收起样式 /// @@ -172,11 +160,63 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBaseInverse], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? actionStyle; + BrnTextStyle? _actionStyle; /// icon 颜色 /// 默认为 Colors.white - Color? iconColor; + Color? _iconColor; + + BrnTextStyle get appbarTitleStyle => + _appbarTitleStyle ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.appbarTitleStyle; + + BrnTextStyle get appbarActionStyle => + _appbarActionStyle ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.appbarActionStyle; + + Color get appbarBackgroundColor => + _appbarBackgroundColor ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.appbarBackgroundColor; + + Brightness get appbarBrightness => + _appbarBrightness ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.appbarBrightness; + + BrnTextStyle get tabBarUnSelectedLabelStyle => + _tabBarUnSelectedLabelStyle ?? + BrnDefaultConfigUtils + .defaultGalleryDetailConfig.tabBarUnSelectedLabelStyle; + + BrnTextStyle get tabBarLabelStyle => + _tabBarLabelStyle ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.tabBarLabelStyle; + + Color get tabBarBackgroundColor => + _tabBarBackgroundColor ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.tabBarBackgroundColor; + + Color get pageBackgroundColor => + _pageBackgroundColor ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.pageBackgroundColor; + + Color get bottomBackgroundColor => + _bottomBackgroundColor ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.bottomBackgroundColor; + + BrnTextStyle get titleStyle => + _titleStyle ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.titleStyle; + + BrnTextStyle get contentStyle => + _contentStyle ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.contentStyle; + + BrnTextStyle get actionStyle => + _actionStyle ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.actionStyle; + + Color get iconColor => + _iconColor ?? BrnDefaultConfigUtils.defaultGalleryDetailConfig.iconColor; @override void initThemeConfig( @@ -189,55 +229,55 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { ); /// 用户全局组件配置 - BrnGalleryDetailConfig? galleryDetailConfig = BrnThemeConfigurator.instance + BrnGalleryDetailConfig galleryDetailConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .galleryDetailConfig; - appbarTitleStyle = galleryDetailConfig?.appbarTitleStyle?.merge( + _appbarTitleStyle = galleryDetailConfig.appbarTitleStyle.merge( BrnTextStyle( color: commonConfig.colorTextBaseInverse, fontSize: commonConfig.fontSizeSubHead, - ).merge(appbarTitleStyle), + ).merge(_appbarTitleStyle), ); - appbarActionStyle = galleryDetailConfig?.appbarActionStyle?.merge( - appbarActionStyle, + _appbarActionStyle = galleryDetailConfig.appbarActionStyle.merge( + _appbarActionStyle, ); - appbarBrightness ??= galleryDetailConfig?.appbarBrightness; - appbarBackgroundColor ??= galleryDetailConfig?.appbarBackgroundColor; - tabBarUnSelectedLabelStyle = galleryDetailConfig?.tabBarUnSelectedLabelStyle - ?.merge(BrnTextStyle(fontSize: commonConfig.fontSizeSubHead)) - .merge(tabBarUnSelectedLabelStyle); - tabBarLabelStyle = galleryDetailConfig?.tabBarLabelStyle - ?.merge( + _appbarBrightness ??= galleryDetailConfig.appbarBrightness; + _appbarBackgroundColor ??= galleryDetailConfig.appbarBackgroundColor; + _tabBarUnSelectedLabelStyle = galleryDetailConfig.tabBarUnSelectedLabelStyle + .merge(BrnTextStyle(fontSize: commonConfig.fontSizeSubHead)) + .merge(_tabBarUnSelectedLabelStyle); + _tabBarLabelStyle = galleryDetailConfig.tabBarLabelStyle + .merge( BrnTextStyle( color: commonConfig.colorTextBaseInverse, fontSize: commonConfig.fontSizeSubHead, ), ) - .merge(tabBarLabelStyle); - tabBarBackgroundColor ??= galleryDetailConfig?.tabBarBackgroundColor; - pageBackgroundColor ??= galleryDetailConfig?.pageBackgroundColor; - bottomBackgroundColor ??= galleryDetailConfig?.bottomBackgroundColor; - titleStyle = galleryDetailConfig?.titleStyle - ?.merge( + .merge(_tabBarLabelStyle); + _tabBarBackgroundColor ??= galleryDetailConfig._tabBarBackgroundColor; + _pageBackgroundColor ??= galleryDetailConfig._pageBackgroundColor; + _bottomBackgroundColor ??= galleryDetailConfig._bottomBackgroundColor; + _titleStyle = galleryDetailConfig.titleStyle + .merge( BrnTextStyle( color: commonConfig.colorTextBaseInverse, fontSize: commonConfig.fontSizeHead, ), ) - .merge(titleStyle); - contentStyle = galleryDetailConfig?.contentStyle - ?.merge(BrnTextStyle(fontSize: commonConfig.fontSizeBase)) - .merge(contentStyle); - actionStyle = galleryDetailConfig?.actionStyle - ?.merge( + .merge(_titleStyle); + _contentStyle = galleryDetailConfig.contentStyle + .merge(BrnTextStyle(fontSize: commonConfig.fontSizeBase)) + .merge(_contentStyle); + _actionStyle = galleryDetailConfig.actionStyle + .merge( BrnTextStyle( color: commonConfig.colorTextBaseInverse, fontSize: commonConfig.fontSizeBase, ), ) - .merge(actionStyle); - iconColor ??= galleryDetailConfig?.iconColor; + .merge(_actionStyle); + _iconColor ??= galleryDetailConfig._iconColor; } BrnGalleryDetailConfig copyWith({ @@ -259,48 +299,40 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { Color? iconColor, }) { return BrnGalleryDetailConfig( - appbarTitleStyle: appbarTitleStyle ?? this.appbarTitleStyle, - appbarActionStyle: appbarActionStyle ?? this.appbarActionStyle, - appbarBackgroundColor: - appbarBackgroundColor ?? this.appbarBackgroundColor, - appbarBrightness: appbarBrightness ?? this.appbarBrightness, + appbarTitleStyle: appbarTitleStyle ?? _appbarTitleStyle, + appbarActionStyle: appbarActionStyle ?? _appbarActionStyle, + appbarBackgroundColor: appbarBackgroundColor ?? _appbarBackgroundColor, + appbarBrightness: appbarBrightness ?? _appbarBrightness, tabBarUnSelectedLabelStyle: - tabBarUnSelectedLabelStyle ?? this.tabBarUnSelectedLabelStyle, - tabBarLabelStyle: tabBarLabelStyle ?? this.tabBarLabelStyle, - tabBarBackgroundColor: - tabBarBackgroundColor ?? this.tabBarBackgroundColor, - pageBackgroundColor: pageBackgroundColor ?? this.pageBackgroundColor, - bottomBackgroundColor: - bottomBackgroundColor ?? this.bottomBackgroundColor, - titleStyle: titleStyle ?? this.titleStyle, - contentStyle: contentStyle ?? this.contentStyle, - actionStyle: actionStyle ?? this.actionStyle, - iconColor: iconColor ?? this.iconColor, + tabBarUnSelectedLabelStyle ?? _tabBarUnSelectedLabelStyle, + tabBarLabelStyle: tabBarLabelStyle ?? _tabBarLabelStyle, + tabBarBackgroundColor: tabBarBackgroundColor ?? _tabBarBackgroundColor, + pageBackgroundColor: pageBackgroundColor ?? _pageBackgroundColor, + bottomBackgroundColor: bottomBackgroundColor ?? _bottomBackgroundColor, + titleStyle: titleStyle ?? _titleStyle, + contentStyle: contentStyle ?? _contentStyle, + actionStyle: actionStyle ?? _actionStyle, + iconColor: iconColor ?? _iconColor, ); } BrnGalleryDetailConfig merge(BrnGalleryDetailConfig? other) { if (other == null) return this; return copyWith( - appbarTitleStyle: appbarTitleStyle?.merge(other.appbarTitleStyle) ?? - other.appbarTitleStyle, - appbarActionStyle: appbarActionStyle?.merge(other.appbarActionStyle) ?? - other.appbarActionStyle, - appbarBackgroundColor: other.appbarBackgroundColor, - appbarBrightness: other.appbarBrightness, + appbarTitleStyle: appbarTitleStyle.merge(other._appbarTitleStyle), + appbarActionStyle: appbarActionStyle.merge(other._appbarActionStyle), + appbarBackgroundColor: other._appbarBackgroundColor, + appbarBrightness: other._appbarBrightness, tabBarUnSelectedLabelStyle: - tabBarUnSelectedLabelStyle?.merge(other.tabBarUnSelectedLabelStyle) ?? - other.tabBarUnSelectedLabelStyle, - tabBarLabelStyle: tabBarLabelStyle?.merge(other.tabBarLabelStyle) ?? - other.tabBarLabelStyle, - tabBarBackgroundColor: other.tabBarBackgroundColor, - pageBackgroundColor: other.pageBackgroundColor, - bottomBackgroundColor: other.bottomBackgroundColor, - titleStyle: titleStyle?.merge(other.titleStyle) ?? other.titleStyle, - contentStyle: - contentStyle?.merge(other.contentStyle) ?? other.contentStyle, - actionStyle: actionStyle?.merge(other.actionStyle) ?? other.actionStyle, - iconColor: other.iconColor, + tabBarUnSelectedLabelStyle.merge(other._tabBarUnSelectedLabelStyle), + tabBarLabelStyle: tabBarLabelStyle.merge(other._tabBarLabelStyle), + tabBarBackgroundColor: other._tabBarBackgroundColor, + pageBackgroundColor: other._pageBackgroundColor, + bottomBackgroundColor: other._bottomBackgroundColor, + titleStyle: titleStyle.merge(other._titleStyle), + contentStyle: contentStyle.merge(other._contentStyle), + actionStyle: actionStyle.merge(other._actionStyle), + iconColor: other._iconColor, ); } } diff --git a/lib/src/theme/configs/brn_pair_info_config.dart b/lib/src/theme/configs/brn_pair_info_config.dart index 50b68802..987dfb67 100644 --- a/lib/src/theme/configs/brn_pair_info_config.dart +++ b/lib/src/theme/configs/brn_pair_info_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -8,19 +9,24 @@ class BrnPairInfoTableConfig extends BrnBaseConfig { /// 遵循外部主题配置 /// 默认为 [BrnDefaultConfigUtils.defaultPairInfoTableConfig] BrnPairInfoTableConfig({ - this.rowSpacing, - this.itemSpacing, - this.keyTextStyle, - this.valueTextStyle, - this.linkTextStyle, + double? rowSpacing, + double? itemSpacing, + BrnTextStyle? keyTextStyle, + BrnTextStyle? valueTextStyle, + BrnTextStyle? linkTextStyle, String configId: GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _rowSpacing = rowSpacing, + _itemSpacing = itemSpacing, + _keyTextStyle = keyTextStyle, + _valueTextStyle = valueTextStyle, + _linkTextStyle = linkTextStyle, + super(configId: configId); /// 行间距 纵向 - double? rowSpacing; + double? _rowSpacing; /// BrnInfoModal 属性配置 行间距 - double? itemSpacing; + double? _itemSpacing; /// BrnInfoModal key文字样式 /// @@ -29,7 +35,7 @@ class BrnPairInfoTableConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeBase], /// fontWeight: FontWeight.w400, /// ) - BrnTextStyle? keyTextStyle; + BrnTextStyle? _keyTextStyle; /// BrnInfoModal value文字样式 /// @@ -38,7 +44,7 @@ class BrnPairInfoTableConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeBase], /// fontWeight: FontWeight.w400, /// ) - BrnTextStyle? valueTextStyle; + BrnTextStyle? _valueTextStyle; /// BrnInfoModal 链接文字样式 /// @@ -47,7 +53,27 @@ class BrnPairInfoTableConfig extends BrnBaseConfig { /// fontWeight: FontWeight.w400, /// fontSize: [BrnCommonConfig.fontSizeBase] /// ) - BrnTextStyle? linkTextStyle; + BrnTextStyle? _linkTextStyle; + + double get rowSpacing => + _rowSpacing ?? + BrnDefaultConfigUtils.defaultPairInfoTableConfig.rowSpacing; + + double get itemSpacing => + _itemSpacing ?? + BrnDefaultConfigUtils.defaultPairInfoTableConfig.itemSpacing; + + BrnTextStyle get keyTextStyle => + _keyTextStyle ?? + BrnDefaultConfigUtils.defaultPairInfoTableConfig.keyTextStyle; + + BrnTextStyle get valueTextStyle => + _valueTextStyle ?? + BrnDefaultConfigUtils.defaultPairInfoTableConfig.valueTextStyle; + + BrnTextStyle get linkTextStyle => + _linkTextStyle ?? + BrnDefaultConfigUtils.defaultPairInfoTableConfig.linkTextStyle; @override void initThemeConfig( @@ -60,30 +86,30 @@ class BrnPairInfoTableConfig extends BrnBaseConfig { ); /// 用户全局组件配置 - BrnPairInfoTableConfig? pairInfoTableConfig = BrnThemeConfigurator.instance + BrnPairInfoTableConfig pairInfoTableConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .pairInfoTableConfig; - rowSpacing ??= pairInfoTableConfig?.rowSpacing; - keyTextStyle = pairInfoTableConfig?.keyTextStyle?.merge( + _rowSpacing ??= pairInfoTableConfig._rowSpacing; + _keyTextStyle = pairInfoTableConfig.keyTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextSecondary, fontSize: commonConfig.fontSizeBase, - ).merge(keyTextStyle), + ).merge(_keyTextStyle), ); - valueTextStyle = pairInfoTableConfig?.valueTextStyle?.merge( + _valueTextStyle = pairInfoTableConfig.valueTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeBase, - ).merge(valueTextStyle), + ).merge(_valueTextStyle), ); - linkTextStyle = pairInfoTableConfig?.linkTextStyle?.merge( + _linkTextStyle = pairInfoTableConfig.linkTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeBase, - ).merge(linkTextStyle), + ).merge(_linkTextStyle), ); - itemSpacing ??= pairInfoTableConfig?.itemSpacing; + _itemSpacing ??= pairInfoTableConfig._itemSpacing; } BrnPairInfoTableConfig copyWith({ @@ -94,25 +120,22 @@ class BrnPairInfoTableConfig extends BrnBaseConfig { BrnTextStyle? linkTextStyle, }) { return BrnPairInfoTableConfig( - rowSpacing: rowSpacing ?? this.rowSpacing, - itemSpacing: itemSpacing ?? this.itemSpacing, - keyTextStyle: keyTextStyle ?? this.keyTextStyle, - valueTextStyle: valueTextStyle ?? this.valueTextStyle, - linkTextStyle: linkTextStyle ?? this.linkTextStyle, + rowSpacing: rowSpacing ?? _rowSpacing, + itemSpacing: itemSpacing ?? _itemSpacing, + keyTextStyle: keyTextStyle ?? _keyTextStyle, + valueTextStyle: valueTextStyle ?? _valueTextStyle, + linkTextStyle: linkTextStyle ?? _linkTextStyle, ); } BrnPairInfoTableConfig merge(BrnPairInfoTableConfig? other) { if (other == null) return this; return copyWith( - rowSpacing: other.rowSpacing, - itemSpacing: other.itemSpacing, - keyTextStyle: - keyTextStyle?.merge(other.keyTextStyle) ?? other.keyTextStyle, - valueTextStyle: - valueTextStyle?.merge(other.valueTextStyle) ?? other.valueTextStyle, - linkTextStyle: - linkTextStyle?.merge(other.linkTextStyle) ?? other.linkTextStyle, + rowSpacing: other._rowSpacing, + itemSpacing: other._itemSpacing, + keyTextStyle: keyTextStyle.merge(other._keyTextStyle), + valueTextStyle: valueTextStyle.merge(other._valueTextStyle), + linkTextStyle: linkTextStyle.merge(other._linkTextStyle), ); } } @@ -121,23 +144,29 @@ class BrnPairRichInfoGridConfig extends BrnBaseConfig { /// 遵循外部主题配置 /// 默认为 [BrnDefaultConfigUtils.defaultPairRichInfoGridConfig] BrnPairRichInfoGridConfig({ - this.rowSpacing, - this.itemSpacing, - this.itemHeight, - this.keyTextStyle, - this.valueTextStyle, - this.linkTextStyle, + double? rowSpacing, + double? itemSpacing, + double? itemHeight, + BrnTextStyle? keyTextStyle, + BrnTextStyle? valueTextStyle, + BrnTextStyle? linkTextStyle, String configId: GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _rowSpacing = rowSpacing, + _itemSpacing = itemSpacing, + _itemHeight = itemHeight, + _keyTextStyle = keyTextStyle, + _valueTextStyle = valueTextStyle, + _linkTextStyle = linkTextStyle, + super(configId: configId); /// 行间距 纵向 - double? rowSpacing; + double? _rowSpacing; /// 元素间距 横向 - double? itemSpacing; + double? _itemSpacing; /// 元素高度 - double? itemHeight; + double? _itemHeight; /// key文字样式 /// @@ -146,7 +175,7 @@ class BrnPairRichInfoGridConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeBase], /// fontWeight: FontWeight.w400, /// ) - BrnTextStyle? keyTextStyle; + BrnTextStyle? _keyTextStyle; /// value文字样式 /// @@ -155,7 +184,7 @@ class BrnPairRichInfoGridConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? valueTextStyle; + BrnTextStyle? _valueTextStyle; /// 链接文字样式 /// @@ -164,7 +193,31 @@ class BrnPairRichInfoGridConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.brandPrimary], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? linkTextStyle; + BrnTextStyle? _linkTextStyle; + + double get rowSpacing => + _rowSpacing ?? + BrnDefaultConfigUtils.defaultPairRichInfoGridConfig.rowSpacing; + + double get itemSpacing => + _itemSpacing ?? + BrnDefaultConfigUtils.defaultPairRichInfoGridConfig.itemSpacing; + + double get itemHeight => + _itemHeight ?? + BrnDefaultConfigUtils.defaultPairRichInfoGridConfig.itemHeight; + + BrnTextStyle get keyTextStyle => + _keyTextStyle ?? + BrnDefaultConfigUtils.defaultPairRichInfoGridConfig.keyTextStyle; + + BrnTextStyle get valueTextStyle => + _valueTextStyle ?? + BrnDefaultConfigUtils.defaultPairRichInfoGridConfig.valueTextStyle; + + BrnTextStyle get linkTextStyle => + _linkTextStyle ?? + BrnDefaultConfigUtils.defaultPairRichInfoGridConfig.linkTextStyle; @override void initThemeConfig( @@ -177,31 +230,31 @@ class BrnPairRichInfoGridConfig extends BrnBaseConfig { ); /// 用户全局组件配置 - BrnPairRichInfoGridConfig? pairRichInfoGridConfig = BrnThemeConfigurator + BrnPairRichInfoGridConfig pairRichInfoGridConfig = BrnThemeConfigurator .instance .getConfig(configId: configId) .pairRichInfoGridConfig; - rowSpacing ??= pairRichInfoGridConfig?.rowSpacing; - itemSpacing ??= pairRichInfoGridConfig?.itemSpacing; - itemHeight ??= pairRichInfoGridConfig?.itemHeight; - keyTextStyle = pairRichInfoGridConfig?.keyTextStyle?.merge( + _rowSpacing ??= pairRichInfoGridConfig._rowSpacing; + _itemSpacing ??= pairRichInfoGridConfig._itemSpacing; + _itemHeight ??= pairRichInfoGridConfig._itemHeight; + _keyTextStyle = pairRichInfoGridConfig.keyTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextSecondary, fontSize: commonConfig.fontSizeBase, - ).merge(keyTextStyle), + ).merge(_keyTextStyle), ); - valueTextStyle = pairRichInfoGridConfig?.valueTextStyle?.merge( + _valueTextStyle = pairRichInfoGridConfig.valueTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeBase, - ).merge(valueTextStyle), + ).merge(_valueTextStyle), ); - linkTextStyle = pairRichInfoGridConfig?.linkTextStyle?.merge( + _linkTextStyle = pairRichInfoGridConfig.linkTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeBase, - ).merge(linkTextStyle), + ).merge(_linkTextStyle), ); } @@ -215,27 +268,24 @@ class BrnPairRichInfoGridConfig extends BrnBaseConfig { BrnTextStyle? titleTextsStyle, }) { return BrnPairRichInfoGridConfig( - rowSpacing: rowSpacing ?? this.rowSpacing, - itemSpacing: itemSpacing ?? this.itemSpacing, - itemHeight: itemHeight ?? this.itemHeight, - keyTextStyle: keyTextStyle ?? this.keyTextStyle, - valueTextStyle: valueTextStyle ?? this.valueTextStyle, - linkTextStyle: linkTextStyle ?? this.linkTextStyle, + rowSpacing: rowSpacing ?? _rowSpacing, + itemSpacing: itemSpacing ?? _itemSpacing, + itemHeight: itemHeight ?? _itemHeight, + keyTextStyle: keyTextStyle ?? _keyTextStyle, + valueTextStyle: valueTextStyle ?? _valueTextStyle, + linkTextStyle: linkTextStyle ?? _linkTextStyle, ); } BrnPairRichInfoGridConfig merge(BrnPairRichInfoGridConfig? other) { if (other == null) return this; return copyWith( - rowSpacing: other.rowSpacing, - itemSpacing: other.itemSpacing, - itemHeight: other.itemHeight, - keyTextStyle: - keyTextStyle?.merge(other.keyTextStyle) ?? other.keyTextStyle, - valueTextStyle: - valueTextStyle?.merge(other.valueTextStyle) ?? other.valueTextStyle, - linkTextStyle: - linkTextStyle?.merge(other.linkTextStyle) ?? other.linkTextStyle, + rowSpacing: other._rowSpacing, + itemSpacing: other._itemSpacing, + itemHeight: other._itemHeight, + keyTextStyle: keyTextStyle.merge(other._keyTextStyle), + valueTextStyle: valueTextStyle.merge(other._valueTextStyle), + linkTextStyle: linkTextStyle.merge(other._linkTextStyle), ); } } diff --git a/lib/src/theme/configs/brn_picker_config.dart b/lib/src/theme/configs/brn_picker_config.dart index ec23f606..92b903ba 100644 --- a/lib/src/theme/configs/brn_picker_config.dart +++ b/lib/src/theme/configs/brn_picker_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -9,23 +10,34 @@ class BrnPickerConfig extends BrnBaseConfig { /// 遵循外部主题配置 /// 默认为 [BrnDefaultConfigUtils.defaultPickerConfig] BrnPickerConfig({ - this.backgroundColor, - this.cancelTextStyle, - this.confirmTextStyle, - this.titleTextStyle, - this.pickerHeight, - this.titleHeight, - this.itemHeight, - this.itemTextStyle, - this.itemTextSelectedStyle, - this.dividerColor, - this.cornerRadius, + Color? backgroundColor, + BrnTextStyle? cancelTextStyle, + BrnTextStyle? confirmTextStyle, + BrnTextStyle? titleTextStyle, + double? pickerHeight, + double? titleHeight, + double? itemHeight, + BrnTextStyle? itemTextStyle, + BrnTextStyle? itemTextSelectedStyle, + Color? dividerColor, + double? cornerRadius, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _backgroundColor = backgroundColor, + _cancelTextStyle = cancelTextStyle, + _confirmTextStyle = confirmTextStyle, + _titleTextStyle = titleTextStyle, + _pickerHeight = pickerHeight, + _titleHeight = titleHeight, + _itemHeight = itemHeight, + _itemTextStyle = itemTextStyle, + _itemTextSelectedStyle = itemTextSelectedStyle, + _dividerColor = dividerColor, + _cornerRadius = cornerRadius, + super(configId: configId); /// 日期选择器的背景色 /// 默认为 [PICKER_BACKGROUND_COLOR] - Color? backgroundColor; + Color? _backgroundColor; /// 取消文字的样式 /// @@ -33,7 +45,7 @@ class BrnPickerConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? cancelTextStyle; + BrnTextStyle? _cancelTextStyle; /// 确认文字的样式 /// @@ -41,7 +53,7 @@ class BrnPickerConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.brandPrimary], /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? confirmTextStyle; + BrnTextStyle? _confirmTextStyle; /// 标题文字的样式 /// @@ -50,19 +62,19 @@ class BrnPickerConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWidget:FontWeight.w600, /// ) - BrnTextStyle? titleTextStyle; + BrnTextStyle? _titleTextStyle; /// 日期选择器的高度 /// 默认为 [PICKER_HEIGHT] - double? pickerHeight; + double? _pickerHeight; /// 日期选择器标题的高度 /// 默认为 [PICKER_TITLE_HEIGHT] - double? titleHeight; + double? _titleHeight; /// 日期选择器列表的高度 /// 默认为 [PICKER_ITEM_HEIGHT] - double? itemHeight; + double? _itemHeight; /// 日期选择器列表的文字样式 /// @@ -70,7 +82,7 @@ class BrnPickerConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeHead], /// ) - BrnTextStyle? itemTextStyle; + BrnTextStyle? _itemTextStyle; /// 日期选择器列表选中的文字样式 /// @@ -79,10 +91,48 @@ class BrnPickerConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeHead], /// fontWidget: FontWeight.w600, /// ) - BrnTextStyle? itemTextSelectedStyle; + BrnTextStyle? _itemTextSelectedStyle; + + Color? _dividerColor; + double? _cornerRadius; - Color? dividerColor; - double? cornerRadius; + Color get backgroundColor => + _backgroundColor ?? + BrnDefaultConfigUtils.defaultPickerConfig.backgroundColor; + + BrnTextStyle get cancelTextStyle => + _cancelTextStyle ?? + BrnDefaultConfigUtils.defaultPickerConfig.cancelTextStyle; + + BrnTextStyle get confirmTextStyle => + _confirmTextStyle ?? + BrnDefaultConfigUtils.defaultPickerConfig.confirmTextStyle; + + BrnTextStyle get titleTextStyle => + _titleTextStyle ?? + BrnDefaultConfigUtils.defaultPickerConfig.titleTextStyle; + + double get pickerHeight => + _pickerHeight ?? BrnDefaultConfigUtils.defaultPickerConfig.pickerHeight; + + double get titleHeight => + _titleHeight ?? BrnDefaultConfigUtils.defaultPickerConfig.titleHeight; + + double get itemHeight => + _itemHeight ?? BrnDefaultConfigUtils.defaultPickerConfig.itemHeight; + + BrnTextStyle get itemTextStyle => + _itemTextStyle ?? BrnDefaultConfigUtils.defaultPickerConfig.itemTextStyle; + + BrnTextStyle get itemTextSelectedStyle => + _itemTextSelectedStyle ?? + BrnDefaultConfigUtils.defaultPickerConfig.itemTextSelectedStyle; + + Color get dividerColor => + _dividerColor ?? BrnDefaultConfigUtils.defaultPickerConfig.dividerColor; + + double get cornerRadius => + _cornerRadius ?? BrnDefaultConfigUtils.defaultPickerConfig.cornerRadius; @override void initThemeConfig( @@ -95,47 +145,47 @@ class BrnPickerConfig extends BrnBaseConfig { ); /// 用户全局组件配置 - BrnPickerConfig? pickerConfig = BrnThemeConfigurator.instance + BrnPickerConfig pickerConfig = BrnThemeConfigurator.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( + _backgroundColor ??= pickerConfig.backgroundColor; + _pickerHeight ??= pickerConfig.pickerHeight; + _titleHeight ??= pickerConfig.titleHeight; + _itemHeight ??= pickerConfig.itemHeight; + _dividerColor ??= pickerConfig.dividerColor; + _cornerRadius ??= pickerConfig.cornerRadius; + _titleTextStyle = pickerConfig.titleTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(titleTextStyle), + ).merge(_titleTextStyle), ); - cancelTextStyle = pickerConfig?.cancelTextStyle - ?.merge( + _cancelTextStyle = pickerConfig.cancelTextStyle + .merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, ), ) - .merge(cancelTextStyle); - confirmTextStyle = pickerConfig?.confirmTextStyle?.merge( + .merge(_cancelTextStyle); + _confirmTextStyle = pickerConfig.confirmTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeSubHead, - ).merge(confirmTextStyle), + ).merge(_confirmTextStyle), ); - itemTextStyle = pickerConfig?.itemTextStyle?.merge( + _itemTextStyle = pickerConfig.itemTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeHead, - ).merge(itemTextStyle), + ).merge(_itemTextStyle), ); - itemTextSelectedStyle = pickerConfig?.itemTextSelectedStyle?.merge( + _itemTextSelectedStyle = pickerConfig.itemTextSelectedStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeHead, - ).merge(itemTextSelectedStyle), + ).merge(_itemTextSelectedStyle), ); } @@ -153,41 +203,35 @@ class BrnPickerConfig extends BrnBaseConfig { double? cornerRadius, }) { return BrnPickerConfig( - backgroundColor: backgroundColor ?? this.backgroundColor, - cancelTextStyle: cancelTextStyle ?? this.cancelTextStyle, - confirmTextStyle: confirmTextStyle ?? this.confirmTextStyle, - titleTextStyle: titleTextStyle ?? this.titleTextStyle, - pickerHeight: pickerHeight ?? this.pickerHeight, - titleHeight: titleHeight ?? this.titleHeight, - itemHeight: itemHeight ?? this.itemHeight, - itemTextStyle: itemTextStyle ?? this.itemTextStyle, - itemTextSelectedStyle: - itemTextSelectedStyle ?? this.itemTextSelectedStyle, - dividerColor: dividerColor ?? this.dividerColor, - cornerRadius: cornerRadius ?? this.cornerRadius, + backgroundColor: backgroundColor ?? _backgroundColor, + cancelTextStyle: cancelTextStyle ?? _cancelTextStyle, + confirmTextStyle: confirmTextStyle ?? _confirmTextStyle, + titleTextStyle: titleTextStyle ?? _titleTextStyle, + pickerHeight: pickerHeight ?? _pickerHeight, + titleHeight: titleHeight ?? _titleHeight, + itemHeight: itemHeight ?? _itemHeight, + itemTextStyle: itemTextStyle ?? _itemTextStyle, + itemTextSelectedStyle: itemTextSelectedStyle ?? _itemTextSelectedStyle, + dividerColor: dividerColor ?? _dividerColor, + cornerRadius: cornerRadius ?? _cornerRadius, ); } BrnPickerConfig merge(BrnPickerConfig? other) { if (other == null) return this; return copyWith( - backgroundColor: other.backgroundColor, - cancelTextStyle: cancelTextStyle?.merge(other.cancelTextStyle) ?? - other.cancelTextStyle, - confirmTextStyle: confirmTextStyle?.merge(other.confirmTextStyle) ?? - other.confirmTextStyle, - titleTextStyle: - titleTextStyle?.merge(other.titleTextStyle) ?? other.titleTextStyle, - pickerHeight: other.pickerHeight, - titleHeight: other.titleHeight, - itemHeight: other.itemHeight, - itemTextStyle: - itemTextStyle?.merge(other.itemTextStyle) ?? other.itemTextStyle, + backgroundColor: other._backgroundColor, + cancelTextStyle: cancelTextStyle.merge(other._cancelTextStyle), + confirmTextStyle: confirmTextStyle.merge(other._confirmTextStyle), + titleTextStyle: titleTextStyle.merge(other._titleTextStyle), + pickerHeight: other._pickerHeight, + titleHeight: other._titleHeight, + itemHeight: other._itemHeight, + itemTextStyle: itemTextStyle.merge(other._itemTextStyle), itemTextSelectedStyle: - itemTextSelectedStyle?.merge(other.itemTextSelectedStyle) ?? - other.itemTextSelectedStyle, - dividerColor: other.dividerColor, - cornerRadius: other.cornerRadius, + itemTextSelectedStyle.merge(other._itemTextSelectedStyle), + dividerColor: other._dividerColor, + cornerRadius: other._cornerRadius, ); } } diff --git a/lib/src/theme/configs/brn_selection_config.dart b/lib/src/theme/configs/brn_selection_config.dart index 25f7b8cd..1dc0019b 100644 --- a/lib/src/theme/configs/brn_selection_config.dart +++ b/lib/src/theme/configs/brn_selection_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -9,34 +10,60 @@ class BrnSelectionConfig extends BrnBaseConfig { /// 遵循外部主题配置 /// 默认为 [BrnDefaultConfigUtils.defaultSelectionConfig] BrnSelectionConfig({ - this.menuNormalTextStyle, - this.menuSelectedTextStyle, - this.tagNormalTextStyle, - this.tagSelectedTextStyle, - this.tagRadius, - this.tagNormalBackgroundColor, - this.tagSelectedBackgroundColor, - this.hintTextStyle, - this.rangeTitleTextStyle, - this.inputTextStyle, - this.itemNormalTextStyle, - this.itemSelectedTextStyle, - this.itemBoldTextStyle, - this.deepNormalBgColor, - this.deepSelectBgColor, - this.middleNormalBgColor, - this.middleSelectBgColor, - this.lightNormalBgColor, - this.lightSelectBgColor, - this.resetTextStyle, - this.titleForMoreTextStyle, - this.optionTextStyle, - this.moreTextStyle, - this.flayerNormalTextStyle, - this.flayerSelectedTextStyle, - this.flayerBoldTextStyle, + BrnTextStyle? menuNormalTextStyle, + BrnTextStyle? menuSelectedTextStyle, + BrnTextStyle? tagNormalTextStyle, + BrnTextStyle? tagSelectedTextStyle, + double? tagRadius, + Color? tagNormalBackgroundColor, + Color? tagSelectedBackgroundColor, + BrnTextStyle? hintTextStyle, + BrnTextStyle? rangeTitleTextStyle, + BrnTextStyle? inputTextStyle, + BrnTextStyle? itemNormalTextStyle, + BrnTextStyle? itemSelectedTextStyle, + BrnTextStyle? itemBoldTextStyle, + Color? deepNormalBgColor, + Color? deepSelectBgColor, + Color? middleNormalBgColor, + Color? middleSelectBgColor, + Color? lightNormalBgColor, + Color? lightSelectBgColor, + BrnTextStyle? resetTextStyle, + BrnTextStyle? titleForMoreTextStyle, + BrnTextStyle? optionTextStyle, + BrnTextStyle? moreTextStyle, + BrnTextStyle? flayerNormalTextStyle, + BrnTextStyle? flayerSelectedTextStyle, + BrnTextStyle? flayerBoldTextStyle, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _menuNormalTextStyle = menuNormalTextStyle, + _menuSelectedTextStyle = menuSelectedTextStyle, + _tagNormalTextStyle = tagNormalTextStyle, + _tagSelectedTextStyle = tagSelectedTextStyle, + _tagRadius = tagRadius, + _tagNormalBackgroundColor = tagNormalBackgroundColor, + _tagSelectedBackgroundColor = tagSelectedBackgroundColor, + _hintTextStyle = hintTextStyle, + _rangeTitleTextStyle = rangeTitleTextStyle, + _inputTextStyle = inputTextStyle, + _itemNormalTextStyle = itemNormalTextStyle, + _itemSelectedTextStyle = itemSelectedTextStyle, + _itemBoldTextStyle = itemBoldTextStyle, + _deepNormalBgColor = deepNormalBgColor, + _deepSelectBgColor = deepSelectBgColor, + _middleNormalBgColor = middleNormalBgColor, + _middleSelectBgColor = middleSelectBgColor, + _lightNormalBgColor = lightNormalBgColor, + _lightSelectBgColor = lightSelectBgColor, + _resetTextStyle = resetTextStyle, + _titleForMoreTextStyle = titleForMoreTextStyle, + _optionTextStyle = optionTextStyle, + _moreTextStyle = moreTextStyle, + _flayerNormalTextStyle = flayerNormalTextStyle, + _flayerSelectedTextStyle = flayerSelectedTextStyle, + _flayerBoldTextStyle = flayerBoldTextStyle, + super(configId: configId); /// menu 正常文本样式 /// @@ -45,7 +72,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeBase], /// fontWeight: FontWeight.normal, /// ) - BrnTextStyle? menuNormalTextStyle; + BrnTextStyle? _menuNormalTextStyle; /// menu 选中文本样式 /// @@ -54,7 +81,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeBase], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? menuSelectedTextStyle; + BrnTextStyle? _menuSelectedTextStyle; /// tag 正常文本样式 /// @@ -63,7 +90,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeCaption], /// fontWeight: FontWeight.w400, /// ) - BrnTextStyle? tagNormalTextStyle; + BrnTextStyle? _tagNormalTextStyle; /// tag 选中文本样式 /// @@ -72,19 +99,19 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeCaption], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? tagSelectedTextStyle; + BrnTextStyle? _tagSelectedTextStyle; /// tag 圆角 /// 默认为 [BrnCommonConfig.radiusSm] - double? tagRadius; + double? _tagRadius; /// tag 正常背景色 /// 默认为 [BrnCommonConfig.fillBody] - Color? tagNormalBackgroundColor; + Color? _tagNormalBackgroundColor; /// tag 选中背景色 /// 默认为 [BrnCommonConfig.brandPrimary].withOpacity(0.12) - Color? tagSelectedBackgroundColor; + Color? _tagSelectedBackgroundColor; /// 输入选项标题文本样式 /// @@ -93,7 +120,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? rangeTitleTextStyle; + BrnTextStyle? _rangeTitleTextStyle; /// 输入提示文本样式 /// @@ -101,7 +128,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextHint], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? hintTextStyle; + BrnTextStyle? _hintTextStyle; /// 输入框默认文本样式 /// @@ -109,7 +136,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? inputTextStyle; + BrnTextStyle? _inputTextStyle; /// item 正常字体样式 /// @@ -117,7 +144,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? itemNormalTextStyle; + BrnTextStyle? _itemNormalTextStyle; /// item 选中文本样式 /// @@ -126,7 +153,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeBase], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? itemSelectedTextStyle; + BrnTextStyle? _itemSelectedTextStyle; /// item 仅加粗样式 /// @@ -135,31 +162,31 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeBase], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? itemBoldTextStyle; + BrnTextStyle? _itemBoldTextStyle; /// 三级 item 背景色 /// 默认为 Color(0xFFF0F0F0) - Color? deepNormalBgColor; + Color? _deepNormalBgColor; /// 三级 item 选中背景色 /// 默认为 Color(0xFFF8F8F8) - Color? deepSelectBgColor; + Color? _deepSelectBgColor; /// 二级 item 背景色 /// 默认为 Color(0xFFF8F8F8) - Color? middleNormalBgColor; + Color? _middleNormalBgColor; /// 二级 item 选中背景色 /// 默认为 Colors.white - Color? middleSelectBgColor; + Color? _middleSelectBgColor; /// 一级 item 背景色 /// 默认为 Colors.white - Color? lightNormalBgColor; + Color? _lightNormalBgColor; /// 一级 item 选中背景色 /// 默认为 Colors.white - Color? lightSelectBgColor; + Color? _lightSelectBgColor; /// 重置按钮颜色 /// @@ -167,7 +194,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextImportant], /// fontSize: [BrnCommonConfig.fontSizeCaption] /// ) - BrnTextStyle? resetTextStyle; + BrnTextStyle? _resetTextStyle; /// 更多筛选-标题文本样式 /// @@ -176,7 +203,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeBase], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? titleForMoreTextStyle; + BrnTextStyle? _titleForMoreTextStyle; /// 选项-显示文本 /// @@ -184,7 +211,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.brandPrimary], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? optionTextStyle; + BrnTextStyle? _optionTextStyle; /// 更多文本样式 /// @@ -192,7 +219,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextSecondary], /// fontSize: [BrnCommonConfig.fontSizeCaption], /// ) - BrnTextStyle? moreTextStyle; + BrnTextStyle? _moreTextStyle; /// 跳转二级页-正常文本样式 /// @@ -201,7 +228,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWeight: FontWeight.normal, /// ) - BrnTextStyle? flayerNormalTextStyle; + BrnTextStyle? _flayerNormalTextStyle; /// 跳转二级页-选中文本样式 /// @@ -210,7 +237,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? flayerSelectedTextStyle; + BrnTextStyle? _flayerSelectedTextStyle; /// 跳转二级页-加粗文本样式 /// @@ -219,7 +246,110 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWeight: FontWeight.w600 /// ) - BrnTextStyle? flayerBoldTextStyle; + BrnTextStyle? _flayerBoldTextStyle; + + BrnTextStyle get menuNormalTextStyle => + _menuNormalTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.menuNormalTextStyle; + + BrnTextStyle get menuSelectedTextStyle => + _menuSelectedTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.menuSelectedTextStyle; + + BrnTextStyle get tagNormalTextStyle => + _tagNormalTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.tagNormalTextStyle; + + BrnTextStyle get tagSelectedTextStyle => + _tagSelectedTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.tagSelectedTextStyle; + + double get tagRadius => + _tagRadius ?? BrnDefaultConfigUtils.defaultSelectionConfig.tagRadius; + + Color get tagNormalBackgroundColor => + _tagNormalBackgroundColor ?? + BrnDefaultConfigUtils.defaultSelectionConfig.tagNormalBackgroundColor; + + Color get tagSelectedBackgroundColor => + _tagSelectedBackgroundColor ?? + BrnDefaultConfigUtils.defaultSelectionConfig.tagSelectedBackgroundColor; + + BrnTextStyle get rangeTitleTextStyle => + _rangeTitleTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.rangeTitleTextStyle; + + BrnTextStyle get hintTextStyle => + _hintTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.hintTextStyle; + + BrnTextStyle get inputTextStyle => + _inputTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.inputTextStyle; + + BrnTextStyle get itemNormalTextStyle => + _itemNormalTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.itemNormalTextStyle; + + BrnTextStyle get itemSelectedTextStyle => + _itemSelectedTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.itemSelectedTextStyle; + + BrnTextStyle get itemBoldTextStyle => + _itemBoldTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.itemBoldTextStyle; + + Color get deepNormalBgColor => + _deepNormalBgColor ?? + BrnDefaultConfigUtils.defaultSelectionConfig.deepNormalBgColor; + + Color get deepSelectBgColor => + _deepSelectBgColor ?? + BrnDefaultConfigUtils.defaultSelectionConfig.deepSelectBgColor; + + Color get middleNormalBgColor => + _middleNormalBgColor ?? + BrnDefaultConfigUtils.defaultSelectionConfig.middleNormalBgColor; + + Color get middleSelectBgColor => + _middleSelectBgColor ?? + BrnDefaultConfigUtils.defaultSelectionConfig.middleSelectBgColor; + + Color get lightNormalBgColor => + _lightNormalBgColor ?? + BrnDefaultConfigUtils.defaultSelectionConfig.lightNormalBgColor; + + Color get lightSelectBgColor => + _lightSelectBgColor ?? + BrnDefaultConfigUtils.defaultSelectionConfig.lightSelectBgColor; + + BrnTextStyle get resetTextStyle => + _resetTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.resetTextStyle; + + BrnTextStyle get titleForMoreTextStyle => + _titleForMoreTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.titleForMoreTextStyle; + + BrnTextStyle get optionTextStyle => + _optionTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.optionTextStyle; + + BrnTextStyle get moreTextStyle => + _moreTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.moreTextStyle; + + BrnTextStyle get flayerNormalTextStyle => + _flayerNormalTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.flayerNormalTextStyle; + + BrnTextStyle get flayerSelectedTextStyle => + _flayerSelectedTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.flayerSelectedTextStyle; + + BrnTextStyle get flayerBoldTextStyle => + _flayerBoldTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.flayerBoldTextStyle; @override void initThemeConfig( @@ -232,118 +362,119 @@ class BrnSelectionConfig extends BrnBaseConfig { ); /// 用户全局筛选配置 - BrnSelectionConfig? selectionConfig = BrnThemeConfigurator.instance + BrnSelectionConfig selectionConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .selectionConfig; - lightSelectBgColor ??= selectionConfig?.lightSelectBgColor; - lightNormalBgColor ??= selectionConfig?.lightNormalBgColor; - middleSelectBgColor ??= selectionConfig?.middleSelectBgColor; - middleNormalBgColor ??= selectionConfig?.middleNormalBgColor; - deepSelectBgColor ??= selectionConfig?.deepSelectBgColor; - deepNormalBgColor ??= selectionConfig?.deepNormalBgColor; - tagSelectedBackgroundColor ??= commonConfig.brandPrimary?.withOpacity(0.12); - tagNormalBackgroundColor ??= commonConfig.fillBody; - tagRadius ??= commonConfig.radiusSm; - flayerBoldTextStyle = selectionConfig?.flayerBoldTextStyle?.merge( + _lightSelectBgColor ??= selectionConfig._lightSelectBgColor; + _lightNormalBgColor ??= selectionConfig._lightNormalBgColor; + _middleSelectBgColor ??= selectionConfig._middleSelectBgColor; + _middleNormalBgColor ??= selectionConfig._middleNormalBgColor; + _deepSelectBgColor ??= selectionConfig._deepSelectBgColor; + _deepNormalBgColor ??= selectionConfig._deepNormalBgColor; + _tagSelectedBackgroundColor ??= + commonConfig.brandPrimary.withOpacity(0.12); + _tagNormalBackgroundColor ??= commonConfig.fillBody; + _tagRadius ??= commonConfig.radiusSm; + _flayerBoldTextStyle = selectionConfig.flayerBoldTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(flayerBoldTextStyle), + ).merge(_flayerBoldTextStyle), ); - flayerSelectedTextStyle = selectionConfig?.flayerSelectedTextStyle?.merge( + _flayerSelectedTextStyle = selectionConfig.flayerSelectedTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeSubHead, - ).merge(flayerSelectedTextStyle), + ).merge(_flayerSelectedTextStyle), ); - flayerNormalTextStyle = selectionConfig?.flayerNormalTextStyle?.merge( + _flayerNormalTextStyle = selectionConfig.flayerNormalTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(flayerNormalTextStyle), + ).merge(_flayerNormalTextStyle), ); - moreTextStyle = selectionConfig?.moreTextStyle?.merge( + _moreTextStyle = selectionConfig.moreTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextSecondary, fontSize: commonConfig.fontSizeCaption, - ).merge(moreTextStyle), + ).merge(_moreTextStyle), ); - optionTextStyle = selectionConfig?.optionTextStyle?.merge( + _optionTextStyle = selectionConfig.optionTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeBase, - ).merge(optionTextStyle), + ).merge(_optionTextStyle), ); - titleForMoreTextStyle = selectionConfig?.titleForMoreTextStyle?.merge( + _titleForMoreTextStyle = selectionConfig.titleForMoreTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeBase, - ).merge(titleForMoreTextStyle), + ).merge(_titleForMoreTextStyle), ); - resetTextStyle = selectionConfig?.resetTextStyle?.merge(BrnTextStyle( + _resetTextStyle = selectionConfig.resetTextStyle.merge(BrnTextStyle( color: commonConfig.colorTextImportant, fontSize: commonConfig.fontSizeCaption, - ).merge(resetTextStyle)); - itemBoldTextStyle = selectionConfig?.itemBoldTextStyle?.merge( + ).merge(_resetTextStyle)); + _itemBoldTextStyle = selectionConfig.itemBoldTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeBase, - ).merge(itemBoldTextStyle), + ).merge(_itemBoldTextStyle), ); - itemSelectedTextStyle = selectionConfig?.itemSelectedTextStyle?.merge( + _itemSelectedTextStyle = selectionConfig.itemSelectedTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeBase, - ).merge(itemSelectedTextStyle), + ).merge(_itemSelectedTextStyle), ); - itemNormalTextStyle = selectionConfig?.itemNormalTextStyle?.merge( + _itemNormalTextStyle = selectionConfig.itemNormalTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeBase, - ).merge(itemNormalTextStyle), + ).merge(_itemNormalTextStyle), ); - inputTextStyle = selectionConfig?.inputTextStyle?.merge( + _inputTextStyle = selectionConfig.inputTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeBase, - ).merge(inputTextStyle), + ).merge(_inputTextStyle), ); - hintTextStyle = selectionConfig?.hintTextStyle?.merge( + _hintTextStyle = selectionConfig.hintTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextHint, fontSize: commonConfig.fontSizeBase, - ).merge(hintTextStyle), + ).merge(_hintTextStyle), ); - rangeTitleTextStyle = selectionConfig?.rangeTitleTextStyle?.merge( + _rangeTitleTextStyle = selectionConfig.rangeTitleTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(rangeTitleTextStyle), + ).merge(_rangeTitleTextStyle), ); - tagSelectedTextStyle = selectionConfig?.tagSelectedTextStyle?.merge( + _tagSelectedTextStyle = selectionConfig.tagSelectedTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeCaption, - ).merge(tagSelectedTextStyle), + ).merge(_tagSelectedTextStyle), ); - tagNormalTextStyle = selectionConfig?.tagNormalTextStyle?.merge( + _tagNormalTextStyle = selectionConfig.tagNormalTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeCaption, - ).merge(tagNormalTextStyle), + ).merge(_tagNormalTextStyle), ); - menuNormalTextStyle = selectionConfig?.menuNormalTextStyle?.merge( + _menuNormalTextStyle = selectionConfig.menuNormalTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeBase, - ).merge(menuNormalTextStyle), + ).merge(_menuNormalTextStyle), ); - menuSelectedTextStyle = selectionConfig?.menuSelectedTextStyle?.merge( + _menuSelectedTextStyle = selectionConfig.menuSelectedTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeBase, - ).merge(menuSelectedTextStyle), + ).merge(_menuSelectedTextStyle), ); } @@ -376,97 +507,71 @@ class BrnSelectionConfig extends BrnBaseConfig { BrnTextStyle? flayerBoldTextStyle, }) { return BrnSelectionConfig( - menuNormalTextStyle: menuNormalTextStyle ?? this.menuNormalTextStyle, - menuSelectedTextStyle: - menuSelectedTextStyle ?? this.menuSelectedTextStyle, - tagNormalTextStyle: tagTextStyle ?? this.tagNormalTextStyle, - tagSelectedTextStyle: tagSelectedTextStyle ?? this.tagSelectedTextStyle, - tagRadius: tagRadius ?? this.tagRadius, - tagNormalBackgroundColor: - tagBackgroundColor ?? this.tagNormalBackgroundColor, + menuNormalTextStyle: menuNormalTextStyle ?? _menuNormalTextStyle, + menuSelectedTextStyle: menuSelectedTextStyle ?? _menuSelectedTextStyle, + tagNormalTextStyle: tagTextStyle ?? _tagNormalTextStyle, + tagSelectedTextStyle: tagSelectedTextStyle ?? _tagSelectedTextStyle, + tagRadius: tagRadius ?? _tagRadius, + tagNormalBackgroundColor: tagBackgroundColor ?? _tagNormalBackgroundColor, tagSelectedBackgroundColor: - tagSelectedBackgroundColor ?? this.tagSelectedBackgroundColor, - hintTextStyle: hintTextStyle ?? this.hintTextStyle, - rangeTitleTextStyle: rangeTitleTextStyle ?? this.rangeTitleTextStyle, - inputTextStyle: inputTextStyle ?? this.inputTextStyle, - itemNormalTextStyle: itemNormalTextStyle ?? this.itemNormalTextStyle, - itemSelectedTextStyle: - itemSelectedTextStyle ?? this.itemSelectedTextStyle, - itemBoldTextStyle: itemBoldTextStyle ?? this.itemBoldTextStyle, - deepNormalBgColor: deepNormalBgColor ?? this.deepNormalBgColor, - deepSelectBgColor: deepSelectBgColor ?? this.deepSelectBgColor, - middleNormalBgColor: middleNormalBgColor ?? this.middleNormalBgColor, - middleSelectBgColor: middleSelectBgColor ?? this.middleSelectBgColor, - lightNormalBgColor: lightNormalBgColor ?? this.lightNormalBgColor, - lightSelectBgColor: lightSelectBgColor ?? this.lightSelectBgColor, - resetTextStyle: resetTextStyle ?? this.resetTextStyle, - titleForMoreTextStyle: - titleForMoreTextStyle ?? this.titleForMoreTextStyle, - optionTextStyle: optionTextStyle ?? this.optionTextStyle, - moreTextStyle: moreTextStyle ?? this.moreTextStyle, - flayerNormalTextStyle: - flayerNormalTextStyle ?? this.flayerNormalTextStyle, + tagSelectedBackgroundColor ?? _tagSelectedBackgroundColor, + hintTextStyle: hintTextStyle ?? _hintTextStyle, + rangeTitleTextStyle: rangeTitleTextStyle ?? _rangeTitleTextStyle, + inputTextStyle: inputTextStyle ?? _inputTextStyle, + itemNormalTextStyle: itemNormalTextStyle ?? _itemNormalTextStyle, + itemSelectedTextStyle: itemSelectedTextStyle ?? _itemSelectedTextStyle, + itemBoldTextStyle: itemBoldTextStyle ?? _itemBoldTextStyle, + deepNormalBgColor: deepNormalBgColor ?? _deepNormalBgColor, + deepSelectBgColor: deepSelectBgColor ?? _deepSelectBgColor, + middleNormalBgColor: middleNormalBgColor ?? _middleNormalBgColor, + middleSelectBgColor: middleSelectBgColor ?? _middleSelectBgColor, + lightNormalBgColor: lightNormalBgColor ?? _lightNormalBgColor, + lightSelectBgColor: lightSelectBgColor ?? _lightSelectBgColor, + resetTextStyle: resetTextStyle ?? _resetTextStyle, + titleForMoreTextStyle: titleForMoreTextStyle ?? _titleForMoreTextStyle, + optionTextStyle: optionTextStyle ?? _optionTextStyle, + moreTextStyle: moreTextStyle ?? _moreTextStyle, + flayerNormalTextStyle: flayerNormalTextStyle ?? _flayerNormalTextStyle, flayerSelectedTextStyle: - flayerSelectedTextStyle ?? this.flayerSelectedTextStyle, - flayerBoldTextStyle: flayerBoldTextStyle ?? this.flayerBoldTextStyle, + flayerSelectedTextStyle ?? _flayerSelectedTextStyle, + flayerBoldTextStyle: flayerBoldTextStyle ?? _flayerBoldTextStyle, ); } BrnSelectionConfig merge(BrnSelectionConfig other) { return copyWith( - menuNormalTextStyle: - menuNormalTextStyle?.merge(other.menuNormalTextStyle) ?? - other.menuNormalTextStyle, + menuNormalTextStyle: menuNormalTextStyle.merge(other._menuNormalTextStyle), menuSelectedTextStyle: - menuSelectedTextStyle?.merge(other.menuSelectedTextStyle) ?? - other.menuSelectedTextStyle, - tagTextStyle: tagNormalTextStyle?.merge(other.tagNormalTextStyle) ?? - other.tagNormalTextStyle, + menuSelectedTextStyle.merge(other._menuSelectedTextStyle), + tagTextStyle: tagNormalTextStyle.merge(other._tagNormalTextStyle), tagSelectedTextStyle: - tagSelectedTextStyle?.merge(other.tagSelectedTextStyle) ?? - other.tagSelectedTextStyle, - tagRadius: other.tagRadius, - tagBackgroundColor: other.tagNormalBackgroundColor, - tagSelectedBackgroundColor: other.tagSelectedBackgroundColor, - hintTextStyle: - hintTextStyle?.merge(other.hintTextStyle) ?? other.hintTextStyle, - rangeTitleTextStyle: - rangeTitleTextStyle?.merge(other.rangeTitleTextStyle) ?? - other.rangeTitleTextStyle, - inputTextStyle: - inputTextStyle?.merge(other.inputTextStyle) ?? other.inputTextStyle, - itemNormalTextStyle: - itemNormalTextStyle?.merge(other.itemNormalTextStyle) ?? - other.itemNormalTextStyle, + tagSelectedTextStyle.merge(other._tagSelectedTextStyle), + tagRadius: other._tagRadius, + tagBackgroundColor: other._tagNormalBackgroundColor, + tagSelectedBackgroundColor: other._tagSelectedBackgroundColor, + hintTextStyle: hintTextStyle.merge(other._hintTextStyle), + rangeTitleTextStyle: rangeTitleTextStyle.merge(other._rangeTitleTextStyle), + inputTextStyle: inputTextStyle.merge(other._inputTextStyle), + itemNormalTextStyle: itemNormalTextStyle.merge(other._itemNormalTextStyle), itemSelectedTextStyle: - itemSelectedTextStyle?.merge(other.itemSelectedTextStyle) ?? - other.itemSelectedTextStyle, - itemBoldTextStyle: itemBoldTextStyle?.merge(other.itemBoldTextStyle) ?? - other.itemBoldTextStyle, - deepNormalBgColor: other.deepNormalBgColor, - deepSelectBgColor: other.deepSelectBgColor, - middleNormalBgColor: other.middleNormalBgColor, - middleSelectBgColor: other.middleSelectBgColor, - lightNormalBgColor: other.lightNormalBgColor, - lightSelectBgColor: other.lightSelectBgColor, - resetTextStyle: - resetTextStyle?.merge(other.resetTextStyle) ?? other.resetTextStyle, + itemSelectedTextStyle.merge(other._itemSelectedTextStyle), + itemBoldTextStyle: itemBoldTextStyle.merge(other._itemBoldTextStyle), + deepNormalBgColor: other._deepNormalBgColor, + deepSelectBgColor: other._deepSelectBgColor, + middleNormalBgColor: other._middleNormalBgColor, + middleSelectBgColor: other._middleSelectBgColor, + lightNormalBgColor: other._lightNormalBgColor, + lightSelectBgColor: other._lightSelectBgColor, + resetTextStyle: resetTextStyle.merge(other._resetTextStyle), titleForMoreTextStyle: - titleForMoreTextStyle?.merge(other.titleForMoreTextStyle) ?? - other.titleForMoreTextStyle, - optionTextStyle: optionTextStyle?.merge(other.optionTextStyle) ?? - other.optionTextStyle, - moreTextStyle: - moreTextStyle?.merge(other.moreTextStyle) ?? other.moreTextStyle, + titleForMoreTextStyle.merge(other._titleForMoreTextStyle), + optionTextStyle: optionTextStyle.merge(other._optionTextStyle), + moreTextStyle: moreTextStyle.merge(other._moreTextStyle), flayerNormalTextStyle: - flayerNormalTextStyle?.merge(other.flayerNormalTextStyle) ?? - other.flayerNormalTextStyle, + flayerNormalTextStyle.merge(other._flayerNormalTextStyle), flayerSelectedTextStyle: - flayerSelectedTextStyle?.merge(other.flayerSelectedTextStyle) ?? - other.flayerSelectedTextStyle, - flayerBoldTextStyle: - flayerBoldTextStyle?.merge(other.flayerBoldTextStyle) ?? - other.flayerBoldTextStyle, + flayerSelectedTextStyle.merge(other._flayerSelectedTextStyle), + flayerBoldTextStyle: flayerBoldTextStyle.merge(other._flayerBoldTextStyle), ); } } diff --git a/lib/src/theme/configs/brn_tabbar_config.dart b/lib/src/theme/configs/brn_tabbar_config.dart index 69a3e7b1..457ae2c8 100644 --- a/lib/src/theme/configs/brn_tabbar_config.dart +++ b/lib/src/theme/configs/brn_tabbar_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -9,34 +10,48 @@ class BrnTabBarConfig extends BrnBaseConfig { /// 遵循外部主题配置 /// 默认为 [BrnDefaultConfigUtils.tabBarConfig] BrnTabBarConfig({ - this.tabHeight, - this.indicatorHeight, - this.indicatorWidth, - this.labelStyle, - this.unselectedLabelStyle, - this.backgroundColor, - this.tagNormalTextStyle, - this.tagNormalBgColor, - this.tagSelectedTextStyle, - this.tagSelectedBgColor, - this.tagRadius, - this.tagSpacing, - this.preLineTagCount, - this.tagHeight, + double? tabHeight, + double? indicatorHeight, + double? indicatorWidth, + BrnTextStyle? labelStyle, + BrnTextStyle? unselectedLabelStyle, + Color? backgroundColor, + BrnTextStyle? tagNormalTextStyle, + Color? tagNormalBgColor, + BrnTextStyle? tagSelectedTextStyle, + Color? tagSelectedBgColor, + double? tagRadius, + double? tagSpacing, + int? preLineTagCount, + double? tagHeight, String configId: GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _tabHeight = tabHeight, + _indicatorHeight = indicatorHeight, + _indicatorWidth = indicatorWidth, + _labelStyle = labelStyle, + _unselectedLabelStyle = unselectedLabelStyle, + _backgroundColor = backgroundColor, + _tagNormalTextStyle = tagNormalTextStyle, + _tagNormalBgColor = tagNormalBgColor, + _tagSelectedTextStyle = tagSelectedTextStyle, + _tagSelectedBgColor = tagSelectedBgColor, + _tagRadius = tagRadius, + _tagSpacing = tagSpacing, + _preLineTagCount = preLineTagCount, + _tagHeight = tagHeight, + super(configId: configId); /// TabBar 的整体高度 /// 默认为 50 - double? tabHeight; + double? _tabHeight; /// 指示器的高度 /// 默认为 2 - double? indicatorHeight; + double? _indicatorHeight; /// 指示器的宽度 /// 默认为 24 - double? indicatorWidth; + double? _indicatorWidth; /// 选中 Tab 文本的样式 /// @@ -44,7 +59,7 @@ class BrnTabBarConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.brandPrimary], /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? labelStyle; + BrnTextStyle? _labelStyle; /// 未选中 Tab 文本的样式 /// @@ -52,11 +67,11 @@ class BrnTabBarConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? unselectedLabelStyle; + BrnTextStyle? _unselectedLabelStyle; /// 背景色 /// 默认为 [BrnCommonConfig.fillBase] - Color? backgroundColor; + Color? _backgroundColor; /// 标签字体样式 /// @@ -64,11 +79,11 @@ class BrnTabBarConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeCaption], /// ) - BrnTextStyle? tagNormalTextStyle; + BrnTextStyle? _tagNormalTextStyle; /// 标签背景色 /// 默认为 [BrnCommonConfig.brandPrimary].withAlpha(0x14), - Color? tagNormalBgColor; + Color? _tagNormalBgColor; /// 标签字体样式 /// @@ -76,27 +91,78 @@ class BrnTabBarConfig extends BrnBaseConfig { /// color:[BrnCommonConfig.brandPrimary], /// fontSize: [BrnCommonConfig.fontSizeCaption], /// ) - BrnTextStyle? tagSelectedTextStyle; + BrnTextStyle? _tagSelectedTextStyle; /// 标签选中背景色 /// 默认为 [BrnCommonConfig.fillBody] - Color? tagSelectedBgColor; + Color? _tagSelectedBgColor; /// tag圆角 /// 默认为 [BrnCommonConfig.radiusSm] - double? tagRadius; + double? _tagRadius; /// tag间距 /// 默认为 12 - double? tagSpacing; + double? _tagSpacing; /// 每行的tag数 /// 默认为 4 - int? preLineTagCount; + int? _preLineTagCount; /// tag高度 /// 默认为 32 - double? tagHeight; + double? _tagHeight; + + double get tabHeight => + _tabHeight ?? BrnDefaultConfigUtils.defaultTabBarConfig.tabHeight; + + double get indicatorHeight => + _indicatorHeight ?? + BrnDefaultConfigUtils.defaultTabBarConfig.indicatorHeight; + + double get indicatorWidth => + _indicatorWidth ?? + BrnDefaultConfigUtils.defaultTabBarConfig.indicatorWidth; + + BrnTextStyle get labelStyle => + _labelStyle ?? BrnDefaultConfigUtils.defaultTabBarConfig.labelStyle; + + BrnTextStyle get unselectedLabelStyle => + _unselectedLabelStyle ?? + BrnDefaultConfigUtils.defaultTabBarConfig.unselectedLabelStyle; + + Color get backgroundColor => + _backgroundColor ?? + BrnDefaultConfigUtils.defaultTabBarConfig.backgroundColor; + + BrnTextStyle get tagNormalTextStyle => + _tagNormalTextStyle ?? + BrnDefaultConfigUtils.defaultTabBarConfig.tagNormalTextStyle; + + Color get tagNormalBgColor => + _tagNormalBgColor ?? + BrnDefaultConfigUtils.defaultTabBarConfig.tagNormalBgColor; + + BrnTextStyle get tagSelectedTextStyle => + _tagSelectedTextStyle ?? + BrnDefaultConfigUtils.defaultTabBarConfig.tagSelectedTextStyle; + + Color get tagSelectedBgColor => + _tagSelectedBgColor ?? + BrnDefaultConfigUtils.defaultTabBarConfig.tagSelectedBgColor; + + double get tagRadius => + _tagRadius ?? BrnDefaultConfigUtils.defaultTabBarConfig.tagRadius; + + double get tagSpacing => + _tagSpacing ?? BrnDefaultConfigUtils.defaultTabBarConfig.tagSpacing; + + int get preLineTagCount => + _preLineTagCount ?? + BrnDefaultConfigUtils.defaultTabBarConfig.preLineTagCount; + + double get tagHeight => + _tagHeight ?? BrnDefaultConfigUtils.defaultTabBarConfig.tagHeight; @override void initThemeConfig( @@ -108,44 +174,44 @@ class BrnTabBarConfig extends BrnBaseConfig { currentLevelCommonConfig: currentLevelCommonConfig, ); - BrnTabBarConfig? tabBarConfig = BrnThemeConfigurator.instance + BrnTabBarConfig tabBarConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .tabBarConfig; - tabHeight ??= tabBarConfig?.tabHeight; - indicatorHeight ??= tabBarConfig?.indicatorHeight; - indicatorWidth ??= tabBarConfig?.indicatorWidth; - labelStyle = tabBarConfig?.labelStyle?.merge( + _tabHeight ??= tabBarConfig._tabHeight; + _indicatorHeight ??= tabBarConfig._indicatorHeight; + _indicatorWidth ??= tabBarConfig._indicatorWidth; + _labelStyle = tabBarConfig.labelStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeSubHead, - ).merge(labelStyle), + ).merge(_labelStyle), ); - unselectedLabelStyle = tabBarConfig?.unselectedLabelStyle?.merge( + _unselectedLabelStyle = tabBarConfig.unselectedLabelStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(unselectedLabelStyle), + ).merge(_unselectedLabelStyle), ); - backgroundColor ??= tabBarConfig?.backgroundColor; - tagNormalTextStyle = tabBarConfig?.tagNormalTextStyle?.merge( + _backgroundColor ??= tabBarConfig._backgroundColor; + _tagNormalTextStyle = tabBarConfig.tagNormalTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeCaption, - ).merge(tagNormalTextStyle), + ).merge(_tagNormalTextStyle), ); - tagSelectedTextStyle = tabBarConfig?.tagSelectedTextStyle?.merge( + _tagSelectedTextStyle = tabBarConfig.tagSelectedTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeCaption, - ).merge(tagSelectedTextStyle), + ).merge(_tagSelectedTextStyle), ); - tagNormalBgColor ??= tabBarConfig?.tagNormalBgColor; - tagSelectedBgColor ??= tabBarConfig?.tagSelectedBgColor; - tagRadius ??= commonConfig.radiusSm; - tagSpacing ??= tabBarConfig?.tagSpacing; - preLineTagCount ??= tabBarConfig?.preLineTagCount; - tagHeight ??= tabBarConfig?.tagHeight; + _tagNormalBgColor ??= tabBarConfig._tagNormalBgColor; + _tagSelectedBgColor ??= tabBarConfig._tagSelectedBgColor; + _tagRadius ??= commonConfig.radiusSm; + _tagSpacing ??= tabBarConfig._tagSpacing; + _preLineTagCount ??= tabBarConfig._preLineTagCount; + _tagHeight ??= tabBarConfig._tagHeight; } BrnTabBarConfig copyWith({ @@ -165,45 +231,42 @@ class BrnTabBarConfig extends BrnBaseConfig { double? tagHeight, }) { return BrnTabBarConfig( - tabHeight: tabHeight ?? this.tabHeight, - indicatorHeight: indicatorHeight ?? this.indicatorHeight, - indicatorWidth: indicatorWidth ?? this.indicatorWidth, - labelStyle: labelStyle ?? this.labelStyle, - unselectedLabelStyle: unselectedLabelStyle ?? this.unselectedLabelStyle, - backgroundColor: backgroundColor ?? this.backgroundColor, - tagNormalTextStyle: tagNormalTextStyle ?? this.tagNormalTextStyle, - tagNormalBgColor: tagNormalColor ?? this.tagNormalBgColor, - tagSelectedTextStyle: tagSelectedTextStyle ?? this.tagSelectedTextStyle, - tagSelectedBgColor: tagSelectedColor ?? this.tagSelectedBgColor, - tagRadius: tagRadius ?? this.tagRadius, - tagSpacing: tagSpacing ?? this.tagSpacing, - preLineTagCount: preLineTagSize ?? this.preLineTagCount, - tagHeight: tagHeight ?? this.tagHeight, + tabHeight: tabHeight ?? _tabHeight, + indicatorHeight: indicatorHeight ?? _indicatorHeight, + indicatorWidth: indicatorWidth ?? _indicatorWidth, + labelStyle: labelStyle ?? _labelStyle, + unselectedLabelStyle: unselectedLabelStyle ?? _unselectedLabelStyle, + backgroundColor: backgroundColor ?? _backgroundColor, + tagNormalTextStyle: tagNormalTextStyle ?? _tagNormalTextStyle, + tagNormalBgColor: tagNormalColor ?? _tagNormalBgColor, + tagSelectedTextStyle: tagSelectedTextStyle ?? _tagSelectedTextStyle, + tagSelectedBgColor: tagSelectedColor ?? _tagSelectedBgColor, + tagRadius: tagRadius ?? _tagRadius, + tagSpacing: tagSpacing ?? _tagSpacing, + preLineTagCount: preLineTagSize ?? _preLineTagCount, + tagHeight: tagHeight ?? _tagHeight, ); } BrnTabBarConfig merge(BrnTabBarConfig? other) { if (other == null) return this; return copyWith( - tabHeight: other.tabHeight, - indicatorHeight: other.indicatorHeight, - indicatorWidth: other.indicatorWidth, - labelStyle: labelStyle?.merge(other.labelStyle) ?? other.labelStyle, + tabHeight: other._tabHeight, + indicatorHeight: other._indicatorHeight, + indicatorWidth: other._indicatorWidth, + labelStyle: labelStyle.merge(other._labelStyle), unselectedLabelStyle: - unselectedLabelStyle?.merge(other.unselectedLabelStyle) ?? - other.unselectedLabelStyle, - backgroundColor: other.backgroundColor, - tagNormalTextStyle: tagNormalTextStyle?.merge(other.tagNormalTextStyle) ?? - other.tagNormalTextStyle, - tagNormalColor: other.tagNormalBgColor, + unselectedLabelStyle.merge(other._unselectedLabelStyle), + backgroundColor: other._backgroundColor, + tagNormalTextStyle: tagNormalTextStyle.merge(other._tagNormalTextStyle), + tagNormalColor: other._tagNormalBgColor, tagSelectedTextStyle: - tagSelectedTextStyle?.merge(other.tagSelectedTextStyle) ?? - other.tagSelectedTextStyle, - tagSelectedColor: other.tagSelectedBgColor, - tagRadius: other.tagRadius, - tagSpacing: other.tagSpacing, - preLineTagSize: other.preLineTagCount, - tagHeight: other.tagHeight, + tagSelectedTextStyle.merge(other._tagSelectedTextStyle), + tagSelectedColor: other._tagSelectedBgColor, + tagRadius: other._tagRadius, + tagSpacing: other._tagSpacing, + preLineTagSize: other._preLineTagCount, + tagHeight: other._tagHeight, ); } } diff --git a/lib/src/theme/configs/brn_tag_config.dart b/lib/src/theme/configs/brn_tag_config.dart index 113493c6..39b03a26 100644 --- a/lib/src/theme/configs/brn_tag_config.dart +++ b/lib/src/theme/configs/brn_tag_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -7,16 +8,24 @@ import 'package:flutter/painting.dart'; /// 标签配置类 class BrnTagConfig extends BrnBaseConfig { BrnTagConfig({ - this.tagTextStyle, - this.selectTagTextStyle, - this.tagRadius, - this.tagBackgroundColor, - this.selectedTagBackgroundColor, - this.tagHeight, - this.tagWidth, - this.tagMinWidth, + BrnTextStyle? tagTextStyle, + BrnTextStyle? selectTagTextStyle, + double? tagRadius, + Color? tagBackgroundColor, + Color? selectedTagBackgroundColor, + double? tagHeight, + double? tagWidth, + double? tagMinWidth, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _tagTextStyle = tagTextStyle, + _selectTagTextStyle = selectTagTextStyle, + _tagRadius = tagRadius, + _tagBackgroundColor = tagBackgroundColor, + _selectedTagBackgroundColor = selectedTagBackgroundColor, + _tagHeight = tagHeight, + _tagWidth = tagWidth, + _tagMinWidth = tagMinWidth, + super(configId: configId); /// tag 文本样式 /// @@ -24,7 +33,7 @@ class BrnTagConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeCaption], /// ) - BrnTextStyle? tagTextStyle; + BrnTextStyle? _tagTextStyle; /// tag选中文本样式 /// @@ -33,31 +42,58 @@ class BrnTagConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeCaption], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? selectTagTextStyle; + BrnTextStyle? _selectTagTextStyle; /// 标签背景色 /// default [BrnCommonConfig.fillBody] - Color? tagBackgroundColor; + Color? _tagBackgroundColor; /// 选中背景色 /// default [BrnCommonConfig.brandPrimary] - Color? selectedTagBackgroundColor; + Color? _selectedTagBackgroundColor; /// 标签圆角 /// 默认为 [BrnCommonConfig.radiusXs] - double? tagRadius; + double? _tagRadius; /// 标签高度,跟 fixWidthMode 无关 /// 默认为 34 - double? tagHeight; + double? _tagHeight; /// 标签宽度,且仅在组件设置了固定宽度(fixWidthMode 为 true)时才生效 /// 默认为 75 - double? tagWidth; + double? _tagWidth; /// 标签最小宽度 /// 默认为 75 - double? tagMinWidth; + double? _tagMinWidth; + + BrnTextStyle get tagTextStyle => + _tagTextStyle ?? BrnDefaultConfigUtils.defaultTagConfig.tagTextStyle; + + BrnTextStyle get selectTagTextStyle => + _selectTagTextStyle ?? + BrnDefaultConfigUtils.defaultTagConfig.selectTagTextStyle; + + Color get tagBackgroundColor => + _tagBackgroundColor ?? + BrnDefaultConfigUtils.defaultTagConfig.tagBackgroundColor; + + Color get selectedTagBackgroundColor => + _selectedTagBackgroundColor ?? + BrnDefaultConfigUtils.defaultTagConfig.selectedTagBackgroundColor; + + double get tagRadius => + _tagRadius ?? BrnDefaultConfigUtils.defaultTagConfig.tagRadius; + + double get tagHeight => + _tagHeight ?? BrnDefaultConfigUtils.defaultTagConfig.tagHeight; + + double get tagWidth => + _tagWidth ?? BrnDefaultConfigUtils.defaultTagConfig.tagWidth; + + double get tagMinWidth => + _tagMinWidth ?? BrnDefaultConfigUtils.defaultTagConfig.tagMinWidth; @override void initThemeConfig( @@ -70,26 +106,26 @@ class BrnTagConfig extends BrnBaseConfig { ); /// 用户全局组件配置 - BrnTagConfig? tagConfig = + BrnTagConfig tagConfig = BrnThemeConfigurator.instance.getConfig(configId: configId).tagConfig; - tagHeight ??= tagConfig?.tagHeight; - tagWidth ??= tagConfig?.tagWidth; - tagMinWidth ??= tagConfig?.tagMinWidth; - tagRadius ??= commonConfig.radiusXs; - tagBackgroundColor ??= commonConfig.fillBody; - selectedTagBackgroundColor ??= commonConfig.brandPrimary; - tagTextStyle = tagConfig?.tagTextStyle?.merge( + _tagHeight ??= tagConfig._tagHeight; + _tagWidth ??= tagConfig._tagWidth; + _tagMinWidth ??= tagConfig._tagMinWidth; + _tagRadius ??= commonConfig.radiusXs; + _tagBackgroundColor ??= commonConfig.fillBody; + _selectedTagBackgroundColor ??= commonConfig.brandPrimary; + _tagTextStyle = tagConfig.tagTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeCaption, - ).merge(tagTextStyle), + ).merge(_tagTextStyle), ); - selectTagTextStyle = tagConfig?.selectTagTextStyle?.merge( + _selectTagTextStyle = tagConfig.selectTagTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeCaption, - ).merge(selectTagTextStyle), + ).merge(_selectTagTextStyle), ); } @@ -104,29 +140,28 @@ class BrnTagConfig extends BrnBaseConfig { double? tagMinWidth, }) { return BrnTagConfig( - tagTextStyle: textStyle ?? this.tagTextStyle, - selectTagTextStyle: selectTextStyle ?? this.selectTagTextStyle, - tagRadius: radius ?? this.tagRadius, - tagBackgroundColor: backgroundColor ?? this.tagBackgroundColor, + tagTextStyle: textStyle ?? _tagTextStyle, + selectTagTextStyle: selectTextStyle ?? _selectTagTextStyle, + tagRadius: radius ?? _tagRadius, + tagBackgroundColor: backgroundColor ?? _tagBackgroundColor, selectedTagBackgroundColor: - selectedBackgroundColor ?? this.selectedTagBackgroundColor, - tagHeight: height ?? this.tagHeight, - tagWidth: width ?? this.tagWidth, - tagMinWidth: tagMinWidth ?? this.tagMinWidth, + selectedBackgroundColor ?? _selectedTagBackgroundColor, + tagHeight: height ?? _tagHeight, + tagWidth: width ?? _tagWidth, + tagMinWidth: tagMinWidth ?? _tagMinWidth, ); } BrnTagConfig merge(BrnTagConfig other) { return copyWith( - textStyle: tagTextStyle?.merge(other.tagTextStyle) ?? other.tagTextStyle, - selectTextStyle: selectTagTextStyle?.merge(other.selectTagTextStyle) ?? - other.selectTagTextStyle, - radius: other.tagRadius, - backgroundColor: other.tagBackgroundColor, - selectedBackgroundColor: other.selectedTagBackgroundColor, - height: other.tagHeight, - width: other.tagWidth, - tagMinWidth: other.tagMinWidth, + textStyle: tagTextStyle.merge(other._tagTextStyle), + selectTextStyle: selectTagTextStyle.merge(other._selectTagTextStyle), + radius: other._tagRadius, + backgroundColor: other._tagBackgroundColor, + selectedBackgroundColor: other._selectedTagBackgroundColor, + height: other._tagHeight, + width: other._tagWidth, + tagMinWidth: other._tagMinWidth, ); } }