mirror of
https://github.com/foomo/gotrspc-mobile-examples.git
synced 2025-10-16 12:35:38 +00:00
47 lines
1.3 KiB
Swift
47 lines
1.3 KiB
Swift
//
|
|
// ContentView.swift
|
|
// FileShare
|
|
//
|
|
// Created by Hans Halfar on 13.05.24.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct ContentView: View {
|
|
@State var isShowing = false
|
|
var body: some View {
|
|
VStack {
|
|
Image(systemName: "globe")
|
|
.imageScale(.large)
|
|
.foregroundStyle(.tint)
|
|
Text("Hello, world!")
|
|
Button {
|
|
isShowing.toggle()
|
|
} label: {
|
|
Text("select a file")
|
|
}
|
|
.fileImporter(isPresented: $isShowing, allowedContentTypes: [.item], allowsMultipleSelection: true, onCompletion: { results in
|
|
|
|
switch results {
|
|
case .success(let fileurls):
|
|
print(fileurls.count)
|
|
|
|
for fileurl in fileurls {
|
|
print(fileurl.path)
|
|
server?.exposeFile(fileurl.path)
|
|
}
|
|
|
|
case .failure(let error):
|
|
print(error)
|
|
}
|
|
|
|
})
|
|
}
|
|
.padding()
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
ContentView()
|
|
}
|