Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Redesign the thread replies divider in the message replies list [#1354](https://github.com/GetStream/stream-chat-swiftui/pull/1354)

### 🐞 Fixed
- Fix swipe-to-reply icon layout for outgoing messages and RTL [#1402](https://github.com/GetStream/stream-chat-swiftui/pull/1402)
- Fix unwanted border on the Edit button in Channel Info [#1402](https://github.com/GetStream/stream-chat-swiftui/pull/1402)
- Fix send button icon not mirroring in RTL layouts [#1397](https://github.com/GetStream/stream-chat-swiftui/pull/1397)
- Fix composer attachment picker prompt views layout to center all content vertically [#1397](https://github.com/GetStream/stream-chat-swiftui/pull/1397)
- Fix poll icon inconsistency in the attachment type picker and attachment previews [#1397](https://github.com/GetStream/stream-chat-swiftui/pull/1397)
Expand All @@ -37,6 +39,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix spacings in message annotations [#1403](https://github.com/GetStream/stream-chat-swiftui/pull/1403)

### πŸ”„ Changed
- Rename `AddUsersView`/`AddUsersViewModel` to `MemberAddView`/`MemberAddViewModel` [#1402](https://github.com/GetStream/stream-chat-swiftui/pull/1402)
- Unify Channel Info navigation headers styling [#1402](https://github.com/GetStream/stream-chat-swiftui/pull/1402)
- Renamed the `onMessageSent` callback to `willSendMessage` in `MessageComposerViewModel`, `ViewModelsFactory`, and `ComposerViewFactoryOptions` [#1327](https://github.com/GetStream/stream-chat-swiftui/pull/1327)
- Remove `InjectedChannelInfo` from `ChatChannelListItemView` [#1338](https://github.com/GetStream/stream-chat-swiftui/pull/1338)
- Rename empty state views from `No` prefix to `Empty` prefix [#1345](https://github.com/GetStream/stream-chat-swiftui/pull/1345)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,94 +257,6 @@ public struct ChannelInfoItemView<TrailingView: View>: View {
}
}

// MARK: - Member List View

/// A view that displays the full member list for a group channel, presented as a sheet.
public struct MemberListView<Factory: ViewFactory>: View {
@Injected(\.colors) private var colors
@Injected(\.fonts) private var fonts
@Injected(\.tokens) private var tokens
@Injected(\.images) private var images
@Injected(\.chatClient) private var chatClient

let factory: Factory
@ObservedObject var viewModel: ChatChannelInfoViewModel
@State private var selectedParticipant: ParticipantInfo?
@State private var addUsersShown = false

public init(factory: Factory = DefaultViewFactory.shared, viewModel: ChatChannelInfoViewModel) {
self.factory = factory
self.viewModel = viewModel
}

public var body: some View {
NavigationView {
ScrollView {
LazyVStack(spacing: 0) {
ForEach(viewModel.allParticipants) { participant in
ChatInfoMemberView(
factory: factory,
participant: participant,
backgroundColor: colors.backgroundCoreApp,
onAppear: { viewModel.onMemberAppear(participant) },
onTap: {
selectedParticipant = participant
}
)
}
}
}
.background(Color(colors.backgroundCoreApp).edgesIgnoringSafeArea(.all))
.toolbarThemed {
ToolbarItem(placement: .principal) {
Text(L10n.ChatInfo.Members.count(viewModel.channel.memberCount))
.font(fonts.bodyBold)
.foregroundColor(Color(colors.navigationBarTitle))
}
ToolbarItem(placement: .navigationBarLeading) {
Button {
viewModel.memberListSheetShown = false
} label: {
Image(uiImage: images.close)
.foregroundColor(Color(colors.textSecondary))
}
}
ToolbarItem(placement: .navigationBarTrailing) {
if viewModel.shouldShowAddUserButton {
StreamIconButton(role: .primary, style: .solid, size: .small) {
addUsersShown = true
} icon: {
Image(systemName: "person.badge.plus")
}
}
}
}
.navigationBarTitleDisplayMode(.inline)
}
.sheet(item: $selectedParticipant) { participant in
ParticipantInfoView(
factory: factory,
participant: participant,
actions: viewModel.participantActions(for: participant)
) {
selectedParticipant = nil
}
.modifier(PresentationDetentsModifier(sheetSizes: [.custom(280), .medium]))
}
.sheet(isPresented: $addUsersShown) {
factory.makeAddUsersView(
options: AddUsersViewOptions(
options: .init(loadedUserIds: viewModel.allMemberIds),
onConfirm: { users in
viewModel.addUsersTapped(users)
addUsersShown = false
}
)
)
}
}
}

public final class ParticipantInfo: Identifiable {
public var id: String {
chatUser.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public struct ChatChannelInfoView<Factory: ViewFactory>: View, KeyboardReadable
EditGroupView(factory: factory, viewModel: viewModel)
}
.sheet(isPresented: $viewModel.addUsersShown) {
factory.makeAddUsersView(
options: AddUsersViewOptions(
factory.makeMemberAddView(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs reminder

options: MemberAddViewOptions(
Comment thread
martinmitrevski marked this conversation as resolved.
options: .init(loadedUserIds: viewModel.allMemberIds),
onConfirm: viewModel.addUsersTapped(_:)
)
Expand Down Expand Up @@ -216,7 +216,7 @@ public struct ChatChannelInfoView<Factory: ViewFactory>: View, KeyboardReadable

Spacer()

if viewModel.shouldShowAddUserButton {
if viewModel.shouldShowAddMemberButton {
StreamTextButton(role: .secondary, style: .outline, size: .small) {
viewModel.addUsersShown = true
} text: {
Expand Down Expand Up @@ -378,7 +378,7 @@ struct ChatChannelInfoViewHeaderViewModifier: ViewModifier {
Text(L10n.ChatInfo.edit)
.font(fonts.bodyBold)
}
.modifier(LiquidGlassModifier(shape: Capsule(), isInteractive: true))
.modifier(LiquidGlassBorderlessModifier(shape: Capsule(), isInteractive: true))
} else {
StreamTextButton(role: .secondary, style: .outline, size: .medium) {
viewModel.editGroupShown = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import SwiftUI
channel.ownCapabilities.contains(.updateChannel)
}

open var shouldShowAddUserButton: Bool {
open var shouldShowAddMemberButton: Bool {
if channel.isDirectMessageChannel {
false
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ struct MediaAttachmentsGridView<Factory: ViewFactory>: View {
let mediaItems: [MediaItem]?
let showAvatars: Bool
let onItemAppear: ((Int) -> Void)?
let onItemSelected: ((Int) -> Void)?

private let targetItemWidth: CGFloat = 120

Expand All @@ -80,13 +81,15 @@ struct MediaAttachmentsGridView<Factory: ViewFactory>: View {
attachments: [MediaAttachment],
mediaItems: [MediaItem]? = nil,
showAvatars: Bool = true,
onItemAppear: ((Int) -> Void)? = nil
onItemAppear: ((Int) -> Void)? = nil,
onItemSelected: ((Int) -> Void)? = nil
) {
self.factory = factory
self.attachments = attachments
self.mediaItems = mediaItems
self.showAvatars = showAvatars
self.onItemAppear = onItemAppear
self.onItemSelected = onItemSelected
}

public var body: some View {
Expand Down Expand Up @@ -156,6 +159,19 @@ struct MediaAttachmentsGridView<Factory: ViewFactory>: View {
}
}
)
} else if let onItemSelected {
Button {
onItemSelected(index)
} label: {
LazyLoadingImage(
source: attachments[index],
width: itemWidth,
height: itemWidth,
showVideoIcon: false
)
.frame(width: itemWidth, height: itemWidth)
.clipped()
}
Comment thread
nuno-vieira marked this conversation as resolved.
} else {
LazyLoadingImage(
source: attachments[index],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import SwiftUI

/// Full-sheet view for adding members to a channel.
/// Supports search, pagination, and multi-select with a batch confirm action.
public struct AddUsersView<Factory: ViewFactory>: View {
public struct MemberAddView<Factory: ViewFactory>: View {
@Injected(\.colors) private var colors

@Environment(\.presentationMode) private var presentationMode

private let factory: Factory
@StateObject private var viewModel: AddUsersViewModel
@StateObject private var viewModel: MemberAddViewModel
var onConfirm: @MainActor ([ChatUser]) -> Void

public init(
Expand All @@ -22,15 +22,15 @@ public struct AddUsersView<Factory: ViewFactory>: View {
onConfirm: @escaping @MainActor ([ChatUser]) -> Void
) {
_viewModel = StateObject(
wrappedValue: AddUsersViewModel(loadedUserIds: loadedUserIds)
wrappedValue: MemberAddViewModel(loadedUserIds: loadedUserIds)
)
self.onConfirm = onConfirm
self.factory = factory
}

init(
factory: Factory = DefaultViewFactory.shared,
viewModel: AddUsersViewModel,
viewModel: MemberAddViewModel,
onConfirm: @escaping @MainActor ([ChatUser]) -> Void
) {
_viewModel = StateObject(wrappedValue: viewModel)
Expand Down Expand Up @@ -62,7 +62,8 @@ public struct AddUsersView<Factory: ViewFactory>: View {
))
.background(Color(colors.backgroundCoreApp).edgesIgnoringSafeArea(.all))
.modifier(
AddMembersToolbarModifier(
MemberAddToolbarModifier(
factory: factory,
viewModel: viewModel,
onConfirm: { onConfirm(viewModel.selectedUsers) },
onDismiss: { presentationMode.wrappedValue.dismiss() }
Expand All @@ -73,8 +74,8 @@ public struct AddUsersView<Factory: ViewFactory>: View {
}
}

/// Options used in the add users view.
public final class AddUsersOptions: Sendable {
/// Options used in the member add view.
public final class MemberAddOptions: Sendable {
public let loadedUserIds: [String]

public init(loadedUserIds: [String]) {
Expand Down Expand Up @@ -155,54 +156,51 @@ private struct AddMembersUserRow<Factory: ViewFactory>: View {

// MARK: - Toolbar

private struct AddMembersToolbarModifier: ViewModifier {
private struct MemberAddToolbarModifier<Factory: ViewFactory>: ViewModifier {
@Injected(\.colors) private var colors
@Injected(\.fonts) private var fonts
@Injected(\.images) private var images
@Injected(\.tokens) private var tokens

@ObservedObject var viewModel: AddUsersViewModel
let factory: Factory
@ObservedObject var viewModel: MemberAddViewModel
let onConfirm: () -> Void
let onDismiss: () -> Void

func body(content: Content) -> some View {
if #available(iOS 26.0, *) {
content
.toolbarThemed {
toolbarContent()
#if compiler(>=6.2)
.sharedBackgroundVisibility(.hidden)
#endif
}
} else {
content
.toolbarThemed {
toolbarContent()
}
}
content
.toolbarThemed {
toolbarContent()
}
}

@ToolbarContentBuilder private func toolbarContent() -> some ToolbarContent {
ToolbarItem(placement: .navigationBarLeading) {
Button(action: onDismiss) {
Image(systemName: "xmark")
.renderingMode(.template)
.font(.system(size: 12))
.foregroundColor(Color(colors.buttonSecondaryText))
}
}

ToolbarItem(placement: .principal) {
Text(L10n.ChatInfo.Members.addMembersTitle)
.font(fonts.bodyBold)
.foregroundColor(Color(colors.navigationBarTitle))
}
ToolbarItem(placement: .navigationBarLeading) {
Button(action: onDismiss) {
Image(uiImage: images.close)
.foregroundColor(Color(colors.textSecondary))
}

ToolbarItem(placement: .topBarTrailing) {
confirmButton
}
ToolbarItem(placement: .navigationBarTrailing) {
Button(action: onConfirm) {
Image(uiImage: images.selectionBadgeIcon)
.customizable()
.frame(width: tokens.iconSizeSm)
.foregroundColor(Color(colors.buttonPrimaryTextOnAccent))
}
.frame(width: tokens.buttonVisualHeightMd)
.background(Circle().fill(Color(colors.accentPrimary)))
}

private var confirmButton: some View {
Button(action: onConfirm) {
Image(systemName: "checkmark")
.renderingMode(.template)
.font(.system(size: 16))
.foregroundColor(Color(colors.buttonPrimaryTextOnAccent))
}
.modifier(factory.styles.makeToolbarConfirmActionModifier(options: .init()))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import Combine
import StreamChat
import SwiftUI

/// View model for the `AddUsersView`.
@MainActor class AddUsersViewModel: ObservableObject {
/// View model for the `MemberAddView`.
@MainActor class MemberAddViewModel: ObservableObject {
@Injected(\.chatClient) private var chatClient

@Published var users = [ChatUser]()
Expand Down
Loading
Loading