mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 14:53:25 +01:00
[ADD] WIP: Add My Apps view with support for sideloading new apps, refreshing installed apps and much more
This commit is contained in:
committed by
Joe Mattiello
parent
a0eb30f98e
commit
02e48a207f
@@ -26,4 +26,10 @@ extension View {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder func tintedBackground(_ color: Color) -> some View {
|
||||
self
|
||||
.blurBackground(.systemUltraThinMaterial)
|
||||
.background(color.opacity(0.4))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// DocumentPicker.swift
|
||||
// SideStore
|
||||
//
|
||||
// Created by Fabian Thies on 20.12.22.
|
||||
// Copyright © 2022 SideStore. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import SwiftUI
|
||||
|
||||
struct DocumentPicker: UIViewControllerRepresentable {
|
||||
internal class Coordinator: NSObject {
|
||||
var parent: DocumentPicker
|
||||
|
||||
init(_ parent: DocumentPicker) {
|
||||
self.parent = parent
|
||||
}
|
||||
}
|
||||
|
||||
@Binding var selectedUrl: URL?
|
||||
let supportedTypes: [String]
|
||||
|
||||
func makeCoordinator() -> Coordinator {
|
||||
Coordinator(self)
|
||||
}
|
||||
|
||||
func makeUIViewController(context: Context) -> some UIViewController {
|
||||
|
||||
let documentPickerViewController = UIDocumentPickerViewController(documentTypes: supportedTypes, in: .import)
|
||||
documentPickerViewController.delegate = context.coordinator
|
||||
return documentPickerViewController
|
||||
}
|
||||
|
||||
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {}
|
||||
}
|
||||
|
||||
extension DocumentPicker.Coordinator: UIDocumentPickerDelegate {
|
||||
|
||||
func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
|
||||
self.parent.selectedUrl = nil
|
||||
}
|
||||
|
||||
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
|
||||
|
||||
guard let firstURL = urls.first else {
|
||||
return
|
||||
}
|
||||
|
||||
self.parent.selectedUrl = firstURL
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user