Skip to content

Commit

Permalink
IOS-3632 Revert "IOS-3632 Renamed NFCTag -> ScanTagImage. Moved it ou…
Browse files Browse the repository at this point in the history
…t of style into config"

This reverts commit 83385d6.
  • Loading branch information
megakoko committed May 16, 2023
1 parent b38f991 commit 9c2b4d7
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 39 deletions.
4 changes: 0 additions & 4 deletions TangemSdk/TangemSdk.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@
B0EC6500260110530088F03D /* WalletDeserializer.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0EC64FF260110530088F03D /* WalletDeserializer.swift */; };
B0EC6508260110CC0088F03D /* ReadWalletCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0EC6507260110CC0088F03D /* ReadWalletCommand.swift */; };
B0EC650E260131220088F03D /* ReadWalletsListCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0EC650D260131220088F03D /* ReadWalletsListCommand.swift */; };
DA11B1802A13876200C4604B /* ScanTagImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA11B17F2A13876200C4604B /* ScanTagImage.swift */; };
DA216CC0282E4D86003585B9 /* AccessCodeRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA216CBF282E4D86003585B9 /* AccessCodeRepository.swift */; };
DA6C752A292682650070EEFD /* LAContext+.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA6C7529292682650070EEFD /* LAContext+.swift */; };
DC1244B329B60B6F0037BC05 /* BIP39.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC1244B229B60B6F0037BC05 /* BIP39.swift */; };
Expand Down Expand Up @@ -635,7 +634,6 @@
B0EC64FF260110530088F03D /* WalletDeserializer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletDeserializer.swift; sourceTree = "<group>"; };
B0EC6507260110CC0088F03D /* ReadWalletCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReadWalletCommand.swift; sourceTree = "<group>"; };
B0EC650D260131220088F03D /* ReadWalletsListCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReadWalletsListCommand.swift; sourceTree = "<group>"; };
DA11B17F2A13876200C4604B /* ScanTagImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScanTagImage.swift; sourceTree = "<group>"; };
DA216CBF282E4D86003585B9 /* AccessCodeRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessCodeRepository.swift; sourceTree = "<group>"; };
DA6C7529292682650070EEFD /* LAContext+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LAContext+.swift"; sourceTree = "<group>"; };
DADB544F298BAFBC00491102 /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/Localizable.strings"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -981,7 +979,6 @@
5D7D5FB123449D4000058D69 /* SessionEnvironment.swift */,
5D705B5A23DAF2BB002CCD7A /* Config.swift */,
5D379C28268FA4AC00C7F473 /* CardSessionRunnable.swift */,
DA11B17F2A13876200C4604B /* ScanTagImage.swift */,
);
path = Core;
sourceTree = "<group>";
Expand Down Expand Up @@ -1813,7 +1810,6 @@
B006971825FFABA10040D203 /* InteractionMode.swift in Sources */,
DC1244E029BB6D460037BC05 /* Base58.swift in Sources */,
DCC0A21129D3146100C45B13 /* SetUserSettingsCommand.swift in Sources */,
DA11B1802A13876200C4604B /* ScanTagImage.swift in Sources */,
5DDD6C5625D2D14000E48D7B /* TlvLogging.swift in Sources */,
5D58202024221E060057EF40 /* CardSession.swift in Sources */,
B0390F92256590250061E5ED /* EllipticCurve.swift in Sources */,
Expand Down
4 changes: 2 additions & 2 deletions TangemSdk/TangemSdk/Common/Core/CardSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ public class CardSession {
break
case .sessionStarted:
self.viewDelegate.sessionStarted()
self.viewDelegate.setState(.scan(scanTagImage: environment.config.scanTagImage))
self.viewDelegate.setState(.scan)
case .sessionStopped:
self.viewDelegate.sessionStopped(completion: nil)
case .tagConnected:
self.viewDelegate.tagConnected()
self.viewDelegate.setState(.default)
case .tagLost:
self.viewDelegate.tagLost()
self.viewDelegate.setState(.scan(scanTagImage: environment.config.scanTagImage))
self.viewDelegate.setState(.scan)
}
})
.store(in: &nfcReaderSubscriptions)
Expand Down
3 changes: 0 additions & 3 deletions TangemSdk/TangemSdk/Common/Core/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ public struct Config {

/// Localized reason for Touch ID. DO NOT leave it empty.
public var biometricsLocalizedReason: String = "touch_id_localized_reason".localized

/// Image to be displayed as a scan tag on the scanning screen
public var scanTagImage: ScanTagImage = .genericCard
}

