2023-03-11 03:17:34 +00:00
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
|
|
|
|
import '../globals.dart';
|
|
|
|
import '../routes.dart';
|
|
|
|
import '../services/auth_service.dart';
|
|
|
|
|
|
|
|
class StandardAppDrawer extends StatelessWidget {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Drawer(
|
|
|
|
child: ListView(
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
children: [
|
|
|
|
...getIt<AccountsService>().loggedInProfiles.map(
|
|
|
|
(p) => ListTile(
|
|
|
|
onTap: () async {
|
|
|
|
await getIt<AccountsService>().setActiveProfile(p);
|
2023-03-11 18:40:36 +00:00
|
|
|
if (context.mounted) {
|
|
|
|
context.pop();
|
|
|
|
}
|
2023-03-11 03:17:34 +00:00
|
|
|
},
|
|
|
|
leading: CircleAvatar(
|
|
|
|
child: CachedNetworkImage(imageUrl: p.avatar)),
|
|
|
|
title: Text(
|
|
|
|
p.username,
|
|
|
|
style: p == getIt<AccountsService>().currentProfile
|
|
|
|
? TextStyle(fontWeight: FontWeight.bold)
|
|
|
|
: null,
|
|
|
|
),
|
|
|
|
subtitle: Text(
|
|
|
|
p.serverName,
|
|
|
|
style: p == getIt<AccountsService>().currentProfile
|
|
|
|
? TextStyle(fontWeight: FontWeight.bold)
|
|
|
|
: null,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2023-03-11 04:23:44 +00:00
|
|
|
buildMenuButton(
|
|
|
|
context,
|
|
|
|
'Manage Profiles',
|
|
|
|
() => context.pushNamed(ScreenPaths.manageProfiles),
|
|
|
|
),
|
|
|
|
const Divider(),
|
2023-03-11 03:17:34 +00:00
|
|
|
buildMenuButton(
|
|
|
|
context,
|
|
|
|
'Gallery',
|
|
|
|
() => context.pushNamed(ScreenPaths.gallery),
|
|
|
|
),
|
|
|
|
buildMenuButton(
|
|
|
|
context,
|
|
|
|
'Direct Messages',
|
|
|
|
() => context.pushNamed(ScreenPaths.messages),
|
|
|
|
),
|
|
|
|
buildMenuButton(
|
|
|
|
context,
|
|
|
|
'Settings',
|
|
|
|
() => context.pushNamed(ScreenPaths.settings),
|
|
|
|
),
|
|
|
|
buildMenuButton(context, 'Clear Caches', () async {
|
|
|
|
final confirm = await showYesNoDialog(
|
|
|
|
context, 'You want to clear all memory and disk cache data?');
|
|
|
|
if (confirm == true) {
|
|
|
|
clearCaches();
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget buildMenuButton(BuildContext context, String title, Function() onTap) {
|
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: ListTile(
|
|
|
|
title: Text(title),
|
|
|
|
onTap: () {
|
|
|
|
context.pop();
|
|
|
|
onTap();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|