2022-09-24 20:46:37 +02:00
|
|
|
import 'package:antd_mobile/antd_mobile.dart';
|
2022-09-17 14:35:45 +02:00
|
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/S.dart';
|
2019-09-25 11:06:36 +02:00
|
|
|
import 'package:git_touch/scaffolds/tab_stateful.dart';
|
2019-09-08 15:20:12 +02:00
|
|
|
import 'package:git_touch/utils/utils.dart';
|
2019-09-11 13:59:47 +02:00
|
|
|
import 'package:git_touch/widgets/app_bar_title.dart';
|
2020-02-08 08:11:17 +01:00
|
|
|
import 'package:git_touch/widgets/link.dart';
|
2022-10-02 06:49:55 +02:00
|
|
|
import 'package:git_touch/widgets/repo_item.dart';
|
2019-09-24 14:45:55 +02:00
|
|
|
import 'package:git_touch/widgets/user_item.dart';
|
2020-02-09 10:57:12 +01:00
|
|
|
import 'package:github_trending/github_trending.dart';
|
2019-03-02 11:17:46 +01:00
|
|
|
|
2020-02-07 07:17:05 +01:00
|
|
|
class GhTrendingScreen extends StatelessWidget {
|
2020-10-06 15:59:29 +02:00
|
|
|
static final trending = GithubTrending(prefix: 'https://gtrend.yapie.me');
|
|
|
|
|
2022-09-06 18:28:12 +02:00
|
|
|
@override
|
2019-03-02 11:17:46 +01:00
|
|
|
Widget build(BuildContext context) {
|
2020-02-09 10:57:12 +01:00
|
|
|
return TabStatefulScaffold<List>(
|
2021-05-16 09:16:35 +02:00
|
|
|
title: AppBarTitle(AppLocalizations.of(context)!.trending),
|
2021-02-03 05:04:41 +01:00
|
|
|
tabs: [
|
2021-05-16 09:16:35 +02:00
|
|
|
AppLocalizations.of(context)!.repositories,
|
|
|
|
AppLocalizations.of(context)!.developers
|
2021-02-03 05:04:41 +01:00
|
|
|
],
|
2019-09-30 11:37:51 +02:00
|
|
|
fetchData: (tabIndex) async {
|
2020-02-09 10:57:12 +01:00
|
|
|
if (tabIndex == 0) {
|
2020-10-06 15:59:29 +02:00
|
|
|
return trending.getTrendingRepositories();
|
2020-02-09 10:57:12 +01:00
|
|
|
} else {
|
2020-10-06 15:59:29 +02:00
|
|
|
return trending.getTrendingDevelopers();
|
2020-02-09 10:57:12 +01:00
|
|
|
}
|
2019-09-23 19:46:50 +02:00
|
|
|
},
|
2019-09-24 14:45:55 +02:00
|
|
|
bodyBuilder: (payload, activeTab) {
|
2019-03-02 11:17:46 +01:00
|
|
|
return Column(
|
2019-09-08 15:20:12 +02:00
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: join(
|
2019-10-02 10:09:54 +02:00
|
|
|
CommonStyle.border,
|
2020-02-09 10:57:12 +01:00
|
|
|
activeTab == 0
|
|
|
|
? [
|
|
|
|
for (var v in payload.cast<GithubTrendingRepository>())
|
2022-10-02 06:49:55 +02:00
|
|
|
RepoItem.gh(
|
2020-02-09 10:57:12 +01:00
|
|
|
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>())
|
2020-10-08 09:55:26 +02:00
|
|
|
UserItem.github(
|
2020-02-09 10:57:12 +01:00
|
|
|
login: v.username,
|
2020-10-08 09:55:26 +02:00
|
|
|
name: v.name,
|
2020-02-09 10:57:12 +01:00
|
|
|
avatarUrl: v.avatar,
|
2020-10-03 08:26:01 +02:00
|
|
|
bio: v.repo == null
|
|
|
|
? null
|
2021-05-16 09:16:35 +02:00
|
|
|
: LinkWidget(
|
|
|
|
url: '/github/${v.username}/${v.repo!.name}',
|
2020-10-03 08:26:01 +02:00
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Icon(
|
|
|
|
Octicons.repo,
|
|
|
|
size: 17,
|
2022-09-24 20:46:37 +02:00
|
|
|
color: AntTheme.of(context)
|
|
|
|
.colorTextSecondary,
|
2020-10-03 08:26:01 +02:00
|
|
|
),
|
2022-09-06 18:28:12 +02:00
|
|
|
const SizedBox(width: 4),
|
2020-10-03 08:26:01 +02:00
|
|
|
Expanded(
|
|
|
|
child: Text(
|
2021-05-16 09:16:35 +02:00
|
|
|
'${v.username} / ${v.repo!.name}',
|
2020-10-03 08:26:01 +02:00
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 17,
|
2022-09-24 20:46:37 +02:00
|
|
|
color: AntTheme.of(context)
|
|
|
|
.colorTextSecondary,
|
2020-10-03 08:26:01 +02:00
|
|
|
),
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
))
|
|
|
|
],
|
2020-04-16 05:36:48 +02:00
|
|
|
),
|
2020-10-03 08:26:01 +02:00
|
|
|
),
|
2020-02-09 10:57:12 +01:00
|
|
|
)
|
|
|
|
],
|
2019-09-08 15:20:12 +02:00
|
|
|
),
|
2019-03-02 11:17:46 +01:00
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|