-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PIA-1274: Add expired account view for tvOS (#125)
* PIA-1274: Add expired account view for tvOS * PIA-1274: Moved expiring state handling to RootContainerViewModel
- Loading branch information
1 parent
d2902c4
commit 35a656b
Showing
17 changed files
with
378 additions
and
11 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
PIA VPN-tvOS/ExpiredAccount/CompositionRoot/ExpiredAccountFactory.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// ExpiredAccountFactory.swift | ||
// PIA VPN-tvOS | ||
// | ||
// Created by Said Rehouni on 20/3/24. | ||
// Copyright © 2024 Private Internet Access Inc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
class ExpiredAccountFactory { | ||
static func makeExpiredAccountView() -> ExpiredAccountView { | ||
ExpiredAccountView(viewModel: makeExpiredAccountViewModel()) | ||
} | ||
|
||
static private func makeExpiredAccountViewModel() -> ExpiredAccountViewModel { | ||
let qrTitle = [ | ||
L10n.Localizable.Tvos.Signin.Expired.Qr.title1, | ||
L10n.Localizable.Tvos.Signin.Expired.Qr.title2 | ||
] | ||
|
||
let buttonsTitle = [ | ||
L10n.Localizable.Tvos.Signin.Expired.Button.renewed, | ||
L10n.Localizable.Tvos.Signin.Expired.Button.signout | ||
] | ||
|
||
|
||
let separation = L10n.Localizable.Settings.Dedicatedip.Status.expired.lowercased() | ||
let titleSeparated = L10n.Localizable.Tvos.Signin.Expired.title.replacingOccurrences(of: separation, with: "") | ||
|
||
return ExpiredAccountViewModel(title1: titleSeparated, | ||
title2: separation, | ||
subtitle: L10n.Localizable.Tvos.Signin.Expired.subtitle, | ||
qrTitle: qrTitle, | ||
qrCodeURL: URL(string: "https://apps.apple.com/us/app/vpn-by-private-internet-access/id955626407"), | ||
logOutUseCase: SettingsFactory.makeLogOutUseCase()) | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
PIA VPN-tvOS/ExpiredAccount/Presentation/ExpiredAccountViewModel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// ExpiredAccountViewModel.swift | ||
// PIA VPN-tvOS | ||
// | ||
// Created by Said Rehouni on 20/3/24. | ||
// Copyright © 2024 Private Internet Access Inc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
class ExpiredAccountViewModel { | ||
let title1: String | ||
let title2: String? | ||
let subtitle: String | ||
let qrTitle: [String] | ||
let qrCodeURL: URL? | ||
|
||
@Published var isLoading: Bool = false | ||
private let logOutUseCase: LogOutUseCaseType | ||
|
||
init(title1: String, title2: String?, subtitle: String, qrTitle: [String], qrCodeURL: URL?, logOutUseCase: LogOutUseCaseType) { | ||
self.title1 = title1 | ||
self.title2 = title2 | ||
self.subtitle = subtitle | ||
self.qrTitle = qrTitle | ||
self.qrCodeURL = qrCodeURL | ||
self.logOutUseCase = logOutUseCase | ||
} | ||
|
||
func logout() { | ||
Task { | ||
do { | ||
setLoading(to: true) | ||
try await logOutUseCase.logOut() | ||
setLoading(to: false) | ||
} catch { | ||
setLoading(to: false) | ||
} | ||
} | ||
} | ||
|
||
private func setLoading(to loading: Bool) { | ||
DispatchQueue.main.async { [weak self] in | ||
self?.isLoading = loading | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// | ||
// ExpiredAccountView.swift | ||
// PIA VPN-tvOS | ||
// | ||
// Created by Said Rehouni on 20/3/24. | ||
// Copyright © 2024 Private Internet Access Inc. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct ExpiredAccountView: View { | ||
var viewModel: ExpiredAccountViewModel | ||
|
||
var body: some View { | ||
if viewModel.isLoading { | ||
LoginLoadingView() | ||
} else { | ||
HStack { | ||
VStack(alignment: .leading, spacing: 50) { | ||
VStack(alignment: .leading, spacing: 35) { | ||
HStack(spacing: 0) { | ||
Text(viewModel.title1) | ||
.font(.system(size: 57)) | ||
.foregroundColor(.piaOnBackground) | ||
.bold() | ||
|
||
if let title2 = viewModel.title2 { | ||
Text(title2) | ||
.font(.system(size: 57)) | ||
.foregroundColor(.piaError) | ||
.bold() | ||
.fixedSize(horizontal: false, vertical: true) | ||
} | ||
} | ||
|
||
Text(viewModel.subtitle) | ||
.font(.system(size: 31)) | ||
.foregroundColor(.piaOnSurfaceContainerSecondary) | ||
.fixedSize(horizontal: false, vertical: true) | ||
} | ||
|
||
HStack(spacing: 30) { | ||
if let qrCodeURL = viewModel.qrCodeURL { | ||
QRImageView(qrImageURL: qrCodeURL) | ||
} | ||
|
||
VStack(alignment: .leading, spacing: 35) { | ||
ForEach(viewModel.qrTitle, id: \.self) { title in | ||
Text(title) | ||
.font(.system(size: 29)) | ||
.foregroundColor(.piaOnSurfaceContainerSecondary) | ||
.fixedSize(horizontal: false, vertical: true) | ||
} | ||
} | ||
}.padding(EdgeInsets(top: 0, leading: 0, bottom: 15, trailing: 0)) | ||
|
||
VStack { | ||
ActionButton( | ||
title: L10n.Localizable.Tvos.Signin.Expired.Button.signout, | ||
action: { viewModel.logout() } | ||
) | ||
.frame(width: 510, height: 66) | ||
} | ||
} | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
.padding(EdgeInsets(top: 0, leading: 30, bottom: 0, trailing: 0)) | ||
|
||
Image.signup_setup_screen | ||
.frame(maxWidth: .infinity, alignment: .trailing) | ||
.padding(.trailing) | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.