Xcode 11 beta 6

This commit is contained in:
John Holdsworth
2019-08-20 18:54:37 +02:00
parent a36ff1b7ca
commit 7de7e1e47b
40 changed files with 114 additions and 115 deletions

View File

@@ -22,14 +22,14 @@ struct TaskEditView: View {
let inset = EdgeInsets(top: -8, leading: -10, bottom: -7, trailing: -10)
return VStack(alignment: .leading, spacing: 0) {
TextField(
"Enter New Title...", text: self.draftTitle.binding,
"Enter New Title...", text: self.draftTitle.projectedValue,
onEditingChanged: { _ in self.updateTask() },
onCommit: {}
)
.background(
RoundedRectangle(cornerRadius: 5)
.fill(Color.clear)
.border(Color(red: 0.7, green: 0.7, blue: 0.7), width: 1 / UIScreen.main.scale, cornerRadius: 5)
.background(RoundedRectangle(cornerRadius: 5).strokeBorder(Color(red: 0.7, green: 0.7, blue: 0.7), lineWidth: 1 / UIScreen.main.scale))
.padding(inset)
)
.padding(EdgeInsets(
@@ -46,6 +46,6 @@ struct TaskEditView: View {
private func updateTask() {
guard let index = self.userData.tasks.firstIndex(of: self.task) else { return }
self.userData.tasks[index].title = self.draftTitle.value
self.userData.tasks[index].title = self.draftTitle.wrappedValue
}
}

View File

@@ -19,7 +19,7 @@ struct TaskItemView: View {
if self.isEditing {
Image(systemName: "minus.circle")
.foregroundColor(.red)
.tapAction(count: 1) {
.onTapGesture(count: 1) {
self.delete()
}
NavigationLink(destination: TaskEditView(task: task).environmentObject(self.userData)) {

View File

@@ -14,13 +14,13 @@ private let defaultTasks: [Task] = [
Task(title: "Watch WWDC19 Keynote 🎉", isDone: true),
]
final class UserData: BindableObject {
let willChange = PassthroughSubject<UserData, Never>()
final class UserData: ObservableObject {
let objectWillChange = PassthroughSubject<UserData, Never>()
@UserDefaultValue(key: "Tasks", defaultValue: defaultTasks)
var tasks: [Task] {
didSet {
willChange.send(self)
objectWillChange.send(self)
}
}
}