Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let package = Package(
fuse ? .package(url: "https://source.skip.tools/skip-fuse-ui.git", from: "1.0.0")
: .package(url: "https://source.skip.tools/skip-ui.git", from: "1.59.0"),
.package(url: "https://source.skip.tools/skip.git", from: "1.9.4"),
.package(url: "https://source.skip.tools/skip-kit.git", from: "1.1.0"),
.package(url: "https://github.com/fhasse95/skip-kit.git", branch: "Document-Exporter"),
.package(url: "https://source.skip.tools/skip-av.git", "0.7.1"..<"2.0.0"),
.package(url: "https://source.skip.tools/skip-web.git", "0.11.2"..<"2.0.0"),
.package(url: "https://source.skip.tools/skip-sql.git", "0.16.0"..<"2.0.0"),
Expand Down
45 changes: 45 additions & 0 deletions Sources/Showcase/DocumentPickerPlayground.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ struct DocumentPickerPlayground: View {
@State var presentPreview = false
@State var presentCamera = false
@State var presentMediaPicker = false
@State var presentDocumentExporter = false

@State var allowsMultipleSelection = true

@State var selectedDocumentURLs: [URL] = []
@State var selectedFilenames: [String] = []
@State var selectedFileMimeTypes: [String] = []
@State var selectedMediaURLs: [URL] = []
@State var exportDocumentURL: URL?
@State var resultItems: [ResultItem] = []
@State var resultItemHeights: [String: Double] = [:]

Expand Down Expand Up @@ -79,6 +81,24 @@ struct DocumentPickerPlayground: View {
ScrollView {
VStack(alignment: .leading, spacing: 16) {
VStack(alignment: .center, spacing: 8) {
Button {
if let url = photoExportURL() {
exportDocumentURL = url
presentDocumentExporter = true
}
} label: {
Text("Export Photo")
.frame(maxWidth: .infinity, alignment: .center)
}
.buttonStyle(.borderedProminent)
.withDocumentExporter(
isPresented: $presentDocumentExporter,
contentType: .png,
documentURL: exportDocumentURL
)

Divider()

Button {
presentCamera = true
} label: {
Expand Down Expand Up @@ -229,6 +249,31 @@ struct DocumentPickerPlayground: View {
.clipShape(RoundedRectangle(cornerRadius: 8))
}

private func photoExportURL() -> URL? {
guard let resourceURL = Bundle.module.url(forResource: "skip-logo", withExtension: "png") else {
return nil
}

#if SKIP
guard let cacheDir = UIApplication.shared.androidActivity?.cacheDir else {
return nil
}

let destinationFile = java.io.File(cacheDir, "skip-logo.png")
let destinationURL = URL(fileURLWithPath: destinationFile.absolutePath)

do {
let data = try Data(contentsOf: resourceURL)
try data.write(to: destinationURL)
return destinationURL
} catch {
return nil
}
#else
return resourceURL
#endif
}

private func filename(at index: Int, fallback: String) -> String {
guard selectedFilenames.indices.contains(index) else {
return fallback
Expand Down
49 changes: 29 additions & 20 deletions Sources/Showcase/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,12 @@
},
"AsyncImage" : {

},
"Audio" : {
"comment" : "Title of Audio playground"
},
"AudioPlayground is Lite-only until ported to SkipAV" : {

},
"Authenticate" : {

Expand All @@ -1023,12 +1029,6 @@
},
"Authentication" : {

},
"Audio" : {
"comment" : "Title of Audio playground"
},
"AudioPlayground is Lite-only until ported to SkipAV" : {

},
"Availability" : {

Expand Down Expand Up @@ -1207,13 +1207,13 @@
"Calendars (%lld)" : {

},
"Cancel" : {
"Can Authenticate" : {

},
"Cancelled" : {
"Cancel" : {

},
"Can Authenticate" : {
"Cancelled" : {

},
"Capsule" : {
Expand Down Expand Up @@ -1485,6 +1485,9 @@
},
"Detail View" : {

},
"Dictionary version: %lld" : {

},
"Difference" : {

Expand Down Expand Up @@ -1700,6 +1703,9 @@
},
"Expanding container in scroll view" : {

},
"Export Photo" : {

},
"F1" : {

Expand Down Expand Up @@ -2687,10 +2693,10 @@
"Nil Enum" : {

},
"NO" : {
"No" : {

},
"No" : {
"NO" : {

},
"No badge (count 0)" : {
Expand All @@ -2708,10 +2714,10 @@
"No URL\n.frame(100, 100)" : {

},
"Normal" : {
"None" : {

},
"None" : {
"Normal" : {

},
"Not authenticated" : {
Expand Down Expand Up @@ -4339,6 +4345,9 @@
}
}
}
},
"Replace dictionary" : {

},
"Repository item tap count: %lld" : {

Expand Down Expand Up @@ -5405,9 +5414,6 @@
},
"Title Only" : {

},
"Type" : {

},
"To:" : {

Expand Down Expand Up @@ -5480,6 +5486,9 @@
},
"Two Buttons" : {

},
"Type" : {

},
"UIImage Prepared Thumbnail" : {

Expand All @@ -5489,15 +5498,15 @@
},
"Unavailable" : {

},
"Unspecified Biometric" : {

},
"Underline" : {

},
"UnevenRoundedRectangle" : {

},
"Unspecified Biometric" : {

},
"Upcoming Events (%lld)" : {

Expand Down Expand Up @@ -5923,4 +5932,4 @@
}
},
"version" : "1.0"
}
}
Loading