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

39 lines
1.2 KiB
Dart
Raw Normal View History

2020-02-02 10:47:05 +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/user_item.dart';
import 'package:provider/provider.dart';
import 'package:timeago/timeago.dart' as timeago;
import 'package:flutter_gen/gen_l10n/S.dart';
2020-02-02 10:47:05 +01:00
class BbTeamsScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
2021-05-16 09:16:35 +02:00
return ListStatefulScaffold<BbUser, String?>(
title: AppBarTitle(AppLocalizations.of(context)!.teams),
fetch: (nextUrl) async {
2020-10-04 16:10:05 +02:00
final res = await context
.read<AuthModel>()
.fetchBbWithPage(nextUrl ?? '/teams?role=member');
return ListPayload(
cursor: res.cursor,
hasMore: res.hasMore,
items: <BbUser>[
2021-05-16 09:16:35 +02:00
for (var v in res.data!) BbUser.fromJson(v),
2020-10-04 16:10:05 +02:00
],
);
},
2020-02-02 10:47:05 +01:00
itemBuilder: (v) {
2020-10-08 09:55:26 +02:00
return UserItem.bitbucket(
2020-02-02 10:47:05 +01:00
login: v.username,
2020-10-08 09:55:26 +02:00
name: v.nickname,
2020-02-02 10:47:05 +01:00
avatarUrl: v.avatarUrl,
2021-05-16 09:16:35 +02:00
bio: Text('Created ${timeago.format(v.createdOn!)}'),
2020-02-02 10:47:05 +01:00
);
},
);
}
}