Skip to content

Commit 5d41baa

Browse files
author
ggzgli
committed
Optimize landscape template layout in portrait mode
1 parent fbb9f9f commit 5d41baa

2 files changed

Lines changed: 65 additions & 24 deletions

File tree

live/Sources/Features/AudienceContainer/View/LivingView/AudienceLivingView.swift

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,7 @@ class AudienceLivingView: RTCBaseView {
173173
make.height.equalTo(24.scale375Width())
174174
}
175175

176-
rotateScreenButton.snp.remakeConstraints { make in
177-
make.trailing.equalToSuperview().offset(-10.scale375Width())
178-
make.top.equalToSuperview().offset(475.scale375Height())
179-
make.width.equalTo(32.scale375Width())
180-
make.height.equalTo(32.scale375Width())
181-
}
176+
updateRotateScreenButtonLayout()
182177

183178
#if RTCube_APPSTORE
184179
reportBtn.snp.remakeConstraints { make in
@@ -254,12 +249,7 @@ class AudienceLivingView: RTCBaseView {
254249
make.height.equalTo(24.scale375Width())
255250
}
256251

257-
rotateScreenButton.snp.remakeConstraints { make in
258-
make.trailing.equalToSuperview().offset(-20.scale375Width())
259-
make.top.equalToSuperview().offset(185.scale375Height())
260-
make.width.equalTo(32.scale375Width())
261-
make.height.equalTo(32.scale375Width())
262-
}
252+
updateRotateScreenButtonLayout()
263253

264254
#if RTCube_APPSTORE
265255
reportBtn.snp.remakeConstraints { make in
@@ -341,6 +331,37 @@ class AudienceLivingView: RTCBaseView {
341331
func setGiftPureMode(_ isPureMode: Bool) {
342332
giftDisplayView.onPureModeSet(isPureMode: isPureMode)
343333
}
334+
335+
private func updateRotateScreenButtonLayout() {
336+
if !manager.liveListState.currentLive.isEmpty,
337+
manager.liveListState.currentLive.seatTemplate == .videoLandscape4Seats,
338+
WindowUtils.isPortrait {
339+
let coreViewHeight = Screen_Width * 720 / 1280
340+
rotateScreenButton.snp.remakeConstraints { make in
341+
make.trailing.equalToSuperview().offset(-10.scale375Width())
342+
make.top.equalToSuperview().offset(150 + coreViewHeight - 32.scale375Width() - 8)
343+
make.width.equalTo(32.scale375Width())
344+
make.height.equalTo(32.scale375Width())
345+
}
346+
return
347+
}
348+
349+
if WindowUtils.isPortrait {
350+
rotateScreenButton.snp.remakeConstraints { make in
351+
make.trailing.equalToSuperview().offset(-10.scale375Width())
352+
make.top.equalToSuperview().offset(475.scale375Height())
353+
make.width.equalTo(32.scale375Width())
354+
make.height.equalTo(32.scale375Width())
355+
}
356+
} else {
357+
rotateScreenButton.snp.remakeConstraints { make in
358+
make.trailing.equalToSuperview().offset(-20.scale375Width())
359+
make.top.equalToSuperview().offset(185.scale375Height())
360+
make.width.equalTo(32.scale375Width())
361+
make.height.equalTo(32.scale375Width())
362+
}
363+
}
364+
}
344365
}
345366

346367
extension AudienceLivingView {
@@ -394,6 +415,7 @@ extension AudienceLivingView {
394415
.sink { [weak self] currentLive in
395416
guard let self = self, !currentLive.isEmpty else { return }
396417
barrageDisplayView.setOwnerId(currentLive.liveOwner.userID)
418+
updateRotateScreenButtonLayout()
397419
}
398420
.store(in: &cancellableSet)
399421
}

live/Sources/Features/AudienceContainer/View/LivingView/AudienceView.swift

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
// Created by krabyu on 2023/10/19.
66
//
77

8+
import AtomicX
89
import AtomicXCore
910
import Combine
1011
import Foundation
1112
import RTCCommon
1213
import RTCRoomEngine
1314
import TUICore
14-
import AtomicX
1515

1616
public protocol RotateScreenDelegate: AnyObject {
1717
func rotateScreen(isPortrait: Bool)
@@ -59,15 +59,15 @@ class AudienceView: RTCBaseView {
5959
return button
6060
}()
6161

62+
lazy var blurView = UIVisualEffectView(effect: UIBlurEffect(style: .light))
63+
6264
lazy var coverBgView: UIImageView = {
6365
let imageView = UIImageView(frame: .zero)
64-
let effect = UIBlurEffect(style: .light)
65-
let blurView = UIVisualEffectView(effect: effect)
66+
blurView.isHidden = true
6667
imageView.addSubview(blurView)
6768
blurView.snp.makeConstraints { make in
6869
make.edges.equalToSuperview()
6970
}
70-
imageView.image = internalImage("live_edit_info_default_cover_image")
7171
return imageView
7272
}()
7373

@@ -91,6 +91,7 @@ class AudienceView: RTCBaseView {
9191
super.init(frame: .zero)
9292
videoView.setLiveID(roomId)
9393
videoView.videoViewDelegate = self
94+
backgroundColor = .black
9495
}
9596

9697
@available(*, unavailable)
@@ -117,9 +118,7 @@ class AudienceView: RTCBaseView {
117118
coverBgView.snp.remakeConstraints { make in
118119
make.edges.equalToSuperview()
119120
}
120-
videoView.snp.remakeConstraints { make in
121-
make.edges.equalToSuperview()
122-
}
121+
updateCoreViewLayout()
123122
livingView.snp.remakeConstraints { make in
124123
make.edges.equalToSuperview()
125124
}
@@ -185,12 +184,27 @@ class AudienceView: RTCBaseView {
185184

186185
func relayoutCoreView() {
187186
addSubview(videoView)
188-
videoView.snp.makeConstraints { make in
189-
make.edges.equalToSuperview()
190-
}
187+
updateCoreViewLayout()
191188
sendSubviewToBack(videoView)
192189
sendSubviewToBack(coverBgView)
193190
}
191+
192+
private func updateCoreViewLayout() {
193+
guard !manager.liveListState.currentLive.isEmpty,
194+
manager.liveListState.currentLive.seatTemplate == .videoLandscape4Seats,
195+
WindowUtils.isPortrait
196+
else {
197+
videoView.snp.remakeConstraints { make in
198+
make.edges.equalToSuperview()
199+
}
200+
return
201+
}
202+
videoView.snp.remakeConstraints { make in
203+
make.leading.trailing.equalToSuperview()
204+
make.top.equalToSuperview().offset(150)
205+
make.height.equalTo(Screen_Width * 720 / 1280)
206+
}
207+
}
194208
}
195209

196210
extension AudienceView {
@@ -212,10 +226,15 @@ extension AudienceView {
212226
guard let self = self else { return }
213227
if currentLive.isEmpty {
214228
routeToAudienceView()
215-
} else if !currentLive.backgroundURL.isEmpty {
229+
return
230+
}
231+
updateCoreViewLayout()
232+
if !currentLive.backgroundURL.isEmpty {
216233
coverBgView.kf.setImage(with: URL(string: currentLive.backgroundURL), placeholder: internalImage("live_edit_info_default_cover_image"))
234+
blurView.isHidden = false
217235
} else if !currentLive.coverURL.isEmpty {
218236
coverBgView.kf.setImage(with: URL(string: currentLive.coverURL), placeholder: internalImage("live_edit_info_default_cover_image"))
237+
blurView.isHidden = false
219238
}
220239
}
221240
.store(in: &cancellableSet)
@@ -350,7 +369,7 @@ extension AudienceView {
350369
}
351370

352371
private func onKickedByAdmin() {
353-
manager.toastSubject.send((.kickedOutText,.info))
372+
manager.toastSubject.send((.kickedOutText, .info))
354373
isUserInteractionEnabled = false
355374
DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in
356375
guard let self = self else { return }

0 commit comments

Comments
 (0)