Fix crash

This commit is contained in:
Christoph Hagen 2022-12-11 19:25:58 +01:00
parent 42f625b94f
commit b767301aa0
2 changed files with 5 additions and 6 deletions

View File

@ -245,7 +245,7 @@ struct ContentView: View {
SettingsView(isPresented: $showSettingsSheet) SettingsView(isPresented: $showSettingsSheet)
} }
.sheet(isPresented: $showGridView) { .sheet(isPresented: $showGridView) {
GridView(isPresented: $showGridView) GridView(isPresented: $showGridView, database: database)
}.alert(isPresented: $showNewClassifierAlert) { }.alert(isPresented: $showNewClassifierAlert) {
Alert(title: Text("New classifier available"), Alert(title: Text("New classifier available"),
message: Text("Classifier \(database.serverClassifierVersion) is available. You have version \(database.classifierVersion). Do you want to download it now?"), message: Text("Classifier \(database.serverClassifierVersion) is available. You have version \(database.classifierVersion). Do you want to download it now?"),

View File

@ -3,8 +3,7 @@ import SFSafeSymbols
struct GridView: View { struct GridView: View {
@EnvironmentObject let database: Database
var database: Database
@AppStorage("currentGridName") @AppStorage("currentGridName")
@ -36,8 +35,9 @@ struct GridView: View {
@State var lastScaleValue: CGFloat = 1.0 @State var lastScaleValue: CGFloat = 1.0
init(isPresented: Binding<Bool>) { init(isPresented: Binding<Bool>, database: Database) {
self._isPresented = isPresented self._isPresented = isPresented
self.database = database
self.image = .init(columns: 1, capPlacements: []) self.image = .init(columns: 1, capPlacements: [])
if let image = database.load(grid: currentGridName) { if let image = database.load(grid: currentGridName) {
@ -165,7 +165,6 @@ struct GridView: View {
struct GridView_Previews: PreviewProvider { struct GridView_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
GridView(isPresented: .constant(true)) GridView(isPresented: .constant(true), database: .largeMock)
.environmentObject(Database.largeMock)
} }
} }