improvement: add trending user repo

This commit is contained in:
Rongjian Zhang 2020-01-02 13:56:50 +08:00
parent 12d542c4f3
commit 7689ac06c6
6 changed files with 57 additions and 52 deletions

View File

@ -227,7 +227,7 @@ class GithubTrendingUser {
@JsonSerializable()
class GithubTrendingUserRepo {
String username;
String name;
String description;
GithubTrendingUserRepo();

View File

@ -268,13 +268,13 @@ Map<String, dynamic> _$GithubTrendingUserToJson(GithubTrendingUser instance) =>
GithubTrendingUserRepo _$GithubTrendingUserRepoFromJson(
Map<String, dynamic> json) {
return GithubTrendingUserRepo()
..username = json['username'] as String
..name = json['name'] as String
..description = json['description'] as String;
}
Map<String, dynamic> _$GithubTrendingUserRepoToJson(
GithubTrendingUserRepo instance) =>
<String, dynamic>{
'username': instance.username,
'name': instance.name,
'description': instance.description,
};

View File

@ -46,6 +46,13 @@ class TrendingScreen extends StatelessWidget {
login: item.username,
name: item.name,
avatarUrl: item.avatar,
bio: Row(
children: <Widget>[
Icon(Octicons.repo, size: 17),
SizedBox(width: 2),
Text(item.repo.name, style: TextStyle(fontSize: 17))
],
),
);
default:
throw '';

View File

@ -179,7 +179,9 @@ class UserScreen extends StatelessWidget {
url: '/$login?tab=following',
),
]),
CommonStyle.border,
CommonStyle.verticalGap,
CommonStyle.border,
Container(
color: theme.palette.background,
padding: CommonStyle.padding,
@ -212,7 +214,9 @@ class UserScreen extends StatelessWidget {
),
),
),
CommonStyle.border,
CommonStyle.verticalGap,
CommonStyle.border,
TableView(
hasIcon: true,
items: [

View File

@ -6,7 +6,6 @@ import 'package:git_touch/utils/utils.dart';
import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/user_item.dart';
import 'package:git_touch/models/auth.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
enum UsersScreenType {

View File

@ -17,69 +17,64 @@ class UserItem extends StatelessWidget {
final String name;
final String avatarUrl;
final Widget bio;
final bool inUserScreen;
UserItem({
this.login,
this.name,
this.avatarUrl,
this.bio,
this.inUserScreen = false,
});
@override
Widget build(BuildContext context) {
final theme = Provider.of<ThemeModel>(context);
final widget = Container(
padding: CommonStyle.padding,
child: Row(
children: <Widget>[
Avatar(url: avatarUrl, size: AvatarSize.large),
SizedBox(width: 10),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: <Widget>[
Text(
name ?? login,
style: TextStyle(
color: theme.palette.primary,
fontSize: 17,
fontWeight: FontWeight.w500,
return Link(
url: '/$login',
child: Container(
padding: CommonStyle.padding,
child: Row(
children: <Widget>[
Avatar(url: avatarUrl, size: AvatarSize.large),
SizedBox(width: 10),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: <Widget>[
Text(
name ?? login,
style: TextStyle(
color: theme.palette.primary,
fontSize: 17,
fontWeight: FontWeight.w500,
),
),
),
SizedBox(width: 4),
Text(
'($login)',
style: TextStyle(
color: theme.palette.secondaryText, fontSize: 16),
),
],
),
SizedBox(height: 6),
if (bio != null)
DefaultTextStyle(
style: TextStyle(
color: theme.palette.secondaryText,
fontSize: 15,
),
child: bio,
SizedBox(width: 4),
Text(
'($login)',
style: TextStyle(
color: theme.palette.secondaryText, fontSize: 16),
),
],
),
],
),
)
],
SizedBox(height: 6),
if (bio != null)
DefaultTextStyle(
style: TextStyle(
color: theme.palette.secondaryText,
fontSize: 15,
),
child: bio,
),
],
),
)
],
),
),
);
if (inUserScreen) {
return widget;
} else {
return Link(url: '/$login', child: widget);
}
}
}