Skip to content

Commit

Permalink
feat: Generate URL from transfer UUID
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinperignon committed Nov 5, 2024
1 parent 08e94f0 commit 98097fc
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/

import InfomaniakCoreSwiftUI
import InfomaniakDI
import STCore
import STResources
import SwiftUI
import SwissTransferCore
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public struct UploadProgressView: View {
}
.stIconNavigationBar()
.navigationBarBackButtonHidden()
.navigationDestination(isPresented: .constant(false)) {
SuccessfulTransferView(type: transferType, recipientsEmails: uploadSession.recipientsEmails, dismiss: dismiss)
}
.task(startUpload)
}

Expand Down
4 changes: 2 additions & 2 deletions Tuist/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down

0 comments on commit 98097fc

Please sign in to comment.