diff --git a/lib/screens/gh_user.dart b/lib/screens/gh_user.dart index 1f946b0..275a13e 100644 --- a/lib/screens/gh_user.dart +++ b/lib/screens/gh_user.dart @@ -75,11 +75,6 @@ class _User extends StatelessWidget { CommonStyle.border, Row( children: [ - EntryItem( - count: p.sponsors.totalCount, - text: 'Sponsors', - url: 'https://github.com/sponsors/${p.login}', - ), EntryItem( count: p.followers.totalCount, text: AppLocalizations.of(context)!.followers, @@ -156,33 +151,86 @@ class _User extends StatelessWidget { ], ), CommonStyle.verticalGap, - if (p.organizations.totalCount > 0) - AntList( - header: Text( - '${AppLocalizations.of(context)!.organizations} (${p.organizations.totalCount})', - ), - children: [ - AntListItem( - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Wrap( - spacing: 8, - children: [ - for (final org in p.organizations.nodes!) - Avatar( - isOrg: true, - url: org.avatarUrl, - linkUrl: '/github/${org.login}', - ), - ], - ), - ), + AntList(children: [ + if (p.sponsors.totalCount > 0) + AntListItem( + prefix: const Icon(Octicons.heart_fill), + extra: Text(p.sponsors.totalCount.toString()), + child: Row( + children: [ + const Text('Sponsors'), + const Spacer(), + for (final sponsor in p.sponsors.nodes!) ...[ + const SizedBox(width: 6), + Avatar( + isOrg: sponsor.G__typename != 'User', + url: sponsor.G__typename == 'User' + ? (sponsor as GUserData_user_sponsors_nodes__asUser) + .avatarUrl + : (sponsor + as GUserParts_sponsors_nodes__asOrganization) + .avatarUrl, + size: AvatarSize.small, + ), + ], + ], ), - ], - ), + onClick: () { + context.goNamed('/github/${p.login}?tab=sponsors'); + }, + ), + if (p.sponsoring.totalCount > 0) + AntListItem( + prefix: const Icon(Octicons.heart), + extra: Text(p.sponsoring.totalCount.toString()), + child: Row( + children: [ + const Text('Sponsoring'), + const Spacer(), + for (final sponsor in p.sponsoring.nodes!) ...[ + const SizedBox(width: 6), + Avatar( + isOrg: sponsor.G__typename != 'User', + url: sponsor.G__typename == 'User' + ? (sponsor as GUserData_user_sponsoring_nodes__asUser) + .avatarUrl + : (sponsor + as GUserParts_sponsoring_nodes__asOrganization) + .avatarUrl, + size: AvatarSize.small, + ), + ], + ], + ), + onClick: () { + context.goNamed('/github/${p.login}?tab=sponsoring'); + }, + ), + if (p.organizations.totalCount > 0) + AntListItem( + prefix: const Icon(Octicons.organization), + extra: Text(p.organizations.totalCount.toString()), + child: Row( + children: [ + Text(AppLocalizations.of(context)!.organizations), + const Spacer(), + for (final org in p.organizations.nodes!) ...[ + const SizedBox(width: 6), + Avatar( + isOrg: true, + url: org.avatarUrl, + size: AvatarSize.small, + ), + ], + ], + ), + onClick: () { + context.pushUrl('/github/${p.login}?tab=organizations'); + }, + ), + ]), CommonStyle.verticalGap, AntList( - header: const Text('Overview'), children: [ AntListItem( prefix: const Icon(Octicons.repo), diff --git a/lib/widgets/avatar.dart b/lib/widgets/avatar.dart index 85aa6f9..81dd62f 100644 --- a/lib/widgets/avatar.dart +++ b/lib/widgets/avatar.dart @@ -35,7 +35,7 @@ class Avatar extends StatelessWidget { final fallbackWidget = Image.asset(fallback, width: size, height: size); final widget = ClipRRect( - borderRadius: BorderRadius.circular(isOrg ? 6 : size), + borderRadius: BorderRadius.circular(isOrg ? 4 : size), child: url == null ? fallbackWidget : FadeInImage.assetNetwork( diff --git a/packages/gql_github/lib/user.graphql b/packages/gql_github/lib/user.graphql index 173f448..fd3824f 100644 --- a/packages/gql_github/lib/user.graphql +++ b/packages/gql_github/lib/user.graphql @@ -33,9 +33,6 @@ fragment UserParts on User { twitterUsername viewerCanFollow # TODO: remove in viewer query viewerIsFollowing - sponsors { - totalCount - } followers { totalCount } @@ -51,10 +48,33 @@ fragment UserParts on User { } } } - organizations(first: 10) { + sponsors(first: 3) { + totalCount + nodes { + __typename + ... on User { + avatarUrl + } + ... on Organization { + avatarUrl + } + } + } + sponsoring(first: 3) { + totalCount + nodes { + __typename + ... on User { + avatarUrl + } + ... on Organization { + avatarUrl + } + } + } + organizations(first: 3) { totalCount nodes { - login avatarUrl } }