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

45 lines
1.4 KiB
Dart
Raw Normal View History

2020-02-03 07:40:56 +01:00
import 'package:flutter/material.dart';
import 'package:git_touch/models/auth.dart';
import 'package:git_touch/models/bitbucket.dart';
import 'package:git_touch/scaffolds/list_stateful.dart';
import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/commit_item.dart';
import 'package:provider/provider.dart';
import '../generated/l10n.dart';
2020-02-03 07:40:56 +01:00
class BbCommitsScreen extends StatelessWidget {
final String owner;
final String name;
final String ref;
BbCommitsScreen(this.owner, this.name, this.ref);
@override
Widget build(BuildContext context) {
2020-02-03 07:44:21 +01:00
final auth = Provider.of<AuthModel>(context);
2020-02-03 07:40:56 +01:00
return ListStatefulScaffold<BbCommit, String>(
title: AppBarTitle(S.of(context).commits),
fetch: (nextUrl) async {
2020-10-04 16:10:05 +02:00
final res = await context.read<AuthModel>().fetchBbWithPage(
nextUrl ?? '/repositories/$owner/$name/commits/$ref');
return ListPayload(
cursor: res.cursor,
hasMore: res.hasMore,
items: <BbCommit>[
for (var v in res.data) BbCommit.fromJson(v),
],
);
},
2020-02-03 07:40:56 +01:00
itemBuilder: (v) {
return CommitItem(
2020-02-03 07:44:21 +01:00
url: '${auth.activeAccount.domain}/$owner/$name/commits/${v.hash}',
2020-02-03 07:40:56 +01:00
avatarUrl: v.author.user?.avatarUrl,
avatarLink: null,
2020-02-03 07:40:56 +01:00
author: v.author.raw.replaceFirst(RegExp(r' <.*>'), ''),
createdAt: v.date,
message: v.message,
);
},
);
}
}