-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Paywalls
: added header image to configuration (#2800)
### Changes: - Added `PaywallData.assetBaseURL` and `PaywallData.Configuration.headerImageName` - Changed template to fetch image from network - Updated snapshot testing to support asynchronous checking, necessary for `AsyncImageView` - Added support for overriding images for snapshot tests - Extracted `DebugErrorView`
- Loading branch information
Showing
23 changed files
with
303 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// DebugErrorView.swift | ||
// | ||
// | ||
// Created by Nacho Soto on 7/13/23. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
|
||
/// A view that displays an error in debug builds | ||
@available(iOS 16.0, macOS 13.0, tvOS 16.0, *) | ||
struct DebugErrorView: View { | ||
|
||
private let description: String | ||
|
||
init(_ error: Error) { | ||
self.init((error as NSError).localizedDescription) | ||
} | ||
|
||
init(_ description: String) { | ||
self.description = description | ||
} | ||
|
||
var body: some View { | ||
#if DEBUG | ||
Text(self.description) | ||
.background( | ||
Color.red | ||
.edgesIgnoringSafeArea(.all) | ||
) | ||
#else | ||
// Fix-me: implement a proper production error screen | ||
// appropriate for each case | ||
EmptyView() | ||
.onAppear { | ||
Logger.warning("Couldn't load paywall: \(self.description)") | ||
} | ||
#endif | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// FitToAspectRatio.swift | ||
// | ||
// | ||
// Created by Nacho Soto on 7/13/23. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
|
||
@available(iOS 16.0, macOS 13.0, tvOS 16.0, *) | ||
struct FitToAspectRatio: ViewModifier { | ||
|
||
let aspectRatio: Double | ||
let contentMode: SwiftUI.ContentMode | ||
|
||
func body(content: Content) -> some View { | ||
Color.clear | ||
.aspectRatio(self.aspectRatio, contentMode: .fit) | ||
.overlay( | ||
content.aspectRatio(nil, contentMode: self.contentMode) | ||
) | ||
} | ||
|
||
} | ||
|
||
@available(iOS 16.0, macOS 13.0, tvOS 16.0, *) | ||
extension Image { | ||
|
||
func fitToAspect(_ aspectRatio: Double, contentMode: SwiftUI.ContentMode) -> some View { | ||
self.resizable() | ||
.scaledToFill() | ||
.modifier(FitToAspectRatio(aspectRatio: aspectRatio, contentMode: contentMode)) | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
RevenueCatUI/Resources/Assets.xcassets/image.imageset/Contents.json
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.