Skip to content

Commit

Permalink
implementation done we just need tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Velin92 committed Jan 18, 2024
1 parent 3ae33f1 commit 86bc01b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
3 changes: 3 additions & 0 deletions ElementX/Resources/Localizations/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"action_join" = "Join";
"action_learn_more" = "Learn more";
"action_leave" = "Leave";
"action_leave_conversation" = "Leave conversation";
"action_leave_room" = "Leave room";
"action_manage_account" = "Manage account";
"action_manage_devices" = "Manage devices";
Expand Down Expand Up @@ -228,6 +229,7 @@
"error_unknown" = "Sorry, an error occurred";
"invite_friends_rich_title" = "🔐️ Join me on %1$@";
"invite_friends_text" = "Hey, talk to me on %1$@: %2$@";
"leave_conversation_alert_subtitle" = "Are you sure that you want to leave this conversation? This conversation is not public and you won't be able to rejoin without an invite.";
"leave_room_alert_empty_subtitle" = "Are you sure that you want to leave this room? You're the only person here. If you leave, no one will be able to join in the future, including you.";
"leave_room_alert_private_subtitle" = "Are you sure that you want to leave this room? This room is not public and you won't be able to rejoin without an invite.";
"leave_room_alert_subtitle" = "Are you sure that you want to leave the room?";
Expand Down Expand Up @@ -679,6 +681,7 @@
"screen_dm_details_unblock_user" = "Unblock user";
"screen_login_subtitle" = "Matrix is an open network for secure, decentralised communication.";
"screen_report_content_block_user" = "Block user";
"screen_room_details_leave_conversation_title" = "Leave conversation";
"screen_room_details_leave_room_title" = "Leave room";
"screen_room_details_security_title" = "Security";
"screen_room_details_topic_title" = "Topic";
Expand Down
6 changes: 6 additions & 0 deletions ElementX/Sources/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ public enum L10n {
public static var actionLearnMore: String { return L10n.tr("Localizable", "action_learn_more") }
/// Leave
public static var actionLeave: String { return L10n.tr("Localizable", "action_leave") }
/// Leave conversation
public static var actionLeaveConversation: String { return L10n.tr("Localizable", "action_leave_conversation") }
/// Leave room
public static var actionLeaveRoom: String { return L10n.tr("Localizable", "action_leave_room") }
/// Manage account
Expand Down Expand Up @@ -524,6 +526,8 @@ public enum L10n {
public static func inviteFriendsText(_ p1: Any, _ p2: Any) -> String {
return L10n.tr("Localizable", "invite_friends_text", String(describing: p1), String(describing: p2))
}
/// Are you sure that you want to leave this conversation? This conversation is not public and you won't be able to rejoin without an invite.
public static var leaveConversationAlertSubtitle: String { return L10n.tr("Localizable", "leave_conversation_alert_subtitle") }
/// Are you sure that you want to leave this room? You're the only person here. If you leave, no one will be able to join in the future, including you.
public static var leaveRoomAlertEmptySubtitle: String { return L10n.tr("Localizable", "leave_room_alert_empty_subtitle") }
/// Are you sure that you want to leave this room? This room is not public and you won't be able to rejoin without an invite.
Expand Down Expand Up @@ -1188,6 +1192,8 @@ public enum L10n {
public static var screenRoomDetailsErrorUnmuting: String { return L10n.tr("Localizable", "screen_room_details_error_unmuting") }
/// Invite people
public static var screenRoomDetailsInvitePeopleTitle: String { return L10n.tr("Localizable", "screen_room_details_invite_people_title") }
/// Leave conversation
public static var screenRoomDetailsLeaveConversationTitle: String { return L10n.tr("Localizable", "screen_room_details_leave_conversation_title") }
/// Leave room
public static var screenRoomDetailsLeaveRoomTitle: String { return L10n.tr("Localizable", "screen_room_details_leave_room_title") }
/// Custom
Expand Down
4 changes: 2 additions & 2 deletions ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
}

if room.isPublic {
state.bindings.leaveRoomAlertItem = LeaveRoomAlertItem(roomId: roomId, state: .public)
state.bindings.leaveRoomAlertItem = LeaveRoomAlertItem(roomId: roomId, isDM: room.isEncryptedOneToOneRoom, state: .public)
} else {
state.bindings.leaveRoomAlertItem = room.joinedMembersCount > 1 ? LeaveRoomAlertItem(roomId: roomId, state: .private) : LeaveRoomAlertItem(roomId: roomId, state: .empty)
state.bindings.leaveRoomAlertItem = room.joinedMembersCount > 1 ? LeaveRoomAlertItem(roomId: roomId, isDM: room.isEncryptedOneToOneRoom, state: .private) : LeaveRoomAlertItem(roomId: roomId, isDM: room.isEncryptedOneToOneRoom, state: .empty)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,19 @@ struct LeaveRoomAlertItem: AlertProtocol {
}

let roomId: String
let isDM: Bool
let state: RoomState
let title = L10n.actionLeaveRoom
let confirmationTitle = L10n.actionLeave
let cancelTitle = L10n.actionCancel

var title: String {
isDM ? L10n.actionLeaveConversation : L10n.actionLeaveRoom
}

var subtitle: String {
switch state {
case .empty: return L10n.leaveRoomAlertEmptySubtitle
case .private: return L10n.leaveRoomAlertPrivateSubtitle
case .private: return isDM ? L10n.leaveConversationAlertSubtitle : L10n.leaveRoomAlertPrivateSubtitle
case .public: return L10n.leaveRoomAlertSubtitle
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
actionsSubject.send(.requestInvitePeoplePresentation)
case .processTapLeave:
guard state.joinedMembersCount > 1 else {
state.bindings.leaveRoomAlertItem = LeaveRoomAlertItem(roomId: roomProxy.id, state: .empty)
state.bindings.leaveRoomAlertItem = LeaveRoomAlertItem(roomId: roomProxy.id, isDM: roomProxy.isEncryptedOneToOneRoom, state: .empty)
return
}
state.bindings.leaveRoomAlertItem = LeaveRoomAlertItem(roomId: roomProxy.id, state: roomProxy.isPublic ? .public : .private)
state.bindings.leaveRoomAlertItem = LeaveRoomAlertItem(roomId: roomProxy.id, isDM: roomProxy.isEncryptedOneToOneRoom, state: roomProxy.isPublic ? .public : .private)
case .confirmLeave:
Task { await leaveRoom() }
case .processTapIgnore:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,14 @@ struct RoomDetailsScreen: View {
}
}
}

private var leaveRoomTitle: String {
context.viewState.dmRecipient == nil ? L10n.screenRoomDetailsLeaveRoomTitle : L10n.screenRoomDetailsLeaveConversationTitle
}

private var leaveRoomSection: some View {
Section {
ListRow(label: .action(title: L10n.actionLeaveRoom,
ListRow(label: .action(title: leaveRoomTitle,
icon: \.leave,
role: .destructive),
kind: .button { context.send(viewAction: .processTapLeave) })
Expand Down

0 comments on commit 86bc01b

Please sign in to comment.