chore: style tweaks

This commit is contained in:
Rongjian Zhang 2022-10-09 02:52:20 +08:00
parent e2de7feec2
commit 06a96a14be
3 changed files with 114 additions and 138 deletions

View File

@ -141,113 +141,105 @@ class RepoItem extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = AntTheme.of(context); final theme = AntTheme.of(context);
const bottomGap = SizedBox(width: 4);
return AntListItem( return AntListItem(
arrow: null, arrow: null,
onClick: () { onClick: () {
context.pushUrl(url); context.pushUrl(url);
}, },
child: DefaultTextStyle( child: Column(
style: const TextStyle(height: null), crossAxisAlignment: CrossAxisAlignment.start,
child: Column( children: <Widget>[
crossAxisAlignment: CrossAxisAlignment.start, Row(
children: <Widget>[ children: <Widget>[
Row( Avatar(
children: <Widget>[ url: avatarUrl,
Avatar( size: AvatarSize.small,
url: avatarUrl, linkUrl: avatarLink,
size: AvatarSize.small, ),
linkUrl: avatarLink, Expanded(
), child: Text.rich(
Expanded( TextSpan(children: [
child: Text.rich( TextSpan(
TextSpan(children: [ text: '$owner / ',
TextSpan( style: TextStyle(
text: '$owner / ', height: 1, fontSize: 18, color: theme.colorPrimary),
style: TextStyle( ),
height: 1, fontSize: 18, color: theme.colorPrimary), TextSpan(
text: name,
style: TextStyle(
height: 1,
fontSize: 18,
color: theme.colorPrimary,
fontWeight: FontWeight.w600,
// overflow: TextOverflow.ellipsis,
), ),
TextSpan( ),
text: name, ]),
style: TextStyle( overflow: TextOverflow.ellipsis,
height: 1,
fontSize: 18,
color: theme.colorPrimary,
fontWeight: FontWeight.w600,
// overflow: TextOverflow.ellipsis,
),
),
]),
overflow: TextOverflow.ellipsis,
),
),
if (iconData != null)
DefaultTextStyle(
style: TextStyle(color: theme.colorTextSecondary),
child: Icon(iconData,
size: 18, color: theme.colorTextSecondary),
),
].withSeparator(const SizedBox(width: 8)),
),
if (description != null && description!.isNotEmpty)
Text(
description!,
style: TextStyle(
color: theme.colorTextSecondary,
fontSize: 16,
leadingDistribution: TextLeadingDistribution.even,
), ),
), ),
if (note != null) if (iconData != null)
Text(note!, DefaultTextStyle(
style: TextStyle(fontSize: 14, color: theme.colorWeak)), style: TextStyle(color: theme.colorTextSecondary),
DefaultTextStyle( child:
style: TextStyle(color: theme.colorText, fontSize: 14), Icon(iconData, size: 18, color: theme.colorTextSecondary),
child: Row( ),
children: <Widget>[ ].withSeparator(const SizedBox(width: 8)),
if (primaryLanguageName != null) ...[ ),
Row( if (description != null && description!.isNotEmpty)
children: [ Text(
Container( description!,
width: 12, style: TextStyle(color: theme.colorTextSecondary, fontSize: 16),
height: 12, ),
decoration: BoxDecoration( if (note != null)
color: fromCssColor(primaryLanguageColor ?? Text(note!, style: TextStyle(fontSize: 14, color: theme.colorWeak)),
github.languageColors[primaryLanguageName!]!), Builder(builder: (context) {
shape: BoxShape.circle, return DefaultTextStyle(
style: DefaultTextStyle.of(context).style.copyWith(fontSize: 14),
child: IconTheme(
data: IconThemeData(size: 14, color: theme.colorText),
child: Row(
children: <Widget>[
if (primaryLanguageName != null)
Row(
children: [
Container(
width: 12,
height: 12,
decoration: BoxDecoration(
color: fromCssColor(primaryLanguageColor ??
github.languageColors[primaryLanguageName!]!),
shape: BoxShape.circle,
),
), ),
), bottomGap,
const SizedBox(width: 4), Text(primaryLanguageName!),
Text( ],
primaryLanguageName!, ),
overflow: TextOverflow.ellipsis, if (starCount! > 0)
), Row(
], children: [
), const Icon(Octicons.star),
], bottomGap,
if (starCount! > 0) Text(numberFormat.format(starCount)),
Row( ],
children: [ ),
Icon(Octicons.star, size: 14, color: theme.colorText), if (forkCount! > 0)
const SizedBox(width: 2), Row(
Text(numberFormat.format(starCount)), children: [
], const Icon(Octicons.repo_forked),
), bottomGap,
if (forkCount! > 0) ...[ Text(numberFormat.format(forkCount)),
Row( ],
children: [ ),
Icon(Octicons.repo_forked, ].withSeparator(const SizedBox(width: 24)),
size: 14, color: theme.colorText), ),
const SizedBox(width: 2),
Text(numberFormat.format(forkCount)),
],
),
],
].withSeparator(const SizedBox(width: 24)),
), ),
), );
].withSeparator(const SizedBox(height: 10)), }),
), ].withSeparator(const SizedBox(height: 8)),
), ),
); );
} }

