mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-11 22:55:55 +05:45
Follow up to #3378. This allows us to link both `RevenueCat` and `RevenueCatUI` from `PurchasesHybridCommon` supporting the same platforms. The actual types might not be available in some platforms / versions, but we can detect that at compile time. See https://app.circleci.com/pipelines/github/RevenueCat/purchases-hybrid-common/2564/workflows/ea6a4e24-e1eb-4c7a-a930-173945732999/jobs/10352 --------- Co-authored-by: Andy Boedo <andresboedo@gmail.com>
66 lines
1.7 KiB
Swift
66 lines
1.7 KiB
Swift
//
|
|
// Copyright RevenueCat Inc. All Rights Reserved.
|
|
//
|
|
// Licensed under the MIT License (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// https://opensource.org/licenses/MIT
|
|
//
|
|
// FooterHidingModifier.swift
|
|
//
|
|
// Created by Nacho Soto on 8/9/23.
|
|
|
|
import RevenueCat
|
|
import SwiftUI
|
|
|
|
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
|
|
extension View {
|
|
|
|
func hideFooterContent(
|
|
_ configuration: TemplateViewConfiguration,
|
|
hide: Bool
|
|
) -> some View {
|
|
return self.modifier(FooterHidingModifier(configuration: configuration,
|
|
hide: hide))
|
|
}
|
|
|
|
}
|
|
|
|
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
|
|
private struct FooterHidingModifier: ViewModifier {
|
|
|
|
@State
|
|
private var height: CGFloat = 10
|
|
|
|
var configuration: TemplateViewConfiguration
|
|
var hide: Bool
|
|
|
|
func body(content: Content) -> some View {
|
|
switch self.configuration.mode {
|
|
case .fullScreen:
|
|
// These modes don't support hiding the content
|
|
content
|
|
.padding(.vertical)
|
|
|
|
case .footer:
|
|
content
|
|
|
|
case .condensedFooter:
|
|
content
|
|
.onHeightChange { if $0 > 0 { self.height = $0 } }
|
|
.opacity(self.hide ? 0 : 1)
|
|
.offset(
|
|
y: self.hide
|
|
? self.height
|
|
: 0
|
|
)
|
|
.frame(height: self.hide ? 0 : nil)
|
|
.blur(radius: self.hide ? Self.blurRadius : 0)
|
|
}
|
|
}
|
|
|
|
private static let blurRadius: CGFloat = 20
|
|
|
|
}
|