Skip to content

Commit

Permalink
Fix swift6
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanov91 committed Nov 10, 2024
1 parent 6c1edab commit 437c040
Show file tree
Hide file tree
Showing 19 changed files with 197 additions and 186 deletions.
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PackageDescription
let productionDependencies: [PackageDescription.Package.Dependency] = [
.package(url: "https://github.com/oversizedev/OversizeUI.git", .upToNextMajor(from: "3.0.2")),
.package(url: "https://github.com/oversizedev/OversizeCore.git", .upToNextMajor(from: "1.3.0")),
.package(url: "https://github.com/oversizedev/OversizeLocalizable.git", .upToNextMajor(from: "1.4.0")),
.package(url: "https://github.com/oversizedev/OversizeLocalizable.git", .upToNextMajor(from: "1.5.0")),
.package(url: "https://github.com/lorenzofiamingo/swiftui-cached-async-image.git", .upToNextMajor(from: "2.1.1")),
]

Expand All @@ -22,7 +22,7 @@ let package = Package(
defaultLocalization: "en",
platforms: [
.iOS(.v15),
.macOS(.v13),
.macOS(.v14),
.tvOS(.v16),
.watchOS(.v9),
],
Expand All @@ -32,7 +32,7 @@ let package = Package(
.library(name: "OversizeHealthComponents", targets: ["OversizeHealthComponents"]),
.library(name: "OversizeWeatherComponents", targets: ["OversizeWeatherComponents"]),
],
dependencies: developmentDependencies,
dependencies: productionDependencies,
targets: [
.target(
name: "OversizeComponents",
Expand Down
4 changes: 2 additions & 2 deletions Sources/OversizeComponents/FieldScreen/FieldScreenView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public struct FieldScreenView: View {

TextField(placeholder, text: $text)
.largeTitle()
.foregroundColor(.onSurfaceHighEmphasis)
.foregroundColor(.onSurfacePrimary)
.multilineTextAlignment(.center)
.focused($isFocused)

Expand All @@ -71,7 +71,7 @@ public struct FieldScreenView: View {
if helperText != "" {
Text(helperText)
.subheadline()
.foregroundColor(.onSurfaceMediumEmphasis)
.foregroundColor(.onSurfaceSecondary)
}

Spacer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public struct FloatingTabBar<Content: View>: View {
} label: {
tabItem.icon
.renderingMode(.template)
.foregroundColor(index == selection ? Color.onSurfaceHighEmphasis : Color.onSurfaceMediumEmphasis)
.foregroundColor(index == selection ? Color.onSurfacePrimary : Color.onSurfaceSecondary)
}
.buttonStyle(ScaleRoundButtonStyle())

Expand All @@ -92,7 +92,7 @@ public struct FloatingTabBar<Content: View>: View {
} label: {
tabItem.icon
.renderingMode(.template)
.foregroundColor(index == selection ? Color.onSurfaceHighEmphasis : Color.onSurfaceMediumEmphasis)
.foregroundColor(index == selection ? Color.onSurfacePrimary : Color.onSurfaceSecondary)
}
.buttonStyle(ScaleRoundButtonStyle())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ import SwiftUI
HStack(spacing: .xxSmall) {
Text(label)
.headline()
.foregroundColor(.onSurfaceHighEmphasis)
.foregroundColor(.onSurfacePrimary)
}
Spacer()
if let imageName = selection {
Image(imageName, bundle: .main)
}
OversizeUI.IconDeprecated(.chevronDown, color: .onSurfaceHighEmphasis)
OversizeUI.IconDeprecated(.chevronDown, color: .onSurfacePrimary)
}
.frame(minWidth: 0, maxWidth: .infinity)
.padding()
Expand Down
10 changes: 5 additions & 5 deletions Sources/OversizeComponents/LocationPicker/LocationPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ import SwiftUI
Text(label)
.bold()
.headline()
.foregroundColor(.onSurfaceHighEmphasis)
.foregroundColor(.onSurfacePrimary)
}
Spacer()

if let positionName {
Text(positionName)
.subheadline()
.foregroundColor(.onPrimaryMediumEmphasis)
.foregroundColor(.onPrimarySecondary)
}

IconDeprecated(.chevronDown, color: .onSurfaceHighEmphasis)
IconDeprecated(.chevronDown, color: .onSurfacePrimary)
}
.frame(minWidth: 0, maxWidth: .infinity)
.padding()
Expand Down Expand Up @@ -83,11 +83,11 @@ import SwiftUI
if let positionName {
Text(positionName)
.title3()
.foregroundColor(.onSurfaceHighEmphasis)
.foregroundColor(.onSurfacePrimary)
}
Text("\(coordinates.latitude), \(coordinates.longitude)")
.subheadline()
.foregroundColor(.onSurfaceMediumEmphasis)
.foregroundColor(.onSurfaceSecondary)
}
}
.surfaceContentMargins(.small)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ import SwiftUI
if let positionName {
Text(positionName)
.title3()
.foregroundColor(.onSurfaceHighEmphasis)
.foregroundColor(.onSurfacePrimary)
}
Text("\(coordinates.latitude), \(coordinates.longitude)")
.subheadline()
.foregroundColor(.onSurfaceMediumEmphasis)
.foregroundColor(.onSurfaceSecondary)
}
}
.surfaceContentMargins(.small)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public struct RatingPickerView: View {

Image.Base.Star.fill
.renderingMode(.template)
.foregroundColor(rating ?? 0 >= Double(score) ? .warning : .onSurfaceDisabled)
.foregroundColor(rating ?? 0 >= Double(score) ? .warning : .onSurfaceTertiary)

Spacer()
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/OversizeComponents/ScreenMockup/ScreenMockup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public struct ScreenMockup: View {
} placeholder: {
ZStack {
RoundedRectangle(cornerRadius: 28, style: .continuous)
.fillOnPrimaryDisabled()
.fillOnPrimaryTertiary()

ProgressView()
}
Expand All @@ -37,7 +37,7 @@ public struct ScreenMockup: View {

} placeholder: {
RoundedRectangle(cornerRadius: 28, style: .continuous)
.fillOnPrimaryDisabled()
.fillOnPrimaryTertiary()
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions Sources/OversizeHealthComponents/BMIView/BMIHelpView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,22 @@ struct BMIHelpView: View {
VStack(spacing: .xxSmall) {
Text(bmi.toStringWithoutPoint)
.font(.system(size: 70, weight: .heavy, design: .rounded))
.foregroundColor(.onBackgroundHighEmphasis)
.foregroundColor(.onBackgroundPrimary)
}
}

var textInfoView: some View {
VStack(spacing: .xxSmall) {
Text("Body mass index is a value\nderived from the mass and height")
.headline()
.foregroundColor(.onBackgroundMediumEmphasis)
.foregroundColor(.onBackgroundSecondary)
.multilineTextAlignment(.center)
}
}

var infoListView: some View {
VStack(spacing: 2) {
bmiRow(value: "16.0", title: "Underweight", description: "Severe thinness", color: .blue, icon: IconDeprecated(.chevronLeft, color: .onPrimaryHighEmphasis))
bmiRow(value: "16.0", title: "Underweight", description: "Severe thinness", color: .blue, icon: IconDeprecated(.chevronLeft, color: .onPrimary))

bmiRow(value: "16.0–16.9", title: "Underweight", description: "Moderate thinness", color: .cyan)

Expand All @@ -138,7 +138,7 @@ struct BMIHelpView: View {

bmiRow(value: "35.0–39.9", title: "Obese", description: "Class II", color: .orange)

bmiRow(value: "40", title: "Obese", description: "Class III", color: .red, icon: IconDeprecated(.chevronRight, color: .onPrimaryHighEmphasis))
bmiRow(value: "40", title: "Obese", description: "Class III", color: .red, icon: IconDeprecated(.chevronRight, color: .onPrimary))
}
}

Expand All @@ -149,7 +149,7 @@ struct BMIHelpView: View {
icon
}
Text(value)
.foregroundColor(.onPrimaryHighEmphasis)
.foregroundColor(.onPrimary)
.font(.system(size: 17, weight: .bold, design: .rounded))
.padding(.vertical, .xSmall)
.padding(.trailing, icon != nil ? 8 : 0)
Expand All @@ -163,12 +163,12 @@ struct BMIHelpView: View {
VStack(alignment: .leading, spacing: .xxxSmall) {
Text(title)
.callout(true)
.foregroundColor(.onSurfaceHighEmphasis)
.foregroundColor(.onSurfacePrimary)

if !description.isEmpty {
Text(description)
.subheadline()
.foregroundColor(.onSurfaceMediumEmphasis)
.foregroundColor(.onSurfaceSecondary)
}
}

Expand Down
6 changes: 3 additions & 3 deletions Sources/OversizeHealthComponents/BMIView/BMIView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ public struct BMIView: View {
VStack(spacing: .xxSmall) {
Text(bmi.toStringWithoutPoint)
.font(.system(size: 70, weight: .heavy, design: .rounded))
.foregroundColor(.onBackgroundHighEmphasis)
.foregroundColor(.onBackgroundPrimary)

HStack(spacing: .xxxSmall) {
Text("Body mass index")
.headline()
.foregroundColor(.onBackgroundMediumEmphasis)
.foregroundColor(.onBackgroundSecondary)

Button { isShowHelp.toggle() } label: {
IconDeprecated(.helpCircle, size: .medium, color: .onBackgroundDisabled)
IconDeprecated(.helpCircle, size: .medium, color: .onBackgroundTertiary)
}
}
.unredacted()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import SwiftUI
Image.Base.Camera.fill
.renderingMode(.template)
.resizable()
.foregroundColor(Color.onSurfaceMediumEmphasis)
.foregroundColor(Color.onSurfaceSecondary)
.frame(width: 48, height: 48)
}
}
Expand Down
130 changes: 65 additions & 65 deletions Sources/OversizePhotoComponents/Camera/CameraController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,82 +5,82 @@

import AVFoundation
#if canImport(UIKit)
import UIKit
import UIKit
#endif

#if os(iOS)
@MainActor
class CameraController: NSObject {
private var captureSession: AVCaptureSession?
private var frontCamera: AVCaptureDevice?
private var frontCameraInput: AVCaptureDeviceInput?
private var previewLayer: AVCaptureVideoPreviewLayer?
@MainActor
class CameraController: NSObject {
private var captureSession: AVCaptureSession?
private var frontCamera: AVCaptureDevice?
private var frontCameraInput: AVCaptureDeviceInput?
private var previewLayer: AVCaptureVideoPreviewLayer?

func prepare(completionHandler: @escaping (Error?) -> Void) {
func createCaptureSession() {
captureSession = AVCaptureSession()
}

func configureCaptureDevices() throws {
guard let camera = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .front) else {
throw CameraControllerError.noCamerasAvailable
func prepare(completionHandler: @escaping (Error?) -> Void) {
func createCaptureSession() {
captureSession = AVCaptureSession()
}
frontCamera = camera
try camera.lockForConfiguration()
camera.unlockForConfiguration()
}

func configureDeviceInputs() throws {
guard let captureSession = captureSession else {
throw CameraControllerError.captureSessionIsMissing

func configureCaptureDevices() throws {
guard let camera = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .front) else {
throw CameraControllerError.noCamerasAvailable
}
frontCamera = camera
try camera.lockForConfiguration()
camera.unlockForConfiguration()
}
guard let frontCamera = frontCamera else {
throw CameraControllerError.noCamerasAvailable

func configureDeviceInputs() throws {
guard let captureSession else {
throw CameraControllerError.captureSessionIsMissing
}
guard let frontCamera else {
throw CameraControllerError.noCamerasAvailable
}

frontCameraInput = try AVCaptureDeviceInput(device: frontCamera)
if captureSession.canAddInput(frontCameraInput!) {
captureSession.addInput(frontCameraInput!)
} else {
throw CameraControllerError.inputsAreInvalid
}

captureSession.startRunning()
}

frontCameraInput = try AVCaptureDeviceInput(device: frontCamera)
if captureSession.canAddInput(frontCameraInput!) {
captureSession.addInput(frontCameraInput!)
} else {
throw CameraControllerError.inputsAreInvalid

Task {
do {
createCaptureSession()
try configureCaptureDevices()
try configureDeviceInputs()
completionHandler(nil)
} catch {
completionHandler(error)
}
}

captureSession.startRunning()
}

Task {
do {
createCaptureSession()
try configureCaptureDevices()
try configureDeviceInputs()
completionHandler(nil)
} catch {
completionHandler(error)

@MainActor
func displayPreview(on view: UIView) throws {
guard let captureSession, captureSession.isRunning else {
throw CameraControllerError.captureSessionIsMissing
}

previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
previewLayer?.videoGravity = .resizeAspectFill
previewLayer?.connection?.videoOrientation = .portrait

view.layer.insertSublayer(previewLayer!, at: 0)
previewLayer?.frame = view.bounds
}
}

@MainActor
func displayPreview(on view: UIView) throws {
guard let captureSession = captureSession, captureSession.isRunning else {
throw CameraControllerError.captureSessionIsMissing
}

previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
previewLayer?.videoGravity = .resizeAspectFill
previewLayer?.connection?.videoOrientation = .portrait

view.layer.insertSublayer(previewLayer!, at: 0)
previewLayer?.frame = view.bounds
}
}

enum CameraControllerError: Swift.Error {
case captureSessionAlreadyRunning
case captureSessionIsMissing
case inputsAreInvalid
case invalidOperation
case noCamerasAvailable
case unknown
}
enum CameraControllerError: Swift.Error {
case captureSessionAlreadyRunning
case captureSessionIsMissing
case inputsAreInvalid
case invalidOperation
case noCamerasAvailable
case unknown
}
#endif
Loading

0 comments on commit 437c040

Please sign in to comment.