mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +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 {
|
struct scrollPaging: ViewModifier {
|
||||||
func body(content: Content) -> some View {
|
func body(content: Content) -> some View {
|
||||||
if #available(iOS 17, *) {
|
if #available(iOS 17, *) {
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ struct AddSnippetView: View {
|
|||||||
ToolbarItem(placement: .topBarTrailing) {
|
ToolbarItem(placement: .topBarTrailing) {
|
||||||
Button {
|
Button {
|
||||||
hostsManager.addSnippet(snippet)
|
hostsManager.addSnippet(snippet)
|
||||||
|
dismiss()
|
||||||
} label: {
|
} label: {
|
||||||
Label("Add", systemImage: "plus")
|
Label("Add", systemImage: "plus")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ struct SnippetPicker: View {
|
|||||||
@ObservedObject var hostsManager: HostsManager
|
@ObservedObject var hostsManager: HostsManager
|
||||||
var callback: ((Snippet) -> Void)?
|
var callback: ((Snippet) -> Void)?
|
||||||
|
|
||||||
|
@State var showAdder: Bool = false
|
||||||
|
|
||||||
@Environment(\.dismiss) var dismiss
|
@Environment(\.dismiss) var dismiss
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
@@ -20,6 +22,11 @@ struct SnippetPicker: View {
|
|||||||
Text("No Snippets")
|
Text("No Snippets")
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
.monospaced()
|
.monospaced()
|
||||||
|
Button() {
|
||||||
|
showAdder.toggle()
|
||||||
|
} label: {
|
||||||
|
Label("Add", systemImage: "plus.circle.fill")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ForEach(hostsManager.snippets) { snip in
|
ForEach(hostsManager.snippets) { snip in
|
||||||
Button(snip.name) {
|
Button(snip.name) {
|
||||||
@@ -28,6 +35,9 @@ struct SnippetPicker: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.sheet(isPresented: $showAdder) {
|
||||||
|
AddSnippetView(hostsManager: hostsManager)
|
||||||
|
}
|
||||||
.toolbar {
|
.toolbar {
|
||||||
ToolbarItem(placement: .topBarLeading) {
|
ToolbarItem(placement: .topBarLeading) {
|
||||||
Button() {
|
Button() {
|
||||||
|
|||||||
@@ -81,14 +81,18 @@ struct ShellTabView: View {
|
|||||||
showSnippetPicker.toggle()
|
showSnippetPicker.toggle()
|
||||||
} label: {
|
} label: {
|
||||||
Image(systemName: "paperclip")
|
Image(systemName: "paperclip")
|
||||||
|
.resizable().scaledToFit()
|
||||||
|
.frame(width: 20, height: 20)
|
||||||
}
|
}
|
||||||
.foregroundStyle(foreground)
|
.foregroundStyle(foreground)
|
||||||
.sheet(isPresented: $showSnippetPicker) {
|
.popover(isPresented: $showSnippetPicker) {
|
||||||
SnippetPicker(hostsManager: hostsManager) {
|
SnippetPicker(hostsManager: hostsManager) {
|
||||||
container.sessions[selectedID ?? UUID()]?.handler.writeToChannel($0.content)
|
container.sessions[selectedID ?? UUID()]?.handler.writeToChannel($0.content)
|
||||||
}
|
}
|
||||||
.presentationDragIndicator(.visible)
|
.frame(minWidth: 300, minHeight: 400)
|
||||||
.presentationDetents([.fraction(0.4), .large])
|
.modifier(presentationCompactPopover())
|
||||||
|
// .presentationDragIndicator(.visible)
|
||||||
|
// .presentationDetents([.fraction(0.4), .large])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(.horizontal, 10)
|
.padding(.horizontal, 10)
|
||||||
|
|||||||
Reference in New Issue
Block a user