fix: reset first page when switching space (#6097)

* fix: reset first page when switching space

* fix: primary field icon align issue in grid page
This commit is contained in:
Lucas.Xu 2024-08-28 21:25:57 +08:00 committed by GitHub
parent 9ee8cc6a7b
commit 9209562648
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 38 additions and 30 deletions

View File

@ -1,5 +1,5 @@
import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/mention_page_block.dart';
import 'package:appflowy/plugins/document/presentation/sync_error_page.dart';
import 'package:appflowy/shared/flowy_error_page.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/protobuf.dart';
import 'package:flowy_infra/uuid.dart';
import 'package:flutter_test/flutter_test.dart';
@ -92,7 +92,7 @@ void main() {
);
expect(finder, findsOneWidget);
await tester.tapButton(finder);
expect(find.byType(SyncErrorPage), findsOneWidget);
expect(find.byType(AppFlowyErrorPage), findsOneWidget);
});
});
}

View File

@ -3,13 +3,13 @@ import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/mobile/presentation/database/board/board.dart';
import 'package:appflowy/mobile/presentation/database/board/widgets/group_card_header.dart';
import 'package:appflowy/mobile/presentation/database/card/card.dart';
import 'package:appflowy/mobile/presentation/widgets/widgets.dart';
import 'package:appflowy/plugins/database/application/database_controller.dart';
import 'package:appflowy/plugins/database/board/application/board_bloc.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/header/field_type_extension.dart';
import 'package:appflowy/plugins/database/widgets/card/card.dart';
import 'package:appflowy/plugins/database/widgets/cell/card_cell_builder.dart';
import 'package:appflowy/plugins/database/widgets/cell/card_cell_style_maps/mobile_board_card_cell_style.dart';
import 'package:appflowy/shared/flowy_error_page.dart';
import 'package:appflowy/workspace/application/settings/appearance/appearance_cubit.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/protobuf.dart';
@ -69,10 +69,8 @@ class _MobileBoardPageState extends State<MobileBoardPage> {
loading: (_) => const Center(
child: CircularProgressIndicator.adaptive(),
),
error: (err) => FlowyMobileStateContainer.error(
emoji: '🛸',
title: LocaleKeys.board_mobile_failedToLoad.tr(),
errorMsg: err.toString(),
error: (err) => AppFlowyErrorPage(
error: err.error,
),
ready: (data) => const _BoardContent(),
orElse: () => const SizedBox.shrink(),

View File

@ -45,6 +45,7 @@ class MobileFolders extends StatelessWidget {
SpaceEvent.reset(
user,
state.currentWorkspace?.workspaceId ?? workspaceId,
false,
),
);
},

View File

@ -4,11 +4,13 @@ import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet.dart';
import 'package:appflowy/mobile/presentation/home/space/mobile_space_header.dart';
import 'package:appflowy/mobile/presentation/home/space/mobile_space_menu.dart';
import 'package:appflowy/mobile/presentation/page_item/mobile_view_item.dart';
import 'package:appflowy/shared/list_extension.dart';
import 'package:appflowy/workspace/application/sidebar/folder/folder_bloc.dart';
import 'package:appflowy/workspace/application/sidebar/space/space_bloc.dart';
import 'package:appflowy/workspace/application/view/view_bloc.dart';
import 'package:appflowy/workspace/application/view/view_ext.dart';
import 'package:appflowy/workspace/presentation/home/home_sizes.dart';
import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
@ -124,8 +126,15 @@ class _Pages extends StatelessWidget {
final spaceType = space.spacePermission == SpacePermission.publicToAll
? FolderSpaceType.public
: FolderSpaceType.private;
final childViews = state.view.childViews.unique((view) => view.id);
if (childViews.length != state.view.childViews.length) {
final duplicatedViews = state.view.childViews
.where((view) => childViews.contains(view))
.toList();
Log.error('some view id are duplicated: $duplicatedViews');
}
return Column(
children: state.view.childViews
children: childViews
.map(
(view) => MobileViewItem(
key: ValueKey(

View File

@ -1,5 +1,3 @@
import 'package:flutter/material.dart';
import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/mobile/presentation/database/card/card_detail/mobile_card_detail_screen.dart';
@ -9,6 +7,7 @@ import 'package:appflowy/plugins/database/application/row/row_service.dart';
import 'package:appflowy/plugins/database/grid/application/grid_bloc.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/shortcuts.dart';
import 'package:appflowy/plugins/database/tab_bar/tab_bar_view.dart';
import 'package:appflowy/shared/flowy_error_page.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/workspace/application/action_navigation/action_navigation_bloc.dart';
import 'package:appflowy_backend/log.dart';
@ -18,7 +17,7 @@ import 'package:collection/collection.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/theme_extension.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flowy_infra_ui/widget/error_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:linked_scroll_controller/linked_scroll_controller.dart';
@ -106,9 +105,8 @@ class _MobileGridPageState extends State<MobileGridPage> {
_openRow(context, widget.initialRowId, true);
return result.successOrFail.fold(
(_) => GridShortcuts(child: GridPageContent(view: widget.view)),
(err) => FlowyErrorPage.message(
err.toString(),
howToFix: LocaleKeys.errorDialog_howToFixFallback.tr(),
(err) => AppFlowyErrorPage(
error: err,
),
);
},

View File

@ -1,5 +1,3 @@
import 'package:flutter/material.dart';
import 'package:appflowy/plugins/database/application/cell/cell_controller.dart';
import 'package:appflowy/plugins/database/application/database_controller.dart';
import 'package:appflowy/plugins/database/application/field/field_controller.dart';
@ -9,6 +7,7 @@ import 'package:appflowy/plugins/database/application/row/row_service.dart';
import 'package:appflowy/plugins/database/grid/application/row/row_bloc.dart';
import 'package:appflowy/plugins/database/widgets/cell/editable_cell_builder.dart';
import 'package:appflowy/plugins/database/widgets/row/cells/mobile_cell_container.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../layout/sizes.dart';
@ -81,8 +80,8 @@ class _MobileGridRowState extends State<MobileGridRow> {
@override
Future<void> dispose() async {
await _rowController.dispose();
super.dispose();
await _rowController.dispose();
}
}

View File

@ -1,5 +1,5 @@
import 'package:appflowy/plugins/database/widgets/row/cells/cell_container.dart';
import 'package:appflowy/plugins/database/application/cell/bloc/text_cell_bloc.dart';
import 'package:appflowy/plugins/database/widgets/row/cells/cell_container.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@ -17,27 +17,28 @@ class MobileGridTextCellSkin extends IEditableTextCellSkin {
) {
return Row(
children: [
const HSpace(10),
BlocBuilder<TextCellBloc, TextCellState>(
buildWhen: (p, c) => p.emoji != c.emoji,
builder: (context, state) => Center(
child: FlowyText(
child: FlowyText.emoji(
state.emoji,
fontSize: 16,
fontSize: 15,
optimizeEmojiAlign: true,
),
),
),
const HSpace(6),
Expanded(
child: TextField(
controller: textEditingController,
focusNode: focusNode,
style:
Theme.of(context).textTheme.bodyMedium?.copyWith(fontSize: 15),
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontSize: 15,
),
decoration: const InputDecoration(
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
contentPadding:
EdgeInsets.symmetric(horizontal: 14, vertical: 12),
contentPadding: EdgeInsets.symmetric(horizontal: 4),
isCollapsed: true,
),
onTapOutside: (event) => focusNode.unfocus(),

View File

@ -11,7 +11,7 @@ import 'package:appflowy/plugins/document/presentation/editor_plugins/image/cust
import 'package:appflowy/plugins/document/presentation/editor_plugins/image/multi_image_block_component/multi_image_block_component.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
import 'package:appflowy/plugins/document/presentation/editor_style.dart';
import 'package:appflowy/plugins/document/presentation/sync_error_page.dart';
import 'package:appflowy/shared/flowy_error_page.dart';
import 'package:appflowy/shared/patterns/common_patterns.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/workspace/application/action_navigation/action_navigation_bloc.dart';
@ -114,7 +114,7 @@ class _DocumentPageState extends State<DocumentPage>
if (error != null || editorState == null) {
Log.error(error);
return Center(
child: SyncErrorPage(
child: AppFlowyErrorPage(
error: error,
),
);

View File

@ -13,8 +13,8 @@ import 'package:flowy_infra_ui/widget/spacing.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
class SyncErrorPage extends StatelessWidget {
const SyncErrorPage({
class AppFlowyErrorPage extends StatelessWidget {
const AppFlowyErrorPage({
super.key,
this.error,
});

View File

@ -296,7 +296,7 @@ class SpaceBloc extends Bloc<SpaceEvent, SpaceState> {
),
);
},
reset: (userProfile, workspaceId) async {
reset: (userProfile, workspaceId, openFirstPage) async {
if (workspaceId == _workspaceId) {
return;
}
@ -738,6 +738,7 @@ class SpaceEvent with _$SpaceEvent {
const factory SpaceEvent.reset(
UserProfilePB userProfile,
String workspaceId,
bool openFirstPage,
) = _Reset;
const factory SpaceEvent.migrate() = _Migrate;
const factory SpaceEvent.switchToNextSpace() = _SwitchToNextSpace;

View File

@ -196,6 +196,7 @@ class HomeSideBar extends StatelessWidget {
userProfile,
state.currentWorkspace?.workspaceId ??
workspaceSetting.workspaceId,
true,
),
);
}