Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Jan 20, 2025
1 parent dac7ba8 commit f95dbd7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 44 deletions.
34 changes: 17 additions & 17 deletions ElementX/Sources/Mocks/RoomPreviewProxyMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
import Foundation
import MatrixRustSDK

struct RoomPreviewProxyMockConfiguration {
var roomId = "1"
var canonicalAlias = "#3🌞problem:matrix.org"
var name = "The Three-Body Problem - 三体"
var topic = "“Science and technology were the only keys to opening the door to the future, and people approached science with the faith and sincerity of elementary school students.”"
var avatarUrl = URL.mockMXCAvatar.absoluteString
var numJoinedMembers = UInt64(100)
var numActiveMembers = UInt64(100)
var roomType = RoomType.room
var membership: Membership?
var joinRule: JoinRule
}

extension RoomPreviewProxyMock {
struct Configuration {
var roomID = "1"
var canonicalAlias = "#3🌞problem:matrix.org"
var name = "The Three-Body Problem - 三体"
var topic = "“Science and technology were the only keys to opening the door to the future, and people approached science with the faith and sincerity of elementary school students.”"
var avatarURL = URL.mockMXCAvatar.absoluteString
var numJoinedMembers = UInt64(100)
var numActiveMembers = UInt64(100)
var roomType = RoomType.room
var membership: Membership?
var joinRule: JoinRule
}

static var joinable: RoomPreviewProxyMock {
.init(.init(membership: nil, joinRule: .public))
}
Expand All @@ -36,7 +36,7 @@ extension RoomPreviewProxyMock {

static func invited(roomID: String? = nil) -> RoomPreviewProxyMock {
if let roomID {
return .init(.init(roomId: roomID, membership: .invited, joinRule: .invite))
return .init(.init(roomID: roomID, membership: .invited, joinRule: .invite))
}

return .init(.init(membership: .invited, joinRule: .invite))
Expand All @@ -58,13 +58,13 @@ extension RoomPreviewProxyMock {
.init(.init(membership: .banned, joinRule: .public))
}

convenience init(_ configuration: RoomPreviewProxyMockConfiguration) {
convenience init(_ configuration: RoomPreviewProxyMock.Configuration) {
self.init()
underlyingInfo = .init(roomPreviewInfo: .init(roomId: configuration.roomId,
underlyingInfo = .init(roomPreviewInfo: .init(roomId: configuration.roomID,
canonicalAlias: configuration.canonicalAlias,
name: configuration.name,
topic: configuration.topic,
avatarUrl: configuration.avatarUrl,
avatarUrl: configuration.avatarURL,
numJoinedMembers: configuration.numJoinedMembers,
numActiveMembers: configuration.numActiveMembers,
roomType: configuration.roomType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
break
}

let name = roomInfo?.displayName ?? roomPreview?.info.displayName
state.roomDetails = JoinRoomScreenRoomDetails(name: name,
topic: roomInfo?.topic ?? roomPreview?.info.topic,
canonicalAlias: roomInfo?.canonicalAlias ?? roomPreview?.info.canonicalAlias,
avatar: roomInfo?.avatar ?? .room(id: roomID, name: name ?? "", avatarURL: roomPreview?.info.avatarURL),
memberCount: UInt(roomInfo?.activeMembersCount ?? Int(roomPreview?.info.activeMembersCount ?? 0)),
let info = roomInfo ?? roomPreview?.info
state.roomDetails = JoinRoomScreenRoomDetails(name: info?.displayName,
topic: info?.topic,
canonicalAlias: info?.canonicalAlias,
avatar: info?.avatar ?? .room(id: roomID, name: info?.displayName ?? "", avatarURL: nil),
memberCount: UInt(info?.activeMembersCount ?? 0),
inviter: inviter)

await updateMode()
Expand Down Expand Up @@ -149,9 +149,7 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
case .private, .invite:
state.mode = .inviteRequired
case .knock, .knockRestricted:
if appSettings.knockingEnabled {
state.mode = .knockable
}
state.mode = appSettings.knockingEnabled ? .knockable : .joinable
case .restricted:
state.mode = .restricted
default:
Expand Down
30 changes: 12 additions & 18 deletions ElementX/Sources/Screens/JoinRoomScreen/View/JoinRoomScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,25 +184,16 @@ struct JoinRoomScreen: View {
}

func bottomNoticeMessage(_ notice: String) -> some View {
HStack(alignment: .top, spacing: 12) {
CompoundIcon(\.info)

Text(notice)
.font(.compound.bodyLGSemibold)
.foregroundStyle(.compound.textPrimary)

Spacer()
}
.padding()
.background(.compound.bgSubtleSecondary)
.cornerRadius(14, corners: .allCorners)
Label(notice, icon: \.info)
.labelStyle(.custom(spacing: 12, alignment: .top))
.frame(maxWidth: .infinity, alignment: .leading)
.padding()
.background(.compound.bgSubtleSecondary)
.cornerRadius(14, corners: .allCorners)
}

func bottomErrorMessage(title: String, subtitle: String?) -> some View {
HStack(alignment: .top, spacing: 12) {
CompoundIcon(\.error)
.foregroundStyle(.compound.iconCriticalPrimary)

Label {
VStack(alignment: .leading, spacing: 4) {
Text(title)
.font(.compound.bodyLGSemibold)
Expand All @@ -214,9 +205,12 @@ struct JoinRoomScreen: View {
.foregroundStyle(.compound.textSecondary)
}
}

Spacer()
} icon: {
CompoundIcon(\.error)
.foregroundStyle(.compound.iconCriticalPrimary)
}
.labelStyle(.custom(spacing: 12, alignment: .top))
.frame(maxWidth: .infinity, alignment: .leading)
.padding()
.background(.compound.bgSubtleSecondary)
.cornerRadius(14, corners: .allCorners)
Expand Down

0 comments on commit f95dbd7

Please sign in to comment.