Skip to content

Update for v2 #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Feb 26, 2024
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
8 changes: 7 additions & 1 deletion .github/workflows/testing-matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ name: Testing Matrix
on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
run_all_tests:
Expand All @@ -16,7 +22,7 @@ jobs:
runs-on: macos-13

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: maxim-lobanov/setup-xcode@v1
with:
Expand Down
11 changes: 7 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
// swift-tools-version:5.7
// (Xcode14.0+)

import PackageDescription

Expand All @@ -8,6 +8,7 @@ let package = Package(
platforms: [
.iOS(.v14),
.macOS(.v11),
.macCatalyst(.v14),
],
products: [
.library(
Expand All @@ -16,13 +17,15 @@ let package = Package(
),
],
dependencies: [
.package(name: "LiveKit", url: "https://github.com/livekit/client-sdk-swift.git", .exact("1.0.13")),
.package(url: "https://github.com/livekit/client-sdk-swift.git", exact: "2.0.4"),
.package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.3.0"),
],
targets: [
.target(
name: "LiveKitComponents",
dependencies: ["LiveKit"],
dependencies: [
.product(name: "LiveKit", package: "client-sdk-swift"),
],
path: "Sources"
),
.testTarget(
Expand Down
5 changes: 1 addition & 4 deletions Sources/LiveKitComponents/Components.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
import LiveKit
import SwiftUI

// Scope for Components framework
enum LiveKitComponents {
public static let version = "0.0.1"
}
public let liveKitComponentsVersion = "0.0.1"

public typealias ComponentBuilder<Content: View> = () -> Content
public typealias ParticipantComponentBuilder<Content: View> = (_: Participant) -> Content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public struct ForEachTrackPublication<Content: View>: View {
}

private func computedTrackPublications() -> [TrackPublication] {
let trackPublications = Array(participant.tracks.values)
let trackPublications = Array(participant.trackPublications.values)
switch filter {
case .all: return trackPublications
case .video: return trackPublications.filter { $0.kind == .video }
Expand Down
2 changes: 1 addition & 1 deletion Sources/LiveKitComponents/Prebuilt/ConnectView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public struct ConnectView: View {
} label: {
Text("Connect")
}
.disabled(!room.connectionState.isDisconnected)
.disabled(room.connectionState != .disconnected)
}
}
}
Expand Down
12 changes: 5 additions & 7 deletions Sources/LiveKitComponents/Prebuilt/VideoConferenceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
* limitations under the License.
*/

import LiveKit
import SwiftUI

public struct VideoConferenceView: View {
@EnvironmentObject var ui: UIPreference
@EnvironmentObject var room: Room

public init() {}

Expand Down Expand Up @@ -48,14 +50,10 @@ public struct VideoConferenceView: View {
}

public var body: some View {
ConnectionStateBuilder { _ in
buildNotConnectedView()
} connecting: {
buildNotConnectedView()
} reconnecting: {
buildConnectedView()
} connected: {
if [.reconnecting, .connected].contains(room.connectionState) {
buildConnectedView()
} else {
buildNotConnectedView()
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import LiveKit
import SwiftUI

extension GeometryProxy {
public var isTall: Bool {
public extension GeometryProxy {
var isTall: Bool {
size.height > size.width
}

Expand Down
10 changes: 3 additions & 7 deletions Sources/LiveKitComponents/Support/HorVGrid.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,10 @@ public struct HorVGrid<Content: View>: View {

public var body: some View {
Group {
if #available(macOS 11.0, *) {
if axis == .vertical {
LazyVGrid(columns: [GridItem(.flexible())], spacing: spacing, content: content)
} else {
LazyHGrid(rows: [GridItem(.flexible())], spacing: spacing, content: content)
}
if axis == .vertical {
LazyVGrid(columns: [GridItem(.flexible())], spacing: spacing, content: content)
} else {
// Fallback on earlier versions
LazyHGrid(rows: [GridItem(.flexible())], spacing: spacing, content: content)
}
}
}
Expand Down
13 changes: 5 additions & 8 deletions Sources/LiveKitComponents/UIPreference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,12 @@ open class UIPreference: ObservableObject {
}

func connectionQualityIndicatorBuilder(connectionQuality: ConnectionQuality) -> some View {
if connectionQuality == .excellent {
return Image(systemName: "wifi")
.foregroundColor(.green)
} else if connectionQuality == .good {
return Image(systemName: "wifi")
.foregroundColor(Color.orange)
if case .excellent = connectionQuality {
return Image(systemName: "wifi").foregroundColor(.green)
} else if case .good = connectionQuality {
return Image(systemName: "wifi").foregroundColor(Color.orange)
}

return Image(systemName: "wifi.exclamationmark")
.foregroundColor(Color.red)
return Image(systemName: "wifi.exclamationmark").foregroundColor(Color.red)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ public struct ParticipantInformationView: View {

public var body: some View {
HStack(spacing: ui.paddingSmall) {
Text(participant.identity ?? "")
.fontWeight(.bold)
if let identity = participant.identity {
Text(String(describing: identity))
.fontWeight(.bold)
}

if let audio = participant.firstAudioPublication {
TrackPublicationStateBuilder {
if audio.isSubscribed, !audio.isMuted {
ui.micEnabledView()
} off: {
} else {
ui.micDisabledView()
}.environmentObject(audio)
}
} else {
ui.micDisabledView()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,21 @@ public struct VideoTrackPublicationView: View {
@EnvironmentObject var trackPublication: TrackPublication
@EnvironmentObject var ui: UIPreference

var layoutMode: VideoView.LayoutMode = .fill
var mirrorMode: VideoView.MirrorMode = .auto

public var body: some View {
GeometryReader { geometry in

ZStack {
ui.videoDisabledView(geometry: geometry)

if let track = trackPublication.track as? VideoTrack,
trackPublication.subscribed,
!trackPublication.muted
trackPublication.isSubscribed,
!trackPublication.isMuted
{
SwiftUIVideoView(track
// layoutMode: appCtx.videoViewMode,
// mirrorMode: appCtx.videoViewMirrored ? .mirror : .auto,
// debugMode: false, // appCtx.showInformationOverlay,
// isRendering: $isRendering,
// dimensions: $dimensions,
// trackStats: $videoTrackStats
)
SwiftUIVideoView(track,
layoutMode: layoutMode,
mirrorMode: mirrorMode)
}
}
}
Expand Down