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 content_card themeData is not null #79

Merged
merged 1 commit into from
Jan 13, 2022
Merged
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
64 changes: 31 additions & 33 deletions lib/src/components/card/content_card/brn_pair_info_table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ class _BrnPairInfoTableState extends State<BrnPairInfoTable> {
// 是否具备展开收起功能 如果不展示则显示全部
bool canExpanded = false;

BrnPairInfoTableConfig? themeData;
late BrnPairInfoTableConfig themeData;

@override
void initState() {
themeData = widget.themeData ?? BrnPairInfoTableConfig();
themeData =
themeData!.merge(BrnPairInfoTableConfig(rowSpacing: widget.rowDistance));
themeData.merge(BrnPairInfoTableConfig(rowSpacing: widget.rowDistance));
themeData = BrnThemeConfigurator.instance
.getConfig(configId: themeData!.configId)
.getConfig(configId: themeData.configId)
.pairInfoTableConfig
.merge(themeData);

Expand All @@ -167,11 +167,10 @@ class _BrnPairInfoTableState extends State<BrnPairInfoTable> {
@override
void didUpdateWidget(BrnPairInfoTable oldWidget) {
super.didUpdateWidget(oldWidget);
themeData ??= BrnPairInfoTableConfig();
themeData =
themeData!.merge(BrnPairInfoTableConfig(rowSpacing: widget.rowDistance));
themeData.merge(BrnPairInfoTableConfig(rowSpacing: widget.rowDistance));
themeData = BrnThemeConfigurator.instance
.getConfig(configId: themeData!.configId)
.getConfig(configId: themeData.configId)
.pairInfoTableConfig
.merge(themeData);
}
Expand Down Expand Up @@ -216,14 +215,14 @@ class _BrnPairInfoTableState extends State<BrnPairInfoTable> {
valueWidget = _valueTitleText(data.valuePart,
isValueAlign: widget.isValueAlign,
isArrow: data.isArrow,
themeData: themeData!);
themeData: themeData);
} else {
valueWidget = data.valuePart;

if (valueWidget == null) {
valueWidget = Text(
'--',
style: themeData!.valueTextStyle?.generateTextStyle(),
style: themeData.valueTextStyle.generateTextStyle(),
);
}
}
Expand All @@ -239,7 +238,7 @@ class _BrnPairInfoTableState extends State<BrnPairInfoTable> {
);
}
return Padding(
padding: EdgeInsets.only(left: itemSpacing ?? themeData!.itemSpacing),
padding: EdgeInsets.only(left: itemSpacing ?? themeData.itemSpacing),
child: valueWidget,
);
}
Expand Down Expand Up @@ -279,7 +278,7 @@ class _BrnPairInfoTableState extends State<BrnPairInfoTable> {
'展开',
style: TextStyle(
fontSize: 14,
color: themeData!.commonConfig.colorTextSecondary,
color: themeData.commonConfig.colorTextSecondary,
),
),
),
Expand Down Expand Up @@ -337,7 +336,7 @@ class _BrnPairInfoTableState extends State<BrnPairInfoTable> {
'收起',
style: TextStyle(
fontSize: 14,
color: themeData!.commonConfig.colorTextSecondary,
color: themeData.commonConfig.colorTextSecondary,
),
),
),
Expand Down Expand Up @@ -408,7 +407,7 @@ class _BrnPairInfoTableState extends State<BrnPairInfoTable> {
show,
overflow: isSingle ? TextOverflow.ellipsis : TextOverflow.clip,
maxLines: isSingle ? 1 : null,
style: themeData.valueTextStyle?.generateTextStyle(),
style: themeData.valueTextStyle.generateTextStyle(),
);
return keyOrValue;
}
Expand Down Expand Up @@ -460,7 +459,7 @@ mixin PairInfoPart {
if (valueWidget == null) {
valueWidget = Text(
'--',
style: themeData.valueTextStyle?.generateTextStyle(),
style: themeData.valueTextStyle.generateTextStyle(),
);
}
}
Expand All @@ -484,7 +483,7 @@ mixin PairInfoPart {
Widget keyOrValueTitleText(bool isKey, String text,
{bool isValueAlign = true,
bool isArrow = false,
BrnPairInfoTableConfig? themeData}) {
required BrnPairInfoTableConfig themeData}) {
bool isSingle;
if (isArrow) {
isSingle = true;
Expand All @@ -508,8 +507,8 @@ mixin PairInfoPart {
overflow: isSingle ? TextOverflow.ellipsis : TextOverflow.clip,
maxLines: isSingle ? 1 : null,
style: isKey
? themeData!.keyTextStyle?.generateTextStyle()
: themeData!.valueTextStyle?.generateTextStyle(),
? themeData.keyTextStyle.generateTextStyle()
: themeData.valueTextStyle.generateTextStyle(),
);
return keyOrValue;
}
Expand Down Expand Up @@ -554,8 +553,8 @@ class BrnFollowPairInfo extends StatelessWidget with PairInfoPart {
children: children!.map((data) {
index++;
return Padding(
padding:
EdgeInsets.only(top: (index == 0) ? 0 : themeData!.rowSpacing),
padding: EdgeInsets.only(
top: (index == 0) ? 0 : themeData!.rowSpacing),
child: _buildSingleInfo(
data!, constraints.maxWidth / 2, defaultThemeConfig),
);
Expand Down Expand Up @@ -711,8 +710,7 @@ class BrnInfoModal {
this.isArrow = false,
this.valueClickCallback})
: assert(keyPart == null || keyPart is String || keyPart is Widget),
assert(
valuePart == null || valuePart is String || valuePart is Widget) {}
assert(valuePart == null || valuePart is String || valuePart is Widget);

///-----------以下静态方法为常见显示的快捷构造-----------
/// value的最后一部分带有可点击的超链接
Expand Down Expand Up @@ -760,7 +758,7 @@ class BrnInfoModal {
valueTitle,
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: themeData.valueTextStyle?.generateTextStyle(),
style: themeData.valueTextStyle.generateTextStyle(),
),
),
GestureDetector(
Expand All @@ -773,7 +771,7 @@ class BrnInfoModal {
clickValue,
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: themeData.linkTextStyle?.generateTextStyle(),
style: themeData.linkTextStyle.generateTextStyle(),
),
)
],
Expand All @@ -782,11 +780,11 @@ class BrnInfoModal {
valueWidget = BrnRichTextGenerator()
.addText(
valueTitle,
textStyle: themeData.valueTextStyle?.generateTextStyle(),
textStyle: themeData.valueTextStyle.generateTextStyle(),
)
.addTextWithLink(
clickValue,
textStyle: themeData.linkTextStyle?.generateTextStyle(),
textStyle: themeData.linkTextStyle.generateTextStyle(),
richTextLinkClick: (text, url) {
if (clickCallback != null) {
clickCallback(text);
Expand Down Expand Up @@ -849,7 +847,7 @@ class BrnInfoModal {

if (isArrow) {
MediaQueryData mediaQuery = MediaQueryData.fromWindow(ui.window);
double screen = mediaQuery?.size?.width ?? 375;
double screen = mediaQuery.size.width;

if (keyShow) {
keyWidget = Container(
Expand All @@ -863,7 +861,7 @@ class BrnInfoModal {
keyTitle,
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: themeData.keyTextStyle?.generateTextStyle(),
style: themeData.keyTextStyle.generateTextStyle(),
),
),
GestureDetector(
Expand All @@ -878,7 +876,7 @@ class BrnInfoModal {
':',
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: themeData.valueTextStyle?.generateTextStyle(),
style: themeData.valueTextStyle.generateTextStyle(),
)
],
),
Expand All @@ -896,7 +894,7 @@ class BrnInfoModal {
valueTitle,
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: themeData.keyTextStyle?.generateTextStyle(),
style: themeData.keyTextStyle.generateTextStyle(),
),
),
GestureDetector(
Expand All @@ -915,7 +913,7 @@ class BrnInfoModal {
} else {
BrnRichTextGenerator keyGen = BrnRichTextGenerator();
keyGen.addText(keyTitle,
textStyle: themeData.keyTextStyle?.generateTextStyle());
textStyle: themeData.keyTextStyle.generateTextStyle());
if (keyShow) {
keyGen.addIcon(GestureDetector(
onTap: () {
Expand All @@ -926,13 +924,13 @@ class BrnInfoModal {
child: BrunoTools.getAssetImage(BrnAsset.iconQuestion),
));
keyGen.addText(':',
textStyle: themeData.keyTextStyle?.generateTextStyle());
textStyle: themeData.keyTextStyle.generateTextStyle());
}
keyWidget = keyGen.build();

BrnRichTextGenerator valueGen = BrnRichTextGenerator();
valueGen.addText(valueTitle,
textStyle: themeData.valueTextStyle?.generateTextStyle());
textStyle: themeData.valueTextStyle.generateTextStyle());
if (valueShow) {
valueGen.addIcon(GestureDetector(
onTap: () {
Expand Down Expand Up @@ -1002,7 +1000,7 @@ class BrnInfoModal {
}

keyGen.addText(keyTitle,
textStyle: themeData.keyTextStyle?.generateTextStyle());
textStyle: themeData.keyTextStyle.generateTextStyle());

return BrnInfoModal(
keyPart: keyGen.build(),
Expand Down Expand Up @@ -1043,7 +1041,7 @@ class BrnInfoModal {
maxLines: isArrow ? 1 : null,
textOverflow:
isArrow ? TextOverflow.ellipsis : TextOverflow.clip,
defaultStyle: themeData.valueTextStyle?.generateTextStyle(),
defaultStyle: themeData.valueTextStyle.generateTextStyle(),
linksCallback: (text, url) {
if (richTextLinkClick != null) {
richTextLinkClick(text, url);
Expand Down