mobile_home_page.dart 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import 'package:appflowy/generated/flowy_svgs.g.dart';
  2. import 'package:appflowy/startup/startup.dart';
  3. import 'package:appflowy/user/application/auth/auth_service.dart';
  4. import 'package:appflowy_backend/dispatch/dispatch.dart';
  5. import 'package:appflowy_backend/protobuf/flowy-folder2/workspace.pb.dart';
  6. import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';
  7. import 'package:flutter/material.dart';
  8. // TODO(yijing): This is just a placeholder for now.
  9. class MobileHomeScreen extends StatelessWidget {
  10. const MobileHomeScreen({super.key});
  11. static const routeName = "/MobileHomeScreen";
  12. @override
  13. Widget build(BuildContext context) {
  14. return FutureBuilder(
  15. future: Future.wait([
  16. FolderEventGetCurrentWorkspace().send(),
  17. getIt<AuthService>().getUser(),
  18. ]),
  19. builder: (context, snapshots) {
  20. if (!snapshots.hasData) {
  21. return const Center(child: CircularProgressIndicator.adaptive());
  22. }
  23. final workspaceSetting = snapshots.data?[0].fold(
  24. (workspaceSettingPB) {
  25. return workspaceSettingPB as WorkspaceSettingPB?;
  26. },
  27. (error) => null,
  28. );
  29. final userProfile =
  30. snapshots.data?[1].fold((error) => null, (userProfilePB) {
  31. return userProfilePB as UserProfilePB?;
  32. });
  33. // TODO(yijing): implement home page later
  34. return Scaffold(
  35. key: ValueKey(userProfile?.id),
  36. // TODO(yijing):Need to change to workspace when it is ready
  37. appBar: AppBar(
  38. title: Text(
  39. userProfile?.email.toString() ?? 'No email found',
  40. ),
  41. actions: [
  42. IconButton(
  43. onPressed: () {
  44. // TODO(yijing): Navigate to setting page
  45. },
  46. icon: const FlowySvg(
  47. FlowySvgs.m_setting_m,
  48. ),
  49. )
  50. ],
  51. ),
  52. body: Center(
  53. child: Column(
  54. children: [
  55. const Text(
  56. 'User',
  57. ),
  58. Text(
  59. userProfile.toString(),
  60. ),
  61. Text('Workspace name: ${workspaceSetting?.workspace.name}'),
  62. ElevatedButton(
  63. onPressed: () async {
  64. await getIt<AuthService>().signOut();
  65. runAppFlowy();
  66. },
  67. child: const Text('Logout'),
  68. )
  69. ],
  70. ),
  71. ),
  72. );
  73. },
  74. );
  75. }
  76. }