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: Create account view #959

Merged
merged 4 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 10 additions & 10 deletions .package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/CocoaLumberjack/CocoaLumberjack",
"state" : {
"revision" : "0188d31089b5881a269e01777be74c7316924346",
"version" : "3.8.0"
"revision" : "67ec5818a757aba4d7c534e21a905d878d128dbf",
"version" : "3.8.1"
}
},
{
Expand Down Expand Up @@ -139,8 +139,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/kean/Nuke",
"state" : {
"revision" : "29d3a7e0c687f97fe35b584f60b93fc547d3dade",
"version" : "12.1.5"
"revision" : "3f666f120b63ea7de57d42e9a7c9b47f8e7a290b",
"version" : "12.1.6"
}
},
{
Expand Down Expand Up @@ -175,8 +175,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/getsentry/sentry-cocoa",
"state" : {
"revision" : "04bee4ad86d74d4cb4d7101ff826d6e355301ba9",
"version" : "8.9.4"
"revision" : "d062d9b31ccabdec706134f2216476d1996caf11",
"version" : "8.10.0"
}
},
{
Expand Down Expand Up @@ -246,17 +246,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/siteline/SwiftUI-Introspect",
"state" : {
"revision" : "ccb973cfff703cba53fb88197413485c060eb26b",
"version" : "0.10.0"
"revision" : "1136c9a348329887844de9353107c787becc675b",
"version" : "0.11.0"
}
},
{
"identity" : "swiftui-shimmer",
"kind" : "remoteSourceControl",
"location" : "https://github.com/markiv/SwiftUI-Shimmer",
"state" : {
"revision" : "17b66b0e7d94d2d3f220bbcb021b5026436f06c7",
"version" : "1.3.0"
"revision" : "1f3a620e4abe890d00008cb2af7023d810b433a7",
"version" : "1.4.0"
}
},
{
Expand Down
24 changes: 10 additions & 14 deletions Mail/Views/Onboarding/OnboardingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ final class LoginHandler: InfomaniakLoginDelegate, ObservableObject {

func loginAfterAccountCreation(from viewController: UIViewController) {
isLoading = true
matomo.track(eventWithCategory: .account, name: "openCreationWebview")
loginService.setupWebviewNavbar(
title: MailResourcesStrings.Localizable.buttonLogin,
titleColor: nil,
Expand Down Expand Up @@ -151,17 +150,17 @@ final class LoginHandler: InfomaniakLoginDelegate, ObservableObject {
}

struct OnboardingView: View {
@Environment(\.dismiss) private var dismiss

@LazyInjectService var orientationManager: OrientationManageable

@Environment(\.dismiss) private var dismiss
@EnvironmentObject private var navigationState: NavigationState

@AppStorage(UserDefaults.shared.key(.accentColor)) private var accentColor = DefaultPreferences.accentColor

@State private var selection: Int
@State private var isPresentingCreateAccount = false
@StateObject private var loginHandler = LoginHandler()

private var isScrollEnabled: Bool
private var slides = Slide.onBoardingSlides

Expand All @@ -175,10 +174,7 @@ struct OnboardingView: View {
var body: some View {
VStack(spacing: 0) {
Group {
if !isScrollEnabled,
let slide = slides.first(where: { $0.id == selection }) {
SlideView(slide: slide, updateAnimationColors: updateAnimationColors)
} else {
if isScrollEnabled {
TabView(selection: $selection) {
ForEach(slides) { slide in
SlideView(slide: slide, updateAnimationColors: updateAnimationColors)
Expand All @@ -187,6 +183,8 @@ struct OnboardingView: View {
}
.tabViewStyle(.page)
.ignoresSafeArea(edges: .top)
} else if let slide = slides.first(where: { $0.id == selection }) {
SlideView(slide: slide)
}
}
.overlay(alignment: .top) {
Expand All @@ -206,7 +204,7 @@ struct OnboardingView: View {
.mailButtonLoading(loginHandler.isLoading)

MailButton(label: MailResourcesStrings.Localizable.buttonCreateAccount) {
isPresentingCreateAccount.toggle()
isPresentingCreateAccount = true
}
.mailButtonStyle(.link)
.disabled(loginHandler.isLoading)
Expand Down Expand Up @@ -240,12 +238,6 @@ struct OnboardingView: View {
} message: {
Text(MailResourcesStrings.Localizable.errorLoginDescription)
}
.sheet(isPresented: $isPresentingCreateAccount) {
RegisterView(registrationProcess: .mail) { viewController in
guard let viewController else { return }
loginHandler.loginAfterAccountCreation(from: viewController)
}
}
.onAppear {
if UIDevice.current.userInterfaceIdiom == .phone {
UIDevice.current
Expand All @@ -259,6 +251,10 @@ struct OnboardingView: View {
navigationState.transitionToRootViewDestination(.noMailboxes)
}
}
.matomoView(view: [MatomoUtils.View.onboarding.displayName, "Main"])
.sheet(isPresented: $isPresentingCreateAccount) {
CreateAccountView(loginHandler: loginHandler)
}
}

// MARK: - Private methods
Expand Down
97 changes: 97 additions & 0 deletions Mail/Views/Switch User/CreateAccountView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
Infomaniak Mail - iOS App
Copyright (C) 2022 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 InfomaniakCoreUI
import InfomaniakCreateAccount
import InfomaniakDI
import InfomaniakLogin
import MailCore
import MailResources
import SwiftUI

struct CreateAccountView: View {
@AppStorage(UserDefaults.shared.key(.accentColor)) private var accentColor = DefaultPreferences.accentColor

@State private var isPresentingCreateAccount = false

@ObservedObject var loginHandler: LoginHandler

var body: some View {
VStack(spacing: 0) {
accentColor.createAccountImage.swiftUIImage
.resizable()
.scaledToFit()
.padding(.top, 24)
.padding(.bottom, 48)

Text(MailResourcesStrings.Localizable.newAccountTitle)
.textStyle(.header1)
.multilineTextAlignment(.center)
.padding(.bottom, 24)

HStack {
Text(MailResourcesStrings.Localizable.newAccountStorageMail)
.textStyle(.labelMediumAccent)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.padding(8)
.background(accentColor.secondary.swiftUIColor)
.clipShape(Capsule())
.multilineTextAlignment(.center)
Text(MailResourcesStrings.Localizable.newAccountStorageDrive)
.textStyle(.labelMediumAccent)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.padding(8)
.background(accentColor.secondary.swiftUIColor)
.clipShape(Capsule())
.multilineTextAlignment(.center)
}
.fixedSize(horizontal: false, vertical: true)
.padding(.bottom, 24)

Text(MailResourcesStrings.Localizable.newAccountDescription)
.textStyle(.bodySmallSecondary)
.padding(.bottom, 24)
.multilineTextAlignment(.center)

Spacer()

MailButton(label: MailResourcesStrings.Localizable.buttonStart) {
@InjectService var matomo: MatomoUtils
matomo.track(eventWithCategory: .account, name: "openCreationWebview")
isPresentingCreateAccount = true
}
.mailButtonFullWidth(true)
.mailButtonLoading(loginHandler.isLoading)
.padding(.bottom, 24)
}
.padding(.horizontal, 24)
.sheet(isPresented: $isPresentingCreateAccount) {
RegisterView(registrationProcess: .mail) { viewController in
guard let viewController else { return }
loginHandler.loginAfterAccountCreation(from: viewController)
}
}
.matomoView(view: [MatomoUtils.View.onboarding.displayName, "CreateAccount"])
}
}

struct CreateAccountView_Previews: PreviewProvider {
static var previews: some View {
CreateAccountView(loginHandler: LoginHandler())
}
}
9 changes: 9 additions & 0 deletions MailCore/Models/Settings/AccentColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ public enum AccentColor: String, CaseIterable, SettingsOptionEnum {
}
}

public var createAccountImage: MailResourcesImages {
switch self {
case .pink:
return MailResourcesAsset.createAccountPink
case .blue:
return MailResourcesAsset.createAccountBlue
}
}

// MARK: Swipe settings icons

public var fullTrailingIcon: MailResourcesImages {
Expand Down
1 change: 1 addition & 0 deletions MailCore/Utils/Matomo+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import SwiftUI
public extension MatomoUtils.View {
static let accountView = MatomoUtils.View(displayName: "AccountView")
static let bottomSheet = MatomoUtils.View(displayName: "BottomSheet")
static let onboarding = MatomoUtils.View(displayName: "Onboarding")
static let threadListView = MatomoUtils.View(displayName: "ThreadListView")
static let threadView = MatomoUtils.View(displayName: "ThreadView")
static let settingsView = MatomoUtils.View(displayName: "SettingsView")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"images" : [
{
"filename" : "create-account-blue-light.svg",
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "create-account-blue-dark.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Loading
Loading