show trx detail view

This commit is contained in:
loj 2019-01-27 18:52:22 +01:00
parent 5faf3db968
commit 3503f7cf21
22 changed files with 474 additions and 88 deletions

View File

@ -35,8 +35,14 @@
EE377EDA21F4BE5500138385 /* TrxHistoryProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE377ED921F4BE5500138385 /* TrxHistoryProvider.swift */; };
EE377EDF21F4C45A00138385 /* TrxHistoryProviderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE377EDE21F4C45A00138385 /* TrxHistoryProviderTests.swift */; };
EE377EE221F4F18700138385 /* TrxDirection.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE377EE121F4F18700138385 /* TrxDirection.swift */; };
EE377EE421F4F1A100138385 /* TrxDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE377EE321F4F1A100138385 /* TrxDetail.swift */; };
EE377EE621F4F1C400138385 /* TrxHistoryObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE377EE521F4F1C400138385 /* TrxHistoryObserver.swift */; };
EE377EE421F4F1A100138385 /* TrxDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE377EE321F4F1A100138385 /* TrxDetails.swift */; };
EE377EE621F4F1C400138385 /* TrxHistoryObservable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE377EE521F4F1C400138385 /* TrxHistoryObservable.swift */; };
EE377EE921F7A76500138385 /* TrxDetailsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE377EE821F7A76500138385 /* TrxDetailsVC.swift */; };
EE377EEB21F7AF3C00138385 /* TrxDetailTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE377EEA21F7AF3C00138385 /* TrxDetailTableViewCell.swift */; };
EE377EED21F7B02600138385 /* TrxMemoTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE377EEC21F7B02600138385 /* TrxMemoTableViewCell.swift */; };
EE377EEF21FDE64400138385 /* TrxDetails.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EE07A44B21E206D7006031C8 /* TrxDetails.storyboard */; };
EE377EF121FDEE3F00138385 /* ZEC.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE377EF021FDEE3F00138385 /* ZEC.swift */; };
EE377EF321FE181000138385 /* Date-Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE377EF221FE181000138385 /* Date-Extension.swift */; };
EE576FFE21CFCC5500433CAB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE576FFD21CFCC5500433CAB /* AppDelegate.swift */; };
EE57700321CFCC5500433CAB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EE57700121CFCC5500433CAB /* Main.storyboard */; };
EE57700521CFCC5600433CAB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EE57700421CFCC5600433CAB /* Assets.xcassets */; };
@ -102,8 +108,14 @@
EE377ED921F4BE5500138385 /* TrxHistoryProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrxHistoryProvider.swift; sourceTree = "<group>"; };
EE377EDE21F4C45A00138385 /* TrxHistoryProviderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrxHistoryProviderTests.swift; sourceTree = "<group>"; };
EE377EE121F4F18700138385 /* TrxDirection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrxDirection.swift; sourceTree = "<group>"; };
EE377EE321F4F1A100138385 /* TrxDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrxDetail.swift; sourceTree = "<group>"; };
EE377EE521F4F1C400138385 /* TrxHistoryObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrxHistoryObserver.swift; sourceTree = "<group>"; };
EE377EE321F4F1A100138385 /* TrxDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrxDetails.swift; sourceTree = "<group>"; };
EE377EE521F4F1C400138385 /* TrxHistoryObservable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrxHistoryObservable.swift; sourceTree = "<group>"; };
EE377EE821F7A76500138385 /* TrxDetailsVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrxDetailsVC.swift; sourceTree = "<group>"; };
EE377EEA21F7AF3C00138385 /* TrxDetailTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrxDetailTableViewCell.swift; sourceTree = "<group>"; };
EE377EEC21F7B02600138385 /* TrxMemoTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrxMemoTableViewCell.swift; sourceTree = "<group>"; };
EE377EEE21F9013800138385 /* ___TODO.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = "___TODO.md"; sourceTree = "<group>"; };
EE377EF021FDEE3F00138385 /* ZEC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZEC.swift; sourceTree = "<group>"; };
EE377EF221FE181000138385 /* Date-Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date-Extension.swift"; sourceTree = "<group>"; };
EE576FFA21CFCC5500433CAB /* ZWallet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ZWallet.app; sourceTree = BUILT_PRODUCTS_DIR; };
EE576FFD21CFCC5500433CAB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
EE57700221CFCC5500433CAB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
@ -205,6 +217,7 @@
isa = PBXGroup;
children = (
EE377ECE21EB56AD00138385 /* ZWKeyboardLayoutConstraint.swift */,
EE377EF221FE181000138385 /* Date-Extension.swift */,
);
path = Extensions;
sourceTree = "<group>";
@ -230,13 +243,24 @@
EE377EE021F4F16100138385 /* Types */ = {
isa = PBXGroup;
children = (
EE377EE321F4F1A100138385 /* TrxDetail.swift */,
EE377EE321F4F1A100138385 /* TrxDetails.swift */,
EE377EE121F4F18700138385 /* TrxDirection.swift */,
EE377EE521F4F1C400138385 /* TrxHistoryObserver.swift */,
EE377EE521F4F1C400138385 /* TrxHistoryObservable.swift */,
EE377EF021FDEE3F00138385 /* ZEC.swift */,
);
path = Types;
sourceTree = "<group>";
};
EE377EE721F7A71A00138385 /* TrxDetails */ = {
isa = PBXGroup;
children = (
EE377EEA21F7AF3C00138385 /* TrxDetailTableViewCell.swift */,
EE377EE821F7A76500138385 /* TrxDetailsVC.swift */,
EE377EEC21F7B02600138385 /* TrxMemoTableViewCell.swift */,
);
path = TrxDetails;
sourceTree = "<group>";
};
EE576FF121CFCC5500433CAB = {
isa = PBXGroup;
children = (
@ -258,6 +282,7 @@
EE576FFC21CFCC5500433CAB /* ZWallet */ = {
isa = PBXGroup;
children = (
EE377EEE21F9013800138385 /* ___TODO.md */,
EE57701E21CFCFCE00433CAB /* _Assets */,
EE57701D21CFCFB000433CAB /* _Main */,
EE57702721D000EE00433CAB /* Definitions */,
@ -333,6 +358,7 @@
EE07A44E21E217E0006031C8 /* Main */,
EE377EC321E8F44C00138385 /* Passphrase */,
EE377EBA21E68A6600138385 /* Pin */,
EE377EE721F7A71A00138385 /* TrxDetails */,
);
path = Views;
sourceTree = "<group>";
@ -478,6 +504,7 @@
EE76B85C21D8D1930093571F /* SourceSansPro-BoldItalic.ttf in Resources */,
EE377ECC21EB4A6800138385 /* Passphrase.storyboard in Resources */,
EE76B85321D8D1930093571F /* SourceSansPro-BlackItalic.ttf in Resources */,
EE377EEF21FDE64400138385 /* TrxDetails.storyboard in Resources */,
EE76B85821D8D1930093571F /* SourceSansPro-Light.ttf in Resources */,
EE76B85621D8D1930093571F /* SourceSansPro-Bold.ttf in Resources */,
EE76B85921D8D1930093571F /* SourceSansPro-Black.ttf in Resources */,
@ -516,18 +543,22 @@
EE07A45221E23E92006031C8 /* MainVCDelegate.swift in Sources */,
EE377EC521E8F47100138385 /* PassphraseVC.swift in Sources */,
EE57702621CFFDDB00433CAB /* ZWButtom.swift in Sources */,
EE377EEB21F7AF3C00138385 /* TrxDetailTableViewCell.swift in Sources */,
EE377EDA21F4BE5500138385 /* TrxHistoryProvider.swift in Sources */,
EE07A46E21E3E71B006031C8 /* OnboardingCoordinator.swift in Sources */,
EE377ED821F485FB00138385 /* HomeCoordinator.swift in Sources */,
EE07A46C21E29EA4006031C8 /* BaseCoordinator.swift in Sources */,
EE57702B21D0230C00433CAB /* ZWProgressBar.swift in Sources */,
EE377EED21F7B02600138385 /* TrxMemoTableViewCell.swift in Sources */,
EE57702921D0011400433CAB /* Colors.swift in Sources */,
EE377EE621F4F1C400138385 /* TrxHistoryObserver.swift in Sources */,
EE377EE421F4F1A100138385 /* TrxDetail.swift in Sources */,
EE377EE621F4F1C400138385 /* TrxHistoryObservable.swift in Sources */,
EE377EE421F4F1A100138385 /* TrxDetails.swift in Sources */,
EE377ECB21E8F71700138385 /* PassphraseEntryMode.swift in Sources */,
EE377EB321E5303E00138385 /* ViewFactory.swift in Sources */,
EE07A47221E3EACE006031C8 /* OnboardingCoordinator.Delegate.swift in Sources */,
EE377EF321FE181000138385 /* Date-Extension.swift in Sources */,
EE07A45521E24FDD006031C8 /* Localization.swift in Sources */,
EE377EE921F7A76500138385 /* TrxDetailsVC.swift in Sources */,
EE576FFE21CFCC5500433CAB /* AppDelegate.swift in Sources */,
EE377EC021E7D92200138385 /* PinEntryMode.swift in Sources */,
EE377EB721E6831E00138385 /* CreateNewWalletCoordinator.Delegate.swift in Sources */,
@ -538,6 +569,7 @@
EE377EC221E7DFD200138385 /* Constants.swift in Sources */,
EE377EC921E8F67000138385 /* PassphraseVCDelegate.swift in Sources */,
EE07A45721E26E88006031C8 /* IocContainer.swift in Sources */,
EE377EF121FDEE3F00138385 /* ZEC.swift in Sources */,
EE377ED221F47E1400138385 /* HomeVC.swift in Sources */,
EE377ED621F4835F00138385 /* HomeVCDelegate.swift in Sources */,
EE377EBE21E68C0B00138385 /* PinVCDelegate.swift in Sources */,

View File

@ -31,4 +31,8 @@ public class Colors {
background: Colors.zwalletColor,
border: Colors.zwalletColor,
text: .white)
public static let trxDetailReceivedBackgroundColor = UIColor(red: 0.15, green: 0.7, blue: 0.32, alpha: 1)
public static let trxDetailSentBackgroundColor = UIColor(red: 0.87, green: 0.07, blue: 0.13, alpha: 1)
}

View File

@ -12,5 +12,8 @@ import Foundation
internal class Constants {
public static let pinCodeLength = 6
public static let atomicUnitsPerZec: UInt64 = 1_000_000_000_000
public static let numberOfFractionDigits: Int = 12
public static let prettyPrintNumberOfFractionDigits = 7
}

View File

@ -0,0 +1,29 @@
//
// Date-Extension.swift
// ZWallet
//
// Created by loj on 27.01.19.
// Copyright © 2019 XMR Systems LLC. All rights reserved.
//
import Foundation
extension Date {
/// Formatted date and time
public func dateAndTime() -> String {
let df = DateFormatter()
df.dateStyle = .medium
df.timeStyle = .medium
return df.string(from: self)
}
/// Formatted time in HH:mm
public func time() -> String {
let df = DateFormatter()
df.dateStyle = .none
df.timeStyle = .medium
return df.string(from: self)
}
}

View File

@ -18,11 +18,35 @@
"pin.description.confirmPin" = "Du kennst das. Wiederhole den PIN aus dem letzten Schritt um diesen zu bestätigen.";
"passphrase.title.initialPassphrase" = "Wähle ein Passwort";
"passphrase.description.initialPassphrase" = "Bitte wähle ein Passwort um das Backup deiner Wallet zu verschlüsseln. Deine Backups werden in deinem iCloud Nutzerkonto gespeichert. Falls du dein Passwort vergisst kann deine Wallet nicht wiederhergestellt werden.";
"passphrase.next" = "Weiter";
"passphrase.placeholder.initialPassphrase" = "Passwort";
"passphrase.title.confirmPassphrase" = "Bestätige Passwort";
"passphrase.description.confirmPassphrase" = "Wiederhole dein Passwort und notiere es *exakt so wie du es hier eingibst* auf einem Blatt Papier. Anschliessend versorge dieses Papier an einem sicheren Ort. Zeige es niemandem und rede nicht darüber.";
"passphrase.placeholder.confirmPassphrase" = "Wiederhole dein Passwort";
"passphrase.mismatch.title" = "Passwort ungleich";
"global.Ok" = "Ok";
"trxDetailCell.received" = "Empfangen";
"trxDetail.received" = "Empfangen";
"trxDetailCell.sent" = "Gesendet";
"trxDetail.sent" = "Gesendet";
"trxDetail.date" = "Datum";
"trxDetail.sourceAddress" = "Von Adresse";
"trxDetail.trxId" = "Transaktions-ID";
"trxDetail.memo" = "Anmerkung";
"trxDetail.destinationAddress" = "Nach Adresse";

View File

@ -36,7 +36,17 @@
"global.Ok" = "Ok";
"trxDetailCell.received" = "Received";
"trxDetail.received" = "Received";
"trxDetailCell.sent" = "Sent";
"trxDetail.sent" = "Sent";
"trxDetail.date" = "Date";
"trxDetail.sourceAddress" = "From Address";
"trxDetail.trxId" = "Transaction ID";
"trxDetail.memo" = "Memo";
"trxDetail.destinationAddress" = "To Address";

View File

@ -10,30 +10,30 @@ import Foundation
public protocol TrxHistoryProviderProtocol: class {
func add(trxDetail: TrxDetail)
func all() -> [TrxDetail]
func add(trxDetails: TrxDetails)
func all() -> [TrxDetails]
func count() -> Int
func register(observer: TrxHistoryObserver)
func deregister(observer: TrxHistoryObserver)
func register(observer: TrxHistoryObservable)
func deregister(observer: TrxHistoryObservable)
}
public class TrxHistoryProvider: TrxHistoryProviderProtocol {
private var trxHistory: [TrxDetail]
private var observers: [TrxHistoryObserver]
private var trxHistory: [TrxDetails]
private var observers: [TrxHistoryObservable]
public init() {
self.trxHistory = [TrxDetail]()
self.observers = [TrxHistoryObserver]()
self.trxHistory = [TrxDetails]()
self.observers = [TrxHistoryObservable]()
}
public func add(trxDetail: TrxDetail) {
self.trxHistory.append(trxDetail)
public func add(trxDetails: TrxDetails) {
self.trxHistory.append(trxDetails)
self.notifyAllObservers()
}
public func all() -> [TrxDetail] {
public func all() -> [TrxDetails] {
return self.trxHistory
}
@ -41,11 +41,11 @@ public class TrxHistoryProvider: TrxHistoryProviderProtocol {
return self.trxHistory.count
}
public func register(observer: TrxHistoryObserver) {
public func register(observer: TrxHistoryObservable) {
self.observers.append(observer)
}
public func deregister(observer: TrxHistoryObserver) {
public func deregister(observer: TrxHistoryObservable) {
self.observers = self.observers.filter { $0 !== observer }
}

View File

@ -24,6 +24,7 @@ internal protocol ViewFactoryProtocol {
func getPinView() -> PinVC
func getPassphraseView() -> PassphraseVC
func getHomeView() -> HomeVC
func getTrxDetailsView() -> TrxDetailsVC
}
@ -45,6 +46,10 @@ internal class ViewFactory: ViewFactoryProtocol {
return UIStoryboard(name: "Home", bundle: nil)
}()
private lazy var trxDetailsStoryboard: UIStoryboard = {
return UIStoryboard(name: "TrxDetails", bundle: nil)
}()
func getOnboardingMainView() -> MainVC {
let vc = self.mainStoryboard.instantiateViewController(withIdentifier: "Main") as! MainVC
return vc
@ -64,4 +69,9 @@ internal class ViewFactory: ViewFactoryProtocol {
let vc = self.homeStoryboard.instantiateViewController(withIdentifier: "Home") as! HomeVC
return vc
}
func getTrxDetailsView() -> TrxDetailsVC {
let vc = self.trxDetailsStoryboard.instantiateViewController(withIdentifier: "TrxDetails") as! TrxDetailsVC
return vc
}
}

View File

@ -29,7 +29,7 @@
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" allowsSelection="NO" rowHeight="80" estimatedRowHeight="80" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="etR-G8-YOv" userLabel="TrxTableView">
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" rowHeight="80" estimatedRowHeight="80" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="etR-G8-YOv" userLabel="TrxTableView">
<rect key="frame" x="0.0" y="256" width="414" height="640"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<prototypes>
@ -57,9 +57,9 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" alpha="0.40000000000000002" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="!!22:08" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="TJc-P0-KVQ">
<rect key="frame" x="54" y="43" width="50" height="18"/>
<rect key="frame" x="54" y="43" width="100" height="18"/>
<constraints>
<constraint firstAttribute="width" constant="50" id="i3t-uO-hLC"/>
<constraint firstAttribute="width" constant="100" id="i3t-uO-hLC"/>
</constraints>
<fontDescription key="fontDescription" name="SourceSansPro-Regular" family="Source Sans Pro" pointSize="14"/>
<nil key="textColor"/>
@ -120,7 +120,7 @@
<rect key="frame" x="0.0" y="0.0" width="414" height="256"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="!!Balance" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Uox-ul-SfL" userLabel="TitleLabel">
<rect key="frame" x="132" y="58" width="150" height="21"/>
<rect key="frame" x="132" y="58" width="150" height="23"/>
<constraints>
<constraint firstAttribute="width" constant="150" id="y3J-5f-Wcc"/>
</constraints>
@ -129,13 +129,13 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="!!2'208.123456 ZEC" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oqZ-HW-Zcf" userLabel="AmountLabel">
<rect key="frame" x="8" y="103" width="398" height="47"/>
<rect key="frame" x="8" y="105" width="398" height="50.5"/>
<fontDescription key="fontDescription" name="SourceSansPro-Light" family="Source Sans Pro" pointSize="40"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" alpha="0.5" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="!!22.08 CHF" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9dR-7B-uMn" userLabel="FiatAmountLabel">
<rect key="frame" x="8" y="150" width="398" height="23.5"/>
<rect key="frame" x="8" y="155.5" width="398" height="25.5"/>
<fontDescription key="fontDescription" name="SourceSansPro-Regular" family="Source Sans Pro" pointSize="20"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>

View File

@ -20,10 +20,10 @@
</array>
</customFonts>
<scenes>
<!--View Controller-->
<!--Trx DetailsVC-->
<scene sceneID="Tig-fj-IV0">
<objects>
<viewController storyboardIdentifier="Home" id="3iR-4S-bLd" sceneMemberID="viewController">
<viewController storyboardIdentifier="TrxDetails" id="3iR-4S-bLd" customClass="TrxDetailsVC" customModule="ZWallet" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="kOX-QC-cnU">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@ -31,7 +31,7 @@
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jbe-IX-HiN" userLabel="BalanceView">
<rect key="frame" x="0.0" y="0.0" width="414" height="212"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="!!TrxKind" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Uox-ul-SfL" userLabel="TitleLabel">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="!!TrxDirection" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Uox-ul-SfL" userLabel="TitleLabel">
<rect key="frame" x="132" y="58" width="150" height="23"/>
<constraints>
<constraint firstAttribute="width" constant="150" id="y3J-5f-Wcc"/>
@ -68,11 +68,11 @@
<constraint firstItem="9dR-7B-uMn" firstAttribute="centerX" secondItem="jbe-IX-HiN" secondAttribute="centerX" id="v9Y-Yr-4BN"/>
</constraints>
</view>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" allowsSelection="NO" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="etR-G8-YOv" userLabel="TrxDetailsTableView">
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" allowsSelection="NO" rowHeight="-1" estimatedRowHeight="91" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="etR-G8-YOv" userLabel="TrxDetailsTableView">
<rect key="frame" x="0.0" y="212" width="414" height="684"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="TrxDetailCell" rowHeight="91" id="tJV-bC-RBh" userLabel="TrxDetailCell">
<tableViewCell contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="TrxDetailsCell" rowHeight="91" id="tJV-bC-RBh" customClass="TrxDetailsTableViewCell" customModule="ZWallet">
<rect key="frame" x="0.0" y="55.5" width="414" height="91"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="tJV-bC-RBh" id="tbN-Xt-Swv">
@ -101,8 +101,12 @@
<constraint firstAttribute="trailing" secondItem="kfl-QO-Fmg" secondAttribute="trailing" constant="16" id="w1x-MU-H2J"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="bodyLabel" destination="TJc-P0-KVQ" id="rhL-Q2-idb"/>
<outlet property="titleLabel" destination="kfl-QO-Fmg" id="Mrh-qR-20w"/>
</connections>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="TrxMemoCell" rowHeight="150" id="9TF-EQ-0V3" userLabel="TrxMemoCell">
<tableViewCell contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="TrxMemoCell" rowHeight="150" id="9TF-EQ-0V3" customClass="TrxMemoTableViewCell" customModule="ZWallet">
<rect key="frame" x="0.0" y="146.5" width="414" height="150"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="9TF-EQ-0V3" id="Ggp-h3-rdl">
@ -135,6 +139,10 @@ Memo 4</string>
<constraint firstAttribute="trailing" secondItem="tgH-GG-6Bg" secondAttribute="trailing" constant="16" id="RyH-h3-ZfN"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="bodyLabel" destination="hcq-mJ-dSS" id="Upe-uj-5gL"/>
<outlet property="titleLabel" destination="tgH-GG-6Bg" id="2Cv-wv-Nw7"/>
</connections>
</tableViewCell>
</prototypes>
</tableView>
@ -151,6 +159,13 @@ Memo 4</string>
</constraints>
<viewLayoutGuide key="safeArea" id="BYh-FW-Fpk"/>
</view>
<connections>
<outlet property="amountLabel" destination="oqZ-HW-Zcf" id="r5e-JA-dQq"/>
<outlet property="detailsTableView" destination="etR-G8-YOv" id="5r1-iQ-qOl"/>
<outlet property="fiatAmountLabel" destination="9dR-7B-uMn" id="y2f-Fc-VGx"/>
<outlet property="headerView" destination="jbe-IX-HiN" id="ShJ-QC-BaI"/>
<outlet property="trxDirectionLabel" destination="Uox-ul-SfL" id="VMn-tQ-ICJ"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="avL-L1-Q13" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>

View File

@ -9,24 +9,24 @@
import Foundation
public struct TrxDetail {
public struct TrxDetails {
public let direction: TrxDirection
public let date: Date
public let amountInAtomicUnits: UInt64
public let amount: ZecInAtomicUnits
public let address: String
public let trxId: String
public let memo: String
public init(direction: TrxDirection,
date: Date,
amountInAtomicUnits: UInt64,
amount: ZecInAtomicUnits,
address: String,
trxId: String,
memo: String)
{
self.direction = direction
self.date = date
self.amountInAtomicUnits = amountInAtomicUnits
self.amount = amount
self.address = address
self.trxId = trxId
self.memo = memo

View File

@ -9,6 +9,6 @@
import Foundation
public protocol TrxHistoryObserver: class {
public protocol TrxHistoryObservable: class {
func changed()
}

29
ZWallet/Types/ZEC.swift Normal file
View File

@ -0,0 +1,29 @@
//
// ZEC.swift
// ZWallet
//
// Created by loj on 27.01.19.
// Copyright © 2019 XMR Systems LLC. All rights reserved.
//
import Foundation
public typealias ZecInAtomicUnits = UInt64
extension ZecInAtomicUnits {
public func formatted() -> String {
let nf = NumberFormatter()
nf.allowsFloats = true
nf.minimumIntegerDigits = 1
nf.minimumFractionDigits = Constants.prettyPrintNumberOfFractionDigits
nf.maximumFractionDigits = Constants.prettyPrintNumberOfFractionDigits
let zec = Double(self) / Double(Constants.atomicUnitsPerZec)
guard let formatted = nf.string(from: NSNumber(value: zec)) else {
return ""
}
return formatted
}
}

View File

@ -16,6 +16,9 @@ internal class HomeCoordinator: BaseCoordinator {
private var viewFactory: ViewFactoryProtocol
private var localizer: Localizable
private var trxHistoryProvider: TrxHistoryProviderProtocol
private var homeVC: HomeVC?
internal init(navigationController: UINavigationController,
iocContainer: IocContainerProtocol)
@ -24,6 +27,7 @@ internal class HomeCoordinator: BaseCoordinator {
self.viewFactory = self.iocContainer.viewFactory
self.localizer = self.iocContainer.localizer
self.trxHistoryProvider = self.iocContainer.trxHistoryProvider
super.init(navigationController: navigationController)
}
@ -47,8 +51,9 @@ extension HomeCoordinator: HomeVCDelegate {
#warning("implement")
}
func homeVCTrxCellTouched(sender: HomeVC) {
#warning("implement")
func homeVCTrxCellTouched(sender: HomeVC, rowNumber: Int) {
let trxDetails = self.trxHistoryProvider.all()[rowNumber]
self.showTrxDetailsView(for: trxDetails)
}
private func showHomeView() {
@ -56,35 +61,60 @@ extension HomeCoordinator: HomeVCDelegate {
#warning("remove")
self.test_addDummyData()
self.registerForNewTrx()
let vc = self.viewFactory.getHomeView()
vc.delegate = self
vc.localizer = self.localizer
vc.trxHistoryProvider = self.iocContainer.trxHistoryProvider
vc.trxHistory = self.trxHistoryProvider.all()
self.navigationController.pushViewController(vc, animated: true)
}
private func showTrxDetailsView(for trxDetails: TrxDetails) {
let vc = self.viewFactory.getTrxDetailsView()
vc.localizer = self.localizer
vc.trxDetails = trxDetails
self.navigationController.pushViewController(vc, animated: true)
}
private func registerForNewTrx() {
self.trxHistoryProvider.register(observer: self)
}
private func deregisterFromNewTrx() {
self.trxHistoryProvider.deregister(observer: self)
}
private func test_addDummyData() {
let trxHistoryProvider = self.iocContainer.trxHistoryProvider
let detailSent = TrxDetail(direction: .send,
date: Date.init(),
amountInAtomicUnits: 2208,
address: "address send to",
trxId: "trx id send",
memo: "memo send")
let detailReceived = TrxDetail(direction: .receive,
date: Date.init(),
amountInAtomicUnits: 22,
address: "address received from",
trxId: "trx id receive",
memo: "memo receive")
trxHistoryProvider.add(trxDetail: detailSent)
trxHistoryProvider.add(trxDetail: detailReceived)
trxHistoryProvider.add(trxDetail: detailSent)
trxHistoryProvider.add(trxDetail: detailReceived)
trxHistoryProvider.add(trxDetail: detailSent)
trxHistoryProvider.add(trxDetail: detailReceived)
trxHistoryProvider.add(trxDetail: detailSent)
trxHistoryProvider.add(trxDetail: detailReceived)
let detailsSent = TrxDetails(direction: .send,
date: Date.init(),
amount: 22_080_000_000_000_000,
address: "address send to",
trxId: "trx id send",
memo: "memo send")
let detailsReceived = TrxDetails(direction: .receive,
date: Date.init(),
amount: 22_000_000_000_000,
address: "address received from",
trxId: "trx id receive",
memo: "memo receive")
trxHistoryProvider.add(trxDetails: detailsSent)
trxHistoryProvider.add(trxDetails: detailsReceived)
trxHistoryProvider.add(trxDetails: detailsSent)
trxHistoryProvider.add(trxDetails: detailsReceived)
trxHistoryProvider.add(trxDetails: detailsSent)
trxHistoryProvider.add(trxDetails: detailsReceived)
trxHistoryProvider.add(trxDetails: detailsSent)
trxHistoryProvider.add(trxDetails: detailsReceived)
}
}
extension HomeCoordinator: TrxHistoryObservable {
func changed() {
#warning("implement")
}
}

View File

@ -26,5 +26,4 @@ class HomeTrxTableViewCell: UITableViewCell {
// Configure the view for the selected state
}
}

View File

@ -20,9 +20,8 @@ class HomeVC: UIViewController {
public weak var delegate: HomeVCDelegate?
public weak var localizer: Localizable?
public weak var trxHistoryProvider: TrxHistoryProviderProtocol?
private var trxHistory = [TrxDetail]()
public var trxHistory = [TrxDetails]()
@IBAction func sendButtonTouched() {
self.delegate?.homeVCSendButtonTouched(sender: self)
@ -45,36 +44,38 @@ class HomeVC: UIViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.trxHistoryProvider?.register(observer: self)
self.updateView()
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.trxHistoryProvider?.deregister(observer: self)
}
private func setup() {
self.trxTableView.dataSource = self
self.trxTableView.delegate = self
}
private func updateView() {
#warning("move somewhere else")
self.trxHistory = self.trxHistoryProvider?.all() ?? [TrxDetail]()
self.trxTableView.reloadData()
}
}
extension HomeVC: TrxHistoryObserver {
//extension HomeVC: TrxHistoryObservable {
//
// func changed() {
// DispatchQueue.main.async {
// self.updateView()
// }
// }
//}
func changed() {
DispatchQueue.main.async {
self.updateView()
}
extension HomeVC: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.delegate?.homeVCTrxCellTouched(sender: self, rowNumber: indexPath.row)
}
}
@ -89,17 +90,22 @@ extension HomeVC: UITableViewDataSource {
let cell = self.trxTableView.dequeueReusableCell(withIdentifier: "TrxCell") as! HomeTrxTableViewCell
let cellData = self.trxHistory[indexPath.row]
cell.trxDateLabel.text = cellData.date.time()
switch cellData.direction {
case .receive:
cell.directionLabel.text = self.localizer?.localized("trxDetailCell.received")
cell.directionLabel.text = self.localizer?.localized("trxDetail.received")
cell.directionImageView.image = UIImage(named: "ArrowDown")
cell.trxAmountLabel.text = "+\(cellData.amount.formatted()) ZEC"
#warning("fill in real value")
cell.trxFiatAmountLabel.text = "+ fiat CHF"
case .send:
cell.directionLabel.text = self.localizer?.localized("trxDetailCell.sent")
cell.directionLabel.text = self.localizer?.localized("trxDetail.sent")
cell.directionImageView.image = UIImage(named: "ArrowUp")
cell.trxAmountLabel.text = "-\(cellData.amount.formatted()) ZEC"
#warning("fill in real value")
cell.trxFiatAmountLabel.text = "- fiat CHF"
}
cell.trxDateLabel.text = "date"
cell.trxAmountLabel.text = "amount ZEC"
cell.trxFiatAmountLabel.text = "fiat CHF"
return cell
}

View File

@ -13,5 +13,5 @@ internal protocol HomeVCDelegate: class {
func homeVCSendButtonTouched(sender: HomeVC)
func homeVCReceiveButtonTouched(sender: HomeVC)
func homeVCSettingsButtonTouched(sender: HomeVC)
func homeVCTrxCellTouched(sender: HomeVC)
func homeVCTrxCellTouched(sender: HomeVC, rowNumber: Int)
}

View File

@ -0,0 +1,26 @@
//
// TrxDetailTableViewCell.swift
// ZWallet
//
// Created by loj on 22.01.19.
// Copyright © 2019 XMR Systems LLC. All rights reserved.
//
import UIKit
class TrxDetailsTableViewCell: UITableViewCell {
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var bodyLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}

View File

@ -0,0 +1,138 @@
//
// TrxDetailVC.swift
// ZWallet
//
// Created by loj on 22.01.19.
// Copyright © 2019 XMR Systems LLC. All rights reserved.
//
import UIKit
class TrxDetailsVC: UIViewController {
@IBOutlet weak var trxDirectionLabel: UILabel!
@IBOutlet weak var amountLabel: UILabel!
@IBOutlet weak var fiatAmountLabel: UILabel!
@IBOutlet weak var headerView: UIView!
@IBOutlet weak var detailsTableView: UITableView!
public weak var localizer: Localizable?
public var trxDetails: TrxDetails?
override func viewDidLoad() {
super.viewDidLoad()
self.setup()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.updateView()
}
private func setup() {
self.detailsTableView.delegate = self
self.detailsTableView.dataSource = self
}
private func updateView() {
self.updateHeader()
self.updateDetails()
}
private func updateHeader() {
guard let trxDetails = self.trxDetails else {
return
}
switch trxDetails.direction {
case .receive:
self.headerView.backgroundColor = Colors.trxDetailReceivedBackgroundColor
self.trxDirectionLabel.text = self.localizer?.localized("trxDetail.received")
self.amountLabel.text = "+\(trxDetails.amount.formatted()) ZEC"
#warning("show fiat amont")
self.fiatAmountLabel.text = ""
case .send:
self.headerView.backgroundColor = Colors.trxDetailSentBackgroundColor
self.trxDirectionLabel.text = self.localizer?.localized("trxDetail.sent")
self.amountLabel.text = "-\(trxDetails.amount.formatted()) ZEC"
#warning("show fiat amont")
self.fiatAmountLabel.text = ""
}
}
private func updateDetails() {
self.detailsTableView.reloadData()
}
private enum CellIdentifier: String {
case detail = "TrxDetailsCell"
case memo = "TrxMemoCell"
}
private var cellDefinitions: [(cell: UITableViewCell, height: Int)] {
get {
return [(self.dateCell, 91),
(self.addressCell, 91),
(self.trxIdCell, 91),
(self.memoCell, 150)]
}
}
private var dateCell: UITableViewCell {
get {
let cell = self.detailsTableView.dequeueReusableCell(withIdentifier: CellIdentifier.detail.rawValue) as! TrxDetailsTableViewCell
cell.titleLabel.text = self.localizer?.localized("trxDetail.date")
cell.bodyLabel.text = self.trxDetails?.date.dateAndTime()
return cell
}
}
private var addressCell: UITableViewCell {
get {
let cell = self.detailsTableView.dequeueReusableCell(withIdentifier: CellIdentifier.detail.rawValue) as! TrxDetailsTableViewCell
cell.titleLabel.text = self.localizer?.localized("trxDetail.sourceAddress")
cell.bodyLabel.text = self.trxDetails?.address
return cell
}
}
private var trxIdCell: UITableViewCell {
get {
let cell = self.detailsTableView.dequeueReusableCell(withIdentifier: CellIdentifier.detail.rawValue) as! TrxDetailsTableViewCell
cell.titleLabel.text = self.localizer?.localized("trxDetail.trxId")
cell.bodyLabel.text = self.trxDetails?.trxId
return cell
}
}
private var memoCell: UITableViewCell {
get {
let cell = self.detailsTableView.dequeueReusableCell(withIdentifier: CellIdentifier.memo.rawValue) as! TrxMemoTableViewCell
cell.titleLabel.text = self.localizer?.localized("trxDetail.memo")
cell.bodyLabel.text = self.trxDetails?.memo
return cell
}
}
}
extension TrxDetailsVC: UITableViewDelegate {
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return CGFloat(self.cellDefinitions[indexPath.row].height)
}
}
extension TrxDetailsVC: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.cellDefinitions.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
return self.cellDefinitions[indexPath.row].cell
}
}

View File

@ -0,0 +1,26 @@
//
// TrxMemoTableViewCell.swift
// ZWallet
//
// Created by loj on 22.01.19.
// Copyright © 2019 XMR Systems LLC. All rights reserved.
//
import UIKit
class TrxMemoTableViewCell: UITableViewCell {
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var bodyLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}

5
ZWallet/___TODO.md Normal file
View File

@ -0,0 +1,5 @@
# TODO
## HomeVC
- group by date
- cell touched -> (group, row)

View File

@ -80,7 +80,7 @@ class TrxHistoryProviderTests: XCTestCase {
}
private class ObserverMock: TrxHistoryObserver {
private class ObserverMock: TrxHistoryObservable {
public var isNotified = false