1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-17 10:48:50 +01:00
git-touch-android-ios-app/lib/screens/news.dart
2019-02-03 14:42:50 +08:00

39 lines
927 B
Dart

import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import '../widgets/list_scaffold.dart';
import '../widgets/event_item.dart';
import '../utils/utils.dart';
class NewsScreen extends StatefulWidget {
@override
NewsScreenState createState() => NewsScreenState();
}
class NewsScreenState extends State<NewsScreen> {
int page = 1;
List<Event> _events = [];
@override
Widget build(context) {
return ListScaffold(
title: 'News',
itemCount: _events.length,
itemBuilder: (context, index) => EventItem(_events[index]),
onRefresh: () async {
page = 1;
var items = await fetchEvents(page);
setState(() {
_events = items;
});
},
onLoadMore: () async {
page = page + 1;
var items = await fetchEvents(page);
setState(() {
_events.addAll(items);
});
},
);
}
}