This file contains hidden or 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
| func loadStatus() { | |
| projectName = shell("basename \"\(launchDir)\"") | |
| branch = shell("git -C \"\(launchDir)\" rev-parse --abbrev-ref HEAD 2>/dev/null || echo '(not a git repo)'") | |
| lastCommit = shell("git -C \"\(launchDir)\" log -1 --pretty=format:'%h %s' 2>/dev/null") | |
| let raw = shell("git -C \"\(launchDir)\" status --porcelain 2>/dev/null | wc -l | tr -d ' '") | |
| changedFiles = raw.isEmpty ? "–" : raw | |
| } |
This file contains hidden or 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
| func shell(_ command: String) -> String { | |
| let task = Process() | |
| let pipe = Pipe() | |
| task.standardOutput = pipe | |
| task.standardError = Pipe() | |
| task.launchPath = "/bin/bash" | |
| task.arguments = ["-c", command] | |
| task.environment = ProcessInfo.processInfo.environment | |
| try? task.run() | |
| task.waitUntilExit() |
This file contains hidden or 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
| class AppDelegate: UIResponder, UIApplicationDelegate { | |
| func application( | |
| _ application: UIApplication, | |
| configurationForConnecting connectingSceneSession: UISceneSession, | |
| options: UIScene.ConnectionOptions | |
| ) -> UISceneConfiguration { | |
| let configuration = UISceneConfiguration( | |
| name: "Default Configuration", | |
| sessionRole: connectingSceneSession.role | |
| ) |
This file contains hidden or 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 project: GiftRegistry | |
| // | |
| // Follow me on Mastodon: https://iosdev.space/@StewartLynch | |
| // Follow me on Threads: https://www.threads.net/@stewartlynch | |
| // Follow me on Bluesky: https://bsky.app/profile/stewartlynch.bsky.social | |
| // Follow me on X: https://x.com/StewartLynch | |
| // Follow me on LinkedIn: https://linkedin.com/in/StewartLynch | |
| // Email: slynch@createchsol.com |
This file contains hidden or 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
| // Occasions | |
| Occasion(id: UUID(0), name: "Christmas", hexColor: "C0392B") | |
| Occasion(id: UUID(1), name: "Birthday", hexColor: "8E44AD") | |
| Occasion(id: UUID(2), name: "Valentines Day", hexColor: "E91E8C") | |
| Occasion(id: UUID(3), name: "Wedding", hexColor: "D4AF37") | |
| // OccasionGifts (Many-to-Many join records) | |
| OccasionGift(id: UUID(0), occasionID: UUID(0), giftID: UUID(0)) | |
| OccasionGift(id: UUID(1), occasionID: UUID(0), giftID: UUID(1)) | |
| OccasionGift(id: UUID(2), occasionID: UUID(1), giftID: UUID(1)) |
This file contains hidden or 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 project: GiftRegistry | |
| // | |
| // Follow me on Mastodon: https://iosdev.space/@StewartLynch | |
| // Follow me on Threads: https://www.threads.net/@stewartlynch | |
| // Follow me on Bluesky: https://bsky.app/profile/stewartlynch.bsky.social | |
| // Follow me on X: https://x.com/StewartLynch | |
| // Follow me on LinkedIn: https://linkedin.com/in/StewartLynch | |
| // Email: slynch@createchsol.com |
This file contains hidden or 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 project: GiftRegistry | |
| // | |
| // Follow me on Mastodon: https://iosdev.space/@StewartLynch | |
| // Follow me on Threads: https://www.threads.net/@stewartlynch | |
| // Follow me on Bluesky: https://bsky.app/profile/stewartlynch.bsky.social | |
| // Follow me on X: https://x.com/StewartLynch | |
| // Follow me on LinkedIn: https://linkedin.com/in/StewartLynch | |
| // Email: slynch@createchsol.com |
This file contains hidden or 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
| func resizedAndOptimizedImageData(from data: Data, maxWidth: CGFloat = 1000) -> Data? { | |
| guard let image = UIImage(data: data) else { return nil } | |
| let originalSize = image.size | |
| let scaleFactor = min(1, maxWidth / originalSize.width) | |
| let newSize = CGSize( | |
| width: originalSize.width * scaleFactor, | |
| height: originalSize.height * scaleFactor | |
| ) |
This file contains hidden or 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
| import SwiftUI | |
| struct GiftForm: View { | |
| @State private var name = "" | |
| @State private var price: Double? | |
| @State private var isPurchased = false | |
| @Environment(\.dismiss) var dismiss | |
| var body: some View { | |
| NavigationStack { |
This file contains hidden or 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
| Section { | |
| List { | |
| ForEach(model.gifts) { gift in | |
| HStack { | |
| Button { | |
| // purchaseButtonTapped | |
| } label: { | |
| Image(systemName: gift.isPurchased ? "checkmark.circle.fill" : "circle") | |
| .foregroundStyle(gift.isPurchased ? .green : .secondary) |
NewerOlder