mirror of
https://github.com/sudosylabs/vnidrop.git
synced 2026-08-05 02:29:55 +02:00
feat(apple): native SwiftUI app for iOS and macOS
Add a native SwiftUI VniDrop app (Send/Receive/Settings) talking to the Rust core via generated UniFFI Swift bindings, plus the uniffi-bindgen helper crate. iOS uses a TabView, macOS a NavigationSplitView sidebar.
This commit is contained in:
21
apple/VniDrop/Platform/InvitationFile.swift
Normal file
21
apple/VniDrop/Platform/InvitationFile.swift
Normal file
@@ -0,0 +1,21 @@
|
||||
import Foundation
|
||||
|
||||
/// Builds a `.vnd` invitation filename from a transfer name, mirroring the iOS
|
||||
/// helper in `TransferShareActions.ios.kt`.
|
||||
func invitationFileName(_ transferName: String) -> String {
|
||||
let trimmed = transferName.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
let base = trimmed.isEmpty ? "invitation" : trimmed
|
||||
let safe = base.components(separatedBy: CharacterSet.alphanumerics.inverted.subtracting(CharacterSet(charactersIn: "-_ ")))
|
||||
.joined()
|
||||
.replacingOccurrences(of: " ", with: "-")
|
||||
let name = safe.isEmpty ? "invitation" : safe
|
||||
return "\(name).\(vniDropInvitationExtension)"
|
||||
}
|
||||
|
||||
/// Writes a temporary `.vnd` file for sharing/exporting.
|
||||
func writeTemporaryInvitation(ticket: String, transferName: String) throws -> URL {
|
||||
let dir = FileManager.default.temporaryDirectory
|
||||
let url = dir.appendingPathComponent(invitationFileName(transferName))
|
||||
try ticket.write(to: url, atomically: true, encoding: .utf8)
|
||||
return url
|
||||
}
|
||||
Reference in New Issue
Block a user