Skip to content

Commit

Permalink
Account Settings Cleanup - Support / FAQ / Email (2U) (#198)
Browse files Browse the repository at this point in the history
* chore: add faq, open in browser screen

* chore: merge develop to branch

* chore: add new links Cookie Policy,  Do Not Sell my Personal Information and refactor

* chore: add folder subviews to profile

* chore: add support language to support urls

* chore: add create button

* chore: add tests

* chore: fix language local

* chore: changes PR feedback

* chore: change strings

* chore: change strings

* chore: changes from PR feedback

* chore:  add progress to web browser

* chore: show always progress when web page loading

* chore: add show progress param to web browser
  • Loading branch information
eyatsenkoperpetio authored Dec 18, 2023
1 parent 7647134 commit e58a7cd
Show file tree
Hide file tree
Showing 12 changed files with 567 additions and 314 deletions.
8 changes: 6 additions & 2 deletions Core/Core.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
0770DE5F28D0B22C006D8A5D /* Strings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0770DE5E28D0B22C006D8A5D /* Strings.swift */; };
0770DE6128D0B2CB006D8A5D /* Assets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0770DE6028D0B2CB006D8A5D /* Assets.swift */; };
07DDFCBD29A780BB00572595 /* UINavigationController+Animation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07DDFCBC29A780BB00572595 /* UINavigationController+Animation.swift */; };
BAAD62C62AFCF00B000E6103 /* CustomDisclosureGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAAD62C52AFCF00B000E6103 /* CustomDisclosureGroup.swift */; };
BA30427F2B20B320009B64B7 /* SocialAuthError.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA30427D2B20B299009B64B7 /* SocialAuthError.swift */; };
BA76135C2B21BC7300B599B7 /* SocialAuthResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA76135B2B21BC7300B599B7 /* SocialAuthResponse.swift */; };
BA8B3A2F2AD546A700D25EF5 /* DebugLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA8B3A2E2AD546A700D25EF5 /* DebugLog.swift */; };
Expand All @@ -128,6 +127,8 @@
BA8FA66C2AD59BBC00EA029A /* GoogleSignIn in Frameworks */ = {isa = PBXBuildFile; productRef = BA8FA66B2AD59BBC00EA029A /* GoogleSignIn */; };
BA8FA66E2AD59E7D00EA029A /* FacebookAuthProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA8FA66D2AD59E7D00EA029A /* FacebookAuthProvider.swift */; };
BA8FA6702AD59EA300EA029A /* MicrosoftAuthProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA8FA66F2AD59EA300EA029A /* MicrosoftAuthProvider.swift */; };
BAAD62C62AFCF00B000E6103 /* CustomDisclosureGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAAD62C52AFCF00B000E6103 /* CustomDisclosureGroup.swift */; };
BAD9CA422B2B140100DE790A /* AgreementConfigTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAD9CA412B2B140100DE790A /* AgreementConfigTests.swift */; };
BADB3F5B2AD6EC56004D5CFA /* ResultExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BADB3F5A2AD6EC56004D5CFA /* ResultExtension.swift */; };
BAF0D4CB2AD6AE14007AC334 /* FacebookLogin in Frameworks */ = {isa = PBXBuildFile; productRef = BAF0D4CA2AD6AE14007AC334 /* FacebookLogin */; };
BAFB99822B0E2354007D09F9 /* FacebookConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAFB99812B0E2354007D09F9 /* FacebookConfig.swift */; };
Expand Down Expand Up @@ -289,7 +290,6 @@
3B74C6685E416657F3C5F5A8 /* Pods-App-Core.releaseprod.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Core.releaseprod.xcconfig"; path = "Target Support Files/Pods-App-Core/Pods-App-Core.releaseprod.xcconfig"; sourceTree = "<group>"; };
60153262DBC2F9E660D7E11B /* Pods-App-Core.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Core.release.xcconfig"; path = "Target Support Files/Pods-App-Core/Pods-App-Core.release.xcconfig"; sourceTree = "<group>"; };
9D5B06CAA99EA5CD49CBE2BB /* Pods-App-Core.debugdev.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Core.debugdev.xcconfig"; path = "Target Support Files/Pods-App-Core/Pods-App-Core.debugdev.xcconfig"; sourceTree = "<group>"; };
BAAD62C52AFCF00B000E6103 /* CustomDisclosureGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomDisclosureGroup.swift; sourceTree = "<group>"; };
BA30427D2B20B299009B64B7 /* SocialAuthError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocialAuthError.swift; sourceTree = "<group>"; };
BA76135B2B21BC7300B599B7 /* SocialAuthResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocialAuthResponse.swift; sourceTree = "<group>"; };
BA8B3A2E2AD546A700D25EF5 /* DebugLog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebugLog.swift; sourceTree = "<group>"; };
Expand All @@ -298,6 +298,8 @@
BA8FA6692AD59B5500EA029A /* GoogleAuthProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoogleAuthProvider.swift; sourceTree = "<group>"; };
BA8FA66D2AD59E7D00EA029A /* FacebookAuthProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FacebookAuthProvider.swift; sourceTree = "<group>"; };
BA8FA66F2AD59EA300EA029A /* MicrosoftAuthProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MicrosoftAuthProvider.swift; sourceTree = "<group>"; };
BAAD62C52AFCF00B000E6103 /* CustomDisclosureGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomDisclosureGroup.swift; sourceTree = "<group>"; };
BAD9CA412B2B140100DE790A /* AgreementConfigTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgreementConfigTests.swift; sourceTree = "<group>"; };
BADB3F5A2AD6EC56004D5CFA /* ResultExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResultExtension.swift; sourceTree = "<group>"; };
BAFB99812B0E2354007D09F9 /* FacebookConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FacebookConfig.swift; sourceTree = "<group>"; };
BAFB99832B0E282E007D09F9 /* MicrosoftConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MicrosoftConfig.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -718,6 +720,7 @@
isa = PBXGroup;
children = (
E09179FC2B0F204D002AB695 /* ConfigTests.swift */,
BAD9CA412B2B140100DE790A /* AgreementConfigTests.swift */,
);
path = Configuration;
sourceTree = "<group>";
Expand Down Expand Up @@ -902,6 +905,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BAD9CA422B2B140100DE790A /* AgreementConfigTests.swift in Sources */,
E09179FD2B0F204E002AB695 /* ConfigTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
50 changes: 47 additions & 3 deletions Core/Core/Configuration/Config/AgreementConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,60 @@ import Foundation
private enum AgreementKeys: String {
case privacyPolicyURL = "PRIVACY_POLICY_URL"
case tosURL = "TOS_URL"
case cookiePolicyURL = "COOKIE_POLICY_URL"
case dataSellContentURL = "DATA_SELL_CONSENT_URL"
case supportedLanguages = "SUPPORTED_LANGUAGES"
}

public class AgreementConfig: NSObject {
public var privacyPolicyURL: URL?
public var tosURL: URL?

public var cookiePolicyURL: URL?
public var dataSellContentURL: URL?
public var supportedLanguages: [String]?

init(dictionary: [String: AnyObject]) {
privacyPolicyURL = (dictionary[AgreementKeys.privacyPolicyURL.rawValue] as? String).flatMap(URL.init)
tosURL = (dictionary[AgreementKeys.tosURL.rawValue] as? String).flatMap(URL.init)
supportedLanguages = dictionary[AgreementKeys.supportedLanguages.rawValue] as? [String]
cookiePolicyURL = (dictionary[AgreementKeys.cookiePolicyURL.rawValue] as? String).flatMap(URL.init)
dataSellContentURL = (dictionary[AgreementKeys.dataSellContentURL.rawValue] as? String).flatMap(URL.init)

super.init()

if let tosURL = dictionary[AgreementKeys.tosURL.rawValue] as? String {
self.tosURL = URL(string: completePath(url: tosURL))
}

if let privacyPolicyURL = dictionary[AgreementKeys.privacyPolicyURL.rawValue] as? String {
self.privacyPolicyURL = URL(string: completePath(url: privacyPolicyURL))
}
}

private func completePath(url: String) -> String {
let langCode: String
if #available(iOS 16, *) {
langCode = Locale.current.language.languageCode?.identifier ?? ""
} else {
langCode = Locale.current.languageCode ?? ""
}

if let supportedLanguages = supportedLanguages,
!supportedLanguages.contains(langCode) {
return url
}

let URL = URL(string: url)
let host = URL?.host ?? ""
let components = url.components(separatedBy: host)

if components.count != 2 {
return url
}

if let firstComponent = components.first, let lastComponent = components.last {
return "\(firstComponent)\(host)/\(langCode)\(lastComponent)"
}

return url
}
}

Expand Down
15 changes: 14 additions & 1 deletion Core/Core/Configuration/Config/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public protocol ConfigProtocol {
var tokenType: TokenType { get }
var feedbackEmail: String { get }
var appStoreLink: String { get }
var faq: URL? { get }
var platformName: String { get }
var agreement: AgreementConfig { get }
var firebase: FirebaseConfig { get }
Expand All @@ -38,6 +39,7 @@ private enum ConfigKeys: String {
case platformName = "PLATFORM_NAME"
case organizationCode = "ORGANIZATION_CODE"
case appstoreID = "APP_STORE_ID"
case faq = "FAQ_URL"
}

public class Config {
Expand Down Expand Up @@ -137,6 +139,14 @@ extension Config: ConfigProtocol {
public var appStoreLink: String {
"itms-apps://itunes.apple.com/app/id\(appStoreId)?mt=8"
}

public var faq: URL? {
guard let urlString = string(for: ConfigKeys.faq.rawValue),
let url = URL(string: urlString) else {
return nil
}
return url
}
}

// Mark - For testing and SwiftUI preview
Expand All @@ -151,7 +161,10 @@ public class ConfigMock: Config {
"WHATS_NEW_ENABLED": false,
"AGREEMENT_URLS": [
"PRIVACY_POLICY_URL": "https://www.example.com/privacy",
"TOS_URL": "https://www.example.com/tos"
"TOS_URL": "https://www.example.com/tos",
"DATA_SELL_CONSENT_URL": "https://www.example.com/sell",
"COOKIE_POLICY_URL": "https://www.example.com/cookie",
"SUPPORTED_LANGUAGES": ["es"]
],
"GOOGLE": [
"ENABLED": true,
Expand Down
66 changes: 40 additions & 26 deletions Core/Core/View/Base/WebBrowser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,56 @@ import WebKit
import Theme

public struct WebBrowser: View {

var url: String
var pageTitle: String
@State private var isShowProgress: Bool = true

@State private var isLoading: Bool = true
@Environment(\.presentationMode) var presentationMode

private var url: String
private var pageTitle: String
private var showProgress: Bool

public init(url: String, pageTitle: String) {
public init(url: String, pageTitle: String, showProgress: Bool = false) {
self.url = url
self.pageTitle = pageTitle
self.showProgress = showProgress
}

public var body: some View {
ZStack(alignment: .top) {
Theme.Colors.background.ignoresSafeArea()
// MARK: - Page name
VStack(alignment: .center) {
NavigationBar(title: pageTitle,
leftButtonAction: { presentationMode.wrappedValue.dismiss() })

// MARK: - Page Body
VStack {
ZStack(alignment: .top) {
// NavigationView {
WebView(
viewModel: .init(url: url, baseURL: ""),
isLoading: $isShowProgress,
refreshCookies: {}
)

// }
}.navigationBarTitle(Text("")) // Needed for hide navBar on ios 14, 15
.navigationBarHidden(true)
.ignoresSafeArea()
GeometryReader { proxy in
ZStack(alignment: .center) {
Theme.Colors.background.ignoresSafeArea()
webView(proxy: proxy)
if isLoading, showProgress {
HStack(alignment: .center) {
ProgressBar(
size: 40,
lineWidth: 8
)
.padding(20)
}
.frame(maxWidth: .infinity)
}
}
.navigationBarTitle(Text(""))
.navigationBarHidden(true)
.ignoresSafeArea()
}
}

private func webView(proxy: GeometryProxy) -> some View {
VStack(alignment: .center) {
NavigationBar(
title: pageTitle,
leftButtonAction: { presentationMode.wrappedValue.dismiss() }
)
WebView(
viewModel: .init(url: url, baseURL: ""),
isLoading: $isLoading,
refreshCookies: {}
)
}
.padding(.top, proxy.safeAreaInsets.top)
.padding(.bottom, proxy.safeAreaInsets.bottom)
}
}

Expand Down
38 changes: 38 additions & 0 deletions Core/CoreTests/Configuration/AgreementConfigTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// AgreementConfigTests.swift
// CoreTests
//
// Created by Eugene Yatsenko on 14.12.2023.
//

import XCTest
@testable import Core

class AgreementConfigTests: XCTestCase {

private let privacy = "https://www.example.com/privacy"
private let tos = "https://www.example.com/tos"
private let dataSellContent = "https://www.example.com/sell"
private let cookie = "https://www.example.com/cookie"
private let supportedLanguages = ["es"]

private lazy var properties: [String: Any] = [
"AGREEMENT_URLS": [
"PRIVACY_POLICY_URL": privacy,
"TOS_URL": tos,
"DATA_SELL_CONSENT_URL": dataSellContent,
"COOKIE_POLICY_URL": cookie,
"SUPPORTED_LANGUAGES": supportedLanguages
]
]

func testAgreementConfigInitialization() {
let config = Config(properties: properties)

XCTAssertEqual(config.agreement.privacyPolicyURL, URL(string: privacy))
XCTAssertEqual(config.agreement.tosURL, URL(string: tos))
XCTAssertEqual(config.agreement.cookiePolicyURL, URL(string: cookie))
XCTAssertEqual(config.agreement.dataSellContentURL, URL(string: dataSellContent))
XCTAssertEqual(config.agreement.supportedLanguages, supportedLanguages)
}
}
12 changes: 4 additions & 8 deletions Core/CoreTests/Configuration/ConfigTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ class ConfigTests: XCTestCase {
"WHATS_NEW_ENABLED": true,
"AGREEMENT_URLS": [
"PRIVACY_POLICY_URL": "https://www.example.com/privacy",
"TOS_URL": "https://www.example.com/tos"
"TOS_URL": "https://www.example.com/tos",
"DATA_SELL_CONSENT_URL": "https://www.example.com/sell",
"COOKIE_POLICY_URL": "https://www.example.com/cookie",
"SUPPORTED_LANGUAGES": ["es"]
],
"FIREBASE": [
"ENABLED": true,
Expand Down Expand Up @@ -68,13 +71,6 @@ class ConfigTests: XCTestCase {
XCTAssertTrue(config.features.whatNewEnabled)
}

func testAgreementConfigInitialization() {
let config = Config(properties: properties)

XCTAssertEqual(config.agreement.privacyPolicyURL, URL(string: "https://www.example.com/privacy"))
XCTAssertEqual(config.agreement.tosURL, URL(string: "https://www.example.com/tos"))
}

func testFirebaseConfigInitialization() {
let config = Config(properties: properties)

Expand Down
12 changes: 12 additions & 0 deletions Profile/Profile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
02F3BFE7292539850051930C /* ProfileRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F3BFE6292539850051930C /* ProfileRouter.swift */; };
0796C8C929B7905300444B05 /* ProfileBottomSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0796C8C829B7905300444B05 /* ProfileBottomSheet.swift */; };
25B36FF48C1307888A3890DA /* Pods_App_Profile.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEA369C38362C1A91A012F70 /* Pods_App_Profile.framework */; };
BAD9CA3F2B29BF5C00DE790A /* ProfileSupportInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAD9CA3E2B29BF5C00DE790A /* ProfileSupportInfoView.swift */; };
E8264C634DD8AD314ECE8905 /* Pods_App_Profile_ProfileTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C85ADF87135E03275A980E07 /* Pods_App_Profile_ProfileTests.framework */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -94,6 +95,7 @@
9D125F82E0EAC4B6C0CE280F /* Pods-App-Profile-ProfileTests.releaseprod.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Profile-ProfileTests.releaseprod.xcconfig"; path = "Target Support Files/Pods-App-Profile-ProfileTests/Pods-App-Profile-ProfileTests.releaseprod.xcconfig"; sourceTree = "<group>"; };
A9F98CD65D1F657EB8F9EA59 /* Pods-App-Profile.releasedev.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Profile.releasedev.xcconfig"; path = "Target Support Files/Pods-App-Profile/Pods-App-Profile.releasedev.xcconfig"; sourceTree = "<group>"; };
B3F05DC21379BD4FE1AFCCF1 /* Pods-App-Profile.debugprod.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Profile.debugprod.xcconfig"; path = "Target Support Files/Pods-App-Profile/Pods-App-Profile.debugprod.xcconfig"; sourceTree = "<group>"; };
BAD9CA3E2B29BF5C00DE790A /* ProfileSupportInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileSupportInfoView.swift; sourceTree = "<group>"; };
BEA369C38362C1A91A012F70 /* Pods_App_Profile.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_App_Profile.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C85ADF87135E03275A980E07 /* Pods_App_Profile_ProfileTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_App_Profile_ProfileTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
F52EFE7DC07BE68B9A302DAF /* Pods-App-Profile.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Profile.debug.xcconfig"; path = "Target Support Files/Pods-App-Profile/Pods-App-Profile.debug.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -135,6 +137,7 @@
0203DC3D29AE79F80017BD05 /* Profile */ = {
isa = PBXGroup;
children = (
BAD9CA402B29D6CD00DE790A /* Subviews */,
02D0FD072AD695E10020D752 /* UserProfile */,
021D924528DC634300ACC565 /* ProfileView.swift */,
021D925128DC918D00ACC565 /* ProfileViewModel.swift */,
Expand Down Expand Up @@ -342,6 +345,14 @@
path = ../Pods;
sourceTree = "<group>";
};
BAD9CA402B29D6CD00DE790A /* Subviews */ = {
isa = PBXGroup;
children = (
BAD9CA3E2B29BF5C00DE790A /* ProfileSupportInfoView.swift */,
);
path = Subviews;
sourceTree = "<group>";
};
C456081FB065DCEDAB8119E4 /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -563,6 +574,7 @@
021D924E28DC88BB00ACC565 /* ProfileRepository.swift in Sources */,
0796C8C929B7905300444B05 /* ProfileBottomSheet.swift in Sources */,
021D924C28DC884A00ACC565 /* ProfileEndpoint.swift in Sources */,
BAD9CA3F2B29BF5C00DE790A /* ProfileSupportInfoView.swift in Sources */,
020306C82932B13F000949EA /* EditProfileView.swift in Sources */,
0262149229AE57A1008BD75A /* DeleteAccountView.swift in Sources */,
02D0FD092AD698380020D752 /* UserProfileView.swift in Sources */,
Expand Down
Loading

0 comments on commit e58a7cd

Please sign in to comment.