Skip to content

Commit

Permalink
Move privacy to main setting. Make stats only for premium
Browse files Browse the repository at this point in the history
  • Loading branch information
ant013 committed Jan 23, 2025
1 parent 3d2c2fe commit 8e60ab6
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 151 deletions.
18 changes: 12 additions & 6 deletions UnstoppableWallet/UnstoppableWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1393,13 +1393,11 @@
1A5643C5A8BBFD6F2DC8C734 /* BtcRestoreMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A564BE241BFC5DD59D0FB7C /* BtcRestoreMode.swift */; };
1A5643C73BEDA01E4E378BEF /* ZcashAddressParserItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A5642E923141415CCFC9167 /* ZcashAddressParserItem.swift */; };
1A5643CFF5657C9C6B7DBA19 /* ThemeSearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A564EA6F1CCDF88F78351F8 /* ThemeSearchViewController.swift */; };
1A5643D323BAB0B8B45A9038 /* PrivacyPolicyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A564CE10FD5FEC14EF38BD8 /* PrivacyPolicyViewController.swift */; };
1A5643D7C72CDCB87E3D5F17 /* SendTransactionError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A56422C196B48931CDE1445 /* SendTransactionError.swift */; };
1A564406716193E4A2D9075F /* ReachabilityViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A564814721244F4D4D87557 /* ReachabilityViewModel.swift */; };
1A56440AD78BD32AEAE2A2EA /* PlaceholderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A5644A21F9FEC4E2A7B0860 /* PlaceholderView.swift */; };
1A56441AD76BA80CB74902CB /* TraitCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A5648911028181BB1462CFE /* TraitCell.swift */; };
1A5644271F4CD209136352EE /* FilterHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A564B1C051AF2C87C670563 /* FilterHeaderView.swift */; };
1A56444313F5FB0DE9B06BE4 /* PrivacyPolicyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A564CE10FD5FEC14EF38BD8 /* PrivacyPolicyViewController.swift */; };
1A5644CF2BEC2E7C6227BDC7 /* AppStatusModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A56404C1C16B85434117DB7 /* AppStatusModule.swift */; };
1A5644FE2885F71299CC66EA /* PlaceholderViewModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A564CF35E7A07E96B704ADA /* PlaceholderViewModule.swift */; };
1A564504E164177DD6EECFBA /* BalanceErrorService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A5646B5D68A302515565030 /* BalanceErrorService.swift */; };
Expand Down Expand Up @@ -1863,6 +1861,10 @@
6BB14F7E2C05FBB000E879B2 /* MarketTvlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6BB14F792C05FAB600E879B2 /* MarketTvlView.swift */; };
6BB14F802C06F19300E879B2 /* DefiCoin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6BB14F7F2C06F19300E879B2 /* DefiCoin.swift */; };
6BB14F812C06F19300E879B2 /* DefiCoin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6BB14F7F2C06F19300E879B2 /* DefiCoin.swift */; };
6BB6E75A2D4218BB00C1EA66 /* PrivacyPolicyViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6BB6E7592D4218BB00C1EA66 /* PrivacyPolicyViewModel.swift */; };
6BB6E75B2D4218BB00C1EA66 /* PrivacyPolicyViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6BB6E7592D4218BB00C1EA66 /* PrivacyPolicyViewModel.swift */; };
6BB6E75D2D42354600C1EA66 /* PrivacyPolicyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6BB6E75C2D42354600C1EA66 /* PrivacyPolicyView.swift */; };
6BB6E75E2D42354600C1EA66 /* PrivacyPolicyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6BB6E75C2D42354600C1EA66 /* PrivacyPolicyView.swift */; };
6BBB92A82D0D18AF00112409 /* RoundedCorner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B7EB8252D0D11E900783F66 /* RoundedCorner.swift */; };
6BBB92A92D0D18CD00112409 /* RoundedCorner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B7EB8252D0D11E900783F66 /* RoundedCorner.swift */; };
6BBB92AA2D0D18CE00112409 /* RoundedCorner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B7EB8252D0D11E900783F66 /* RoundedCorner.swift */; };
Expand Down Expand Up @@ -3987,7 +3989,6 @@
1A564C46FB773A67E29D9D32 /* BlockchainSettingRecord.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlockchainSettingRecord.swift; sourceTree = "<group>"; };
1A564C4B0D13BC7214419A3E /* GradientClippingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GradientClippingView.swift; sourceTree = "<group>"; };
1A564CB28708314AE0A69424 /* TitledHighlightedDescriptionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TitledHighlightedDescriptionView.swift; sourceTree = "<group>"; };
1A564CE10FD5FEC14EF38BD8 /* PrivacyPolicyViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PrivacyPolicyViewController.swift; sourceTree = "<group>"; };
1A564CE56CEC73B78C9DB6B5 /* BalanceErrorViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BalanceErrorViewController.swift; sourceTree = "<group>"; };
1A564CF35E7A07E96B704ADA /* PlaceholderViewModule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlaceholderViewModule.swift; sourceTree = "<group>"; };
1A564D2011D7A4E80B2B7B92 /* JailbreakTestManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JailbreakTestManager.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4201,6 +4202,8 @@
6BB14F792C05FAB600E879B2 /* MarketTvlView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarketTvlView.swift; sourceTree = "<group>"; };
6BB14F7A2C05FAB600E879B2 /* MarketTvlViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarketTvlViewModel.swift; sourceTree = "<group>"; };
6BB14F7F2C06F19300E879B2 /* DefiCoin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefiCoin.swift; sourceTree = "<group>"; };
6BB6E7592D4218BB00C1EA66 /* PrivacyPolicyViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacyPolicyViewModel.swift; sourceTree = "<group>"; };
6BB6E75C2D42354600C1EA66 /* PrivacyPolicyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacyPolicyView.swift; sourceTree = "<group>"; };
6BBB92AC2D0FD43D00112409 /* PurchaseBottomSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PurchaseBottomSheetView.swift; sourceTree = "<group>"; };
6BBB92AF2D10095300112409 /* SubscribePeriodSegmentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscribePeriodSegmentView.swift; sourceTree = "<group>"; };
6BBB92B22D10142900112409 /* PurchaseBottomSheetViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PurchaseBottomSheetViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6864,7 +6867,8 @@
1A5648A0CFE0BED4703D9794 /* Privacy */ = {
isa = PBXGroup;
children = (
1A564CE10FD5FEC14EF38BD8 /* PrivacyPolicyViewController.swift */,
6BB6E7592D4218BB00C1EA66 /* PrivacyPolicyViewModel.swift */,
6BB6E75C2D42354600C1EA66 /* PrivacyPolicyView.swift */,
);
path = Privacy;
sourceTree = "<group>";
Expand Down Expand Up @@ -9355,6 +9359,7 @@
D008CA67267C8E1800001E0A /* ApproveTransactionRecord.swift in Sources */,
D09D768F2A2E06D6004311E6 /* SendTronConfirmationViewController.swift in Sources */,
D0A690262BFCB51800E59296 /* TronPresendHandler.swift in Sources */,
6BB6E75E2D42354600C1EA66 /* PrivacyPolicyView.swift in Sources */,
D384057F218317DF007D50AD /* LaunchService.swift in Sources */,
D3840581218317DF007D50AD /* App.swift in Sources */,
D3840583218317DF007D50AD /* BlurManager.swift in Sources */,
Expand Down Expand Up @@ -9924,6 +9929,7 @@
11B351767B71D6C42A23C518 /* NftCollectionRecord.swift in Sources */,
11B35C8D53F838E7E5CA6EEC /* NftStorage.swift in Sources */,
2FA5D1897F90F77E6D9076AB /* LegacyEvmFeeDataSource.swift in Sources */,
6BB6E75B2D4218BB00C1EA66 /* PrivacyPolicyViewModel.swift in Sources */,
D3DD67262BC3BEC100EC7F78 /* BaseUniswapMultiSwapConfirmationQuote.swift in Sources */,
2FA5D3893C3B6F2270F857C7 /* SendEvmCautionsFactory.swift in Sources */,
2FA5D4EB5405131B9635E958 /* FeeCell.swift in Sources */,
Expand Down Expand Up @@ -10069,7 +10075,6 @@
11B350F9E67A095998D9462C /* BalanceConversionManager.swift in Sources */,
11B35D11D00301F7B67B0340 /* AppIconManager.swift in Sources */,
11B35B0E1435737240D26C92 /* AppIcon.swift in Sources */,
1A5643D323BAB0B8B45A9038 /* PrivacyPolicyViewController.swift in Sources */,
11B359C5A1F97662FDD57259 /* RestoreSettingRecord_v_0_25.swift in Sources */,
11B35F45249FDF026B27F06F /* EnabledWallet_v_0_25.swift in Sources */,
11B355B5E78279B792F102BB /* CoinType.swift in Sources */,
Expand Down Expand Up @@ -10846,6 +10851,7 @@
D008CA66267C8E1800001E0A /* ApproveTransactionRecord.swift in Sources */,
D384066E21831B3D007D50AD /* LaunchService.swift in Sources */,
D0A690252BFCB51800E59296 /* TronPresendHandler.swift in Sources */,
6BB6E75D2D42354600C1EA66 /* PrivacyPolicyView.swift in Sources */,
D384067021831B3D007D50AD /* App.swift in Sources */,
D384067221831B3D007D50AD /* BlurManager.swift in Sources */,
D384067421831B3D007D50AD /* MainSettingsModule.swift in Sources */,
Expand Down Expand Up @@ -11415,6 +11421,7 @@
58AAAE0E85B0DFB61C94E14D /* BitcoinAddressParserItem.swift in Sources */,
1A5645C7334EED7FF57FFD47 /* DashAddressParserItem.swift in Sources */,
1A564AB8471E098F68FDB9D7 /* BinanceAddressParserItem.swift in Sources */,
6BB6E75A2D4218BB00C1EA66 /* PrivacyPolicyViewModel.swift in Sources */,
1A5643C73BEDA01E4E378BEF /* ZcashAddressParserItem.swift in Sources */,
D3DD67252BC3BEC100EC7F78 /* BaseUniswapMultiSwapConfirmationQuote.swift in Sources */,
11B35837076F6B350DFA89E7 /* NftDatabaseStorage.swift in Sources */,
Expand Down Expand Up @@ -11565,7 +11572,6 @@
11B35D71C5893D4B1F1332B5 /* BalanceConversionManager.swift in Sources */,
11B35A7DFBD8FB2E663C97FE /* AppIconManager.swift in Sources */,
11B355A7C40EADCE1921CEF5 /* AppIcon.swift in Sources */,
1A56444313F5FB0DE9B06BE4 /* PrivacyPolicyViewController.swift in Sources */,
11B357355C6AC09A7B6F8AF3 /* RestoreSettingRecord_v_0_25.swift in Sources */,
11B3516E6F489646368A4DDE /* EnabledWallet_v_0_25.swift in Sources */,
11B35531B3F80D06EF040301 /* CoinType.swift in Sources */,
Expand Down
5 changes: 3 additions & 2 deletions UnstoppableWallet/UnstoppableWallet/Core/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,14 @@ class App {
logger: logger
)

purchaseManager = PurchaseManager()

let statStorage = StatStorage(dbPool: dbPool)
statManager = StatManager(marketKit: marketKit, storage: statStorage, userDefaultsStorage: userDefaultsStorage)
statManager = StatManager(marketKit: marketKit, storage: statStorage, userDefaultsStorage: userDefaultsStorage, purchaseManager: purchaseManager)

let tonConnectStorage = try TonConnectStorage(dbPool: dbPool)
tonConnectManager = TonConnectManager(storage: tonConnectStorage, accountManager: accountManager)

purchaseManager = PurchaseManager()

kitCleaner = KitCleaner(accountManager: accountManager)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class StatManager {
private let marketKit: MarketKit.Kit
private let storage: StatStorage
private let userDefaultsStorage: UserDefaultsStorage
private let purchaseManager: PurchaseManager
private let appVersion: String
private let appId: String?

Expand All @@ -33,18 +34,19 @@ class StatManager {
allowedSubject.eraseToAnyPublisher()
}

init(marketKit: MarketKit.Kit, storage: StatStorage, userDefaultsStorage: UserDefaultsStorage) {
init(marketKit: MarketKit.Kit, storage: StatStorage, userDefaultsStorage: UserDefaultsStorage, purchaseManager: PurchaseManager) {
self.marketKit = marketKit
self.storage = storage
self.userDefaultsStorage = userDefaultsStorage
self.purchaseManager = purchaseManager

appVersion = AppConfig.appVersion
appId = AppConfig.appId
allowed = userDefaultsStorage.value(for: StatManager.keySendingAllowed) ?? true
}

func logStat(eventPage: StatPage, eventSection: StatSection? = nil, event: StatEvent) {
guard allowed else { return }
guard purchaseManager.subscription == nil || allowed else { return }
var parameters: [String: Any]?

if let params = event.params {
Expand All @@ -71,7 +73,7 @@ class StatManager {
}

func sendStats() {
guard allowed else { return }
guard purchaseManager.subscription == nil || allowed else { return }
let lastSent: Double? = userDefaultsStorage.value(for: Self.keyLastSent)

if let lastSent, Date().timeIntervalSince1970 - lastSent < Self.sendThreshold {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,6 @@ struct AboutView: View {

Image.disclosureIcon
}

NavigationRow(destination: {
PrivacyPolicyView(config: .privacy)
.navigationTitle(PrivacyPolicyViewController.Config.privacy.title)
.onFirstAppear { stat(page: .aboutApp, event: .open(page: .privacy)) }
.ignoresSafeArea()
}) {
Image("user_24").themeIcon()
Text("settings.privacy".localized).themeBody()
Image.disclosureIcon
}
}

ListSection {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class MainSettingsViewController: ThemeViewController {
private let walletConnectCell = BaseSelectableThemeCell()
private let tonConnectCell = BaseSelectableThemeCell()
private let securityCell = BaseSelectableThemeCell()
private let privacyCell = BaseSelectableThemeCell()
private let appearanceCell = BaseSelectableThemeCell()
private let subscriptionCell = BaseSelectableThemeCell()
private let contactBookCell = BaseSelectableThemeCell()
Expand Down Expand Up @@ -80,6 +81,9 @@ class MainSettingsViewController: ThemeViewController {
securityCell.set(backgroundStyle: .lawrence, isFirst: true)
syncSecurityCell()

privacyCell.set(backgroundStyle: .lawrence)
buildTitleValue(cell: privacyCell, image: UIImage(named: "eye_2_24"), title: "settings.privacy".localized)

appearanceCell.set(backgroundStyle: .lawrence)
buildTitleValue(cell: appearanceCell, image: UIImage(named: "brush_24"), title: "appearance.title".localized)

Expand Down Expand Up @@ -321,6 +325,17 @@ class MainSettingsViewController: ThemeViewController {
stat(page: .settings, event: .open(page: .security))
}
),
StaticRow(
cell: privacyCell,
id: "privacy",
height: .heightCell48,
action: { [weak self] in
let viewController = PrivacyPolicyView(config: .privacy).toViewController(title: "settings.privacy".localized)

self?.navigationController?.pushViewController(viewController, animated: true)
stat(page: .settings, event: .open(page: .privacy))
}
),
StaticRow(
cell: contactBookCell,
id: "address-book",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import SwiftUI

struct PrivacyPolicyView: View {
@StateObject var viewModel: PrivacyPolicyViewModel

@State var subscriptionPresented = false

init(config: PrivacyPolicyViewModel.Config) {
_viewModel = StateObject(wrappedValue: PrivacyPolicyViewModel(config: config))
}

var body: some View {
ScrollableThemeView {
VStack(spacing: .margin24) {
HighlightedTextView(text: viewModel.config.description)

VStack(spacing: 0) {
PremiumListSectionHeader()
ListSection {
premiumRow(statsRow())
}
.modifier(ColoredBorder())
ListSectionFooter(text: "settings.privacy.allow.description".localized)
}
}
.padding(EdgeInsets(top: .margin12, leading: .margin16, bottom: .margin32, trailing: .margin16))
.sheet(isPresented: $subscriptionPresented) {
PurchasesView()
}
}
.navigationTitle("settings.privacy".localized)
.navigationBarTitleDisplayMode(.inline)
}

@ViewBuilder private func premiumRow(_ view: some View) -> some View {
if viewModel.premiumEnabled {
ListRow {
view
}
} else {
ClickableRow {
subscriptionPresented = true
} content: {
view
}
}
}

@ViewBuilder private func statsRow() -> some View {
Toggle(isOn: Binding(get: { viewModel.statsEnabled }, set: { viewModel.set(allowed: $0) })) {
HStack(spacing: .margin16) {
Image("share_1_24").themeIcon(color: .themeJacob)
Text("settings.privacy.allow".localized).themeBody()
}
}
.allowsHitTesting(viewModel.premiumEnabled)
.toggleStyle(SwitchToggleStyle(tint: .themeYellow))
}
}
Loading

0 comments on commit 8e60ab6

Please sign in to comment.