-
Notifications
You must be signed in to change notification settings - Fork 211
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
[Polls] Add PollAttachmentView
+ ViewContainerBuilder
#3374
Conversation
SDK Performance
|
Generated by 🚫 Danger |
b83ec7c
to
580e01c
Compare
SDK Size
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still some work to be done, a lot of UI is missing. Given that some of the missing features are part of the public component, I'm not sure we should merge it. I would prefer a base branch instead.
Merging without the poll creation flow is fine, but not with an incomplete poll attachment view.
Btw, first time running it - I had a crash DatabaseContainer line 255 (the assertion failure).
...ageList/Attachments/Poll/PollAttachmentOptionListView/PollAttachmentOptionListItemView.swift
Outdated
Show resolved
Hide resolved
...ageList/Attachments/Poll/PollAttachmentOptionListView/PollAttachmentOptionListItemView.swift
Show resolved
Hide resolved
...atUI/ChatMessageList/Attachments/Poll/PollResultsVC/PollResultsSectionHeaderOptionView.swift
Outdated
Show resolved
Hide resolved
/// A result builder to create a stack view given an array of views. | ||
/// The goal is to build UIKit layout similar to SwiftUI so that it easier to create and re-layout views. | ||
@resultBuilder | ||
public struct ViewContainerBuilder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Sources/StreamChatUI/Utils/Extensions/Reusable+Extensions.swift
Outdated
Show resolved
Hide resolved
Sources/StreamChatUI/Utils/Extensions/Reusable+Extensions.swift
Outdated
Show resolved
Hide resolved
Sources/StreamChatUI/ChatMessageList/Attachments/Poll/PollAttachmentView.swift
Outdated
Show resolved
Hide resolved
Okay, I will do a chain of PRs then 👍 The crash is a known one and it is already fixed on develop |
580e01c
to
ffba03c
Compare
Sources/StreamChatUI/Appearance+Formatters/Appearance+Formatters.swift
Outdated
Show resolved
Hide resolved
Sources/StreamChatUI/Appearance+Formatters/PollTimestampFormatter.swift
Outdated
Show resolved
Hide resolved
Sources/StreamChatUI/Appearance+Formatters/PollTimestampFormatter.swift
Outdated
Show resolved
Hide resolved
c061e20
to
c1982dd
Compare
...MessageList/Attachments/Poll/PollAttachmentOptionListView/PollAttachmentOptionListView.swift
Outdated
Show resolved
Hide resolved
...MessageList/Attachments/Poll/PollAttachmentOptionListView/PollAttachmentOptionListView.swift
Outdated
Show resolved
Hide resolved
4ab9cf6
to
ab55fdc
Compare
PollAttachmentView
+ ViewContainerBuilder
PollAttachmentView
+ ViewContainerBuilder
PollAttachmentView
+ ViewContainerBuilder
...ageList/Attachments/Poll/PollAttachmentOptionListView/PollAttachmentOptionListItemView.swift
Outdated
Show resolved
Hide resolved
ab55fdc
to
8cc7aff
Compare
Sources/StreamChatUI/ViewContainerBuilder/ViewContainerBuilder.swift
Outdated
Show resolved
Hide resolved
/// Embeds the container to the given view respecting the layout margins guide. | ||
/// The margins can be customised by changing the `directionalLayoutMargins`. | ||
@discardableResult | ||
func embedToMargins(in view: UIView) -> UIStackView { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer that to be more generic. One method where you can pass either a view or a layout guide
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I wanted to make this API a little more beginner friendly, but maybe better to stick to Apple's API 🤔 I'll see if I can improve this 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to put this on Hold for now. Let's revisit this on the final PR 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would probably look like this:
func embed(in view: UIView, margins: UILayoutGuide) -> UIStackView
which would be consistent with the existing:
func embed(in view: UIView, insets: NSDirectionalEdgeInsets) -> UIStackView
WDYT?
The only con is that using it is a bit more code, but nothing special:
self.directionalLayoutMargins = .init(top: 8, leading: 32, bottom: 8, trailing: 32)
VContainer {
....
}.embed(in: self, margins: layoutMarginsGuide)
150a5a4
to
57073a4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ✅ Great docs and examples
createdBy: createdBy ?? currentUser, | ||
options: [ | ||
.init(id: "messi", text: "Messi"), | ||
.init(id: "ronaldo", text: "Ronaldo", latestVotes: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are talking here about the Brazilian Ronaldo R9, right? If that's the case, totally agree 😃
Components.default.threadListItemView = CustomChatThreadListItemView.self | ||
``` | ||
|
||
From the version **4.63.0** onward our own components will be using the `ViewContainerBuilder` to create the layout. This will make it easier to understand how the components are laid out and make it easier to customize them. This does not mean that you need to use the `ViewContainerBuilder` to customize the components, you can still use regular UIKit or your own UI framework to customize the components. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice docs, good examples too 👍
Quality Gate passedIssues Measures |
* Introduce new ViewContainerBuilder * Add PollAttachmentView component * Change to SwiftUI ENV * Add `shouldShowOnlineIndicator` to turn off online presence in `ChatUserAvatarView` * Fix small iOS 13 deprecation * Add domain logic helpers to Poll * Message Polls live updates * Event.ownVotes workaround (Drop when fixed) * Manage data races when voting on a poll in the message list * Add haptic feedback when voting * Make sure to update the latestVotes author avatar views * Improve performance of Option List View by no recreating the item views everytime * Improve flexibility of Option List View without compromising performance * Make content of StackedUserAvatarsView public * Re-structure Common Buttons Folder * Add `CheckboxButton` as a common view * Add vote ratio logic to `ChatChannelListItemView` * Fix UI Glitches for option list item view when text is too big and avatar appears and disappears * Extract more common logic to `Poll` domain model * Add closed poll and winner option state logic * Add subtitle text logic to `PollAttachmentView` * Change winner logic to be the one and only one option with most votes * Add channel list message preview text for polls * Add poll quoted message text rendering * Add View Results and End Button to the Poll Attachment View * Fix poll option label width ui glitch * Added End Poll functionality * Add isOptionWinner and isOptionOneOfTheWinners to Poll * Fix message with Polls not showing when long pressing * Fix poll controller with incorrect data in message list * Sort the `latestVotes` and `latestAnswers` in the LLC * Add test coverage to Poll domain helpers * Add Test Coverage to Poll Message Preview in Channel List * Add test coverage to PollAttachmentView * Add test coverage to disabling online indicator in ChatUserAvatarView * Add test coverage to quoted poll * Fix some existing snapshot tests * Use UIStackView for Spacer() to avoid drawing * Fix Xcode 14 Build * Fix Poll AttachmentView Tests on CI * Update CHANGELOG.md * Update CHANGELOG.md * Fix Xcode 14 Build, conflict with SwiftUI Spacer * Revert "Change to SwiftUI ENV" This reverts commit 6d9129a. * Add documentation to ViewContainerBuilder * Fix vale issues * Fix using pin() instead of constraint() in docs
* [Polls] Add `PollAttachmentView` + `ViewContainerBuilder` (#3374) * Introduce new ViewContainerBuilder * Add PollAttachmentView component * Change to SwiftUI ENV * Add `shouldShowOnlineIndicator` to turn off online presence in `ChatUserAvatarView` * Fix small iOS 13 deprecation * Add domain logic helpers to Poll * Message Polls live updates * Event.ownVotes workaround (Drop when fixed) * Manage data races when voting on a poll in the message list * Add haptic feedback when voting * Make sure to update the latestVotes author avatar views * Improve performance of Option List View by no recreating the item views everytime * Improve flexibility of Option List View without compromising performance * Make content of StackedUserAvatarsView public * Re-structure Common Buttons Folder * Add `CheckboxButton` as a common view * Add vote ratio logic to `ChatChannelListItemView` * Fix UI Glitches for option list item view when text is too big and avatar appears and disappears * Extract more common logic to `Poll` domain model * Add closed poll and winner option state logic * Add subtitle text logic to `PollAttachmentView` * Change winner logic to be the one and only one option with most votes * Add channel list message preview text for polls * Add poll quoted message text rendering * Add View Results and End Button to the Poll Attachment View * Fix poll option label width ui glitch * Added End Poll functionality * Add isOptionWinner and isOptionOneOfTheWinners to Poll * Fix message with Polls not showing when long pressing * Fix poll controller with incorrect data in message list * Sort the `latestVotes` and `latestAnswers` in the LLC * Add test coverage to Poll domain helpers * Add Test Coverage to Poll Message Preview in Channel List * Add test coverage to PollAttachmentView * Add test coverage to disabling online indicator in ChatUserAvatarView * Add test coverage to quoted poll * Fix some existing snapshot tests * Use UIStackView for Spacer() to avoid drawing * Fix Xcode 14 Build * Fix Poll AttachmentView Tests on CI * Update CHANGELOG.md * Update CHANGELOG.md * Fix Xcode 14 Build, conflict with SwiftUI Spacer * Revert "Change to SwiftUI ENV" This reverts commit 6d9129a. * Add documentation to ViewContainerBuilder * Fix vale issues * Fix using pin() instead of constraint() in docs * [Polls] Add `PollResultsVC` (#3381) * [Polls] Comments + Suggestions + Anonymous Polls + LLC Fixes (#3398) * Refactor PollResultsVC Section views to be more simple and flat hierarchy * Fix bottom spacing in Poll Results Section Header * Add comment buttons to `PollAttachmentView` * Add comment to poll implementation * Fix `poll.latestAnswers` being reset after poll event did not retreive the `latestAnswers` data We should not treat optional `latestAnswers` as empty, since they have different meanings * Add `PollCommentListVC` implementation * Fix `PollVoteListQueryDTO.filterHash` using filterHash only instead of queryHash This was causing the pollId to not be considered when fetching the DB votes * Make diffable data sources more stable * Fix first page of poll vote list resetting all votes * Fix the default vote list sorting * Add poll suggestions feature * Add anonymous polls support * Fix AlertsRouter docs * Add test coverage to `PollCommentListVC` * Add test coverage when poll comments are 0 * Add test coverage to allow suggestions * Add test coverage to anonymous polls * Re-record snapshots after renaming test file * Fix snapshot on CI * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md * Update Sources/StreamChatUI/ChatMessageList/Attachments/Poll/PollAttachmentView.swift * Update Sources/StreamChatUI/ChatMessageList/Attachments/Poll/PollCommentListVC/PollCommentListSectionFooterView.swift * Fix comments and suggestion buttons showing when poll is closed * Update CHANGELOG.md * Change alert titles to follow Apples guideline * Improve comments view spacing * Optimize a bit to check if a user has already a comment * Add poll creation action to composer if polls are enabled * Add Poll Creation Views and UX * Handle keyboard adjustment in the poll creation view * Add actual if-statement support to ViewContainerBuilder * Add Poll Creation View Styling * Add poll creation section header view * Add Poll Creation Feature Cell Styling * Add Multiple Votes Feature Cell Data handling * Improve data handling in PollCreationVC * Add poll creation button * Fix Poll Creation Memory Leaks + Add Poll Option Errors * Implement poll option error indices * Refactor Poll Creation View to Collection View * Add views to components and appearance * Implement keyboard management in Poll Creation VC * Implementation of discarding poll changes * Add poll alert error if creation fails * Fix basic features not being persisted * Add localization to the views * Add for polls feature support configuration * Add Poll Creation View test coverage * Update CHANGELOG.md * Fix test_canCreatePoll_whenOptionsError_shouldReturnFalse test * [CI] Snapshots (#3434) Co-authored-by: Stream Bot <[email protected]> * Fix maximum votes error not being cleared when multiple votes is disabled * Change multiple votes keyboard to number bad * Remove custom equatable implementation that is not required for PollFeatureType * Remove yeetd-normal.pkg file? * Fix adding duplicate options * Disable swiftlint notification_center_detachment and switch_case_alignment * Extract poll creation input view height to a constant --------- Co-authored-by: Stream SDK Bot <[email protected]> Co-authored-by: Stream Bot <[email protected]>
* Introduce new ViewContainerBuilder * Add PollAttachmentView component * Change to SwiftUI ENV * Add `shouldShowOnlineIndicator` to turn off online presence in `ChatUserAvatarView` * Fix small iOS 13 deprecation * Add domain logic helpers to Poll * Message Polls live updates * Event.ownVotes workaround (Drop when fixed) * Manage data races when voting on a poll in the message list * Add haptic feedback when voting * Make sure to update the latestVotes author avatar views * Improve performance of Option List View by no recreating the item views everytime * Improve flexibility of Option List View without compromising performance * Make content of StackedUserAvatarsView public * Re-structure Common Buttons Folder * Add `CheckboxButton` as a common view * Add vote ratio logic to `ChatChannelListItemView` * Fix UI Glitches for option list item view when text is too big and avatar appears and disappears * Extract more common logic to `Poll` domain model * Add closed poll and winner option state logic * Add subtitle text logic to `PollAttachmentView` * Change winner logic to be the one and only one option with most votes * Add channel list message preview text for polls * Add poll quoted message text rendering * Add View Results and End Button to the Poll Attachment View * Fix poll option label width ui glitch * Added End Poll functionality * Add isOptionWinner and isOptionOneOfTheWinners to Poll * Fix message with Polls not showing when long pressing * Fix poll controller with incorrect data in message list * Sort the `latestVotes` and `latestAnswers` in the LLC * Add test coverage to Poll domain helpers * Add Test Coverage to Poll Message Preview in Channel List * Add test coverage to PollAttachmentView * Add test coverage to disabling online indicator in ChatUserAvatarView * Add test coverage to quoted poll * Fix some existing snapshot tests * Use UIStackView for Spacer() to avoid drawing * Fix Xcode 14 Build * Fix Poll AttachmentView Tests on CI * Update CHANGELOG.md * Update CHANGELOG.md * Fix Xcode 14 Build, conflict with SwiftUI Spacer * Revert "Change to SwiftUI ENV" This reverts commit 6d9129a. * Add documentation to ViewContainerBuilder * Fix vale issues * Fix using pin() instead of constraint() in docs
* [Polls] Add `PollAttachmentView` + `ViewContainerBuilder` (#3374) * Introduce new ViewContainerBuilder * Add PollAttachmentView component * Change to SwiftUI ENV * Add `shouldShowOnlineIndicator` to turn off online presence in `ChatUserAvatarView` * Fix small iOS 13 deprecation * Add domain logic helpers to Poll * Message Polls live updates * Event.ownVotes workaround (Drop when fixed) * Manage data races when voting on a poll in the message list * Add haptic feedback when voting * Make sure to update the latestVotes author avatar views * Improve performance of Option List View by no recreating the item views everytime * Improve flexibility of Option List View without compromising performance * Make content of StackedUserAvatarsView public * Re-structure Common Buttons Folder * Add `CheckboxButton` as a common view * Add vote ratio logic to `ChatChannelListItemView` * Fix UI Glitches for option list item view when text is too big and avatar appears and disappears * Extract more common logic to `Poll` domain model * Add closed poll and winner option state logic * Add subtitle text logic to `PollAttachmentView` * Change winner logic to be the one and only one option with most votes * Add channel list message preview text for polls * Add poll quoted message text rendering * Add View Results and End Button to the Poll Attachment View * Fix poll option label width ui glitch * Added End Poll functionality * Add isOptionWinner and isOptionOneOfTheWinners to Poll * Fix message with Polls not showing when long pressing * Fix poll controller with incorrect data in message list * Sort the `latestVotes` and `latestAnswers` in the LLC * Add test coverage to Poll domain helpers * Add Test Coverage to Poll Message Preview in Channel List * Add test coverage to PollAttachmentView * Add test coverage to disabling online indicator in ChatUserAvatarView * Add test coverage to quoted poll * Fix some existing snapshot tests * Use UIStackView for Spacer() to avoid drawing * Fix Xcode 14 Build * Fix Poll AttachmentView Tests on CI * Update CHANGELOG.md * Update CHANGELOG.md * Fix Xcode 14 Build, conflict with SwiftUI Spacer * Revert "Change to SwiftUI ENV" This reverts commit 6d9129a. * Add documentation to ViewContainerBuilder * Fix vale issues * Fix using pin() instead of constraint() in docs * [Polls] Add `PollResultsVC` (#3381) * [Polls] Comments + Suggestions + Anonymous Polls + LLC Fixes (#3398) * Refactor PollResultsVC Section views to be more simple and flat hierarchy * Fix bottom spacing in Poll Results Section Header * Add comment buttons to `PollAttachmentView` * Add comment to poll implementation * Fix `poll.latestAnswers` being reset after poll event did not retreive the `latestAnswers` data We should not treat optional `latestAnswers` as empty, since they have different meanings * Add `PollCommentListVC` implementation * Fix `PollVoteListQueryDTO.filterHash` using filterHash only instead of queryHash This was causing the pollId to not be considered when fetching the DB votes * Make diffable data sources more stable * Fix first page of poll vote list resetting all votes * Fix the default vote list sorting * Add poll suggestions feature * Add anonymous polls support * Fix AlertsRouter docs * Add test coverage to `PollCommentListVC` * Add test coverage when poll comments are 0 * Add test coverage to allow suggestions * Add test coverage to anonymous polls * Re-record snapshots after renaming test file * Fix snapshot on CI * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md * Update Sources/StreamChatUI/ChatMessageList/Attachments/Poll/PollAttachmentView.swift * Update Sources/StreamChatUI/ChatMessageList/Attachments/Poll/PollCommentListVC/PollCommentListSectionFooterView.swift * Fix comments and suggestion buttons showing when poll is closed * Update CHANGELOG.md * Change alert titles to follow Apples guideline * Improve comments view spacing * Optimize a bit to check if a user has already a comment * Add poll creation action to composer if polls are enabled * Add Poll Creation Views and UX * Handle keyboard adjustment in the poll creation view * Add actual if-statement support to ViewContainerBuilder * Add Poll Creation View Styling * Add poll creation section header view * Add Poll Creation Feature Cell Styling * Add Multiple Votes Feature Cell Data handling * Improve data handling in PollCreationVC * Add poll creation button * Fix Poll Creation Memory Leaks + Add Poll Option Errors * Implement poll option error indices * Refactor Poll Creation View to Collection View * Add views to components and appearance * Implement keyboard management in Poll Creation VC * Implementation of discarding poll changes * Add poll alert error if creation fails * Fix basic features not being persisted * Add localization to the views * Add for polls feature support configuration * Add Poll Creation View test coverage * Update CHANGELOG.md * Fix test_canCreatePoll_whenOptionsError_shouldReturnFalse test * [CI] Snapshots (#3434) Co-authored-by: Stream Bot <[email protected]> * Fix maximum votes error not being cleared when multiple votes is disabled * Change multiple votes keyboard to number bad * Remove custom equatable implementation that is not required for PollFeatureType * Remove yeetd-normal.pkg file? * Fix adding duplicate options * Disable swiftlint notification_center_detachment and switch_case_alignment * Extract poll creation input view height to a constant --------- Co-authored-by: Stream SDK Bot <[email protected]> Co-authored-by: Stream Bot <[email protected]>
* [Polls] Add `PollAttachmentView` + `ViewContainerBuilder` (#3374) * Introduce new ViewContainerBuilder * Add PollAttachmentView component * Change to SwiftUI ENV * Add `shouldShowOnlineIndicator` to turn off online presence in `ChatUserAvatarView` * Fix small iOS 13 deprecation * Add domain logic helpers to Poll * Message Polls live updates * Event.ownVotes workaround (Drop when fixed) * Manage data races when voting on a poll in the message list * Add haptic feedback when voting * Make sure to update the latestVotes author avatar views * Improve performance of Option List View by no recreating the item views everytime * Improve flexibility of Option List View without compromising performance * Make content of StackedUserAvatarsView public * Re-structure Common Buttons Folder * Add `CheckboxButton` as a common view * Add vote ratio logic to `ChatChannelListItemView` * Fix UI Glitches for option list item view when text is too big and avatar appears and disappears * Extract more common logic to `Poll` domain model * Add closed poll and winner option state logic * Add subtitle text logic to `PollAttachmentView` * Change winner logic to be the one and only one option with most votes * Add channel list message preview text for polls * Add poll quoted message text rendering * Add View Results and End Button to the Poll Attachment View * Fix poll option label width ui glitch * Added End Poll functionality * Add isOptionWinner and isOptionOneOfTheWinners to Poll * Fix message with Polls not showing when long pressing * Fix poll controller with incorrect data in message list * Sort the `latestVotes` and `latestAnswers` in the LLC * Add test coverage to Poll domain helpers * Add Test Coverage to Poll Message Preview in Channel List * Add test coverage to PollAttachmentView * Add test coverage to disabling online indicator in ChatUserAvatarView * Add test coverage to quoted poll * Fix some existing snapshot tests * Use UIStackView for Spacer() to avoid drawing * Fix Xcode 14 Build * Fix Poll AttachmentView Tests on CI * Update CHANGELOG.md * Update CHANGELOG.md * Fix Xcode 14 Build, conflict with SwiftUI Spacer * Revert "Change to SwiftUI ENV" This reverts commit 6d9129a. * Add documentation to ViewContainerBuilder * Fix vale issues * Fix using pin() instead of constraint() in docs * [Polls] Add `PollResultsVC` (#3381) * [Polls] Comments + Suggestions + Anonymous Polls + LLC Fixes (#3398) * Refactor PollResultsVC Section views to be more simple and flat hierarchy * Fix bottom spacing in Poll Results Section Header * Add comment buttons to `PollAttachmentView` * Add comment to poll implementation * Fix `poll.latestAnswers` being reset after poll event did not retreive the `latestAnswers` data We should not treat optional `latestAnswers` as empty, since they have different meanings * Add `PollCommentListVC` implementation * Fix `PollVoteListQueryDTO.filterHash` using filterHash only instead of queryHash This was causing the pollId to not be considered when fetching the DB votes * Make diffable data sources more stable * Fix first page of poll vote list resetting all votes * Fix the default vote list sorting * Add poll suggestions feature * Add anonymous polls support * Fix AlertsRouter docs * Add test coverage to `PollCommentListVC` * Add test coverage when poll comments are 0 * Add test coverage to allow suggestions * Add test coverage to anonymous polls * Re-record snapshots after renaming test file * Fix snapshot on CI * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md * Update Sources/StreamChatUI/ChatMessageList/Attachments/Poll/PollAttachmentView.swift * Update Sources/StreamChatUI/ChatMessageList/Attachments/Poll/PollCommentListVC/PollCommentListSectionFooterView.swift * Fix comments and suggestion buttons showing when poll is closed * Update CHANGELOG.md * Change alert titles to follow Apples guideline * Improve comments view spacing * Optimize a bit to check if a user has already a comment * [Polls] Add Poll Creation Flow (#3433) * [Polls] Add `PollAttachmentView` + `ViewContainerBuilder` (#3374) * Introduce new ViewContainerBuilder * Add PollAttachmentView component * Change to SwiftUI ENV * Add `shouldShowOnlineIndicator` to turn off online presence in `ChatUserAvatarView` * Fix small iOS 13 deprecation * Add domain logic helpers to Poll * Message Polls live updates * Event.ownVotes workaround (Drop when fixed) * Manage data races when voting on a poll in the message list * Add haptic feedback when voting * Make sure to update the latestVotes author avatar views * Improve performance of Option List View by no recreating the item views everytime * Improve flexibility of Option List View without compromising performance * Make content of StackedUserAvatarsView public * Re-structure Common Buttons Folder * Add `CheckboxButton` as a common view * Add vote ratio logic to `ChatChannelListItemView` * Fix UI Glitches for option list item view when text is too big and avatar appears and disappears * Extract more common logic to `Poll` domain model * Add closed poll and winner option state logic * Add subtitle text logic to `PollAttachmentView` * Change winner logic to be the one and only one option with most votes * Add channel list message preview text for polls * Add poll quoted message text rendering * Add View Results and End Button to the Poll Attachment View * Fix poll option label width ui glitch * Added End Poll functionality * Add isOptionWinner and isOptionOneOfTheWinners to Poll * Fix message with Polls not showing when long pressing * Fix poll controller with incorrect data in message list * Sort the `latestVotes` and `latestAnswers` in the LLC * Add test coverage to Poll domain helpers * Add Test Coverage to Poll Message Preview in Channel List * Add test coverage to PollAttachmentView * Add test coverage to disabling online indicator in ChatUserAvatarView * Add test coverage to quoted poll * Fix some existing snapshot tests * Use UIStackView for Spacer() to avoid drawing * Fix Xcode 14 Build * Fix Poll AttachmentView Tests on CI * Update CHANGELOG.md * Update CHANGELOG.md * Fix Xcode 14 Build, conflict with SwiftUI Spacer * Revert "Change to SwiftUI ENV" This reverts commit 6d9129a. * Add documentation to ViewContainerBuilder * Fix vale issues * Fix using pin() instead of constraint() in docs * [Polls] Add `PollResultsVC` (#3381) * [Polls] Comments + Suggestions + Anonymous Polls + LLC Fixes (#3398) * Refactor PollResultsVC Section views to be more simple and flat hierarchy * Fix bottom spacing in Poll Results Section Header * Add comment buttons to `PollAttachmentView` * Add comment to poll implementation * Fix `poll.latestAnswers` being reset after poll event did not retreive the `latestAnswers` data We should not treat optional `latestAnswers` as empty, since they have different meanings * Add `PollCommentListVC` implementation * Fix `PollVoteListQueryDTO.filterHash` using filterHash only instead of queryHash This was causing the pollId to not be considered when fetching the DB votes * Make diffable data sources more stable * Fix first page of poll vote list resetting all votes * Fix the default vote list sorting * Add poll suggestions feature * Add anonymous polls support * Fix AlertsRouter docs * Add test coverage to `PollCommentListVC` * Add test coverage when poll comments are 0 * Add test coverage to allow suggestions * Add test coverage to anonymous polls * Re-record snapshots after renaming test file * Fix snapshot on CI * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md * Update Sources/StreamChatUI/ChatMessageList/Attachments/Poll/PollAttachmentView.swift * Update Sources/StreamChatUI/ChatMessageList/Attachments/Poll/PollCommentListVC/PollCommentListSectionFooterView.swift * Fix comments and suggestion buttons showing when poll is closed * Update CHANGELOG.md * Change alert titles to follow Apples guideline * Improve comments view spacing * Optimize a bit to check if a user has already a comment * Add poll creation action to composer if polls are enabled * Add Poll Creation Views and UX * Handle keyboard adjustment in the poll creation view * Add actual if-statement support to ViewContainerBuilder * Add Poll Creation View Styling * Add poll creation section header view * Add Poll Creation Feature Cell Styling * Add Multiple Votes Feature Cell Data handling * Improve data handling in PollCreationVC * Add poll creation button * Fix Poll Creation Memory Leaks + Add Poll Option Errors * Implement poll option error indices * Refactor Poll Creation View to Collection View * Add views to components and appearance * Implement keyboard management in Poll Creation VC * Implementation of discarding poll changes * Add poll alert error if creation fails * Fix basic features not being persisted * Add localization to the views * Add for polls feature support configuration * Add Poll Creation View test coverage * Update CHANGELOG.md * Fix test_canCreatePoll_whenOptionsError_shouldReturnFalse test * [CI] Snapshots (#3434) Co-authored-by: Stream Bot <[email protected]> * Fix maximum votes error not being cleared when multiple votes is disabled * Change multiple votes keyboard to number bad * Remove custom equatable implementation that is not required for PollFeatureType * Remove yeetd-normal.pkg file? * Fix adding duplicate options * Disable swiftlint notification_center_detachment and switch_case_alignment * Extract poll creation input view height to a constant --------- Co-authored-by: Stream SDK Bot <[email protected]> Co-authored-by: Stream Bot <[email protected]> * Add `padding()` to ViewContainerBuilder + Remove ViewContainerBuilder `layout` and `constraints` The layout and constraints function would not work at all because applying constraints before adding a view to hierarchy is not possibl.e * Fix votes impacting latest answers * Fix poll.ownVotes and poll.latestAnwers impacting each other by moving them to poll.latestVotes * Fix Poll Repository Tests * Fix reorder icon showing before adding a new option * Fix anonymous comments logic * Fix channel list message preview incorrect latest voter * Fix edit message appearing in poll attachment * Fix being able to tap on options in a closed poll * Change min votes to 2 when maximum votes enabled since 1 maximum is not multiple votes * Fix trophy not showing for poll results winner * Fix snapshot UI Tests * Fix section header tests * Remove unnecessary disabling of swiftlint rules * PR Feedback * Change the order of the latest votes so that the first one is the most recent one * Adds the `PollAllOptionsListVC` component * Add missing test coverage to `PollAllOptionsListVC` * Fix poll question tappable on the All Options view * Fix not allow creating poll with only 1 option * Fix snapshots of poll all options view * Fix Message Actions not scrollable when multiple options * Update CHANGELOG.md * Add documentation to Polls UIKit * Update Poll Configuration docs * Better consistency in Polls documentation titles * Improve Poll State documentation structure * Update Poll Vote List Controller documentation with new inits * [CI] Snapshots (#3441) Co-authored-by: Stream Bot <[email protected]> * Remove unwanted file --------- Co-authored-by: Stream SDK Bot <[email protected]> Co-authored-by: Stream Bot <[email protected]> Co-authored-by: Stream Bot <[email protected]>
🔗 Issue Links
https://stream-io.atlassian.net/browse/PBE-4287
🎯 Goal
Adds the
PollAttachmentView
Components to the Message List.Out of Scope
📝 Summary
New
ViewContainerBuilder
This PR introduces a new way to build and customize UIs in the UIKit SDK. The goal is to make it easier to re-layout when customizing the default views and also to make it easier for us to create new components more quickly and easily.
The API is pretty small, this is all the things we can use:
HContainer(spacing:distribution:alignment:)
to create Horizontal Stack Views.VContainer(spacing:distribution:alignment:)
to create Vertical Stack Views.Spacer()
to create Empty/Spacing views.UIView.layout {}
to create additional layout changes in place.UIView.constraints { }
to automatically activate constraints.UIStackView.views { }
to replace thearrangedSubviews
of a stack view.UIStackView.embed()
to easily embed containers into the existing hierarchyUIView.width()
andUIView.heigh()
to easily provide width and height values to a viewLLC Changes
Updates the
MessageDTO
whenever thePollDTO
changes.This is needed to trigger
didMessageUpdates
delegate changes. This is especially important for UIKit since it requires table view cell reloading for the UI updates to be visible.Adds domain logic helpers to the
Poll
model:This logic is close to the domain logic, so it can live in the LLC SDK and be shared by both SwiftUI and UIKit. Ideally, SwiftUI should update to use these helpers internally. This is quite useful as well because it is used in multiple components across the UI SDKs.
New API added:
currentMaximumVoteCount: Int
isOptionWinner(_ option:) -> Bool
isOptionOneOfTheWinners(_ option:) -> Bool
isOptionWithMostVotes(_ option:) -> Bool
isOptionWithMaximumVotes(_ option:) -> Bool
voteCount(for option:) -> Int
voteRatio(for option: PollOption) -> Float
currentUserVote(for option: PollOption) -> PollVote?
hasCurrentUserVoted(for option: PollOptions) -> Bool
PollAttachmentView
High-level Overview
Poll Implementation Details
PollController
reference in theChatMessageListVC
to manage poll interactionsUI SDK Changes
ChatUserAvatarView.shouldShowOnlineIndicator
to allow disabling the online indicatorStackedUserAvatarView
to reuse overlaying a stack of avatarsCheckboxButton
🧪 Manual Testing Notes
Only some overall simple QA should be done. The full QA should be done on the final PR.
Note: The SwiftUI environment should be used.
Since poll creation has not yet been done, it should be done on the SwiftUI Demo app.
☑️ Contributor Checklist