Skip to content

Commit

Permalink
Fix tvOS errors
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanov91 committed May 18, 2024
1 parent 754506e commit 502b879
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 55 deletions.
2 changes: 1 addition & 1 deletion AppExample/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@
repositoryURL = "https://github.com/hmlongco/Factory";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.2.0;
minimumVersion = 2.1.3;
};
};
845A59312BA4FD2B00988D52 /* XCRemoteSwiftPackageReference "OversizeModels" */ = {
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ let package = Package(
platforms: [
.iOS(.v16),
.macOS(.v13),
.tvOS(.v15),
.tvOS(.v16),
.watchOS(.v9),
],
products: [
Expand Down
4 changes: 3 additions & 1 deletion Sources/OversizeKit/AdsKit/AdView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ public struct AdView: View {
}
.buttonStyle(.tertiary)
.controlBorderShape(.capsule)
.controlSize(.small)
.padding(.trailing, .xxxSmall)
.loading(isShowProduct)
#if !os(tvOS)
.controlSize(.small)
#endif
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions Sources/OversizeKit/LauncherKit/RateAppScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ struct RateAppScreen: View {
}
.controlBorderShape(.capsule)
.elevation(.z3)
.controlSize(.large)
#if !os(tvOS)
.controlSize(.large)
#endif
}
}
.multilineTextAlignment(.center)
Expand All @@ -68,9 +70,11 @@ struct RateAppScreen: View {
IconDeprecated(.xMini, color: .onSurfaceHighEmphasis)
}
.buttonStyle(.tertiary(infinityWidth: false))
.controlSize(.mini)
.controlBorderShape(.capsule)
.padding(.medium)
#if !os(tvOS)
.controlSize(.mini)
#endif
}
// reviewService.rewiewBunnerClosed()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public class StoreViewModel: ObservableObject {
}

@Injected(\.storeKitService) var storeKitService: StoreKitService
@Injected(\.localNotificationService) var localNotificationService: LocalNotificationServiceProtocol
#if !os(tvOS)
@Injected(\.localNotificationService) var localNotificationService: LocalNotificationServiceProtocol
#endif

@Published var state = State.initial

Expand Down Expand Up @@ -303,23 +305,25 @@ extension StoreViewModel {
}

func addTrialNotification(product: Product) async {
if product.type == .autoRenewable, product.subscription?.introductoryOffer != nil {
do {
try await localNotificationService.requestAuthorization()
if let trialDaysCount = product.trialDaysCount {
let timeInterval = TimeInterval((trialDaysCount - 2) * 24 * 60 * 60)
let notificationTime = Date().addingTimeInterval(timeInterval)
let dateComponents = Calendar.current.dateComponents([.year, .month, .day, .hour, .minute], from: notificationTime)
await localNotificationService.schedule(localNotification: .init(
id: UUID(),
title: "Trial ends soon",
body: "Subscription ends in 2 days",
dateComponents: dateComponents,
repeats: false
))
}
} catch {}
}
#if !os(tvOS)
if product.type == .autoRenewable, product.subscription?.introductoryOffer != nil {
do {
try await localNotificationService.requestAuthorization()
if let trialDaysCount = product.trialDaysCount {
let timeInterval = TimeInterval((trialDaysCount - 2) * 24 * 60 * 60)
let notificationTime = Date().addingTimeInterval(timeInterval)
let dateComponents = Calendar.current.dateComponents([.year, .month, .day, .hour, .minute], from: notificationTime)
await localNotificationService.schedule(localNotification: .init(
id: UUID(),
title: "Trial ends soon",
body: "Subscription ends in 2 days",
dateComponents: dateComponents,
repeats: false
))
}
} catch {}
}
#endif
}
}

Expand Down
72 changes: 43 additions & 29 deletions Sources/OversizeKit/StoreKit/Views/BuyButtonStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ public struct PaymentButtonStyle: ButtonStyle {
@Environment(\.isLoading) private var isLoading: Bool
@Environment(\.isAccent) private var isAccent: Bool
@Environment(\.elevation) private var elevation: Elevation
@Environment(\.controlSize) var controlSize: ControlSize
@Environment(\.controlBorderShape) var controlBorderShape: ControlBorderShape
@Environment(\.isBordered) var isBordered: Bool
#if !os(tvOS)
@Environment(\.controlSize) var controlSize: ControlSize
#endif

private let isInfinityWidth: Bool?

Expand Down Expand Up @@ -81,33 +83,41 @@ public struct PaymentButtonStyle: ButtonStyle {
}

private var horizontalPadding: Space {
switch controlSize {
case .mini:
return .xxSmall
case .small:
return .small
case .regular:
return .small
case .large, .extraLarge:
#if os(tvOS)
return .medium
@unknown default:
return .zero
}
#else
switch controlSize {
case .mini:
return .xxSmall
case .small:
return .small
case .regular:
return .small
case .large, .extraLarge:
return .medium
@unknown default:
return .zero
}
#endif
}

private var verticalPadding: Space {
switch controlSize {
case .mini:
return .xxSmall
case .small:
return .xxSmall
case .regular:
return .small
case .large, .extraLarge:
#if os(tvOS)
return .medium
@unknown default:
return .zero
}
#else
switch controlSize {
case .mini:
return .xxSmall
case .small:
return .xxSmall
case .regular:
return .small
case .large, .extraLarge:
return .medium
@unknown default:
return .zero
}
#endif
}

private var backgroundOpacity: CGFloat {
Expand All @@ -119,13 +129,17 @@ public struct PaymentButtonStyle: ButtonStyle {
}

private var maxWidth: CGFloat? {
if isInfinityWidth == nil, controlSize == .regular {
return .infinity
} else if let infinity = isInfinityWidth, infinity == true {
return .infinity
} else {
#if os(tvOS)
return nil
}
#else
if isInfinityWidth == nil, controlSize == .regular {
return .infinity
} else if let infinity = isInfinityWidth, infinity == true {
return .infinity
} else {
return nil
}
#endif
}
}

Expand Down
6 changes: 3 additions & 3 deletions Sources/OversizeKit/SystemKit/SystemServices.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ public struct SystemServicesModifier: ViewModifier {
}
.blur(radius: blurRadius)
.preferredColorScheme(theme.appearance.colorScheme)
.premiumStatus(isPremium)
.theme(ThemeSettings())
.screenSize(screnSize)
#if os(iOS)
.accentColor(theme.accentColor)
.screenSize(screnSize)
#endif
.premiumStatus(isPremium)
.theme(ThemeSettings())
}
}
}
Expand Down

0 comments on commit 502b879

Please sign in to comment.