Skip to content

Commit

Permalink
IOS-2768 Fix Task layout with checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-pusya committed Apr 24, 2024
1 parent 885dfa0 commit 047d52e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ final class SimpleTableCellsBuilder {
let textBlockViewModel = TextBlockViewModel(
document: document,
blockInformationProvider: .init(infoContainer: document.infoContainer, info: information),
stylePublisher: .empty(),
actionHandler: textBlockActionHandler,
cursorManager: cursorManager
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,17 @@ final class TextBlockContentView: UIView, BlockContentView, DynamicHeightView, F
$0.trailing.equal(to: contentView.trailingAnchor)
}

// Double-check this anchors (we already have stack)
textBlockLeadingView.layoutUsing.anchors {
$0.top.equal(to: contentStackView.topAnchor)
$0.bottom.equal(to: contentStackView.bottomAnchor)
}


// Double-check this anchors (we already have stack)
textView.layoutUsing.anchors {
$0.trailing.equal(to: contentStackView.trailingAnchor)
$0.top.equal(to: contentStackView.topAnchor)
$0.leading.equal(to: textBlockLeadingView.trailingAnchor)
$0.leading.equal(to: textBlockLeadingView.trailingAnchor, constant: 8)
}

createEmptyBlockButton.layoutUsing.anchors {
Expand All @@ -97,7 +98,7 @@ final class TextBlockContentView: UIView, BlockContentView, DynamicHeightView, F
textView.textView.textStorage.setAttributedString(configuration.attributedString)
TextBlockLeftViewStyler.applyStyle(contentStackView: contentStackView, configuration: configuration)

textBlockLeadingView.update(style: .init(with: configuration))
textBlockLeadingView.update(style: TextBlockLeadingStyle(with: configuration))

let restrictions = BlockRestrictionsBuilder.build(textContentType: configuration.content.contentType)
TextBlockTextViewStyler.applyStyle(textView: textView, configuration: configuration, restrictions: restrictions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,24 @@ final class TextBlockViewModel: BlockViewModelProtocol {
init(
document: BaseDocumentProtocol,
blockInformationProvider: BlockModelInfomationProvider,
stylePublisher: AnyPublisher<Style, Never>,
actionHandler: TextBlockActionHandlerProtocol,
cursorManager: EditorCursorManager,
customBackgroundColor: UIColor? = nil
customBackgroundColor: UIColor? = nil,
collectionController: EditorBlockCollectionController? = nil
) {
self.blockInformationProvider = blockInformationProvider
self.document = document
self.actionHandler = actionHandler
self.cursorManager = cursorManager
self.customBackgroundColor = customBackgroundColor

stylePublisher.receiveOnMain().sink { [weak self] style in
self?.style = style

document.detailsPublisher.receiveOnMain().sink { [weak self] objectDetails in
guard let self, let collectionController else { return }
let newStyle = styleFromDetails(objectDetails: objectDetails)
if style != newStyle {
style = newStyle
collectionController.reconfigure(items: [.block(self)])
}
}.store(in: &cancellables)
}

Expand Down Expand Up @@ -160,4 +165,9 @@ final class TextBlockViewModel: BlockViewModelProtocol {
styleConfiguration: CellStyleConfiguration(backgroundColor: color)
)
}

private func styleFromDetails(objectDetails: ObjectDetails?) -> Style {
guard let objectDetails else { return .none }
return objectDetails.layoutValue == .todo ? .todo : .none
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,12 @@ final class BlockViewModelBuilder {
self?.output?.showLinkToObject(data: data)
}
)

let viewModel = TextBlockViewModel(
document: document,
blockInformationProvider: blockInformationProvider,
stylePublisher: .empty(),
actionHandler: textBlockActionHandler,
cursorManager: cursorManager
cursorManager: cursorManager,
collectionController: blockCollectionController
)

textBlockActionHandler.viewModel = viewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ enum HeaderBuilder {
return .empty(usecase: presentationUsecase, onTap: {})
}

let icon = details.layoutValue == .bookmark ? nil : details.objectIcon
let icon = DetailsLayout.layoutsWithIcon.contains(details.layoutValue) ? details.objectIcon : nil

if let icon = icon, let cover = details.documentCover {
return .filled(state:
Expand Down

0 comments on commit 047d52e

Please sign in to comment.