Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: BrnAppBar global style don't work #424

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions lib/src/components/navbar/brn_appbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,9 @@ class BrnAppBar extends PreferredSize {
} else if (brightness == Brightness.dark) {
_defaultConfig = _defaultConfig.merge(BrnAppBarConfig.dark());
}
_defaultConfig = _defaultConfig
.merge(BrnAppBarConfig(backgroundColor: this.backgroundColor, showDefaultBottom: this.showDefaultBottom));
_defaultConfig = _defaultConfig.merge(BrnAppBarConfig(
backgroundColor: this.backgroundColor,
showDefaultBottom: this.showDefaultBottom));

_defaultConfig = BrnThemeConfigurator.instance
.getConfig(configId: _defaultConfig.configId)
Expand All @@ -259,19 +260,33 @@ class BrnAppBar extends PreferredSize {
@override
Widget get child {
BrnAppBarConfig _defaultConfig = themeData ?? BrnAppBarConfig();
BrnAppBarConfig globalAppBarConfig = BrnThemeConfigurator.instance
.getConfig(configId: _defaultConfig.configId)
.appBarConfig;
BrnAppBarConfig _appBarConfig = globalAppBarConfig.merge(
BrnAppBarConfig(backgroundColor: backgroundColor),
);
//当外部传入主题
if (brightness == Brightness.light) {
_defaultConfig = _defaultConfig.merge(BrnAppBarConfig.light());
_appBarConfig = _appBarConfig.merge(
BrnAppBarConfig.light(
titleStyle: globalAppBarConfig.titleStyle,
actionsStyle: globalAppBarConfig.actionsStyle,
leadIconBuilder: globalAppBarConfig.leadIconBuilder,
backgroundColor: backgroundColor,
),
);
} else if (brightness == Brightness.dark) {
_defaultConfig = _defaultConfig.merge(BrnAppBarConfig.dark());
_appBarConfig = _appBarConfig.merge(
BrnAppBarConfig.dark(
titleStyle: globalAppBarConfig.titleStyle,
actionsStyle: globalAppBarConfig.actionsStyle,
leadIconBuilder: globalAppBarConfig.leadIconBuilder,
backgroundColor: backgroundColor,
),
);
}
_defaultConfig =
_defaultConfig.merge(BrnAppBarConfig(backgroundColor: backgroundColor));

_defaultConfig = BrnThemeConfigurator.instance
.getConfig(configId: _defaultConfig.configId)
.appBarConfig
.merge(_defaultConfig);
_defaultConfig = globalAppBarConfig.merge(themeData).merge(_appBarConfig);

Widget? flexibleSpace;
if (this.flexibleSpace != null) {
Expand Down Expand Up @@ -624,8 +639,7 @@ class _BrnSearchResultAppBar extends StatelessWidget {
_defaultConfig = _defaultConfig.merge(BrnAppBarConfig.dark());
}

_defaultConfig = _defaultConfig
.merge(BrnAppBarConfig(
_defaultConfig = _defaultConfig.merge(BrnAppBarConfig(
backgroundColor: this.backgroundColor,
showDefaultBottom: this.showDefaultBottom,
));
Expand Down
52 changes: 31 additions & 21 deletions lib/src/theme/configs/brn_appbar_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,31 +51,36 @@ class BrnAppBarConfig extends BrnBaseConfig {
EdgeInsets? titlePadding,
double? iconSize,
String configId = GLOBAL_CONFIG_ID,
BrnTextStyle? titleStyle,
BrnTextStyle? actionsStyle,
Color? backgroundColor,
Widget Function()? leadIconBuilder,
}) : _appBarHeight = appBarHeight,
_titleMaxLength = titleMaxLength,
_leftAndRightPadding = leftAndRightPadding,
_itemSpacing = itemSpacing,
_titlePadding = titlePadding,
_iconSize = iconSize,
super(configId: configId) {
_backgroundColor = Color(0xff2E313B);
_leadIconBuilder = () => Image.asset(
BrnAsset.iconBackWhite,
package: BrnStrings.flutterPackageName,
width: BrnAppBarTheme.iconSize,
height: BrnAppBarTheme.iconSize,
fit: BoxFit.fitHeight,
);
_backgroundColor = backgroundColor ?? Color(0xff2E313B);
_leadIconBuilder = leadIconBuilder ??
() => Image.asset(
BrnAsset.iconBackWhite,
package: BrnStrings.flutterPackageName,
width: BrnAppBarTheme.iconSize,
height: BrnAppBarTheme.iconSize,
fit: BoxFit.fitHeight,
);
_titleStyle = BrnTextStyle(
fontSize: BrnAppBarTheme.titleFontSize,
fontWeight: FontWeight.w600,
color: BrnAppBarTheme.darkTextColor,
);
).merge(titleStyle);
_actionsStyle = BrnTextStyle(
color: BrnAppBarTheme.darkTextColor,
fontSize: BrnAppBarTheme.actionFontSize,
fontWeight: FontWeight.w600,
);
).merge(actionsStyle);
_systemUiOverlayStyle = SystemUiOverlayStyle.light;
}

Expand All @@ -86,6 +91,10 @@ class BrnAppBarConfig extends BrnBaseConfig {
double? itemSpacing,
EdgeInsets? titlePadding,
double? iconSize,
BrnTextStyle? titleStyle,
BrnTextStyle? actionsStyle,
Color? backgroundColor,
Widget Function()? leadIconBuilder,
String configId = GLOBAL_CONFIG_ID,
}) : _appBarHeight = appBarHeight,
_titleMaxLength = titleMaxLength,
Expand All @@ -94,24 +103,25 @@ class BrnAppBarConfig extends BrnBaseConfig {
_titlePadding = titlePadding,
_iconSize = iconSize,
super(configId: configId) {
_backgroundColor = Colors.white;
_leadIconBuilder = () => Image.asset(
BrnAsset.iconBackBlack,
package: BrnStrings.flutterPackageName,
width: BrnAppBarTheme.iconSize,
height: BrnAppBarTheme.iconSize,
fit: BoxFit.fitHeight,
);
_backgroundColor = backgroundColor ?? Colors.white;
_leadIconBuilder = leadIconBuilder ??
() => Image.asset(
BrnAsset.iconBackBlack,
package: BrnStrings.flutterPackageName,
width: BrnAppBarTheme.iconSize,
height: BrnAppBarTheme.iconSize,
fit: BoxFit.fitHeight,
);
_titleStyle = BrnTextStyle(
fontSize: BrnAppBarTheme.titleFontSize,
fontWeight: FontWeight.w600,
color: BrnAppBarTheme.lightTextColor,
);
).merge(titleStyle);
_actionsStyle = BrnTextStyle(
color: BrnAppBarTheme.lightTextColor,
fontSize: BrnAppBarTheme.actionFontSize,
fontWeight: FontWeight.w600,
);
).merge(actionsStyle);
_systemUiOverlayStyle = SystemUiOverlayStyle.dark;
}

Expand Down Expand Up @@ -204,7 +214,7 @@ class BrnAppBarConfig extends BrnBaseConfig {

bool get showDefaultBottom =>
_showDefaultBottom ??
BrnDefaultConfigUtils.defaultAppBarConfig.showDefaultBottom;
BrnDefaultConfigUtils.defaultAppBarConfig.showDefaultBottom;

@override
void initThemeConfig(
Expand Down