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

38 lines
1.2 KiB
Dart
Raw Normal View History

2020-02-01 11:51:33 +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/user_item.dart';
import 'package:provider/provider.dart';
2020-02-07 15:20:06 +01:00
class GtOrgsScreen extends StatelessWidget {
2020-10-06 07:25:43 +02:00
final String api;
GtOrgsScreen() : api = '/orgs';
GtOrgsScreen.ofUser(String login) : api = '/users/$login/orgs';
2020-02-01 11:51:33 +01:00
@override
Widget build(BuildContext context) {
return ListStatefulScaffold<GiteaOrg, int>(
title: AppBarTitle('Organizations'),
fetch: (page) async {
2020-10-06 07:25:43 +02:00
final res =
await context.read<AuthModel>().fetchGiteaWithPage(api, page: page);
2020-10-04 16:10:05 +02:00
return ListPayload(
cursor: res.cursor,
hasMore: res.hasMore,
2020-10-06 07:25:43 +02:00
items: [for (var v in res.data) GiteaOrg.fromJson(v)],
2020-10-04 16:10:05 +02:00
);
},
2020-02-01 11:51:33 +01:00
itemBuilder: (v) {
2020-10-08 09:55:26 +02:00
return UserItem.gitea(
2020-02-01 11:51:33 +01:00
avatarUrl: v.avatarUrl,
login: v.username,
2020-10-08 09:55:26 +02:00
name: v.fullName,
2020-10-06 07:25:43 +02:00
bio: Text(v.description ?? v.website ?? v.location),
2020-02-01 11:51:33 +01:00
);
},
);
}
}