Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Handling enum case and icons
Browse files Browse the repository at this point in the history
  • Loading branch information
soner-yuksel committed Sep 8, 2023
1 parent f8de54e commit 1736474
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ extension BrowserViewController {
return
}

if receiptStatus != .retryPeriod {
if receiptStatus != BraveVPN.ReceiptResponse.Status.retryPeriod.rawValue {
return
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extension BrowserViewController {
func featuresMenuSection(_ menuController: MenuViewController) -> some View {
VStack(alignment: .leading, spacing: 5) {
VPNMenuButton(
retryStateActive: Preferences.VPN.vpnReceiptStatus.value == .retryPeriod,
retryStateActive: Preferences.VPN.vpnReceiptStatus.value == BraveVPN.ReceiptResponse.Status.retryPeriod.rawValue,
vpnProductInfo: self.vpnProductInfo,
displayVPNDestination: { [unowned self] vc in
(self.presentedViewController as? MenuViewController)?
Expand Down Expand Up @@ -55,7 +55,7 @@ extension BrowserViewController {
.padding(.bottom, 5)

VPNMenuButton(
retryStateActive: Preferences.VPN.vpnReceiptStatus.value == .retryPeriod,
retryStateActive: Preferences.VPN.vpnReceiptStatus.value == BraveVPN.ReceiptResponse.Status.retryPeriod.rawValue,
vpnProductInfo: self.vpnProductInfo,
description: Strings.OptionsMenu.braveVPNItemDescription,
displayVPNDestination: { [unowned self] vc in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ struct VPNMenuButton: View {

private var headerView: some View {
HStack(spacing: 14) {
Image(braveSystemName: retryStateActive ? "leo.vpn.error" : "leo.product.vpn")
Image(braveSystemName: retryStateActive ? "leo.warning.triangle-filled" : "leo.product.vpn")
.font(.body)
.frame(width: 32, height: 32)
.foregroundColor(retryStateActive ? Color(.braveErrorLabel) : Color(.braveLabel))
Expand Down
12 changes: 6 additions & 6 deletions Sources/Brave/Frontend/Settings/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ class SettingsViewController: TableViewController {
private func vpnSettingsRow() -> Row {

let (text, color) = { () -> (String, UIColor) in
if Preferences.VPN.vpnReceiptStatus.value == .retryPeriod {
if Preferences.VPN.vpnReceiptStatus.value == BraveVPN.ReceiptResponse.Status.retryPeriod.rawValue {
return (Strings.VPN.updateActionCellTitle, .braveErrorLabel)
}

Expand Down Expand Up @@ -597,11 +597,11 @@ class SettingsViewController: TableViewController {
guard let vcToShow = vc else { return }
self.navigationController?.pushViewController(vcToShow, animated: true)
},
image: Preferences.VPN.vpnReceiptStatus.value == .retryPeriod
? UIImage(braveSystemNamed: "leo.product.vpn")
: UIImage(braveSystemNamed: "leo.vpn.error")?
.withRenderingMode(.alwaysOriginal)
.withTintColor(.braveErrorLabel),
image: Preferences.VPN.vpnReceiptStatus.value == BraveVPN.ReceiptResponse.Status.retryPeriod.rawValue
? UIImage(braveSystemNamed: "leo.warning.triangle-filled")?
.withRenderingMode(.alwaysOriginal)
.withTintColor(.braveErrorLabel)
: UIImage(braveSystemNamed: "leo.product.vpn"),
accessory: .disclosureIndicator,
cellClass: ColoredDetailCell.self, context: [ColoredDetailCell.colorKey: color], uuid: "vpnrow")
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/BraveVPN/BraveVPN.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public class BraveVPN {
GRDSubscriptionManager.setIsPayingUser(true)
}

Preferences.VPN.vpnReceiptStatus.value = processedReceiptDetail.status
Preferences.VPN.vpnReceiptStatus.value = processedReceiptDetail.status.rawValue

receiptResponse?(processedReceiptDetail)
}
Expand Down Expand Up @@ -283,7 +283,7 @@ public class BraveVPN {
// MARK: - ReceiptResponse

public struct ReceiptResponse {
public enum Status: UserDefaultsEncodable {
public enum Status: Int {
case active, expired, retryPeriod
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/BraveVPN/BraveVPNPreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extension Preferences {
/// to make sure vpn expiration logic will be called.
public static let expirationDate = Option<Date?>(key: "vpn.expiration-date", default: nil)
/// The status of vpn receipt status, used to determine retry period
public static let vpnReceiptStatus = Option<BraveVPN.ReceiptResponse.Status?>(key: "vpn.expiration-date", default: nil)
public static let vpnReceiptStatus = Option<Int?>(key: "vpn.expiration-date", default: nil)
/// Whether free trial for the vpn expired for the user.
public static let freeTrialUsed = Option<Bool>(key: "vpn.free-trial-used", default: false)
/// First time after user background the app after after installing vpn, we show a notification to say that the vpn
Expand Down
6 changes: 3 additions & 3 deletions Sources/BraveVPN/BraveVPNSettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ public class BraveVPNSettingsViewController: TableViewController {
}
})

if Preferences.VPN.vpnReceiptStatus.value == .retryPeriod {
switchView.tintColor = .braveErrorLabel
if Preferences.VPN.vpnReceiptStatus.value == BraveVPN.ReceiptResponse.Status.retryPeriod.rawValue {
switchView.onTintColor = .braveErrorLabel
}

self.vpnConnectionStatusSwitch = switchView
Expand All @@ -120,7 +120,7 @@ public class BraveVPNSettingsViewController: TableViewController {
], uuid: vpnStatusSectionCellId)

let (subscriptionStatus, statusDetailColor) = { () -> (String, UIColor) in
if Preferences.VPN.vpnReceiptStatus.value == .retryPeriod {
if Preferences.VPN.vpnReceiptStatus.value == BraveVPN.ReceiptResponse.Status.retryPeriod.rawValue {
return (Strings.VPN.vpnActionUpdatePaymentMethodSettingsText, .braveErrorLabel)
}

Expand Down

0 comments on commit 1736474

Please sign in to comment.