public enum CardIdDisplayFormat {
Expand Down
21 changes: 0 additions & 21 deletions TangemSdk/TangemSdk/Common/Core/ScanTagImage.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class DefaultSessionViewDelegate: BaseViewDelegate {
private let engine: HapticsEngine
private var pinnedMessage: String?
private var style: TangemSdkStyle
private let viewModel: MainViewModel = .init(viewState: .empty)
private let viewModel: MainViewModel = .init(viewState: .scan)

init(reader: CardReader, style: TangemSdkStyle) {
self.reader = reader
Expand Down
6 changes: 3 additions & 3 deletions TangemSdk/TangemSdk/UI/Main/MainScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ struct MainScreen: View {
@ViewBuilder
private var mainView: some View {
switch viewModel.viewState {
case .scan(let scanTagImage):
ReadView(scanTagImage: scanTagImage)
case .scan:
ReadView()

case .requestCode(let type, cardId: let cardId, let showForgotButton, completion: let completion):
EnterUserCodeView(title: type.enterCodeTitle,
Expand Down Expand Up @@ -84,7 +84,7 @@ private extension MainScreen {
struct MainScreen_Preview: PreviewProvider {
static var previews: some View {
MainScreen()
.environmentObject(MainViewModel(viewState: .scan(scanTagImage: .genericCard)))
.environmentObject(MainViewModel(viewState: .scan))
.environmentObject(TangemSdkStyle())
}
}
Expand Down
2 changes: 1 addition & 1 deletion TangemSdk/TangemSdk/UI/Main/SessionViewDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public enum SessionViewState {
case progress(percent: Int)
case `default`
case empty
case scan(scanTagImage: ScanTagImage)
case scan
case requestCode(_ type: UserCodeType, cardId: String?, showForgotButton: Bool, completion: CompletionResult<String>)
case requestCodeChange(_ type: UserCodeType, cardId: String?, completion: CompletionResult<String>)

Expand Down
16 changes: 16 additions & 0 deletions TangemSdk/TangemSdk/UI/TangemSdkStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class TangemSdkStyle: ObservableObject {
public var colors: Colors = .default
public var textSizes: TextSizes = .default
public var indicatorWidth: Float = 12
public var nfcTag: NFCTag = .genericCard

public static var `default`: TangemSdkStyle = .init()
}
Expand Down Expand Up @@ -66,3 +67,18 @@ public extension TangemSdkStyle {
public static var `default`: TextSizes = .init()
}
}

@available(iOS 13.0, *)
public extension TangemSdkStyle {
/// Options for displaying different tags on the scanning screen
enum NFCTag {
/// Generic card provided by the SDK
case genericCard

/// A custom tag made out of an UIImage instance.
/// The image can be shifted vertically from the standard position by specifying `verticalOffset`.
/// Note that the width of the image will be limited to a certain size, while the height will be determined by the aspect ratio of the image.
/// The value of the width can be found in ReadView.swift and is 210 points at the time of the writing.
case image(uiImage: UIImage, verticalOffset: Double)
}
}
7 changes: 3 additions & 4 deletions TangemSdk/TangemSdk/UI/Views/Scan/ReadView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import SwiftUI
struct ReadView: View {
@EnvironmentObject var style: TangemSdkStyle

@State var scanTagImage: ScanTagImage
@State private var cardOffset: CGSize = .init(width: -220, height: -160)

var body: some View {
Expand Down Expand Up @@ -43,7 +42,7 @@ struct ReadView: View {

@ViewBuilder
private var tagView: some View {
switch scanTagImage {
switch style.nfcTag {
case .genericCard:
CardView(cardColor: style.colors.cardColor, starsColor: style.colors.starsColor)
case .image(let uiImage, let verticalOffset):
Expand All @@ -59,8 +58,8 @@ struct ReadView: View {
struct ReadView_Previews: PreviewProvider {
static var previews: some View {
Group {
ReadView(scanTagImage: .genericCard)
ReadView(scanTagImage: .genericCard)
ReadView()
ReadView()
.preferredColorScheme(.dark)
}
.environmentObject(TangemSdkStyle())
Expand Down

0 comments on commit 9c2b4d7

Please sign in to comment.