Files
element-x-ios/ElementX/Sources/Screens/RoomMemberListScreen/View/RoomMembersListScreenMemberCell.swift
T
Alfonso Grillo 63df68fd29 Room details: improve members count UX (#1050)
* Inject user id into room’s details

* Refactor member fetch logic in RoomDetailsScreenViewModel

* Refactor DI

* Fetch members in RoomMembersListScreenViewModel

* Fetch members in InviteUsersScreen

* Use joinedMembersCount in room members list

* Cleanup

* Limit members refresh

* Cleanup binding

* Fix UT build errors

* Fix RoomDetailsScreenViewModelTests

* Fix RoomMembersListScreenViewModelTests

* Fix UTs

* Fix RoomDetailsScreenUITests

* Refine RoomDetailsScreenViewModelTests

* Add roomProxy extension

* PR comments

* Refactor room’s counter to Int

* Improve updateMembers() performances

* Fix memory leaks
2023-06-09 16:21:01 +02:00

66 lines
2.3 KiB
Swift

//
// Copyright 2022 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 SwiftUI
struct RoomMembersListScreenMemberCell: View {
@ScaledMetric private var avatarSize = AvatarSize.user(on: .roomDetails).value
let member: RoomMemberDetails
let context: RoomMembersListScreenViewModel.Context
var body: some View {
Button {
context.send(viewAction: .selectMember(id: member.id))
} label: {
HStack {
LoadableAvatarImage(url: member.avatarURL,
name: member.name ?? "",
contentID: member.id,
avatarSize: .user(on: .roomDetails),
imageProvider: context.imageProvider)
.accessibilityHidden(true)
Text(member.name ?? "")
.font(.compound.bodyMDSemibold)
.foregroundColor(.element.primaryContent)
.lineLimit(1)
Spacer()
}
.accessibilityElement(children: .combine)
}
}
}
struct RoomMembersListMemberCell_Previews: PreviewProvider {
static var previews: some View {
let members: [RoomMemberProxyMock] = [
.mockAlice,
.mockBob,
.mockCharlie
]
let viewModel = RoomMembersListScreenViewModel(roomProxy: RoomProxyMock(with: .init(displayName: "Some room", members: members)),
mediaProvider: MockMediaProvider())
return VStack {
ForEach(members, id: \.userID) { member in
RoomMembersListScreenMemberCell(member: .init(withProxy: member), context: viewModel.context)
}
}
}
}