Skip to content

Commit

Permalink
fix: v0.6.2 issues (AppFlowy-IO#5654)
Browse files Browse the repository at this point in the history
* fix: remove create button in move to menu

* fix: add loading indicator when duplicating space

* fix: sidebar header expand icon status

* fix: text within select tag overflow

* fix: callout block icon align issue

* feat: sync the space icon when creating a space

* fix: duplicated hover views

* fix: cover image doesn't update
  • Loading branch information
LucasXu0 authored Jul 1, 2024
1 parent 50f5be3 commit c78f23e
Show file tree
Hide file tree
Showing 25 changed files with 142 additions and 98 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:appflowy/plugins/database/application/cell/bloc/select_option_cell_bloc.dart';
import 'package:appflowy/plugins/database/grid/presentation/layout/sizes.dart';
import 'package:appflowy/plugins/database/widgets/row/cells/cell_container.dart';
import 'package:appflowy/plugins/database/widgets/cell_editor/extension.dart';
import 'package:appflowy/plugins/database/application/cell/bloc/select_option_cell_bloc.dart';
import 'package:appflowy/plugins/database/widgets/cell_editor/select_option_cell_editor.dart';
import 'package:appflowy/plugins/database/widgets/row/cells/cell_container.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';
import 'package:appflowy_popover/appflowy_popover.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
Expand Down Expand Up @@ -56,7 +56,7 @@ class DesktopGridSelectOptionCellSkin extends IEditableSelectOptionCellSkin {
child: SelectOptionTag(
option: option,
padding: const EdgeInsets.symmetric(
vertical: 1,
vertical: 4,
horizontal: 8,
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/database/widgets/row/cells/cell_container.dart';
import 'package:appflowy/plugins/database/widgets/cell_editor/extension.dart';
import 'package:appflowy/plugins/database/application/cell/bloc/select_option_cell_bloc.dart';
import 'package:appflowy/plugins/database/widgets/cell_editor/extension.dart';
import 'package:appflowy/plugins/database/widgets/cell_editor/select_option_cell_editor.dart';
import 'package:appflowy/plugins/database/widgets/row/cells/cell_container.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';
import 'package:appflowy_popover/appflowy_popover.dart';
import 'package:easy_localization/easy_localization.dart';
Expand Down Expand Up @@ -67,7 +67,7 @@ class DesktopRowDetailSelectOptionCellSkin
return SelectOptionTag(
option: option,
padding: const EdgeInsets.symmetric(
vertical: 1,
vertical: 4,
horizontal: 8,
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ class SelectOptionTag extends StatelessWidget {
);

return Container(
height: 20,
padding: onRemove == null ? padding : padding.copyWith(right: 2.0),
decoration: BoxDecoration(
color: optionColor,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import 'dart:collection';
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/database/application/cell/bloc/select_option_cell_editor_bloc.dart';
Expand All @@ -14,12 +10,14 @@ import 'package:appflowy_popover/appflowy_popover.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:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

import '../../grid/presentation/layout/sizes.dart';
import '../../grid/presentation/widgets/common/type_option_separator.dart';
import '../field/type_option_editor/select/select_option_editor.dart';

import 'extension.dart';
import 'select_option_text_field.dart';

Expand Down Expand Up @@ -476,11 +474,11 @@ class SelectOptionTagCell extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 6.0,
vertical: 4.0,
),
child: SelectOptionTag(
option: option,
padding: const EdgeInsets.symmetric(horizontal: 8),
padding:
const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ class _SelectOptionTextFieldState extends State<SelectOptionTextField> {
(option) => SelectOptionTag(
option: option,
onRemove: (option) => widget.onRemove(option),
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 1),
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
),
),
)
.toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'package:appflowy/plugins/document/application/document_data_pb_extension
import 'package:appflowy/plugins/document/application/document_listener.dart';
import 'package:appflowy/plugins/document/application/document_service.dart';
import 'package:appflowy/plugins/document/application/editor_transaction_adapter.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/migration/editor_migration.dart';
import 'package:appflowy/plugins/trash/application/trash_service.dart';
import 'package:appflowy/shared/feature_flags.dart';
import 'package:appflowy/startup/startup.dart';
Expand All @@ -19,7 +18,6 @@ import 'package:appflowy/util/color_to_hex_string.dart';
import 'package:appflowy/util/debounce.dart';
import 'package:appflowy/util/throttle.dart';
import 'package:appflowy/workspace/application/view/view_listener.dart';
import 'package:appflowy/workspace/application/view/view_service.dart';
import 'package:appflowy_backend/protobuf/flowy-document/entities.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-document/protobuf.dart';
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
Expand Down Expand Up @@ -118,11 +116,6 @@ class DocumentBloc extends Bloc<DocumentEvent, DocumentState> {
final result = await _fetchDocumentState();
_onViewChanged();
_onDocumentChanged();
result.onSuccess((s) {
if (s != null) {
_migrateCover(s);
}
});
final newState = await result.fold(
(s) async {
final userProfilePB =
Expand Down Expand Up @@ -390,14 +383,6 @@ class DocumentBloc extends Bloc<DocumentEvent, DocumentState> {
metadata: jsonEncode(metadata.toJson()),
);
}

// from version 0.5.5, the cover is stored in the view.ext
Future<void> _migrateCover(EditorState editorState) async {
final view = await ViewBackendService.getView(documentId);
view.onSuccess((s) {
return EditorMigration.migrateCoverIfNeeded(s, editorState);
});
}
}

@freezed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ class _CalloutBlockComponentWidgetState
), // force to refresh the popover state
title: '',
emoji: emoji,
emojiSize: 16.0,
onSubmitted: (emoji, controller) {
setEmoji(emoji);
controller?.close();
Expand All @@ -204,7 +205,7 @@ class _CalloutBlockComponentWidgetState
),
Flexible(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
padding: const EdgeInsets.symmetric(vertical: 6.0),
child: buildCalloutBlockComponent(context, textDirection),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class _DocumentCoverWidgetState extends State<DocumentCoverWidget> {

String viewIcon = '';
PageStyleCover? cover;
late ViewPB view;
late final ViewListener viewListener;

@override
Expand All @@ -99,6 +100,7 @@ class _DocumentCoverWidgetState extends State<DocumentCoverWidget> {
final value = widget.view.icon.value;
viewIcon = value.isNotEmpty ? value : icon ?? '';
cover = widget.view.cover;
view = widget.view;
widget.node.addListener(_reload);
viewListener = ViewListener(
viewId: widget.view.id,
Expand All @@ -107,6 +109,7 @@ class _DocumentCoverWidgetState extends State<DocumentCoverWidget> {
setState(() {
viewIcon = p0.icon.value;
cover = p0.cover;
view = p0;
});
},
);
Expand Down Expand Up @@ -137,7 +140,7 @@ class _DocumentCoverWidgetState extends State<DocumentCoverWidget> {
),
if (hasCover)
DocumentCover(
view: widget.view,
view: view,
editorState: widget.editorState,
node: widget.node,
coverType: coverType,
Expand Down Expand Up @@ -204,7 +207,7 @@ class _DocumentCoverWidgetState extends State<DocumentCoverWidget> {
// compatible with version > 0.5.5.
EditorMigration.migrateCoverIfNeeded(
widget.view,
widget.editorState,
attributes,
overwrite: true,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,17 @@ class EditorMigration {
// Now, the cover is stored in the view.ext.
static void migrateCoverIfNeeded(
ViewPB view,
EditorState editorState, {
Attributes attributes, {
bool overwrite = false,
}) async {
if (view.extra.isNotEmpty && !overwrite) {
return;
}

final root = editorState.document.root;
final coverType = CoverType.fromString(
root.attributes[DocumentHeaderBlockKeys.coverType],
attributes[DocumentHeaderBlockKeys.coverType],
);
final coverDetails = root.attributes[DocumentHeaderBlockKeys.coverDetails];
final coverDetails = attributes[DocumentHeaderBlockKeys.coverDetails];

Map extra = {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,16 @@ class SpaceBloc extends Bloc<SpaceEvent, SpaceState> {
if (currentSpace == null) {
return;
}
emit(state.copyWith(isDuplicatingSpace: true));

final newSpace = await _duplicateSpace(currentSpace);
// open the duplicated space
if (newSpace != null) {
add(const SpaceEvent.didReceiveSpaceUpdate());
add(SpaceEvent.open(newSpace));
}

emit(state.copyWith(isDuplicatingSpace: false));
},
);
},
Expand Down Expand Up @@ -346,25 +351,22 @@ class SpaceBloc extends Bloc<SpaceEvent, SpaceState> {
SpacePermission.private => ViewSectionPB.Private,
};

final extra = {
ViewExtKeys.isSpaceKey: true,
ViewExtKeys.spaceIconKey: icon,
ViewExtKeys.spaceIconColorKey: iconColor,
ViewExtKeys.spacePermissionKey: permission.index,
ViewExtKeys.spaceCreatedAtKey: DateTime.now().millisecondsSinceEpoch,
};
final result = await _workspaceService.createView(
name: name,
viewSection: section,
setAsCurrent: false,
setAsCurrent: true,
viewId: viewId,
extra: jsonEncode(extra),
);
return await result.fold((space) async {
Log.info('Space created: $space');
final extra = {
ViewExtKeys.isSpaceKey: true,
ViewExtKeys.spaceIconKey: icon,
ViewExtKeys.spaceIconColorKey: iconColor,
ViewExtKeys.spacePermissionKey: permission.index,
ViewExtKeys.spaceCreatedAtKey: DateTime.now().millisecondsSinceEpoch,
};
await ViewBackendService.updateView(
viewId: space.id,
extra: jsonEncode(extra),
);
return space;
}, (error) {
Log.error('Failed to create space: $error');
Expand Down Expand Up @@ -620,19 +622,17 @@ class SpaceBloc extends Bloc<SpaceEvent, SpaceState> {
}

for (final view in space.childViews) {
unawaited(
ViewBackendService.duplicate(
view: view,
openAfterDuplicate: true,
includeChildren: true,
parentViewId: newSpace.id,
suffix: '',
),
await ViewBackendService.duplicate(
view: view,
openAfterDuplicate: true,
includeChildren: true,
parentViewId: newSpace.id,
suffix: '',
);
}

Log.info('Space duplicated: $newSpace');
add(const SpaceEvent.didReceiveSpaceUpdate());

return newSpace;
}
}
Expand Down Expand Up @@ -688,6 +688,7 @@ class SpaceState with _$SpaceState {
@Default(null) ViewPB? lastCreatedPage,
FlowyResult<void, FlowyError>? createPageResult,
@Default(false) bool shouldShowUpgradeDialog,
@Default(false) bool isDuplicatingSpace,
}) = _SpaceState;

factory SpaceState.initial() => const SpaceState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,21 @@ extension ViewExtension on ViewPB {
}
}

FlowySvg get spaceIconSvg {
FlowySvg? get spaceIconSvg {
try {
final ext = jsonDecode(extra);
final icon = ext[ViewExtKeys.spaceIconKey];
final color = ext[ViewExtKeys.spaceIconColorKey];
if (icon == null || color == null) {
return const FlowySvg(FlowySvgs.space_icon_s, blendMode: null);
return null;
}
return FlowySvg(
FlowySvgData('assets/flowy_icons/16x/$icon.svg'),
color: Color(int.parse(color)),
blendMode: BlendMode.srcOut,
);
} catch (e) {
return const FlowySvg(FlowySvgs.space_icon_s, blendMode: null);
return null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class WorkspaceService {
ViewLayoutPB? layout,
bool? setAsCurrent,
String? viewId,
String? extra,
}) {
final payload = CreateViewPayloadPB.create()
..parentViewId = workspaceId
Expand All @@ -42,6 +43,10 @@ class WorkspaceService {
payload.viewId = viewId;
}

if (extra != null) {
payload.extra = extra;
}

return FolderEventCreateView(payload).send();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class _MovePageMenuState extends State<MovePageMenu> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SpacePopup(
showCreateButton: false,
child: CurrentSpace(
space: space,
),
Expand Down
Loading

0 comments on commit c78f23e

Please sign in to comment.