Skip to content

Commit 728edf3

Browse files
authored
Merge pull request #1 from TreeHacks/dev
2 parents f7324af + 5ebd93e commit 728edf3

30 files changed

+1182
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.xcuserstate
2+
*.xcworkspace
3+
*.pbxproj
4+
*.DS_Store

My App/My App.xcodeproj/project.pbxproj

+599
Large diffs are not rendered by default.

My App/My App.xcodeproj/project.xcworkspace/contents.xcworkspacedata

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>SchemeUserState</key>
6+
<dict>
7+
<key>My App.xcscheme_^#shared#^_</key>
8+
<dict>
9+
<key>orderHint</key>
10+
<integer>0</integer>
11+
</dict>
12+
</dict>
13+
</dict>
14+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"platform" : "ios",
6+
"size" : "1024x1024"
7+
}
8+
],
9+
"info" : {
10+
"author" : "xcode",
11+
"version" : 1
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}

My App/My App/ButtonView.swift

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// ButtonView.swift
3+
// My App
4+
//
5+
// Created by Irfan Nafi on 10/15/23.
6+
//
7+
8+
import SwiftUI
9+
10+
struct ButtonView: View {
11+
var label: String
12+
13+
var body: some View {
14+
Button(action: {
15+
print("Button tapped")
16+
}, label: {
17+
Text(label)
18+
})
19+
}
20+
}

My App/My App/ContentView.swift

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// ContentView.swift
3+
// My App
4+
//
5+
// Created by Irfan Nafi on 10/15/23.
6+
//
7+
8+
import SwiftUI
9+
10+
struct ContentView: View {
11+
var body: some View {
12+
NavigationView {
13+
VStack {
14+
Image(systemName: "globe")
15+
.imageScale(.large)
16+
.foregroundStyle(.tint)
17+
Text("Hello, world!")
18+
ButtonView(label: "Tap me!")
19+
NavigationLink(destination: ListView(items: ["Item 1", "Item 2", "Item 3"])) {
20+
Text("Go to list")
21+
}
22+
NavigationLink(destination: NetworkingView()) {
23+
Text("Go to networking")
24+
}
25+
}
26+
.padding()
27+
}
28+
}
29+
}
30+
31+
#Preview {
32+
ContentView()
33+
}

My App/My App/ListView.swift

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// ListView.swift
3+
// My App
4+
//
5+
// Created by Irfan Nafi on 10/15/23.
6+
//
7+
8+
import SwiftUI
9+
10+
struct ListView: View {
11+
var items: [String]
12+
13+
var body: some View {
14+
List(items, id: \.self) { item in
15+
Text(item)
16+
}
17+
}
18+
}

My App/My App/My_AppApp.swift

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// My_AppApp.swift
3+
// My App
4+
//
5+
// Created by Irfan Nafi on 10/15/23.
6+
//
7+
8+
import SwiftUI
9+
10+
@main
11+
struct My_AppApp: App {
12+
var body: some Scene {
13+
WindowGroup {
14+
ContentView()
15+
}
16+
}
17+
}

My App/My App/NetworkingView.swift

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//
2+
// NetworkingView.swift
3+
// My App
4+
//
5+
// Created by Irfan Nafi on 10/15/23.
6+
//
7+
8+
import SwiftUI
9+
10+
struct NetworkingView: View {
11+
@State var posts: [Post] = []
12+
13+
var body: some View {
14+
List(posts, id: \.id) { post in
15+
VStack(alignment: .leading) {
16+
Text(post.title)
17+
.font(.headline)
18+
Text(post.body)
19+
.font(.subheadline)
20+
}
21+
}
22+
.task {
23+
do {
24+
posts = try await fetchPosts()
25+
} catch {
26+
print(error)
27+
}
28+
}
29+
}
30+
31+
func fetchPosts() async throws -> [Post] {
32+
let url = URL(string: "https://jsonplaceholder.typicode.com/posts")!
33+
let (data, _) = try await URLSession.shared.data(from: url)
34+
return try JSONDecoder().decode([Post].self, from: data)
35+
}
36+
}
37+
38+
struct Post: Codable, Identifiable {
39+
let id: Int
40+
let title: String
41+
let body: String
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}

My App/My AppTests/My_AppTests.swift

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// My_AppTests.swift
3+
// My AppTests
4+
//
5+
// Created by Irfan Nafi on 10/15/23.
6+
//
7+
8+
import XCTest
9+
@testable import My_App
10+
11+
final class My_AppTests: XCTestCase {
12+
13+
override func setUpWithError() throws {
14+
// Put setup code here. This method is called before the invocation of each test method in the class.
15+
}
16+
17+
override func tearDownWithError() throws {
18+
// Put teardown code here. This method is called after the invocation of each test method in the class.
19+
}
20+
21+
func testExample() throws {
22+
// This is an example of a functional test case.
23+
// Use XCTAssert and related functions to verify your tests produce the correct results.
24+
// Any test you write for XCTest can be annotated as throws and async.
25+
// Mark your test throws to produce an unexpected failure when your test encounters an uncaught error.
26+
// Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards.
27+
}
28+
29+
func testPerformanceExample() throws {
30+
// This is an example of a performance test case.
31+
self.measure {
32+
// Put the code you want to measure the time of here.
33+
}
34+
}
35+
36+
}
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// My_AppUITests.swift
3+
// My AppUITests
4+
//
5+
// Created by Irfan Nafi on 10/15/23.
6+
//
7+
8+
import XCTest
9+
10+
final class My_AppUITests: XCTestCase {
11+
12+
override func setUpWithError() throws {
13+
// Put setup code here. This method is called before the invocation of each test method in the class.
14+
15+
// In UI tests it is usually best to stop immediately when a failure occurs.
16+
continueAfterFailure = false
17+
18+
// 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.
19+
}
20+
21+
override func tearDownWithError() throws {
22+
// Put teardown code here. This method is called after the invocation of each test method in the class.
23+
}
24+
25+
func testExample() throws {
26+
// UI tests must launch the application that they test.
27+
let app = XCUIApplication()
28+
app.launch()
29+
30+
// Use XCTAssert and related functions to verify your tests produce the correct results.
31+
}
32+
33+
func testLaunchPerformance() throws {
34+
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
35+
// This measures how long it takes to launch your application.
36+
measure(metrics: [XCTApplicationLaunchMetric()]) {
37+
XCUIApplication().launch()
38+
}
39+
}
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// My_AppUITestsLaunchTests.swift
3+
// My AppUITests
4+
//
5+
// Created by Irfan Nafi on 10/15/23.
6+
//
7+
8+
import XCTest
9+
10+
final class My_AppUITestsLaunchTests: XCTestCase {
11+
12+
override class var runsForEachTargetApplicationUIConfiguration: Bool {
13+
true
14+
}
15+
16+
override func setUpWithError() throws {
17+
continueAfterFailure = false
18+
}
19+
20+
func testLaunch() throws {
21+
let app = XCUIApplication()
22+
app.launch()
23+
24+
// Insert steps here to perform after app launch but before taking a screenshot,
25+
// such as logging into a test account or navigating somewhere in the app
26+
27+
let attachment = XCTAttachment(screenshot: app.screenshot())
28+
attachment.name = "Launch Screen"
29+
attachment.lifetime = .keepAlways
30+
add(attachment)
31+
}
32+
}

0 commit comments

Comments
 (0)