diff --git a/Anytype/Sources/PresentationLayer/ObjectCreationSettings/SetObjectCreationSettingsCoordinator.swift b/Anytype/Sources/PresentationLayer/ObjectCreationSettings/SetObjectCreationSettingsCoordinator.swift index 52397517bb..4ebedecb4f 100644 --- a/Anytype/Sources/PresentationLayer/ObjectCreationSettings/SetObjectCreationSettingsCoordinator.swift +++ b/Anytype/Sources/PresentationLayer/ObjectCreationSettings/SetObjectCreationSettingsCoordinator.swift @@ -72,7 +72,7 @@ final class SetObjectCreationSettingsCoordinator: data: EditorPageObject( objectId: setting.templateId, spaceId: setting.spaceId, - usecase: .templateEditing + usecase: .embedded ), showHeader: false, setupEditorInput: { [weak self] input, _ in diff --git a/Anytype/Sources/PresentationLayer/ObjectCreationSettings/TemplatesCoordinator.swift b/Anytype/Sources/PresentationLayer/ObjectCreationSettings/TemplatesCoordinator.swift index cb6e9f6418..4b7569dc54 100644 --- a/Anytype/Sources/PresentationLayer/ObjectCreationSettings/TemplatesCoordinator.swift +++ b/Anytype/Sources/PresentationLayer/ObjectCreationSettings/TemplatesCoordinator.swift @@ -45,7 +45,7 @@ extension TemplatesCoordinator: TemplatePickerViewModuleOutput { data: EditorPageObject( objectId: template.id, spaceId: template.spaceId, - usecase: .templateEditing + usecase: .embedded ), showHeader: false, setupEditorInput: { [weak self] input, objectId in diff --git a/Anytype/Sources/PresentationLayer/ObjectCreationSettings/Views/Selection/SetObjectCreationSettingsViewModel.swift b/Anytype/Sources/PresentationLayer/ObjectCreationSettings/Views/Selection/SetObjectCreationSettingsViewModel.swift index 0b3e908520..2f4fdb28b3 100644 --- a/Anytype/Sources/PresentationLayer/ObjectCreationSettings/Views/Selection/SetObjectCreationSettingsViewModel.swift +++ b/Anytype/Sources/PresentationLayer/ObjectCreationSettings/Views/Selection/SetObjectCreationSettingsViewModel.swift @@ -306,7 +306,7 @@ extension TemplatePreviewModel { header: HeaderBuilder.buildObjectHeader( details: objectDetails, usecase: .templatePreview, - presentationUsecase: .editor, + presentationUsecase: .full, onIconTap: {}, onCoverTap: {} ), diff --git a/Anytype/Sources/PresentationLayer/TextEditor/Assembly/EditorScreenData+Details.swift b/Anytype/Sources/PresentationLayer/TextEditor/Assembly/EditorScreenData+Details.swift index a32083836a..397c9efd2e 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/Assembly/EditorScreenData+Details.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/Assembly/EditorScreenData+Details.swift @@ -27,7 +27,7 @@ extension EditorPageObject { details: ObjectDetails, mode: DocumentMode = .handling, blockId: String? = nil, - usecase: ObjectHeaderEmptyData.ObjectHeaderEmptyUsecase = .editor + usecase: ObjectHeaderEmptyUsecase = .full ) { self.objectId = details.id self.spaceId = details.spaceId @@ -38,12 +38,18 @@ extension EditorPageObject { } extension EditorSetObject { - init(details: ObjectDetails, activeViewId: String? = nil, mode: DocumentMode = .handling) { + init( + details: ObjectDetails, + activeViewId: String? = nil, + mode: DocumentMode = .handling, + usecase: ObjectHeaderEmptyUsecase = .full + ) { self.objectId = details.id self.spaceId = details.spaceId self.activeViewId = activeViewId self.inline = nil self.mode = mode + self.usecase = usecase } } diff --git a/Anytype/Sources/PresentationLayer/TextEditor/Assembly/EditorScreenData.swift b/Anytype/Sources/PresentationLayer/TextEditor/Assembly/EditorScreenData.swift index aa79352d21..e842b8e8e5 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/Assembly/EditorScreenData.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/Assembly/EditorScreenData.swift @@ -18,14 +18,14 @@ struct EditorPageObject: Hashable, Codable { let spaceId: String let mode: DocumentMode var blockId: String? - let usecase: ObjectHeaderEmptyData.ObjectHeaderEmptyUsecase + let usecase: ObjectHeaderEmptyUsecase init( objectId: String, spaceId: String, mode: DocumentMode = .handling, blockId: String? = nil, - usecase: ObjectHeaderEmptyData.ObjectHeaderEmptyUsecase = .editor + usecase: ObjectHeaderEmptyUsecase = .full ) { self.objectId = objectId self.spaceId = spaceId @@ -41,19 +41,22 @@ struct EditorSetObject: Hashable, Codable { let activeViewId: String? var inline: EditorInlineSetObject? let mode: DocumentMode + let usecase: ObjectHeaderEmptyUsecase init( objectId: String, spaceId: String, activeViewId: String? = nil, inline: EditorInlineSetObject? = nil, - mode: DocumentMode = .handling + mode: DocumentMode = .handling, + usecase: ObjectHeaderEmptyUsecase = .full ) { self.objectId = objectId self.spaceId = spaceId self.activeViewId = activeViewId self.inline = inline self.mode = mode + self.usecase = usecase } } diff --git a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/EditorPageViewModelConfiguration.swift b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/EditorPageViewModelConfiguration.swift index 089ce41129..658046de2d 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/EditorPageViewModelConfiguration.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/EditorPageViewModelConfiguration.swift @@ -2,5 +2,5 @@ import Foundation struct EditorPageViewModelConfiguration { let blockId: String? - let usecase: ObjectHeaderEmptyData.ObjectHeaderEmptyUsecase + let usecase: ObjectHeaderEmptyUsecase } diff --git a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Empty/ObjectHeaderEmptyContentView.swift b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Empty/ObjectHeaderEmptyContentView.swift index a63de0e472..19d09a2ff7 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Empty/ObjectHeaderEmptyContentView.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Empty/ObjectHeaderEmptyContentView.swift @@ -29,10 +29,10 @@ final class ObjectHeaderEmptyContentView: UIView, BlockContentView { } switch configuration.data.presentationStyle { - case .editor: + case .full: heightConstraint?.constant = ObjectHeaderConstants.emptyViewHeight - case .templateEditing: - heightConstraint?.constant = ObjectHeaderConstants.templateEditingEmptyViewHeight + case .embedded: + heightConstraint?.constant = ObjectHeaderConstants.emptyViewHeightCompact } } } diff --git a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/HeaderBuilder.swift b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/HeaderBuilder.swift index 5340f92059..00375b1d86 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/HeaderBuilder.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/HeaderBuilder.swift @@ -4,7 +4,7 @@ enum HeaderBuilder { static func buildObjectHeader( details: ObjectDetails, usecase: ObjectIconImageUsecase, - presentationUsecase: ObjectHeaderEmptyData.ObjectHeaderEmptyUsecase, + presentationUsecase: ObjectHeaderEmptyUsecase, onIconTap: @escaping () -> Void, onCoverTap: @escaping () -> Void ) -> ObjectHeader { diff --git a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/ObjectHeader.swift b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/ObjectHeader.swift index 57e13c1005..e1408a55eb 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/ObjectHeader.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/ObjectHeader.swift @@ -11,7 +11,7 @@ enum ObjectHeader: Hashable { } static func empty( - usecase: ObjectHeaderEmptyData.ObjectHeaderEmptyUsecase, + usecase: ObjectHeaderEmptyUsecase, onTap: @escaping () -> Void ) -> Self { return .empty(data: .init(presentationStyle: usecase, onTap: onTap), isShimmering: false) diff --git a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/ObjectHeaderEmptyData.swift b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/ObjectHeaderEmptyData.swift index d6144374b1..6f62e37781 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/ObjectHeaderEmptyData.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/ObjectHeaderEmptyData.swift @@ -1,11 +1,11 @@ import Foundation +enum ObjectHeaderEmptyUsecase: Codable { + case full + case embedded +} + struct ObjectHeaderEmptyData: Hashable { - enum ObjectHeaderEmptyUsecase: Codable { - case editor - case templateEditing - } - let presentationStyle: ObjectHeaderEmptyUsecase @EquatableNoop private(set) var onTap: () -> Void } diff --git a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/ObjectHeaderConstants.swift b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/ObjectHeaderConstants.swift index 259e559074..bc0e7162ea 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/ObjectHeaderConstants.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/ObjectHeaderConstants.swift @@ -2,8 +2,8 @@ import CoreGraphics enum ObjectHeaderConstants { static let minimizedHeaderHeight: CGFloat = 48 - static let templateEditingEmptyViewHeight: CGFloat = 32 static let emptyViewHeight: CGFloat = 124 + static let emptyViewHeightCompact: CGFloat = 32 static let coverHeight: CGFloat = 228 static let coverBottomInset: CGFloat = 32 diff --git a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Settings/History/Object/ObjectVersionView.swift b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Settings/History/Object/ObjectVersionView.swift index e7216ee31a..046971b639 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Settings/History/Object/ObjectVersionView.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Settings/History/Object/ObjectVersionView.swift @@ -12,12 +12,10 @@ struct ObjectVersionView: View { var body: some View { VStack(spacing: 0) { + header content buttons } - .overlay(alignment: .topLeading) { - header - } .task { await model.setupObject() } diff --git a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Settings/History/Object/ObjectVersionViewModel.swift b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Settings/History/Object/ObjectVersionViewModel.swift index e773814a1f..652bd28e0a 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Settings/History/Object/ObjectVersionViewModel.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Settings/History/Object/ObjectVersionViewModel.swift @@ -42,9 +42,23 @@ final class ObjectVersionViewModel: ObservableObject { private func currentScreenData() -> EditorScreenData? { let mode: DocumentMode = .version(data.versionId) if data.isListType { - return .set(EditorSetObject(objectId: data.objectId, spaceId: data.spaceId, mode: mode)) + return .set( + EditorSetObject( + objectId: data.objectId, + spaceId: data.spaceId, + mode: mode, + usecase: .embedded + ) + ) } else { - return .page(EditorPageObject(objectId: data.objectId, spaceId: data.spaceId, mode: mode)) + return .page( + EditorPageObject( + objectId: data.objectId, + spaceId: data.spaceId, + mode: mode, + usecase: .embedded + ) + ) } } } diff --git a/Anytype/Sources/PresentationLayer/TextEditor/Set/EditorSetViewModel.swift b/Anytype/Sources/PresentationLayer/TextEditor/Set/EditorSetViewModel.swift index 8e47f9ca00..fbd628ab2b 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/Set/EditorSetViewModel.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/Set/EditorSetViewModel.swift @@ -185,7 +185,7 @@ final class EditorSetViewModel: ObservableObject { targetObjectId: setDocument.targetObjectId, configuration: EditorPageViewModelConfiguration( blockId: nil, - usecase: .editor + usecase: data.usecase ), output: output ) diff --git a/Anytype/Sources/PresentationLayer/TextEditor/Set/Views/Header/SetFullHeader.swift b/Anytype/Sources/PresentationLayer/TextEditor/Set/Views/Header/SetFullHeader.swift index 07ab8bedc4..fbd08fda75 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/Set/Views/Header/SetFullHeader.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/Set/Views/Header/SetFullHeader.swift @@ -31,7 +31,7 @@ struct SetFullHeader: View { private var inlineHeader: some View { VStack(alignment: .leading, spacing: 0) { - emptyCover + emptyCover(presentationStyle: .full) VStack(alignment: .leading, spacing: 8) { iconWithTitle featuredRelationsView @@ -46,7 +46,7 @@ struct SetFullHeader: View { switch model.headerModel.header { case .empty(let data, _): Button(action: data.onTap) { - emptyCover + emptyCover(presentationStyle: data.presentationStyle) } case .filled(let state, _): ObjectHeaderFilledContentSwitfUIView( @@ -62,9 +62,9 @@ struct SetFullHeader: View { } } - private var emptyCover: some View { + private func emptyCover(presentationStyle: ObjectHeaderEmptyUsecase) -> some View { Color.Background.primary - .frame(height: ObjectHeaderConstants.emptyViewHeight) + .frame(height: presentationStyle == .full ? ObjectHeaderConstants.emptyViewHeight : ObjectHeaderConstants.emptyViewHeightCompact) } }