Skip to content

Commit c18db1b

Browse files
authored
Merge branch 'develop' into leave-channel-permissions
2 parents a613d3f + 57726e1 commit c18db1b

25 files changed

+463
-120
lines changed

.github/workflows/testflight.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Test Flight Deploy DemoApp
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- 'main'
7+
8+
release:
9+
types: [published]
10+
11+
workflow_dispatch:
12+
13+
env:
14+
HOMEBREW_NO_INSTALL_CLEANUP: 1
15+
16+
jobs:
17+
deploy:
18+
runs-on: macos-14
19+
steps:
20+
- name: Connect Bot
21+
uses: webfactory/[email protected]
22+
with:
23+
ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }}
24+
- uses: actions/[email protected]
25+
with:
26+
fetch-depth: 0
27+
- uses: ./.github/actions/ruby-cache
28+
- uses: ./.github/actions/xcode-cache
29+
- name: Deploy Demo app
30+
env:
31+
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
32+
APPSTORE_API_KEY: ${{ secrets.APPSTORE_API_KEY }}
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
GITHUB_PR_NUM: ${{ github.event.number }}
35+
run: bundle exec fastlane swiftui_testflight_build
36+
- uses: 8398a7/action-slack@v3
37+
with:
38+
status: ${{ job.status }}
39+
text: "You shall not pass!"
40+
fields: message,commit,author,action,workflow,job,took
41+
env:
42+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
43+
MATRIX_CONTEXT: ${{ toJson(matrix) }}
44+
if: failure()

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
33

44
# Upcoming
55

