mirror of
https://github.com/git-touch/git-touch
synced 2025-01-18 18:29:59 +01:00
refactor: using github-trending-api instead of parsing html
This commit is contained in:
parent
46e380c10d
commit
1c768c6ca3
@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:github_trending/github_trending.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import '../scaffolds/refresh.dart';
|
||||
import '../widgets/repo_item.dart';
|
||||
|
||||
@ -10,26 +11,27 @@ class TrendingScreen extends StatefulWidget {
|
||||
|
||||
class _TrendingScreenState extends State<TrendingScreen> {
|
||||
Future<List<dynamic>> _fetchTrendingRepos() async {
|
||||
var items = await getTrendingRepositories();
|
||||
var res = await http.get('https://github-trending-api.now.sh');
|
||||
var items = json.decode(res.body);
|
||||
|
||||
return items.map((item) {
|
||||
return {
|
||||
'owner': {
|
||||
'login': item.owner,
|
||||
'login': item['author'],
|
||||
},
|
||||
'name': item.name,
|
||||
'description': item.description,
|
||||
'name': item['name'],
|
||||
'description': item['description'],
|
||||
'stargazers': {
|
||||
'totalCount': item.starCount,
|
||||
'totalCount': item['stars'],
|
||||
},
|
||||
'forks': {
|
||||
'totalCount': item.forkCount,
|
||||
'totalCount': item['forks'],
|
||||
},
|
||||
'primaryLanguage': item.primaryLanguage == null
|
||||
'primaryLanguage': item['language'] == null
|
||||
? null
|
||||
: {
|
||||
'name': item.primaryLanguage.name,
|
||||
'color': item.primaryLanguage.color,
|
||||
'name': item['language'],
|
||||
'color': item['languageColor'],
|
||||
},
|
||||
'isPrivate': false,
|
||||
'isFork': false // TODO:
|
||||
|
@ -26,7 +26,6 @@ dependencies:
|
||||
nanoid: ^0.0.6
|
||||
share: ^0.6.0
|
||||
flutter_vector_icons: ^0.0.2
|
||||
github_trending: ^0.1.2
|
||||
github_contributions: ^0.1.1
|
||||
flutter_svg: ^0.13.0
|
||||
launch_review: ^2.0.0
|
||||
|
Loading…
Reference in New Issue
Block a user