Skip to content

Commit

Permalink
Removes testnet background image when running on mainnet. Fixes issue #…
Browse files Browse the repository at this point in the history
  • Loading branch information
robbiehanson committed Mar 19, 2021
1 parent 00d047f commit dd398ac
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 22 deletions.
6 changes: 4 additions & 2 deletions phoenix-ios/phoenix-ios/views/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ struct HomeView : MVIView {

ZStack {

Image("testnet_bg")
.resizable(resizingMode: .tile)
if AppDelegate.get().business.chain == Chain.testnet {
Image("testnet_bg")
.resizable(resizingMode: .tile)
}

VStack {

Expand Down
6 changes: 4 additions & 2 deletions phoenix-ios/phoenix-ios/views/ReceiveView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ struct ReceiveView: MVIView {

ZStack {

Image("testnet_bg")
.resizable(resizingMode: .tile)
if AppDelegate.get().business.chain == Chain.testnet {
Image("testnet_bg")
.resizable(resizingMode: .tile)
}

if verticalSizeClass == UserInterfaceSizeClass.compact {
mainLandscape()
Expand Down
52 changes: 35 additions & 17 deletions phoenix-ios/phoenix-ios/views/ScanView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ struct ReadyView: View {

ZStack {

Image("testnet_bg")
.resizable(resizingMode: .tile)
if AppDelegate.get().business.chain == Chain.testnet {
Image("testnet_bg")
.resizable(resizingMode: .tile)
}

VStack {
Spacer()
Expand Down Expand Up @@ -291,19 +293,21 @@ struct ValidateView: View {
Color.primaryBackground
.ignoresSafeArea(.all, edges: .all)

Image("testnet_bg")
.resizable(resizingMode: .tile)
.ignoresSafeArea(.all, edges: .all)
.onTapGesture {
// dismiss keyboard (number pad) if visible
let keyWindow = UIApplication.shared.connectedScenes
.filter({ $0.activationState == .foregroundActive })
.map({ $0 as? UIWindowScene })
.compactMap({ $0 })
.first?.windows
.filter({ $0.isKeyWindow }).first
keyWindow?.endEditing(true)
}
if AppDelegate.get().business.chain == Chain.testnet {
Image("testnet_bg")
.resizable(resizingMode: .tile)
.ignoresSafeArea(.all, edges: .all)
.onTapGesture {
dismissKeyboardIfVisible()
}
} else {
Color.clear
.ignoresSafeArea(.all, edges: .all)
.contentShape(Rectangle())
.onTapGesture {
dismissKeyboardIfVisible()
}
}

VStack {

Expand Down Expand Up @@ -417,6 +421,18 @@ struct ValidateView: View {
}
}

func dismissKeyboardIfVisible() -> Void {
log.trace("(ValidateView) dismissKeyboardIfVisible()")

let keyWindow = UIApplication.shared.connectedScenes
.filter({ $0.activationState == .foregroundActive })
.map({ $0 as? UIWindowScene })
.compactMap({ $0 })
.first?.windows
.filter({ $0.isKeyWindow }).first
keyWindow?.endEditing(true)
}

func amountDidChange() -> Void {
log.trace("(ValidateView) amountDidChange()")

Expand Down Expand Up @@ -536,8 +552,10 @@ struct SendingView: View {

ZStack {

Image("testnet_bg")
.resizable(resizingMode: .tile)
if AppDelegate.get().business.chain == Chain.testnet {
Image("testnet_bg")
.resizable(resizingMode: .tile)
}

VStack {
Text("Sending Payment...")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class PhoenixBusiness(private val ctx: PlatformContext) {
private val appDb by lazy { SqliteAppDb(createAppDbDriver(ctx)) }
private val paymentsDb by lazy { SqlitePaymentsDb(createPaymentsDbDriver(ctx)) }

private val chain = Chain.TESTNET
public val chain = Chain.TESTNET

private val electrumClient by lazy { ElectrumClient(tcpSocketBuilder, MainScope()) }
private val electrumWatcher by lazy { ElectrumWatcher(electrumClient, MainScope()) }
Expand Down

0 comments on commit dd398ac

Please sign in to comment.