git.iko.soy/dashared/hookah-tau
on develop help sign in
Merge pull request #24 from dashared/admin/new-build

Admin/new build - фикс багов

commitc896aef669810f64aa37df804b880a0f736614a2 authorDarya Rednikina <31587869+dashared@users.noreply.github.com> dateWed 8 Jan 2020, 17:14 (7 years ago) parentfb6f9c4ac8a0ca
33 files changed+448−102
Hookah Tau.xcodeproj/project.pbxproj+10−2 Hookah Tau/API/ClientsService/ClientsService.swift+1−1 Hookah Tau/API/ClientsService/Resolvers/ClientsListResolver.swift+1−1 Hookah Tau/API/Reservations api/ReservationsService.swift+8−2 Hookah Tau/API/Reservations api/Resolvers/Admin/ADeleteReservationResolver.swift+34 Hookah Tau/Controllers/Admin/Clients/Cells/ClientTableViewCell.swift+2−1 Hookah Tau/Controllers/Admin/Clients/ClientsCoordinator.swift+5−2 Hookah Tau/Controllers/Admin/Clients/ClientsViewController.swift+6−2 Hookah Tau/Controllers/Admin/Clients/Profile/ClientProfileCoordinator.swift+13 Hookah Tau/Controllers/Admin/Clients/Profile/ProfileTableViewController.swift+84−9 Hookah Tau/Controllers/Admin/Reservations/AdminReservationEditingViewController.swift+17 Hookah Tau/Controllers/Admin/Reservations/List of reservations/AdminReservationsController.swift+74−1 Hookah Tau/Controllers/Admin/Reservations/List of reservations/Cell/AdminReservationCellView.xib+10−20 Hookah Tau/Controllers/Admin/Tab bar/Admin.storyboard+13−8 Hookah Tau/Controllers/BaseTableViewController.swift+28 Hookah Tau/Controllers/Client/Reservations/Active Reservations/ReservationsViewController.swift+22−1 Hookah Tau/Controllers/Client/Reservations/Maps/1/MapView1.xib+14−14 Hookah Tau/Controllers/Client/Reservations/Reservation.storyboard+4−4 Hookah Tau/Controllers/Client/Reservations/Steps/2/SecondStepView.swift−7 Hookah Tau/Controllers/Client/Reservations/Steps/2/SecondStepView.xib+10−17 Hookah Tau/Controllers/Client/Reservations/Steps/3/ThirdStepReservationViewController.swift+1−1 Hookah Tau/Controllers/Client/Tab bar/Client.storyboard+10−6 Hookah Tau/Info.plist+2−2 Hookah Tau/Models/Reservation.swift+9 Hookah Tau/Models/User.swift+10−1 Hookah Tau/Supporting Files/Assets.xcassets/peoplee.imageset/Contents.json+15 Hookah Tau/Supporting Files/Assets.xcassets/peoplee.imageset/peoplee.pdf Hookah Tau/Supporting Files/Assets.xcassets/person.imageset/Contents.json+15 Hookah Tau/Supporting Files/Assets.xcassets/person.imageset/person.pdf Hookah Tau/Supporting Files/Assets.xcassets/stack.imageset/Contents.json+15 Hookah Tau/Supporting Files/Assets.xcassets/stack.imageset/Light-S.pdf Hookah Tau/Supporting Files/Assets.xcassets/stack2.imageset/Contents.json+15 Hookah Tau/Supporting Files/Assets.xcassets/stack2.imageset/stack2.pdf
Hookah Tau.xcodeproj/project.pbxproj+10−2
@@ -95,6 +95,8 @@
9595 12D8FA2D237F003800305F57 /* DateView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 12D8FA2C237F003800305F57 /* DateView.xib */; };
9696 12D8FA2F237F00E200305F57 /* DateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12D8FA2E237F00E200305F57 /* DateView.swift */; };
9797 12D8FA31237F08C700305F57 /* AllReservations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12D8FA30237F08C700305F57 /* AllReservations.swift */; };
98+ 12D928AF23C47DCF0051724D /* ADeleteReservationResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12D928AE23C47DCF0051724D /* ADeleteReservationResolver.swift */; };
99+ 12D928B123C486380051724D /* BaseTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12D928B023C486380051724D /* BaseTableViewController.swift */; };
98100 12DBEEB223539F2100AF1BB6 /* Client.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 12DBEEB123539F2100AF1BB6 /* Client.storyboard */; };
99101 12E35071239FA8CA004BB188 /* Extensions+String.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12E35070239FA8CA004BB188 /* Extensions+String.swift */; };
100102 12E35074239FAF52004BB188 /* ClientsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12E35073239FAF52004BB188 /* ClientsService.swift */; };
@@ -249,6 +251,8 @@
249251 12D8FA2C237F003800305F57 /* DateView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DateView.xib; sourceTree = "<group>"; };
250252 12D8FA2E237F00E200305F57 /* DateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateView.swift; sourceTree = "<group>"; };
251253 12D8FA30237F08C700305F57 /* AllReservations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllReservations.swift; sourceTree = "<group>"; };
254+ 12D928AE23C47DCF0051724D /* ADeleteReservationResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ADeleteReservationResolver.swift; sourceTree = "<group>"; };
255+ 12D928B023C486380051724D /* BaseTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseTableViewController.swift; sourceTree = "<group>"; };
252256 12DBEEB123539F2100AF1BB6 /* Client.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Client.storyboard; sourceTree = "<group>"; };
253257 12E35070239FA8CA004BB188 /* Extensions+String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Extensions+String.swift"; sourceTree = "<group>"; };
254258 12E35073239FAF52004BB188 /* ClientsService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientsService.swift; sourceTree = "<group>"; };
@@ -590,6 +594,7 @@
590594 children = (
591595 12B3A7AC23ABEABF009E2FA6 /* AReservationsResolver.swift */,
592596 12B3A7C323AD2FCD009E2FA6 /* AChangeReservationResolver.swift */,
597+ 12D928AE23C47DCF0051724D /* ADeleteReservationResolver.swift */,
593598 );
594599 path = Admin;
595600 sourceTree = "<group>";
@@ -792,6 +797,7 @@
792797 F3FC7DFC2315C4710080D851 /* BaseCoordinator.swift */,
793798 F3FC7DFA2315C25D0080D851 /* ApplicationCoordinator.swift */,
794799 12B6A612235B9B4300898B31 /* BaseViewController.swift */,
800+ 12D928B023C486380051724D /* BaseTableViewController.swift */,
795801 12B3A79D23ABB8F4009E2FA6 /* Picker view */,
796802 F30369BB2336845F00A8EA84 /* Admin */,
797803 F30369BA2336845400A8EA84 /* Client */,
@@ -1171,6 +1177,7 @@
11711177 12B3A7BE23AD0049009E2FA6 /* AdminReservationEditingViewController.swift in Sources */,
11721178 12BE4B352399A60A00FC974B /* AdminTabbarController.swift in Sources */,
11731179 12FC403A2382CB6F00AB593B /* TableButton.swift in Sources */,
1180+ 12D928AF23C47DCF0051724D /* ADeleteReservationResolver.swift in Sources */,
11741181 12EB698123661CB300E4D1CE /* AddressCell.swift in Sources */,
11751182 F3895F48233D2EEA00FA6A37 /* CodeSmsViewController.swift in Sources */,
11761183 12219CEF2353A63F0057DDEE /* ReservationsCoordinator.swift in Sources */,
@@ -1236,6 +1243,7 @@
12361243 1212048E23915A0A00CAF162 /* ChangeReservationResolver.swift in Sources */,
12371244 12230AFC239034D3004A01E5 /* SecondStepReservationViewController.swift in Sources */,
12381245 F3851B2923409F8A009EE0B6 /* PhoneView.swift in Sources */,
1246+ 12D928B123C486380051724D /* BaseTableViewController.swift in Sources */,
12391247 12C72EE3235380EB00AD7004 /* ReservationsViewController.swift in Sources */,
12401248 12B6A611235B8EC500898B31 /* User.swift in Sources */,
12411249 12B3A7AD23ABEABF009E2FA6 /* AReservationsResolver.swift in Sources */,
@@ -1402,7 +1410,7 @@
14021410 buildSettings = {
14031411 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
14041412 CODE_SIGN_STYLE = Automatic;
1405− CURRENT_PROJECT_VERSION = 2;
1413+ CURRENT_PROJECT_VERSION = 3;
14061414 DEVELOPMENT_TEAM = 23S94LRHD8;
14071415 INFOPLIST_FILE = "Hookah Tau/Info.plist";
14081416 IPHONEOS_DEPLOYMENT_TARGET = 11.0;
@@ -1422,7 +1430,7 @@
14221430 buildSettings = {
14231431 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
14241432 CODE_SIGN_STYLE = Automatic;
1425− CURRENT_PROJECT_VERSION = 2;
1433+ CURRENT_PROJECT_VERSION = 3;
14261434 DEVELOPMENT_TEAM = 23S94LRHD8;
14271435 INFOPLIST_FILE = "Hookah Tau/Info.plist";
14281436 IPHONEOS_DEPLOYMENT_TARGET = 11.0;
Hookah Tau/API/ClientsService/ClientsService.swift+1−1
@@ -15,7 +15,7 @@ class ClientsService {
1515 self.apiClient = apiClient
1616 }
1717
18− func loadClientsList(completion: @escaping ((Result<[FullUser], GeneralError>) -> Void)) {
18+ func loadClientsList(completion: @escaping ((Result<[Client], GeneralError>) -> Void)) {
1919 let resolver = ClientsListResolver<ClientsResponce>()
2020 let request = ApiRequest(resolver: resolver, httpMethod: .get)
2121
Hookah Tau/API/ClientsService/Resolvers/ClientsListResolver.swift+1−1
@@ -9,7 +9,7 @@
99import Foundation
1010
1111struct ClientsResponce: MyCodable {
12− var clients: [FullUser]
12+ var clients: [Client]
1313}
1414
1515class ClientsListResolver<Responce: MyCodable>: ApiResolver {
Hookah Tau/API/Reservations api/ReservationsService.swift+8−2
@@ -40,8 +40,14 @@ class ReservationsService {
4040 }
4141 }
4242
43− func deleteReservation(uuid: String, completion: @escaping ((Bool) -> Void)) {
44− let resolver = DeleteReservationResolver(uuid: uuid)
43+ func deleteReservation(isAdmin: Bool, uuid: String, completion: @escaping ((Bool) -> Void)) {
44+ var resolver: ApiResolver!
45+ if isAdmin {
46+ resolver = ADeleteReservationResolver(uuid: uuid)
47+ } else {
48+ resolver = DeleteReservationResolver(uuid: uuid)
49+ }
50+
4551 let request = ApiRequest(resolver: resolver, httpMethod: .delete)
4652
4753 apiClient.load(request: request.request) { result in
Hookah Tau/API/Reservations api/Resolvers/Admin/ADeleteReservationResolver.swiftnew file+34
@@ -0,0 +1,34 @@
1+//
2+// ADeleteReservationResolver.swift
3+// Hookah Tau
4+//
5+// Created by cstore on 07/01/2020.
6+// Copyright © 2020 Daria Rednikina. All rights reserved.
7+//
8+
9+import Foundation
10+
11+class ADeleteReservationResolver: ApiResolver {
12+
13+ struct Request: MyCodable {
14+ var reservation: String
15+ }
16+
17+ var name: String {
18+ return "/reservations"
19+ }
20+
21+ var groupName: String? {
22+ return "/admin"
23+ }
24+
25+ var uuid: String
26+
27+ init(uuid: String) {
28+ self.uuid = uuid
29+ }
30+
31+ func parameters() -> MyCodable? {
32+ return Request(reservation: uuid)
33+ }
34+}
Hookah Tau/Controllers/Admin/Clients/Cells/ClientTableViewCell.swift+2−1
@@ -35,10 +35,11 @@ class ClientTableViewCell: UITableViewCell {
3535
3636 // MARK: - Bind
3737
38− func bind(withModel model: FullUser) {
38+ func bind(withModel model: Client) {
3939 let name = model.name ?? "❔"
4040 nameLabel.text = model.isAdmin ? "👑 " + name : name
4141 phoneNumberLabel.text = model.phoneNumber.formattedNumber()
42+ numberOfReservationsLabel.text = "\(model.reservationCount)"
4243 }
4344
4445}
Hookah Tau/Controllers/Admin/Clients/ClientsCoordinator.swift+5−2
@@ -21,9 +21,12 @@ class ClientsCoordinator: BaseCoordinator {
2121 }
2222
2323 /// TODO
24− func openUserProfile(_ profile: FullUser) {
24+ func openUserProfile(_ profile: Client) {
2525 let profileCoordinator = ClientProfileCoordinator(navigationController: navigationController)
26− profileCoordinator.user = profile
26+ profileCoordinator.user = FullUser(uuid: profile.uuid,
27+ name: profile.name,
28+ phoneNumber: profile.phoneNumber,
29+ isAdmin: profile.isAdmin)
2730
2831 self.addDependency(profileCoordinator)
2932 profileCoordinator.didEndFlow = {
Hookah Tau/Controllers/Admin/Clients/ClientsViewController.swift+6−2
@@ -12,9 +12,8 @@ class ClientsViewController: UITableViewController {
1212
1313 // MARK: - Properties
1414
15− var dataSource: [FullUser] = [] {
15+ var dataSource: [Client] = [] {
1616 didSet {
17− print(dataSource)
1817 tableView.reloadData()
1918 }
2019 }
@@ -32,6 +31,11 @@ class ClientsViewController: UITableViewController {
3231 clientsService = ClientsService(apiClient: APIClient.shared)
3332 }
3433
34+ override func viewWillAppear(_ animated: Bool) {
35+ super.viewWillAppear(animated)
36+ tabBarController?.tabBar.isHidden = false
37+ }
38+
3539 override func viewDidAppear(_ animated: Bool) {
3640 super.viewDidAppear(animated)
3741 loadClients()
Hookah Tau/Controllers/Admin/Clients/Profile/ClientProfileCoordinator.swift+13
@@ -17,6 +17,7 @@ class ClientProfileCoordinator: BaseCoordinator {
1717 let storyboard = UIStoryboard(name: "ClientList", bundle: nil)
1818 let viewController = storyboard.instantiateViewController(withIdentifier: "ProfileTableViewController") as? ProfileTableViewController
1919 viewController?.user = user
20+ viewController?.coodinator = self
2021 guard let vc = viewController else { return }
2122 navigationController?.pushViewController(vc, animated: true)
2223 }
@@ -26,4 +27,16 @@ class ClientProfileCoordinator: BaseCoordinator {
2627 func createReservation(forUserWithPhone phoneNumber: String) {
2728
2829 }
30+
31+ // Просмотр (и редактирование) брони
32+ func seeExistingReservation(data: ReservationWithUser) {
33+ let reservationCoordinator = AdminReservationEditingCoordinator(navigationController: navigationController)
34+ addDependency(reservationCoordinator)
35+ reservationCoordinator.reservationData = data
36+ reservationCoordinator.didEndFlow = { [weak self] in
37+ self?.removeDependency(reservationCoordinator)
38+ self?.navigationController?.popViewController(animated: true)
39+ }
40+ reservationCoordinator.start()
41+ }
2942}
Hookah Tau/Controllers/Admin/Clients/Profile/ProfileTableViewController.swift+84−9
@@ -8,7 +8,7 @@
88
99import UIKit
1010
11−class ProfileTableViewController: UITableViewController {
11+class ProfileTableViewController: BaseTableViewController {
1212
1313 // MARK: - IBAOutlets
1414
@@ -26,6 +26,7 @@ class ProfileTableViewController: UITableViewController {
2626 didSet {
2727 let style = BlackButtonStyle()
2828 style.apply(to: copyButton, withTitle: "СКОПИРОВАТЬ")
29+ copyButton.addTarget(self, action: #selector(copyNumber(_:)), for: .touchUpInside)
2930 }
3031 }
3132
@@ -33,6 +34,8 @@ class ProfileTableViewController: UITableViewController {
3334
3435 var clientsService: ClientsService?
3536
37+ var reservationsService: ReservationsService?
38+
3639 var user: FullUser? {
3740 didSet {
3841 guard let u = user else { return }
@@ -56,9 +59,15 @@ class ProfileTableViewController: UITableViewController {
5659 tableView?.register(ReservationCell.self, forCellReuseIdentifier: reservationCell)
5760
5861 clientsService = ClientsService(apiClient: APIClient.shared)
62+ reservationsService = ReservationsService(apiClient: APIClient.shared)
5963 loadReservations()
6064 }
6165
66+ override func viewWillAppear(_ animated: Bool) {
67+ super.viewDidAppear(animated)
68+ tabBarController?.tabBar.isHidden = true
69+ }
70+
6271 func loadReservations() {
6372 guard let uuid = user?.uuid else { return }
6473 clientsService?.loadReservationsForUser(withUUID: uuid,
@@ -72,7 +81,46 @@ class ProfileTableViewController: UITableViewController {
7281 })
7382 }
7483
75− // MARK: - Table view data source
84+
85+ func deleteReservation(uuid: String, completion: @escaping (([Reservation]?) -> Void)) {
86+ reservationsService?.deleteReservation(isAdmin: true, uuid: uuid) { result in
87+ if result {
88+ let newReservations = self.dataSource.filter { $0.uuid != uuid }
89+ completion(newReservations)
90+ return
91+ }
92+
93+ completion(nil)
94+ }
95+ }
96+
97+ // MARK: - Button handlers
98+
99+ @objc func callUser() {
100+ guard
101+ let u = user,
102+ let urlPhone = URL(string: "tel://79\(u.phoneNumber)")
103+ else { return }
104+
105+ UIApplication.shared.open(urlPhone)
106+ }
107+
108+ @objc func copyNumber(_ sender: UIButton) {
109+ guard
110+ let u = user
111+ else { return }
112+ //Copy a string to the pasteboard.
113+ UIPasteboard.general.string = "79\(u.phoneNumber)"
114+
115+ //Alert
116+ self.displayAlert(with: "Номер скопирован!")
117+ }
118+
119+}
120+
121+// MARK: - Table view data source
122+
123+extension ProfileTableViewController {
76124
77125 override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
78126 return dataSource.count
@@ -86,13 +134,40 @@ class ProfileTableViewController: UITableViewController {
86134 return cell
87135 }
88136
89− @objc func callUser() {
90− guard
91− let u = user,
92− let urlPhone = URL(string: "tel://79\(u.phoneNumber)")
93− else { return }
137+ // tap
138+
139+ override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
140+ guard let u = user else { return }
141+ let r = dataSource[indexPath.row]
142+ let reservation = ReservationWithUser(reservation: r, user: u)
143+ coodinator?.seeExistingReservation(data: reservation)
144+ }
145+
146+ // Update
147+
148+ override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
149+ return true
150+ }
151+
152+ override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
94153
95− UIApplication.shared.open(urlPhone)
154+ let uuid = dataSource[indexPath.row].uuid
155+ let cancelButton = UITableViewRowAction(style: .normal, title: "❌") { _,_ in
156+
157+ self.deleteReservation(uuid: uuid) { optionalNewVal in
158+ if let newval = optionalNewVal {
159+ self.tableView?.beginUpdates()
160+ self.tableView?.deleteRows(at: [indexPath], with: .automatic)
161+ self.dataSource = newval
162+ self.tableView?.endUpdates()
163+ } else {
164+ self.displayAlert(with: "Не удалось удалить вашу бронь! Попробуйте еще раз!")
165+ }
166+ }
167+ }
168+
169+ cancelButton.backgroundColor = .black
170+
171+ return [cancelButton]
96172 }
97−
98173}
Hookah Tau/Controllers/Admin/Reservations/AdminReservationEditingViewController.swift+17
@@ -68,6 +68,7 @@ class AdminReservationEditingViewController: BaseViewController {
6868 constant: -mainContentView.frame.height - 10)
6969
7070 saveButton.addTarget(self, action: #selector(saveReservation), for: .touchUpInside)
71+ reservationView?.cancelButton?.addTarget(self, action: #selector(cancelReservation), for: .touchUpInside)
7172 }
7273
7374 func setupContentViews() {
@@ -81,6 +82,8 @@ class AdminReservationEditingViewController: BaseViewController {
8182 mapView = MapView2.loadFromNib()
8283 }
8384
85+ navigationItem.title = TotalStorage.standard.getEstablishment(model.establishment)?.address
86+
8487 mapView?.isUserInteractionEnabled = false
8588
8689 tableContentView.addSubviewThatFills(mapView)
@@ -136,4 +139,18 @@ class AdminReservationEditingViewController: BaseViewController {
136139 self?.saveButton.loading = false
137140 })
138141 }
142+
143+ @objc func cancelReservation() {
144+ guard
145+ let uuid = reservationData?.uuid
146+ else { return }
147+
148+ reservationService?.deleteReservation(isAdmin: true, uuid: uuid, completion: { [weak self] (res) in
149+ if res {
150+ self?.coordinator?.didEndFlow?()
151+ } else {
152+ self?.displayAlert(with: "Что-то пошло не так!\nПопробуешь еще раз?")
153+ }
154+ })
155+ }
139156}
Hookah Tau/Controllers/Admin/Reservations/List of reservations/AdminReservationsController.swift+74−1
@@ -33,6 +33,10 @@ class AdminReservationsController: BaseViewController {
3333
3434 weak var coordinator: AdminReservationsCoordinator?
3535
36+ var refrControl: UIRefreshControl?
37+
38+ var activityIndicator: UIActivityIndicatorView?
39+
3640 var activeReservations: [ReservationWithUser] = [] {
3741 didSet {
3842 guard let empty = noReservationsView else { return }
@@ -43,7 +47,7 @@ class AdminReservationsController: BaseViewController {
4347 contentView.sendSubviewToBack(empty)
4448 tableView?.alpha = 1
4549 }
46−
50+ activityIndicator?.stopAnimating()
4751 tableView?.reloadData()
4852 }
4953 }
@@ -52,6 +56,7 @@ class AdminReservationsController: BaseViewController {
5256 super.viewDidLoad()
5357
5458 reservationsService = ReservationsService(apiClient: APIClient.shared)
59+ setupRefreshControl()
5560 setUpContentView()
5661 setupNavBar()
5762 }
@@ -67,12 +72,17 @@ class AdminReservationsController: BaseViewController {
6772
6873 func setupNavBar() {
6974 self.navigationItem.title = "Брони"
75+ navigationController?.navigationBar.prefersLargeTitles = true
7076 navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(book))
7177 }
7278
7379 func setUpContentView() {
7480 self.view.addSubviewThatFills(contentView)
7581
82+ activityIndicator = UIActivityIndicatorView()
83+ contentView.addSubviewThatFills(activityIndicator)
84+ activityIndicator?.startAnimating()
85+
7686 // empty
7787 noReservationsView = AdminNoReservationsView.loadFromNib()
7888 contentView.addSubviewThatFills(noReservationsView)
@@ -106,6 +116,7 @@ class AdminReservationsController: BaseViewController {
106116 case .failure(let err):
107117 self?.displayAlert(forError: err)
108118 }
119+ self?.refrControl?.endRefreshing()
109120 })
110121 }
111122
@@ -114,6 +125,30 @@ class AdminReservationsController: BaseViewController {
114125 @objc func book() {
115126
116127 }
128+
129+ func deleteReservation(uuid: String, completion: @escaping (([ReservationWithUser]?) -> Void)) {
130+ reservationsService?.deleteReservation(isAdmin: true, uuid: uuid) { result in
131+ if result {
132+ let newReservations = self.activeReservations.filter { $0.uuid != uuid }
133+ completion(newReservations)
134+ return
135+ }
136+
137+ completion(nil)
138+ }
139+ }
140+
141+ // MARK: - Refresh control
142+
143+ @objc func refreshData( _ ff: UIRefreshControl) {
144+ performUpdate()
145+ }
146+
147+ func setupRefreshControl() {
148+ refrControl = UIRefreshControl()
149+ tableView?.refreshControl = refrControl
150+ refrControl?.addTarget(self, action: #selector(refreshData(_:)), for: .valueChanged)
151+ }
117152
118153}
119154
@@ -141,5 +176,43 @@ extension AdminReservationsController: UITableViewDelegate, UITableViewDataSourc
141176 let reservation = activeReservations[indexPath.row]
142177 coordinator?.seeExistingReservation(data: reservation)
143178 }
179+
180+ // Dimesions
181+
182+ func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
183+ return UITableView.automaticDimension
184+ }
185+
186+ func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
187+ return 180.0
188+ }
189+
190+ // Update
191+
192+ func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
193+ return true
194+ }
195+
196+ func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
197+
198+ let uuid = activeReservations[indexPath.row].uuid
199+ let cancelButton = UITableViewRowAction(style: .normal, title: "❌") { _,_ in
200+
201+ self.deleteReservation(uuid: uuid) { optionalNewVal in
202+ if let newval = optionalNewVal {
203+ self.tableView?.beginUpdates()
204+ self.tableView?.deleteRows(at: [indexPath], with: .automatic)
205+ self.activeReservations = newval
206+ self.tableView?.endUpdates()
207+ } else {
208+ self.displayAlert(with: "Не удалось удалить вашу бронь! Попробуйте еще раз!")
209+ }
210+ }
211+ }
212+
213+ cancelButton.backgroundColor = .black
214+
215+ return [cancelButton]
216+ }
144217
145218}
Hookah Tau/Controllers/Admin/Reservations/List of reservations/Cell/AdminReservationCellView.xib+10−20
@@ -12,14 +12,14 @@
1212 <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
1313 <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
1414 <view contentMode="scaleToFill" id="iN0-l3-epB" customClass="AdminReservationCellView" customModule="Hookah_Tau" customModuleProvider="target">
15− <rect key="frame" x="0.0" y="0.0" width="414" height="136"/>
15+ <rect key="frame" x="0.0" y="0.0" width="414" height="180"/>
1616 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1717 <subviews>
1818 <stackView opaque="NO" contentMode="scaleToFill" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="au9-nK-XbR">
19− <rect key="frame" x="17" y="3" width="380" height="133"/>
19+ <rect key="frame" x="20" y="20" width="374" height="140"/>
2020 <subviews>
2121 <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" alignment="top" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="rCf-m8-E3w">
22− <rect key="frame" x="0.0" y="0.0" width="254" height="133"/>
22+ <rect key="frame" x="0.0" y="0.0" width="248" height="140"/>
2323 <subviews>
2424 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Стасик" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="KV8-UG-2ws">
2525 <rect key="frame" x="0.0" y="0.0" width="54" height="19.5"/>
@@ -28,7 +28,7 @@
2828 <nil key="highlightedColor"/>
2929 </label>
3030 <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="top" spacing="4" translatesAutoresizingMaskIntoConstraints="NO" id="nsQ-SE-3vW">
31− <rect key="frame" x="0.0" y="43.5" width="102" height="45"/>
31+ <rect key="frame" x="0.0" y="47" width="102" height="45"/>
3232 <subviews>
3333 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="27 марта" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9k3-E5-XKR">
3434 <rect key="frame" x="0.0" y="0.0" width="76.5" height="20.5"/>
@@ -45,7 +45,7 @@
4545 </subviews>
4646 </stackView>
4747 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="3 человека" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VhL-qH-zM9">
48− <rect key="frame" x="0.0" y="112.5" width="89" height="20.5"/>
48+ <rect key="frame" x="0.0" y="119.5" width="89" height="20.5"/>
4949 <fontDescription key="fontDescription" type="system" pointSize="17"/>
5050 <nil key="textColor"/>
5151 <nil key="highlightedColor"/>
@@ -53,27 +53,17 @@
5353 </subviews>
5454 </stackView>
5555 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="1_7" translatesAutoresizingMaskIntoConstraints="NO" id="Oa6-n7-joV">
56− <rect key="frame" x="262" y="0.0" width="118" height="133"/>
56+ <rect key="frame" x="256" y="0.0" width="118" height="140"/>
5757 </imageView>
5858 </subviews>
5959 </stackView>
60− <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3u6-xl-ioO">
61− <rect key="frame" x="20" y="135" width="394" height="1"/>
62− <color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
63− <constraints>
64− <constraint firstAttribute="height" constant="1" id="YCb-84-2qo"/>
65− </constraints>
66− </view>
6760 </subviews>
6861 <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
6962 <constraints>
70− <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="au9-nK-XbR" secondAttribute="trailing" constant="17" id="Afx-VC-Cb6"/>
71− <constraint firstItem="3u6-xl-ioO" firstAttribute="bottom" secondItem="vUN-kp-3ea" secondAttribute="bottom" id="Lpw-A9-AcM"/>
72− <constraint firstItem="au9-nK-XbR" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="3" id="P5E-WG-AYe"/>
73− <constraint firstItem="au9-nK-XbR" firstAttribute="bottom" secondItem="vUN-kp-3ea" secondAttribute="bottom" id="Z6h-RB-tvj"/>
74− <constraint firstItem="au9-nK-XbR" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="17" id="fJE-La-qC6"/>
75− <constraint firstItem="3u6-xl-ioO" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="20" id="pqq-kW-AFb"/>
76− <constraint firstItem="3u6-xl-ioO" firstAttribute="trailing" secondItem="vUN-kp-3ea" secondAttribute="trailing" id="zrd-Ir-hU2"/>
63+ <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="au9-nK-XbR" secondAttribute="trailing" constant="20" id="Afx-VC-Cb6"/>
64+ <constraint firstItem="au9-nK-XbR" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="20" id="P5E-WG-AYe"/>
65+ <constraint firstItem="au9-nK-XbR" firstAttribute="bottom" secondItem="vUN-kp-3ea" secondAttribute="bottom" constant="-20" id="Z6h-RB-tvj"/>
66+ <constraint firstItem="au9-nK-XbR" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="20" id="fJE-La-qC6"/>
7767 </constraints>
7868 <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
7969 <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
Hookah Tau/Controllers/Admin/Tab bar/Admin.storyboard+13−8
@@ -1,14 +1,14 @@
11<?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">
33 <device id="retina6_1" orientation="portrait" appearance="light"/>
44 <dependencies>
55 <deployment identifier="iOS"/>
6− <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14824"/>
6+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
77 <capability name="Safe area layout guides" minToolsVersion="9.0"/>
88 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
99 </dependencies>
1010 <scenes>
11− <!--Navigation Controller-->
11+ <!--Клиенты-->
1212 <scene sceneID="Q3i-Bo-7ns">
1313 <objects>
1414 <viewController id="Ifn-72-mgx" customClass="UINavigationController" sceneMemberID="viewController">
@@ -18,13 +18,13 @@
1818 <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
1919 <viewLayoutGuide key="safeArea" id="yHG-bf-ndj"/>
2020 </view>
21− <tabBarItem key="tabBarItem" systemItem="downloads" id="9K1-uc-72H"/>
21+ <tabBarItem key="tabBarItem" title="Клиенты" image="peoplee" id="9K1-uc-72H"/>
2222 </viewController>
2323 <placeholder placeholderIdentifier="IBFirstResponder" id="8X9-ca-bCi" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
2424 </objects>
2525 <point key="canvasLocation" x="1061" y="-327"/>
2626 </scene>
27− <!--Navigation Controller-->
27+ <!--Профиль-->
2828 <scene sceneID="cAb-sw-24k">
2929 <objects>
3030 <viewController id="Jsm-cH-XbJ" customClass="UINavigationController" sceneMemberID="viewController">
@@ -34,13 +34,13 @@
3434 <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
3535 <viewLayoutGuide key="safeArea" id="f96-UV-eoi"/>
3636 </view>
37− <tabBarItem key="tabBarItem" systemItem="contacts" id="ziF-T0-lg1"/>
37+ <tabBarItem key="tabBarItem" title="Профиль" image="person" id="ziF-T0-lg1"/>
3838 </viewController>
3939 <placeholder placeholderIdentifier="IBFirstResponder" id="qqi-vY-Mog" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
4040 </objects>
4141 <point key="canvasLocation" x="1061" y="433"/>
4242 </scene>
43− <!--Navigation Controller-->
43+ <!--Брони-->
4444 <scene sceneID="p6D-Gs-DUK">
4545 <objects>
4646 <viewController id="Tc3-UW-Fwi" customClass="UINavigationController" sceneMemberID="viewController">
@@ -50,7 +50,7 @@
5050 <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
5151 <viewLayoutGuide key="safeArea" id="z8c-Ub-USh"/>
5252 </view>
53− <tabBarItem key="tabBarItem" systemItem="mostViewed" id="szW-oN-ixR"/>
53+ <tabBarItem key="tabBarItem" title="Брони" image="stack" id="szW-oN-ixR"/>
5454 </viewController>
5555 <placeholder placeholderIdentifier="IBFirstResponder" id="1ST-zr-4Zs" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
5656 </objects>
@@ -76,4 +76,9 @@
7676 <point key="canvasLocation" x="-817" y="-251"/>
7777 </scene>
7878 </scenes>
79+ <resources>
80+ <image name="peoplee" width="51" height="25"/>
81+ <image name="person" width="25" height="24"/>
82+ <image name="stack" width="25" height="24"/>
83+ </resources>
7984</document>
Hookah Tau/Controllers/BaseTableViewController.swiftnew file+28
@@ -0,0 +1,28 @@
1+//
2+// BaseTableViewController.swift
3+// Hookah Tau
4+//
5+// Created by cstore on 07/01/2020.
6+// Copyright © 2020 Daria Rednikina. All rights reserved.
7+//
8+
9+import UIKit
10+
11+class BaseTableViewController: UITableViewController {
12+
13+ // MARK: - Alert
14+
15+ func displayAlert(forError error: GeneralError = GeneralError.noData, with message: String? = nil) {
16+ var title: String? = message == nil ? error.localizedDescription : message
17+ switch error {
18+ case .serverError(let se):
19+ title = se.error
20+ fallthrough // да тоже произведение искусства
21+ default:
22+ let alert = UIAlertController(title: title, message: nil, preferredStyle: .alert)
23+ alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
24+ self.present(alert, animated: true, completion: nil)
25+ }
26+ }
27+
28+}
Hookah Tau/Controllers/Client/Reservations/Active Reservations/ReservationsViewController.swift+22−1
@@ -23,6 +23,7 @@ class ReservationsViewController: BaseViewController {
2323 tableView?.alpha = 1
2424 }
2525
26+ activityIndicator.stopAnimating()
2627 tableView?.reloadData()
2728 }
2829 }
@@ -45,6 +46,8 @@ class ReservationsViewController: BaseViewController {
4546 return tableView
4647 }()
4748
49+ var activityIndicator = UIActivityIndicatorView()
50+
4851 // MARK: - Lifecycle
4952
5053 override func viewDidLoad() {
@@ -74,6 +77,9 @@ class ReservationsViewController: BaseViewController {
7477 func setUpContentView() {
7578 self.view.addSubviewThatFills(contentView)
7679
80+ contentView.addSubviewThatFills(activityIndicator)
81+ activityIndicator.startAnimating()
82+
7783 // empty
7884 noReservationsView = NoReservationsView.loadFromNib()
7985 contentView.addSubviewThatFills(noReservationsView)
@@ -85,6 +91,7 @@ class ReservationsViewController: BaseViewController {
8591 contentView.addSubviewThatFills(tableView)
8692
8793 setUpTableView()
94+ setupRefreshControl()
8895 }
8996
9097 func setUpTableView() {
@@ -120,11 +127,12 @@ class ReservationsViewController: BaseViewController {
120127 case .failure(let err):
121128 self?.displayAlert(forError: err)
122129 }
130+ self?.refrControl?.endRefreshing()
123131 })
124132 }
125133
126134 func deleteReservation(uuid: String, completion: @escaping (([Reservation]?) -> Void)) {
127− reservationsService?.deleteReservation(uuid: uuid) { result in
135+ reservationsService?.deleteReservation(isAdmin: false, uuid: uuid) { result in
128136 if result {
129137 let newReservations = self.activeReservations.filter { $0.uuid != uuid }
130138 completion(newReservations)
@@ -135,6 +143,19 @@ class ReservationsViewController: BaseViewController {
135143 }
136144 }
137145
146+ // MARK: - Refresh control
147+
148+ var refrControl: UIRefreshControl?
149+
150+ func setupRefreshControl() {
151+ refrControl = UIRefreshControl()
152+ tableView?.refreshControl = refrControl
153+ refrControl?.addTarget(self, action: #selector(refreshData(_:)), for: .valueChanged)
154+ }
155+
156+ @objc func refreshData( _ ff: UIRefreshControl) {
157+ performUpdate()
158+ }
138159}
139160
140161extension ReservationsViewController: UITableViewDelegate, UITableViewDataSource {
Hookah Tau/Controllers/Client/Reservations/Maps/1/MapView1.xib+14−14
@@ -1,9 +1,9 @@
11<?xml version="1.0" encoding="UTF-8"?>
2−<document type="com.apple.InterfaceBuilder3.CocoaTouch.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.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
33 <device id="retina4_7" orientation="portrait" appearance="light"/>
44 <dependencies>
55 <deployment identifier="iOS"/>
6− <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14824"/>
6+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
77 <capability name="Safe area layout guides" minToolsVersion="9.0"/>
88 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
99 </dependencies>
@@ -21,22 +21,22 @@
2121 <rect key="frame" x="0.0" y="0.0" width="536" height="636"/>
2222 </imageView>
2323 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Y23-Wu-4BW" customClass="TableButton" customModule="Hookah_Tau" customModuleProvider="target">
24− <rect key="frame" x="44" y="37" width="102" height="117"/>
24+ <rect key="frame" x="44" y="37" width="102" height="119"/>
2525 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
2626 <constraints>
2727 <constraint firstAttribute="width" constant="102" id="EKZ-Ny-4RQ"/>
28− <constraint firstAttribute="height" constant="117" id="u1N-5d-cFR"/>
28+ <constraint firstAttribute="height" constant="119" id="u1N-5d-cFR"/>
2929 </constraints>
3030 <connections>
3131 <action selector="chooseFirstTable:" destination="iN0-l3-epB" eventType="touchUpInside" id="1O9-7Q-a8g"/>
3232 </connections>
3333 </button>
3434 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="xsw-fJ-8cN" customClass="TableButton" customModule="Hookah_Tau" customModuleProvider="target">
35− <rect key="frame" x="209" y="113" width="131" height="119"/>
35+ <rect key="frame" x="209" y="116" width="131" height="117"/>
3636 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
3737 <constraints>
3838 <constraint firstAttribute="width" constant="131" id="2xi-Oz-ceC"/>
39− <constraint firstAttribute="height" constant="119" id="xPD-fh-9Zg"/>
39+ <constraint firstAttribute="height" constant="117" id="xPD-fh-9Zg"/>
4040 </constraints>
4141 <connections>
4242 <action selector="chooseSecondTable:" destination="iN0-l3-epB" eventType="touchUpInside" id="5XE-gZ-DyJ"/>
@@ -54,10 +54,10 @@
5454 </connections>
5555 </button>
5656 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Fw9-l6-N8a" customClass="TableButton" customModule="Hookah_Tau" customModuleProvider="target">
57− <rect key="frame" x="60" y="350" width="102" height="118"/>
57+ <rect key="frame" x="60" y="350" width="102" height="120"/>
5858 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
5959 <constraints>
60− <constraint firstAttribute="height" constant="118" id="2Vp-Ip-7cO"/>
60+ <constraint firstAttribute="height" constant="120" id="2Vp-Ip-7cO"/>
6161 <constraint firstAttribute="width" constant="102" id="2hI-75-UCM"/>
6262 </constraints>
6363 <connections>
@@ -65,10 +65,10 @@
6565 </connections>
6666 </button>
6767 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="KJZ-Nl-7hH" customClass="TableButton" customModule="Hookah_Tau" customModuleProvider="target">
68− <rect key="frame" x="222" y="272" width="104" height="119"/>
68+ <rect key="frame" x="222" y="273" width="104" height="120"/>
6969 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
7070 <constraints>
71− <constraint firstAttribute="height" constant="119" id="Ifu-kd-YHH"/>
71+ <constraint firstAttribute="height" constant="120" id="Ifu-kd-YHH"/>
7272 <constraint firstAttribute="width" constant="104" id="phm-aP-6dx"/>
7373 </constraints>
7474 <connections>
@@ -76,7 +76,7 @@
7676 </connections>
7777 </button>
7878 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="mUw-im-1BC" customClass="TableButton" customModule="Hookah_Tau" customModuleProvider="target">
79− <rect key="frame" x="222" y="431" width="92" height="67"/>
79+ <rect key="frame" x="222" y="433" width="92" height="67"/>
8080 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
8181 <constraints>
8282 <constraint firstAttribute="width" constant="92" id="AJ6-ku-4R3"/>
@@ -87,10 +87,10 @@
8787 </connections>
8888 </button>
8989 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="aIM-Qn-Uhl" customClass="TableButton" customModule="Hookah_Tau" customModuleProvider="target">
90− <rect key="frame" x="386" y="116" width="130" height="119"/>
90+ <rect key="frame" x="386" y="116" width="131" height="119"/>
9191 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
9292 <constraints>
93− <constraint firstAttribute="width" constant="130" id="Lhq-jM-PQ0"/>
93+ <constraint firstAttribute="width" constant="131" id="Lhq-jM-PQ0"/>
9494 <constraint firstAttribute="height" constant="119" id="vsx-u8-L6o"/>
9595 </constraints>
9696 <connections>
@@ -123,7 +123,7 @@
123123 <constraint firstItem="mUw-im-1BC" firstAttribute="top" secondItem="KJZ-Nl-7hH" secondAttribute="bottom" constant="40" id="GaI-BE-NZy"/>
124124 <constraint firstItem="btD-Wl-3P6" firstAttribute="width" secondItem="FuE-LV-NBR" secondAttribute="width" priority="250" id="MDs-kk-aza"/>
125125 <constraint firstItem="btD-Wl-3P6" firstAttribute="top" secondItem="aIM-Qn-Uhl" secondAttribute="bottom" constant="-235" id="NwR-U0-V6F"/>
126− <constraint firstItem="mUw-im-1BC" firstAttribute="top" secondItem="btD-Wl-3P6" secondAttribute="bottom" constant="-205" id="UXz-DD-dPH"/>
126+ <constraint firstItem="mUw-im-1BC" firstAttribute="top" secondItem="btD-Wl-3P6" secondAttribute="bottom" constant="-203" id="UXz-DD-dPH"/>
127127 <constraint firstItem="mUw-im-1BC" firstAttribute="leading" secondItem="Fw9-l6-N8a" secondAttribute="trailing" constant="60" id="V4u-ko-iFV"/>
128128 <constraint firstItem="KJZ-Nl-7hH" firstAttribute="top" secondItem="xsw-fJ-8cN" secondAttribute="bottom" constant="40" id="XFV-l2-chC"/>
129129 <constraint firstItem="btD-Wl-3P6" firstAttribute="top" secondItem="onR-hl-Q2x" secondAttribute="bottom" constant="-332" id="XNT-i4-1l8"/>
Hookah Tau/Controllers/Client/Reservations/Reservation.storyboard+4−4
@@ -1,9 +1,9 @@
11<?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">
33 <device id="retina6_1" orientation="portrait" appearance="light"/>
44 <dependencies>
55 <deployment identifier="iOS"/>
6− <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14824"/>
6+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
77 <capability name="Safe area layout guides" minToolsVersion="9.0"/>
88 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
99 </dependencies>
@@ -49,10 +49,10 @@
4949 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
5050 <subviews>
5151 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="NBJ-7w-vpV">
52− <rect key="frame" x="0.0" y="502" width="414" height="394"/>
52+ <rect key="frame" x="0.0" y="544" width="414" height="352"/>
5353 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
5454 <constraints>
55− <constraint firstAttribute="height" constant="394" id="KKm-d5-Srx"/>
55+ <constraint firstAttribute="height" constant="352" id="KKm-d5-Srx"/>
5656 </constraints>
5757 </view>
5858 </subviews>
Hookah Tau/Controllers/Client/Reservations/Steps/2/SecondStepView.swift−7
@@ -23,8 +23,6 @@ class SecondStepView: UIView {
2323
2424 @IBOutlet weak var totalBookingLabel: UILabel!
2525
26− @IBOutlet weak var infoLabel: UILabel!
27−
2826 @IBOutlet weak var specialLabel: UILabel! {
2927 didSet {
3028 let m = NSMutableAttributedString(string: "Если Вам нужно что-то особенное, Вы можете связаться с администратором ")
@@ -131,7 +129,6 @@ class SecondStepView: UIView {
131129 @IBAction func sliderValueChanged(_ sender: UISlider) {
132130 let value = Int(sender.value)
133131 numberOfGuestsLabel.text = "Количество гостей: \(value)"
134− infoLabel.text = getNumberOfCalians(value)
135132
136133 guard let d = data else { return }
137134
@@ -151,10 +148,6 @@ class SecondStepView: UIView {
151148 UIApplication.shared.open(urlPhone)
152149 }
153150
154− func getNumberOfCalians(_ sliderValue: Int) -> String {
155− return "Минимальное количество кальянов: \(sliderValue > 6 ? 2 : 1)"
156− }
157−
158151 // MARK: - Setup
159152
160153 /// Тут происходит установка интервалов. Разное для клиента и админа
Hookah Tau/Controllers/Client/Reservations/Steps/2/SecondStepView.xib+10−17
@@ -1,9 +1,9 @@
11<?xml version="1.0" encoding="UTF-8"?>
2−<document type="com.apple.InterfaceBuilder3.CocoaTouch.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.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
33 <device id="retina4_7" orientation="portrait" appearance="light"/>
44 <dependencies>
55 <deployment identifier="iOS"/>
6− <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14824"/>
6+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
77 <capability name="Safe area layout guides" minToolsVersion="9.0"/>
88 <capability name="Stack View standard spacing" minToolsVersion="9.0"/>
99 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -12,14 +12,14 @@
1212 <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
1313 <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
1414 <view contentMode="scaleToFill" id="iN0-l3-epB" customClass="SecondStepView" customModule="Hookah_Tau" customModuleProvider="target">
15− <rect key="frame" x="0.0" y="0.0" width="414" height="394"/>
15+ <rect key="frame" x="0.0" y="0.0" width="414" height="352"/>
1616 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1717 <subviews>
1818 <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="bJ1-1q-VXq">
19− <rect key="frame" x="20" y="20" width="374" height="131.5"/>
19+ <rect key="frame" x="20" y="20" width="374" height="80"/>
2020 <subviews>
2121 <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" alignment="center" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="Dkh-B7-3Dl">
22− <rect key="frame" x="16.5" y="0.0" width="341.5" height="92.5"/>
22+ <rect key="frame" x="16.5" y="0.0" width="341.5" height="41"/>
2323 <subviews>
2424 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Забронировать 7 столик на 3 человека 29 марта с 3:00 до 5:30?" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7M9-lI-egu">
2525 <rect key="frame" x="0.0" y="0.0" width="341.5" height="41"/>
@@ -27,16 +27,10 @@
2727 <nil key="textColor"/>
2828 <nil key="highlightedColor"/>
2929 </label>
30− <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Минимальное количество кальянов: 2" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zMP-Wa-N6b">
31− <rect key="frame" x="11" y="72" width="319" height="20.5"/>
32− <fontDescription key="fontDescription" type="system" weight="semibold" pointSize="17"/>
33− <nil key="textColor"/>
34− <nil key="highlightedColor"/>
35− </label>
3630 </subviews>
3731 </stackView>
3832 <label opaque="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PHb-Nt-9I2">
39− <rect key="frame" x="47" y="102.5" width="280.5" height="29"/>
33+ <rect key="frame" x="47" y="51" width="280.5" height="29"/>
4034 <string key="text">Если Вам нужно что-то особенное, Вы можете
4135связаться с администратором. </string>
4236 <fontDescription key="fontDescription" name=".AppleSystemUIFont" family=".AppleSystemUIFont" pointSize="12"/>
@@ -46,7 +40,7 @@
4640 </subviews>
4741 </stackView>
4842 <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="9c7-IZ-n2p">
49− <rect key="frame" x="20" y="171.5" width="373.5" height="60.5"/>
43+ <rect key="frame" x="20" y="120" width="373.5" height="70"/>
5044 <subviews>
5145 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Количество гостей: 3" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QuY-68-2ax">
5246 <rect key="frame" x="0.0" y="0.0" width="373.5" height="20.5"/>
@@ -55,7 +49,7 @@
5549 <nil key="highlightedColor"/>
5650 </label>
5751 <slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="3" minValue="1" maxValue="10" translatesAutoresizingMaskIntoConstraints="NO" id="TrY-MC-Ty0">
58− <rect key="frame" x="-2" y="30.5" width="377.5" height="31"/>
52+ <rect key="frame" x="-2" y="30.5" width="377.5" height="40.5"/>
5953 <connections>
6054 <action selector="sliderValueChanged:" destination="iN0-l3-epB" eventType="valueChanged" id="ekZ-3h-EeB"/>
6155 </connections>
@@ -63,7 +57,7 @@
6357 </subviews>
6458 </stackView>
6559 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="RJE-Hk-KNh">
66− <rect key="frame" x="0.0" y="252" width="414" height="106"/>
60+ <rect key="frame" x="0.0" y="210" width="414" height="106"/>
6761 <subviews>
6862 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dmc-2e-y3T">
6963 <rect key="frame" x="0.0" y="21" width="414" height="85"/>
@@ -144,14 +138,13 @@
144138 <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
145139 <connections>
146140 <outlet property="guestSlider" destination="TrY-MC-Ty0" id="mR0-wv-AM7"/>
147− <outlet property="infoLabel" destination="zMP-Wa-N6b" id="htu-ql-T0O"/>
148141 <outlet property="intervalsStackView" destination="IIO-je-eBt" id="gaP-LX-Xed"/>
149142 <outlet property="numberOfGuestsLabel" destination="QuY-68-2ax" id="DvK-dr-c3J"/>
150143 <outlet property="scrollView" destination="zk1-3E-2kS" id="b8R-jY-2Q3"/>
151144 <outlet property="specialLabel" destination="PHb-Nt-9I2" id="hXL-Je-dax"/>
152145 <outlet property="totalBookingLabel" destination="7M9-lI-egu" id="7YU-yI-Gm4"/>
153146 </connections>
154− <point key="canvasLocation" x="-8" y="70"/>
147+ <point key="canvasLocation" x="-8" y="88.15592203898052"/>
155148 </view>
156149 </objects>
157150</document>
Hookah Tau/Controllers/Client/Reservations/Steps/3/ThirdStepReservationViewController.swift+1−1
@@ -139,7 +139,7 @@ class ThirdStepReservationViewController: BaseViewController {
139139 guard let res = reservation else { return }
140140
141141 cancelButton.loading = true
142− reservationService?.deleteReservation(uuid: res.uuid, completion: { [weak self] (result) in
142+ reservationService?.deleteReservation(isAdmin: false, uuid: res.uuid, completion: { [weak self] (result) in
143143 self?.cancelButton.loading = false
144144
145145 if result {
Hookah Tau/Controllers/Client/Tab bar/Client.storyboard+10−6
@@ -1,14 +1,14 @@
11<?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">
33 <device id="retina6_1" orientation="portrait" appearance="light"/>
44 <dependencies>
55 <deployment identifier="iOS"/>
6− <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14824"/>
6+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
77 <capability name="Safe area layout guides" minToolsVersion="9.0"/>
88 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
99 </dependencies>
1010 <scenes>
11− <!--Navigation Controller-->
11+ <!--Профиль-->
1212 <scene sceneID="b0t-Wu-VhQ">
1313 <objects>
1414 <viewController id="qqN-qg-VJ7" customClass="UINavigationController" sceneMemberID="viewController">
@@ -18,13 +18,13 @@
1818 <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
1919 <viewLayoutGuide key="safeArea" id="WgY-fu-N23"/>
2020 </view>
21− <tabBarItem key="tabBarItem" systemItem="contacts" id="vPo-1j-5WO"/>
21+ <tabBarItem key="tabBarItem" title="Профиль" image="person" id="vPo-1j-5WO"/>
2222 </viewController>
2323 <placeholder placeholderIdentifier="IBFirstResponder" id="zv0-gE-V7c" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
2424 </objects>
2525 <point key="canvasLocation" x="-166" y="195"/>
2626 </scene>
27− <!--Navigation Controller-->
27+ <!--Брони-->
2828 <scene sceneID="nQv-Ks-RjM">
2929 <objects>
3030 <viewController id="MGt-zZ-AbL" customClass="UINavigationController" sceneMemberID="viewController">
@@ -34,7 +34,7 @@
3434 <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
3535 <viewLayoutGuide key="safeArea" id="vjZ-Ji-o7T"/>
3636 </view>
37− <tabBarItem key="tabBarItem" systemItem="mostViewed" id="B7T-zH-VfU"/>
37+ <tabBarItem key="tabBarItem" title="Брони" image="stack" id="B7T-zH-VfU"/>
3838 </viewController>
3939 <placeholder placeholderIdentifier="IBFirstResponder" id="W83-e1-iNk" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
4040 </objects>
@@ -59,4 +59,8 @@
5959 <point key="canvasLocation" x="-1081" y="-130"/>
6060 </scene>
6161 </scenes>
62+ <resources>
63+ <image name="person" width="25" height="24"/>
64+ <image name="stack" width="25" height="24"/>
65+ </resources>
6266</document>
Hookah Tau/Info.plist+2−2
@@ -2,8 +2,6 @@
22<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33<plist version="1.0">
44<dict>
5− <key>ITSAppUsesNonExemptEncryption</key>
6− <false/>
75 <key>CFBundleDevelopmentRegion</key>
86 <string>$(DEVELOPMENT_LANGUAGE)</string>
97 <key>CFBundleExecutable</key>
@@ -20,6 +18,8 @@
2018 <string>1.0</string>
2119 <key>CFBundleVersion</key>
2220 <string>$(CURRENT_PROJECT_VERSION)</string>
21+ <key>ITSAppUsesNonExemptEncryption</key>
22+ <false/>
2323 <key>LSRequiresIPhoneOS</key>
2424 <true/>
2525 <key>UILaunchStoryboardName</key>
Hookah Tau/Models/Reservation.swift+9
@@ -59,6 +59,15 @@ struct ReservationWithUser: MyCodable {
5959 var reservedTable: Int
6060 var owner: FullUser
6161
62+ init(reservation: Reservation, user: FullUser) {
63+ self.uuid = reservation.uuid
64+ self.establishment = reservation.establishment
65+ self.startTime = reservation.startTime
66+ self.endTime = reservation.endTime
67+ self.numberOfGuests = reservation.numberOfGuests
68+ self.reservedTable = reservation.reservedTable
69+ self.owner = user
70+ }
6271}
6372
6473
Hookah Tau/Models/User.swift+10−1
@@ -15,10 +15,19 @@ struct User: MyCodable {
1515 var isAdmin: Bool
1616}
1717
18−/// При запросах на список пользователей в аккаунте администратора
18+/// При запросах на список пользователей в аккаунте администратора.
1919struct FullUser: MyCodable {
2020 var uuid: String
2121 var name: String?
2222 var phoneNumber: String
2323 var isAdmin: Bool
2424}
25+
26+/// `GET /admin/clients`
27+struct Client: MyCodable {
28+ var uuid: String
29+ var name: String?
30+ var phoneNumber: String
31+ var isAdmin: Bool
32+ var reservationCount: Int
33+}
Hookah Tau/Supporting Files/Assets.xcassets/peoplee.imageset/Contents.jsonnew file+15
@@ -0,0 +1,15 @@
1+{
2+ "images" : [
3+ {
4+ "idiom" : "universal",
5+ "filename" : "peoplee.pdf"
6+ }
7+ ],
8+ "info" : {
9+ "version" : 1,
10+ "author" : "xcode"
11+ },
12+ "properties" : {
13+ "template-rendering-intent" : "template"
14+ }
15+}
Hookah Tau/Supporting Files/Assets.xcassets/peoplee.imageset/peoplee.pdfnew file

Binary file not shown.

Hookah Tau/Supporting Files/Assets.xcassets/person.imageset/Contents.jsonnew file+15
@@ -0,0 +1,15 @@
1+{
2+ "images" : [
3+ {
4+ "idiom" : "universal",
5+ "filename" : "person.pdf"
6+ }
7+ ],
8+ "info" : {
9+ "version" : 1,
10+ "author" : "xcode"
11+ },
12+ "properties" : {
13+ "template-rendering-intent" : "template"
14+ }
15+}
Hookah Tau/Supporting Files/Assets.xcassets/person.imageset/person.pdfnew file

Binary file not shown.

Hookah Tau/Supporting Files/Assets.xcassets/stack.imageset/Contents.jsonnew file+15
@@ -0,0 +1,15 @@
1+{
2+ "images" : [
3+ {
4+ "idiom" : "universal",
5+ "filename" : "Light-S.pdf"
6+ }
7+ ],
8+ "info" : {
9+ "version" : 1,
10+ "author" : "xcode"
11+ },
12+ "properties" : {
13+ "template-rendering-intent" : "template"
14+ }
15+}
Hookah Tau/Supporting Files/Assets.xcassets/stack.imageset/Light-S.pdfnew file

Binary file not shown.

Hookah Tau/Supporting Files/Assets.xcassets/stack2.imageset/Contents.jsonnew file+15
@@ -0,0 +1,15 @@
1+{
2+ "images" : [
3+ {
4+ "idiom" : "universal",
5+ "filename" : "stack2.pdf"
6+ }
7+ ],
8+ "info" : {
9+ "version" : 1,
10+ "author" : "xcode"
11+ },
12+ "properties" : {
13+ "preserves-vector-representation" : true
14+ }
15+}
Hookah Tau/Supporting Files/Assets.xcassets/stack2.imageset/stack2.pdfnew file

Binary file not shown.