Skip to content
This repository was archived by the owner on Aug 25, 2023. It is now read-only.

Commit cb3d863

Browse files
authored
Merge pull request #109 from BLOCKvIO/fix/project-file-2
add files
2 parents 135815f + 4e96872 commit cb3d863

File tree

4 files changed

+682
-15
lines changed

4 files changed

+682
-15
lines changed

Example/BlockV.xcodeproj/project.pbxproj

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
AD3DB5302157FD7200E00B67 /* TappedVatomViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD3DB52F2157FD7200E00B67 /* TappedVatomViewController.swift */; };
1717
AD61462E213DC88700204E5B /* FaceSelectionProcedure_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD61462A213DC83D00204E5B /* FaceSelectionProcedure_Tests.swift */; };
1818
AD61462F213DC88B00204E5B /* MockModelFaces.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD61462C213DC87100204E5B /* MockModelFaces.swift */; };
19-
AD920A4E215FAD6900CEFC1D /* PasswordTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD920A4B215FAD6900CEFC1D /* PasswordTableViewController.swift */; };
20-
AD920A4F215FAD6900CEFC1D /* ProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD920A4C215FAD6900CEFC1D /* ProfileViewController.swift */; };
21-
AD920A50215FAD6900CEFC1D /* UserInfoTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD920A4D215FAD6900CEFC1D /* UserInfoTableViewController.swift */; };
19+
AD920A5B215FB47200CEFC1D /* UserInfoTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD920A58215FB47100CEFC1D /* UserInfoTableViewController.swift */; };
20+
AD920A5C215FB47200CEFC1D /* PasswordTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD920A59215FB47200CEFC1D /* PasswordTableViewController.swift */; };
21+
AD920A5D215FB47200CEFC1D /* ProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD920A5A215FB47200CEFC1D /* ProfileViewController.swift */; };
2222
CDC268C7232CDB5AF1386116 /* Pods_BlockV_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DE93FD598C0B61200B996A4 /* Pods_BlockV_Example.framework */; };
2323
D519A845205E6EE3006B0D19 /* NetworkOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D519A844205E6EE3006B0D19 /* NetworkOperation.swift */; };
2424
D519A848205E76EB006B0D19 /* NetworkDataOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D519A847205E76EB006B0D19 /* NetworkDataOperation.swift */; };
@@ -83,9 +83,9 @@
8383
AD3DB52F2157FD7200E00B67 /* TappedVatomViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TappedVatomViewController.swift; sourceTree = "<group>"; };
8484
AD61462A213DC83D00204E5B /* FaceSelectionProcedure_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FaceSelectionProcedure_Tests.swift; sourceTree = "<group>"; };
8585
AD61462C213DC87100204E5B /* MockModelFaces.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockModelFaces.swift; sourceTree = "<group>"; };
86-
AD920A4B215FAD6900CEFC1D /* PasswordTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordTableViewController.swift; sourceTree = "<group>"; };
87-
AD920A4C215FAD6900CEFC1D /* ProfileViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileViewController.swift; sourceTree = "<group>"; };
88-
AD920A4D215FAD6900CEFC1D /* UserInfoTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserInfoTableViewController.swift; sourceTree = "<group>"; };
86+
AD920A58215FB47100CEFC1D /* UserInfoTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserInfoTableViewController.swift; sourceTree = "<group>"; };
87+
AD920A59215FB47200CEFC1D /* PasswordTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordTableViewController.swift; sourceTree = "<group>"; };
88+
AD920A5A215FB47200CEFC1D /* ProfileViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileViewController.swift; sourceTree = "<group>"; };
8989
B5A79A9FDD3524D3628C080E /* Pods-BlockV_Example.dev.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BlockV_Example.dev.xcconfig"; path = "Pods/Target Support Files/Pods-BlockV_Example/Pods-BlockV_Example.dev.xcconfig"; sourceTree = "<group>"; };
9090
BC27A08D03F2D2401C48F394 /* Pods-BlockV_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BlockV_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-BlockV_Example/Pods-BlockV_Example.release.xcconfig"; sourceTree = "<group>"; };
9191
C55D0BD7FD8ECD417C235202 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
@@ -244,14 +244,14 @@
244244
path = "Face Selection Procedure";
245245
sourceTree = "<group>";
246246
};
247-
AD920A4A215FAD5200CEFC1D /* Profile */ = {
247+
AD920A51215FB3EA00CEFC1D /* User Profile */ = {
248248
isa = PBXGroup;
249249
children = (
250-
AD920A4B215FAD6900CEFC1D /* PasswordTableViewController.swift */,
251-
AD920A4C215FAD6900CEFC1D /* ProfileViewController.swift */,
252-
AD920A4D215FAD6900CEFC1D /* UserInfoTableViewController.swift */,
250+
AD920A59215FB47200CEFC1D /* PasswordTableViewController.swift */,
251+
AD920A5A215FB47200CEFC1D /* ProfileViewController.swift */,
252+
AD920A58215FB47100CEFC1D /* UserInfoTableViewController.swift */,
253253
);
254-
path = Profile;
254+
path = "User Profile";
255255
sourceTree = "<group>";
256256
};
257257
D519A846205E76C9006B0D19 /* Operations */ = {
@@ -333,7 +333,7 @@
333333
D58E31B5205E962D0024BA0E /* Controllers */ = {
334334
isa = PBXGroup;
335335
children = (
336-
AD920A4A215FAD5200CEFC1D /* Profile */,
336+
AD920A51215FB3EA00CEFC1D /* User Profile */,
337337
AD36A5A0215D382D009EFD55 /* Onboarding */,
338338
D519A849205E8360006B0D19 /* Inventory */,
339339
D5728D5A206130E40041F4F7 /* Actions */,
@@ -554,23 +554,23 @@
554554
isa = PBXSourcesBuildPhase;
555555
buildActionMask = 2147483647;
556556
files = (
557-
AD920A4E215FAD6900CEFC1D /* PasswordTableViewController.swift in Sources */,
558557
D519A848205E76EB006B0D19 /* NetworkDataOperation.swift in Sources */,
559558
D5475764205D124100E6FE90 /* UIView+Ext.swift in Sources */,
559+
AD920A5C215FB47200CEFC1D /* PasswordTableViewController.swift in Sources */,
560560
D547576B205E67AD00E6FE90 /* VatomCell.swift in Sources */,
561561
D519A84B205E83AB006B0D19 /* VatomDetailTableViewController.swift in Sources */,
562562
AD3DB5302157FD7200E00B67 /* TappedVatomViewController.swift in Sources */,
563+
AD920A5D215FB47200CEFC1D /* ProfileViewController.swift in Sources */,
563564
D55B21FB2056E04B00B6D5C2 /* InventoryCollectionViewController.swift in Sources */,
564565
D55B21F52056745700B6D5C2 /* UIViewController+Ext.swift in Sources */,
565566
D597FF272051305A009B2910 /* UIAlertController+Etx.swift in Sources */,
566567
D55B21EE2053E24900B6D5C2 /* TitleValueCell.swift in Sources */,
567-
AD920A50215FAD6900CEFC1D /* UserInfoTableViewController.swift in Sources */,
568568
D55B21E520527EB400B6D5C2 /* TokenCell.swift in Sources */,
569569
D55B21F020540AC200B6D5C2 /* RegisterTableViewController.swift in Sources */,
570570
D5E3AC9F2049883900CFFEEA /* LoginViewController.swift in Sources */,
571+
AD920A5B215FB47200CEFC1D /* UserInfoTableViewController.swift in Sources */,
571572
D55B21E02052772400B6D5C2 /* VerifyTableViewController.swift in Sources */,
572573
D55B21F92056DE6D00B6D5C2 /* UIColor+Ext.swift in Sources */,
573-
AD920A4F215FAD6900CEFC1D /* ProfileViewController.swift in Sources */,
574574
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */,
575575
D55B21EA2052E38000B6D5C2 /* RoundedImageView.swift in Sources */,
576576
D5728D5E206155600041F4F7 /* ActionListTableViewController.swift in Sources */,
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
// MIT License
2+
//
3+
// Copyright (c) 2018 BlockV AG
4+
//
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files (the "Software"), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be included in all
13+
// copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
// SOFTWARE.
22+
//
23+
24+
//
25+
// PasswordTableViewController.swift
26+
// BlockV_Example
27+
//
28+
// Created by Cameron McOnie on 2018/03/24.
29+
// Copyright © 2018 CocoaPods. All rights reserved.
30+
//
31+
32+
import UIKit
33+
import BLOCKv
34+
35+
class PasswordTableViewController: UITableViewController {
36+
37+
// MARK: - Enums
38+
39+
/// Represents a table section
40+
fileprivate enum TableSection: Int {
41+
case password = 0
42+
}
43+
44+
// MARK: - Outlets
45+
46+
@IBOutlet var doneButton: UIBarButtonItem!
47+
48+
// MARK: - Actions
49+
50+
@IBAction func doneButtonTapped(_ sender: UIBarButtonItem) {
51+
updateProfile()
52+
}
53+
54+
// MARK: - Properties
55+
56+
fileprivate let titleValueCellId = "cell.profile.id"
57+
58+
/// Dictionary of table view cells for display. Since the number of cells is known and
59+
/// the count small, we needn't worry about efficiently deque-ing from a reuse pool.
60+
fileprivate var tableViewCells: [TableSection: [TitleValueCell]] = [:]
61+
62+
// MARK: - Lifecycle
63+
64+
override func viewDidLoad() {
65+
super.viewDidLoad()
66+
67+
// add cells to tableview
68+
createCells()
69+
}
70+
71+
// MARK: - Helpers
72+
73+
/// Creates table view cellls.
74+
fileprivate func createCells() {
75+
76+
let passwordCell = TitleValueCell()
77+
passwordCell.titleLabel.text = "Password"
78+
passwordCell.valueTextField.placeholder = "******"
79+
passwordCell.valueTextField.keyboardType = .default
80+
passwordCell.valueTextField.autocorrectionType = .no
81+
passwordCell.valueTextField.autocapitalizationType = .none
82+
83+
// add cells
84+
tableViewCells[.password] = [passwordCell]
85+
86+
}
87+
88+
/// Capture data from table view cells.
89+
fileprivate func buildForm() -> UserInfo {
90+
91+
let passwordCell = tableViewCells[.password]![0]
92+
93+
return UserInfo(password: passwordCell.valueTextField.text)
94+
95+
}
96+
97+
/// Performs the network request to update the user's profile information.
98+
fileprivate func updateProfile() {
99+
print(#function)
100+
101+
self.showNavBarActivityRight()
102+
103+
let userInfo = buildForm()
104+
105+
BLOCKv.updateCurrentUser(userInfo) {
106+
[weak self] (userModel, error) in
107+
108+
// reset nav bar
109+
self?.hideNavBarActivityRight()
110+
self?.navigationItem.setRightBarButton(self!.doneButton, animated: true)
111+
112+
// handle error
113+
guard let model = userModel, error == nil else {
114+
print(">>> Error > Viewer: \(error!.localizedDescription)")
115+
self?.present(UIAlertController.errorAlert(error!), animated: true)
116+
return
117+
}
118+
119+
// handle success
120+
print("Viewer > \(model)\n")
121+
122+
// update the model
123+
self?.tableView.reloadData()
124+
125+
// pop back
126+
self?.navigationController?.popViewController(animated: true)
127+
128+
}
129+
130+
}
131+
132+
}
133+
134+
// MARK: - Table view data source
135+
136+
extension PasswordTableViewController {
137+
138+
override func numberOfSections(in tableView: UITableView) -> Int {
139+
return 1
140+
}
141+
142+
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
143+
switch TableSection(rawValue: section)! {
144+
case .password: return tableViewCells[.password]!.count
145+
}
146+
}
147+
148+
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> TitleValueCell {
149+
let section = TableSection(rawValue: indexPath.section)!
150+
return tableViewCells[section]![indexPath.row]
151+
}
152+
153+
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
154+
let cell = tableView.cellForRow(at: indexPath) as! TitleValueCell
155+
cell.valueTextField.becomeFirstResponder()
156+
}
157+
158+
}

0 commit comments

Comments
 (0)