Skip to content

Commit

Permalink
[Redesign] SDK changes (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
ipavlidakis authored Jan 29, 2024
1 parent 6d12617 commit a951508
Show file tree
Hide file tree
Showing 208 changed files with 1,075 additions and 279 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ _December 08, 2023_

### 🔄 Changed
- You can now focus on a desired point in the local video stream. [#221](https://github.com/GetStream/stream-video-swift/pull/221)
- The following API changes occurred as part of the redesign. [#221](https://github.com/GetStream/stream-video-swift/pull/221)
- The following API changes occurred as part of the redesign. [#221](https://github.com/GetStream/stream-video-swift/pull/221) & [#269](https://github.com/GetStream/stream-video-swift/pull/269)
- `CornerDragableView` has been renamed to `CornerDraggableView` and initializer changed.
- `LocalParticipantViewModifier` & `VideoCallParticipantModifier` now accept a few parameters that allow you to further control their presentation.
- `ScreenSharingView` now accepts a `isZoomEnabled` parameter to control if the the view will be zoom-able.
- `LocalVideoView` now accepts a `availableFrame` parameter.
- `OutgoingCallView` now accepts an additional `callTopView` parameter to align with the updated design.
- `CallParticipantsInfoView` and the `ViewFactory.makeParticipantsListView` method aren't accept the `availableFrame` anymore.

# [0.4.1](https://github.com/GetStream/stream-video-swift/releases/tag/0.4.1)
_October 16, 2023_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ fileprivate func content() {
struct CustomView: View {
public var body: some View {
OutgoingCallView(
outgoingCallMembers: outgoingCallMembers,
outgoingCallMembers: outgoingCallMembers,
callTopView: callTopView,
callControls: callControls
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Combine
@MainActor
fileprivate func content() {
container {
let view = CallParticipantsInfoView(callViewModel: viewModel, availableFrame: availableFrame)
let view = CallParticipantsInfoView(callViewModel: viewModel)
}

container {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ struct YourView: View { var body: some View { EmptyView() } }
struct YourHostingView: View { var body: some View { EmptyView() } }
struct YourHostView: View { var body: some View { EmptyView() } }
struct ViewThatHostsCall: View { var body: some View { EmptyView() } }
struct ViewThatHostsCall: View { var body: some View { EmptyView() } }

struct LongPressToFocusViewModifier: ViewModifier {

Expand Down
6 changes: 5 additions & 1 deletion Sources/StreamVideoSwiftUI/CallContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ public struct WaitingLocalUserView<Factory: ViewFactory>: View {
DefaultBackgroundGradient()
.edgesIgnoringSafeArea(.all)

VStack(spacing: 16) {
VStack {
viewFactory.makeCallTopView(viewModel: viewModel)
.opacity(viewModel.callingState == .reconnecting ? 0 : 1)

Group {
if let localParticipant = viewModel.localParticipant {
GeometryReader { proxy in
Expand All @@ -136,6 +139,7 @@ public struct WaitingLocalUserView<Factory: ViewFactory>: View {
}
}
.padding(.horizontal, 8)
.opacity(viewModel.callingState == .reconnecting ? 0 : 1)

viewFactory.makeCallControlsView(viewModel: viewModel)
.opacity(viewModel.callingState == .reconnecting ? 0 : 1)
Expand Down
64 changes: 22 additions & 42 deletions Sources/StreamVideoSwiftUI/CallView/CallControlsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,28 @@ import SwiftUI
public struct CallControlsView: View {

@Injected(\.streamVideo) var streamVideo

private let size: CGFloat = 50
private let cornerRadius: CGFloat = 24
@Injected(\.colors) var colors

@ObservedObject var viewModel: CallViewModel

@Injected(\.images) var images
@Injected(\.colors) var colors


public init(viewModel: CallViewModel) {
self.viewModel = viewModel
}

public var body: some View {
HStack(alignment: .top) {
Spacer()

HStack {
VideoIconView(viewModel: viewModel)

Spacer()

MicrophoneIconView(viewModel: viewModel)

Spacer()

ToggleCameraIconView(viewModel: viewModel)

Spacer()

HangUpIconView(viewModel: viewModel)

Spacer()
if viewModel.callingState == .inCall {
ParticipantsListButton(viewModel: viewModel)
}
}
.padding()
.padding(.horizontal, 16)
.padding(.vertical)
.frame(maxWidth: .infinity)
.cornerRadius(
cornerRadius,
corners: [.topLeft, .topRight],
backgroundColor: colors.callControlsBackground,
extendToSafeArea: true
)
}
}

Expand All @@ -59,7 +40,7 @@ public struct VideoIconView: View {
@ObservedObject var viewModel: CallViewModel
let size: CGFloat

public init(viewModel: CallViewModel, size: CGFloat = 50) {
public init(viewModel: CallViewModel, size: CGFloat = 44) {
self.viewModel = viewModel
self.size = size
}
Expand All @@ -73,7 +54,7 @@ public struct VideoIconView: View {
CallIconView(
icon: (viewModel.callSettings.videoOn ? images.videoTurnOn : images.videoTurnOff),
size: size,
iconStyle: (viewModel.callSettings.videoOn ? .primary : .transparent)
iconStyle: (viewModel.callSettings.videoOn ? .transparent : .disabled)
)
}
)
Expand All @@ -89,7 +70,7 @@ public struct MicrophoneIconView: View {
@ObservedObject var viewModel: CallViewModel
let size: CGFloat

public init(viewModel: CallViewModel, size: CGFloat = 50) {
public init(viewModel: CallViewModel, size: CGFloat = 44) {
self.viewModel = viewModel
self.size = size
}
Expand All @@ -103,7 +84,7 @@ public struct MicrophoneIconView: View {
CallIconView(
icon: (viewModel.callSettings.audioOn ? images.micTurnOn : images.micTurnOff),
size: size,
iconStyle: (viewModel.callSettings.audioOn ? .primary : .transparent)
iconStyle: (viewModel.callSettings.audioOn ? .transparent : .disabled)
)
}
)
Expand All @@ -119,7 +100,7 @@ public struct ToggleCameraIconView: View {
@ObservedObject var viewModel: CallViewModel
let size: CGFloat

public init(viewModel: CallViewModel, size: CGFloat = 50) {
public init(viewModel: CallViewModel, size: CGFloat = 44) {
self.viewModel = viewModel
self.size = size
}
Expand All @@ -133,7 +114,7 @@ public struct ToggleCameraIconView: View {
CallIconView(
icon: images.toggleCamera,
size: size,
iconStyle: .primary
iconStyle: .secondary
)
}
)
Expand All @@ -150,7 +131,7 @@ public struct HangUpIconView: View {
@ObservedObject var viewModel: CallViewModel
let size: CGFloat

public init(viewModel: CallViewModel, size: CGFloat = 50) {
public init(viewModel: CallViewModel, size: CGFloat = 44) {
self.viewModel = viewModel
self.size = size
}
Expand All @@ -159,11 +140,11 @@ public struct HangUpIconView: View {
Button {
viewModel.hangUp()
} label: {
images.hangup
.applyCallButtonStyle(
color: colors.hangUpIconColor,
size: size
)
CallIconView(
icon: images.hangup,
size: size,
iconStyle: .destructive
)
}
.accessibility(identifier: "hangUp")
}
Expand All @@ -176,7 +157,7 @@ public struct AudioOutputIconView: View {
@ObservedObject var viewModel: CallViewModel
let size: CGFloat

public init(viewModel: CallViewModel, size: CGFloat = 50) {
public init(viewModel: CallViewModel, size: CGFloat = 44) {
self.viewModel = viewModel
self.size = size
}
Expand All @@ -195,7 +176,6 @@ public struct AudioOutputIconView: View {
}
)
}

}

public struct SpeakerIconView: View {
Expand All @@ -205,7 +185,7 @@ public struct SpeakerIconView: View {
@ObservedObject var viewModel: CallViewModel
let size: CGFloat

public init(viewModel: CallViewModel, size: CGFloat = 50) {
public init(viewModel: CallViewModel, size: CGFloat = 44) {
self.viewModel = viewModel
self.size = size
}
Expand Down
100 changes: 100 additions & 0 deletions Sources/StreamVideoSwiftUI/CallView/CallDurationView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
//
// Copyright © 2024 Stream.io Inc. All rights reserved.
//

import Foundation
import SwiftUI
import StreamVideo

/// A view that presents the call's duration and recording state.
public struct CallDurationView: View {

@Injected(\.colors) private var colors: Colors
@Injected(\.fonts) private var fonts: Fonts
@Injected(\.images) private var images: Images
@Injected(\.formatters.mediaDuration) private var formatter: MediaDurationFormatter

@State private var duration: TimeInterval
@ObservedObject private var viewModel: CallViewModel

@MainActor
public init(_ viewModel: CallViewModel) {
self.viewModel = viewModel
self.duration = viewModel.call?.state.duration ?? 0
}

public var body: some View {
Group {
if duration > 0, let formattedDuration = formatter.format(duration) {
HStack(spacing: 4) {
iconView
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 12)
.foregroundColor(
viewModel.recordingState == .recording
? colors.inactiveCallControl
: colors.onlineIndicatorColor
)

TimeView(formattedDuration)
.layoutPriority(2)
}
.padding(.horizontal)
.padding(.vertical, 4)
.background(Color(colors.participantBackground))
.clipShape(Capsule())
} else {
EmptyView()
}
}
.onReceive(viewModel.call?.state.$duration) { self.duration = $0 }
.accessibility(identifier: accessibilityLabel)
}

// MARK - Private Helpers

private var iconView: Image {
viewModel.recordingState == .recording
? images.recordIcon
: images.secureCallIcon
}

private var accessibilityLabel: String {
var result = "Call duration: \(duration) seconds."
if viewModel.recordingState == .recording {
result += "Recording in progress."
}

return result
}
}

fileprivate struct TimeView: View {

@Injected(\.fonts) private var fonts: Fonts
@Injected(\.colors) private var colors: Colors

var value: NSMutableAttributedString

fileprivate init(_ value: String) {
let attributed = NSMutableAttributedString(string: value)
self.value = attributed
self.value.addAttribute(.foregroundColor, value: colors.callDurationColor.withAlphaComponent(0.6), range: .init(location: 0, length: attributed.length - 3))
self.value.addAttribute(.foregroundColor, value: colors.callDurationColor, range: .init(location: attributed.length - 3, length: 3))
}

fileprivate var body: some View {
Group {
if #available(iOS 15.0, *) {
Text(AttributedString(value))
} else {
Text(value.string)
.foregroundColor(Color.white.opacity(0.6))
}
}
.font(fonts.bodyBold.monospacedDigit())
.minimumScaleFactor(0.2)
.lineLimit(1)
}
}
64 changes: 33 additions & 31 deletions Sources/StreamVideoSwiftUI/CallView/CallTopView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,43 @@ public struct CallTopView: View {
}

public var body: some View {
HStack {
Button {
withAnimation {
viewModel.isMinimized = true
Group {
HStack(spacing: 0) {
HStack {
if
#available(iOS 14.0, *),
viewModel.callParticipants.count > 1
{
LayoutMenuView(viewModel: viewModel)
.opacity(hideLayoutMenu ? 0 : 1)
.accessibility(identifier: "viewMenu")
}

ToggleCameraIconView(viewModel: viewModel)

Spacer()
}
} label: {
Image(systemName: "chevron.left")
.foregroundColor(colors.textInverted)
.padding()
}
.accessibility(identifier: "minimizeCallViewButton")

if viewModel.recordingState == .recording {
RecordingView()
.accessibility(identifier: "recordingLabel")
}
.frame(maxWidth: .infinity)

Spacer()


if #available(iOS 14, *) {
LayoutMenuView(viewModel: viewModel)
.opacity(hideLayoutMenu ? 0 : 1)
.accessibility(identifier: "viewMenu")

Button {
viewModel.participantsShown.toggle()
} label: {
images.participants
.padding(.horizontal)
.padding(.horizontal, 2)
.foregroundColor(.white)
HStack(alignment: .center) {
if #available(iOS 14.0, *) {
CallDurationView(viewModel)
} else {
EmptyView()
}
}
.frame(height: 44)
.frame(maxWidth: .infinity)

HStack {
Spacer()
HangUpIconView(viewModel: viewModel)
}
.accessibility(identifier: "participantMenu")
.frame(maxWidth: .infinity)
}
.padding(.horizontal, 16)
.padding(.vertical)
.frame(maxWidth: .infinity)
}
.overlay(
viewModel.call?.state.isCurrentUserScreensharing == true ?
Expand Down
Loading

0 comments on commit a951508

Please sign in to comment.