Skip to content

Commit c6aef3b

Browse files
CreateBookView refactor
1 parent b1f402a commit c6aef3b

3 files changed

Lines changed: 32 additions & 23 deletions

File tree

Examples/Example_02/Example_02.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
97AB88CC2BE9899200AB314B /* CreateAuthorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97AB88CB2BE9899200AB314B /* CreateAuthorView.swift */; };
2424
97AB88CE2BE989B500AB314B /* AuthorsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97AB88CD2BE989B400AB314B /* AuthorsView.swift */; };
2525
97AB88D02BE98EED00AB314B /* BooksView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97AB88CF2BE98EED00AB314B /* BooksView.swift */; };
26+
97B60BD92BE9E569007DB2D8 /* CreateBookView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97B60BD82BE9E569007DB2D8 /* CreateBookView.swift */; };
2627
/* End PBXBuildFile section */
2728

2829
/* Begin PBXFileReference section */
@@ -43,6 +44,7 @@
4344
97AB88CB2BE9899200AB314B /* CreateAuthorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateAuthorView.swift; sourceTree = "<group>"; };
4445
97AB88CD2BE989B400AB314B /* AuthorsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthorsView.swift; sourceTree = "<group>"; };
4546
97AB88CF2BE98EED00AB314B /* BooksView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BooksView.swift; sourceTree = "<group>"; };
47+
97B60BD82BE9E569007DB2D8 /* CreateBookView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateBookView.swift; sourceTree = "<group>"; };
4648
/* End PBXFileReference section */
4749

4850
/* Begin PBXFrameworksBuildPhase section */
@@ -111,6 +113,7 @@
111113
children = (
112114
97AB889D2BE97CC600AB314B /* ContentView.swift */,
113115
97AB88CB2BE9899200AB314B /* CreateAuthorView.swift */,
116+
97B60BD82BE9E569007DB2D8 /* CreateBookView.swift */,
114117
97AB88CD2BE989B400AB314B /* AuthorsView.swift */,
115118
97AB88CF2BE98EED00AB314B /* BooksView.swift */,
116119
);
@@ -233,6 +236,7 @@
233236
97AB88CA2BE987F000AB314B /* BooksManager.swift in Sources */,
234237
97AB88AC2BE97D5800AB314B /* AppState.swift in Sources */,
235238
97AB88C42BE983D100AB314B /* BookEntity.swift in Sources */,
239+
97B60BD92BE9E569007DB2D8 /* CreateBookView.swift in Sources */,
236240
97AB88C62BE984A100AB314B /* ContainerBuilder.swift in Sources */,
237241
97AB889E2BE97CC600AB314B /* ContentView.swift in Sources */,
238242
97AB88CC2BE9899200AB314B /* CreateAuthorView.swift in Sources */,

Examples/Example_02/Example_02/UI/CreateAuthorView.swift

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,3 @@ struct CreateAuthorView: View {
2525
}
2626
}
2727

28-
struct CreateBookView: View {
29-
30-
let booksManager = AppState.shared.booksManager
31-
32-
let author: AuthorEntity
33-
34-
@State
35-
var title: String = ""
36-
37-
var body: some View {
38-
HStack {
39-
TextField("new book", text: $title)
40-
.textFieldStyle(.roundedBorder)
41-
Button("create") {
42-
Task {
43-
try await booksManager.create(title: title, author: author)
44-
title = ""
45-
}
46-
}
47-
.disabled(title.isEmpty)
48-
}.padding()
49-
}
50-
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Created by Axel Ancona Esselmann on 5/6/24.
2+
//
3+
4+
import SwiftUI
5+
6+
struct CreateBookView: View {
7+
8+
let booksManager = AppState.shared.booksManager
9+
10+
let author: AuthorEntity
11+
12+
@State
13+
var title: String = ""
14+
15+
var body: some View {
16+
HStack {
17+
TextField("new book", text: $title)
18+
.textFieldStyle(.roundedBorder)
19+
Button("create") {
20+
Task {
21+
try await booksManager.create(title: title, author: author)
22+
title = ""
23+
}
24+
}
25+
.disabled(title.isEmpty)
26+
}.padding()
27+
}
28+
}

0 commit comments

Comments
 (0)