Skip to content

Commit

Permalink
/issues/5114 - Polls in the timeline.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Nov 24, 2021
1 parent 88dba32 commit 8f5e9de
Show file tree
Hide file tree
Showing 34 changed files with 1,190 additions and 169 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "poll_checkbox_default.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "poll_checkbox_default@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "poll_checkbox_default@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "poll_checkbox_selected.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "poll_checkbox_selected@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "poll_checkbox_selected@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "poll_winner_icon.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "poll_winner_icon@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "poll_winner_icon@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion Riot/Assets/en.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,10 @@ Tap the + to start adding people.";

"poll_edit_form_create_options" = "Create options";

"poll_edit_form_option_number" = "Option %d";
"poll_edit_form_option_number" = "Option %lu";

"poll_edit_form_add_option" = "Add option";

"poll_timeline_votes_count" = "%lu votes";

"poll_timeline_total_votes_count" = "Based on %lu votes";
3 changes: 3 additions & 0 deletions Riot/Generated/Images.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,13 @@ internal enum Asset {
internal static let videoCall = ImageAsset(name: "video_call")
internal static let voiceCallHangonIcon = ImageAsset(name: "voice_call_hangon_icon")
internal static let voiceCallHangupIcon = ImageAsset(name: "voice_call_hangup_icon")
internal static let pollCheckboxDefault = ImageAsset(name: "poll_checkbox_default")
internal static let pollCheckboxSelected = ImageAsset(name: "poll_checkbox_selected")
internal static let pollDeleteIcon = ImageAsset(name: "poll_delete_icon")
internal static let pollDeleteOptionIcon = ImageAsset(name: "poll_delete_option_icon")
internal static let pollEditIcon = ImageAsset(name: "poll_edit_icon")
internal static let pollEndIcon = ImageAsset(name: "poll_end_icon")
internal static let pollWinnerIcon = ImageAsset(name: "poll_winner_icon")
internal static let urlPreviewClose = ImageAsset(name: "url_preview_close")
internal static let urlPreviewCloseDark = ImageAsset(name: "url_preview_close_dark")
internal static let voiceMessageCancelGradient = ImageAsset(name: "voice_message_cancel_gradient")
Expand Down
10 changes: 9 additions & 1 deletion Riot/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2379,7 +2379,7 @@ public class VectorL10n: NSObject {
public static var pollEditFormInputPlaceholder: String {
return VectorL10n.tr("Vector", "poll_edit_form_input_placeholder")
}
/// Option %d
/// Option %lu
public static func pollEditFormOptionNumber(_ p1: Int) -> String {
return VectorL10n.tr("Vector", "poll_edit_form_option_number", p1)
}
Expand All @@ -2391,6 +2391,14 @@ public class VectorL10n: NSObject {
public static var pollEditFormQuestionOrTopic: String {
return VectorL10n.tr("Vector", "poll_edit_form_question_or_topic")
}
/// Based on %lu votes
public static func pollTimelineTotalVotesCount(_ p1: Int) -> String {
return VectorL10n.tr("Vector", "poll_timeline_total_votes_count", p1)
}
/// %lu votes
public static func pollTimelineVotesCount(_ p1: Int) -> String {
return VectorL10n.tr("Vector", "poll_timeline_votes_count", p1)
}
/// Preview
public static var preview: String {
return VectorL10n.tr("Vector", "preview")
Expand Down
3 changes: 2 additions & 1 deletion Riot/Modules/Room/CellData/RoomBubbleCellData.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ typedef NS_ENUM(NSInteger, RoomBubbleCellDataTag)
RoomBubbleCellDataTagKeyVerificationConclusion,
RoomBubbleCellDataTagCall,
RoomBubbleCellDataTagGroupCall,
RoomBubbleCellDataTagRoomCreationIntro
RoomBubbleCellDataTagRoomCreationIntro,
RoomBubbleCellDataTagPoll
};

/**
Expand Down
21 changes: 20 additions & 1 deletion Riot/Modules/Room/CellData/RoomBubbleCellData.m
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ - (instancetype)initWithEvent:(MXEvent *)event andRoomState:(MXRoomState *)roomS

// Show timestamps always on right
self.displayTimestampForSelectedComponentOnLeftWhenPossible = NO;
break;
}
case MXEventTypePollStart:
{
self.tag = RoomBubbleCellDataTagPoll;
self.collapsable = NO;
self.collapsed = NO;

break;
}
case MXEventTypeCustom:
{
Expand Down Expand Up @@ -260,6 +269,11 @@ - (BOOL)hasNoDisplay
return NO;
}

if (self.tag == RoomBubbleCellDataTagPoll)
{
return NO;
}

return [super hasNoDisplay];
}

Expand Down Expand Up @@ -418,7 +432,9 @@ - (NSInteger)firstVisibleComponentIndex
{
__block NSInteger firstVisibleComponentIndex = NSNotFound;

if (self.attachment && self.bubbleComponents.count)
BOOL isPoll = (self.events.firstObject.eventType == MXEventTypePollStart);

if ((isPoll || self.attachment) && self.bubbleComponents.count)
{
firstVisibleComponentIndex = 0;
}
Expand Down Expand Up @@ -874,6 +890,9 @@ - (BOOL)addEvent:(MXEvent*)event andRoomState:(MXRoomState*)roomState
case MXEventTypeCallReject:
shouldAddEvent = NO;
break;
case MXEventTypePollStart:
shouldAddEvent = NO;
break;
case MXEventTypeCustom:
{
if ([event.type isEqualToString:kWidgetMatrixEventTypeString]
Expand Down
15 changes: 13 additions & 2 deletions Riot/Modules/Room/RoomCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
self.roomViewController = RoomViewController.instantiate()
self.activityIndicatorPresenter = ActivityIndicatorPresenter()

if #available(iOS 14, *) {
PollTimelineViewProvider.shared.session = parameters.session
}

super.init()
}

Expand Down Expand Up @@ -149,6 +153,10 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
self.activityIndicatorPresenter.removeCurrentActivityIndicator(animated: true)

if let roomDataSource = roomDataSource {
if #available(iOS 14, *) {
PollTimelineViewProvider.shared.room = roomDataSource.room
}

self.roomViewController.displayRoom(roomDataSource)
}

Expand All @@ -175,6 +183,10 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
guard let roomDataSource = dataSource as? RoomDataSource else {
return
}

if #available(iOS 14, *) {
PollTimelineViewProvider.shared.room = roomDataSource.room
}

roomDataSource.markTimelineInitialEvent = true
self.roomViewController.displayRoom(roomDataSource)
Expand Down Expand Up @@ -248,8 +260,7 @@ extension RoomCoordinator: RoomViewControllerDelegate {
return
}

let parameters = PollEditFormCoordinatorParameters(navigationRouter: self.navigationRouter)

let parameters = PollEditFormCoordinatorParameters(navigationRouter: self.navigationRouter, room: roomViewController.roomDataSource.room)
pollEditFormCoordinator = PollEditFormCoordinator(parameters: parameters)

pollEditFormCoordinator?.start()
Expand Down
Loading

0 comments on commit 8f5e9de

Please sign in to comment.