-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🦺[Tech debt] Add configuration to hide / unhide card tab #47
Changes from 5 commits
15855ee
c12f7ae
83faefc
d51e50e
3d94855
c4e8f03
4c68e78
81420bd
2f89a91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// LocaleChangeView.swift | ||
// loafwallet | ||
// | ||
// Created by Kerry Washington on 5/11/21. | ||
// Copyright © 2021 Litecoin Foundation. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct LocaleChangeView: View { | ||
|
||
//MARK: - Combine Variables | ||
@ObservedObject | ||
var viewModel: LocaleChangeViewModel | ||
|
||
init(viewModel: LocaleChangeViewModel) { | ||
self.viewModel = viewModel | ||
} | ||
var body: some View { | ||
VStack { | ||
|
||
Text("Current Locale: \(viewModel.displayName)") | ||
.font(Font(UIFont.barlowSemiBold(size: 18.0))) | ||
.foregroundColor(.black) | ||
.padding(.leading, 20) | ||
.padding(.top, 10) | ||
|
||
Spacer() | ||
} | ||
} | ||
} | ||
|
||
struct LocaleChangeView_Previews: PreviewProvider { | ||
|
||
static let viewModel = LocaleChangeViewModel() | ||
|
||
static var previews: some View { | ||
|
||
Group { | ||
LocaleChangeView(viewModel: viewModel) | ||
.previewDevice(PreviewDevice(rawValue: DeviceType.Name.iPhoneSE2)) | ||
.previewDisplayName(DeviceType.Name.iPhoneSE2) | ||
|
||
LocaleChangeView(viewModel: viewModel) | ||
.previewDevice(PreviewDevice(rawValue: DeviceType.Name.iPhone8)) | ||
.previewDisplayName(DeviceType.Name.iPhone8) | ||
|
||
LocaleChangeView(viewModel: viewModel) | ||
.previewDevice(PreviewDevice(rawValue: DeviceType.Name.iPhone12ProMax)) | ||
.previewDisplayName(DeviceType.Name.iPhone12ProMax) | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// LocaleChangeViewModel.swift | ||
// loafwallet | ||
// | ||
// Created by Kerry Washington on 5/11/21. | ||
// Copyright © 2021 Litecoin Foundation. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
class LocaleChangeViewModel: ObservableObject { | ||
|
||
var updatedLocale: Locale = Locale.current | ||
|
||
//MARK: - Combine Variables | ||
@Published | ||
var displayName: String = "" | ||
|
||
init() { | ||
let currentLocale = Locale.current | ||
|
||
if let regionCode = currentLocale.regionCode, | ||
let name = currentLocale.localizedString(forRegionCode: regionCode) { | ||
displayName = name | ||
} else { | ||
displayName = "-" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,40 +91,61 @@ class MainViewController : UIViewController, Subscriber, LoginViewControllerDele | |
} | ||
|
||
func didUnlockLogin() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kcw-grunt refactor this method like this:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh that won't work. The classes are custom and inherit so the values can't be passed to the NonUS and Tab ViewControllers There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kcw-grunt hmm I see. Can you do this 👇 ?
|
||
|
||
if let vc = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "TabBarViewController") as? TabBarViewController { | ||
|
||
vc.store = self.store | ||
vc.isLtcSwapped = store.state.isLtcSwapped | ||
vc.walletManager = self.walletManager | ||
|
||
if let rate = store.state.currentRate { | ||
vc.exchangeRate = rate | ||
let placeholderAmount = Amount(amount: 0, rate: rate, maxDigits: store.state.maxDigits) | ||
vc.secondaryBalanceLabel = UpdatingLabel(formatter: placeholderAmount.localFormat) | ||
vc.primaryBalanceLabel = UpdatingLabel(formatter: placeholderAmount.ltcFormat) | ||
} else { | ||
vc.secondaryBalanceLabel = UpdatingLabel(formatter: NumberFormatter()) | ||
vc.primaryBalanceLabel | ||
= UpdatingLabel(formatter: NumberFormatter()) | ||
|
||
if UserDefaults.userIsInUSA { | ||
guard let usaVC = UIStoryboard.init(name: "Main", bundle: nil) | ||
.instantiateViewController(withIdentifier: "TabBarViewController") | ||
as? TabBarViewController else { | ||
|
||
NSLog("TabBarViewController not intialized") | ||
return | ||
} | ||
|
||
addChildViewController(vc, layout:{ | ||
vc.view.constrain(toSuperviewEdges: nil) | ||
vc.view.alpha = 0 | ||
vc.view.layoutIfNeeded() | ||
|
||
usaVC.store = self.store | ||
usaVC.walletManager = walletManager | ||
|
||
addChildViewController(usaVC, layout:{ | ||
usaVC.view.constrain(toSuperviewEdges: nil) | ||
usaVC.view.alpha = 0 | ||
usaVC.view.layoutIfNeeded() | ||
}) | ||
|
||
UIView.animate(withDuration: 0.3, delay: 0.1, options: .transitionCrossDissolve, animations: { | ||
vc.view.alpha = 1 | ||
|
||
UIView.animate(withDuration: 0.3, | ||
delay: 0.1, | ||
options: .transitionCrossDissolve, | ||
animations: { | ||
|
||
usaVC.view.alpha = 1 | ||
|
||
}) { (finished) in | ||
NSLog("MainView Controller presented") | ||
NSLog(" Ex US MainView Controller presented") | ||
} | ||
|
||
} else { | ||
NSLog("ERROR: MainView Controller Not presented") | ||
|
||
guard let exUSAVC = UIStoryboard.init(name: "Main", bundle: nil) | ||
.instantiateViewController(withIdentifier: "NonUSTabBarViewController") | ||
as? NonUSTabBarViewController else { | ||
|
||
NSLog("NonUSTabBarViewController not intialized") | ||
return | ||
} | ||
|
||
exUSAVC.store = self.store | ||
exUSAVC.walletManager = walletManager | ||
|
||
addChildViewController(exUSAVC, layout:{ | ||
exUSAVC.view.constrain(toSuperviewEdges: nil) | ||
exUSAVC.view.alpha = 0 | ||
exUSAVC.view.layoutIfNeeded() | ||
}) | ||
|
||
UIView.animate(withDuration: 0.3, delay: 0.1, options: .transitionCrossDissolve, animations: { | ||
exUSAVC.view.alpha = 1 | ||
}) { (finished) in | ||
NSLog("US MainView Controller presented") | ||
} | ||
} | ||
|
||
} | ||
|
||
private func addTemporaryStartupViews() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kcw-grunt we can simplify the expression like this:
UserDefaults.userIsInUSA = suffix == "_US"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @mosadialiou this is to allow people that are in the US but speak other languages . So, someone that speaks French and has their phone set for french but are in say, New York . This region code would be "fr_US".
So this code truncates the
fr
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kcw-grunt yeah I understand. I am talking about the code. You can simplify it like I said!