-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Persist Quick Launch entries with SwiftData (#34)
- Loading branch information
Showing
26 changed files
with
664 additions
and
531 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// QuickLaunchEntry.swift | ||
// Tophat | ||
// | ||
// Created by Lukas Romsicki on 2024-11-22. | ||
// Copyright © 2024 Shopify. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import TophatFoundation | ||
import SwiftData | ||
|
||
@Model | ||
final class QuickLaunchEntry: Identifiable, Hashable { | ||
typealias Source = InstallRecipe | ||
|
||
@Attribute(.unique) | ||
var id: String | ||
|
||
var name: String | ||
|
||
var iconURL: URL? | ||
|
||
@Relationship(deleteRule: .cascade, minimumModelCount: 1) | ||
var sources: [QuickLaunchEntrySource] | ||
|
||
var order: Int = 0 | ||
|
||
init(id: String? = nil, name: String, iconURL: URL? = nil, sources: [QuickLaunchEntrySource], order: Int = 0) { | ||
self.id = id ?? UUID().uuidString | ||
self.name = name | ||
self.iconURL = iconURL | ||
self.sources = sources | ||
self.order = order | ||
} | ||
} | ||
|
||
extension QuickLaunchEntry { | ||
var platforms: Set<Platform> { | ||
Set(sources.compactMap { $0.platformHint }) | ||
} | ||
} |
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,34 @@ | ||
// | ||
// QuickLaunchEntrySource.swift | ||
// Tophat | ||
// | ||
// Created by Lukas Romsicki on 2024-11-25. | ||
// Copyright © 2024 Shopify. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import TophatFoundation | ||
import SwiftData | ||
|
||
@Model | ||
final class QuickLaunchEntrySource: Hashable { | ||
var artifactProviderID: String | ||
var artifactProviderParameters: [String: String] | ||
var launchArguments: [String] | ||
var platformHint: Platform | ||
var destinationHint: DeviceType? | ||
|
||
init( | ||
artifactProviderID: String, | ||
artifactProviderParameters: [String: String], | ||
launchArguments: [String], | ||
platformHint: Platform, | ||
destinationHint: DeviceType? = nil | ||
) { | ||
self.artifactProviderID = artifactProviderID | ||
self.artifactProviderParameters = artifactProviderParameters | ||
self.launchArguments = launchArguments | ||
self.platformHint = platformHint | ||
self.destinationHint = destinationHint | ||
} | ||
} |
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.