Add communities list page
This commit is contained in:
parent
e3ef1fab2d
commit
34cd4ff1c1
|
@ -0,0 +1,58 @@
|
|||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:lemmy_api_client/lemmy_api_client.dart';
|
||||
|
||||
import '../widgets/markdown_text.dart';
|
||||
|
||||
class CommunitiesListPage extends StatelessWidget {
|
||||
final String title;
|
||||
final List<CommunityView> communities;
|
||||
|
||||
const CommunitiesListPage({Key key, @required this.communities, this.title})
|
||||
: assert(communities != null),
|
||||
super(key: key);
|
||||
|
||||
void goToUser(BuildContext context, int id) {
|
||||
print('GO TO COMMUNITY $id');
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
// TODO: abillity to load more, right now its 10 - default page size
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(title ?? '', style: theme.textTheme.headline6),
|
||||
centerTitle: true,
|
||||
backgroundColor: theme.cardColor,
|
||||
iconTheme: theme.iconTheme,
|
||||
),
|
||||
body: ListView.builder(
|
||||
itemBuilder: (context, i) => ListTile(
|
||||
title: Text(communities[i].name ?? '@${communities[i].name}'),
|
||||
subtitle: communities[i].description != null
|
||||
? Opacity(
|
||||
opacity: 0.5,
|
||||
child: MarkdownText(communities[i].description),
|
||||
)
|
||||
: null,
|
||||
onTap: () => goToUser(context, communities[i].id),
|
||||
leading: communities[i].icon != null
|
||||
? CachedNetworkImage(
|
||||
height: 50,
|
||||
width: 50,
|
||||
imageUrl: communities[i].icon,
|
||||
imageBuilder: (context, imageProvider) => Container(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.cover, image: imageProvider),
|
||||
),
|
||||
))
|
||||
: SizedBox(width: 50),
|
||||
// TODO: add trailing button for un/subscribing to communities
|
||||
),
|
||||
itemCount: communities.length,
|
||||
));
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ import '../util/text_color.dart';
|
|||
import '../widgets/badge.dart';
|
||||
import '../widgets/bottom_modal.dart';
|
||||
import '../widgets/markdown_text.dart';
|
||||
import 'communities_list.dart';
|
||||
import 'users_list.dart';
|
||||
|
||||
class InstancePage extends HookWidget {
|
||||
|
@ -99,7 +100,8 @@ class InstancePage extends HookWidget {
|
|||
actions: [
|
||||
IconButton(icon: Icon(Icons.share), onPressed: _share),
|
||||
IconButton(
|
||||
icon: Icon(Icons.more_vert), onPressed: _openMoreMenu),
|
||||
icon: Icon(Icons.more_vert),
|
||||
onPressed: () => _openMoreMenu(context)),
|
||||
],
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
background: Stack(children: [
|
||||
|
@ -212,15 +214,19 @@ class _AboutTab extends HookWidget {
|
|||
print('GO TO COMMUNITY $id');
|
||||
}
|
||||
|
||||
void goToCommunities() {
|
||||
print('GO TO COMMUNITIES');
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final commSnap = useFuture(communitiesFuture);
|
||||
|
||||
void goToCommunities() {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (_) => CommunitiesListPage(
|
||||
communities: commSnap.data,
|
||||
title: 'Communities of ${site.site.name}'),
|
||||
));
|
||||
}
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
|
|
Loading…
Reference in New Issue