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

44 lines
1.3 KiB
Dart
Raw Normal View History

2022-09-17 14:35:45 +02:00
import 'package:flutter/widgets.dart';
import 'package:git_touch/models/auth.dart';
2021-01-23 15:08:05 +01:00
import 'package:git_touch/models/gogs.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';
class GoUsersScreen extends StatelessWidget {
final String api;
final String title;
2022-09-06 18:28:12 +02:00
const GoUsersScreen.followers(String login)
2021-01-23 15:08:05 +01:00
: api = '/users/$login/followers',
title = 'Followers';
2022-09-06 18:28:12 +02:00
const GoUsersScreen.following(String login)
2021-01-23 15:08:05 +01:00
: api = '/users/$login/following',
title = 'Following';
2021-01-23 15:08:05 +01:00
@override
Widget build(BuildContext context) {
return ListStatefulScaffold<GogsUser, int>(
title: AppBarTitle(title),
fetch: (page) async {
final res =
await context.read<AuthModel>().fetchGogsWithPage(api, page: page);
return ListPayload(
cursor: res.cursor,
hasMore: res.hasMore,
items: [for (var v in res.data) GogsUser.fromJson(v)],
);
},
itemBuilder: (payload) {
return UserItem.gogs(
login: payload.username,
name: payload.fullName,
avatarUrl: payload.avatarUrl,
bio: null,
);
},
);
}
}