diff --git a/Anytype.xcodeproj/project.pbxproj b/Anytype.xcodeproj/project.pbxproj index 5e4c3a1d1c..993ee33c08 100644 --- a/Anytype.xcodeproj/project.pbxproj +++ b/Anytype.xcodeproj/project.pbxproj @@ -1239,7 +1239,6 @@ 8624C8612A6E577E0065CBC0 /* EditorPageViewModelConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8624C8602A6E577E0065CBC0 /* EditorPageViewModelConfiguration.swift */; }; 863776832A658AF10040308E /* TemplateModulesAssembly.swift in Sources */ = {isa = PBXBuildFile; fileRef = 863776822A658AF10040308E /* TemplateModulesAssembly.swift */; }; 863776852A658B410040308E /* TemplateOptionAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 863776842A658B410040308E /* TemplateOptionAction.swift */; }; - 863776872A6663E50040308E /* VisualEffectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 863776862A6663E50040308E /* VisualEffectView.swift */; }; 8637768A2A66644B0040308E /* DataviewTemplateSelectionInteractorProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 863776892A66644B0040308E /* DataviewTemplateSelectionInteractorProvider.swift */; }; 8637768F2A6668680040308E /* TemplatePreviewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8637768E2A6668680040308E /* TemplatePreviewModel.swift */; }; 863776902A6669030040308E /* MockTemplateSelectionInteractorProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8637768B2A6664DB0040308E /* MockTemplateSelectionInteractorProvider.swift */; }; @@ -2706,7 +2705,6 @@ 8624C8602A6E577E0065CBC0 /* EditorPageViewModelConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorPageViewModelConfiguration.swift; sourceTree = ""; }; 863776822A658AF10040308E /* TemplateModulesAssembly.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateModulesAssembly.swift; sourceTree = ""; }; 863776842A658B410040308E /* TemplateOptionAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateOptionAction.swift; sourceTree = ""; }; - 863776862A6663E50040308E /* VisualEffectView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VisualEffectView.swift; sourceTree = ""; }; 863776892A66644B0040308E /* DataviewTemplateSelectionInteractorProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataviewTemplateSelectionInteractorProvider.swift; sourceTree = ""; }; 8637768B2A6664DB0040308E /* MockTemplateSelectionInteractorProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockTemplateSelectionInteractorProvider.swift; sourceTree = ""; }; 8637768E2A6668680040308E /* TemplatePreviewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplatePreviewModel.swift; sourceTree = ""; }; @@ -8050,7 +8048,6 @@ 863877792A5808620024F814 /* TemplatesSelectionView.swift */, 8638777B2A58088F0024F814 /* TemplatesSelectionViewModel.swift */, 861E75F52A5C03E400F18552 /* EditableView.swift */, - 863776862A6663E50040308E /* VisualEffectView.swift */, 863776842A658B410040308E /* TemplateOptionAction.swift */, ); path = Selection; @@ -10098,7 +10095,6 @@ 535F799A274705C30050A1B8 /* FlowRelationsViewModel.swift in Sources */, 2A1F949929795FEB00E25782 /* FavoriteSubscriptionService.swift in Sources */, 2ADFA9DC2949C61D00F64688 /* UIKitModule.swift in Sources */, - 863776872A6663E50040308E /* VisualEffectView.swift in Sources */, C93B2D2F274E41390008544D /* CustomStateKeys.swift in Sources */, 2A2C3311289294B8008BC326 /* ModulesDI.swift in Sources */, 2AFFFB9B292778B700A487E1 /* ObjectSettingModuleAssembly.swift in Sources */, diff --git a/Anytype/Generated/Assets.swift b/Anytype/Generated/Assets.swift index 2fbcd548cd..a495612a60 100644 --- a/Anytype/Generated/Assets.swift +++ b/Anytype/Generated/Assets.swift @@ -72,7 +72,6 @@ internal enum Asset { static let yellow = ColorAsset(name: "VeryLight/yellow") } internal enum Additional { - static let editingBackground = ColorAsset(name: "Additional/editingBackground") static let space = ColorAsset(name: "Additional/space") } internal enum Auth { diff --git a/Anytype/Generated/Color+Assets.swift b/Anytype/Generated/Color+Assets.swift index 70e68119cd..a3721837cf 100644 --- a/Anytype/Generated/Color+Assets.swift +++ b/Anytype/Generated/Color+Assets.swift @@ -65,7 +65,6 @@ extension Color { // MARK: - Additional enum Additional { - internal static let editingBackground = Color(asset: Asset.Additional.editingBackground) internal static let space = Color(asset: Asset.Additional.space) } diff --git a/Anytype/Generated/Color+Info.swift b/Anytype/Generated/Color+Info.swift index 3142e3b072..89fa1dc617 100644 --- a/Anytype/Generated/Color+Info.swift +++ b/Anytype/Generated/Color+Info.swift @@ -119,7 +119,6 @@ extension UIColor.Additional { static let collectionInfo = ColorCollectionInfo( name: "Additional", colors: [ - ColorInfo(name: "editingBackground", color: UIColor.Additional.editingBackground), ColorInfo(name: "space", color: UIColor.Additional.space) ] ) diff --git a/Anytype/Generated/UIColor+Assets.swift b/Anytype/Generated/UIColor+Assets.swift index 4bcd2a2f78..6a00b2897f 100644 --- a/Anytype/Generated/UIColor+Assets.swift +++ b/Anytype/Generated/UIColor+Assets.swift @@ -65,7 +65,6 @@ extension UIColor { // MARK: - Additional enum Additional { - internal static let editingBackground = UIColor(asset: Asset.Additional.editingBackground) internal static let space = UIColor(asset: Asset.Additional.space) } diff --git a/Anytype/Resources/SystemColors.xcassets/Additional/editingBackground.colorset/Contents.json b/Anytype/Resources/SystemColors.xcassets/Additional/editingBackground.colorset/Contents.json deleted file mode 100644 index 3a50d2bf5b..0000000000 --- a/Anytype/Resources/SystemColors.xcassets/Additional/editingBackground.colorset/Contents.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xEA", - "green" : "0xEA", - "red" : "0xEA" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Anytype/Sources/Design system/Fonts/AnytypeFont.swift b/Anytype/Sources/Design system/Fonts/AnytypeFont.swift index e0c7ca93f2..f706d83ec2 100644 --- a/Anytype/Sources/Design system/Fonts/AnytypeFont.swift +++ b/Anytype/Sources/Design system/Fonts/AnytypeFont.swift @@ -41,4 +41,6 @@ enum AnytypeFont: CaseIterable { case authBody case authCaption case authInput + + case navigationBarTitle } diff --git a/Anytype/Sources/Design system/Fonts/AnytypeFontConfig.swift b/Anytype/Sources/Design system/Fonts/AnytypeFontConfig.swift index 0a422988ff..74d932d093 100644 --- a/Anytype/Sources/Design system/Fonts/AnytypeFontConfig.swift +++ b/Anytype/Sources/Design system/Fonts/AnytypeFontConfig.swift @@ -239,6 +239,14 @@ extension AnytypeFont { lineHeight: 22, kern: -0.24 ) + case .navigationBarTitle: + return AnytypeFontConfig( + fontName: .inter, + size: 15, + weight: .semibold, + lineHeight: 20, + kern: -0.24 + ) } } diff --git a/Anytype/Sources/PresentationLayer/Templates/TemplateSelectionCoordinator.swift b/Anytype/Sources/PresentationLayer/Templates/TemplateSelectionCoordinator.swift index 1c3faa2be6..ce0f4a2eef 100644 --- a/Anytype/Sources/PresentationLayer/Templates/TemplateSelectionCoordinator.swift +++ b/Anytype/Sources/PresentationLayer/Templates/TemplateSelectionCoordinator.swift @@ -65,7 +65,14 @@ final class TemplateSelectionCoordinator: TemplateSelectionCoordinatorProtocol { func showTemplateEditing(blockId: BlockId, onTemplateSelection: @escaping (BlockId) -> Void) { let editorPage = editorAssembly.buildEditorModule( browser: nil, - data: .page(.init(objectId: blockId, isSupportedForEdit: true, isOpenedForPreview: false)) + data: .page( + .init( + objectId: blockId, + isSupportedForEdit: true, + isOpenedForPreview: false, + usecase: .templateEditing + ) + ) ) let editingTemplateViewController = TemplateEditingViewController( editorViewController: editorPage.vc, diff --git a/Anytype/Sources/PresentationLayer/Templates/Views/Selection/EditableView.swift b/Anytype/Sources/PresentationLayer/Templates/Views/Selection/EditableView.swift index ddb75204f3..1c7e2803e5 100644 --- a/Anytype/Sources/PresentationLayer/Templates/Views/Selection/EditableView.swift +++ b/Anytype/Sources/PresentationLayer/Templates/Views/Selection/EditableView.swift @@ -5,6 +5,10 @@ protocol ContextualMenuItemsProvider { var contextMenuItems: AnyView { get } } +private enum Constaints { + static let dotImageSize: CGFloat = 28 +} + struct EditableView: View { var content: Content var onTap: () -> Void @@ -33,16 +37,13 @@ struct EditableView: View { } var dotImage: some View { - ZStack { - VisualEffectView(effect: UIBlurEffect(style: .light)) - .cornerRadius(14) - .background(Color.Additional.editingBackground.opacity(0.51)) - .frame(width: 24, height: 24) - .cornerRadius(14) - Image(asset: ImageAsset.X24.more) - .foregroundColor(Color.Button.active) - - } + Image(asset: ImageAsset.X24.more) + .resizable() + .frame(width: Constaints.dotImageSize, height: Constaints.dotImageSize) + .foregroundColor(Color.Button.active) + .background(Color.Background.highlightedOfSelected) + .background(.ultraThinMaterial) + .cornerRadius(Constaints.dotImageSize / 2) } } diff --git a/Anytype/Sources/PresentationLayer/Templates/Views/Selection/TemplatesSelectionView.swift b/Anytype/Sources/PresentationLayer/Templates/Views/Selection/TemplatesSelectionView.swift index 23d0d9b2d3..b057736142 100644 --- a/Anytype/Sources/PresentationLayer/Templates/Views/Selection/TemplatesSelectionView.swift +++ b/Anytype/Sources/PresentationLayer/Templates/Views/Selection/TemplatesSelectionView.swift @@ -9,9 +9,9 @@ struct TemplatesSelectionView: View { var body: some View { VStack { - Spacer.fixedHeight(16) + Spacer.fixedHeight(8) navigation - Spacer.fixedHeight(14) + Spacer.fixedHeight(8) collection Spacer.fixedHeight(24) } diff --git a/Anytype/Sources/PresentationLayer/Templates/Views/Selection/TemplatesSelectionViewModel.swift b/Anytype/Sources/PresentationLayer/Templates/Views/Selection/TemplatesSelectionViewModel.swift index 3797fdc768..88b0466563 100644 --- a/Anytype/Sources/PresentationLayer/Templates/Views/Selection/TemplatesSelectionViewModel.swift +++ b/Anytype/Sources/PresentationLayer/Templates/Views/Selection/TemplatesSelectionViewModel.swift @@ -154,6 +154,7 @@ extension TemplatePreviewModel { header: HeaderBuilder.buildObjectHeader( details: objectDetails, usecase: .templatePreview, + presentationUsecase: .editor, onIconTap: {}, onCoverTap: {} ), diff --git a/Anytype/Sources/PresentationLayer/Templates/Views/Selection/VisualEffectView.swift b/Anytype/Sources/PresentationLayer/Templates/Views/Selection/VisualEffectView.swift deleted file mode 100644 index 18646100e1..0000000000 --- a/Anytype/Sources/PresentationLayer/Templates/Views/Selection/VisualEffectView.swift +++ /dev/null @@ -1,8 +0,0 @@ -import SwiftUI -import UIKit - -struct VisualEffectView: UIViewRepresentable { - var effect: UIVisualEffect? - func makeUIView(context: UIViewRepresentableContext) -> UIVisualEffectView { UIVisualEffectView() } - func updateUIView(_ uiView: UIVisualEffectView, context: UIViewRepresentableContext) { uiView.effect = effect } -} diff --git a/Anytype/Sources/PresentationLayer/TextEditor/Assembly/EditorPageAssembly.swift b/Anytype/Sources/PresentationLayer/TextEditor/Assembly/EditorPageAssembly.swift index 2b8f509cd4..e0550d5936 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/Assembly/EditorPageAssembly.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/Assembly/EditorPageAssembly.swift @@ -182,7 +182,8 @@ final class EditorAssembly { bottomNavigationManager: bottomNavigationManager, configuration: EditorPageViewModelConfiguration( isOpenedForPreview: data.isOpenedForPreview, - shouldShowTemplateSelection: data.shouldShowTemplatesOptions + shouldShowTemplateSelection: data.shouldShowTemplatesOptions, + usecase: data.usecase ) ) @@ -286,7 +287,7 @@ final class EditorAssembly { let headerModel = ObjectHeaderViewModel( document: document, router: router, - isOpenedForPreview: configuration.isOpenedForPreview + configuration: configuration ) let responderScrollViewHelper = ResponderScrollViewHelper(scrollView: scrollView) diff --git a/Anytype/Sources/PresentationLayer/TextEditor/Assembly/EditorScreenData+Details.swift b/Anytype/Sources/PresentationLayer/TextEditor/Assembly/EditorScreenData+Details.swift index c739c7dd56..ecb3c35471 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/Assembly/EditorScreenData+Details.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/Assembly/EditorScreenData+Details.swift @@ -22,12 +22,14 @@ extension EditorPageObject { init( details: ObjectDetails, isOpenedForPreview: Bool = false, - shouldShowTemplatesOptions: Bool = true + shouldShowTemplatesOptions: Bool = true, + usecase: ObjectHeaderEmptyData.ObjectHeaderEmptyUsecase = .editor ) { self.objectId = details.id self.isSupportedForEdit = details.isSupportedForEdit self.isOpenedForPreview = isOpenedForPreview self.shouldShowTemplatesOptions = shouldShowTemplatesOptions + self.usecase = usecase } } diff --git a/Anytype/Sources/PresentationLayer/TextEditor/Assembly/EditorScreenData.swift b/Anytype/Sources/PresentationLayer/TextEditor/Assembly/EditorScreenData.swift index 02cba389c3..b761a0dd85 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/Assembly/EditorScreenData.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/Assembly/EditorScreenData.swift @@ -17,17 +17,20 @@ struct EditorPageObject: Hashable, Codable { let isSupportedForEdit: Bool let isOpenedForPreview: Bool let shouldShowTemplatesOptions: Bool + let usecase: ObjectHeaderEmptyData.ObjectHeaderEmptyUsecase init( objectId: String, isSupportedForEdit: Bool, isOpenedForPreview: Bool, - shouldShowTemplatesOptions: Bool = true + shouldShowTemplatesOptions: Bool = true, + usecase: ObjectHeaderEmptyData.ObjectHeaderEmptyUsecase = .editor ) { self.objectId = objectId self.isSupportedForEdit = isSupportedForEdit self.isOpenedForPreview = isOpenedForPreview self.shouldShowTemplatesOptions = shouldShowTemplatesOptions + self.usecase = usecase } } diff --git a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/EditorPageViewModelConfiguration.swift b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/EditorPageViewModelConfiguration.swift index 00600ea45d..fe5ffe0322 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/EditorPageViewModelConfiguration.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/EditorPageViewModelConfiguration.swift @@ -3,4 +3,5 @@ import Foundation struct EditorPageViewModelConfiguration { let isOpenedForPreview: Bool let shouldShowTemplateSelection: Bool + let usecase: ObjectHeaderEmptyData.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 4d09dbaaad..233f95bc78 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Empty/ObjectHeaderEmptyContentView.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Empty/ObjectHeaderEmptyContentView.swift @@ -4,6 +4,8 @@ final class ObjectHeaderEmptyContentView: UIView, BlockContentView { // MARK: - Private variables private let emptyView = UIView() private let tapGesture = BindableGestureRecognizer() + + private var heightConstraint: NSLayoutConstraint? override init(frame: CGRect) { super.init(frame: frame) @@ -25,6 +27,13 @@ final class ObjectHeaderEmptyContentView: UIView, BlockContentView { tapGesture.action = { _ in configuration.data.onTap() } + + switch configuration.data.presentationStyle { + case .editor: + heightConstraint?.constant = ObjectHeaderConstants.emptyViewHeight + case .templateEditing: + heightConstraint?.constant = ObjectHeaderConstants.templateEditingEmptyViewHeight + } } } @@ -40,7 +49,7 @@ private extension ObjectHeaderEmptyContentView { addSubview(emptyView) { $0.pinToSuperview(excluding: [.bottom]) $0.bottom.equal(to: bottomAnchor, priority: .init(rawValue: 999)) - $0.height.equal(to: ObjectHeaderConstants.emptyViewHeight) + heightConstraint = $0.height.equal(to: ObjectHeaderConstants.emptyViewHeight) } } } diff --git a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/ObjectHeader+Mutation.swift b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/ObjectHeader+Mutation.swift index ba0be5a54e..31eb6c6c3c 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/ObjectHeader+Mutation.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/ObjectHeader+Mutation.swift @@ -6,7 +6,7 @@ extension ObjectHeader { _ update: ObjectHeaderUpdate, onIconTap: @escaping () -> (), onCoverTap: @escaping () -> () - ) -> ObjectHeader? { + ) -> ObjectHeader { switch update { case .iconUploading(let path): return modifiedByIconUploadingEventWith( @@ -34,7 +34,7 @@ extension ObjectHeader { image: UIImage?, onIconTap: @escaping () -> (), onCoverTap: @escaping () -> () - ) -> ObjectHeader? { + ) -> ObjectHeader { switch self { case .filled(let filledState, _): return .filled(state: @@ -63,7 +63,7 @@ extension ObjectHeader { private func modifiedByCoverUploadingEventWith( previewType: ObjectHeaderCoverPreviewType, onCoverTap: @escaping () -> () - ) -> ObjectHeader? { + ) -> ObjectHeader { let newCover = ObjectHeaderCover( coverType: .preview(previewType), onTap: onCoverTap 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 98f51bfd3d..4ca581d919 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/ObjectHeader.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/ObjectHeader.swift @@ -10,8 +10,11 @@ enum ObjectHeader: Hashable { .filled(state: state, isShimmering: false) } - static func empty(data: ObjectHeaderEmptyData) -> Self { - .empty(data: data, isShimmering: false) + static func empty( + usecase: ObjectHeaderEmptyData.ObjectHeaderEmptyUsecase, + onTap: @escaping () -> Void + ) -> Self { + return .empty(data: .init(presentationStyle: usecase, onTap: onTap), isShimmering: false) } } extension ObjectHeader: ContentConfigurationProvider { 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 f98684c6f4..d6144374b1 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/ObjectHeaderEmptyData.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/ObjectHeaderEmptyData.swift @@ -1,5 +1,11 @@ import Foundation 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/Header/Entities/ObjectHeaderViewModel.swift b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/ObjectHeaderViewModel.swift index 2adbc1a167..47063f926d 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/ObjectHeaderViewModel.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Entities/ObjectHeaderViewModel.swift @@ -15,13 +15,13 @@ final class ObjectHeaderViewModel: ObservableObject { // MARK: - Private variables private lazy var onIconTap = { [weak self] in - guard let self = self, !self.isOpenedForPreview else { return } + guard let self = self, !self.configuration.isOpenedForPreview else { return } UISelectionFeedbackGenerator().selectionChanged() self.router.showIconPicker() } private lazy var onCoverTap = { [weak self] in - guard let self = self, !self.isOpenedForPreview else { return } + guard let self = self, !self.configuration.isOpenedForPreview else { return } guard self.document.details?.layoutValue != .note else { return } @@ -34,14 +34,18 @@ final class ObjectHeaderViewModel: ObservableObject { private let router: ObjectHeaderRouterProtocol private var subscription: AnyCancellable? - private let isOpenedForPreview: Bool + private let configuration: EditorPageViewModelConfiguration // MARK: - Initializers - init(document: BaseDocumentGeneralProtocol, router: ObjectHeaderRouterProtocol, isOpenedForPreview: Bool) { + init( + document: BaseDocumentGeneralProtocol, + router: ObjectHeaderRouterProtocol, + configuration: EditorPageViewModelConfiguration + ) { self.document = document self.router = router - self.isOpenedForPreview = isOpenedForPreview + self.configuration = configuration setupSubscription() @@ -95,7 +99,13 @@ final class ObjectHeaderViewModel: ObservableObject { guard let details = document.details else { return buildShimmeringHeader() } - return HeaderBuilder.buildObjectHeader(details: details, usecase: .openedObject, onIconTap: onIconTap, onCoverTap: onCoverTap) + return HeaderBuilder.buildObjectHeader( + details: details, + usecase: .openedObject, + presentationUsecase: configuration.usecase, + onIconTap: onIconTap, + onCoverTap: onCoverTap + ) } private func buildLoadingHeader(_ update: ObjectHeaderUpdate) -> ObjectHeader { @@ -103,12 +113,18 @@ final class ObjectHeaderViewModel: ObservableObject { return fakeHeader(update: update) } - let header = HeaderBuilder.buildObjectHeader(details: details, usecase: .openedObject, onIconTap: onIconTap, onCoverTap: onCoverTap) + let header = HeaderBuilder.buildObjectHeader( + details: details, + usecase: .openedObject, + presentationUsecase: configuration.usecase, + onIconTap: onIconTap, + onCoverTap: onCoverTap + ) return header.modifiedByUpdate( update, onIconTap: onIconTap, onCoverTap: onCoverTap - ) ?? .empty(data: ObjectHeaderEmptyData(onTap: onCoverTap)) + ) } private func fakeHeader(update: ObjectHeaderUpdate) -> ObjectHeader { @@ -155,13 +171,14 @@ enum HeaderBuilder { static func buildObjectHeader( details: ObjectDetails, usecase: ObjectIconImageUsecase, + presentationUsecase: ObjectHeaderEmptyData.ObjectHeaderEmptyUsecase, onIconTap: @escaping () -> Void, onCoverTap: @escaping () -> Void ) -> ObjectHeader { let layoutAlign = details.layoutAlignValue if details.layoutValue == .note { - return .empty(data: .init(onTap: {})) + return .empty(usecase: presentationUsecase, onTap: {}) } let icon = details.layoutValue == .bookmark ? nil : details.icon @@ -208,7 +225,9 @@ enum HeaderBuilder { ) } - return .empty(data: ObjectHeaderEmptyData(onTap: onCoverTap)) + return .empty( + data: .init(presentationStyle: presentationUsecase, onTap: onCoverTap), + isShimmering: false + ) } - } diff --git a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Filled/Subviews/HeaderViewSizeConfiguration.swift b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Filled/Subviews/HeaderViewSizeConfiguration.swift index ef98441e7d..5d67ada7dd 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Filled/Subviews/HeaderViewSizeConfiguration.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Filled/Subviews/HeaderViewSizeConfiguration.swift @@ -9,6 +9,7 @@ struct HeaderViewSizeConfiguration: Hashable { let iconHorizontalInset: CGFloat let onlyIconTopInset: CGFloat let iconBorderWidth: CGFloat + let iconBorderColor: UIColor } extension HeaderViewSizeConfiguration { @@ -21,7 +22,8 @@ extension HeaderViewSizeConfiguration { iconBottomInset: ObjectHeaderConstants.iconBottomInset, iconHorizontalInset: ObjectHeaderConstants.iconHorizontalInset, onlyIconTopInset: ObjectHeaderConstants.emptyViewHeight, - iconBorderWidth: 4 + iconBorderWidth: 4, + iconBorderColor: .Background.primary ) } @@ -33,6 +35,7 @@ extension HeaderViewSizeConfiguration { iconBottomInset: 0, iconHorizontalInset: 16, onlyIconTopInset: 28, - iconBorderWidth: 2 + iconBorderWidth: 2, + iconBorderColor: .Background.secondary ) } diff --git a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Filled/Subviews/Icon/ObjectHeaderIconView.swift b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Filled/Subviews/Icon/ObjectHeaderIconView.swift index 1251706db1..3dff3c9e6a 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Filled/Subviews/Icon/ObjectHeaderIconView.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Filled/Subviews/Icon/ObjectHeaderIconView.swift @@ -17,6 +17,12 @@ final class ObjectHeaderIconView: UIView { iconViewLeadingConstraint?.constant = initialBorderWidth } } + + var borderColor: UIColor = .Background.primary { + didSet { + setupBackgroundColor(color: borderColor) + } + } // MARK: - Private variables @@ -159,16 +165,15 @@ private extension ObjectHeaderIconView { previewImageView.isHidden = true activityIndicatorView.hide() - setupBackgroundColor() setupLayout() } - func setupBackgroundColor() { - backgroundColor = .Background.primary + func setupBackgroundColor(color: UIColor) { + backgroundColor = color - containerView.backgroundColor = .Background.primary - iconImageView.backgroundColor = .Background.primary - previewImageView.backgroundColor = .Background.primary + containerView.backgroundColor = color + iconImageView.backgroundColor = color + previewImageView.backgroundColor = color } func setupLayout() { diff --git a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Filled/Subviews/ObjectHeaderView.swift b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Filled/Subviews/ObjectHeaderView.swift index 2465e0a1c0..6157d185c8 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Filled/Subviews/ObjectHeaderView.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/Header/Filled/Subviews/ObjectHeaderView.swift @@ -76,6 +76,8 @@ extension ObjectHeaderView: ConfigurableView { func configure(model: Model) { update(sizeConfiguration: model.sizeConfiguration) iconView.initialBorderWidth = model.sizeConfiguration.iconBorderWidth + iconView.borderColor = model.sizeConfiguration.iconBorderColor + switch model.state { case .iconOnly(let objectHeaderIconState): diff --git a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/ObjectHeaderConstants.swift b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/ObjectHeaderConstants.swift index 3c26cc099d..259e559074 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/ObjectHeaderConstants.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/Views/ObjectHeaderConstants.swift @@ -2,6 +2,7 @@ import CoreGraphics enum ObjectHeaderConstants { static let minimizedHeaderHeight: CGFloat = 48 + static let templateEditingEmptyViewHeight: CGFloat = 32 static let emptyViewHeight: CGFloat = 124 static let coverHeight: CGFloat = 228 diff --git a/Anytype/Sources/PresentationLayer/TextEditor/Set/EditorSetViewModel.swift b/Anytype/Sources/PresentationLayer/TextEditor/Set/EditorSetViewModel.swift index 78c0ff1bf7..b7ece01498 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/Set/EditorSetViewModel.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/Set/EditorSetViewModel.swift @@ -164,7 +164,15 @@ final class EditorSetViewModel: ObservableObject { func setup(router: EditorSetRouterProtocol) { self.router = router - self.headerModel = ObjectHeaderViewModel(document: setDocument, router: router, isOpenedForPreview: false) + self.headerModel = ObjectHeaderViewModel( + document: setDocument, + router: router, + configuration: .init( + isOpenedForPreview: false, + shouldShowTemplateSelection: false, + usecase: .editor + ) + ) setDocument.setUpdatePublisher.sink { [weak self] in self?.onDataChange($0)