View File

@ -51,8 +51,7 @@ class UserHeader extends StatelessWidget {
] ]
], ],
), ),
const SizedBox(height: 8), if (name != null && name!.isNotEmpty)
if (name != null && name!.isNotEmpty) ...[
Text( Text(
name!, name!,
style: TextStyle( style: TextStyle(
@ -61,16 +60,11 @@ class UserHeader extends StatelessWidget {
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
), ),
), ),
const SizedBox(height: 4),
],
Text( Text(
login!, login!,
style: TextStyle( style: TextStyle(
color: AntTheme.of(context).colorPrimary, color: AntTheme.of(context).colorPrimary, fontSize: 18),
fontSize: 18,
),
), ),
const SizedBox(height: 8),
if (createdAt != null) if (createdAt != null)
Row( Row(
children: <Widget>[ children: <Widget>[
@ -83,14 +77,11 @@ class UserHeader extends StatelessWidget {
Text( Text(
'Joined on ${dateFormat.format(createdAt!)}', 'Joined on ${dateFormat.format(createdAt!)}',
style: TextStyle( style: TextStyle(
color: AntTheme.of(context).colorWeak, color: AntTheme.of(context).colorWeak, fontSize: 16),
fontSize: 16,
),
), ),
], ],
), ),
if (bio != null && bio!.isNotEmpty) ...[ if (bio != null && bio!.isNotEmpty)
const SizedBox(height: 10),
Text( Text(
bio!, bio!,
style: TextStyle( style: TextStyle(
@ -98,8 +89,7 @@ class UserHeader extends StatelessWidget {
fontSize: 17, fontSize: 17,
), ),
) )
] ].withSeparator(const SizedBox(height: 8)),
],
), ),
); );
} }

View File

@ -19,13 +19,15 @@ class GhBioWidget extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = AntTheme.of(context);
if (location != null) { if (location != null) {
return Row( return Row(
children: <Widget>[ children: <Widget>[
Icon( Icon(
Octicons.location, Octicons.location,
size: 15, size: 15,
color: AntTheme.of(context).colorTextSecondary, color: theme.colorTextSecondary,
), ),
const SizedBox(width: 4), const SizedBox(width: 4),
Expanded(child: Text(location!, overflow: TextOverflow.ellipsis)), Expanded(child: Text(location!, overflow: TextOverflow.ellipsis)),
@ -37,7 +39,7 @@ class GhBioWidget extends StatelessWidget {
Icon( Icon(
Octicons.clock, Octicons.clock,
size: 15, size: 15,
color: AntTheme.of(context).colorTextSecondary, color: theme.colorTextSecondary,
), ),
const SizedBox(width: 4), const SizedBox(width: 4),
Expanded( Expanded(
@ -121,6 +123,8 @@ class UserItem extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = AntTheme.of(context);
return AntListItem( return AntListItem(
onClick: () { onClick: () {
context.pushUrl(url); context.pushUrl(url);
@ -128,48 +132,38 @@ class UserItem extends StatelessWidget {
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
Avatar(url: avatarUrl, size: AvatarSize.large), Avatar(url: avatarUrl, size: AvatarSize.large),
const SizedBox(width: 10), const SizedBox(width: 12),
Expanded( Expanded(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Row( Row(
textBaseline: TextBaseline.alphabetic, children: [
crossAxisAlignment: CrossAxisAlignment.baseline, if (name != null)
children: <Widget>[
if (name != null && name!.isNotEmpty) ...[
Text( Text(
name!, name!,
style: TextStyle( style: const TextStyle(
color: AntTheme.of(context).colorText, fontSize: 18, fontWeight: FontWeight.w500),
fontSize: 18,
fontWeight: FontWeight.w500,
),
), ),
const SizedBox(width: 8),
],
Expanded( Expanded(
child: Text( child: Text(
login!, login!,
style: TextStyle( style:
color: AntTheme.of(context).colorText, TextStyle(fontSize: 16, color: theme.colorPrimary),
fontSize: 16,
),
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
), ),
], ].withSeparator(const SizedBox(width: 8)),
), ),
const SizedBox(height: 6),
if (bio != null) if (bio != null)
DefaultTextStyle( Builder(builder: (context) {
style: TextStyle( return DefaultTextStyle(
color: AntTheme.of(context).colorTextSecondary, style: DefaultTextStyle.of(context).style.copyWith(
fontSize: 16, color: theme.colorTextSecondary, fontSize: 16),
), child: bio!,
child: bio!, );
), }),
], ],
), ),
) )