mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-15 09:43:34 +01:00
[ADD] Backported dismiss() environment variable to let views dismiss themselves
This commit is contained in:
committed by
Joe Mattiello
parent
0e7083539d
commit
378631e976
16
AltStore/View Extensions/EnvironmentValues.swift
Normal file
16
AltStore/View Extensions/EnvironmentValues.swift
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// EnvironmentValues.swift
|
||||||
|
// SideStore
|
||||||
|
//
|
||||||
|
// Created by Fabian Thies on 29.11.22.
|
||||||
|
// Copyright © 2022 SideStore. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
@available(iOS 14.0, *)
|
||||||
|
extension EnvironmentValues {
|
||||||
|
var dismiss: () -> Void {
|
||||||
|
{ presentationMode.wrappedValue.dismiss() }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -65,18 +65,8 @@ struct ConfirmAddSourceView: View {
|
|||||||
confirmationHandler(fetchedSource)
|
confirmationHandler(fetchedSource)
|
||||||
} label: {
|
} label: {
|
||||||
Label(title: { Text("Add Source") }, icon: { Image(systemName: "plus") })
|
Label(title: { Text("Add Source") }, icon: { Image(systemName: "plus") })
|
||||||
.multilineTextAlignment(.center)
|
|
||||||
.foregroundColor(.white)
|
|
||||||
.padding()
|
|
||||||
.frame(
|
|
||||||
maxWidth: .infinity,
|
|
||||||
alignment: .bottomLeading
|
|
||||||
)
|
|
||||||
.background(
|
|
||||||
RoundedRectangle(cornerRadius: 10)
|
|
||||||
.foregroundColor(Color.accentColor)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
.buttonStyle(FilledButtonStyle())
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
.background(Color(UIColor.systemGroupedBackground).ignoresSafeArea())
|
.background(Color(UIColor.systemGroupedBackground).ignoresSafeArea())
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ import CoreData
|
|||||||
|
|
||||||
struct SourcesView: View {
|
struct SourcesView: View {
|
||||||
|
|
||||||
|
@Environment(\.dismiss)
|
||||||
|
private var dismiss
|
||||||
|
|
||||||
@Environment(\.managedObjectContext)
|
@Environment(\.managedObjectContext)
|
||||||
var managedObjectContext
|
var managedObjectContext
|
||||||
|
|
||||||
@@ -102,9 +105,7 @@ struct SourcesView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ToolbarItem(placement: .navigationBarTrailing) {
|
ToolbarItem(placement: .navigationBarTrailing) {
|
||||||
SwiftUI.Button {
|
SwiftUI.Button(action: self.dismiss) {
|
||||||
self.isShowingAddSourceAlert = false
|
|
||||||
} label: {
|
|
||||||
Text("Done").bold()
|
Text("Done").bold()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user