1
0
mirror of https://github.com/git-touch/git-touch synced 2025-02-15 19:10:45 +01:00

84 lines
3.2 KiB
Dart
Raw Normal View History

2019-03-02 18:17:46 +08:00
import 'package:flutter/material.dart';
2020-01-12 16:18:37 +08:00
import 'package:git_touch/models/theme.dart';
2019-09-25 17:06:36 +08:00
import 'package:git_touch/scaffolds/tab_stateful.dart';
2019-09-08 21:20:12 +08:00
import 'package:git_touch/utils/utils.dart';
2019-09-11 19:59:47 +08:00
import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/link.dart';
2019-09-24 20:45:55 +08:00
import 'package:git_touch/widgets/user_item.dart';
2020-02-09 17:57:12 +08:00
import 'package:github_trending/github_trending.dart';
2019-09-23 18:28:33 +08:00
import 'package:git_touch/widgets/repository_item.dart';
2020-01-12 16:18:37 +08:00
import 'package:provider/provider.dart';
2019-03-02 18:17:46 +08:00
2020-02-07 14:17:05 +08:00
class GhTrendingScreen extends StatelessWidget {
2019-03-02 18:17:46 +08:00
Widget build(BuildContext context) {
2020-02-09 17:57:12 +08:00
return TabStatefulScaffold<List>(
2019-09-11 19:59:47 +08:00
title: AppBarTitle('Trending'),
2019-12-30 20:55:56 +08:00
tabs: ['Repositories', 'Developers'],
2019-09-30 17:37:51 +08:00
fetchData: (tabIndex) async {
2020-02-09 17:57:12 +08:00
if (tabIndex == 0) {
return getTrendingRepositories();
} else {
return getTrendingDevelopers();
}
},
2019-09-24 20:45:55 +08:00
bodyBuilder: (payload, activeTab) {
2020-01-12 16:18:37 +08:00
final theme = Provider.of<ThemeModel>(context);
2019-03-02 18:17:46 +08:00
return Column(
2019-09-08 21:20:12 +08:00
crossAxisAlignment: CrossAxisAlignment.stretch,
children: join(
2019-10-02 16:09:54 +08:00
CommonStyle.border,
2020-02-09 17:57:12 +08:00
activeTab == 0
? [
for (var v in payload.cast<GithubTrendingRepository>())
RepositoryItem.gh(
owner: v.author,
avatarUrl: v.avatar,
name: v.name,
description: v.description,
starCount: v.stars ?? 0,
forkCount: v.forks ?? 0,
primaryLanguageName: v.language,
primaryLanguageColor: v.languageColor,
note: '${v.currentPeriodStars} stars today',
isPrivate: false,
isFork: false, // TODO:
)
]
: [
for (var v in payload.cast<GithubTrendingDeveloper>())
UserItem.gh(
login: v.username,
// name: v.name,
avatarUrl: v.avatar,
bio: Link(
url: '/${v.username}/${v.repo.name}',
child: Row(
children: <Widget>[
Icon(
Octicons.repo,
size: 17,
color: theme.palette.secondaryText,
),
SizedBox(width: 4),
2020-02-13 18:46:07 +09:00
Expanded(
child: Text(
'${v.username} / ${v.repo.name}',
style: TextStyle(
fontSize: 17,
color: theme.palette.secondaryText,
),
overflow: TextOverflow.ellipsis,
)
2020-02-09 17:57:12 +08:00
)
],
),
2020-02-09 17:57:12 +08:00
),
)
],
2019-09-08 21:20:12 +08:00
),
2019-03-02 18:17:46 +08:00
);
},
);
}
}