mydrawer.dart 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import 'package:e2ee_chat/common/global.dart';
  2. import 'package:e2ee_chat/presenter/login.dart';
  3. import 'package:flutter/material.dart';
  4. class MyDrawer extends StatelessWidget {
  5. const MyDrawer({
  6. Key? key,
  7. }) : super(key: key);
  8. @override
  9. Widget build(BuildContext context) {
  10. return Drawer(
  11. child: MediaQuery.removePadding(
  12. context: context,
  13. //移除抽屉菜单顶部默认留白
  14. removeTop: true,
  15. child: Column(
  16. crossAxisAlignment: CrossAxisAlignment.start,
  17. children: <Widget>[
  18. Padding(
  19. padding: const EdgeInsets.only(top: 38.0),
  20. child: Row(
  21. children: <Widget>[
  22. Padding(
  23. padding: const EdgeInsets.symmetric(horizontal: 16.0),
  24. child: ClipOval(
  25. child: Global.defaultAvatar, //TODO: avatar
  26. ),
  27. ),
  28. Text(
  29. Global.profile.username!,
  30. style: TextStyle(fontWeight: FontWeight.bold),
  31. )
  32. ],
  33. ),
  34. ),
  35. Expanded(
  36. child: ListView(
  37. children: <Widget>[
  38. ListTile(
  39. leading: const Icon(Icons.logout),
  40. title: const Text('logout'),
  41. onTap: () => LoginModel().logout(),
  42. ),
  43. ListTile(
  44. leading: const Icon(Icons.settings),
  45. title: const Text('Manage accounts'),
  46. ),
  47. ],
  48. ),
  49. ),
  50. ],
  51. ),
  52. ),
  53. );
  54. }
  55. }