From ece353b6b16517f56a65c0c07ccc527d86f2d804 Mon Sep 17 00:00:00 2001 From: appflowy Date: Sat, 9 Oct 2021 16:43:56 +0800 Subject: [PATCH] [flutter]: config ui of left menu --- app_flowy/.vscode/settings.json | 12 +++ .../assets/images/flowy_logo_with_text.svg | 25 +++++ .../home/{Arrow left.svg => arrow_left.svg} | 0 .../home/{Arrow right.svg => arrow_right.svg} | 0 .../Hide.svg => drop_down_hide.svg} | 0 .../Show.svg => drop_down_show.svg} | 0 .../home/{Hide menu.svg => hide_menu.svg} | 0 app_flowy/assets/images/home/new_app.svg | 5 + app_flowy/fonts/FlowyIconData.ttf | Bin 0 -> 1904 bytes .../lib/user/application/sign_in_bloc.dart | 14 ++- .../lib/user/application/sign_up_bloc.dart | 29 ++++-- .../lib/user/presentation/sign_in_screen.dart | 15 +-- .../lib/user/presentation/sign_up_screen.dart | 15 ++- .../user/presentation/widgets/background.dart | 2 +- app_flowy/lib/workspace/domain/image.dart | 11 +-- .../presentation/app/app_header.dart | 32 ++++--- .../workspace/presentation/app/app_page.dart | 4 +- .../presentation/view/view_page.dart | 2 +- .../presentation/widgets/menu/menu_list.dart | 8 +- .../widgets/menu/menu_new_app.dart | 15 +-- .../widgets/menu/menu_top_bar.dart | 16 +--- .../presentation/widgets/menu/menu_user.dart | 33 ++++--- .../lib/flowy_icon_data_icons.dart | 30 ++++++ app_flowy/packages/flowy_infra/lib/image.dart | 11 ++- app_flowy/packages/flowy_infra/lib/theme.dart | 1 - .../lib/style_widget/icon_button.dart | 2 +- .../lib/style_widget/snap_bar.dart | 25 +++++ .../flowy_infra_ui/lib/style_widget/text.dart | 17 ++-- .../protobuf/flowy-user/errors.pbenum.dart | 2 + .../protobuf/flowy-user/errors.pbjson.dart | 3 +- app_flowy/pubspec.yaml | 5 + .../src/services/doc/edit/doc_actor.rs | 9 -- .../src/services/doc/edit/edit_doc.rs | 6 +- .../src/services/doc/revision/manager.rs | 6 -- .../src/services/doc/revision/model.rs | 6 +- .../src/services/doc/revision/rev_store.rs | 3 +- .../src/sql_tables/doc/rev_sql.rs | 1 + rust-lib/flowy-user/src/errors.rs | 21 ++++- .../flowy-user/src/protobuf/model/errors.rs | 87 +++++++++--------- .../src/protobuf/proto/errors.proto | 1 + .../src/services/user/user_session.rs | 7 +- 41 files changed, 312 insertions(+), 169 deletions(-) create mode 100644 app_flowy/assets/images/flowy_logo_with_text.svg rename app_flowy/assets/images/home/{Arrow left.svg => arrow_left.svg} (100%) rename app_flowy/assets/images/home/{Arrow right.svg => arrow_right.svg} (100%) rename app_flowy/assets/images/home/{drop_menu/Hide.svg => drop_down_hide.svg} (100%) rename app_flowy/assets/images/home/{drop_menu/Show.svg => drop_down_show.svg} (100%) rename app_flowy/assets/images/home/{Hide menu.svg => hide_menu.svg} (100%) create mode 100644 app_flowy/assets/images/home/new_app.svg create mode 100644 app_flowy/fonts/FlowyIconData.ttf create mode 100644 app_flowy/packages/flowy_infra/lib/flowy_icon_data_icons.dart create mode 100644 app_flowy/packages/flowy_infra_ui/lib/style_widget/snap_bar.dart diff --git a/app_flowy/.vscode/settings.json b/app_flowy/.vscode/settings.json index df7d65a8eb..6f00a92abd 100644 --- a/app_flowy/.vscode/settings.json +++ b/app_flowy/.vscode/settings.json @@ -1,4 +1,16 @@ { + "[dart]": { + "editor.formatOnSave": true, + "editor.formatOnType": true, + "editor.rulers": [ + 120 + ], + "editor.selectionHighlight": false, + "editor.suggest.snippetsPreventQuickSuggestions": false, + "editor.suggestSelection": "first", + "editor.tabCompletion": "onlySnippets", + "editor.wordBasedSuggestions": false + }, "svgviewer.enableautopreview": true, "svgviewer.previewcolumn": "Active", "svgviewer.showzoominout": true, diff --git a/app_flowy/assets/images/flowy_logo_with_text.svg b/app_flowy/assets/images/flowy_logo_with_text.svg new file mode 100644 index 0000000000..b8f2bef427 --- /dev/null +++ b/app_flowy/assets/images/flowy_logo_with_text.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app_flowy/assets/images/home/Arrow left.svg b/app_flowy/assets/images/home/arrow_left.svg similarity index 100% rename from app_flowy/assets/images/home/Arrow left.svg rename to app_flowy/assets/images/home/arrow_left.svg diff --git a/app_flowy/assets/images/home/Arrow right.svg b/app_flowy/assets/images/home/arrow_right.svg similarity index 100% rename from app_flowy/assets/images/home/Arrow right.svg rename to app_flowy/assets/images/home/arrow_right.svg diff --git a/app_flowy/assets/images/home/drop_menu/Hide.svg b/app_flowy/assets/images/home/drop_down_hide.svg similarity index 100% rename from app_flowy/assets/images/home/drop_menu/Hide.svg rename to app_flowy/assets/images/home/drop_down_hide.svg diff --git a/app_flowy/assets/images/home/drop_menu/Show.svg b/app_flowy/assets/images/home/drop_down_show.svg similarity index 100% rename from app_flowy/assets/images/home/drop_menu/Show.svg rename to app_flowy/assets/images/home/drop_down_show.svg diff --git a/app_flowy/assets/images/home/Hide menu.svg b/app_flowy/assets/images/home/hide_menu.svg similarity index 100% rename from app_flowy/assets/images/home/Hide menu.svg rename to app_flowy/assets/images/home/hide_menu.svg diff --git a/app_flowy/assets/images/home/new_app.svg b/app_flowy/assets/images/home/new_app.svg new file mode 100644 index 0000000000..ac6c002d3d --- /dev/null +++ b/app_flowy/assets/images/home/new_app.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/app_flowy/fonts/FlowyIconData.ttf b/app_flowy/fonts/FlowyIconData.ttf new file mode 100644 index 0000000000000000000000000000000000000000..8f03a5c8f932e4e65caac7823e05f2c1a0eb7e8d GIT binary patch literal 1904 zcmd^9L2D#M6#i;@GBeI>Cg4VqMM5Lln8h$NnS(5A48de41O%649b_+|ccy20LQi+o zUD;&zu*pG0FoGxX;#s^3q6dF~_y;_QvMe6v;6V|O8oyWF(aDnhf~}^yzW06aRlWD9 zZYTg19K%9mbLZW+?2oQL1k_Ekci-8mH&^YgL)s^_+nu2keYpPHm$ZN9eAM?xz0OaK z9|4O#h& zifhzgqHPDx(0%{C9f$gub0rEB{l(SWe*ndK>RVv$*7oUMs++e|GdV2rkvW}sE4wo* zf1x6K0Y886cW-jF#!7N5Atx+{#964C6^1RNOzu=f4$;eKU=_KI*4uYc^&K5B_qmo5&RAyg38r}5!<=MulCJ78mKF2LVag(V!MM}A-No7%V`chr z&)UYPbdwx8O!uUNrgGVzl>tkf%t5s?zdK|lVu>p&C7;K<@yQE6R;R3e40+Q|vu9RH zvVYdc71MyltPSjnwA!@WbWXZQ;_Pn8ofjLqk9q5+*~4OCPQ9U;tE#RRUQthuN~&7< zr&3j=qv8wd>*M0=%*<@@xX6&RxX&f-`l}185;v!2RN?8kKaWZh#x3M1;CcL#MiaL< z%}#tz(@Jp;MeJnQB7ZN#dE$PCr}($f87`1N%5WL4;UvQqT*WtXoAS@`oD=+zVTEhF zRVklCRYe)L$Un+(p7^s2PvJ%NRfY@Xzt36)fa#u7}Ym9`rqJFRtIPn~mnO zeSc(!qy~ZG+s?lB!Z@+l?4G}`wHpsQVNmOY!zH^H2HN%gP^^|89*njqZ8+N5cKiFj z6QASG8ErRC24P??*Ba;eO*e33N4s4~A$ibmYTdJYaX7SF*;#fJhkI^E*F3GGTlM;6 z4p>Ks2qVN8u;(6oZDWz_4X#c8Z<<&px=#b9PBf~GfF~xjk8BZSPj?s zcc=!aLDnI^cJUBKbe~W7pVl(g0ngep-T^jvg67<&Z=bvR#4+!WL|x=}xzaY-B&<@- zwpmq;)m`qtN&mpaNCqytj7htY-~n@KlGUt4s)@Phkf>$${=Y7pofU15@f~{COn)`m qTd4E7tPf}3t^EHl8kWi_OXX4R#$mME4G)4{Z_sro%)|>1Oys}7A{Fld literal 0 HcmV?d00001 diff --git a/app_flowy/lib/user/application/sign_in_bloc.dart b/app_flowy/lib/user/application/sign_in_bloc.dart index 1cd6cec773..97dedb56df 100644 --- a/app_flowy/lib/user/application/sign_in_bloc.dart +++ b/app_flowy/lib/user/application/sign_in_bloc.dart @@ -21,16 +21,24 @@ class SignInBloc extends Bloc { ); }, emailChanged: (EmailChanged value) async* { - yield state.copyWith(email: value.email, successOrFail: none()); + yield state.copyWith( + email: value.email, emailError: none(), successOrFail: none()); }, passwordChanged: (PasswordChanged value) async* { - yield state.copyWith(password: value.password, successOrFail: none()); + yield state.copyWith( + password: value.password, + passwordError: none(), + successOrFail: none()); }, ); } Stream _performActionOnSignIn(SignInState state) async* { - yield state.copyWith(isSubmitting: true); + yield state.copyWith( + isSubmitting: true, + emailError: none(), + passwordError: none(), + successOrFail: none()); final result = await authImpl.signIn(state.email, state.password); yield result.fold( diff --git a/app_flowy/lib/user/application/sign_up_bloc.dart b/app_flowy/lib/user/application/sign_up_bloc.dart index 425007d1d4..43d4132cbe 100644 --- a/app_flowy/lib/user/application/sign_up_bloc.dart +++ b/app_flowy/lib/user/application/sign_up_bloc.dart @@ -17,18 +17,25 @@ class SignUpBloc extends Bloc { yield* event.map(signUpWithUserEmailAndPassword: (e) async* { yield* _performActionOnSignUp(); }, emailChanged: (EmailChanged value) async* { - yield state.copyWith(email: value.email, successOrFail: none()); + yield state.copyWith( + email: value.email, emailError: none(), successOrFail: none()); }, passwordChanged: (PasswordChanged value) async* { - yield state.copyWith(password: value.password, successOrFail: none()); + yield state.copyWith( + password: value.password, + passwordError: none(), + successOrFail: none()); }, repeatPasswordChanged: (RepeatPasswordChanged value) async* { yield state.copyWith( - repeatedPassword: value.password, successOrFail: none()); + repeatedPassword: value.password, + repeatPasswordError: none(), + successOrFail: none()); }); } Stream _performActionOnSignUp() async* { yield state.copyWith( isSubmitting: true, + successOrFail: none(), ); final password = state.password; @@ -81,14 +88,18 @@ class SignUpBloc extends Bloc { switch (error.code) { case ErrorCode.EmailFormatInvalid: return state.copyWith( - isSubmitting: false, - emailError: some(error.msg), - passwordError: none()); + isSubmitting: false, + emailError: some(error.msg), + passwordError: none(), + successOrFail: none(), + ); case ErrorCode.PasswordFormatInvalid: return state.copyWith( - isSubmitting: false, - passwordError: some(error.msg), - emailError: none()); + isSubmitting: false, + passwordError: some(error.msg), + emailError: none(), + successOrFail: none(), + ); default: return state.copyWith( isSubmitting: false, successOrFail: some(right(error))); diff --git a/app_flowy/lib/user/presentation/sign_in_screen.dart b/app_flowy/lib/user/presentation/sign_in_screen.dart index 68d0768789..d5b6d29a34 100644 --- a/app_flowy/lib/user/presentation/sign_in_screen.dart +++ b/app_flowy/lib/user/presentation/sign_in_screen.dart @@ -6,6 +6,7 @@ import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/widget/rounded_button.dart'; import 'package:flowy_infra_ui/widget/rounded_input_field.dart'; import 'package:flowy_infra_ui/widget/spacing.dart'; +import 'package:flowy_infra_ui/style_widget/snap_bar.dart'; import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart'; import 'package:flutter/material.dart'; @@ -39,15 +40,7 @@ class SignInScreen extends StatelessWidget { Either result, BuildContext context) { result.fold( (user) => router.pushWelcomeScreen(context, user), - (error) => _showErrorMessage(context, error.msg), - ); - } - - void _showErrorMessage(BuildContext context, String msg) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text(msg), - ), + (error) => showSnapBar(context, error.msg), ); } } @@ -179,8 +172,8 @@ class PasswordTextField extends StatelessWidget { return RoundedInputField( obscureText: true, fontSize: 14, - obscureIcon: svgWidgetWithName("home/Hide.svg"), - obscureHideIcon: svgWidgetWithName("home/Show.svg"), + obscureIcon: svg("home/Hide"), + obscureHideIcon: svg("home/Show"), hintText: 'Password', normalBorderColor: theme.shader4, highlightBorderColor: theme.red, diff --git a/app_flowy/lib/user/presentation/sign_up_screen.dart b/app_flowy/lib/user/presentation/sign_up_screen.dart index b839f0d6f3..428ecf5e72 100644 --- a/app_flowy/lib/user/presentation/sign_up_screen.dart +++ b/app_flowy/lib/user/presentation/sign_up_screen.dart @@ -8,6 +8,7 @@ import 'package:flowy_infra_ui/widget/rounded_input_field.dart'; import 'package:flowy_infra_ui/widget/spacing.dart'; import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart'; +import 'package:flowy_infra_ui/style_widget/snap_bar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:dartz/dartz.dart'; @@ -37,11 +38,7 @@ class SignUpScreen extends StatelessWidget { BuildContext context, Either result) { result.fold( (user) => router.pushWelcomeScreen(context, user), - (error) => ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text(error.msg), - ), - ), + (error) => showSnapBar(context, error.msg), ); } } @@ -140,8 +137,8 @@ class PasswordTextField extends StatelessWidget { builder: (context, state) { return RoundedInputField( obscureText: true, - obscureIcon: svgWidgetWithName("home/Hide.svg"), - obscureHideIcon: svgWidgetWithName("home/Show.svg"), + obscureIcon: svg("home/Hide"), + obscureHideIcon: svg("home/Show"), fontSize: 14, fontWeight: FontWeight.w500, hintText: "Password", @@ -175,8 +172,8 @@ class RepeatPasswordTextField extends StatelessWidget { builder: (context, state) { return RoundedInputField( obscureText: true, - obscureIcon: svgWidgetWithName("home/Hide.svg"), - obscureHideIcon: svgWidgetWithName("home/Show.svg"), + obscureIcon: svg("home/Hide"), + obscureHideIcon: svg("home/Show"), fontSize: 14, fontWeight: FontWeight.w500, hintText: "Repeate password", diff --git a/app_flowy/lib/user/presentation/widgets/background.dart b/app_flowy/lib/user/presentation/widgets/background.dart index 76a8122029..cfac6ac667 100644 --- a/app_flowy/lib/user/presentation/widgets/background.dart +++ b/app_flowy/lib/user/presentation/widgets/background.dart @@ -44,7 +44,7 @@ class AuthFormTitle extends StatelessWidget { children: [ SizedBox.fromSize( size: const Size.square(40), - child: svgWidgetWithName("flowy_logo.svg"), + child: svg("flowy_logo"), ), const VSpace(30), Text( diff --git a/app_flowy/lib/workspace/domain/image.dart b/app_flowy/lib/workspace/domain/image.dart index 2841269e6b..49110dd5b9 100644 --- a/app_flowy/lib/workspace/domain/image.dart +++ b/app_flowy/lib/workspace/domain/image.dart @@ -7,18 +7,17 @@ AssetImage assetImageForViewType(ViewType type) { return AssetImage('assets/images/$imageName'); } -Widget svgImageForViewType(ViewType type) { +Widget svgForViewType(ViewType type) { final imageName = imageNameForViewType(type); - final Widget svg = svgWidgetWithName(imageName); - - return svg; + final Widget widget = svg(imageName); + return widget; } String imageNameForViewType(ViewType type) { switch (type) { case ViewType.Doc: - return "file_icon.svg"; + return "file_icon"; default: - return "file_icon.svg"; + return "file_icon"; } } diff --git a/app_flowy/lib/workspace/presentation/app/app_header.dart b/app_flowy/lib/workspace/presentation/app/app_header.dart index 61adf6021a..e38005b0c1 100644 --- a/app_flowy/lib/workspace/presentation/app/app_header.dart +++ b/app_flowy/lib/workspace/presentation/app/app_header.dart @@ -1,7 +1,11 @@ import 'package:app_flowy/workspace/application/app/app_bloc.dart'; import 'package:expandable/expandable.dart'; +import 'package:flowy_infra/image.dart'; +import 'package:flowy_infra/theme.dart'; +import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flowy_infra_ui/widget/spacing.dart'; import 'package:flowy_infra_ui/style_widget/text_button.dart'; +import 'package:flowy_infra/flowy_icon_data_icons.dart'; import 'package:flowy_sdk/protobuf/flowy-workspace/app_create.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart'; import 'package:flutter/material.dart'; @@ -18,8 +22,9 @@ class AppHeader extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = context.watch(); return Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ InkWell( @@ -30,9 +35,9 @@ class AppHeader extends StatelessWidget { }, child: ExpandableIcon( theme: ExpandableThemeData( - expandIcon: Icons.arrow_drop_up, - collapseIcon: Icons.arrow_drop_down, - iconColor: Colors.black, + expandIcon: FlowyIconData.drop_down_show, + collapseIcon: FlowyIconData.drop_down_hide, + iconColor: theme.shader1, iconSize: AppPageSize.expandedIconSize, iconPadding: EdgeInsets.zero, hasIcon: false, @@ -41,13 +46,18 @@ class AppHeader extends StatelessWidget { ), HSpace(AppPageSize.expandedIconRightSpace), Expanded( - child: FlowyTextButton( + child: GestureDetector( + onTapDown: (_) { + ExpandableController.of(context, + rebuildOnChange: false, required: true) + ?.toggle(); + }, + child: FlowyText( app.name, - onPressed: () { - debugPrint('show app'); - }, + fontSize: 12, ), - ), + )), + // FlowyIconButton( // icon: const Icon(Icons.add), // onPressed: () { @@ -57,9 +67,9 @@ class AppHeader extends StatelessWidget { // }, // ), PopupMenuButton( - iconSize: 20, + iconSize: 16, tooltip: 'create new view', - icon: const Icon(Icons.add), + icon: svg("home/add"), padding: EdgeInsets.zero, onSelected: (viewType) => _createView(viewType as ViewType, context), diff --git a/app_flowy/lib/workspace/presentation/app/app_page.dart b/app_flowy/lib/workspace/presentation/app/app_page.dart index b932701ee9..5c59c71ec3 100644 --- a/app_flowy/lib/workspace/presentation/app/app_page.dart +++ b/app_flowy/lib/workspace/presentation/app/app_page.dart @@ -15,8 +15,8 @@ import 'package:styled_widget/styled_widget.dart'; import 'app_header.dart'; class AppPageSize { - static double expandedIconSize = 24; - static double expandedIconRightSpace = 8; + static double expandedIconSize = 20; + static double expandedIconRightSpace = 6; static double scale = 1; static double get expandedPadding => expandedIconSize * scale + expandedIconRightSpace; diff --git a/app_flowy/lib/workspace/presentation/view/view_page.dart b/app_flowy/lib/workspace/presentation/view/view_page.dart index 47c821b1ed..f225d99ebd 100644 --- a/app_flowy/lib/workspace/presentation/view/view_page.dart +++ b/app_flowy/lib/workspace/presentation/view/view_page.dart @@ -47,7 +47,7 @@ class ViewPage extends StatelessWidget { SizedBox( width: width, height: width, - child: svgImageForViewType(viewCtx.view.viewType)), + child: svgForViewType(viewCtx.view.viewType)), const HSpace(6), Text( viewCtx.view.name, diff --git a/app_flowy/lib/workspace/presentation/widgets/menu/menu_list.dart b/app_flowy/lib/workspace/presentation/widgets/menu/menu_list.dart index f043a92ec5..2d047d71a3 100644 --- a/app_flowy/lib/workspace/presentation/widgets/menu/menu_list.dart +++ b/app_flowy/lib/workspace/presentation/widgets/menu/menu_list.dart @@ -28,7 +28,13 @@ class MenuList extends StatelessWidget { child: Expanded( child: ListView.separated( itemCount: menuItems.length, - separatorBuilder: (context, index) => const VSpace(10), + separatorBuilder: (context, index) { + if (index == 0) { + return const VSpace(29); + } else { + return const VSpace(9); + } + }, physics: const BouncingScrollPhysics(), itemBuilder: (BuildContext context, int index) { return menuItems[index]; diff --git a/app_flowy/lib/workspace/presentation/widgets/menu/menu_new_app.dart b/app_flowy/lib/workspace/presentation/widgets/menu/menu_new_app.dart index 145eb3df62..8ca57ca230 100644 --- a/app_flowy/lib/workspace/presentation/widgets/menu/menu_new_app.dart +++ b/app_flowy/lib/workspace/presentation/widgets/menu/menu_new_app.dart @@ -1,9 +1,13 @@ import 'package:app_flowy/workspace/presentation/home/home_sizes.dart'; import 'package:app_flowy/workspace/presentation/widgets/menu/create_app_dialog.dart'; +import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/size.dart'; +import 'package:flowy_infra/theme.dart'; +import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flowy_infra_ui/widget/dialog/styled_dialogs.dart'; import 'package:flutter/material.dart'; import 'package:flowy_infra_ui/style_widget/extension.dart'; +import 'package:provider/provider.dart'; class NewAppButton extends StatelessWidget { final Function(String)? press; @@ -11,21 +15,18 @@ class NewAppButton extends StatelessWidget { const NewAppButton({this.press, Key? key}) : super(key: key); @override Widget build(BuildContext context) { + final theme = context.watch(); return SizedBox( height: HomeSizes.menuAddButtonHeight, child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ - const Icon(Icons.add_circle_rounded, size: 30), + svgWithSize("home/new_app", const Size(16, 16)), TextButton( onPressed: () async => await _showCreateAppDialog(context), - child: const Text( + child: const FlowyText( 'New App', - style: TextStyle( - color: Colors.black, - fontWeight: FontWeight.bold, - fontSize: 20, - ), + fontSize: 12, ), ) ], diff --git a/app_flowy/lib/workspace/presentation/widgets/menu/menu_top_bar.dart b/app_flowy/lib/workspace/presentation/widgets/menu/menu_top_bar.dart index 0db99423a4..1579b4ac17 100644 --- a/app_flowy/lib/workspace/presentation/widgets/menu/menu_top_bar.dart +++ b/app_flowy/lib/workspace/presentation/widgets/menu/menu_top_bar.dart @@ -1,5 +1,5 @@ import 'package:app_flowy/workspace/application/menu/menu_bloc.dart'; -import 'package:flowy_infra_ui/widget/spacing.dart'; +import 'package:flowy_infra/image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -11,19 +11,11 @@ class MenuTopBar extends StatelessWidget { builder: (context, state) { return Row( children: [ - const Image( - fit: BoxFit.cover, - width: 25, - height: 25, - image: AssetImage('assets/images/app_flowy_logo.jpg')), - const HSpace(8), - const Text( - 'AppFlowy', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), - ), + svgWithSize("flowy_logo_with_text", const Size(92, 17)), const Spacer(), IconButton( - icon: const Icon(Icons.arrow_left), + iconSize: 16, + icon: svg("home/hide_menu"), alignment: Alignment.centerRight, padding: EdgeInsets.zero, onPressed: () => diff --git a/app_flowy/lib/workspace/presentation/widgets/menu/menu_user.dart b/app_flowy/lib/workspace/presentation/widgets/menu/menu_user.dart index bdc41bde8f..7d554b5c3c 100644 --- a/app_flowy/lib/workspace/presentation/widgets/menu/menu_user.dart +++ b/app_flowy/lib/workspace/presentation/widgets/menu/menu_user.dart @@ -1,6 +1,7 @@ import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/workspace/application/menu/menu_user_bloc.dart'; import 'package:app_flowy/workspace/presentation/widgets/menu/menu_list.dart'; +import 'package:flowy_infra/image.dart'; import 'package:flowy_infra_ui/widget/spacing.dart'; import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart'; import 'package:flutter/material.dart'; @@ -18,23 +19,27 @@ class MenuUser extends MenuItem { create: (context) => getIt(param1: user)..add(const MenuUserEvent.initial()), child: BlocBuilder( - builder: (context, state) => Row(children: [ - _renderAvatar(context), - const HSpace(10), - _renderUserName(context), - const HSpace(10), - _renderDropButton(context), - ]), + builder: (context, state) => Row( + children: [ + _renderAvatar(context), + const HSpace(12), + _renderUserName(context), + const HSpace(4), + _renderDropButton(context), + ], + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + ), ), ); } Widget _renderAvatar(BuildContext context) { return SizedBox( - width: 30, - height: 30, + width: 20, + height: 20, child: ClipRRect( - borderRadius: BorderRadius.circular(10), + borderRadius: BorderRadius.circular(4), child: const Image(image: AssetImage('assets/images/avatar.jpg')), ), ); @@ -46,15 +51,15 @@ class MenuUser extends MenuItem { name = context.read().state.user.email; } return Flexible( - child: FlowyText(name, fontSize: 18), + child: FlowyText(name, fontSize: 12), ); } Widget _renderDropButton(BuildContext context) { return FlowyIconButton( - width: 30, - iconRatio: 0.8, - icon: const Icon(Icons.arrow_drop_down), + width: 20, + iconRatio: 1.0, + icon: svg("home/drop_down_show"), onPressed: () { debugPrint('show user profile'); }, diff --git a/app_flowy/packages/flowy_infra/lib/flowy_icon_data_icons.dart b/app_flowy/packages/flowy_infra/lib/flowy_icon_data_icons.dart new file mode 100644 index 0000000000..e6df4c7428 --- /dev/null +++ b/app_flowy/packages/flowy_infra/lib/flowy_icon_data_icons.dart @@ -0,0 +1,30 @@ +/// Flutter icons FlowyIconData +/// Copyright (C) 2021 by original authors @ fluttericon.com, fontello.com +/// This font was generated by FlutterIcon.com, which is derived from Fontello. +/// +/// To use this font, place it in your fonts/ directory and include the +/// following in your pubspec.yaml +/// +/// flutter: +/// fonts: +/// - family: FlowyIconData +/// fonts: +/// - asset: fonts/FlowyIconData.ttf +/// +/// +/// +// ignore_for_file: constant_identifier_names + +import 'package:flutter/widgets.dart'; + +class FlowyIconData { + FlowyIconData._(); + + static const _kFontFam = 'FlowyIconData'; + static const String? _kFontPkg = null; + + static const IconData drop_down_hide = + IconData(0xe800, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData drop_down_show = + IconData(0xe801, fontFamily: _kFontFam, fontPackage: _kFontPkg); +} diff --git a/app_flowy/packages/flowy_infra/lib/image.dart b/app_flowy/packages/flowy_infra/lib/image.dart index 6101735986..a247b1cf97 100644 --- a/app_flowy/packages/flowy_infra/lib/image.dart +++ b/app_flowy/packages/flowy_infra/lib/image.dart @@ -1,10 +1,17 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_svg/flutter_svg.dart'; -Widget svgWidgetWithName(String name) { +Widget svg(String name) { final Widget svg = SvgPicture.asset( - 'assets/images/$name', + 'assets/images/$name.svg', ); return svg; } + +Widget svgWithSize(String name, Size size) { + return SizedBox.fromSize( + size: size, + child: svg(name), + ); +} diff --git a/app_flowy/packages/flowy_infra/lib/theme.dart b/app_flowy/packages/flowy_infra/lib/theme.dart index 1ec8dddee2..57f81cf180 100644 --- a/app_flowy/packages/flowy_infra/lib/theme.dart +++ b/app_flowy/packages/flowy_infra/lib/theme.dart @@ -118,7 +118,6 @@ class AppTheme { var t = ThemeData( textTheme: (isDark ? ThemeData.dark() : ThemeData.light()).textTheme, textSelectionTheme: TextSelectionThemeData(cursorColor: main1), - visualDensity: VisualDensity.adaptivePlatformDensity, colorScheme: ColorScheme( brightness: isDark ? Brightness.dark : Brightness.light, primary: main1, diff --git a/app_flowy/packages/flowy_infra_ui/lib/style_widget/icon_button.dart b/app_flowy/packages/flowy_infra_ui/lib/style_widget/icon_button.dart index 47ee1bf85a..cbc4ebe9d2 100644 --- a/app_flowy/packages/flowy_infra_ui/lib/style_widget/icon_button.dart +++ b/app_flowy/packages/flowy_infra_ui/lib/style_widget/icon_button.dart @@ -4,7 +4,7 @@ class FlowyIconButton extends StatelessWidget { final double width; final double? height; final double iconRatio; - final Icon icon; + final Widget icon; final VoidCallback? onPressed; const FlowyIconButton({ diff --git a/app_flowy/packages/flowy_infra_ui/lib/style_widget/snap_bar.dart b/app_flowy/packages/flowy_infra_ui/lib/style_widget/snap_bar.dart new file mode 100644 index 0000000000..8c63a330ca --- /dev/null +++ b/app_flowy/packages/flowy_infra_ui/lib/style_widget/snap_bar.dart @@ -0,0 +1,25 @@ +import 'package:flutter/material.dart'; + +void showSnapBar(BuildContext context, String title) { + ScaffoldMessenger.of(context).clearSnackBars(); + + ScaffoldMessenger.of(context) + .showSnackBar( + SnackBar( + content: WillPopScope( + onWillPop: () async { + ScaffoldMessenger.of(context).removeCurrentSnackBar(); + return true; + }, + child: Text( + title, + style: const TextStyle( + color: Colors.black, + ), + ), + ), + ), + ) + .closed + .then((value) => null); +} diff --git a/app_flowy/packages/flowy_infra_ui/lib/style_widget/text.dart b/app_flowy/packages/flowy_infra_ui/lib/style_widget/text.dart index 51d74d2c12..b705c0f6ac 100644 --- a/app_flowy/packages/flowy_infra_ui/lib/style_widget/text.dart +++ b/app_flowy/packages/flowy_infra_ui/lib/style_widget/text.dart @@ -1,4 +1,6 @@ +import 'package:flowy_infra/theme.dart'; import 'package:flutter/widgets.dart'; +import 'package:provider/provider.dart'; class FlowyText extends StatelessWidget { final String title; @@ -13,11 +15,14 @@ class FlowyText extends StatelessWidget { @override Widget build(BuildContext context) { - return Text( - title, - overflow: overflow, - softWrap: false, - style: TextStyle(fontSize: fontSize), - ); + final theme = context.watch(); + return Text(title, + overflow: overflow, + softWrap: false, + style: TextStyle( + color: theme.shader1, + fontWeight: FontWeight.w500, + fontSize: fontSize + 2, + )); } } diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbenum.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbenum.dart index d867e7b933..4a74831cd7 100644 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbenum.dart +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbenum.dart @@ -24,6 +24,7 @@ class ErrorCode extends $pb.ProtobufEnum { static const ErrorCode UserIdInvalid = ErrorCode._(23, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserIdInvalid'); static const ErrorCode UserUnauthorized = ErrorCode._(24, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserUnauthorized'); static const ErrorCode UserNotExist = ErrorCode._(25, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserNotExist'); + static const ErrorCode ServerOffline = ErrorCode._(26, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ServerOffline'); static const ErrorCode InternalError = ErrorCode._(100, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'InternalError'); static const $core.List values = [ @@ -41,6 +42,7 @@ class ErrorCode extends $pb.ProtobufEnum { UserIdInvalid, UserUnauthorized, UserNotExist, + ServerOffline, InternalError, ]; diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbjson.dart index 9edbb8a790..74b5d65b07 100644 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbjson.dart +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbjson.dart @@ -26,12 +26,13 @@ const ErrorCode$json = const { const {'1': 'UserIdInvalid', '2': 23}, const {'1': 'UserUnauthorized', '2': 24}, const {'1': 'UserNotExist', '2': 25}, + const {'1': 'ServerOffline', '2': 26}, const {'1': 'InternalError', '2': 100}, ], }; /// Descriptor for `ErrorCode`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List errorCodeDescriptor = $convert.base64Decode('CglFcnJvckNvZGUSEAoMRW1haWxJc0VtcHR5EAASFgoSRW1haWxGb3JtYXRJbnZhbGlkEAESFgoSRW1haWxBbHJlYWR5RXhpc3RzEAISEwoPUGFzc3dvcmRJc0VtcHR5EAoSEwoPUGFzc3dvcmRUb29Mb25nEAsSJAogUGFzc3dvcmRDb250YWluc0ZvcmJpZENoYXJhY3RlcnMQDBIZChVQYXNzd29yZEZvcm1hdEludmFsaWQQDRIUChBQYXNzd29yZE5vdE1hdGNoEA4SEwoPVXNlck5hbWVUb29Mb25nEBQSJgoiVXNlck5hbWVDb250YWluRm9yYmlkZGVuQ2hhcmFjdGVycxAVEhMKD1VzZXJOYW1lSXNFbXB0eRAWEhEKDVVzZXJJZEludmFsaWQQFxIUChBVc2VyVW5hdXRob3JpemVkEBgSEAoMVXNlck5vdEV4aXN0EBkSEQoNSW50ZXJuYWxFcnJvchBk'); +final $typed_data.Uint8List errorCodeDescriptor = $convert.base64Decode('CglFcnJvckNvZGUSEAoMRW1haWxJc0VtcHR5EAASFgoSRW1haWxGb3JtYXRJbnZhbGlkEAESFgoSRW1haWxBbHJlYWR5RXhpc3RzEAISEwoPUGFzc3dvcmRJc0VtcHR5EAoSEwoPUGFzc3dvcmRUb29Mb25nEAsSJAogUGFzc3dvcmRDb250YWluc0ZvcmJpZENoYXJhY3RlcnMQDBIZChVQYXNzd29yZEZvcm1hdEludmFsaWQQDRIUChBQYXNzd29yZE5vdE1hdGNoEA4SEwoPVXNlck5hbWVUb29Mb25nEBQSJgoiVXNlck5hbWVDb250YWluRm9yYmlkZGVuQ2hhcmFjdGVycxAVEhMKD1VzZXJOYW1lSXNFbXB0eRAWEhEKDVVzZXJJZEludmFsaWQQFxIUChBVc2VyVW5hdXRob3JpemVkEBgSEAoMVXNlck5vdEV4aXN0EBkSEQoNU2VydmVyT2ZmbGluZRAaEhEKDUludGVybmFsRXJyb3IQZA=='); @$core.Deprecated('Use userErrorDescriptor instead') const UserError$json = const { '1': 'UserError', diff --git a/app_flowy/pubspec.yaml b/app_flowy/pubspec.yaml index 64c67cf847..ad6cf7ad7b 100644 --- a/app_flowy/pubspec.yaml +++ b/app_flowy/pubspec.yaml @@ -89,6 +89,11 @@ flutter: # the material Icons class. uses-material-design: true + fonts: + - family: FlowyIconData + fonts: + - asset: fonts/FlowyIconData.ttf + # To add assets to your application, add an assets section, like this: assets: - assets/images/ diff --git a/rust-lib/flowy-document/src/services/doc/edit/doc_actor.rs b/rust-lib/flowy-document/src/services/doc/edit/doc_actor.rs index ca2ed96ec1..c9d49b611a 100644 --- a/rust-lib/flowy-document/src/services/doc/edit/doc_actor.rs +++ b/rust-lib/flowy-document/src/services/doc/edit/doc_actor.rs @@ -4,38 +4,29 @@ use crate::{ services::doc::{ edit::{ message::{DocumentMsg, TransformDeltas}, - DocId, }, Document, }, }; use async_stream::stream; -use flowy_database::ConnectionPool; use flowy_ot::core::{Delta, OperationTransformable}; use futures::stream::StreamExt; use std::{convert::TryFrom, sync::Arc}; use tokio::sync::{mpsc, RwLock}; pub struct DocumentActor { - doc_id: DocId, document: Arc>, - pool: Arc, receiver: Option>, } impl DocumentActor { pub fn new( - doc_id: &str, delta: Delta, - pool: Arc, receiver: mpsc::UnboundedReceiver, ) -> Self { - let doc_id = doc_id.to_string(); let document = Arc::new(RwLock::new(Document::from_delta(delta))); Self { - doc_id, document, - pool, receiver: Some(receiver), } } diff --git a/rust-lib/flowy-document/src/services/doc/edit/edit_doc.rs b/rust-lib/flowy-document/src/services/doc/edit/edit_doc.rs index b59f1ce3cf..cb4586f667 100644 --- a/rust-lib/flowy-document/src/services/doc/edit/edit_doc.rs +++ b/rust-lib/flowy-document/src/services/doc/edit/edit_doc.rs @@ -33,7 +33,6 @@ pub struct ClientEditDoc { rev_manager: Arc, document: UnboundedSender, ws: Arc, - pool: Arc, user: Arc, } @@ -57,7 +56,6 @@ impl ClientEditDoc { doc_id, rev_manager, document, - pool, ws, user, }; @@ -323,9 +321,9 @@ async fn save_document(document: UnboundedSender, rev_id: RevId) -> result } -fn spawn_doc_edit_actor(doc_id: &str, delta: Delta, pool: Arc) -> UnboundedSender { +fn spawn_doc_edit_actor(_doc_id: &str, delta: Delta, _pool: Arc) -> UnboundedSender { let (sender, receiver) = mpsc::unbounded_channel::(); - let actor = DocumentActor::new(&doc_id, delta, pool.clone(), receiver); + let actor = DocumentActor::new(delta, receiver); tokio::spawn(actor.run()); sender } diff --git a/rust-lib/flowy-document/src/services/doc/revision/manager.rs b/rust-lib/flowy-document/src/services/doc/revision/manager.rs index 11c1ef3dca..2646bbc1c0 100644 --- a/rust-lib/flowy-document/src/services/doc/revision/manager.rs +++ b/rust-lib/flowy-document/src/services/doc/revision/manager.rs @@ -9,12 +9,6 @@ use flowy_ot::core::{Delta, OperationTransformable}; use std::sync::Arc; use tokio::sync::mpsc; -pub struct DocRevision { - pub base_rev_id: RevId, - pub rev_id: RevId, - pub delta: Delta, -} - pub trait RevisionServer: Send + Sync { fn fetch_document_from_remote(&self, doc_id: &str) -> ResultFuture; } diff --git a/rust-lib/flowy-document/src/services/doc/revision/model.rs b/rust-lib/flowy-document/src/services/doc/revision/model.rs index d971b74c0e..5a8a1debb3 100644 --- a/rust-lib/flowy-document/src/services/doc/revision/model.rs +++ b/rust-lib/flowy-document/src/services/doc/revision/model.rs @@ -6,7 +6,7 @@ use crate::{ use async_stream::stream; use flowy_database::ConnectionPool; use flowy_infra::future::ResultFuture; -use futures::{stream::StreamExt, TryFutureExt}; +use futures::{stream::StreamExt}; use std::{sync::Arc, time::Duration}; use tokio::sync::{broadcast, mpsc}; @@ -39,7 +39,7 @@ impl PendingRevId { if self.rev_id > rev_id { false } else { - self.sender.send(self.rev_id); + let _ = self.sender.send(self.rev_id); true } } @@ -137,7 +137,7 @@ impl PendingRevisionStream { match self.revisions.next().await? { None => Ok(()), Some(revision) => { - self.next_revision.send(revision).map_err(internal_error); + let _ = self.next_revision.send(revision).map_err(internal_error); let _ = tokio::time::timeout(Duration::from_millis(2000), ret.recv()).await; Ok(()) }, diff --git a/rust-lib/flowy-document/src/services/doc/revision/rev_store.rs b/rust-lib/flowy-document/src/services/doc/revision/rev_store.rs index 0b08856173..c76af0847f 100644 --- a/rust-lib/flowy-document/src/services/doc/revision/rev_store.rs +++ b/rust-lib/flowy-document/src/services/doc/revision/rev_store.rs @@ -12,10 +12,9 @@ use dashmap::DashMap; use flowy_database::ConnectionPool; use flowy_infra::future::ResultFuture; use flowy_ot::core::{Delta, OperationTransformable}; -use futures::{stream::StreamExt, TryFutureExt}; use std::{collections::VecDeque, sync::Arc, time::Duration}; use tokio::{ - sync::{broadcast, mpsc, oneshot, RwLock}, + sync::{broadcast, mpsc, RwLock}, task::{spawn_blocking, JoinHandle}, }; diff --git a/rust-lib/flowy-document/src/sql_tables/doc/rev_sql.rs b/rust-lib/flowy-document/src/sql_tables/doc/rev_sql.rs index a96cdf04e8..a5543203ff 100644 --- a/rust-lib/flowy-document/src/sql_tables/doc/rev_sql.rs +++ b/rust-lib/flowy-document/src/sql_tables/doc/rev_sql.rs @@ -104,6 +104,7 @@ impl RevTableSql { Ok(revisions) } + #[allow(dead_code)] pub(crate) fn delete_rev_table( &self, doc_id_s: &str, diff --git a/rust-lib/flowy-user/src/errors.rs b/rust-lib/flowy-user/src/errors.rs index 54749c60e9..88e8db9e76 100644 --- a/rust-lib/flowy-user/src/errors.rs +++ b/rust-lib/flowy-user/src/errors.rs @@ -39,8 +39,8 @@ impl UserError { pub(crate) fn code(code: ErrorCode) -> Self { Self { + msg: format!("{}", &code), code, - msg: "".to_owned(), } } @@ -97,6 +97,9 @@ pub enum ErrorCode { #[display(fmt = "User not exist")] UserNotExist = 25, + #[display(fmt = "Server is offline, try again later")] + ServerOffline = 26, + #[display(fmt = "Internal error")] InternalError = 100, } @@ -139,18 +142,26 @@ impl std::convert::From for UserError { impl std::convert::From for UserError { fn from(error: flowy_net::errors::ServerError) -> Self { - let code = server_error_to_user_error(error.code); - UserError::new(code, &error.msg) + let (code, msg) = server_error_to_user_error(error); + UserError::new(code, &msg) } } use flowy_net::errors::ErrorCode as ServerErrorCode; -fn server_error_to_user_error(code: ServerErrorCode) -> ErrorCode { - match code { +fn server_error_to_user_error(error: flowy_net::errors::ServerError) -> (ErrorCode, String) { + let code = match error.code { ServerErrorCode::UserUnauthorized => ErrorCode::UserUnauthorized, ServerErrorCode::PasswordNotMatch => ErrorCode::PasswordNotMatch, ServerErrorCode::RecordNotFound => ErrorCode::UserNotExist, + ServerErrorCode::ConnectRefused | ServerErrorCode::ConnectTimeout | ServerErrorCode::ConnectClose => ErrorCode::ServerOffline, _ => ErrorCode::InternalError, + }; + + if code != ErrorCode::InternalError { + let msg = format!("{}", &code); + (code, msg) + } else { + (code, error.msg) } } diff --git a/rust-lib/flowy-user/src/protobuf/model/errors.rs b/rust-lib/flowy-user/src/protobuf/model/errors.rs index 75bc5def5f..0e0779fa07 100644 --- a/rust-lib/flowy-user/src/protobuf/model/errors.rs +++ b/rust-lib/flowy-user/src/protobuf/model/errors.rs @@ -229,6 +229,7 @@ pub enum ErrorCode { UserIdInvalid = 23, UserUnauthorized = 24, UserNotExist = 25, + ServerOffline = 26, InternalError = 100, } @@ -253,6 +254,7 @@ impl ::protobuf::ProtobufEnum for ErrorCode { 23 => ::std::option::Option::Some(ErrorCode::UserIdInvalid), 24 => ::std::option::Option::Some(ErrorCode::UserUnauthorized), 25 => ::std::option::Option::Some(ErrorCode::UserNotExist), + 26 => ::std::option::Option::Some(ErrorCode::ServerOffline), 100 => ::std::option::Option::Some(ErrorCode::InternalError), _ => ::std::option::Option::None } @@ -274,6 +276,7 @@ impl ::protobuf::ProtobufEnum for ErrorCode { ErrorCode::UserIdInvalid, ErrorCode::UserUnauthorized, ErrorCode::UserNotExist, + ErrorCode::ServerOffline, ErrorCode::InternalError, ]; values @@ -305,7 +308,7 @@ impl ::protobuf::reflect::ProtobufValue for ErrorCode { static file_descriptor_proto_data: &'static [u8] = b"\ \n\x0cerrors.proto\"=\n\tUserError\x12\x1e\n\x04code\x18\x01\x20\x01(\ \x0e2\n.ErrorCodeR\x04code\x12\x10\n\x03msg\x18\x02\x20\x01(\tR\x03msg*\ - \xee\x02\n\tErrorCode\x12\x10\n\x0cEmailIsEmpty\x10\0\x12\x16\n\x12Email\ + \x81\x03\n\tErrorCode\x12\x10\n\x0cEmailIsEmpty\x10\0\x12\x16\n\x12Email\ FormatInvalid\x10\x01\x12\x16\n\x12EmailAlreadyExists\x10\x02\x12\x13\n\ \x0fPasswordIsEmpty\x10\n\x12\x13\n\x0fPasswordTooLong\x10\x0b\x12$\n\ \x20PasswordContainsForbidCharacters\x10\x0c\x12\x19\n\x15PasswordFormat\ @@ -313,46 +316,48 @@ static file_descriptor_proto_data: &'static [u8] = b"\ eTooLong\x10\x14\x12&\n\"UserNameContainForbiddenCharacters\x10\x15\x12\ \x13\n\x0fUserNameIsEmpty\x10\x16\x12\x11\n\rUserIdInvalid\x10\x17\x12\ \x14\n\x10UserUnauthorized\x10\x18\x12\x10\n\x0cUserNotExist\x10\x19\x12\ - \x11\n\rInternalError\x10dJ\x97\x06\n\x06\x12\x04\0\0\x16\x01\n\x08\n\ - \x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x05\x01\n\n\n\x03\ - \x04\0\x01\x12\x03\x02\x08\x11\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\ - \x17\n\x0c\n\x05\x04\0\x02\0\x06\x12\x03\x03\x04\r\n\x0c\n\x05\x04\0\x02\ - \0\x01\x12\x03\x03\x0e\x12\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x15\ - \x16\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x04\x04\x13\n\x0c\n\x05\x04\0\x02\ - \x01\x05\x12\x03\x04\x04\n\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04\x0b\ - \x0e\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x04\x11\x12\n\n\n\x02\x05\0\ - \x12\x04\x06\0\x16\x01\n\n\n\x03\x05\0\x01\x12\x03\x06\x05\x0e\n\x0b\n\ - \x04\x05\0\x02\0\x12\x03\x07\x04\x15\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\ - \x07\x04\x10\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x07\x13\x14\n\x0b\n\x04\ - \x05\0\x02\x01\x12\x03\x08\x04\x1b\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\ - \x08\x04\x16\n\x0c\n\x05\x05\0\x02\x01\x02\x12\x03\x08\x19\x1a\n\x0b\n\ - \x04\x05\0\x02\x02\x12\x03\t\x04\x1b\n\x0c\n\x05\x05\0\x02\x02\x01\x12\ - \x03\t\x04\x16\n\x0c\n\x05\x05\0\x02\x02\x02\x12\x03\t\x19\x1a\n\x0b\n\ - \x04\x05\0\x02\x03\x12\x03\n\x04\x19\n\x0c\n\x05\x05\0\x02\x03\x01\x12\ - \x03\n\x04\x13\n\x0c\n\x05\x05\0\x02\x03\x02\x12\x03\n\x16\x18\n\x0b\n\ - \x04\x05\0\x02\x04\x12\x03\x0b\x04\x19\n\x0c\n\x05\x05\0\x02\x04\x01\x12\ - \x03\x0b\x04\x13\n\x0c\n\x05\x05\0\x02\x04\x02\x12\x03\x0b\x16\x18\n\x0b\ - \n\x04\x05\0\x02\x05\x12\x03\x0c\x04*\n\x0c\n\x05\x05\0\x02\x05\x01\x12\ - \x03\x0c\x04$\n\x0c\n\x05\x05\0\x02\x05\x02\x12\x03\x0c')\n\x0b\n\x04\ - \x05\0\x02\x06\x12\x03\r\x04\x1f\n\x0c\n\x05\x05\0\x02\x06\x01\x12\x03\r\ - \x04\x19\n\x0c\n\x05\x05\0\x02\x06\x02\x12\x03\r\x1c\x1e\n\x0b\n\x04\x05\ - \0\x02\x07\x12\x03\x0e\x04\x1a\n\x0c\n\x05\x05\0\x02\x07\x01\x12\x03\x0e\ - \x04\x14\n\x0c\n\x05\x05\0\x02\x07\x02\x12\x03\x0e\x17\x19\n\x0b\n\x04\ - \x05\0\x02\x08\x12\x03\x0f\x04\x19\n\x0c\n\x05\x05\0\x02\x08\x01\x12\x03\ - \x0f\x04\x13\n\x0c\n\x05\x05\0\x02\x08\x02\x12\x03\x0f\x16\x18\n\x0b\n\ - \x04\x05\0\x02\t\x12\x03\x10\x04,\n\x0c\n\x05\x05\0\x02\t\x01\x12\x03\ - \x10\x04&\n\x0c\n\x05\x05\0\x02\t\x02\x12\x03\x10)+\n\x0b\n\x04\x05\0\ - \x02\n\x12\x03\x11\x04\x19\n\x0c\n\x05\x05\0\x02\n\x01\x12\x03\x11\x04\ - \x13\n\x0c\n\x05\x05\0\x02\n\x02\x12\x03\x11\x16\x18\n\x0b\n\x04\x05\0\ - \x02\x0b\x12\x03\x12\x04\x17\n\x0c\n\x05\x05\0\x02\x0b\x01\x12\x03\x12\ - \x04\x11\n\x0c\n\x05\x05\0\x02\x0b\x02\x12\x03\x12\x14\x16\n\x0b\n\x04\ - \x05\0\x02\x0c\x12\x03\x13\x04\x1a\n\x0c\n\x05\x05\0\x02\x0c\x01\x12\x03\ - \x13\x04\x14\n\x0c\n\x05\x05\0\x02\x0c\x02\x12\x03\x13\x17\x19\n\x0b\n\ - \x04\x05\0\x02\r\x12\x03\x14\x04\x16\n\x0c\n\x05\x05\0\x02\r\x01\x12\x03\ - \x14\x04\x10\n\x0c\n\x05\x05\0\x02\r\x02\x12\x03\x14\x13\x15\n\x0b\n\x04\ - \x05\0\x02\x0e\x12\x03\x15\x04\x18\n\x0c\n\x05\x05\0\x02\x0e\x01\x12\x03\ - \x15\x04\x11\n\x0c\n\x05\x05\0\x02\x0e\x02\x12\x03\x15\x14\x17b\x06proto\ - 3\ + \x11\n\rServerOffline\x10\x1a\x12\x11\n\rInternalError\x10dJ\xc0\x06\n\ + \x06\x12\x04\0\0\x17\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x04\0\ + \x12\x04\x02\0\x05\x01\n\n\n\x03\x04\0\x01\x12\x03\x02\x08\x11\n\x0b\n\ + \x04\x04\0\x02\0\x12\x03\x03\x04\x17\n\x0c\n\x05\x04\0\x02\0\x06\x12\x03\ + \x03\x04\r\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\x0e\x12\n\x0c\n\x05\ + \x04\0\x02\0\x03\x12\x03\x03\x15\x16\n\x0b\n\x04\x04\0\x02\x01\x12\x03\ + \x04\x04\x13\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x04\x04\n\n\x0c\n\x05\ + \x04\0\x02\x01\x01\x12\x03\x04\x0b\x0e\n\x0c\n\x05\x04\0\x02\x01\x03\x12\ + \x03\x04\x11\x12\n\n\n\x02\x05\0\x12\x04\x06\0\x17\x01\n\n\n\x03\x05\0\ + \x01\x12\x03\x06\x05\x0e\n\x0b\n\x04\x05\0\x02\0\x12\x03\x07\x04\x15\n\ + \x0c\n\x05\x05\0\x02\0\x01\x12\x03\x07\x04\x10\n\x0c\n\x05\x05\0\x02\0\ + \x02\x12\x03\x07\x13\x14\n\x0b\n\x04\x05\0\x02\x01\x12\x03\x08\x04\x1b\n\ + \x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x08\x04\x16\n\x0c\n\x05\x05\0\x02\ + \x01\x02\x12\x03\x08\x19\x1a\n\x0b\n\x04\x05\0\x02\x02\x12\x03\t\x04\x1b\ + \n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\t\x04\x16\n\x0c\n\x05\x05\0\x02\ + \x02\x02\x12\x03\t\x19\x1a\n\x0b\n\x04\x05\0\x02\x03\x12\x03\n\x04\x19\n\ + \x0c\n\x05\x05\0\x02\x03\x01\x12\x03\n\x04\x13\n\x0c\n\x05\x05\0\x02\x03\ + \x02\x12\x03\n\x16\x18\n\x0b\n\x04\x05\0\x02\x04\x12\x03\x0b\x04\x19\n\ + \x0c\n\x05\x05\0\x02\x04\x01\x12\x03\x0b\x04\x13\n\x0c\n\x05\x05\0\x02\ + \x04\x02\x12\x03\x0b\x16\x18\n\x0b\n\x04\x05\0\x02\x05\x12\x03\x0c\x04*\ + \n\x0c\n\x05\x05\0\x02\x05\x01\x12\x03\x0c\x04$\n\x0c\n\x05\x05\0\x02\ + \x05\x02\x12\x03\x0c')\n\x0b\n\x04\x05\0\x02\x06\x12\x03\r\x04\x1f\n\x0c\ + \n\x05\x05\0\x02\x06\x01\x12\x03\r\x04\x19\n\x0c\n\x05\x05\0\x02\x06\x02\ + \x12\x03\r\x1c\x1e\n\x0b\n\x04\x05\0\x02\x07\x12\x03\x0e\x04\x1a\n\x0c\n\ + \x05\x05\0\x02\x07\x01\x12\x03\x0e\x04\x14\n\x0c\n\x05\x05\0\x02\x07\x02\ + \x12\x03\x0e\x17\x19\n\x0b\n\x04\x05\0\x02\x08\x12\x03\x0f\x04\x19\n\x0c\ + \n\x05\x05\0\x02\x08\x01\x12\x03\x0f\x04\x13\n\x0c\n\x05\x05\0\x02\x08\ + \x02\x12\x03\x0f\x16\x18\n\x0b\n\x04\x05\0\x02\t\x12\x03\x10\x04,\n\x0c\ + \n\x05\x05\0\x02\t\x01\x12\x03\x10\x04&\n\x0c\n\x05\x05\0\x02\t\x02\x12\ + \x03\x10)+\n\x0b\n\x04\x05\0\x02\n\x12\x03\x11\x04\x19\n\x0c\n\x05\x05\0\ + \x02\n\x01\x12\x03\x11\x04\x13\n\x0c\n\x05\x05\0\x02\n\x02\x12\x03\x11\ + \x16\x18\n\x0b\n\x04\x05\0\x02\x0b\x12\x03\x12\x04\x17\n\x0c\n\x05\x05\0\ + \x02\x0b\x01\x12\x03\x12\x04\x11\n\x0c\n\x05\x05\0\x02\x0b\x02\x12\x03\ + \x12\x14\x16\n\x0b\n\x04\x05\0\x02\x0c\x12\x03\x13\x04\x1a\n\x0c\n\x05\ + \x05\0\x02\x0c\x01\x12\x03\x13\x04\x14\n\x0c\n\x05\x05\0\x02\x0c\x02\x12\ + \x03\x13\x17\x19\n\x0b\n\x04\x05\0\x02\r\x12\x03\x14\x04\x16\n\x0c\n\x05\ + \x05\0\x02\r\x01\x12\x03\x14\x04\x10\n\x0c\n\x05\x05\0\x02\r\x02\x12\x03\ + \x14\x13\x15\n\x0b\n\x04\x05\0\x02\x0e\x12\x03\x15\x04\x17\n\x0c\n\x05\ + \x05\0\x02\x0e\x01\x12\x03\x15\x04\x11\n\x0c\n\x05\x05\0\x02\x0e\x02\x12\ + \x03\x15\x14\x16\n\x0b\n\x04\x05\0\x02\x0f\x12\x03\x16\x04\x18\n\x0c\n\ + \x05\x05\0\x02\x0f\x01\x12\x03\x16\x04\x11\n\x0c\n\x05\x05\0\x02\x0f\x02\ + \x12\x03\x16\x14\x17b\x06proto3\ "; static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; diff --git a/rust-lib/flowy-user/src/protobuf/proto/errors.proto b/rust-lib/flowy-user/src/protobuf/proto/errors.proto index f27f9f6929..6c352ddbe5 100644 --- a/rust-lib/flowy-user/src/protobuf/proto/errors.proto +++ b/rust-lib/flowy-user/src/protobuf/proto/errors.proto @@ -19,5 +19,6 @@ enum ErrorCode { UserIdInvalid = 23; UserUnauthorized = 24; UserNotExist = 25; + ServerOffline = 26; InternalError = 100; } diff --git a/rust-lib/flowy-user/src/services/user/user_session.rs b/rust-lib/flowy-user/src/services/user/user_session.rs index c20e3bde53..db9dbe1be7 100644 --- a/rust-lib/flowy-user/src/services/user/user_session.rs +++ b/rust-lib/flowy-user/src/services/user/user_session.rs @@ -300,7 +300,12 @@ impl UserSession { WsState::Init => {}, WsState::Connected(_) => {}, WsState::Disconnected(_) => { - ws_controller.retry().await; + match ws_controller.retry().await { + Ok(_) => {}, + Err(e) => { + log::error!("Retry websocket connect failed: {:?}", e); + } + } }, } },