Skip to content

Commit

Permalink
Reduce token cell height and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
vikmeup committed Apr 11, 2018
1 parent 1d30543 commit 9115dc7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 32 deletions.
25 changes: 10 additions & 15 deletions Trust/Browser/Storage/HistoryStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class HistoryStore {
return realm.objects(History.self)
.sorted(byKeyPath: "createdAt", ascending: false)
}

let realm: Realm

init(realm: Realm) {
self.realm = realm
}
Expand All @@ -21,31 +23,24 @@ class HistoryStore {
}()

func record(url: URL, title: String) {
guard !ignoreSet.contains(url.absoluteString) else {
let history = History(url: url.absoluteString, title: title)

guard !ignoreSet.contains(history.url) else {
return
}
let history = History(url: url.absoluteString, title: title)

add(histories: [history])
}

func add(histories: [History]) {

do {
try realm.write {
realm.add(histories, update: true)
}
} catch let error {
print(error.localizedDescription)
try? realm.write {
realm.add(histories, update: true)
}
}

func delete(histories: [History]) {
do {
try realm.write {
realm.delete(histories)
}
} catch let error {
print(error.localizedDescription)
try? realm.write {
realm.delete(histories)
}
}
}
8 changes: 4 additions & 4 deletions Trust/Tokens/Coordinators/TokensBalanceService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ class TokensBalanceService {
completion: @escaping (Result<BigInt, AnyError>) -> Void
) {
let encoded = ERC20Encoder.encodeBalanceOf(address: address)
let request2 = EtherServiceRequest(
let request = EtherServiceRequest(
batch: BatchFactory().create(CallRequest(to: contract.description, data: encoded.hexEncoded))
)
Session.send(request2) { result2 in
switch result2 {
Session.send(request) { result in
switch result {
case .success(let balance):
let biguint = BigUInt(Data(hex: balance))
completion(.success(BigInt(sign: .plus, magnitude: biguint)))
case .failure(let error):
NSLog("getPrice2 error \(error)")
NSLog("getPrice error \(error)")
completion(.failure(AnyError(error)))
}
}
Expand Down
4 changes: 2 additions & 2 deletions Trust/Tokens/Layout/TokensLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import UIKit

struct TokensLayout {
struct tableView {
static let height: CGFloat = 84
static let height: CGFloat = 80
static let separatorColor = UIColor(hex: "d7d7d7")
static let layoutInsets = UIEdgeInsets(top: 0, left: 86, bottom: 0, right: 0)
}

struct cell {
static var imageSize: CGFloat {
return 54
return 52
// TODO: return 44 for 2 scale, same for xib file.
//if UIScreen.main.scale == 3 { return 54 }
//return 44
Expand Down
25 changes: 14 additions & 11 deletions Trust/Tokens/Views/EditTokenTableViewCell.xib
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand All @@ -21,42 +21,45 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" layoutMarginsFollowReadableWidth="YES" insetsLayoutMarginsFromSafeArea="NO" alignment="center" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="d5W-Lo-p3o">
<rect key="frame" x="16" y="13" width="288" height="54"/>
<rect key="frame" x="16" y="14" width="288" height="52"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Tfc-cq-2hm" customClass="TokenImageView" customModule="Trust" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="54" height="54"/>
<rect key="frame" x="0.0" y="0.0" width="52" height="52"/>
<constraints>
<constraint firstAttribute="height" constant="54" id="jAI-H2-0br"/>
<constraint firstAttribute="width" constant="54" id="uhQ-eN-kxx"/>
<constraint firstAttribute="height" constant="52" id="jAI-H2-0br"/>
<constraint firstAttribute="width" constant="52" id="uhQ-eN-kxx"/>
</constraints>
</imageView>
<stackView opaque="NO" contentMode="scaleAspectFit" semanticContentAttribute="spatial" axis="vertical" distribution="fillProportionally" alignment="top" translatesAutoresizingMaskIntoConstraints="NO" id="fRy-j2-9ES" userLabel="Label Stack View">
<rect key="frame" x="64" y="5" width="165" height="44"/>
<rect key="frame" x="62" y="0.0" width="167" height="52"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="751" text="Test lable" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.69999999999999996" translatesAutoresizingMaskIntoConstraints="NO" id="gzC-hL-qRv">
<rect key="frame" x="0.0" y="0.0" width="73" height="24.5"/>
<rect key="frame" x="0.0" y="0.0" width="73" height="29"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Su7-1W-bDk">
<rect key="frame" x="0.0" y="24.5" width="33" height="19.5"/>
<rect key="frame" x="0.0" y="29" width="33" height="23"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="Su7-1W-bDk" firstAttribute="top" secondItem="gzC-hL-qRv" secondAttribute="bottom" constant="4" id="PQc-8k-3ip"/>
</constraints>
</stackView>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Uf5-TC-p3g">
<rect key="frame" x="239" y="11.5" width="51" height="31"/>
<rect key="frame" x="239" y="10.5" width="51" height="31"/>
<connections>
<action selector="didChangeSwitch:" destination="KGk-i7-Jjw" eventType="valueChanged" id="RNY-kW-3Zh"/>
</connections>
</switch>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="Uf5-TC-p3g" secondAttribute="trailing" id="7aq-K9-icd"/>
<constraint firstAttribute="bottom" secondItem="fRy-j2-9ES" secondAttribute="bottom" constant="5" id="sQQ-18-ZYL"/>
<constraint firstAttribute="bottom" secondItem="fRy-j2-9ES" secondAttribute="bottom" id="sQQ-18-ZYL"/>
</constraints>
</stackView>
</subviews>
Expand Down

0 comments on commit 9115dc7

Please sign in to comment.