profile_drawer.dart 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import 'package:auto_route/auto_route.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:hooks_riverpod/hooks_riverpod.dart';
  4. import 'package:immich_mobile/modules/home/providers/asset.provider.dart';
  5. import 'package:immich_mobile/modules/login/models/authentication_state.model.dart';
  6. import 'package:immich_mobile/modules/login/providers/authentication.provider.dart';
  7. class ProfileDrawer extends ConsumerWidget {
  8. const ProfileDrawer({Key? key}) : super(key: key);
  9. @override
  10. Widget build(BuildContext context, WidgetRef ref) {
  11. AuthenticationState _authState = ref.watch(authenticationProvider);
  12. return Drawer(
  13. shape: const RoundedRectangleBorder(
  14. borderRadius: BorderRadius.only(
  15. topRight: Radius.circular(5),
  16. bottomRight: Radius.circular(5),
  17. ),
  18. ),
  19. child: ListView(
  20. padding: EdgeInsets.zero,
  21. children: [
  22. DrawerHeader(
  23. decoration: BoxDecoration(
  24. color: Colors.grey[200],
  25. ),
  26. child: Column(
  27. mainAxisAlignment: MainAxisAlignment.center,
  28. crossAxisAlignment: CrossAxisAlignment.center,
  29. children: [
  30. const Image(
  31. image: AssetImage('assets/immich-logo-no-outline.png'),
  32. width: 50,
  33. filterQuality: FilterQuality.high,
  34. ),
  35. const Padding(padding: EdgeInsets.all(8)),
  36. Text(
  37. _authState.userEmail,
  38. style: TextStyle(color: Theme.of(context).primaryColor, fontWeight: FontWeight.bold),
  39. )
  40. ],
  41. ),
  42. ),
  43. ListTile(
  44. tileColor: Colors.grey[100],
  45. leading: const Icon(
  46. Icons.logout_rounded,
  47. color: Colors.black54,
  48. ),
  49. title: const Text(
  50. "Sign Out",
  51. style: TextStyle(color: Colors.black54, fontSize: 14),
  52. ),
  53. onTap: () async {
  54. bool res = await ref.read(authenticationProvider.notifier).logout();
  55. ref.read(assetProvider.notifier).clearAllAsset();
  56. if (res) {
  57. AutoRouter.of(context).popUntilRoot();
  58. }
  59. },
  60. )
  61. ],
  62. ),
  63. );
  64. }
  65. }