git.iko.soy/dashared/hookah-tau
on develop help sign in
Полностью переделала экран просмотра профиля пользователя
b32f9edDarya Rednikina
Hookah Tau/Controllers/Admin/Clients/ClientList.storyboard+65−50
@@ -1,9 +1,10 @@
1<?xml version="1.0" encoding="UTF-8"?>
1<?xml version="1.0" encoding="UTF-8"?>
2−<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14868" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
2+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
3 <device id="retina4_7" orientation="portrait" appearance="light"/>
3 <device id="retina4_7" orientation="portrait" appearance="light"/>
4 <dependencies>
4 <dependencies>
5 <deployment identifier="iOS"/>
5 <deployment identifier="iOS"/>
6− <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14824"/>
6+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
7+ <capability name="Safe area layout guides" minToolsVersion="9.0"/>
7 <capability name="Stack View standard spacing" minToolsVersion="9.0"/>
8 <capability name="Stack View standard spacing" minToolsVersion="9.0"/>
8 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
9 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
9 </dependencies>
10 </dependencies>
@@ -86,61 +87,75 @@
86 <point key="canvasLocation" x="0.80000000000000004" y="-112.89355322338831"/>
87 <point key="canvasLocation" x="0.80000000000000004" y="-112.89355322338831"/>
87 </scene>
88 </scene>
88 <!--Profile Table View Controller-->
89 <!--Profile Table View Controller-->
89− <scene sceneID="8Qr-sA-YQr">
90+ <scene sceneID="APa-VZ-6hd">
90 <objects>
91 <objects>
91− <tableViewController storyboardIdentifier="ProfileTableViewController" id="mqB-EY-UGh" customClass="ProfileTableViewController" customModule="Hookah_Tau" customModuleProvider="target" sceneMemberID="viewController">
92+ <viewController storyboardIdentifier="ProfileTableViewController" id="ZVH-jf-rtc" customClass="ProfileTableViewController" customModule="Hookah_Tau" customModuleProvider="target" sceneMemberID="viewController">
92− <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="N1B-QX-4Kn">
93+ <view key="view" contentMode="scaleToFill" id="rcq-M9-CvR">
93 <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
94 <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
94 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
95 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
96+ <subviews>
97+ <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ciO-ia-Oob">
98+ <rect key="frame" x="0.0" y="0.0" width="375" height="65"/>
99+ <subviews>
100+ <stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" alignment="center" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="IBA-bj-CWK">
101+ <rect key="frame" x="8" y="16" width="359" height="37"/>
102+ <subviews>
103+ <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="4WC-gi-jbD" customClass="Button" customModule="Hookah_Tau" customModuleProvider="target">
104+ <rect key="frame" x="0.0" y="0.0" width="180" height="37"/>
105+ <color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
106+ <constraints>
107+ <constraint firstAttribute="width" constant="180" id="bJA-V9-gw9"/>
108+ <constraint firstAttribute="height" constant="37" id="pdo-AO-o8a"/>
109+ </constraints>
110+ <state key="normal" title="Button"/>
111+ </button>
112+ <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gfq-ql-lka" customClass="Button" customModule="Hookah_Tau" customModuleProvider="target">
113+ <rect key="frame" x="224" y="0.0" width="135" height="37"/>
114+ <color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
115+ <constraints>
116+ <constraint firstAttribute="width" constant="135" id="Xn3-v6-SLp"/>
117+ <constraint firstAttribute="height" constant="37" id="z68-vW-NjK"/>
118+ </constraints>
119+ <state key="normal" title="Button"/>
120+ </button>
121+ </subviews>
122+ </stackView>
123+ </subviews>
124+ <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
125+ <constraints>
126+ <constraint firstItem="IBA-bj-CWK" firstAttribute="leading" secondItem="ciO-ia-Oob" secondAttribute="leading" constant="8" id="WZS-Vq-tuP"/>
127+ <constraint firstAttribute="trailing" secondItem="IBA-bj-CWK" secondAttribute="trailing" constant="8" id="Yk3-D1-1kg"/>
128+ <constraint firstItem="IBA-bj-CWK" firstAttribute="top" secondItem="ciO-ia-Oob" secondAttribute="top" constant="16" id="fWO-oj-NuN"/>
129+ <constraint firstItem="IBA-bj-CWK" firstAttribute="leading" secondItem="ciO-ia-Oob" secondAttribute="leading" constant="8" id="gP2-jh-5El"/>
130+ <constraint firstAttribute="height" constant="65" id="pzZ-zw-kbc"/>
131+ </constraints>
132+ </view>
133+ <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="T0s-lX-Z5m">
134+ <rect key="frame" x="0.0" y="65" width="375" height="602"/>
135+ <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
136+ </view>
137+ </subviews>
95 <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
138 <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
96− <view key="tableHeaderView" contentMode="scaleToFill" id="oN2-r5-lTy">
97− <rect key="frame" x="0.0" y="0.0" width="375" height="65"/>
98− <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
99− <subviews>
100− <stackView opaque="NO" contentMode="scaleToFill" spacing="47" translatesAutoresizingMaskIntoConstraints="NO" id="UpQ-Uf-0Kc">
101− <rect key="frame" x="8" y="16" width="359" height="37"/>
102− <subviews>
103− <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="nFA-T3-Dxe" customClass="Button" customModule="Hookah_Tau" customModuleProvider="target">
104− <rect key="frame" x="0.0" y="0.0" width="177" height="37"/>
105− <color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
106− <constraints>
139+ <constraints>
107− <constraint firstAttribute="height" constant="37" id="41i-38-mHD"/>
140+ <constraint firstItem="ciO-ia-Oob" firstAttribute="trailing" secondItem="tIS-3m-xwG" secondAttribute="trailing" id="3An-sM-OCN"/>
108− <constraint firstAttribute="width" constant="174" id="po9-OR-zq1"/>
141+ <constraint firstItem="ciO-ia-Oob" firstAttribute="top" secondItem="tIS-3m-xwG" secondAttribute="top" id="5zl-uZ-sTi"/>
109− </constraints>
142+ <constraint firstItem="T0s-lX-Z5m" firstAttribute="leading" secondItem="tIS-3m-xwG" secondAttribute="leading" id="7qA-Hh-3Us"/>
110− <state key="normal" title="Button"/>
111− </button>
112− <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="HkY-u9-thv" customClass="Button" customModule="Hookah_Tau" customModuleProvider="target">
113− <rect key="frame" x="224" y="0.0" width="135" height="37"/>
114− <color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
115− <constraints>
116− <constraint firstAttribute="height" constant="37" id="LDw-fn-Xem"/>
117− <constraint firstAttribute="width" constant="135" id="swI-oV-Khe"/>
118− </constraints>
119− <state key="normal" title="Button"/>
120− </button>
121− </subviews>
122− </stackView>
123− </subviews>
124− <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
125− <constraints>
126− <constraint firstItem="UpQ-Uf-0Kc" firstAttribute="top" secondItem="oN2-r5-lTy" secondAttribute="top" constant="16" id="58o-fg-n3i"/>
143+ <constraint firstItem="T0s-lX-Z5m" firstAttribute="trailing" secondItem="tIS-3m-xwG" secondAttribute="trailing" id="9VD-9Q-wGX"/>
127− <constraint firstItem="UpQ-Uf-0Kc" firstAttribute="leading" secondItem="oN2-r5-lTy" secondAttribute="leading" constant="8" id="5ik-TQ-N4U"/>
144+ <constraint firstItem="T0s-lX-Z5m" firstAttribute="top" secondItem="ciO-ia-Oob" secondAttribute="bottom" id="RSL-fo-wIb"/>
128− <constraint firstAttribute="trailing" secondItem="UpQ-Uf-0Kc" secondAttribute="trailing" constant="8" id="8Ca-3C-Xld"/>
145+ <constraint firstItem="ciO-ia-Oob" firstAttribute="leading" secondItem="tIS-3m-xwG" secondAttribute="leading" id="Tuq-su-gbn"/>
129− </constraints>
146+ <constraint firstItem="T0s-lX-Z5m" firstAttribute="bottom" secondItem="tIS-3m-xwG" secondAttribute="bottom" id="iQj-LM-Im9"/>
130− </view>
147+ </constraints>
131− <connections>
148+ <viewLayoutGuide key="safeArea" id="tIS-3m-xwG"/>
132− <outlet property="dataSource" destination="mqB-EY-UGh" id="YZe-zB-7f3"/>
149+ </view>
133− <outlet property="delegate" destination="mqB-EY-UGh" id="JPi-98-LhH"/>
134− </connections>
135− </tableView>
136 <connections>
150 <connections>
151+ <outlet property="contentView" destination="T0s-lX-Z5m" id="9Z0-5T-f7Z"/>
137− <outlet property="copyButton" destination="HkY-u9-thv" id="RLs-cg-y3g"/>
152+ <outlet property="copyButton" destination="gfq-ql-lka" id="BNi-Ip-AyF"/>
138− <outlet property="phoneButton" destination="nFA-T3-Dxe" id="d7H-jf-NB5"/>
153+ <outlet property="phoneButton" destination="4WC-gi-jbD" id="xlf-g7-CzU"/>
139 </connections>
154 </connections>
140− </tableViewController>
155+ </viewController>
141− <placeholder placeholderIdentifier="IBFirstResponder" id="1YW-I1-Y6m" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
156+ <placeholder placeholderIdentifier="IBFirstResponder" id="g4Y-1k-Lxr" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
142 </objects>
157 </objects>
143− <point key="canvasLocation" x="880.79999999999995" y="-111.0944527736132"/>
158+ <point key="canvasLocation" x="1188" y="-113"/>
144 </scene>
159 </scene>
145 </scenes>
160 </scenes>
146 <resources>
161 <resources>
Hookah Tau/Controllers/Admin/Clients/Profile/ProfileTableViewController.swift+86−18
@@ -8,7 +8,7 @@
8
8
9import UIKit
9import UIKit
10
10
11−class ProfileTableViewController: BaseTableViewController {
11+class ProfileTableViewController: BaseViewController {
12
12
13 // MARK: - IBAOutlets
13 // MARK: - IBAOutlets
14
14
@@ -30,24 +30,41 @@ class ProfileTableViewController: BaseTableViewController {
30 }
30 }
31 }
31 }
32
32
33+
34+ @IBOutlet weak var contentView: UIView!
35+
33 // MARK: - properties
36 // MARK: - properties
34
37
38+ var tableView: UITableView?
39+
35 var clientsService: ClientsService?
40 var clientsService: ClientsService?
36
41
37 var reservationsService: ReservationsService?
42 var reservationsService: ReservationsService?
38
43
39− var user: FullUser? {
44+ var user: FullUser?
40− didSet {
41− guard let u = user else { return }
42− navigationItem.title = u.name
43− }
44− }
45
45
46 weak var coodinator: ClientProfileCoordinator?
46 weak var coodinator: ClientProfileCoordinator?
47
47
48+ var noReserationsYetView: AdminNoReservationsView?
49+
50+ var activityIndicator: UIActivityIndicatorView?
51+
52+ var refreshControl: UIRefreshControl?
53+
48 var dataSource: [Reservation] = [] {
54 var dataSource: [Reservation] = [] {
49 didSet {
55 didSet {
56+ guard let empty = noReserationsYetView else { return }
57+ if dataSource.isEmpty {
58+ empty.alpha = 1
50− tableView.reloadData()
59+ tableView?.alpha = 0
60+ } else {
61+ empty.alpha = 0
62+ tableView?.alpha = 1
63+ }
64+
65+ refreshControl?.endRefreshing()
66+ activityIndicator?.stopAnimating()
67+ tableView?.reloadData()
51 }
68 }
52 }
69 }
53
70
@@ -56,10 +73,12 @@ class ProfileTableViewController: BaseTableViewController {
56 override func viewDidLoad() {
73 override func viewDidLoad() {
57 super.viewDidLoad()
74 super.viewDidLoad()
58
75
59− tableView?.register(ReservationCell.self, forCellReuseIdentifier: reservationCell)
60−
61 clientsService = ClientsService(apiClient: APIClient.shared)
76 clientsService = ClientsService(apiClient: APIClient.shared)
62 reservationsService = ReservationsService(apiClient: APIClient.shared)
77 reservationsService = ReservationsService(apiClient: APIClient.shared)
78+
79+ setupNavBar()
80+ setupTable()
81+ setupActivityIndicator()
63 loadReservations()
82 loadReservations()
64 }
83 }
65
84
@@ -68,13 +87,55 @@ class ProfileTableViewController: BaseTableViewController {
68 tabBarController?.tabBar.isHidden = true
87 tabBarController?.tabBar.isHidden = true
69 }
88 }
70
89
90+ // MARK: - Setup
91+
92+ func setupNavBar() {
93+ guard let u = user else { return }
94+ navigationItem.title = u.name
95+ navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(book))
96+ }
97+
98+ func setupTable() {
99+ tableView = UITableView()
100+
101+ // refresh control
102+ refreshControl = UIRefreshControl()
103+ refreshControl?.addTarget(self, action: #selector(refresh), for: .valueChanged)
104+ tableView?.refreshControl = refreshControl
105+
106+ tableView?.dataSource = self
107+ tableView?.delegate = self
108+
109+ noReserationsYetView = AdminNoReservationsView.loadFromNib()
110+ noReserationsYetView?.setup(withTitle: "У этого пользователя пока нет ни одной брони :(")
111+ noReserationsYetView?.bookButton?.addTarget(self, action: #selector(book), for: .touchUpInside)
112+ contentView.addSubviewThatFills(noReserationsYetView)
113+ noReserationsYetView?.alpha = 0
114+
115+ tableView?.register(ReservationCell.self, forCellReuseIdentifier: reservationCell)
116+
117+ contentView.addSubviewThatFills(tableView)
118+
119+ tableView?.alpha = 0
120+ }
121+
122+ func setupActivityIndicator() {
123+
124+ activityIndicator = UIActivityIndicatorView()
125+ view.addSubviewThatFills(activityIndicator)
126+ activityIndicator?.startAnimating()
127+
128+ }
129+
130+ // MARK: - Api calls
131+
71 func loadReservations() {
132 func loadReservations() {
72 guard let uuid = user?.uuid else { return }
133 guard let uuid = user?.uuid else { return }
73 clientsService?.loadReservationsForUser(withUUID: uuid,
134 clientsService?.loadReservationsForUser(withUUID: uuid,
74 completion: { [weak self] (res) in
135 completion: { [weak self] (res) in
75 switch res {
136 switch res {
76 case .failure(let err):
137 case .failure(let err):
77− print(err)
138+ self?.displayAlert(forError: err)
78 case .success(let data):
139 case .success(let data):
79 self?.dataSource = data
140 self?.dataSource = data
80 }
141 }
@@ -115,18 +176,25 @@ class ProfileTableViewController: BaseTableViewController {
115 //Alert
176 //Alert
116 self.displayAlert(with: "Номер скопирован!")
177 self.displayAlert(with: "Номер скопирован!")
117 }
178 }
118−
179+
180+ @objc func refresh() {
181+ loadReservations()
182+ }
183+
184+ @objc func book() {
185+
186+ }
119}
187}
120
188
121// MARK: - Table view data source
189// MARK: - Table view data source
122
190
123−extension ProfileTableViewController {
191+extension ProfileTableViewController: UITableViewDelegate, UITableViewDataSource {
124
192
125− override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
193+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
126 return dataSource.count
194 return dataSource.count
127 }
195 }
128
196
129− override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
197+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
130 let cell = tableView.dequeueReusableCell(withIdentifier: reservationCell, for: indexPath) as! ReservationCell
198 let cell = tableView.dequeueReusableCell(withIdentifier: reservationCell, for: indexPath) as! ReservationCell
131
199
132 cell.bind(withModel: dataSource[indexPath.row])
200 cell.bind(withModel: dataSource[indexPath.row])
@@ -136,7 +204,7 @@ extension ProfileTableViewController {
136
204
137 // tap
205 // tap
138
206
139− override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
207+ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
140 guard let u = user else { return }
208 guard let u = user else { return }
141 let r = dataSource[indexPath.row]
209 let r = dataSource[indexPath.row]
142 let reservation = ReservationWithUser(reservation: r, user: u)
210 let reservation = ReservationWithUser(reservation: r, user: u)
@@ -145,11 +213,11 @@ extension ProfileTableViewController {
145
213
146 // Update
214 // Update
147
215
148− override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
216+ func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
149 return true
217 return true
150 }
218 }
151
219
152− override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
220+ func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
153
221
154 let uuid = dataSource[indexPath.row].uuid
222 let uuid = dataSource[indexPath.row].uuid
155 let cancelButton = UITableViewRowAction(style: .normal, title: "❌") { _,_ in
223 let cancelButton = UITableViewRowAction(style: .normal, title: "❌") { _,_ in
Hookah Tau/Controllers/Admin/Reservations/Views/No reserv/AdminNoReservationsView.swift+5
@@ -12,6 +12,8 @@ class AdminNoReservationsView: UIView {
12
12
13 // MARK: - IBAOutlets
13 // MARK: - IBAOutlets
14
14
15+ @IBOutlet weak var titleLabel: UILabel?
16+
15 @IBOutlet weak var bookButton: Button? {
17 @IBOutlet weak var bookButton: Button? {
16 didSet {
18 didSet {
17 let style = BlackButtonStyle()
19 let style = BlackButtonStyle()
@@ -19,4 +21,7 @@ class AdminNoReservationsView: UIView {
19 }
21 }
20 }
22 }
21
23
24+ func setup(withTitle title: String) {
25+ titleLabel?.text = title
26+ }
22}
27}
Hookah Tau/Controllers/Admin/Reservations/Views/No reserv/AdminNoReservationsView.xib+1
@@ -46,6 +46,7 @@
46 <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
46 <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
47 <connections>
47 <connections>
48 <outlet property="bookButton" destination="y3F-ua-mLb" id="aC4-gz-Gqd"/>
48 <outlet property="bookButton" destination="y3F-ua-mLb" id="aC4-gz-Gqd"/>
49+ <outlet property="titleLabel" destination="Svd-DB-3Zu" id="n8Z-Wq-vzC"/>
49 </connections>
50 </connections>
50 <point key="canvasLocation" x="137.68115942028987" y="91.741071428571431"/>
51 <point key="canvasLocation" x="137.68115942028987" y="91.741071428571431"/>
51 </view>
52 </view>