Skip to content

Commit

Permalink
Merge branch 'develop' into release/2.12.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	p2p_wallet/Resources/en.lproj/Localizable.strings
  • Loading branch information
Elizaveta Semenova committed Feb 12, 2024
2 parents 7ce5283 + 7d023cc commit 12023b5
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/marmelroy/PhoneNumberKit.git",
"state" : {
"revision" : "d2886b0735a47e47fb227504666756efb2e2ac26",
"version" : "3.7.6"
"revision" : "7268078304df2f4e07ac864b5ba27ae4c1e6f4a6",
"version" : "3.7.7"
}
},
{
Expand Down
1 change: 1 addition & 0 deletions p2p_wallet/Resources/Base.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -609,3 +609,4 @@
"KeyApp swap fee" = "KeyApp swap fee";
"Referral reward" = "Referral reward";
"Open SOLScan" = "Open SOLScan";
"Terms & Conditions" = "Terms & Conditions";
27 changes: 27 additions & 0 deletions p2p_wallet/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -595,3 +595,30 @@
"✌️ Great! Your new PIN is set." = "✌️ Great! Your new PIN is set.";
"😓 name is not available" = "😓 name is not available";
"😢 PIN doesn't match. Please try again" = "😢 PIN doesn't match. Please try again";
"Confirm selection" = "Confirm selection";
"The token %@ is out of the strict list" = "The token %@ is out of the strict list";
"Make sure the mint address %@ is correct before confirming" = "Make sure the mint address %@ is correct before confirming";
"Be save and carefull" = "Be save and carefull";
"The token %@ from your swap link seems suspicious, therefore we've refreshed swap pair to default." = "The token %@ from your swap link seems suspicious, therefore we've refreshed swap pair to default.";
"Charge that you need to pay to send or receive tokens-2022. It helps maintain the network and ensure smooth transactions." = "Charge that you need to pay to send or receive tokens-2022. It helps maintain the network and ensure smooth transactions.";
"Confirm selection" = "Confirm selection";
"The token %@ is out of the strict list" = "The token %@ is out of the strict list";
"Make sure the mint address %@ is correct before confirming" = "Make sure the mint address %@ is correct before confirming";
"Unfortunately, you can not cashout in %@, but you can still use other Key App features" = "Unfortunately, you can not cashout in %@, but you can still use other Key App features";
"Share my link" = "Share my link";
"Open details" = "Open details";
"Token 2022 details" = "Token 2022 details";
"Token 2022 transfer fee" = "Token 2022 transfer fee";
"Calculated by subtracting the token 2022 transfer fee from your balance" = "Calculated by subtracting the token 2022 transfer fee from your balance";
"Calculated by subtracting the token 2022 transfer fee and account creation fee from your balance" = "Calculated by subtracting the token 2022 transfer fee and account creation fee from your balance";
"Update available" = "Update available";
"Referral program" = "Referral program";
"%@ all the time" = "%@ all the time";
"Here’s how do we count your profits for total balance and every single token" = "Here’s how do we count your profits for total balance and every single token";
"Based on absolute and relative profitability of each trade. It shows the relative potential %% profits or losses of your trading strategy." = "Based on absolute and relative profitability of each trade. It shows the relative potential %% profits or losses of your trading strategy.";
"%@%% last 24h" = "%@%% last 24h";
"Result of an investment, trading strategy per 24 hours" = "Result of an investment, trading strategy per 24 hours";
"KeyApp swap fee" = "KeyApp swap fee";
"Referral reward" = "Referral reward";
"Open SOLScan" = "Open SOLScan";
"Terms & Conditions" = "Terms & Conditions";
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ enum ReferralBridgeMethod: String {
case nativeLog
case signMessage
case getUserPublicKey
case openTermsUrl
}

enum ReferralBridgeError: String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@ window.ReferralBridge = {
signMessageAsync: async function(message) {
const result = await handleRequest({ method: "signMessage", message: message });
return result
},
openTermsUrl: function(link) {
handleRequest({ method: "openTermsUrl", link: link });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import WebKit

protocol ReferralBridge {
var sharePublisher: AnyPublisher<String, Never> { get }
var openTermsUrl: AnyPublisher<URL, Never> { get }
}

final class ReferralJSBridge: NSObject, ReferralBridge {
var sharePublisher: AnyPublisher<String, Never> { shareSubject.eraseToAnyPublisher() }
var openTermsUrl: AnyPublisher<URL, Never> { openTermsUrlSubject.eraseToAnyPublisher() }

// MARK: - Dependencies

Expand All @@ -21,6 +23,7 @@ final class ReferralJSBridge: NSObject, ReferralBridge {
// MARK: - Properties

private let shareSubject = PassthroughSubject<String, Never>()
private let openTermsUrlSubject = PassthroughSubject<URL, Never>()
private var subscriptions: [AnyCancellable] = []
private weak var webView: WKWebView?

Expand Down Expand Up @@ -133,6 +136,13 @@ extension ReferralJSBridge: WKScriptMessageHandlerWithReply {

case .getUserPublicKey:
handler(user.account.publicKey.base58EncodedString, nil)
case .openTermsUrl:
if let link = dict["link"] as? String, let url = URL(string: link) {
openTermsUrlSubject.send(url)
handler(link, nil)
} else {
handler(nil, .emptyLink)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ final class ReferralProgramCoordinator: Coordinator<Void> {
}
.store(in: &subscriptions)

viewModel.openTerms
.sink { [weak self] url in
guard let self else { return }
coordinate(to: TermsAndConditionsCoordinator(navigationController: self.navigationController, url: url))
.sink(receiveValue: {}).store(in: &self.subscriptions)
}
.store(in: &subscriptions)

return result.eraseToAnyPublisher()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ final class ReferralProgramViewModel: BaseViewModel, ObservableObject {
let webView: WKWebView

let openShare = PassthroughSubject<String, Never>()
let openTerms = PassthroughSubject<URL, Never>()

override init() {
let wkWebView = ReferralProgramViewModel.buildWebView()
Expand All @@ -27,6 +28,12 @@ final class ReferralProgramViewModel: BaseViewModel, ObservableObject {
self?.openShare.send(value)
})
.store(in: &subscriptions)

bridge.openTermsUrl
.sink(receiveValue: { [weak self] value in
self?.openTerms.send(value)
})
.store(in: &subscriptions)
}

private static func buildWebView() -> WKWebView {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Combine
import SwiftUI
import UIKit

final class TermsAndConditionsCoordinator: Coordinator<Void> {
private let navigationController: UINavigationController
private let result = PassthroughSubject<Void, Never>()
private let url: URL

init(navigationController: UINavigationController, url: URL) {
self.navigationController = navigationController
self.url = url
}

override func start() -> AnyPublisher<Void, Never> {
let view = TermsAndConditionsView(url: url)
let vc = UIHostingController(rootView: view)
navigationController.pushViewController(vc, animated: true)
return result.eraseToAnyPublisher()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Foundation
import SwiftUI
import WebKit

struct TermsAndConditionsView: View {
private let url: URL
init(url: URL) {
self.url = url
}

var body: some View {
ColoredBackground(
{
ReferralWebView(webView: WKWebView(), link: url)
.ignoresSafeArea(edges: .bottom)
},
color: Color(uiColor: UIColor(resource: .f2F5Fa))
)
.navigationTitle(L10n.termsConditions)
.navigationBarTitleDisplayMode(.inline)
}
}

0 comments on commit 12023b5

Please sign in to comment.