-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🥳[Feature] Redesign unlock view (#50)
* 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
Showing
28 changed files
with
297 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
}) | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.