Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Successful transfer #27

Merged
merged 28 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b1bd984
feat: Add views architecture
valentinperignon Oct 16, 2024
15d2bf7
chore: Update loco
valentinperignon Oct 17, 2024
f1e6bcb
chore: Import and clean entities
valentinperignon Oct 17, 2024
0fa616d
feat: Add LargeEmptyState component
valentinperignon Oct 17, 2024
18068af
feat: Add Email successful view
valentinperignon Oct 17, 2024
9767793
chore: Update empty state view
valentinperignon Oct 21, 2024
9156dc8
feat: Connect views together
valentinperignon Oct 21, 2024
39c4e1f
feat(SuccessfulQR): Add main layout
valentinperignon Oct 21, 2024
3f41f5f
feat: Add icons
valentinperignon Oct 22, 2024
9ca1928
feat: Add actions
valentinperignon Oct 22, 2024
d2029f1
feat: Wrap the link view in a ScrollView
valentinperignon Oct 22, 2024
353a447
feat: Update Copy button with animation and impact
valentinperignon Oct 22, 2024
80a6a2d
chore: Support list of recipients
valentinperignon Oct 22, 2024
e499d8c
fix: Use GeometryReader
valentinperignon Oct 23, 2024
5748fb8
feat: Display list of recipients
valentinperignon Oct 24, 2024
edb56af
feat: Update title
valentinperignon Oct 24, 2024
9e20924
feat: Add QR Code
valentinperignon Oct 25, 2024
3704728
feat: Add style to QR Code
valentinperignon Oct 25, 2024
e41ff0e
chore: Update beers image
valentinperignon Oct 25, 2024
ecaec44
feat: Update with new buttons
valentinperignon Oct 25, 2024
cad0c45
feat: Update buttons animation
valentinperignon Oct 25, 2024
c7d518b
feat: Make QR Code a component
valentinperignon Oct 29, 2024
4c7421d
chore: Bump core-ui
valentinperignon Oct 29, 2024
c443eb3
feat: Add ScrollableEmptyStateModifier
valentinperignon Oct 29, 2024
7b778a8
feat: Add SafeAreaButtonsModifier
valentinperignon Oct 29, 2024
cd4ff65
fix: Remove padding 0 in Mail transfer
valentinperignon Oct 30, 2024
fb5af74
chore: Move views to UploadProgressView feature
valentinperignon Oct 31, 2024
3548e1c
perf: Make QRCode creation async
valentinperignon Nov 1, 2024
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
3 changes: 2 additions & 1 deletion Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ let project = Project(
infoPlist: .default,
sources: "SwissTransferCoreUI/**",
dependencies: [
.target(name: "SwissTransferCore")
.target(name: "SwissTransferCore"),
.external(name: "QRCode")
],
settings: .settings(base: Constants.baseSettings)),
.target(name: "STResources",
Expand Down
1 change: 1 addition & 0 deletions SwissTransfer/Sources/SwissTransferApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct SwissTransferApp: App {
WindowGroup {
RootView()
.tint(.ST.primary)
.ikButtonTheme(.swissTransfer)
.detectCompactWindow()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
import STResources
import SwiftUI

enum TransferType: String, CaseIterable {
public enum TransferType: String, CaseIterable {
case link
case qrcode
case proximity
case mail

var title: String {
public var title: String {
switch self {
case .link:
STResourcesStrings.Localizable.transferTypeLink
Expand All @@ -38,7 +38,7 @@ enum TransferType: String, CaseIterable {
}
}

var icon: Image {
public var icon: Image {
switch self {
case .link:
STResourcesAsset.Images.hyperlink.swiftUIImage
Expand Down
70 changes: 70 additions & 0 deletions SwissTransferCoreUI/Components/LargeEmptyStateView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
Infomaniak SwissTransfer - iOS App
Copyright (C) 2024 Infomaniak Network SA

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import InfomaniakCoreSwiftUI
import STResources
import SwiftUI

public struct LargeEmptyStateView: View {
public static let imageMaxWidth: CGFloat = 400
public static let textMaxWidth: CGFloat = 300

let image: Image
let title: String
let subtitle: String
let imageHorizontalPadding: CGFloat

public init(image: Image, title: String, subtitle: String, imageHorizontalPadding: CGFloat = IKPadding.medium) {
self.image = image
self.title = title
self.subtitle = subtitle
self.imageHorizontalPadding = imageHorizontalPadding
}

public var body: some View {
VStack(spacing: 32) {
image
.resizable()
.scaledToFit()
.padding(.horizontal, imageHorizontalPadding)
.frame(maxWidth: Self.imageMaxWidth)

VStack(spacing: IKPadding.medium) {
Text(title)
.font(.ST.title)
.foregroundStyle(Color.ST.textPrimary)

Text(subtitle)
.font(.ST.body)
.foregroundStyle(Color.ST.textSecondary)
.frame(maxWidth: Self.textMaxWidth)
}
.padding(.horizontal, value: .medium)
}
.multilineTextAlignment(.center)
}
}

#Preview {
LargeEmptyStateView(
image: STResourcesAsset.Images.beers.swiftUIImage,
title: "Empty State Title",
subtitle: "Consequat magna cupidatat aute fugiat quis dolore ea labore nisi velit. Culpa deserunt adipisicing velit consequat.",
imageHorizontalPadding: 0
)
}
96 changes: 96 additions & 0 deletions SwissTransferCoreUI/Components/QRCodeView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
Infomaniak SwissTransfer - iOS App
Copyright (C) 2024 Infomaniak Network SA

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import QRCode
import STResources
import SwiftUI

public struct QRCodeView: View {
@Environment(\.colorScheme) private var colorScheme

@State private var generatedDocument: QRCode.Document?
@State private var isShowingError = false

private let url: URL

public init(url: URL) {
self.url = url
}

public var body: some View {
VStack {
if let generatedDocument {
QRCodeDocumentUIView(document: generatedDocument)
} else if isShowingError {
VStack {
Image(systemName: "exclamationmark.triangle.fill")
.font(.ST.title)
Text(STResourcesStrings.Localizable.errorGeneratingQRCode)
.font(.ST.headline)
}
.foregroundStyle(Color.ST.error)
} else {
ProgressView()
}
}
.onAppear {
computeQRCode()
}
valentinperignon marked this conversation as resolved.
Show resolved Hide resolved
.onChange(of: colorScheme) { newColorScheme in
computeQRCode(newColorScheme)
}
}

private func computeQRCode(_ newColorScheme: ColorScheme? = nil) {
do {
let colorScheme = newColorScheme ?? colorScheme
var documentBuilder = try QRCode.build
.url(url)
.errorCorrection(.high)
.foregroundColor(getQRCodeColor(colorScheme))
.backgroundColor(getBackgroundColor(colorScheme))

if let logo = STResourcesAsset.Images.logoK.image.cgImage {
let template = QRCode.LogoTemplate(
image: logo,
path: CGPath(rect: CGRect(x: 0.35, y: 0.35, width: 0.3, height: 0.3), transform: nil),
inset: 2
)
documentBuilder = documentBuilder.logo(template)
}

generatedDocument = documentBuilder.document
} catch {
isShowingError = true
}
}

private func getQRCodeColor(_ newColorScheme: ColorScheme) -> CGColor {
let qrCodeColor = newColorScheme == .light ? STResourcesAsset.Colors.greenDark : STResourcesAsset.Colors.white
return qrCodeColor.color.cgColor
}

private func getBackgroundColor(_ newColorScheme: ColorScheme) -> CGColor {
let backgroundColor = newColorScheme == .light ? STResourcesAsset.Colors.white : STResourcesAsset.Colors.dark0
return backgroundColor.color.cgColor
}
}

#Preview {
QRCodeView(url: URL(string: "https://www.infomaniak.com")!)
}
34 changes: 34 additions & 0 deletions SwissTransferCoreUI/Extensions/IKButtonTheme+Extension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
Infomaniak SwissTransfer - iOS App
Copyright (C) 2024 Infomaniak Network SA

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import InfomaniakCoreSwiftUI
import STResources
import SwiftUI

public extension IKButtonTheme {
static let swissTransfer = IKButtonTheme(
primary: TintShapeStyle.tint,
secondary: Color.ST.onPrimary,
tertiary: Color.ST.tertiaryButton,
disabledPrimary: Color.ST.disabledState,
disabledSecondary: Color.ST.onDisabledState,
error: Color.ST.error,
smallFont: Font.ST.callout,
mediumFont: Font.ST.headline
)
}
18 changes: 18 additions & 0 deletions SwissTransferCoreUI/Foundation/Color+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,24 @@ public extension Color {
dark: STResourcesAsset.Colors.dark2
)

// MARK: - Buttons

/// light: greyRabbit / dark: dark1
public static let tertiaryButton = Color(
light: STResourcesAsset.Colors.greyRabbit,
dark: STResourcesAsset.Colors.dark1
)

/// light: greyShark / dark: greyElephant
public static let disabledState = Color(
light: STResourcesAsset.Colors.greyShark,
dark: STResourcesAsset.Colors.greyElephant
)
public static let onDisabledState = Color(
light: STResourcesAsset.Colors.white,
dark: STResourcesAsset.Colors.dark0
)

// MARK: - Recipient Labels

/// light: greenContrast / dark: greenDark
Expand Down
1 change: 1 addition & 0 deletions SwissTransferCoreUI/Modifiers/RoundedLabelModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct RoundedLabelModifier: ViewModifier {
content
.font(.ST.body)
.foregroundStyle(Color.ST.secondary)
.lineLimit(1)
.padding(.vertical, 2)
.padding(.horizontal, value: .small)
.background(Color.ST.recipientLabelBackground, in: .capsule)
Expand Down
49 changes: 49 additions & 0 deletions SwissTransferCoreUI/Modifiers/SafeAreaButtonsModifier.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
Infomaniak SwissTransfer - iOS App
Copyright (C) 2024 Infomaniak Network SA

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import InfomaniakCoreSwiftUI
import SwiftUI

public extension View {
func safeAreaButtons<Buttons: View>(
spacing: CGFloat = IKPadding.medium,
background: Color = Color.ST.background,
@ViewBuilder content: () -> Buttons
) -> some View {
modifier(SafeAreaButtonsModifier(spacing: spacing, background: background, buttons: content()))
}
}

struct SafeAreaButtonsModifier<Buttons: View>: ViewModifier {
let spacing: CGFloat
let background: Color
let buttons: Buttons

func body(content: Content) -> some View {
content
.safeAreaInset(edge: .bottom, spacing: 0) {
VStack(spacing: IKPadding.medium) {
buttons
}
.ikButtonFullWidth(true)
.controlSize(.large)
.padding(value: .medium)
.background(Color.ST.background)
}
}
}
38 changes: 38 additions & 0 deletions SwissTransferCoreUI/Modifiers/ScrollableEmptyStateModifier.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Infomaniak SwissTransfer - iOS App
Copyright (C) 2024 Infomaniak Network SA

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import SwiftUI

public extension View {
func scrollableEmptyState() -> some View {
modifier(ScrollableEmptyStateModifier())
}
}

struct ScrollableEmptyStateModifier: ViewModifier {
func body(content: Content) -> some View {
GeometryReader { proxy in
ScrollView {
content
.frame(maxWidth: .infinity)
.frame(minHeight: proxy.size.height)
}
.scrollBounceBehavior(.basedOnSize)
}
}
}
Loading
Loading