add more menu

This commit is contained in:
krawieck 2020-09-09 22:04:50 +02:00
parent 1c56ef0d63
commit 11e6c4881b
1 changed files with 66 additions and 9 deletions

View File

@ -1,14 +1,18 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:esys_flutter_share/esys_flutter_share.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:intl/intl.dart';
import 'package:lemmy_api_client/lemmy_api_client.dart';
import 'package:url_launcher/url_launcher.dart' as ul;
import '../util/api_extensions.dart';
import '../util/goto.dart';
import '../util/intl.dart';
import '../util/text_color.dart';
import '../widgets/badge.dart';
import '../widgets/bottom_modal.dart';
import '../widgets/markdown_text.dart';
class CommunityPage extends HookWidget {
@ -39,14 +43,6 @@ class CommunityPage extends HookWidget {
print('SUBSCRIBE');
}
void _share() {
print('SHARE');
}
void _openMoreMenu() {
print('OPEN MORE MENU');
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
@ -64,6 +60,8 @@ class CommunityPage extends HookWidget {
}
}();
// FALLBACK
if (community == null) {
return Scaffold(
appBar: AppBar(
@ -89,6 +87,64 @@ class CommunityPage extends HookWidget {
);
}
// FUNCTIONS
void _share() =>
Share.text('Share instance', community.actorId, 'text/plain');
void _openMoreMenu(BuildContext c) {
showModalBottomSheet(
backgroundColor: Colors.transparent,
context: c,
builder: (context) => BottomModal(
child: Column(
children: [
ListTile(
leading: Icon(Icons.open_in_browser),
title: Text('Open in browser'),
onTap: () async => await ul.canLaunch(community.actorId)
? ul.launch(community.actorId)
: Scaffold.of(context).showSnackBar(
SnackBar(content: Text("can't open in browser"))),
),
ListTile(
leading: Icon(Icons.info_outline),
title: Text('Nerd stuff'),
onTap: () {
showDialog(
context: context,
child: SimpleDialog(
contentPadding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 15,
),
children: [
Table(
children: [
TableRow(children: [
Text('created by:'),
Text('@${community.creatorName}'),
]),
TableRow(children: [
Text('hot rank:'),
Text(community.hotRank.toString()),
]),
TableRow(children: [
Text('published:'),
Text(
'''${DateFormat.yMMMd().format(community.published)}'''
''' ${DateFormat.Hms().format(community.published)}'''),
]),
],
),
]));
},
),
],
),
),
);
}
return Scaffold(
body: DefaultTabController(
length: 3,
@ -107,7 +163,8 @@ class CommunityPage 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: _CommunityOverview(