Skip to content

Commit

Permalink
fix: long list at material theme
Browse files Browse the repository at this point in the history
  • Loading branch information
pd4d10 committed Feb 10, 2019
1 parent d9bec75 commit ce11da3
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 28 deletions.
14 changes: 6 additions & 8 deletions lib/providers/settings.dart
Expand Up @@ -146,7 +146,7 @@ class _SettingsProviderState extends State<SettingsProvider> {
SharedPreferences prefs = await SharedPreferences.getInstance();
var githubData = json.encode(githubAccountMap
.map((login, account) => MapEntry(login, account.toJson())));
print('write github: $githubData');
// print('write github: $githubData');
await prefs.setString('github', githubData);

setState(() {
Expand All @@ -160,7 +160,7 @@ class _SettingsProviderState extends State<SettingsProvider> {
// read GitHub accounts
try {
var str = prefs.getString('github');
print('read github: $str');
// print('read github: $str');
Map<String, dynamic> github = json.decode(str);
githubAccountMap = github.map<String, Account>((login, _accountMap) =>
MapEntry(login, Account.fromJson(_accountMap)));
Expand Down Expand Up @@ -221,12 +221,12 @@ class _SettingsProviderState extends State<SettingsProvider> {
.timeout(_timeoutDuration);

final data = json.decode(res.body);
print(data);
// print(data);

if (data['errors'] != null) {
throw new Exception(data['errors'].toString());
}
// print(data);

return data['data'];
}

Expand Down Expand Up @@ -258,9 +258,7 @@ class _SettingsProviderState extends State<SettingsProvider> {
.put(prefix + url, headers: headers, body: body ?? {})
.timeout(_timeoutDuration);

print(res.body);
// final data = json.decode(res.body);
// return data;
// print(res.body);
return true;
}

Expand All @@ -269,7 +267,7 @@ class _SettingsProviderState extends State<SettingsProvider> {
final res = await http
.delete(prefix + url, headers: headers)
.timeout(_timeoutDuration);
print(res.body);
// print(res.body);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/scaffolds/list.dart
Expand Up @@ -86,7 +86,7 @@ class _ListScaffoldState<T, K> extends State<ListScaffold<T, K>> {
}

Future<void> _loadMore() async {
print('list scaffold load more');
// print('list scaffold load more');
setState(() {
loadingMore = true;
});
Expand Down
21 changes: 7 additions & 14 deletions lib/scaffolds/long_list.dart
Expand Up @@ -181,16 +181,6 @@ class _LongListScaffoldState<T, K> extends State<LongListScaffold<T, K>> {
}
}

Widget _buildBody() {
if (error.isNotEmpty) {
return ErrorReload(text: error, reload: _refresh);
} else if (loading) {
return Loading(more: false);
} else {
return ListView.builder(itemCount: _itemCount, itemBuilder: _buildItem);
}
}

@override
Widget build(BuildContext context) {
switch (SettingsProvider.of(context).theme) {
Expand All @@ -216,11 +206,14 @@ class _LongListScaffoldState<T, K> extends State<LongListScaffold<T, K>> {
),
);
default:
List<Widget> children = [];
List<Widget> slivers = [];
if (payload != null) {
children.add(widget.headerBuilder(payload.header));
slivers.add(
SliverToBoxAdapter(child: widget.headerBuilder(payload.header)),
);
}
children.add(_buildBody());
slivers.add(_buildSliver());

return Scaffold(
appBar: AppBar(
title: widget.title,
Expand All @@ -229,7 +222,7 @@ class _LongListScaffoldState<T, K> extends State<LongListScaffold<T, K>> {
),
body: RefreshIndicator(
onRefresh: widget.onRefresh,
child: Column(children: children),
child: CustomScrollView(slivers: slivers),
),
);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/screens/notifications.dart
Expand Up @@ -34,7 +34,7 @@ class NotificationScreen extends StatefulWidget {
class NotificationScreenState extends State<NotificationScreen> {
String error = '';
int active = 0;
bool loading = true;
bool loading = false;
Map<String, NotificationGroup> groupMap = {};

@override
Expand Down Expand Up @@ -244,7 +244,7 @@ $key: pullRequest(number: ${item.number}) {
// ),
actions: <Widget>[
IconButton(
icon: Icon(Octicons.check),
icon: Icon(Icons.done_all),
onPressed: _confirm,
)
],
Expand Down
4 changes: 2 additions & 2 deletions lib/screens/user.dart
Expand Up @@ -44,13 +44,13 @@ class _UserScreenState extends State<UserScreen> {
following {
totalCount
}
repositories(first: 6, ownerAffiliations: OWNER, orderBy: {field: STARGAZERS, direction: DESC}) {
repositories(first: $pageSize, ownerAffiliations: OWNER, orderBy: {field: STARGAZERS, direction: DESC}) {
totalCount
nodes {
$repoChunk
}
}
pinnedRepositories(first: 6) {
pinnedRepositories(first: $pageSize) {
nodes {
$repoChunk
}
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/loading.dart
Expand Up @@ -31,7 +31,7 @@ class Loading extends StatelessWidget {
);
} else {
return Padding(
padding: EdgeInsets.symmetric(vertical: 100),
padding: EdgeInsets.symmetric(vertical: 50),
child: _buildIndicator(context),
);
}
Expand Down

0 comments on commit ce11da3

Please sign in to comment.