mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: the desktop cover didn't sync with the mobile cover (#5252)
This commit is contained in:
parent
2eb88821ca
commit
554c821db9
@ -2,6 +2,7 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:appflowy/generated/flowy_svgs.g.dart';
|
import 'package:appflowy/generated/flowy_svgs.g.dart';
|
||||||
import 'package:appflowy/generated/locale_keys.g.dart';
|
import 'package:appflowy/generated/locale_keys.g.dart';
|
||||||
|
import 'package:appflowy/mobile/application/page_style/document_page_style_bloc.dart';
|
||||||
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet.dart';
|
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet.dart';
|
||||||
import 'package:appflowy/plugins/base/emoji/emoji_picker_screen.dart';
|
import 'package:appflowy/plugins/base/emoji/emoji_picker_screen.dart';
|
||||||
import 'package:appflowy/plugins/base/icon/icon_picker.dart';
|
import 'package:appflowy/plugins/base/icon/icon_picker.dart';
|
||||||
@ -14,6 +15,7 @@ import 'package:appflowy/plugins/document/presentation/editor_plugins/image/uplo
|
|||||||
import 'package:appflowy/plugins/document/presentation/editor_plugins/migration/editor_migration.dart';
|
import 'package:appflowy/plugins/document/presentation/editor_plugins/migration/editor_migration.dart';
|
||||||
import 'package:appflowy/plugins/document/presentation/editor_style.dart';
|
import 'package:appflowy/plugins/document/presentation/editor_style.dart';
|
||||||
import 'package:appflowy/shared/appflowy_network_image.dart';
|
import 'package:appflowy/shared/appflowy_network_image.dart';
|
||||||
|
import 'package:appflowy/workspace/application/view/view_ext.dart';
|
||||||
import 'package:appflowy/workspace/application/view/view_listener.dart';
|
import 'package:appflowy/workspace/application/view/view_listener.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:appflowy_editor/appflowy_editor.dart' hide UploadImageMenu;
|
import 'package:appflowy_editor/appflowy_editor.dart' hide UploadImageMenu;
|
||||||
@ -85,9 +87,12 @@ class _DocumentCoverWidgetState extends State<DocumentCoverWidget> {
|
|||||||
widget.node.attributes[DocumentHeaderBlockKeys.coverDetails];
|
widget.node.attributes[DocumentHeaderBlockKeys.coverDetails];
|
||||||
String? get icon => widget.node.attributes[DocumentHeaderBlockKeys.icon];
|
String? get icon => widget.node.attributes[DocumentHeaderBlockKeys.icon];
|
||||||
bool get hasIcon => viewIcon.isNotEmpty;
|
bool get hasIcon => viewIcon.isNotEmpty;
|
||||||
bool get hasCover => coverType != CoverType.none;
|
bool get hasCover =>
|
||||||
|
coverType != CoverType.none ||
|
||||||
|
cover?.type != PageStyleCoverImageType.none;
|
||||||
|
|
||||||
String viewIcon = '';
|
String viewIcon = '';
|
||||||
|
PageStyleCover? cover;
|
||||||
late final ViewListener viewListener;
|
late final ViewListener viewListener;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -95,6 +100,7 @@ class _DocumentCoverWidgetState extends State<DocumentCoverWidget> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
final value = widget.view.icon.value;
|
final value = widget.view.icon.value;
|
||||||
viewIcon = value.isNotEmpty ? value : icon ?? '';
|
viewIcon = value.isNotEmpty ? value : icon ?? '';
|
||||||
|
cover = widget.view.cover;
|
||||||
widget.node.addListener(_reload);
|
widget.node.addListener(_reload);
|
||||||
viewListener = ViewListener(
|
viewListener = ViewListener(
|
||||||
viewId: widget.view.id,
|
viewId: widget.view.id,
|
||||||
@ -102,6 +108,7 @@ class _DocumentCoverWidgetState extends State<DocumentCoverWidget> {
|
|||||||
onViewUpdated: (p0) {
|
onViewUpdated: (p0) {
|
||||||
setState(() {
|
setState(() {
|
||||||
viewIcon = p0.icon.value;
|
viewIcon = p0.icon.value;
|
||||||
|
cover = p0.cover;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -176,48 +176,55 @@ class EditorMigration {
|
|||||||
root.attributes[DocumentHeaderBlockKeys.coverType],
|
root.attributes[DocumentHeaderBlockKeys.coverType],
|
||||||
);
|
);
|
||||||
final coverDetails = root.attributes[DocumentHeaderBlockKeys.coverDetails];
|
final coverDetails = root.attributes[DocumentHeaderBlockKeys.coverDetails];
|
||||||
|
|
||||||
|
Map extra = {};
|
||||||
|
|
||||||
if (coverType == CoverType.none ||
|
if (coverType == CoverType.none ||
|
||||||
coverDetails == null ||
|
coverDetails == null ||
|
||||||
coverDetails is! String) {
|
coverDetails is! String) {
|
||||||
return;
|
extra = {
|
||||||
}
|
ViewExtKeys.coverKey: {
|
||||||
|
ViewExtKeys.coverTypeKey: PageStyleCoverImageType.none.toString(),
|
||||||
Map extra = {};
|
ViewExtKeys.coverValueKey: '',
|
||||||
switch (coverType) {
|
},
|
||||||
case CoverType.asset:
|
};
|
||||||
// The new version does not support the asset cover.
|
} else {
|
||||||
break;
|
switch (coverType) {
|
||||||
case CoverType.color:
|
case CoverType.asset:
|
||||||
extra = {
|
// The new version does not support the asset cover.
|
||||||
ViewExtKeys.coverKey: {
|
break;
|
||||||
ViewExtKeys.coverTypeKey:
|
case CoverType.color:
|
||||||
PageStyleCoverImageType.pureColor.toString(),
|
extra = {
|
||||||
ViewExtKeys.coverValueKey: coverDetails,
|
ViewExtKeys.coverKey: {
|
||||||
},
|
ViewExtKeys.coverTypeKey:
|
||||||
};
|
PageStyleCoverImageType.pureColor.toString(),
|
||||||
break;
|
ViewExtKeys.coverValueKey: coverDetails,
|
||||||
case CoverType.file:
|
},
|
||||||
if (isURL(coverDetails)) {
|
};
|
||||||
if (coverDetails.contains('unsplash')) {
|
break;
|
||||||
extra = {
|
case CoverType.file:
|
||||||
ViewExtKeys.coverKey: {
|
if (isURL(coverDetails)) {
|
||||||
ViewExtKeys.coverTypeKey:
|
if (coverDetails.contains('unsplash')) {
|
||||||
PageStyleCoverImageType.unsplashImage.toString(),
|
extra = {
|
||||||
ViewExtKeys.coverValueKey: coverDetails,
|
ViewExtKeys.coverKey: {
|
||||||
},
|
ViewExtKeys.coverTypeKey:
|
||||||
};
|
PageStyleCoverImageType.unsplashImage.toString(),
|
||||||
} else {
|
ViewExtKeys.coverValueKey: coverDetails,
|
||||||
extra = {
|
},
|
||||||
ViewExtKeys.coverKey: {
|
};
|
||||||
ViewExtKeys.coverTypeKey:
|
} else {
|
||||||
PageStyleCoverImageType.customImage.toString(),
|
extra = {
|
||||||
ViewExtKeys.coverValueKey: coverDetails,
|
ViewExtKeys.coverKey: {
|
||||||
},
|
ViewExtKeys.coverTypeKey:
|
||||||
};
|
PageStyleCoverImageType.customImage.toString(),
|
||||||
|
ViewExtKeys.coverValueKey: coverDetails,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extra.isEmpty) {
|
if (extra.isEmpty) {
|
||||||
|
Loading…
Reference in New Issue
Block a user