From 98097fc927ebba064ab9bb2b2422f8c528e6df35 Mon Sep 17 00:00:00 2001 From: Valentin Perignon Date: Tue, 5 Nov 2024 18:21:15 +0100 Subject: [PATCH] feat: Generate URL from transfer UUID --- .../SuccessfulLinkTransferView.swift | 41 ++++++++++++------- .../SuccessfulTransferView.swift | 19 ++++----- .../UploadProgress/UploadProgressView.swift | 3 ++ Tuist/Package.resolved | 4 +- 4 files changed, 39 insertions(+), 28 deletions(-) diff --git a/SwissTransferFeatures/UploadProgressView/SuccessfulTransfer/SuccessfulLinkTransferView.swift b/SwissTransferFeatures/UploadProgressView/SuccessfulTransfer/SuccessfulLinkTransferView.swift index 51474139..4d7a35e0 100644 --- a/SwissTransferFeatures/UploadProgressView/SuccessfulTransfer/SuccessfulLinkTransferView.swift +++ b/SwissTransferFeatures/UploadProgressView/SuccessfulTransfer/SuccessfulLinkTransferView.swift @@ -17,6 +17,8 @@ */ import InfomaniakCoreSwiftUI +import InfomaniakDI +import STCore import STResources import SwiftUI import SwissTransferCore @@ -25,10 +27,18 @@ import SwissTransferCoreUI struct SuccessfulLinkTransferView: View { private static let qrCodeSize: CGFloat = 160 + @LazyInjectService private var injection: SwissTransferInjection + let type: TransferType - let url: URL + let transferUUID: String let dismiss: () -> Void + private var transferURL: URL? { + let apiURLCreator = injection.sharedApiUrlCreator + let url = apiURLCreator.shareTransferUrl(transferUUID: transferUUID) + return URL(string: url) + } + var body: some View { VStack(spacing: 32) { STResourcesAsset.Images.beers.swiftUIImage @@ -40,8 +50,10 @@ struct SuccessfulLinkTransferView: View { .font(.ST.title) .foregroundStyle(Color.ST.textPrimary) - QRCodeView(url: url) - .frame(width: Self.qrCodeSize, height: Self.qrCodeSize) + if let transferURL { + QRCodeView(url: transferURL) + .frame(width: Self.qrCodeSize, height: Self.qrCodeSize) + } if type != .qrcode { Text(STResourcesStrings.Localizable.uploadSuccessLinkDescription) @@ -55,20 +67,21 @@ struct SuccessfulLinkTransferView: View { .padding(.vertical, value: .large) .scrollableEmptyState() .safeAreaButtons { - HStack(spacing: IKPadding.medium) { - ShareLink(item: url) { - Label { - Text(STResourcesStrings.Localizable.buttonShare) - } icon: { - STResourcesAsset.Images.personBadgeShare.swiftUIImage + if let transferURL { + HStack(spacing: IKPadding.medium) { + ShareLink(item: transferURL) { + Label { + Text(STResourcesStrings.Localizable.buttonShare) + } icon: { + STResourcesAsset.Images.personBadgeShare.swiftUIImage + } + .labelStyle(.verticalButton) } - .labelStyle(.verticalButton) + CopyToClipboardButton(url: transferURL) } - - CopyToClipboardButton(url: url) + .buttonStyle(.ikBordered) + .frame(maxWidth: IKButtonConstants.maxWidth) } - .buttonStyle(.ikBordered) - .frame(maxWidth: IKButtonConstants.maxWidth) Button(action: dismiss) { Text(STResourcesStrings.Localizable.buttonFinished) diff --git a/SwissTransferFeatures/UploadProgressView/SuccessfulTransfer/SuccessfulTransferView.swift b/SwissTransferFeatures/UploadProgressView/SuccessfulTransfer/SuccessfulTransferView.swift index 39426345..13b849da 100644 --- a/SwissTransferFeatures/UploadProgressView/SuccessfulTransfer/SuccessfulTransferView.swift +++ b/SwissTransferFeatures/UploadProgressView/SuccessfulTransfer/SuccessfulTransferView.swift @@ -35,21 +35,16 @@ extension TransferType { } public struct SuccessfulTransferView: View { - private let type: TransferType - private let recipientsEmails: [String] - private let dismiss: () -> Void - - public init(type: TransferType, recipientsEmails: [String], dismiss: @escaping () -> Void) { - self.type = type - self.recipientsEmails = recipientsEmails - self.dismiss = dismiss - } + let type: TransferType + let transferUUID: String + let recipientsEmails: [String] + let dismiss: () -> Void public var body: some View { Group { switch type { case .link, .qrcode, .proximity: - SuccessfulLinkTransferView(type: type, url: URL(string: "https://www.infomaniak.com")!, dismiss: dismiss) + SuccessfulLinkTransferView(type: type, transferUUID: transferUUID, dismiss: dismiss) case .mail: SuccessfulMailTransferView(recipients: recipientsEmails, dismiss: dismiss) } @@ -61,11 +56,11 @@ public struct SuccessfulTransferView: View { } #Preview("Mail") { - SuccessfulTransferView(type: .mail, recipientsEmails: []) {} + SuccessfulTransferView(type: .mail, transferUUID: "", recipientsEmails: []) {} } #Preview("QR Code") { - SuccessfulTransferView(type: .qrcode, recipientsEmails: []) {} + SuccessfulTransferView(type: .qrcode, transferUUID: "", recipientsEmails: []) {} } #Preview("Link") { diff --git a/SwissTransferFeatures/UploadProgressView/UploadProgress/UploadProgressView.swift b/SwissTransferFeatures/UploadProgressView/UploadProgress/UploadProgressView.swift index 13bbf3ac..f48279a7 100644 --- a/SwissTransferFeatures/UploadProgressView/UploadProgress/UploadProgressView.swift +++ b/SwissTransferFeatures/UploadProgressView/UploadProgress/UploadProgressView.swift @@ -67,6 +67,9 @@ public struct UploadProgressView: View { } .stIconNavigationBar() .navigationBarBackButtonHidden() + .navigationDestination(isPresented: .constant(false)) { + SuccessfulTransferView(type: transferType, recipientsEmails: uploadSession.recipientsEmails, dismiss: dismiss) + } .task(startUpload) } diff --git a/Tuist/Package.resolved b/Tuist/Package.resolved index 17126c65..1de1fafc 100644 --- a/Tuist/Package.resolved +++ b/Tuist/Package.resolved @@ -77,8 +77,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/Infomaniak/multiplatform-SwissTransfer", "state" : { - "revision" : "026ce2192ddcf3174528d17a0989bc35fe67d92d", - "version" : "0.6.0" + "revision" : "bd4bf654bff4162b2832576ddc9fc9d652fcbf07", + "version" : "0.7.0" } }, {