Skip to content

Commit

Permalink
🚀[Release v3.10.0] Merge into Main (#136)
Browse files Browse the repository at this point in the history
* 🦺[Techdebt] fix firebase (#115)

* Update firebase config
 auto clean up strings

- version bump
- Commented out debug FB file

* Checked the version is sending FB data

- bump build number

* 🥳[Techdebt] relayout address view controller (#120)

* Successfully placed in UIHosting Address

Updated the strings file

* Added event

* added delay

- used for animating U Domain

* Added function of subviews in SendViewController

Layout is updated

* Adding the function to the send

Cleaned up and wired up Cells
- UD View/Model
- Send Address View/Model
Reset the amount Label in SendViewController

* Refactored SendButton

- Using UIHostingViewController

* Successfully send LTC

-WIP: fix white space

* Refactored the layout of the send  button

* buiid bump (#125)

* [Techdebt] ci cd refactor (#132)

* Removed flaky tests

* build bump

* build bump

* removed unused file

- build bump

* build bump

* fixed scan QR (#130)

* fixed scan QR

* update gitignore

* Feature/add bitrefill new (#134)

* Added llocalView

- added bitrefill
- basic function is available
- build bump

* bump

* added basic web widget

* updated logo

* build bump

* changed the Bitrefill link

- build bump

* pre-bump version

- to get a binary to TestFlight

* build bump

* build bump again

* Clean up background

* build bump
  • Loading branch information
kcw-grunt committed Oct 28, 2022
1 parent de424b4 commit 7432e9b
Show file tree
Hide file tree
Showing 16 changed files with 283 additions and 384 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Packages/
Package.pins
Package.resolved
.build/
/*.xcodeproj

# Add this line if you want to avoid checking in Xcode SPM integration.
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
Expand Down
44 changes: 20 additions & 24 deletions loafwallet.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"images" : [
{
"filename" : "bitrefill-logo-app.png",
"idiom" : "universal",
"filename" : "bitrefill@1x.png",
"scale" : "1x"
},
{
Expand All @@ -11,12 +11,11 @@
},
{
"idiom" : "universal",
"filename" : "bitrefill@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
34 changes: 31 additions & 3 deletions loafwallet/BuyTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,28 @@

import UIKit
import SafariServices
import WebKit
import SwiftUI

class BuyTableViewController: UITableViewController, SFSafariViewControllerDelegate {

@IBOutlet weak var bitrefillLogoImageView: UIImageView!
@IBOutlet weak var bitrefillHeaderLabel: UILabel!
@IBOutlet weak var bitrefillDetailsLabel: UILabel!
@IBOutlet weak var bitrefillCellContainerView: UIView!

@IBAction func didTapBitrefill(_ sender: UIButton) {

guard let url = URL(string: "https://www.bitrefill.com/?ref=bAshL935") else
{
return
}

let sfSafariVC = SFSafariViewController(url: url)
sfSafariVC.delegate = self
present(sfSafariVC, animated: true)
}

//MARK: Moonpay UI
@IBOutlet weak var moonpayLogoImageView: UIImageView!
@IBOutlet weak var moonpayHeaderLabel: UILabel!
Expand Down Expand Up @@ -94,9 +113,18 @@ class BuyTableViewController: UITableViewController, SFSafariViewControllerDeleg
setupWkVCData()
}

private func setupWkVCData() {
private func setupWkVCData() {

let bitrefillData = Partner.partnerDataArray()[0]
bitrefillLogoImageView.image = bitrefillData.logo
bitrefillHeaderLabel.text = bitrefillData.headerTitle
bitrefillDetailsLabel.text = bitrefillData.details
bitrefillCellContainerView.layer.cornerRadius = 6.0
bitrefillCellContainerView.layer.borderColor = UIColor.white.cgColor
bitrefillCellContainerView.layer.borderWidth = 1.0
bitrefillCellContainerView.clipsToBounds = true

let moonpayData = Partner.partnerDataArray()[0]
let moonpayData = Partner.partnerDataArray()[1]
moonpayLogoImageView.image = moonpayData.logo
moonpayHeaderLabel.text = moonpayData.headerTitle
moonpayDetailsLabel.text = moonpayData.details
Expand All @@ -105,7 +133,7 @@ class BuyTableViewController: UITableViewController, SFSafariViewControllerDeleg
moonpayCellContainerView.layer.borderWidth = 1.0
moonpayCellContainerView.clipsToBounds = true

let simplexData = Partner.partnerDataArray()[1]
let simplexData = Partner.partnerDataArray()[2]
simplexLogoImageView.image = simplexData.logo
simplexHeaderLabel.text = simplexData.headerTitle
simplexDetailsLabel.text = simplexData.details
Expand Down
99 changes: 99 additions & 0 deletions loafwallet/LocalWebView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
//
// LocalWebView.swift
// loafwallet
//
// Created by Kerry Washington on 10/8/22.
// Copyright © 2022 Litecoin Foundation. All rights reserved.
//

import Foundation
import UIKit
import SwiftUI
import WebKit
import Combine

// MARK: - WebViewHandlerDelegate
protocol WebViewHandlerDelegate {
}

struct LocalWebView: UIViewRepresentable, WebViewHandlerDelegate {

@ObservedObject
var viewModel: LocalWebViewModel

func makeCoordinator() -> Coordinator {
Coordinator(self)
}

func makeUIView(context: Context) -> WKWebView {

let preferences = WKPreferences()
preferences.javaScriptCanOpenWindowsAutomatically = true

let configuration = WKWebViewConfiguration()
configuration.preferences = preferences

let webView = WKWebView(frame: CGRect.zero, configuration: configuration)
webView.navigationDelegate = context.coordinator
webView.allowsBackForwardNavigationGestures = false
webView.scrollView.isScrollEnabled = true
return webView
}

func updateUIView(_ webView: WKWebView, context: Context) {

if let url = Bundle.main.url(forResource: "bitrefill_index", withExtension: "html") {
webView.loadFileURL(url, allowingReadAccessTo: url.deletingLastPathComponent())
} else {
NSLog("ERROR: Local html not found")
}
}

class Coordinator : NSObject, WKNavigationDelegate {
var parent: LocalWebView
var delegate: WebViewHandlerDelegate?
var valueSubscriber: AnyCancellable? = nil
var webViewNavigationSubscriber: AnyCancellable? = nil

init(_ uiWebView: LocalWebView) {
self.parent = uiWebView
self.delegate = parent
}

deinit {
valueSubscriber?.cancel()
webViewNavigationSubscriber?.cancel()
}

func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {

self.parent.viewModel.showLoader.send(false)
}

//MARK: WKWebView's delegate functions
func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
// Hides loader
parent.viewModel.showLoader.send(false)
}

func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) {
// Shows loader
parent.viewModel.showLoader.send(true)
}

func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
// Shows loader
parent.viewModel.showLoader.send(true)
}

}
}

// MARK: - Extensions
extension LocalWebView.Coordinator: WKScriptMessageHandler {
func userContentController(_ userContentController: WKUserContentController,
didReceive message: WKScriptMessage) {
}
}


12 changes: 12 additions & 0 deletions loafwallet/LocalWebViewModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// LocalWebViewModel.swift
// loafwallet

import Foundation
import Combine

class LocalWebViewModel: ObservableObject {

var showLoader = PassthroughSubject<Bool, Never>()
var valuePublisher = PassthroughSubject<String, Never>()
}
124 changes: 4 additions & 120 deletions loafwallet/PartnerData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,129 +23,13 @@ struct Partner {
/// Fills partner data
/// - Returns: Array of Partner Data
static func partnerDataArray() -> [Partner] {

let bitrefill = Partner(logo: UIImage(named: "bitrefillLogo")!, headerTitle: S.BuyCenter.Cells.bitrefillTitle, details: S.BuyCenter.Cells.bitrefillFinancialDetails)
let moonpay = Partner(logo: UIImage(named: "moonpay-logo")!, headerTitle: S.BuyCenter.Cells.moonpayTitle, details: S.BuyCenter.Cells.moonpayFinancialDetails)
let simplex = Partner(logo: UIImage(named: "simplexLogo")!, headerTitle: S.BuyCenter.Cells.simplexTitle, details: S.BuyCenter.Cells.simplexFinancialDetails)
return [moonpay, simplex]
}

/// Returns Partner Key + URL
/// - Parameter name: Enum for the different partners
/// - Returns: Key string url
static func partnerKeyPathURL(name: PartnerName) -> String {

/// Switch the config file based on the environment
var filePath: String
#if Release

// Loads the release Partner Keys config file.
guard let releasePath = Bundle.main.path(forResource: "partner-keys",
ofType: "plist") else {
return "ERROR: FILE-NOT-FOUND"
}
filePath = releasePath

#else

// Loads the debug Partner Keys config file.
guard let debugPath = Bundle.main.path(forResource: "debug-partner-keys",
ofType: "plist") else {
return "ERROR: FILE-NOT-FOUND"
}

filePath = debugPath

#endif

switch name {

case .unstop:

if let dictionary = NSDictionary(contentsOfFile: filePath) as? Dictionary<String, AnyObject>,
let key = dictionary["infura-api"] as? String {
return "https://mainnet.infura.io/v3/" + key
} else {

let errorDescription = "ERROR-INFURA_KEY"
LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: ["error": errorDescription])
return errorDescription
}

case .changeNow:

if let dictionary = NSDictionary(contentsOfFile: filePath) as? Dictionary<String, AnyObject>,
let key = dictionary["change-now-api"] as? String {
return key
} else {

let errorDescription = "ERROR-CHANGENOW_KEY"
LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: ["error": errorDescription])
return errorDescription
}
}

}

/// Returns Partner Key
/// - Parameter name: Enum for the different partners
/// - Returns: Key string
static func partnerKey(name: PartnerName) -> String {

/// Switch the config file based on the environment
var filePath: String
#if Release

// Loads the release Partner Keys config file.
guard let releasePath = Bundle.main.path(forResource: "partner-keys",
ofType: "plist") else {
return "ERROR: FILE-NOT-FOUND"
}
filePath = releasePath

#else

// Loads the debug Partner Keys config file.
guard let debugPath = Bundle.main.path(forResource: "debug-partner-keys",
ofType: "plist") else {
return "ERROR: FILE-NOT-FOUND"
}

filePath = debugPath

#endif

switch name {

case .unstop:

if let dictionary = NSDictionary(contentsOfFile: filePath) as? Dictionary<String, AnyObject>,
let key = dictionary["infura-api"] as? String {
return key
} else {

let errorDescription = "ERROR-INFURA_KEY"
LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: ["error": errorDescription])
return errorDescription
}

case .changeNow:

if let dictionary = NSDictionary(contentsOfFile: filePath) as? Dictionary<String, AnyObject>,
let key = dictionary["change-now-api"] as? String {
return key
} else {

let errorDescription = "ERROR-CHANGENOW_KEY"
LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: ["error": errorDescription])
return errorDescription
}
}
return [bitrefill, moonpay, simplex]
}

//TODO: Uncomment as integration progresses, kcw-grunt
// let bitrefillDictionary =
// ["title":S.BuyCenter.Cells.bitrefillTitle as AnyObject,
// "details":S.BuyCenter.Cells.bitrefillFinancialDetails,
// "logo":UIImage(named:"bitrefillLogo") ?? " ",
// "baseColor":#colorLiteral(red: 0.2235294118, green: 0.5490196078, blue: 0.9333333333, alpha: 1)] as [String : AnyObject]

}

Loading

0 comments on commit 7432e9b

Please sign in to comment.