6-
### 🔄 Changed
6+
### ✅ Added
7+
- Add support for Channel Search in the Channel List [#628](https://github.com/GetStream/stream-chat-swiftui/pull/628)
8+
### 🐞 Fixed
9+
- Fix crash when opening message overlay in iPad with a TabBar [#627](https://github.com/GetStream/stream-chat-swiftui/pull/627)
710

811
# [4.65.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.65.0)
912
_October 18, 2024_

DemoAppSwiftUI/DemoAppSwiftUIApp.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ struct DemoAppSwiftUIApp: App {
1818
var channelListController: ChatChannelListController? {
1919
appState.channelListController
2020
}
21-
21+
22+
var channelListSearchType: ChannelListSearchType {
23+
.messages
24+
}
25+
2226
var body: some Scene {
2327
WindowGroup {
2428
switch appState.userState {
@@ -64,12 +68,14 @@ struct DemoAppSwiftUIApp: App {
6468
ChatChannelListView(
6569
viewFactory: DemoAppFactory.shared,
6670
channelListController: channelListController,
67-
selectedChannelId: notificationsHandler.notificationChannelId
71+
selectedChannelId: notificationsHandler.notificationChannelId,
72+
searchType: channelListSearchType
6873
)
6974
} else {
7075
ChatChannelListView(
7176
viewFactory: DemoAppFactory.shared,
72-
channelListController: channelListController
77+
channelListController: channelListController,
78+
searchType: channelListSearchType
7379
)
7480
}
7581
}

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ GEM
200200
fastlane
201201
pry
202202
fastlane-plugin-sonarcloud_metric_kit (0.2.1)
203-
fastlane-plugin-stream_actions (0.3.70)
203+
fastlane-plugin-stream_actions (0.3.71)
204204
xctest_list (= 1.2.1)
205205
fastlane-plugin-versioning (0.6.0)
206206
ffi (1.17.0)
@@ -427,7 +427,7 @@ DEPENDENCIES
427427
fastlane-plugin-create_xcframework
428428
fastlane-plugin-lizard
429429
fastlane-plugin-sonarcloud_metric_kit
430-
fastlane-plugin-stream_actions (= 0.3.70)
430+
fastlane-plugin-stream_actions (= 0.3.71)
431431
fastlane-plugin-versioning
432432
jazzy
433433
json

Sources/StreamChatSwiftUI/ChatChannel/Gallery/GalleryView.swift

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,20 +153,40 @@ public struct GalleryView: View {
153153
}
154154

155155
struct StreamVideoPlayer: View {
156-
157-
@State var player: AVPlayer
158-
156+
157+
@Injected(\.utils) private var utils
158+
159+
private var fileCDN: FileCDN {
160+
utils.fileCDN
161+
}
162+
163+
let url: URL
164+
165+
@State var avPlayer: AVPlayer?
166+
@State var error: Error?
167+
159168
init(url: URL) {
160-
let player = AVPlayer(url: url)
161-
_player = State(wrappedValue: player)
169+
self.url = url
162170
}
163171

164172
var body: some View {
165-
VideoPlayer(player: player)
166-
.clipped()
167-
.onAppear {
168-
try? AVAudioSession.sharedInstance().setCategory(.playback, options: [])
169-
player.play()
173+
VStack {
174+
if let avPlayer {
175+
VideoPlayer(player: avPlayer)
176+
.clipped()
177+
}
178+
}
179+
.onAppear {
180+
fileCDN.adjustedURL(for: url) { result in
181+
switch result {
182+
case let .success(url):
183+
self.avPlayer = AVPlayer(url: url)
184+
try? AVAudioSession.sharedInstance().setCategory(.playback, options: [])
185+
self.avPlayer?.play()
186+
case let .failure(error):
187+
self.error = error
188+
}
170189
}
190+
}
171191
}
172192
}

Sources/StreamChatSwiftUI/ChatChannel/Gallery/VideoPlayerView.swift

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,18 @@ public struct VideoPlayerView: View {
1212

1313
@Injected(\.fonts) private var fonts
1414
@Injected(\.colors) private var colors
15+
@Injected(\.utils) private var utils
16+
17+
private var fileCDN: FileCDN {
18+
utils.fileCDN
19+
}
1520

1621
let attachment: ChatMessageVideoAttachment
1722
let author: ChatUser
1823
@Binding var isShown: Bool
1924

20-
private let avPlayer: AVPlayer
25+
@State private var avPlayer: AVPlayer?
26+
@State private var error: Error?
2127

2228
public init(
2329
attachment: ChatMessageVideoAttachment,
@@ -26,7 +32,6 @@ public struct VideoPlayerView: View {
2632
) {
2733
self.attachment = attachment
2834
self.author = author
29-
avPlayer = AVPlayer(url: attachment.payload.videoURL)
3035
_isShown = isShown
3136
}
3237

@@ -37,7 +42,9 @@ public struct VideoPlayerView: View {
3742
subtitle: author.onlineText,
3843
isShown: $isShown
3944
)
40-
VideoPlayer(player: avPlayer)
45+
if let avPlayer {
46+
VideoPlayer(player: avPlayer)
47+
}
4148
Spacer()
4249
HStack {
4350
ShareButtonView(content: [attachment.payload.videoURL])
@@ -48,11 +55,19 @@ public struct VideoPlayerView: View {
4855
.foregroundColor(Color(colors.text))
4956
}
5057
.onAppear {
51-
try? AVAudioSession.sharedInstance().setCategory(.playback, options: [])
52-
avPlayer.play()
58+
fileCDN.adjustedURL(for: attachment.payload.videoURL) { result in
59+
switch result {
60+
case let .success(url):
61+
self.avPlayer = AVPlayer(url: url)
62+
try? AVAudioSession.sharedInstance().setCategory(.playback, options: [])
63+
self.avPlayer?.play()
64+
case let .failure(error):
65+
self.error = error
66+
}
67+
}
5368
}
5469
.onDisappear {
55-
avPlayer.replaceCurrentItem(with: nil)
70+
avPlayer?.replaceCurrentItem(with: nil)
5671
}
5772
}
5873
}

Sources/StreamChatSwiftUI/ChatChannel/MessageList/FileAttachmentPreview.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public struct FileAttachmentPreview: View {
1818

1919
var url: URL
2020

21-
@State var adjustedUrl: URL?
21+
@State private var adjustedUrl: URL?
2222
@State private var isLoading = false
2323
@State private var title: String?
2424
@State private var error: Error?

Sources/StreamChatSwiftUI/ChatChannel/Reactions/ReactionsOverlayView.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public struct ReactionsOverlayView<Factory: ViewFactory>: View {
7171
currentSnapshot: currentSnapshot,
7272
popInAnimationInProgress: !popIn
7373
)
74-
.offset(y: spacing > 0 ? screenHeight - currentSnapshot.size.height : 0)
74+
.offset(y: overlayOffsetY)
7575
} else {
7676
Color.gray.opacity(0.4)
7777
}
@@ -290,7 +290,16 @@ public struct ReactionsOverlayView<Factory: ViewFactory>: View {
290290

291291
return originY - spacing
292292
}
293-
293+
294+
private var overlayOffsetY: CGFloat {
295+
if isIPad && UITabBar.appearance().isHidden == false {
296+
// When using iPad with TabBar, this hard coded value makes
297+
// sure that the overlay is in the correct position.
298+
return 20
299+
}
300+
return spacing > 0 ? screenHeight - currentSnapshot.size.height : 0
301+
}
302+
294303
private var spacing: CGFloat {
295304
let divider: CGFloat = isIPad ? 2 : 1
296305
let spacing = (UIScreen.main.bounds.height - screenHeight) / divider

Sources/StreamChatSwiftUI/ChatChannel/Utils/ChatChannelHelpers.swift

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ public struct BottomLeftView<Content: View>: View {
8282

8383
/// Returns the top most view controller.
8484
func topVC() -> UIViewController? {
85+
// TODO: Refactor ReactionsOverlayView to use a background blur, instead of a snapshot.
86+
/// Since the current approach is too error-prone and dependent of the app's hierarchy,
87+
8588
let keyWindow = UIApplication.shared.windows.filter { $0.isKeyWindow }.first
8689

8790
if var topController = keyWindow?.rootViewController {
@@ -92,10 +95,16 @@ func topVC() -> UIViewController? {
9295
if UIDevice.current.userInterfaceIdiom == .pad {
9396
let children = topController.children
9497
if !children.isEmpty {
95-
let splitVC = children[0]
96-
let sideVCs = splitVC.children
97-
if sideVCs.count > 1 {
98-
topController = sideVCs[1]
98+
if let splitVC = children[0] as? UISplitViewController,
99+
let contentVC = splitVC.viewControllers.last {
100+
topController = contentVC
101+
return topController
102+
} else if let tabVC = children[0] as? UITabBarController,
103+
let selectedVC = tabVC.selectedViewController {
104+
// If the selectedVC is split view, we need to grab the content view of it
105+
// other wise, the selectedVC is already the content view.
106+
let selectedContentVC = selectedVC.children.first?.children.last?.children.first
107+
topController = selectedContentVC ?? selectedVC
99108
return topController
100109
}
101110
}

Sources/StreamChatSwiftUI/ChatChannelList/ChannelHeaderLoader.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ open class ChannelHeaderLoader: ObservableObject {
8282
}
8383
}
8484

85-
func channelAvatarChanged(_ cid: ChannelId?) -> AnyPublisher<Void, Never> {
85+
open func channelAvatarChanged(_ cid: ChannelId?) -> AnyPublisher<Void, Never> {
8686
didLoadImage
8787
.filter { $0 == cid }
8888
.map { _ in () }

0 commit comments

Comments
 (0)