fluffychat/lib/components/default_drawer.dart

95 lines
2.9 KiB
Dart
Raw Normal View History

2020-12-06 12:51:40 +01:00
import 'package:adaptive_dialog/adaptive_dialog.dart';
2021-01-16 12:46:38 +01:00
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
2020-12-06 12:51:40 +01:00
import 'package:famedlysdk/famedlysdk.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
2020-12-25 09:58:34 +01:00
import 'package:future_loading_dialog/future_loading_dialog.dart';
2020-12-06 12:51:40 +01:00
import 'matrix.dart';
class DefaultDrawer extends StatelessWidget {
2021-01-16 12:46:38 +01:00
void _drawerTapAction(BuildContext context, String route) {
2020-12-06 12:51:40 +01:00
Navigator.of(context).pop();
2021-01-16 12:46:38 +01:00
AdaptivePageLayout.of(context).pushNamedAndRemoveUntilIsFirst(route);
2020-12-06 12:51:40 +01:00
}
void _setStatus(BuildContext context) async {
2021-01-16 21:33:07 +01:00
final client = Matrix.of(context).client;
2020-12-06 12:51:40 +01:00
final input = await showTextInputDialog(
title: L10n.of(context).setStatus,
context: context,
textFields: [
DialogTextField(
hintText: L10n.of(context).statusExampleMessage,
)
],
);
if (input == null || input.single.isEmpty) return;
2020-12-25 09:58:34 +01:00
await showFutureLoadingDialog(
context: context,
future: () => client.sendPresence(
2020-12-06 12:51:40 +01:00
client.userID,
PresenceType.online,
statusMsg: input.single,
),
);
2021-01-16 21:33:53 +01:00
Navigator.of(context).pop();
2020-12-06 12:51:40 +01:00
return;
}
@override
Widget build(BuildContext context) {
return Drawer(
child: SafeArea(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
ListTile(
leading: Icon(Icons.edit_outlined),
title: Text(L10n.of(context).setStatus),
onTap: () => _setStatus(context),
),
Divider(height: 1),
ListTile(
leading: Icon(Icons.people_outline),
title: Text(L10n.of(context).createNewGroup),
2021-01-16 12:46:38 +01:00
onTap: () => _drawerTapAction(context, '/newgroup'),
2020-12-06 12:51:40 +01:00
),
ListTile(
leading: Icon(Icons.person_add_outlined),
title: Text(L10n.of(context).newPrivateChat),
2021-01-16 12:46:38 +01:00
onTap: () => _drawerTapAction(context, '/newprivatechat'),
2020-12-06 12:51:40 +01:00
),
Divider(height: 1),
ListTile(
leading: Icon(Icons.archive_outlined),
title: Text(L10n.of(context).archive),
onTap: () => _drawerTapAction(
context,
2021-01-16 12:46:38 +01:00
'/archive',
2020-12-06 12:51:40 +01:00
),
),
ListTile(
leading: Icon(Icons.group_work_outlined),
title: Text(L10n.of(context).discoverGroups),
onTap: () => _drawerTapAction(
context,
2021-01-16 12:46:38 +01:00
'/discover',
2020-12-06 12:51:40 +01:00
),
),
Divider(height: 1),
ListTile(
leading: Icon(Icons.settings_outlined),
title: Text(L10n.of(context).settings),
onTap: () => _drawerTapAction(
context,
2021-01-16 12:46:38 +01:00
'/settings',
2020-12-06 12:51:40 +01:00
),
),
],
),
),
);
}
}