paca_championship
Raz 11 months ago
parent a6b4b46afa
commit 354ae4c527
  1. 31
      PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift

@ -483,9 +483,9 @@ struct InscriptionManagerView: View {
// }
// if let teamPaste = teamPaste(.championship) {
// ShareLink(item: teamPaste) {
// Text("En csv pour la ligue")
// }
ShareLink(item: teamPaste(.championship)) {
Text("En csv pour la ligue")
}
// }
} label: {
Label("Exporter les paires", systemImage: "square.and.arrow.up")
@ -500,8 +500,8 @@ struct InscriptionManagerView: View {
tournament.unsortedTeamsWithoutWO()
}
func teamPaste(_ exportFormat: ExportFormat = .rawText) -> URL? {
tournament.pasteDataForImporting(exportFormat).createFile(self.tournament.tournamentTitle(.short), exportFormat)
func teamPaste(_ exportFormat: ExportFormat = .rawText) -> TournamentShareFile {
TournamentShareFile(tournament: tournament, exportFormat: exportFormat)
}
var unsortedPlayers: [PlayerRegistration] {
@ -1208,3 +1208,24 @@ struct InscriptionManagerView: View {
// .environment(Tournament.mock())
// }
//}
struct TournamentShareFile: Transferable {
let tournament: Tournament
let exportFormat: ExportFormat
func shareFile() -> URL {
print("Generating URL...")
return tournament.pasteDataForImporting(exportFormat).createFile(self.tournament.tournamentTitle()+"-inscriptions", exportFormat)
}
static var transferRepresentation: some TransferRepresentation {
FileRepresentation(exportedContentType: .utf8PlainText) { transferable in
return SentTransferredFile(transferable.shareFile())
}
ProxyRepresentation { transferable in
return transferable.shareFile()
}
}
}

Loading…
Cancel
Save