Skip to content

Commit

Permalink
🥳[Feature] Redesign unlock view (#50)
Browse files Browse the repository at this point in the history
* Removed price label from Header View

- Extended tap area of the balance animation

* removed dev loginviewcontroller storyboard

* Added new lock screen SwiftUI view

* Added localizations for the Lock Screen (Login)

* Added SwiftUI : LockScreen HeaderView

- Dev code fixes
- Adjust layout

* Added simple test for the Lock Screen symbol
  • Loading branch information
kcw-grunt authored May 17, 2021
1 parent dd445b1 commit 92986e5
Show file tree
Hide file tree
Showing 28 changed files with 297 additions and 223 deletions.
20 changes: 20 additions & 0 deletions loafwallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@
C3D783A72565EA4B0004FF70 /* UnstoppableDomainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3D783A62565EA4A0004FF70 /* UnstoppableDomainView.swift */; };
C3D783B72565EA6B0004FF70 /* UnstoppableDomainViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3D783B62565EA6B0004FF70 /* UnstoppableDomainViewModel.swift */; };
C3D783C02565ECF60004FF70 /* UnstoppableDomainViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3D783BF2565ECF60004FF70 /* UnstoppableDomainViewModelTests.swift */; };
C3EFA9A12650807B005C59B5 /* LockScreenHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3EFA9A02650807B005C59B5 /* LockScreenHeaderView.swift */; };
C3EFA9A3265080FF005C59B5 /* LockScreenHeaderViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3EFA9A2265080FF005C59B5 /* LockScreenHeaderViewModel.swift */; };
C3EFA9A62651A808005C59B5 /* LockScreenTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3EFA9A52651A808005C59B5 /* LockScreenTests.swift */; };
C3F55645255A193D005F786F /* SupportLitecoinFoundationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F55644255A193D005F786F /* SupportLitecoinFoundationView.swift */; };
C3F55655255A195B005F786F /* SupportLitecoinFoundationViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F55654255A195B005F786F /* SupportLitecoinFoundationViewModel.swift */; };
C3F7BCDC25FEC6AD00694C28 /* FailedAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F7BCD925FEC6AC00694C28 /* FailedAlertView.swift */; };
Expand Down Expand Up @@ -1498,6 +1501,9 @@
C3D783A62565EA4A0004FF70 /* UnstoppableDomainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnstoppableDomainView.swift; sourceTree = "<group>"; };
C3D783B62565EA6B0004FF70 /* UnstoppableDomainViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnstoppableDomainViewModel.swift; sourceTree = "<group>"; };
C3D783BF2565ECF60004FF70 /* UnstoppableDomainViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnstoppableDomainViewModelTests.swift; sourceTree = "<group>"; };
C3EFA9A02650807B005C59B5 /* LockScreenHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LockScreenHeaderView.swift; sourceTree = "<group>"; };
C3EFA9A2265080FF005C59B5 /* LockScreenHeaderViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LockScreenHeaderViewModel.swift; sourceTree = "<group>"; };
C3EFA9A52651A808005C59B5 /* LockScreenTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LockScreenTests.swift; sourceTree = "<group>"; };
C3F55644255A193D005F786F /* SupportLitecoinFoundationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupportLitecoinFoundationView.swift; sourceTree = "<group>"; };
C3F55654255A195B005F786F /* SupportLitecoinFoundationViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupportLitecoinFoundationViewModel.swift; sourceTree = "<group>"; };
C3F7BCD925FEC6AC00694C28 /* FailedAlertView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FailedAlertView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2184,6 +2190,7 @@
2465873723A5AAD100A32E9E /* loafwalletTests */ = {
isa = PBXGroup;
children = (
C3EFA9A42651A7C4005C59B5 /* Lock Screen Tests */,
C32DB42B264847D500017D26 /* Card Tests */,
C3188E3126445E5E0008ADD1 /* File Tests */,
C3B7C3EC255FF56100E98A64 /* Constants Tests */,
Expand Down Expand Up @@ -3165,6 +3172,8 @@
C3D4379E2566EA3E00F423E1 /* LWActivityIndicator.swift */,
C30029E125D0185500F08C2B /* StandardDividerView.swift */,
C30029EA25D019BC00F08C2B /* CopyButtonView.swift */,
C3EFA9A02650807B005C59B5 /* LockScreenHeaderView.swift */,
C3EFA9A2265080FF005C59B5 /* LockScreenHeaderViewModel.swift */,
);
name = "SwiftUI+UIKit";
sourceTree = "<group>";
Expand Down Expand Up @@ -3202,6 +3211,14 @@
name = Unstoppable;
sourceTree = "<group>";
};
C3EFA9A42651A7C4005C59B5 /* Lock Screen Tests */ = {
isa = PBXGroup;
children = (
C3EFA9A52651A808005C59B5 /* LockScreenTests.swift */,
);
path = "Lock Screen Tests";
sourceTree = "<group>";
};
C3F55643255A1916005F786F /* SupportLitecoinFoundation */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -4066,6 +4083,7 @@
2494037623AD35C000369261 /* BuyWKWebVCTests.swift in Sources */,
24470E3223A5F5B100ADDA27 /* NSDataExtensionTests.swift in Sources */,
24470E2C23A5F43B00ADDA27 /* DefaultFiatCurrencyTests.swift in Sources */,
C3EFA9A62651A808005C59B5 /* LockScreenTests.swift in Sources */,
24470E4023A6004800ADDA27 /* WalletCreationTests.swift in Sources */,
24470E3823A5FEF200ADDA27 /* SpendingLimitTests.swift in Sources */,
24470E3E23A6000900ADDA27 /* WalletAuthenticationTests.swift in Sources */,
Expand Down Expand Up @@ -4391,6 +4409,7 @@
C30899792616426800EE6A40 /* ForgotAlertViewModel.swift in Sources */,
CEBF33041DDE17A600348FC6 /* Transaction.swift in Sources */,
CEAA9E911DC0FDFE0066731D /* UIViewPropertyAnimator+BRWAdditions.swift in Sources */,
C3EFA9A12650807B005C59B5 /* LockScreenHeaderView.swift in Sources */,
C3BD4A4A2597542700D97079 /* LoginCardAlertView.swift in Sources */,
CEAA9EA01DC2F9F50066731D /* UIFont+BRWAdditions.swift in Sources */,
C32DB42F26488CAA00017D26 /* NonUSTabBarViewController.swift in Sources */,
Expand Down Expand Up @@ -4431,6 +4450,7 @@
CECCE5A51E02408300D99448 /* UIView+FrameChangeBlocking.swift in Sources */,
22A9A94F1DF61945000F0016 /* BRHTTPRouter.swift in Sources */,
CE6DCC271E6108D50044257B /* EnterPhraseCell.swift in Sources */,
C3EFA9A3265080FF005C59B5 /* LockScreenHeaderViewModel.swift in Sources */,
CE760EDD1E561DF900EFAC2B /* UpdatePinViewController.swift in Sources */,
22A9A9481DF61945000F0016 /* BRBitID.swift in Sources */,
24BA90C62410129E001E3825 /* FeeSelectorView.swift in Sources */,
Expand Down
5 changes: 5 additions & 0 deletions loafwallet/Color+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ extension Color {
static var liteWalletBlue: Color { //345D9D
return Color(UIColor.liteWalletBlue)
}

static var liteWalletDarkBlue: Color { //163e7f
return Color(UIColor.liteWalletDarkBlue)
}

}
2 changes: 1 addition & 1 deletion loafwallet/LWAnalytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class LWAnalytics {
properties?.forEach { key, value in
parameters[key] = value
}

Analytics.logEvent(itemName.rawValue, parameters: parameters)
}

