From 776e35079b749fe4d5d99e35634d21f35f567204 Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Mon, 27 Jun 2022 21:34:14 -0700 Subject: [PATCH] fix edit title modal for macos --- .../App/Views/Labels/ApplyLabelsView.swift | 2 +- .../App/Views/LinkedItemTitleEditView.swift | 73 +++++++++++++------ 2 files changed, 53 insertions(+), 22 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/Labels/ApplyLabelsView.swift b/apple/OmnivoreKit/Sources/App/Views/Labels/ApplyLabelsView.swift index c64633fff..b1c67f823 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Labels/ApplyLabelsView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Labels/ApplyLabelsView.swift @@ -74,7 +74,7 @@ struct ApplyLabelsView: View { } ) #if os(macOS) - .buttonStyle(PlainButtonStyle()) + .buttonStyle(PlainButtonStyle()) #endif } } diff --git a/apple/OmnivoreKit/Sources/App/Views/LinkedItemTitleEditView.swift b/apple/OmnivoreKit/Sources/App/Views/LinkedItemTitleEditView.swift index 4fb72af6e..913eec01a 100644 --- a/apple/OmnivoreKit/Sources/App/Views/LinkedItemTitleEditView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/LinkedItemTitleEditView.swift @@ -63,30 +63,61 @@ struct LinkedItemTitleEditView: View { } var body: some View { - NavigationView { - editForm - .navigationTitle("Edit Title and Description") + Group { #if os(iOS) - .navigationBarTitleDisplayMode(.inline) + iOSBody + #else + macOSBody #endif - .toolbar { - ToolbarItem(placement: .barTrailing) { - Button( - action: { - viewModel.submit(dataService: dataService, item: item) - presentationMode.wrappedValue.dismiss() - }, - label: { Text("Save").foregroundColor(.appGrayTextContrast) } - ) - } - ToolbarItem(placement: .barLeading) { - Button( - action: { presentationMode.wrappedValue.dismiss() }, - label: { Text("Cancel").foregroundColor(.appGrayTextContrast) } - ) - } - } } .task { viewModel.load(item: item) } } + + #if os(iOS) + var iOSBody: some View { + NavigationView { + editForm + .navigationTitle("Edit Title and Description") + .navigationBarTitleDisplayMode(.inline) + .toolbar { + ToolbarItem(placement: .barTrailing) { + Button( + action: { + viewModel.submit(dataService: dataService, item: item) + presentationMode.wrappedValue.dismiss() + }, + label: { Text("Save").foregroundColor(.appGrayTextContrast) } + ) + } + ToolbarItem(placement: .barLeading) { + Button( + action: { presentationMode.wrappedValue.dismiss() }, + label: { Text("Cancel").foregroundColor(.appGrayTextContrast) } + ) + } + } + } + } + #else + var macOSBody: some View { + editForm + .toolbar { + ToolbarItemGroup { + Button( + action: { + viewModel.submit(dataService: dataService, item: item) + presentationMode.wrappedValue.dismiss() + }, + label: { Text("Save").foregroundColor(.appGrayTextContrast) } + ) + + Button( + action: { presentationMode.wrappedValue.dismiss() }, + label: { Text("Cancel").foregroundColor(.appGrayTextContrast) } + ) + } + } + .frame(minWidth: 400, minHeight: 400) + } + #endif }