diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 8af7375..31a58dc 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -33,7 +33,7 @@ SPEC CHECKSUMS: CryptoSwift: f12f037f6d0fcd6d48c96db0071b653de64e6c4d SwiftLint: 22ccbbe3b8008684be5955693bab135e0ed6a447 SwiftProtobuf: ecbec1be9036d15655f6b3443a1c4ea693c97932 - TrustSDK: 94db9da0d77fa9b8cd09e149639cefcb7b218cea + TrustSDK: ad622be6fa2aff65c2e330ba51cc3a5f95ead1b8 TrustWalletCore: cd0373c69fd9bf92700783287544ce6a9aab041b PODFILE CHECKSUM: 598c9b55b1a069a4a551d4116542d400689f4304 diff --git a/Example/TrustSDK.xcodeproj/project.pbxproj b/Example/TrustSDK.xcodeproj/project.pbxproj index 51a07c0..dbd75aa 100644 --- a/Example/TrustSDK.xcodeproj/project.pbxproj +++ b/Example/TrustSDK.xcodeproj/project.pbxproj @@ -11,7 +11,6 @@ 33758FFB3D21DDEAA9C93AA9 /* Pods_TrustSDK_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C5D9043738C8AAF9420A137C /* Pods_TrustSDK_Tests.framework */; }; 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; }; 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; }; - 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; }; 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; }; 607FACEC1AFB9204008FA782 /* RequestRegistryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* RequestRegistryTests.swift */; }; @@ -19,6 +18,7 @@ 7507FFE1240D75AE00DE2741 /* WalletResponseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7507FFE0240D75AE00DE2741 /* WalletResponseTests.swift */; }; 7507FFE3240D774300DE2741 /* WalletRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7507FFE2240D774300DE2741 /* WalletRequestTests.swift */; }; 7598AD192414175000421EFA /* DictionaryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7598AD182414175000421EFA /* DictionaryTests.swift */; }; + 75CD0D8324A41DC300242DA3 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 75CD0D8224A41DC300242DA3 /* Main.storyboard */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -39,7 +39,6 @@ 607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 607FACD71AFB9204008FA782 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; - 607FACDA1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 607FACDC1AFB9204008FA782 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 607FACE51AFB9204008FA782 /* TrustSDK_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TrustSDK_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -49,6 +48,7 @@ 7507FFE0240D75AE00DE2741 /* WalletResponseTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletResponseTests.swift; sourceTree = ""; }; 7507FFE2240D774300DE2741 /* WalletRequestTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletRequestTests.swift; sourceTree = ""; }; 7598AD182414175000421EFA /* DictionaryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DictionaryTests.swift; sourceTree = ""; }; + 75CD0D8224A41DC300242DA3 /* Main.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; 8E3A0941E4AF3948909E87BE /* Pods-TrustSDK_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TrustSDK_Tests.release.xcconfig"; path = "Target Support Files/Pods-TrustSDK_Tests/Pods-TrustSDK_Tests.release.xcconfig"; sourceTree = ""; }; 973C7B142BAB8746D0C53AF2 /* TrustSDK.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = TrustSDK.podspec; path = ../TrustSDK.podspec; sourceTree = ""; }; 9CE43E415D1BA0F22441C393 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; @@ -114,7 +114,7 @@ children = ( 607FACD51AFB9204008FA782 /* AppDelegate.swift */, 607FACD71AFB9204008FA782 /* ViewController.swift */, - 607FACD91AFB9204008FA782 /* Main.storyboard */, + 75CD0D8224A41DC300242DA3 /* Main.storyboard */, 607FACDC1AFB9204008FA782 /* Images.xcassets */, 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */, 607FACD31AFB9204008FA782 /* Supporting Files */, @@ -266,7 +266,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */, + 75CD0D8324A41DC300242DA3 /* Main.storyboard in Resources */, 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */, 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */, ); @@ -404,14 +404,6 @@ /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ - 607FACD91AFB9204008FA782 /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 607FACDA1AFB9204008FA782 /* Base */, - ); - name = Main.storyboard; - sourceTree = ""; - }; 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */ = { isa = PBXVariantGroup; children = ( diff --git a/Example/TrustSDK/Base.lproj/Main.storyboard b/Example/TrustSDK/Main.storyboard similarity index 56% rename from Example/TrustSDK/Base.lproj/Main.storyboard rename to Example/TrustSDK/Main.storyboard index 0aa9cc5..e0fb260 100644 --- a/Example/TrustSDK/Base.lproj/Main.storyboard +++ b/Example/TrustSDK/Main.storyboard @@ -1,81 +1,73 @@ - - + + + - + - - - - - - - - + + + + - - + + - - - - - + - - - + + + + + + + + + + - + - + diff --git a/Example/TrustSDK/ViewController.swift b/Example/TrustSDK/ViewController.swift index c60976a..3cf130c 100644 --- a/Example/TrustSDK/ViewController.swift +++ b/Example/TrustSDK/ViewController.swift @@ -11,12 +11,19 @@ import CryptoSwift import TrustWalletCore class ViewController: UIViewController { + @IBOutlet var signMesageButton: TrustButton! + @IBOutlet var signTransactionButton: TrustButton! + @IBOutlet var payWithTrustButton: TrustButton! + @IBOutlet var getAccountsButton: TrustButton! let meta = TrustSDK.SignMetadata.dApp(name: "Test", url: URL(string: "https://dapptest.com")) override func viewDidLoad() { super.viewDidLoad() - // Do any additional setup after loading the view, typically from a nib. + setupSignTransactionButton() + setupSignMessageButton() + setupGetAccountsButton() + setupPayWithTrustButton() } override func didReceiveMemoryWarning() { @@ -24,22 +31,22 @@ class ViewController: UIViewController { // Dispose of any resources that can be recreated. } - @IBAction func signEthereumTx(_ sender: UIButton) { - let input = EthereumSigningInput.with { - $0.toAddress = "0x728B02377230b5df73Aa4E3192E89b6090DD7312" - $0.chainID = BigInt("1").serialize()! - $0.nonce = BigInt("477").serialize()! - $0.gasPrice = BigInt("2112000000").serialize()! - $0.gasLimit = BigInt("21000").serialize()! - $0.amount = BigInt("100000000000000").serialize()! - } - - TrustSDK.signers.ethereum.sign(input: input, metadata: meta) { result in + func setupSignMessageButton() { + let data = Data("Some message".utf8) + let message = Data("\u{19}Ethereum Signed Message:\n\(data.count)".utf8) + let hash = message.sha3(.keccak256) + + signMesageButton.apply(theme: TrustButtonTheme + .blue + .with(styles: .title(.plain("Sign Message")), .icon(.trust), .roundFull) + ) + + signMesageButton.action = .signMessage(hash) { result in switch result { - case .success(let output): + case .success(let signature): let alert = UIAlertController( - title: "Transaction", - message: output.map({ String(format: "%02x", $0) }).joined(), + title: "Signature", + message: signature, preferredStyle: .alert ) alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil)) @@ -50,16 +57,27 @@ class ViewController: UIViewController { } } - @IBAction func signEthereumMessage(_ sender: UIButton) { - let data = Data("Some message".utf8) - let message = Data("\u{19}Ethereum Signed Message:\n\(data.count)".utf8) - let hash = message.sha3(.keccak256) - TrustSDK.signers.ethereum.sign(message: hash) { result in + func setupSignTransactionButton() { + let input = EthereumSigningInput.with { + $0.toAddress = "0x728B02377230b5df73Aa4E3192E89b6090DD7312" + $0.chainID = BigInt("1").serialize()! + $0.nonce = BigInt("477").serialize()! + $0.gasPrice = BigInt("2112000000").serialize()! + $0.gasLimit = BigInt("21000").serialize()! + $0.amount = BigInt("100000000000000").serialize()! + } + + signTransactionButton.apply(theme: TrustButtonTheme + .white + .with(styles: .title(.plain("Sign Transaction")), .icon(.trust)) + ) + + signTransactionButton.action = .sign(signer: TrustSDK.signers.ethereum, input: input, metadata: meta) { result in switch result { - case .success(let signature): + case .success(let output): let alert = UIAlertController( - title: "Signature", - message: signature, + title: "Transaction", + message: output.map({ String(format: "%02x", $0) }).joined(), preferredStyle: .alert ) alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil)) @@ -70,14 +88,19 @@ class ViewController: UIViewController { } } - @IBAction func signThenSendEthereum(_ sender: UIButton) { + func setupPayWithTrustButton() { let input = EthereumSigningInput.with { $0.toAddress = "0x728B02377230b5df73Aa4E3192E89b6090DD7312" $0.chainID = BigInt("1").serialize()! $0.amount = BigInt("100000000000000").serialize()! } - - TrustSDK.signers.ethereum.signThenSend(input: input, metadata: meta) { result in + + payWithTrustButton.apply(theme: TrustButtonTheme + .black + .with(styles: .title(.payWithTrust(icon: .shieldLined))) + ) + + payWithTrustButton.action = .signThenSend(signer: TrustSDK.signers.ethereum, input: input, metadata: meta) { (result) in switch result { case .success(let output): let alert = UIAlertController( @@ -93,8 +116,13 @@ class ViewController: UIViewController { } } - @IBAction func getAddress(_ sender: UIButton) { - TrustSDK.getAccounts(for: [.ethereum, .binance]) { result in + func setupGetAccountsButton() { + getAccountsButton.apply(theme: TrustButtonTheme + .white + .with(styles: .title(.plain("Get Accounts")), .icon(.trust), .roundFull) + ) + + getAccountsButton.action = .getAccounts(coins: [.ethereum, .binance]) { result in switch result { case .success(let addresses): let alert = UIAlertController( diff --git a/TrustSDK.podspec b/TrustSDK.podspec index 94f1ee8..6d5bf95 100644 --- a/TrustSDK.podspec +++ b/TrustSDK.podspec @@ -11,6 +11,9 @@ Pod::Spec.new do |s| s.default_subspec = 'Client' s.subspec 'Client' do |cs| + cs.resource_bundles = { + 'TrustSDK' => ['TrustSDK/Resources/**/*.xcassets', 'TrustSDK/Resources/**/*.strings'] + } cs.source_files = 'TrustSDK/Classes/Client/**/*' cs.dependency 'TrustWalletCore/Types' cs.dependency 'BigInt' diff --git a/TrustSDK/Classes/Client/Extensions/String.swift b/TrustSDK/Classes/Client/Extensions/String.swift index eec9fcd..1b60956 100644 --- a/TrustSDK/Classes/Client/Extensions/String.swift +++ b/TrustSDK/Classes/Client/Extensions/String.swift @@ -33,3 +33,9 @@ extension String { return Bool(self) ?? false } } + +extension String { + func localized(comment: String = "") -> String { + return NSLocalizedString(self, bundle: TrustSDK.resourceBundle, comment: comment) + } +} diff --git a/TrustSDK/Classes/Client/UI/Colors.swift b/TrustSDK/Classes/Client/UI/Colors.swift new file mode 100644 index 0000000..bf95f88 --- /dev/null +++ b/TrustSDK/Classes/Client/UI/Colors.swift @@ -0,0 +1,26 @@ +// Copyright Trust Wallet. All rights reserved. +// +// This file is part of TrustSDK. The full TrustSDK copyright notice, including +// terms governing use, modification, and redistribution, is contained in the +// file LICENSE at the root of the source code distribution tree. + +import UIKit + +extension TrustSDK { + public struct Colors { + static let white = color(light: .white, dark: .white) + static let light = color(light: .white, dark: .black) + static let black = color(light: .black, dark: .black) + static let blue = color(light: UIColor(hex: 0x2e91db), dark: UIColor(hex: 0x4390E2)) + + internal static func color(light: UIColor, dark: UIColor) -> UIColor { + if #available(iOS 13.0, *) { + return UIColor { (traits) -> UIColor in + return traits.userInterfaceStyle == .dark ? dark : light + } + } else { + return light + } + } + } +} diff --git a/TrustSDK/Classes/Client/UI/Icons.swift b/TrustSDK/Classes/Client/UI/Icons.swift new file mode 100644 index 0000000..b6d9479 --- /dev/null +++ b/TrustSDK/Classes/Client/UI/Icons.swift @@ -0,0 +1,36 @@ +// Copyright Trust Wallet. All rights reserved. +// +// This file is part of TrustSDK. The full TrustSDK copyright notice, including +// terms governing use, modification, and redistribution, is contained in the +// file LICENSE at the root of the source code distribution tree. + +import UIKit + +extension TrustSDK { + public static let resourceBundle: Bundle = { + let bundle = Bundle(for: TrustSDK.self) + guard let resourceBundleUrl = bundle.url(forResource: "TrustSDK", withExtension: "bundle") else { + fatalError("TrustSDK.bundle not found!") + } + guard let resourceBundle = Bundle(url: resourceBundleUrl) else { + fatalError("Could not access TrustSDK.bundle") + } + return resourceBundle + }() + + public enum Icon { + case trust, shieldFilled, shieldLined + + public var image: UIImage? { + switch self { + case .trust: + return UIImage(named: "trust", in: TrustSDK.resourceBundle, compatibleWith: nil) + case .shieldFilled: + return UIImage(named: "trust.shield.fill", in: TrustSDK.resourceBundle, compatibleWith: nil) + case .shieldLined: + return UIImage(named: "trust.shield", in: TrustSDK.resourceBundle, compatibleWith: nil) + } + } + } + +} diff --git a/TrustSDK/Classes/Client/UI/TrustButton.swift b/TrustSDK/Classes/Client/UI/TrustButton.swift new file mode 100644 index 0000000..17125fe --- /dev/null +++ b/TrustSDK/Classes/Client/UI/TrustButton.swift @@ -0,0 +1,111 @@ +// Copyright Trust Wallet. All rights reserved. +// +// This file is part of TrustSDK. The full TrustSDK copyright notice, including +// terms governing use, modification, and redistribution, is contained in the +// file LICENSE at the root of the source code distribution tree. + +import UIKit +import TrustWalletCore + +public final class TrustButton: UIButton { + public enum Action { + case getAccounts( + coins: [CoinType], + callback: ((Result<[String], Error>) -> Void) + ) + + case signMessage(Data, + metadata: TrustSDK.SignMetadata? = nil, + callback: ((Result) -> Void) + ) + + case sign( + signer: TrustSDK.Signer, + input: SigningInput, + metadata: TrustSDK.SignMetadata? = nil, + callback: ((Result) -> Void) + ) + + case signThenSend( + signer: TrustSDK.Signer, + input: SigningInput, + metadata: TrustSDK.SignMetadata? = nil, + callback: ((Result) -> Void) + ) + } + + private var isFullRounded: Bool = false + public var action: Action? + + public override init(frame: CGRect) { + super.init(frame: frame) + initialize() + } + + public required init?(coder: NSCoder) { + super.init(coder: coder) + initialize() + } + + private func initialize() { + self.apply(theme: .blue) + self.addTarget(self, action: #selector(didPress), for: .touchUpInside) + } + + public func apply(theme: TrustButtonTheme) { + for style in theme.styles { + apply(style: style) + } + } + + @objc func didPress() { + switch action { + case let .getAccounts(coins, callback): + TrustSDK.getAccounts(for: coins, callback: callback) + case let .sign(signer, input, metadata, callback): + signer.sign(input: input, metadata: metadata, callback: callback) + case let .signThenSend(signer, input, metadata, callback): + signer.signThenSend(input: input, metadata: metadata, callback: callback) + case let .signMessage(message, metadata, callback): + TrustSDK.signers.ethereum.sign(message: message, metadata: metadata, callback: callback) + case .none: + break + } + } + + func apply(style: TrustButtonStyle) { + switch style { + case let .font(font): + self.titleLabel?.font = font + case let .title(style): + guard let font = self.titleLabel?.font else { + return + } + self.setAttributedTitle(style.title(font: font), for: .normal) + case let .icon(icon, insets): + self.setImage(icon.image, for: .normal) + self.imageView?.contentMode = .scaleAspectFit + self.imageEdgeInsets = insets + case let .tintColor(color): + self.tintColor = color + case let .backgroundColor(color): + self.backgroundColor = color + case let .border(width, color): + self.layer.borderColor = color.cgColor + self.layer.borderWidth = width + case let .round(radius): + self.layer.cornerRadius = radius + self.isFullRounded = false + case .roundFull: + self.layer.cornerRadius = 0 + self.isFullRounded = true + } + } + + public override func layoutSubviews() { + super.layoutSubviews() + if isFullRounded { + self.layer.cornerRadius = self.bounds.height / 2.0 + } + } +} diff --git a/TrustSDK/Classes/Client/UI/TrustButtonTheme.swift b/TrustSDK/Classes/Client/UI/TrustButtonTheme.swift new file mode 100644 index 0000000..cfc5864 --- /dev/null +++ b/TrustSDK/Classes/Client/UI/TrustButtonTheme.swift @@ -0,0 +1,123 @@ +// Copyright Trust Wallet. All rights reserved. +// +// This file is part of TrustSDK. The full TrustSDK copyright notice, including +// terms governing use, modification, and redistribution, is contained in the +// file LICENSE at the root of the source code distribution tree. + +import Foundation + +public struct TrustButtonTheme { + let styles: [TrustButtonStyle] + + public init(_ styles: TrustButtonStyle...) { + self.styles = styles + } + + init(styles: [TrustButtonStyle]) { + self.styles = styles + } + + public func with(styles: TrustButtonStyle...) -> TrustButtonTheme { + let current = self.styles.filter { !styles.contains($0) } + return TrustButtonTheme(styles: current + styles) + } + + public static let white = TrustButtonTheme( + .font(.systemFont(ofSize: 18, weight: .regular)), + .tintColor(TrustSDK.Colors.blue), + .backgroundColor(TrustSDK.Colors.light), + .border(width: 1, color: TrustSDK.Colors.blue), + .round(radius: 8.0) + ) + + public static let blue = TrustButtonTheme( + .font(.systemFont(ofSize: 18, weight: .regular)), + .tintColor(TrustSDK.Colors.white), + .backgroundColor(TrustSDK.Colors.blue), + .round(radius: 8.0) + ) + + public static let black = TrustButtonTheme( + .font(.systemFont(ofSize: 18, weight: .regular)), + .tintColor(TrustSDK.Colors.white), + .backgroundColor(TrustSDK.Colors.black), + .border(width: 1, color: TrustSDK.Colors.white), + .round(radius: 8.0) + ) +} + +enum TrustButtonStyleName: String { + case icon + case font + case title + case backgroundColor + case tintColor + case border + case round + case roundFull +} + +public enum TrustButtonTitleStyle { + case plain(String) + case payWithTrust(icon: TrustSDK.Icon, size: CGSize = CGSize(width: 20, height: 20)) + + func title(font: UIFont) -> NSAttributedString { + switch self { + case .plain(let title): + return NSAttributedString(string: title) + case let .payWithTrust(icon, iconSize): + let titleString = NSMutableAttributedString(string: "Pay with".localized()) + titleString.append(NSAttributedString(string: " ")) + + let iconAttachment = NSTextAttachment() + iconAttachment.image = icon.image + iconAttachment.bounds = CGRect(origin: CGPoint(x: 0, y: (font.capHeight - iconSize.height) / 2), size: iconSize) + + titleString.append(NSAttributedString(attachment: iconAttachment)) + titleString.append(NSAttributedString(string: "Wallet".localized())) + + return titleString + } + + } +} + +public enum TrustButtonStyle { + case backgroundColor(UIColor) + case tintColor(UIColor) + case font(UIFont) + case icon(TrustSDK.Icon, insets: UIEdgeInsets = UIEdgeInsets(top: 5.0, left: 0, bottom: 5.0, right: 8.0)) + case title(TrustButtonTitleStyle) + case border(width: CGFloat, color: UIColor) + case round(radius: CGFloat) + case roundFull + + var name: TrustButtonStyleName { + switch self { + case .icon: return .icon + case .font: return .font + case .title: return .title + case .backgroundColor: return .backgroundColor + case .tintColor: return .tintColor + case .border: return .border + case .round: return .round + case .roundFull: return .roundFull + } + } +} + +extension TrustButtonStyle: Hashable { + public static func == (lhs: TrustButtonStyle, rhs: TrustButtonStyle) -> Bool { + return lhs.name == rhs.name + } + + public func hash(into hasher: inout Hasher) { + self.name.hash(into: &hasher) + } +} + +extension Array where Element == TrustButtonStyle { + func unique() -> [Element] { + return Array(Set(self)) + } +} diff --git a/TrustSDK/Classes/Client/UI/UIColor+Hex.swift b/TrustSDK/Classes/Client/UI/UIColor+Hex.swift new file mode 100644 index 0000000..e37b8b4 --- /dev/null +++ b/TrustSDK/Classes/Client/UI/UIColor+Hex.swift @@ -0,0 +1,21 @@ +// Copyright Trust Wallet. All rights reserved. +// +// This file is part of TrustSDK. The full TrustSDK copyright notice, including +// terms governing use, modification, and redistribution, is contained in the +// file LICENSE at the root of the source code distribution tree. + +import Foundation + +extension UIColor { + convenience init(hex: UInt64) { + let red = (hex & 0xff0000) >> 16 + let green = (hex & 0xff00) >> 8 + let blue = hex & 0xff + + self.init( + red: CGFloat(red) / 0xff, + green: CGFloat(green) / 0xff, + blue: CGFloat(blue) / 0xff, alpha: 1 + ) + } +} diff --git a/TrustSDK/Assets/.gitkeep b/TrustSDK/Resources/.gitkeep similarity index 100% rename from TrustSDK/Assets/.gitkeep rename to TrustSDK/Resources/.gitkeep diff --git a/TrustSDK/Resources/Images.xcassets/Contents.json b/TrustSDK/Resources/Images.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/TrustSDK/Resources/Images.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/TrustSDK/Resources/Images.xcassets/trust.imageset/Contents.json b/TrustSDK/Resources/Images.xcassets/trust.imageset/Contents.json new file mode 100644 index 0000000..074c5a4 --- /dev/null +++ b/TrustSDK/Resources/Images.xcassets/trust.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "filename" : "trust_icon.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" + } +} diff --git a/TrustSDK/Resources/Images.xcassets/trust.imageset/trust_icon.pdf b/TrustSDK/Resources/Images.xcassets/trust.imageset/trust_icon.pdf new file mode 100644 index 0000000..674bd36 Binary files /dev/null and b/TrustSDK/Resources/Images.xcassets/trust.imageset/trust_icon.pdf differ diff --git a/TrustSDK/Resources/Images.xcassets/trust.shield.fill.imageset/Contents.json b/TrustSDK/Resources/Images.xcassets/trust.shield.fill.imageset/Contents.json new file mode 100644 index 0000000..e77a1b4 --- /dev/null +++ b/TrustSDK/Resources/Images.xcassets/trust.shield.fill.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "filename" : "trust_filled.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" + } +} diff --git a/TrustSDK/Resources/Images.xcassets/trust.shield.fill.imageset/trust_filled.pdf b/TrustSDK/Resources/Images.xcassets/trust.shield.fill.imageset/trust_filled.pdf new file mode 100644 index 0000000..4cc2e4d Binary files /dev/null and b/TrustSDK/Resources/Images.xcassets/trust.shield.fill.imageset/trust_filled.pdf differ diff --git a/TrustSDK/Resources/Images.xcassets/trust.shield.imageset/Contents.json b/TrustSDK/Resources/Images.xcassets/trust.shield.imageset/Contents.json new file mode 100644 index 0000000..cd73e26 --- /dev/null +++ b/TrustSDK/Resources/Images.xcassets/trust.shield.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "filename" : "trust_line.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" + } +} diff --git a/TrustSDK/Resources/Images.xcassets/trust.shield.imageset/trust_line.pdf b/TrustSDK/Resources/Images.xcassets/trust.shield.imageset/trust_line.pdf new file mode 100644 index 0000000..e5c3b5a Binary files /dev/null and b/TrustSDK/Resources/Images.xcassets/trust.shield.imageset/trust_line.pdf differ diff --git a/TrustSDK/Resources/en.lproj/Localizable.strings b/TrustSDK/Resources/en.lproj/Localizable.strings new file mode 100644 index 0000000..9a9bac8 --- /dev/null +++ b/TrustSDK/Resources/en.lproj/Localizable.strings @@ -0,0 +1,3 @@ +"Pay with"="Pay with"; +"Trust Wallet"="Trust Wallet"; +"Wallet"="Wallet";