diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2023-07-24 20:19:46 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2023-07-24 20:19:46 +0200 |
| commit | bf063563436a12c003968ae4d00991f49fac226c (patch) | |
| tree | baa95b20f000813c9692f085ece363194041ec94 /Captura | |
Initial commit
Diffstat (limited to 'Captura')
| -rw-r--r-- | Captura/Assets.xcassets/AccentColor.colorset/Contents.json | 11 | ||||
| -rw-r--r-- | Captura/Assets.xcassets/AppIcon.appiconset/Contents.json | 58 | ||||
| -rw-r--r-- | Captura/Assets.xcassets/Contents.json | 6 | ||||
| -rw-r--r-- | Captura/Captura.entitlements | 18 | ||||
| -rw-r--r-- | Captura/CapturaApp.swift | 20 | ||||
| -rw-r--r-- | Captura/ContentView.swift | 57 | ||||
| -rw-r--r-- | Captura/Item.swift | 18 | ||||
| -rw-r--r-- | Captura/Preview Content/Preview Assets.xcassets/Contents.json | 6 |
8 files changed, 194 insertions, 0 deletions
diff --git a/Captura/Assets.xcassets/AccentColor.colorset/Contents.json b/Captura/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/Captura/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Captura/Assets.xcassets/AppIcon.appiconset/Contents.json b/Captura/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..3f00db4 --- /dev/null +++ b/Captura/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,58 @@ +{ + "images" : [ + { + "idiom" : "mac", + "scale" : "1x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "512x512" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "512x512" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Captura/Assets.xcassets/Contents.json b/Captura/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Captura/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Captura/Captura.entitlements b/Captura/Captura.entitlements new file mode 100644 index 0000000..fe097f1 --- /dev/null +++ b/Captura/Captura.entitlements @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>com.apple.developer.aps-environment</key> + <string>development</string> + <key>com.apple.developer.icloud-container-identifiers</key> + <array/> + <key>com.apple.developer.icloud-services</key> + <array> + <string>CloudKit</string> + </array> + <key>com.apple.security.app-sandbox</key> + <true/> + <key>com.apple.security.files.user-selected.read-only</key> + <true/> +</dict> +</plist> diff --git a/Captura/CapturaApp.swift b/Captura/CapturaApp.swift new file mode 100644 index 0000000..b0ccf32 --- /dev/null +++ b/Captura/CapturaApp.swift @@ -0,0 +1,20 @@ +// +// CapturaApp.swift +// Captura +// +// Created by Ruben Beltran del Rio on 7/24/23. +// + +import SwiftUI +import SwiftData + +@main +struct CapturaApp: App { + + var body: some Scene { + WindowGroup { + ContentView() + } + .modelContainer(for: Item.self) + } +} diff --git a/Captura/ContentView.swift b/Captura/ContentView.swift new file mode 100644 index 0000000..63fa7b8 --- /dev/null +++ b/Captura/ContentView.swift @@ -0,0 +1,57 @@ +// +// ContentView.swift +// Captura +// +// Created by Ruben Beltran del Rio on 7/24/23. +// + +import SwiftUI +import SwiftData + +struct ContentView: View { + @Environment(\.modelContext) private var modelContext + @Query private var items: [Item] + + var body: some View { + NavigationView { + List { + ForEach(items) { item in + NavigationLink { + Text("Item at \(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard))") + } label: { + Text(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard)) + } + } + .onDelete(perform: deleteItems) + } + .toolbar { + ToolbarItem { + Button(action: addItem) { + Label("Add Item", systemImage: "plus") + } + } + } + Text("Select an item") + } + } + + private func addItem() { + withAnimation { + let newItem = Item(timestamp: Date()) + modelContext.insert(newItem) + } + } + + private func deleteItems(offsets: IndexSet) { + withAnimation { + for index in offsets { + modelContext.delete(items[index]) + } + } + } +} + +#Preview { + ContentView() + .modelContainer(for: Item.self, inMemory: true) +} diff --git a/Captura/Item.swift b/Captura/Item.swift new file mode 100644 index 0000000..22587d8 --- /dev/null +++ b/Captura/Item.swift @@ -0,0 +1,18 @@ +// +// Item.swift +// Captura +// +// Created by Ruben Beltran del Rio on 7/24/23. +// + +import Foundation +import SwiftData + +@Model +final class Item { + var timestamp: Date + + init(timestamp: Date) { + self.timestamp = timestamp + } +} diff --git a/Captura/Preview Content/Preview Assets.xcassets/Contents.json b/Captura/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Captura/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} |