diff --git a/ShhShell/Views/Misc/ViewModifiers.swift b/ShhShell/Views/Misc/ViewModifiers.swift index 313a2a6..0fcf92b 100644 --- a/ShhShell/Views/Misc/ViewModifiers.swift +++ b/ShhShell/Views/Misc/ViewModifiers.swift @@ -24,6 +24,16 @@ struct foregroundColorStyle: ViewModifier { } } +struct presentationCompactPopover: ViewModifier { + func body(content: Content) -> some View { + if #available(iOS 16.4, *) { + content.presentationCompactAdaptation(.popover) + } else { + content + } + } +} + struct scrollPaging: ViewModifier { func body(content: Content) -> some View { if #available(iOS 17, *) { diff --git a/ShhShell/Views/Snippets/AddSnippetView.swift b/ShhShell/Views/Snippets/AddSnippetView.swift index 398e404..06a4c25 100644 --- a/ShhShell/Views/Snippets/AddSnippetView.swift +++ b/ShhShell/Views/Snippets/AddSnippetView.swift @@ -50,6 +50,7 @@ struct AddSnippetView: View { ToolbarItem(placement: .topBarTrailing) { Button { hostsManager.addSnippet(snippet) + dismiss() } label: { Label("Add", systemImage: "plus") } diff --git a/ShhShell/Views/Snippets/SnippetPicker.swift b/ShhShell/Views/Snippets/SnippetPicker.swift index a81bd8e..ca98a44 100644 --- a/ShhShell/Views/Snippets/SnippetPicker.swift +++ b/ShhShell/Views/Snippets/SnippetPicker.swift @@ -11,6 +11,8 @@ struct SnippetPicker: View { @ObservedObject var hostsManager: HostsManager var callback: ((Snippet) -> Void)? + @State var showAdder: Bool = false + @Environment(\.dismiss) var dismiss var body: some View { @@ -20,6 +22,11 @@ struct SnippetPicker: View { Text("No Snippets") .font(.headline) .monospaced() + Button() { + showAdder.toggle() + } label: { + Label("Add", systemImage: "plus.circle.fill") + } } ForEach(hostsManager.snippets) { snip in Button(snip.name) { @@ -28,6 +35,9 @@ struct SnippetPicker: View { } } } + .sheet(isPresented: $showAdder) { + AddSnippetView(hostsManager: hostsManager) + } .toolbar { ToolbarItem(placement: .topBarLeading) { Button() { diff --git a/ShhShell/Views/Terminal/ShellTabView.swift b/ShhShell/Views/Terminal/ShellTabView.swift index a39ef95..99d567c 100644 --- a/ShhShell/Views/Terminal/ShellTabView.swift +++ b/ShhShell/Views/Terminal/ShellTabView.swift @@ -81,14 +81,18 @@ struct ShellTabView: View { showSnippetPicker.toggle() } label: { Image(systemName: "paperclip") + .resizable().scaledToFit() + .frame(width: 20, height: 20) } .foregroundStyle(foreground) - .sheet(isPresented: $showSnippetPicker) { + .popover(isPresented: $showSnippetPicker) { SnippetPicker(hostsManager: hostsManager) { container.sessions[selectedID ?? UUID()]?.handler.writeToChannel($0.content) } - .presentationDragIndicator(.visible) - .presentationDetents([.fraction(0.4), .large]) + .frame(minWidth: 300, minHeight: 400) + .modifier(presentationCompactPopover()) +// .presentationDragIndicator(.visible) +// .presentationDetents([.fraction(0.4), .large]) } } .padding(.horizontal, 10)