generated from element-hq/.github
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refine polls UI in the timeline (#1474)
* Add summary view in PollRoomTimelineView * Add selectedPollOption action * Handle undisclosed polls * Add more logics in PollRoomTimelineView * Refine ended poll UI * Refine poll layout * More UI refinements * Fix layout issue * Refine progress bar * Add poll mocks and UI tests * Cleanup
- Loading branch information
1 parent
f641596
commit 25f66d2
Showing
27 changed files
with
345 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
ElementX/Resources/Assets.xcassets/images/polls/Contents.json
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-1.62 KB
ElementX/Resources/Assets.xcassets/images/polls/equalizer.imageset/equalizer.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion
2
...es/polls/equalizer.imageset/Contents.json → ...line/timeline-poll.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "equalizer.pdf", | ||
"filename" : "timeline-poll.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
|
Binary file added
BIN
+2.95 KB
ElementX/Resources/Assets.xcassets/images/timeline/timeline-poll.imageset/timeline-poll.pdf
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// | ||
// Copyright 2023 New Vector Ltd | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Foundation | ||
|
||
extension Poll { | ||
static func mock(question: String, | ||
pollKind: Poll.Kind = .disclosed, | ||
options: [Poll.Option], | ||
votes: [String: [String]] = [:], | ||
ended: Bool = false) -> Self { | ||
.init(question: question, | ||
kind: pollKind, | ||
maxSelections: 1, | ||
options: options, | ||
votes: votes, | ||
endDate: ended ? Date() : nil) | ||
} | ||
|
||
static var disclosed: Self { | ||
mock(question: "What country do you like most?", | ||
pollKind: .disclosed, | ||
options: [.mock(text: "Italy 🇮🇹", votes: 5, allVotes: 10, isWinning: true), | ||
.mock(text: "China 🇨🇳", votes: 3, allVotes: 10), | ||
.mock(text: "USA 🇺🇸", votes: 2, allVotes: 10)]) | ||
} | ||
|
||
static var undisclosed: Self { | ||
mock(question: "What country do you like most?", | ||
pollKind: .undisclosed, | ||
options: [.mock(text: "Italy 🇮🇹", votes: 5, allVotes: 10, isWinning: true), | ||
.mock(text: "China 🇨🇳", votes: 3, allVotes: 10, isSelected: true), | ||
.mock(text: "USA 🇺🇸", votes: 2, allVotes: 10)]) | ||
} | ||
|
||
static var endedDisclosed: Self { | ||
mock(question: "What country do you like most?", | ||
pollKind: .disclosed, | ||
options: [.mock(text: "Italy 🇮🇹", votes: 5, allVotes: 10, isWinning: true), | ||
.mock(text: "China 🇨🇳", votes: 3, allVotes: 10, isSelected: true), | ||
.mock(text: "USA 🇺🇸", votes: 2, allVotes: 10)], | ||
ended: true) | ||
} | ||
|
||
static var endedUndisclosed: Self { | ||
mock(question: "What country do you like most?", | ||
pollKind: .undisclosed, | ||
options: [.mock(text: "Italy 🇮🇹", votes: 5, allVotes: 10, isWinning: true), | ||
.mock(text: "China 🇨🇳", votes: 3, allVotes: 10, isSelected: true), | ||
.mock(text: "USA 🇺🇸", votes: 2, allVotes: 10)], | ||
ended: true) | ||
} | ||
} | ||
|
||
extension Poll.Option { | ||
static func mock(text: String, votes: Int = 0, allVotes: Int = 0, isSelected: Bool = false, isWinning: Bool = false) -> Self { | ||
.init(id: UUID().uuidString, | ||
text: text, | ||
votes: votes, | ||
allVotes: allVotes, | ||
isSelected: isSelected, | ||
isWinning: isWinning) | ||
} | ||
} | ||
|
||
extension PollRoomTimelineItem { | ||
static func mock(poll: Poll) -> Self { | ||
.init(id: .random, | ||
poll: poll, | ||
body: "poll", | ||
timestamp: "Now", | ||
isOutgoing: true, | ||
isEditable: false, | ||
sender: .init(id: "userID"), | ||
properties: .init()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.