https://github.com/jaywcjlove/myapplistkit
Encapsulation of My Personal App List
https://github.com/jaywcjlove/myapplistkit
ios ios-swift macos swift swift-package swift-package-manager
Last synced: 4 months ago
JSON representation
Encapsulation of My Personal App List
- Host: GitHub
- URL: https://github.com/jaywcjlove/myapplistkit
- Owner: jaywcjlove
- Created: 2024-11-26T17:47:06.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-02T15:04:06.000Z (over 1 year ago)
- Last Synced: 2025-04-03T11:28:12.053Z (over 1 year ago)
- Topics: ios, ios-swift, macos, swift, swift-package, swift-package-manager
- Language: Swift
- Homepage:
- Size: 57.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
MyAppListKit
===
Encapsulation of My Personal App List
Welcome to download [DevTutor](https://apps.apple.com/app/devtutor/id6471227008), a cheat sheet app designed to help developers quickly build excellent applications using SwiftUI.
## Installation
You can add MyAppListKit to an Xcode project by adding it as a package dependency.
1. From the File menu, select Add Packages…
2. Enter https://github.com/jaywcjlove/MyAppListKit in the Search or Enter Package URL search field
3. Link `MyAppListKit` to your application target
Or add the following to `Package.swift`:
```swift
.package(url: "https://github.com/jaywcjlove/MyAppListKit", branch: "main")
```
Or [add the package in Xcode](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app).
## Usage
```swift
import MyAppListKit
List {
ForEach(MyAppList.apps(), id: \.appId) { app in
Button(app.name, action: {
app.openApp()
// or
MyAppList.openApp(appId: app.appId, appstoreId: app.appstoreId)
})
}
}
Button("More Apps by Me") {
MyAppList.openURL(url: URL(string: MyAppList.appsByMe)!)
// or
MyAppList.openAppsByMe()
}
MyAppList.appDevHub // -> AppData
MyAppList.appDevHub.storeURL // -> URL: macappstore://apps.apple.com/app/id6476452351
MyAppList.appDevHub.appStoreWriteReview
// -> URL: macappstore://apps.apple.com/app/id6476452351?action=write-review
MyAppList.appDevHub.openURL() // Open in browser
MyAppList.appDevHub.openWriteReviewURL() // Open WriteReview in browser
MyAppList.appDevHub.openApp() // Open the app or its store download page
MyAppList.appDevHub.openWriteReviewURL() // Open the app or its store download page
```
Returns the URL of the default app associated with the given bundle identifier.
```
MyAppList.appDevHub.appURL()
```
Checks if the app is installed
```swift
MyAppList.isAppInstalled(appId: "com.wangchujiang.daybar")
```
Get app icon
```swift
MyAppList.getAppIcon() // Get the app's App Store icon
// Get icon using bundleIdentifier (if app is installed locally)
MyAppList.getAppIcon(forId: "com.wangchujiang.vidwall")
// Get icon using bundleIdentifier; if not found locally, fallback to App Store icon
MyAppList.getAppIcon(forId: "com.wangchujiang.vidwall", defaultAppStore: true)
// Get icon using bundleIdentifier; if not found locally,
// fetch from App Store using appstoreId
MyAppList.getAppIcon(forId: "com.wangchujiang.vidwall", appstoreId: "6747587746")
// Fetch icon directly from App Store using the app's ID
MyAppList.fetchAppIconFromAppStore(appId: "6747587746")
```
## Example Command Menu
```swift
import SwiftUI
import MyAppListKit
extension Locale {
/// Get the system's preferred language Locale, ignoring the app's region settings
/// This ensures that the MyAppListKit component always uses
/// the system language instead of the app's region settings
static var systemPreferred: Locale {
Locale(identifier: Locale.preferredLanguages.first ?? "en")
}
}
struct CommandMenus: Commands {
var body: some Commands {
CommandMenu(String.localized(key: "more_tools", locale: Locale.systemPreferred)) {
MoreAppsView().environment(\.locale, Locale.systemPreferred)
}
CommandGroup(replacing: .systemServices) {}
CommandGroup(after: CommandGroupPlacement.appInfo) {
Divider()
MyAppCheckForUpdatesView(app: MyAppList.appIconizeFolder)
.environment(\.locale, Locale.systemPreferred)
Divider()
CommandGroupView()
}
CommandGroup(replacing: CommandGroupPlacement.help) {
MyAppCheckForUpdatesView(app: MyAppList.appIconizeFolder)
.environment(\.locale, Locale.systemPreferred)
Divider()
CommandGroupView()
}
}
}
struct CommandGroupView: View {
var body: some View {
Group {
ButtonWebsite(app: MyAppList.appIconizeFolder)
ButtonRateApp(app: MyAppList.appIconizeFolder)
ButtonSendFeedback(app: MyAppList.appIconizeFolder)
MoreAppsMenuView()
Divider()
CommandAppButton(app: MyAppList.appIconed)
CommandAppButton(app: MyAppList.appCreateCustomSymbols)
CommandAppButton(app: MyAppList.appPaletteGenius)
CommandAppButton(app: MyAppList.appDevHub)
Divider()
}
.environment(\.locale, Locale.systemPreferred)
}
}
struct CommandAppButton: View {
let app: MyAppList.AppData
var body: some View {
Button(action: {
app.openApp()
}, label: {
HStack {
MoreAppsIcon(appId: app.appId, appstoreId: app.appstoreId)
let text: String = " - "
Text(app.name) +
Text(text).foregroundStyle(Color.secondary) +
Text(String.localized(key: desc ?? "", locale: Locale.systemPreferred))
.foregroundStyle(Color.secondary).font(.system(size: 10))
}
})
}
}
```
## MyAppCheckForUpdatesView
```swift
import MyAppListKit
struct ContentView: View {
var body: some View {
MyAppCheckForUpdatesView(app: MyAppList.appIconed)
MyAppCheckForUpdatesView(app: MyAppList.appIconed) { label in
HStack {
Text(label)
Spacer()
Image(systemName: "chevron.right")
}
}
.frame(maxWidth: .infinity)
.buttonStyle(.link)
}
}
```
## MoreAppsView
Display My Apps on the Menu.
```swift
struct CommandMenus: Commands {
var body: some Commands {
//CommandMenu("More Tools") {
// MoreAppsView()
//}
MoreAppsCommandMenus()
MoreAppsCommandMenus() {
Group {
// ....
}
}
CommandGroup(replacing: CommandGroupPlacement.help) {
MoreAppsMenuView()
}
}
}
```
## ButtonRateApp & ButtonSendFeedback
A button that guides users to rate or review the app on the App Store. When clicked, it opens the “Write a Review” page for the current app.
```swift
struct CommandMenus: Commands {
var body: some Commands {
CommandGroup(replacing: CommandGroupPlacement.help) {
ButtonWebsite(app: MyAppList.appRegexMate)
ButtonRateApp(app: MyAppList.appRegexMate)
Divider()
ButtonSendFeedback(app: MyAppList.appRegexMate)
}
}
}
```
## MoreAppsCommandMenus
```swift
import MyAppListKit
@main
struct IconizeFolderApp: App {
var body: some Scene {
return Window("", id: "MainWindow") {
ContentView()
}
.commands {
MoreAppsCommandMenus()
}
}
}
```
## My Apps List
```swift
let locale: Locale = Locale(identifier: Locale.preferredLanguages.first ?? "en")
ForEach(MyAppList.apps(), id: \.appId) { app in
Button(action: {
MyAppList.openApp(appId: app.appId, appstoreId: app.appstoreId)
}, label: {
Label(title: {
VStack(alignment: .leading) {
Text(app.name).font(.system(size: 12))
.multilineTextAlignment(.leading)
if let desc = app.desc {
Text(String.localized(key: desc, locale: locale))
.lineLimit(nil)
.fixedSize(horizontal: false, vertical: true)
.foregroundStyle(Color.secondary)
.font(.system(size: 10))
.multilineTextAlignment(.leading)
.lineSpacing(0)
.frame(maxWidth: .infinity, alignment: .leading)
}
}
.frame(maxWidth: .infinity, alignment: .leading)
}, icon: {
MoreAppsIcon(appId: app.appId, appstoreId: app.appstoreId)
})
})
.buttonStyle(.link)
}
```
## License
Licensed under the MIT License.