mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 05:19:13 +00:00
made the snippet picker actually show as a popover :yay:
added presentationcompactpopover to conditionally force a popover on ios 16.4 and above made addsnippetview dismiss as well after adding
This commit is contained in:
@@ -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, *) {
|
||||
|
||||
@@ -50,6 +50,7 @@ struct AddSnippetView: View {
|
||||
ToolbarItem(placement: .topBarTrailing) {
|
||||
Button {
|
||||
hostsManager.addSnippet(snippet)
|
||||
dismiss()
|
||||
} label: {
|
||||
Label("Add", systemImage: "plus")
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user