-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
290 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
playgrounds/PlayingSwiftUI/PlayingSwiftUI/Assets.xcassets/AccentColor.colorset/Contents.json
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,11 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
playgrounds/PlayingSwiftUI/PlayingSwiftUI/Assets.xcassets/AppIcon.appiconset/Contents.json
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,35 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"platform" : "ios", | ||
"size" : "1024x1024" | ||
}, | ||
{ | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "dark" | ||
} | ||
], | ||
"idiom" : "universal", | ||
"platform" : "ios", | ||
"size" : "1024x1024" | ||
}, | ||
{ | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "tinted" | ||
} | ||
], | ||
"idiom" : "universal", | ||
"platform" : "ios", | ||
"size" : "1024x1024" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
playgrounds/PlayingSwiftUI/PlayingSwiftUI/Assets.xcassets/Contents.json
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,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
playgrounds/PlayingSwiftUI/PlayingSwiftUI/ContentView.swift
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,61 @@ | ||
// | ||
// ContentView.swift | ||
// PlayingSwiftUI | ||
// | ||
// Created by Muukii on 2025/01/20. | ||
// | ||
|
||
import SwiftUI | ||
import SwiftData | ||
|
||
struct ContentView: View { | ||
@Environment(\.modelContext) private var modelContext | ||
@Query private var items: [Item] | ||
|
||
var body: some View { | ||
NavigationSplitView { | ||
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(placement: .navigationBarTrailing) { | ||
EditButton() | ||
} | ||
ToolbarItem { | ||
Button(action: addItem) { | ||
Label("Add Item", systemImage: "plus") | ||
} | ||
} | ||
} | ||
} detail: { | ||
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) | ||
} |
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,10 @@ | ||
<?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>UIBackgroundModes</key> | ||
<array> | ||
<string>remote-notification</string> | ||
</array> | ||
</dict> | ||
</plist> |
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,18 @@ | ||
// | ||
// Item.swift | ||
// PlayingSwiftUI | ||
// | ||
// Created by Muukii on 2025/01/20. | ||
// | ||
|
||
import Foundation | ||
import SwiftData | ||
|
||
@Model | ||
final class Item { | ||
var timestamp: Date | ||
|
||
init(timestamp: Date) { | ||
self.timestamp = timestamp | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
playgrounds/PlayingSwiftUI/PlayingSwiftUI/PlayingSwiftUI.entitlements
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,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>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> |
32 changes: 32 additions & 0 deletions
32
playgrounds/PlayingSwiftUI/PlayingSwiftUI/PlayingSwiftUIApp.swift
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,32 @@ | ||
// | ||
// PlayingSwiftUIApp.swift | ||
// PlayingSwiftUI | ||
// | ||
// Created by Muukii on 2025/01/20. | ||
// | ||
|
||
import SwiftUI | ||
import SwiftData | ||
|
||
@main | ||
struct PlayingSwiftUIApp: App { | ||
var sharedModelContainer: ModelContainer = { | ||
let schema = Schema([ | ||
Item.self, | ||
]) | ||
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false) | ||
|
||
do { | ||
return try ModelContainer(for: schema, configurations: [modelConfiguration]) | ||
} catch { | ||
fatalError("Could not create ModelContainer: \(error)") | ||
} | ||
}() | ||
|
||
var body: some Scene { | ||
WindowGroup { | ||
ContentView() | ||
} | ||
.modelContainer(sharedModelContainer) | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...ounds/PlayingSwiftUI/PlayingSwiftUI/Preview Content/Preview Assets.xcassets/Contents.json
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,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
playgrounds/PlayingSwiftUI/PlayingSwiftUITests/PlayingSwiftUITests.swift
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,17 @@ | ||
// | ||
// PlayingSwiftUITests.swift | ||
// PlayingSwiftUITests | ||
// | ||
// Created by Muukii on 2025/01/20. | ||
// | ||
|
||
import Testing | ||
@testable import PlayingSwiftUI | ||
|
||
struct PlayingSwiftUITests { | ||
|
||
@Test func example() async throws { | ||
// Write your test here and use APIs like `#expect(...)` to check expected conditions. | ||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
playgrounds/PlayingSwiftUI/PlayingSwiftUIUITests/PlayingSwiftUIUITests.swift
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,43 @@ | ||
// | ||
// PlayingSwiftUIUITests.swift | ||
// PlayingSwiftUIUITests | ||
// | ||
// Created by Muukii on 2025/01/20. | ||
// | ||
|
||
import XCTest | ||
|
||
final class PlayingSwiftUIUITests: XCTestCase { | ||
|
||
override func setUpWithError() throws { | ||
// Put setup code here. This method is called before the invocation of each test method in the class. | ||
|
||
// In UI tests it is usually best to stop immediately when a failure occurs. | ||
continueAfterFailure = false | ||
|
||
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. | ||
} | ||
|
||
override func tearDownWithError() throws { | ||
// Put teardown code here. This method is called after the invocation of each test method in the class. | ||
} | ||
|
||
@MainActor | ||
func testExample() throws { | ||
// UI tests must launch the application that they test. | ||
let app = XCUIApplication() | ||
app.launch() | ||
|
||
// Use XCTAssert and related functions to verify your tests produce the correct results. | ||
} | ||
|
||
@MainActor | ||
func testLaunchPerformance() throws { | ||
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { | ||
// This measures how long it takes to launch your application. | ||
measure(metrics: [XCTApplicationLaunchMetric()]) { | ||
XCUIApplication().launch() | ||
} | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
playgrounds/PlayingSwiftUI/PlayingSwiftUIUITests/PlayingSwiftUIUITestsLaunchTests.swift
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,33 @@ | ||
// | ||
// PlayingSwiftUIUITestsLaunchTests.swift | ||
// PlayingSwiftUIUITests | ||
// | ||
// Created by Muukii on 2025/01/20. | ||
// | ||
|
||
import XCTest | ||
|
||
final class PlayingSwiftUIUITestsLaunchTests: XCTestCase { | ||
|
||
override class var runsForEachTargetApplicationUIConfiguration: Bool { | ||
true | ||
} | ||
|
||
override func setUpWithError() throws { | ||
continueAfterFailure = false | ||
} | ||
|
||
@MainActor | ||
func testLaunch() throws { | ||
let app = XCUIApplication() | ||
app.launch() | ||
|
||
// Insert steps here to perform after app launch but before taking a screenshot, | ||
// such as logging into a test account or navigating somewhere in the app | ||
|
||
let attachment = XCTAttachment(screenshot: app.screenshot()) | ||
attachment.name = "Launch Screen" | ||
attachment.lifetime = .keepAlways | ||
add(attachment) | ||
} | ||
} |