2020-09-08 20:24:36 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2021-04-05 20:14:39 +02:00
|
|
|
import 'package:lemmy_api_client/v3.dart';
|
2020-09-08 20:24:36 +02:00
|
|
|
|
2021-01-27 20:50:28 +01:00
|
|
|
import '../util/extensions/api.dart';
|
2021-01-08 18:19:24 +01:00
|
|
|
import '../util/goto.dart';
|
2021-02-18 09:19:00 +01:00
|
|
|
import '../widgets/avatar.dart';
|
2020-09-08 20:24:36 +02:00
|
|
|
import '../widgets/markdown_text.dart';
|
|
|
|
|
2020-09-30 19:05:00 +02:00
|
|
|
/// Infinite list of Users fetched by the given fetcher
|
2020-09-08 20:24:36 +02:00
|
|
|
class UsersListPage extends StatelessWidget {
|
|
|
|
final String title;
|
2021-04-05 20:14:39 +02:00
|
|
|
final List<PersonViewSafe> users;
|
2020-09-08 20:24:36 +02:00
|
|
|
|
2021-04-09 00:11:44 +02:00
|
|
|
const UsersListPage({Key? key, required this.users, this.title = ''})
|
|
|
|
: super(key: key);
|
2020-09-08 20:24:36 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-09-08 23:16:30 +02:00
|
|
|
final theme = Theme.of(context);
|
2020-09-30 19:05:00 +02:00
|
|
|
|
|
|
|
// TODO: change to infinite scroll
|
2020-09-08 20:24:36 +02:00
|
|
|
return Scaffold(
|
2021-01-31 14:38:47 +01:00
|
|
|
appBar: AppBar(
|
|
|
|
backgroundColor: theme.cardColor,
|
2021-04-09 00:11:44 +02:00
|
|
|
title: Text(title),
|
2021-01-31 14:38:47 +01:00
|
|
|
),
|
|
|
|
body: ListView.builder(
|
|
|
|
itemBuilder: (context, i) => UsersListItem(user: users[i]),
|
|
|
|
itemCount: users.length,
|
|
|
|
),
|
|
|
|
);
|
2020-09-08 20:24:36 +02:00
|
|
|
}
|
|
|
|
}
|
2021-01-08 18:19:24 +01:00
|
|
|
|
|
|
|
class UsersListItem extends StatelessWidget {
|
2021-04-05 20:14:39 +02:00
|
|
|
final PersonViewSafe user;
|
2021-01-08 18:19:24 +01:00
|
|
|
|
2021-04-09 00:11:44 +02:00
|
|
|
const UsersListItem({Key? key, required this.user}) : super(key: key);
|
2021-01-08 18:19:24 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) => ListTile(
|
2021-04-29 11:38:28 +02:00
|
|
|
title: Text(user.person.originPreferredName),
|
2021-04-05 20:14:39 +02:00
|
|
|
subtitle: user.person.bio != null
|
2021-01-08 18:19:24 +01:00
|
|
|
? Opacity(
|
|
|
|
opacity: 0.5,
|
|
|
|
child: MarkdownText(
|
2021-04-09 00:11:44 +02:00
|
|
|
user.person.bio!,
|
2021-01-08 18:19:24 +01:00
|
|
|
instanceHost: user.instanceHost,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: null,
|
2021-04-05 20:14:39 +02:00
|
|
|
onTap: () => goToUser.fromPersonSafe(context, user.person),
|
|
|
|
leading: Avatar(url: user.person.avatar),
|
2021-01-08 18:19:24 +01:00
|
|
|
);
|
|
|
|
}
|