Expand Down
65 changes: 65 additions & 0 deletions loafwallet/LockScreenHeaderView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// LockScreenHeaderView.swift
// loafwallet
//
// Created by Kerry Washington on 5/15/21.
// Copyright © 2021 Litecoin Foundation. All rights reserved.
//

import SwiftUI

struct LockScreenHeaderView: View {

//MARK: - Combine Variables
@ObservedObject
var viewModel: LockScreenHeaderViewModel

init(viewModel: LockScreenHeaderViewModel) {
self.viewModel = viewModel
}

var body: some View {

Color
.liteWalletDarkBlue
.opacity(0.9)
.edgesIgnoringSafeArea(.all)
.overlay(
VStack() {
Spacer()
Text(" 1 LTC = \(viewModel.currentValueInFiat)")
.font(Font(UIFont.barlowSemiBold(size: 16.0)))
.foregroundColor(.white)

Text("\(S.History.currentLitecoinValue) \(viewModel.currencyCode)")
.font(Font(UIFont.barlowRegular(size: 14.0)))
.foregroundColor(Color.white.opacity(0.5))
.padding(.bottom, 10)
})
}
}


struct LockScreenHeaderView_Previews: PreviewProvider {

static let store = Store()
static let viewModel = LockScreenHeaderViewModel(store: store)

static var previews: some View {

Group {
LockScreenHeaderView(viewModel: viewModel)
.previewDevice(PreviewDevice(rawValue: DeviceType.Name.iPhoneSE2))
.previewDisplayName(DeviceType.Name.iPhoneSE2)

LockScreenHeaderView(viewModel: viewModel)
.previewDevice(PreviewDevice(rawValue: DeviceType.Name.iPhone8))
.previewDisplayName(DeviceType.Name.iPhone8)

LockScreenHeaderView(viewModel: viewModel)
.previewDevice(PreviewDevice(rawValue: DeviceType.Name.iPhone12ProMax))
.previewDisplayName(DeviceType.Name.iPhone12ProMax)
}
}
}

