Removed extension vor optional bindings. Instead introduced binding for each variable in the views. Seems much cleaner. Maybe in some future xcode version that is implemented officially
This commit is contained in:
@@ -33,7 +33,6 @@
|
||||
B9A0550322F8C2740054D9A0 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9A0550222F8C2740054D9A0 /* MainView.swift */; };
|
||||
B9A0550522F8CB400054D9A0 /* GameSeriesLibraryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9A0550422F8CB400054D9A0 /* GameSeriesLibraryView.swift */; };
|
||||
B9BCCEB92653BDEA005F46D6 /* ICloudManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9BCCEB82653BDEA005F46D6 /* ICloudManager.swift */; };
|
||||
B9BCCEBB2653CA8E005F46D6 /* SwiftUIBindingExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9BCCEBA2653CA8E005F46D6 /* SwiftUIBindingExtension.swift */; };
|
||||
B9BCF4CA2168ACB600ECBAAC /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B9BCF4C92168ACB600ECBAAC /* LaunchScreen.storyboard */; };
|
||||
B9E2A07B233B6A8F00EAEB14 /* GameSeriesEditView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9E2A07A233B6A8F00EAEB14 /* GameSeriesEditView.swift */; };
|
||||
B9E2A07E233B6E4F00EAEB14 /* ConsoleAllView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9E2A07C233B6E4F00EAEB14 /* ConsoleAllView.swift */; };
|
||||
@@ -103,7 +102,6 @@
|
||||
B9A0550222F8C2740054D9A0 /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
|
||||
B9A0550422F8CB400054D9A0 /* GameSeriesLibraryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameSeriesLibraryView.swift; sourceTree = "<group>"; };
|
||||
B9BCCEB82653BDEA005F46D6 /* ICloudManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ICloudManager.swift; sourceTree = "<group>"; };
|
||||
B9BCCEBA2653CA8E005F46D6 /* SwiftUIBindingExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIBindingExtension.swift; sourceTree = "<group>"; };
|
||||
B9BCF4C92168ACB600ECBAAC /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
B9E2A07A233B6A8F00EAEB14 /* GameSeriesEditView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameSeriesEditView.swift; sourceTree = "<group>"; };
|
||||
B9E2A07C233B6E4F00EAEB14 /* ConsoleAllView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConsoleAllView.swift; sourceTree = "<group>"; };
|
||||
@@ -171,7 +169,6 @@
|
||||
B9EC09812383F94B004BC9AB /* LibraryExport.swift */,
|
||||
B90E03EA238557D900E79643 /* LibraryImport.swift */,
|
||||
B98CBBE2265045AC00B1B7AC /* URLExtension.swift */,
|
||||
B9BCCEBA2653CA8E005F46D6 /* SwiftUIBindingExtension.swift */,
|
||||
);
|
||||
path = Utils;
|
||||
sourceTree = "<group>";
|
||||
@@ -396,7 +393,6 @@
|
||||
B94CB50022D1352F0029BFAD /* Accessory+CoreDataProperties.swift in Sources */,
|
||||
B9E2A07B233B6A8F00EAEB14 /* GameSeriesEditView.swift in Sources */,
|
||||
B94CB50422D1352F0029BFAD /* Game+CoreDataProperties.swift in Sources */,
|
||||
B9BCCEBB2653CA8E005F46D6 /* SwiftUIBindingExtension.swift in Sources */,
|
||||
B98A736022C1738800FB3410 /* CDManager.swift in Sources */,
|
||||
B9E2A07E233B6E4F00EAEB14 /* ConsoleAllView.swift in Sources */,
|
||||
B9BCCEB92653BDEA005F46D6 /* ICloudManager.swift in Sources */,
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
//
|
||||
// SwiftUIBindingExtension.swift
|
||||
// Zockerhoehle
|
||||
//
|
||||
// Created by Julian-Steffen Müller on 18.05.21.
|
||||
// Copyright © 2021 Julian-Steffen Müller. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
func ??<T>(lhs: Binding<Optional<T>>, rhs: T) -> Binding<T> {
|
||||
Binding(
|
||||
get: { lhs.wrappedValue ?? rhs },
|
||||
set: { lhs.wrappedValue = $0 }
|
||||
)
|
||||
}
|
||||
@@ -11,14 +11,26 @@ import SwiftUI
|
||||
struct ConsoleEditView: View {
|
||||
@ObservedObject var console : Console
|
||||
|
||||
var consoleShortNameBinding: Binding<String> {
|
||||
Binding<String>(
|
||||
get: { self.console.shortName ?? "" },
|
||||
set: { self.console.shortName = $0 })
|
||||
}
|
||||
|
||||
var consoleManufacturerBinding: Binding<String> {
|
||||
Binding<String>(
|
||||
get: { self.console.manufacturer ?? "" },
|
||||
set: { self.console.manufacturer = $0 })
|
||||
}
|
||||
|
||||
@State var isImportingLogo : Bool = false
|
||||
let defaultImage = UIImage()
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
TextField("Name der Konsole", text: $console.name)
|
||||
TextField("Abkürzung", text: $console.shortName ?? "")
|
||||
TextField("Hersteller", text: $console.manufacturer ?? "")
|
||||
TextField("Abkürzung", text: consoleShortNameBinding)
|
||||
TextField("Hersteller", text: consoleManufacturerBinding)
|
||||
DatePicker(selection: $console.releaseDate, in: ...Date(), displayedComponents: .date) {
|
||||
Text("Erscheinungsjahr")
|
||||
}
|
||||
|
||||
@@ -11,11 +11,17 @@ import SwiftUI
|
||||
struct GameSeriesEditView: View {
|
||||
@ObservedObject var gameSeries : GameSeries
|
||||
|
||||
var seriesNameBinding: Binding<String> {
|
||||
Binding<String>(
|
||||
get: { self.gameSeries.name ?? "" },
|
||||
set: { self.gameSeries.name = $0 })
|
||||
}
|
||||
|
||||
@State var isImportingLogo : Bool = false
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
TextField("Name der Konsole", text: $gameSeries.name ?? "")
|
||||
TextField("Name der Konsole", text: seriesNameBinding)
|
||||
|
||||
//TODO Image
|
||||
/*gameSeriesViewModel.cover.map {
|
||||
|
||||
Reference in New Issue
Block a user