mirror of
https://github.com/git-touch/git-touch
synced 2025-01-31 08:04:51 +01:00
chore: remove unused files
This commit is contained in:
parent
e6a6b026f6
commit
ec4f22ab82
@ -20,7 +20,7 @@ class ListPayload<T, K> {
|
||||
// This is a scaffold for infinite scroll screens
|
||||
class ListStatefulScaffold<T, K> extends StatefulWidget {
|
||||
final Widget title;
|
||||
final Widget Function() trailingBuiler;
|
||||
final Widget Function() actionBuilder;
|
||||
final Widget Function(T payload) itemBuilder;
|
||||
final Future<ListPayload<T, K>> Function() onRefresh;
|
||||
final Future<ListPayload<T, K>> Function(K cursor) onLoadMore;
|
||||
@ -30,7 +30,7 @@ class ListStatefulScaffold<T, K> extends StatefulWidget {
|
||||
@required this.itemBuilder,
|
||||
@required this.onRefresh,
|
||||
@required this.onLoadMore,
|
||||
this.trailingBuiler,
|
||||
this.actionBuilder,
|
||||
});
|
||||
|
||||
@override
|
||||
@ -210,7 +210,7 @@ class _ListStatefulScaffoldState<T, K>
|
||||
return CommonScaffold(
|
||||
title: widget.title,
|
||||
body: _buildBody(),
|
||||
action: widget.trailingBuiler == null ? null : widget.trailingBuiler(),
|
||||
action: widget.actionBuilder == null ? null : widget.actionBuilder(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ class _RefreshStatefulScaffoldState<T>
|
||||
}
|
||||
}
|
||||
|
||||
Widget get _trailing {
|
||||
Widget get _action {
|
||||
if (widget.actionBuilder == null) return null;
|
||||
return widget.actionBuilder(_payload);
|
||||
}
|
||||
@ -86,7 +86,7 @@ class _RefreshStatefulScaffoldState<T>
|
||||
reload: _refresh,
|
||||
),
|
||||
),
|
||||
action: _trailing,
|
||||
action: _action,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import 'package:provider/provider.dart';
|
||||
class TabScaffold extends StatelessWidget {
|
||||
final Widget title;
|
||||
final Widget body;
|
||||
final Widget trailing;
|
||||
final Widget action;
|
||||
final void Function() onRefresh;
|
||||
final List<String> tabs;
|
||||
final int activeTab;
|
||||
@ -17,7 +17,7 @@ class TabScaffold extends StatelessWidget {
|
||||
TabScaffold({
|
||||
@required this.title,
|
||||
@required this.body,
|
||||
this.trailing,
|
||||
this.action,
|
||||
@required this.onRefresh,
|
||||
@required this.tabs,
|
||||
@required this.activeTab,
|
||||
@ -50,7 +50,7 @@ class TabScaffold extends StatelessWidget {
|
||||
final scaffold = CommonScaffold(
|
||||
title: _buildTitle(context),
|
||||
body: RefreshWrapper(body: body, onRefresh: onRefresh),
|
||||
action: trailing,
|
||||
action: action,
|
||||
bottom: TabBar(
|
||||
onTap: onTabSwitch,
|
||||
tabs: tabs.map((text) => Tab(text: text.toUpperCase())).toList(),
|
||||
|
@ -99,7 +99,7 @@ class _TabStatefulScaffoldState<T> extends State<TabStatefulScaffold<T>> {
|
||||
Widget build(BuildContext context) {
|
||||
return TabScaffold(
|
||||
title: widget.title,
|
||||
trailing: widget.actionBuilder == null
|
||||
action: widget.actionBuilder == null
|
||||
? null
|
||||
: widget.actionBuilder(_payload, _refresh),
|
||||
tabs: widget.tabs,
|
||||
|
@ -1,101 +0,0 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/scaffolds/tab.dart';
|
||||
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:http/http.dart' as http;
|
||||
import 'package:git_touch/widgets/repository_item.dart';
|
||||
|
||||
class TrendingScreen extends StatefulWidget {
|
||||
@override
|
||||
_TrendingScreenState createState() => _TrendingScreenState();
|
||||
}
|
||||
|
||||
class _TrendingScreenState extends State<TrendingScreen> {
|
||||
int _activeTab;
|
||||
List _repoItems;
|
||||
List _userItems;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_refresh();
|
||||
}
|
||||
|
||||
Uri get _uri => Uri.parse('https://github-trending-api.now.sh')
|
||||
.resolve(_activeTab == 1 ? '/developers' : '/');
|
||||
|
||||
Iterable<Widget> _buildItems() {
|
||||
switch (_activeTab) {
|
||||
case 0:
|
||||
return _userItems?.map((item) => UserItem(
|
||||
login: item['username'],
|
||||
name: item['name'],
|
||||
avatarUrl: item['avatar'],
|
||||
bio: '',
|
||||
));
|
||||
case 1:
|
||||
default:
|
||||
return _repoItems?.map((item) => RepositoryItem(item));
|
||||
}
|
||||
}
|
||||
|
||||
_refresh() async {
|
||||
var res = await http.get(_uri);
|
||||
var items = json.decode(res.body) as List;
|
||||
setState(() {
|
||||
switch (_activeTab) {
|
||||
case 0:
|
||||
_repoItems = items
|
||||
.map((item) => {
|
||||
'owner': {
|
||||
'login': item['author'],
|
||||
'avatarUrl': item['avatar']
|
||||
},
|
||||
'name': item['name'],
|
||||
'description': item['description'],
|
||||
'stargazers': {
|
||||
'totalCount': item['stars'],
|
||||
},
|
||||
'forks': {
|
||||
'totalCount': item['forks'],
|
||||
},
|
||||
'primaryLanguage': item['language'] == null
|
||||
? null
|
||||
: {
|
||||
'name': item['language'],
|
||||
'color': item['languageColor'],
|
||||
},
|
||||
'isPrivate': false,
|
||||
'isFork': false // TODO:
|
||||
})
|
||||
.toList();
|
||||
break;
|
||||
case 1:
|
||||
_userItems = items;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return TabScaffold(
|
||||
title: AppBarTitle('Trending'),
|
||||
tabs: ['Repositories', 'Users'],
|
||||
onRefresh: _refresh,
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: join(CommonStyle.border, _buildItems()).toList(),
|
||||
),
|
||||
activeTab: _activeTab,
|
||||
onTabSwitch: (int index) {
|
||||
setState(() {
|
||||
_activeTab = index;
|
||||
_refresh();
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user