Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add accessibilityId to Compound message #556

Merged
merged 1 commit into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public final class CompoundMessagePresenter<ViewModelBuilderT, InteractionHandle
private let contentFactories: [AnyMessageContentFactory<ModelT>]
private lazy var layoutProvider: CompoundBubbleLayoutProvider = self.makeLayoutProvider()
private let cache: Cache<CompoundBubbleLayoutProvider.Configuration, CompoundBubbleLayoutProvider>
private let accessibilityIdentifier: String?

public init(
messageModel: ModelT,
Expand All @@ -47,11 +48,13 @@ public final class CompoundMessagePresenter<ViewModelBuilderT, InteractionHandle
sizingCell: CompoundMessageCollectionViewCell<ModelT>,
baseCellStyle: BaseMessageCollectionViewCellStyleProtocol,
compoundCellStyle: CompoundBubbleViewStyleProtocol,
cache: Cache<CompoundBubbleLayoutProvider.Configuration, CompoundBubbleLayoutProvider>
cache: Cache<CompoundBubbleLayoutProvider.Configuration, CompoundBubbleLayoutProvider>,
accessibilityIdentifier: String?
) {
self.compoundCellStyle = compoundCellStyle
self.contentFactories = contentFactories.filter { $0.canCreateMessageModule(forModel: messageModel) }
self.cache = cache
self.accessibilityIdentifier = accessibilityIdentifier
super.init(
messageModel: messageModel,
viewModelBuilder: viewModelBuilder,
Expand Down Expand Up @@ -102,6 +105,7 @@ public final class CompoundMessagePresenter<ViewModelBuilderT, InteractionHandle
bubbleView.style = sSelf.compoundCellStyle
bubbleView.decoratedContentViews = modules.map { .init(module: $0) }
bubbleView.layoutProvider = sSelf.layoutProvider
bubbleView.accessibilityIdentifier = sSelf.accessibilityIdentifier
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ public final class CompoundMessagePresenterBuilder<ViewModelBuilderT, Interactio
public init(
viewModelBuilder: ViewModelBuilderT,
interactionHandler: InteractionHandlerT?,
accessibilityIdentifier: String?,
contentFactories: [AnyMessageContentFactory<ModelT>]) {
self.viewModelBuilder = viewModelBuilder
self.interactionHandler = interactionHandler
self.contentFactories = contentFactories
self.accessibilityIdentifier = accessibilityIdentifier
}

public let viewModelBuilder: ViewModelBuilderT
Expand All @@ -48,6 +50,7 @@ public final class CompoundMessagePresenterBuilder<ViewModelBuilderT, Interactio
public lazy var compoundCellStyle: CompoundBubbleViewStyleProtocol = DefaultCompoundBubbleViewStyle()
public lazy var baseCellStyle: BaseMessageCollectionViewCellStyleProtocol = BaseMessageCollectionViewCellDefaultStyle()
private let cache = Cache<CompoundBubbleLayoutProvider.Configuration, CompoundBubbleLayoutProvider>()
private let accessibilityIdentifier: String?

public func canHandleChatItem(_ chatItem: ChatItemProtocol) -> Bool {
return self.viewModelBuilder.canCreateViewModel(fromModel: chatItem)
Expand All @@ -63,7 +66,8 @@ public final class CompoundMessagePresenterBuilder<ViewModelBuilderT, Interactio
sizingCell: self.sizingCell,
baseCellStyle: self.baseCellStyle,
compoundCellStyle: self.compoundCellStyle,
cache: self.cache
cache: self.cache,
accessibilityIdentifier: self.accessibilityIdentifier
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class DemoChatViewController: BaseChatViewController {
let compoundPresenterBuilder = CompoundMessagePresenterBuilder(
viewModelBuilder: DemoCompoundMessageViewModelBuilder(),
interactionHandler: GenericMessageHandler(baseHandler: self.baseMessageHandler),
accessibilityIdentifier: nil,
contentFactories: [
.init(DemoTextMessageContentFactory()),
.init(DemoImageMessageContentFactory()),
Expand Down