Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marionauta/apps-showcase-swift
A tiny opinionated library for retrieving and displaying apps that you want to showcase inside your app.
https://github.com/marionauta/apps-showcase-swift
swift swift-package swift-package-manager swiftui
Last synced: 17 days ago
JSON representation
A tiny opinionated library for retrieving and displaying apps that you want to showcase inside your app.
- Host: GitHub
- URL: https://github.com/marionauta/apps-showcase-swift
- Owner: marionauta
- License: mit
- Created: 2023-11-24T18:10:38.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-13T20:15:35.000Z (12 months ago)
- Last Synced: 2024-12-06T19:56:03.184Z (about 1 month ago)
- Topics: swift, swift-package, swift-package-manager, swiftui
- Language: Swift
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AppsShowcase
A tiny opinionated library for retrieving and displaying apps that you want to
showcase inside your app. Useful for cross promoting apps by the same developer.## Install
Add `https://github.com/marionauta/apps-showcase-swift` to your Swift Package
Manager dependencies. Other dependency managers are not supported.## How to use it
`AppsShowcase` requires a `.json` file hosted somewhere with the following schema:
```json
[
{
"id": "string", // An unique string, usually the bundle id.
"name": "string",
"tagline": "string",
"ios": "string", // A valid url to the app.
"beta": true // Optional. Marks the app as beta if true.
}
]
```Then in your code:
```swift
import AppsShowcasefunc load() async {
let showcase = AppsShowcase(url: URL(string: "https://example.com/apps.json")!)
switch await showcase.retrieve() {
case let .success(apps):
print(apps)
case let .failure(error):
print(error.localizedDescription)
}
}
```By default `AppsShowcase` will omit apps with the same bundle id as the current
running one. This can be disabled by creating it as:```swift
let showcase = AppsShowcase(url: URL(string: "...")!, excludingId: nil)
```## Display the apps
You can display the `ShowcasedApp` object however you want. Two basic views
`ShowcasedAppRow` and `ShowcasedAppLink` are provided out of the box:```swift
import SwiftUI@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
struct AppList: View {
let apps: [ShowcasedApp]var body: some View {
ForEach(apps) { app in
Link(destination: app.url) {
ShowcasedAppRow(app: app)
}
}
ForEach(apps) { app in
ShowcasedAppLink(app: app) // Uses `Link` for you
}
}
}
```## Out of the box
An additional `ShowcasedAppsSection` view is provided, that takes care of
fetching and displaying the app list:```swift
import SwiftUI@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
struct AppList: View {
@State private var isLoading: Bool = falsevar body: some View {
// Simple
ShowcasedAppsSection("My other apps", url: URL(string: "...")!)
// To report the loading status:
ShowcasedAppsSection("My other apps", url: URL(string: "...")!, isLoading: $isLoading)
}
}
```