git-touch-android-ios-app/lib/screens/gt_issues.dart

43 lines
1.4 KiB
Dart
Raw Normal View History

2020-02-01 08:42:10 +01:00
import 'package:flutter/material.dart';
import 'package:git_touch/models/auth.dart';
import 'package:git_touch/models/gitea.dart';
import 'package:git_touch/scaffolds/list_stateful.dart';
import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/issue_item.dart';
import 'package:provider/provider.dart';
2020-02-07 15:20:06 +01:00
class GtIssuesScreen extends StatelessWidget {
2020-02-01 08:42:10 +01:00
final String owner;
final String name;
final bool isPr;
2020-02-07 15:20:06 +01:00
GtIssuesScreen(this.owner, this.name, {this.isPr = false});
2020-02-01 08:42:10 +01:00
@override
Widget build(BuildContext context) {
return ListStatefulScaffold<GiteaIssue, int>(
title: AppBarTitle(isPr ? 'Pull Requests' : 'Issues'),
// TODO: create issue
2020-10-04 16:10:05 +02:00
onLoadMore: (page) async {
final type = isPr ? 'pulls' : 'issues';
final res = await context.read<AuthModel>().fetchGiteaWithPage(
'/repos/$owner/$name/issues?state=open&type=$type',
page: page);
2020-10-04 16:10:05 +02:00
return ListPayload(
cursor: res.cursor,
hasMore: res.hasMore,
items: (res.data as List).map((v) => GiteaIssue.fromJson(v)).toList(),
);
},
2020-02-01 08:42:10 +01:00
itemBuilder: (p) => IssueItem(
author: p.user.login,
avatarUrl: p.user.avatarUrl,
commentCount: p.comments,
number: p.number,
title: p.title,
updatedAt: p.updatedAt,
url: p.htmlUrl,
),
);
}
}