Skip to content

Commit

Permalink
[Fix]Various bug fixes (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
ipavlidakis authored Dec 11, 2023
1 parent a586b0c commit 7acd202
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Sources/StreamVideoSwiftUI/CallView/CallView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public struct CallView<Factory: ViewFactory>: View {

@ViewBuilder
private func contentView(_ availableFrame: CGRect) -> some View {
if viewModel.localVideoPrimary {
if viewModel.localVideoPrimary, viewModel.participantsLayout == .grid {
localVideoView(bounds: availableFrame)
.accessibility(identifier: "localVideoView")
} else if
Expand Down
13 changes: 12 additions & 1 deletion Sources/StreamVideoSwiftUI/CallView/CornerDraggableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,18 @@ public struct CornerDraggableView<Content: View>: View {

public var body: some View {
content(availableFrame)
.onTapGesture { onTap() }
.overlay(
// SwiftUI seems to remove any interaction of views that not
// getting rendered (e.g. an empty GeometryReader, a VStack
// with a Spacer, an EmptyView, a Color.clear or a Shape
// with clear fill). If we use a simple button here then the
// interaction happening is slower because than what we have now.
Color.black.opacity(0.01)
// This is to avoid conflicts with buttons on the top and bottom
// part of the participant view.
.padding(.vertical, 30)
.onTapGesture { onTap() }
)
.gesture(
DragGesture(coordinateSpace: .global)
.onChanged {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public struct LocalParticipantViewModifier: ViewModifier {
ParticipantMicrophoneCheckView(
audioLevels: microphoneChecker.audioLevels,
microphoneOn: callSettings.audioOn,
isSilent: microphoneChecker.isSilent
isSilent: microphoneChecker.isSilent,
isPinned: localParticipant.isPinned
)

if showAllInfo {
Expand Down Expand Up @@ -107,7 +108,8 @@ public struct LocalParticipantViewModifier_iOS13: ViewModifier {
ParticipantMicrophoneCheckView(
audioLevels: microphoneChecker.audioLevels,
microphoneOn: callSettings.audioOn,
isSilent: microphoneChecker.isSilent
isSilent: microphoneChecker.isSilent,
isPinned: localParticipant.isPinned
)

if showAllInfo {
Expand Down Expand Up @@ -148,12 +150,14 @@ internal struct ParticipantMicrophoneCheckView: View {
var audioLevels: [Float]
var microphoneOn: Bool
var isSilent: Bool
var isPinned: Bool

var body: some View {
MicrophoneCheckView(
audioLevels: audioLevels,
microphoneOn: microphoneOn,
isSilent: isSilent
isSilent: isSilent,
isPinned: isPinned
)
.accessibility(identifier: "microphoneCheckView")
}
Expand Down
12 changes: 12 additions & 0 deletions Sources/StreamVideoSwiftUI/CallingViews/MicrophoneCheckView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,34 @@ public struct MicrophoneCheckView: View {
var audioLevels: [Float]
var microphoneOn: Bool
var isSilent: Bool
var isPinned: Bool
var maxHeight: Float = 14

public init(
audioLevels: [Float],
microphoneOn: Bool,
isSilent: Bool,
isPinned: Bool,
maxHeight: Float = 14
) {
self.audioLevels = audioLevels
self.microphoneOn = microphoneOn
self.isSilent = isSilent
self.isPinned = isPinned
self.maxHeight = maxHeight
}

public var body: some View {
HStack(spacing: 4) {
if isPinned {
Image(systemName: "pin.fill")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(maxHeight: CGFloat(maxHeight))
.foregroundColor(.white)
.padding(.trailing, 4)
}

Text(streamVideo.user.name)
.foregroundColor(.white)
.multilineTextAlignment(.leading)
Expand Down
3 changes: 2 additions & 1 deletion Sources/StreamVideoSwiftUI/CallingViews/PreJoiningView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ struct CameraCheckView: View {
MicrophoneCheckView(
audioLevels: microphoneChecker.audioLevels,
microphoneOn: callSettings.audioOn,
isSilent: microphoneChecker.isSilent
isSilent: microphoneChecker.isSilent,
isPinned: false
)
.accessibility(identifier: "microphoneCheckView")
Spacer()
Expand Down
8 changes: 4 additions & 4 deletions StreamVideo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
40F446022A9E2C23004BE3DA /* DemoCallView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40F446012A9E2C23004BE3DA /* DemoCallView.swift */; };
40F446042A9E2C78004BE3DA /* MicrophoneChecker+MicrophoneChecking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40F446032A9E2C78004BE3DA /* MicrophoneChecker+MicrophoneChecking.swift */; };
40F446062A9E2CB8004BE3DA /* CallViewModel+CallSettingsPublisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40F446052A9E2CB8004BE3DA /* CallViewModel+CallSettingsPublisher.swift */; };
40FAF3D12B0F8305003F8029 /* ParticipantStatsModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40FAF3D02B0F8305003F8029 /* ParticipantStatsModifier.swift */; };
40FAF3D12B0F8305003F8029 /* DemoVideoCallParticipantOptionsModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40FAF3D02B0F8305003F8029 /* DemoVideoCallParticipantOptionsModifier.swift */; };
40FAF3D32B10F611003F8029 /* UIDevice+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40FAF3D22B10F611003F8029 /* UIDevice+Convenience.swift */; };
40FBEF492AC30343007CFF17 /* Safari.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40FBEF482AC30343007CFF17 /* Safari.swift */; };
40FBEF4B2AC30371007CFF17 /* XCUIApplication+KeyboardIntroduction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40FBEF4A2AC30371007CFF17 /* XCUIApplication+KeyboardIntroduction.swift */; };
Expand Down Expand Up @@ -1063,7 +1063,7 @@
40F446012A9E2C23004BE3DA /* DemoCallView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoCallView.swift; sourceTree = "<group>"; };
40F446032A9E2C78004BE3DA /* MicrophoneChecker+MicrophoneChecking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MicrophoneChecker+MicrophoneChecking.swift"; sourceTree = "<group>"; };
40F446052A9E2CB8004BE3DA /* CallViewModel+CallSettingsPublisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CallViewModel+CallSettingsPublisher.swift"; sourceTree = "<group>"; };
40FAF3D02B0F8305003F8029 /* ParticipantStatsModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParticipantStatsModifier.swift; sourceTree = "<group>"; };
40FAF3D02B0F8305003F8029 /* DemoVideoCallParticipantOptionsModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoVideoCallParticipantOptionsModifier.swift; sourceTree = "<group>"; };
40FAF3D22B10F611003F8029 /* UIDevice+Convenience.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIDevice+Convenience.swift"; sourceTree = "<group>"; };
40FBEF482AC30343007CFF17 /* Safari.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Safari.swift; sourceTree = "<group>"; };
40FBEF4A2AC30371007CFF17 /* XCUIApplication+KeyboardIntroduction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCUIApplication+KeyboardIntroduction.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2754,7 +2754,7 @@
8430FD1B2AB07FAA007AA3E6 /* ParticipantStatsView.swift */,
8430FD1D2AB085D9007AA3E6 /* ParticipantStatsViewModel.swift */,
8430FD1F2AB0B0B6007AA3E6 /* RawStatsView.swift */,
40FAF3D02B0F8305003F8029 /* ParticipantStatsModifier.swift */,
40FAF3D02B0F8305003F8029 /* DemoVideoCallParticipantOptionsModifier.swift */,
);
path = Stats;
sourceTree = "<group>";
Expand Down Expand Up @@ -4212,7 +4212,7 @@
40F445DB2A9E2276004BE3DA /* DemoCallContentView.swift in Sources */,
820BD5F72A72C851003A7B8F /* TokenGenerator.swift in Sources */,
40F446022A9E2C23004BE3DA /* DemoCallView.swift in Sources */,
40FAF3D12B0F8305003F8029 /* ParticipantStatsModifier.swift in Sources */,
40FAF3D12B0F8305003F8029 /* DemoVideoCallParticipantOptionsModifier.swift in Sources */,
4030E5A22A9DF6B6003E8CBA /* Router.swift in Sources */,
847B47B52A249E7E000714CE /* Examples.swift in Sources */,
40F445F72A9E2AAC004BE3DA /* ReactionsViewModifier.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ final class MicrophoneCheckView_Tests: StreamVideoUITestCase {
let view = MicrophoneCheckView(
audioLevels: (0..<count).map { 0.2 * Float($0) },
microphoneOn: true,
isSilent: false
isSilent: false,
isPinned: false
)
.frame(width: 100, height: 50)
AssertSnapshot(
Expand All @@ -32,7 +33,8 @@ final class MicrophoneCheckView_Tests: StreamVideoUITestCase {
let view = MicrophoneCheckView(
audioLevels: [],
microphoneOn: true,
isSilent: true
isSilent: true,
isPinned: false
)
.frame(width: 100, height: 50)
AssertSnapshot(
Expand All @@ -46,7 +48,23 @@ final class MicrophoneCheckView_Tests: StreamVideoUITestCase {
let view = MicrophoneCheckView(
audioLevels: [],
microphoneOn: false,
isSilent: false
isSilent: false,
isPinned: false
)
.frame(width: 100, height: 50)
AssertSnapshot(
view,
variants: [.defaultLight],
size: sizeThatFits
)
}

func test_microphoneCheckView_pinned_snapshot() throws {
let view = MicrophoneCheckView(
audioLevels: [],
microphoneOn: false,
isSilent: false,
isPinned: true
)
.frame(width: 100, height: 50)
AssertSnapshot(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7acd202

Please sign in to comment.