Skip to content

Commit

Permalink
Merge pull request #269 from anyproto/ios-1518-templates-menu-layout-…
Browse files Browse the repository at this point in the history
…business-logic

IOS-1518 Templates. Design changes
  • Loading branch information
bududomasidet authored Aug 14, 2023
2 parents 43bcf6a + 0a494aa commit 931ae82
Show file tree
Hide file tree
Showing 27 changed files with 125 additions and 79 deletions.
4 changes: 0 additions & 4 deletions Anytype.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -2706,7 +2705,6 @@
8624C8602A6E577E0065CBC0 /* EditorPageViewModelConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorPageViewModelConfiguration.swift; sourceTree = "<group>"; };
863776822A658AF10040308E /* TemplateModulesAssembly.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateModulesAssembly.swift; sourceTree = "<group>"; };
863776842A658B410040308E /* TemplateOptionAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateOptionAction.swift; sourceTree = "<group>"; };
863776862A6663E50040308E /* VisualEffectView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VisualEffectView.swift; sourceTree = "<group>"; };
863776892A66644B0040308E /* DataviewTemplateSelectionInteractorProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataviewTemplateSelectionInteractorProvider.swift; sourceTree = "<group>"; };
8637768B2A6664DB0040308E /* MockTemplateSelectionInteractorProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockTemplateSelectionInteractorProvider.swift; sourceTree = "<group>"; };
8637768E2A6668680040308E /* TemplatePreviewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplatePreviewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -8050,7 +8048,6 @@
863877792A5808620024F814 /* TemplatesSelectionView.swift */,
8638777B2A58088F0024F814 /* TemplatesSelectionViewModel.swift */,
861E75F52A5C03E400F18552 /* EditableView.swift */,
863776862A6663E50040308E /* VisualEffectView.swift */,
863776842A658B410040308E /* TemplateOptionAction.swift */,
);
path = Selection;
Expand Down Expand Up @@ -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 */,
Expand Down
1 change: 0 additions & 1 deletion Anytype/Generated/Assets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion Anytype/Generated/Color+Assets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
1 change: 0 additions & 1 deletion Anytype/Generated/Color+Info.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
]
)
Expand Down
1 change: 0 additions & 1 deletion Anytype/Generated/UIColor+Assets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

This file was deleted.

2 changes: 2 additions & 0 deletions Anytype/Sources/Design system/Fonts/AnytypeFont.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ enum AnytypeFont: CaseIterable {
case authBody
case authCaption
case authInput

case navigationBarTitle
}
8 changes: 8 additions & 0 deletions Anytype/Sources/Design system/Fonts/AnytypeFontConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ protocol ContextualMenuItemsProvider {
var contextMenuItems: AnyView { get }
}

private enum Constaints {
static let dotImageSize: CGFloat = 28
}

struct EditableView<Content: View & ContextualMenuItemsProvider>: View {
var content: Content
var onTap: () -> Void
Expand Down Expand Up @@ -33,16 +37,13 @@ struct EditableView<Content: View & ContextualMenuItemsProvider>: 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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ extension TemplatePreviewModel {
header: HeaderBuilder.buildObjectHeader(
details: objectDetails,
usecase: .templatePreview,
presentationUsecase: .editor,
onIconTap: {},
onCoverTap: {}
),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ final class EditorAssembly {
bottomNavigationManager: bottomNavigationManager,
configuration: EditorPageViewModelConfiguration(
isOpenedForPreview: data.isOpenedForPreview,
shouldShowTemplateSelection: data.shouldShowTemplatesOptions
shouldShowTemplateSelection: data.shouldShowTemplatesOptions,
usecase: data.usecase
)
)

Expand Down Expand Up @@ -286,7 +287,7 @@ final class EditorAssembly {
let headerModel = ObjectHeaderViewModel(
document: document,
router: router,
isOpenedForPreview: configuration.isOpenedForPreview
configuration: configuration
)

let responderScrollViewHelper = ResponderScrollViewHelper(scrollView: scrollView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import Foundation
struct EditorPageViewModelConfiguration {
let isOpenedForPreview: Bool
let shouldShowTemplateSelection: Bool
let usecase: ObjectHeaderEmptyData.ObjectHeaderEmptyUsecase
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
}
}

Expand All @@ -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)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extension ObjectHeader {
_ update: ObjectHeaderUpdate,
onIconTap: @escaping () -> (),
onCoverTap: @escaping () -> ()
) -> ObjectHeader? {
) -> ObjectHeader {
switch update {
case .iconUploading(let path):
return modifiedByIconUploadingEventWith(
Expand Down Expand Up @@ -34,7 +34,7 @@ extension ObjectHeader {
image: UIImage?,
onIconTap: @escaping () -> (),
onCoverTap: @escaping () -> ()
) -> ObjectHeader? {
) -> ObjectHeader {
switch self {
case .filled(let filledState, _):
return .filled(state:
Expand Down Expand Up @@ -63,7 +63,7 @@ extension ObjectHeader {
private func modifiedByCoverUploadingEventWith(
previewType: ObjectHeaderCoverPreviewType,
onCoverTap: @escaping () -> ()
) -> ObjectHeader? {
) -> ObjectHeader {
let newCover = ObjectHeaderCover(
coverType: .preview(previewType),
onTap: onCoverTap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Loading

0 comments on commit 931ae82

Please sign in to comment.