61 changes: 61 additions & 0 deletions loafwallet/LockScreenHeaderViewModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// LockScreenHeaderViewModel.swift
// loafwallet
//
// Created by Kerry Washington on 5/15/21.
// Copyright © 2021 Litecoin Foundation. All rights reserved.
//

import Foundation

class LockScreenHeaderViewModel: ObservableObject, Subscriber {

//MARK: - Combine Variables
@Published
var currentValueInFiat: String = ""

@Published
var currencyCode: String = ""

//MARK: - Public Variables
var store: Store?

init(store: Store) {

self.store = store

addSubscriptions()
fetchCurrentPrice()
}

private func fetchCurrentPrice() {

guard let currentRate = self.store?.state.currentRate else {
print("Error: Rate not fetched")
return
}

// Price Label
let fiatRate = Double( round ( 100 * currentRate.rate / 100))
let formattedFiatString = String(format: "%.02f", fiatRate)
currencyCode = currentRate.code
let currencySymbol = Currency.getSymbolForCurrencyCode(code: currencyCode) ?? ""
currentValueInFiat = String(currencySymbol + formattedFiatString)
}

// MARK: - Add Subscriptions
private func addSubscriptions() {

guard let store = self.store else {
NSLog("ERROR: Store not initialized")
return
}

store.subscribe(self, selector: { $0.currentRate != $1.currentRate},
callback: { _ in
self.fetchCurrentPrice()
})

}
}

23 changes: 1 addition & 22 deletions loafwallet/NonUSTabBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ class NonUSTabBarViewController: UIViewController, Subscriber, Trackable, UITabB
@IBOutlet weak var headerView: UIView!
@IBOutlet weak var containerView: UIView!
@IBOutlet weak var tabBar: UITabBar!
@IBOutlet weak var currentLTCPriceLabel: UILabel!
@IBOutlet weak var settingsButton: UIButton!
@IBOutlet weak var timeStampLabel: UILabel!
@IBOutlet weak var timeStampStackView: UIStackView!
@IBOutlet weak var timeStampStackViewHeight: NSLayoutConstraint!
@IBOutlet weak var walletBalanceLabel: UILabel!

var primaryBalanceLabel: UpdatingLabel?
Expand Down Expand Up @@ -175,7 +171,7 @@ class NonUSTabBarViewController: UIViewController, Subscriber, Trackable, UITabB

currencyTapView.constrain([
currencyTapView.leadingAnchor.constraint(equalTo: headerView.leadingAnchor, constant: 0),
currencyTapView.trailingAnchor.constraint(equalTo: self.timeStampStackView.leadingAnchor, constant: 0),
currencyTapView.trailingAnchor.constraint(equalTo: self.settingsButton.leadingAnchor, constant: -C.padding[5]),
currencyTapView.topAnchor.constraint(equalTo: primaryLabel.topAnchor, constant: 0),
currencyTapView.bottomAnchor.constraint(equalTo: primaryLabel.bottomAnchor, constant: C.padding[1]) ])

Expand Down Expand Up @@ -281,23 +277,6 @@ class NonUSTabBarViewController: UIViewController, Subscriber, Trackable, UITabB
secondaryLabel.transform = .identity
primaryLabel.transform = transform(forView: primaryLabel)
}

// Time and Price Label
let timeText = S.TransactionDetails.priceTimeStampLabel + " " + dateFormatter.string(from: Date())
let fiatRate = Double(round(100*rate.rate)/100)
let formattedFiatString = String(format: "%.02f", fiatRate)
let newPrice = Currency.getSymbolForCurrencyCode(code: rate.code)! + formattedFiatString

self.currentLTCPriceLabel.text = " "
self.timeStampLabel.text = timeText

// Transitions when the data changes
UIView.transition(with: self.currentLTCPriceLabel,
duration: 2.0,
options: .transitionFlipFromLeft,
animations: { [weak self] in
self?.currentLTCPriceLabel.text = newPrice
}, completion: nil)
}

/// Transform LTC and Fiat Balances
Expand Down
Loading

0 comments on commit 92986e5

Please sign in to comment.