git.iko.soy/dashared/hookah-tau
on develop help sign in
Приделала экран изменения брони, кнопочка по изменению живая
commitec151268251e6ec497cb465bf07782f799ebea80 authorDarya Rednikina <rednikina.com@yandex.ru> dateFri 20 Dec 2019, 20:47 (7 years ago) parent1f3f41c
17 files changed+439−45
Hookah Tau.xcodeproj/project.pbxproj+35−3 Hookah Tau/API/Reservations api/ReservationsService.swift+31−1 Hookah Tau/API/Reservations api/Resolvers/Admin/AChangeReservationResolver.swift+34 Hookah Tau/API/Reservations api/Resolvers/ReservationsAroundResolver.swift+35 Hookah Tau/Controllers/Admin/Clients/Profile/ProfileTableViewController.swift+1−1 Hookah Tau/Controllers/Admin/Reservations/AdminAddressCoordinator.swift+1 Hookah Tau/Controllers/Admin/Reservations/AdminReservationEditingCoordinator.swift+29 Hookah Tau/Controllers/Admin/Reservations/AdminReservationEditingViewController.swift+139 Hookah Tau/Controllers/Admin/Reservations/AdminReservations.storyboard+41 Hookah Tau/Controllers/Admin/Reservations/AdminReservationsController.swift → Hookah Tau/Controllers/Admin/Reservations/List of reservations/AdminReservationsController.swift+22−13 Hookah Tau/Controllers/Admin/Reservations/AdminReservationsCoordinator.swift → Hookah Tau/Controllers/Admin/Reservations/List of reservations/AdminReservationsCoordinator.swift+16 Hookah Tau/Controllers/Admin/Reservations/Cell/AdminReservationCellView.swift → Hookah Tau/Controllers/Admin/Reservations/List of reservations/Cell/AdminReservationCellView.swift Hookah Tau/Controllers/Admin/Reservations/Cell/AdminReservationCellView.xib → Hookah Tau/Controllers/Admin/Reservations/List of reservations/Cell/AdminReservationCellView.xib+2−2 Hookah Tau/Controllers/Admin/Reservations/Views/AdminReservationView.swift+24−8 Hookah Tau/Controllers/Admin/Reservations/Views/AdminReservationView.xib+27−17 Hookah Tau/Controllers/Client/Reservations/Maps/MapView.swift+1 Hookah Tau/Controllers/Client/Reservations/Steps/change /ChangeReservationViewController.swift+1
Hookah Tau.xcodeproj/project.pbxproj+35−3
@@ -71,6 +71,10 @@
7171 12B3A7B423AC1D09009E2FA6 /* AdminReservationCellView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 12B3A7B323AC1D09009E2FA6 /* AdminReservationCellView.xib */; };
7272 12B3A7B723ACCD07009E2FA6 /* SettingsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7B623ACCD07009E2FA6 /* SettingsService.swift */; };
7373 12B3A7B923ACCD83009E2FA6 /* AddOtherAdminResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7B823ACCD83009E2FA6 /* AddOtherAdminResolver.swift */; };
74+ 12B3A7BC23ACFD75009E2FA6 /* ReservationsAroundResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7BB23ACFD75009E2FA6 /* ReservationsAroundResolver.swift */; };
75+ 12B3A7BE23AD0049009E2FA6 /* AdminReservationEditingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7BD23AD0048009E2FA6 /* AdminReservationEditingViewController.swift */; };
76+ 12B3A7C023AD0749009E2FA6 /* AdminReservationEditingCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7BF23AD0749009E2FA6 /* AdminReservationEditingCoordinator.swift */; };
77+ 12B3A7C423AD2FCD009E2FA6 /* AChangeReservationResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7C323AD2FCD009E2FA6 /* AChangeReservationResolver.swift */; };
7478 12B4447C238EF25C000B6B16 /* CreateReservationResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B4447B238EF25C000B6B16 /* CreateReservationResolver.swift */; };
7579 12B6A60F235B857A00898B31 /* ProfileChangeCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B6A60E235B857A00898B31 /* ProfileChangeCoordinator.swift */; };
7680 12B6A611235B8EC500898B31 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B6A610235B8EC500898B31 /* User.swift */; };
@@ -221,6 +225,10 @@
221225 12B3A7B323AC1D09009E2FA6 /* AdminReservationCellView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AdminReservationCellView.xib; sourceTree = "<group>"; };
222226 12B3A7B623ACCD07009E2FA6 /* SettingsService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsService.swift; sourceTree = "<group>"; };
223227 12B3A7B823ACCD83009E2FA6 /* AddOtherAdminResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddOtherAdminResolver.swift; sourceTree = "<group>"; };
228+ 12B3A7BB23ACFD75009E2FA6 /* ReservationsAroundResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReservationsAroundResolver.swift; sourceTree = "<group>"; };
229+ 12B3A7BD23AD0048009E2FA6 /* AdminReservationEditingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminReservationEditingViewController.swift; sourceTree = "<group>"; };
230+ 12B3A7BF23AD0749009E2FA6 /* AdminReservationEditingCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminReservationEditingCoordinator.swift; sourceTree = "<group>"; };
231+ 12B3A7C323AD2FCD009E2FA6 /* AChangeReservationResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AChangeReservationResolver.swift; sourceTree = "<group>"; };
224232 12B4447B238EF25C000B6B16 /* CreateReservationResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateReservationResolver.swift; sourceTree = "<group>"; };
225233 12B6A60E235B857A00898B31 /* ProfileChangeCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileChangeCoordinator.swift; sourceTree = "<group>"; };
226234 12B6A610235B8EC500898B31 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
@@ -455,10 +463,9 @@
455463 isa = PBXGroup;
456464 children = (
457465 12B3A79623ABAD9A009E2FA6 /* Views */,
458− 12B3A7A623ABDD92009E2FA6 /* Cell */,
459− 12B3A7A223ABD594009E2FA6 /* AdminReservationsController.swift */,
466+ 12B3A7C123AD0751009E2FA6 /* Editing */,
467+ 12B3A7C223AD0762009E2FA6 /* List of reservations */,
460468 123D25EF239E3E11002FA32B /* AdminAddressCoordinator.swift */,
461− 12B3A7A423ABDA25009E2FA6 /* AdminReservationsCoordinator.swift */,
462469 12B3A7A923ABDDC1009E2FA6 /* AdminReservations.storyboard */,
463470 );
464471 path = Reservations;
@@ -519,6 +526,7 @@
519526 12B4447B238EF25C000B6B16 /* CreateReservationResolver.swift */,
520527 1212048B23914CFD00CAF162 /* DeleteReservationResolver.swift */,
521528 1212048D23915A0A00CAF162 /* ChangeReservationResolver.swift */,
529+ 12B3A7BB23ACFD75009E2FA6 /* ReservationsAroundResolver.swift */,
522530 );
523531 path = Resolvers;
524532 sourceTree = "<group>";
@@ -581,6 +589,7 @@
581589 isa = PBXGroup;
582590 children = (
583591 12B3A7AC23ABEABF009E2FA6 /* AReservationsResolver.swift */,
592+ 12B3A7C323AD2FCD009E2FA6 /* AChangeReservationResolver.swift */,
584593 );
585594 path = Admin;
586595 sourceTree = "<group>";
@@ -611,6 +620,25 @@
611620 path = Resolvers;
612621 sourceTree = "<group>";
613622 };
623+ 12B3A7C123AD0751009E2FA6 /* Editing */ = {
624+ isa = PBXGroup;
625+ children = (
626+ 12B3A7BF23AD0749009E2FA6 /* AdminReservationEditingCoordinator.swift */,
627+ 12B3A7BD23AD0048009E2FA6 /* AdminReservationEditingViewController.swift */,
628+ );
629+ name = Editing;
630+ sourceTree = "<group>";
631+ };
632+ 12B3A7C223AD0762009E2FA6 /* List of reservations */ = {
633+ isa = PBXGroup;
634+ children = (
635+ 12B3A7A623ABDD92009E2FA6 /* Cell */,
636+ 12B3A7A223ABD594009E2FA6 /* AdminReservationsController.swift */,
637+ 12B3A7A423ABDA25009E2FA6 /* AdminReservationsCoordinator.swift */,
638+ );
639+ path = "List of reservations";
640+ sourceTree = "<group>";
641+ };
614642 12BD95AE237EBE52009614D8 /* Maps */ = {
615643 isa = PBXGroup;
616644 children = (
@@ -1140,6 +1168,7 @@
11401168 12838EB82367834900CEF108 /* MyCodable.swift in Sources */,
11411169 F3DC5A05233E89D500B5E751 /* Button.swift in Sources */,
11421170 F3FC7DFB2315C25D0080D851 /* ApplicationCoordinator.swift in Sources */,
1171+ 12B3A7BE23AD0049009E2FA6 /* AdminReservationEditingViewController.swift in Sources */,
11431172 12BE4B352399A60A00FC974B /* AdminTabbarController.swift in Sources */,
11441173 12FC403A2382CB6F00AB593B /* TableButton.swift in Sources */,
11451174 12EB698123661CB300E4D1CE /* AddressCell.swift in Sources */,
@@ -1179,8 +1208,11 @@
11791208 F3895F53233D5EEB00FA6A37 /* BlackButtonStyle.swift in Sources */,
11801209 12F9652C23868E7200FCA696 /* SecondStepView.swift in Sources */,
11811210 120BFC7923891942001EBE89 /* ThirdStepReservationCoordinator.swift in Sources */,
1211+ 12B3A7BC23ACFD75009E2FA6 /* ReservationsAroundResolver.swift in Sources */,
11821212 12118B9C23682022006BAEE3 /* RegistrationResolver.swift in Sources */,
1213+ 12B3A7C423AD2FCD009E2FA6 /* AChangeReservationResolver.swift in Sources */,
11831214 F30369C02336925800A8EA84 /* ClientTabbarController.swift in Sources */,
1215+ 12B3A7C023AD0749009E2FA6 /* AdminReservationEditingCoordinator.swift in Sources */,
11841216 F31E20C72348DDB900BEA215 /* Extensions+UIView.swift in Sources */,
11851217 F3851B302340A513009EE0B6 /* RegistationViewModel.swift in Sources */,
11861218 12B3A7AF23AC1872009E2FA6 /* AdminNoReservationsView.swift in Sources */,
Hookah Tau/API/Reservations api/ReservationsService.swift+31−1
@@ -60,14 +60,20 @@ class ReservationsService {
6060 numberOfGuests: Int,
6161 endTime: Date,
6262 uuid: String,
63+ isAdmin: Bool,
6364 completion: @escaping ((Bool) -> Void)) {
6465
6566 let reservation = ChangeReservationResolver.Request(startTime: startTime,
6667 uuid: uuid,
6768 numberOfGuests: numberOfGuests,
6869 endTime: endTime)
70+ var resolver: ApiResolver!
71+ if isAdmin {
72+ resolver = AChangeReservationResolver(data: reservation)
73+ } else {
74+ resolver = ChangeReservationResolver(data: reservation)
75+ }
6976
70− let resolver = ChangeReservationResolver(data: reservation)
7177 let request = ApiRequest(resolver: resolver, httpMethod: .put)
7278
7379 apiClient.load(request: request.request) { result in
@@ -169,4 +175,28 @@ class ReservationsService {
169175 }
170176 }
171177 }
178+
179+ func getReservationsAround(uuid: String, completion: @escaping((Result<[ReservationPeriod], GeneralError>) -> Void)) {
180+ let resolver = ReservationsAroundResolver<ReservationsAroundResponse>(reservationId: uuid)
181+ let request = ApiRequest(resolver: resolver, httpMethod: .get)
182+
183+ apiClient.load(request: request.request) { (res) in
184+ switch res {
185+ case .failure(let err):
186+ completion(.failure(err))
187+ return
188+ case .success(let response):
189+ guard
190+ let d = response.data,
191+ let decodedData = resolver.targetClass().fromJSONToSelf(data: d)
192+ else {
193+ completion(.failure(GeneralError.decodeError))
194+ return
195+ }
196+
197+ completion(.success(decodedData.reservations))
198+ return
199+ }
200+ }
201+ }
172202}
Hookah Tau/API/Reservations api/Resolvers/Admin/AChangeReservationResolver.swiftnew file+34
@@ -0,0 +1,34 @@
1+//
2+// AChangeReservationResolver.swift
3+// Hookah Tau
4+//
5+// Created by cstore on 20/12/2019.
6+// Copyright © 2019 Daria Rednikina. All rights reserved.
7+//
8+
9+import Foundation
10+
11+
12+/// `PUT /admin/reservations`
13+
14+class AChangeReservationResolver: ApiResolver {
15+
16+ var name: String {
17+ return "/reservations"
18+ }
19+
20+ var groupName: String? {
21+ return "/admin"
22+ }
23+
24+ var data: ChangeReservationResolver.Request
25+
26+ init(data: ChangeReservationResolver.Request) {
27+ self.data = data
28+ }
29+
30+ func parameters() -> MyCodable? {
31+ return data
32+ }
33+}
34+
Hookah Tau/API/Reservations api/Resolvers/ReservationsAroundResolver.swiftnew file+35
@@ -0,0 +1,35 @@
1+//
2+// ReservationsAroundResolver.swift
3+// Hookah Tau
4+//
5+// Created by cstore on 20/12/2019.
6+// Copyright © 2019 Daria Rednikina. All rights reserved.
7+//
8+
9+import Foundation
10+
11+struct ReservationsAroundResponse: MyCodable {
12+ var reservations: [ReservationPeriod]
13+}
14+
15+/// ` GET /reservations/around/{reservation id}`
16+class ReservationsAroundResolver<Response: MyCodable>: ApiResolver {
17+
18+ var groupName: String? {
19+ return "/reservations"
20+ }
21+
22+ var name: String {
23+ return "/around/\(reservationId)"
24+ }
25+
26+ var reservationId: String
27+
28+ init(reservationId: String) {
29+ self.reservationId = reservationId
30+ }
31+
32+ func targetClass() -> Response.Type {
33+ return Response.self
34+ }
35+}
Hookah Tau/Controllers/Admin/Clients/Profile/ProfileTableViewController.swift+1−1
@@ -25,7 +25,7 @@ class ProfileTableViewController: UITableViewController {
2525 @IBOutlet weak var copyButton: Button! {
2626 didSet {
2727 let style = BlackButtonStyle()
28− style.apply(to: copyButton, withTitle: "скопировать")
28+ style.apply(to: copyButton, withTitle: "СКОПИРОВАТЬ")
2929 }
3030 }
3131
Hookah Tau/Controllers/Admin/Reservations/AdminAddressCoordinator.swift+1
@@ -21,6 +21,7 @@ class AdminAddressCoordinator: BaseCoordinator {
2121
2222 private func openReservations(forEstablishment id: Int) {
2323 let reservationsCoordinator = AdminReservationsCoordinator(navigationController: navigationController)
24+ addDependency(reservationsCoordinator)
2425 reservationsCoordinator.establishmentId = id
2526 reservationsCoordinator.start()
2627 }
Hookah Tau/Controllers/Admin/Reservations/AdminReservationEditingCoordinator.swiftnew file+29
@@ -0,0 +1,29 @@
1+//
2+// AdminReservationEditingCoordinator.swift
3+// Hookah Tau
4+//
5+// Created by cstore on 20/12/2019.
6+// Copyright © 2019 Daria Rednikina. All rights reserved.
7+//
8+
9+import UIKit
10+
11+
12+class AdminReservationEditingCoordinator: BaseCoordinator {
13+
14+ // MARK: - Peoperties
15+
16+ var reservationData: ReservationWithUser?
17+
18+ // MARK: - Lifecycle
19+
20+ override func start() {
21+ let storyboard = UIStoryboard(name: "AdminReservations", bundle: nil)
22+ let vc = storyboard.instantiateViewController(withIdentifier: "AdminReservationEditingViewController") as! AdminReservationEditingViewController
23+ vc.reservationData = reservationData
24+ vc.coordinator = self
25+
26+ navigationController?.pushViewController(vc, animated: true)
27+ }
28+
29+}
Hookah Tau/Controllers/Admin/Reservations/AdminReservationEditingViewController.swiftnew file+139
@@ -0,0 +1,139 @@
1+//
2+// AdminReservationEditingViewController.swift
3+// Hookah Tau
4+//
5+// Created by cstore on 20/12/2019.
6+// Copyright © 2019 Daria Rednikina. All rights reserved.
7+//
8+
9+import UIKit
10+
11+class AdminReservationEditingViewController: BaseViewController {
12+
13+ // MARK:- IBAOutlets
14+
15+ @IBOutlet weak var tableContentView: UIView!
16+
17+ @IBOutlet weak var mainContentView: UIView!
18+
19+ // MARK:- Properties
20+
21+ var mapView: MapImageScroll?
22+
23+ var reservationView: AdminReservationView?
24+
25+ var reservationData: ReservationWithUser?
26+
27+ weak var coordinator: AdminReservationEditingCoordinator?
28+
29+ var reservationService: ReservationsService?
30+
31+ var reservedPeriods: [ReservationPeriod] = [] {
32+ didSet {
33+ setupReservationViewWithIntervals()
34+ }
35+ }
36+
37+ var saveButton: Button = {
38+ let button = Button()
39+ let style = BlackButtonStyle()
40+ style.apply(to: button, withTitle: "СОХРАНИТЬ")
41+ return button
42+ }()
43+
44+ // MARK:- Lifecycle
45+
46+ override func viewDidLoad() {
47+ super.viewDidLoad()
48+
49+ setupContentViews()
50+
51+ reservationService = ReservationsService(apiClient: APIClient.shared)
52+
53+ loadReservedPeriods()
54+
55+ setupButtons()
56+ }
57+
58+ override func viewWillAppear(_ animated: Bool) {
59+ super.viewWillAppear(animated)
60+
61+ tabBarController?.tabBar.isHidden = true
62+ }
63+
64+ // MARK: - Setup
65+
66+ func setupButtons() {
67+ addStackViewWithButtons(rightBtn: saveButton,
68+ constant: -mainContentView.frame.height - 10)
69+
70+ saveButton.addTarget(self, action: #selector(saveReservation), for: .touchUpInside)
71+ }
72+
73+ func setupContentViews() {
74+ guard
75+ let model = reservationData
76+ else { return }
77+
78+ if model.establishment == 1 {
79+ mapView = MapView1.loadFromNib()
80+ } else {
81+ mapView = MapView2.loadFromNib()
82+ }
83+
84+ mapView?.isUserInteractionEnabled = false
85+
86+ tableContentView.addSubviewThatFills(mapView)
87+ mapView?.scrollToTable(table: model.reservedTable)
88+
89+ reservationView = AdminReservationView.loadFromNib()
90+ reservationView?.bind(withModel: model)
91+
92+ mainContentView.addSubviewThatFills(reservationView)
93+ }
94+
95+ func setupReservationViewWithIntervals() {
96+ reservationView?.bind(withIntervals: reservedPeriods)
97+ }
98+
99+ func loadReservedPeriods() {
100+ guard let model = reservationData else { return }
101+
102+ reservationService?.getReservationsAround(uuid: model.uuid, completion: { [weak self] (res) in
103+ switch res {
104+ case .failure(let err):
105+ self?.displayAlert(forError: err)
106+ return
107+ case .success(let reserv):
108+ self?.reservedPeriods = reserv
109+ return
110+ }
111+ })
112+ }
113+
114+ // MARK:- Handlers
115+
116+ @objc func saveReservation() {
117+ guard
118+ let r = reservationView?.data,
119+ let uuid = reservationData?.uuid
120+ else { return }
121+
122+ saveButton.loading = true
123+
124+ reservationService?.updateReservation(startTime: r.startTime,
125+ numberOfGuests: r.numberOfGuests,
126+ endTime: r.endTime,
127+ uuid: uuid,
128+ isAdmin: true,
129+ completion: { [weak self] (res) in
130+ if res {
131+ self?.coordinator?.didEndFlow?()
132+ } else {
133+ self?.displayAlert(with: "Что-то пошло не так! Попробуешь еще раз?")
134+ }
135+
136+ self?.saveButton.loading = false
137+ })
138+ }
139+}
Hookah Tau/Controllers/Admin/Reservations/AdminReservations.storyboard+41
@@ -23,5 +23,46 @@
2323 </objects>
2424 <point key="canvasLocation" x="111" y="159"/>
2525 </scene>
26+ <!--Admin Reservation Editing View Controller-->
27+ <scene sceneID="hWe-Nm-jBL">
28+ <objects>
29+ <viewController storyboardIdentifier="AdminReservationEditingViewController" id="BgQ-ca-cuZ" customClass="AdminReservationEditingViewController" customModule="Hookah_Tau" customModuleProvider="target" sceneMemberID="viewController">
30+ <view key="view" contentMode="scaleToFill" id="tjV-EU-XvW">
31+ <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
32+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
33+ <subviews>
34+ <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uNU-TW-vfq">
35+ <rect key="frame" x="0.0" y="206" width="375" height="441"/>
36+ <color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
37+ <constraints>
38+ <constraint firstAttribute="height" constant="441" id="wfZ-i9-ruU"/>
39+ </constraints>
40+ </view>
41+ <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ghQ-Jv-1Uo">
42+ <rect key="frame" x="0.0" y="0.0" width="375" height="198"/>
43+ <color key="backgroundColor" systemColor="systemGreenColor" red="0.20392156859999999" green="0.78039215689999997" blue="0.34901960780000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
44+ </view>
45+ </subviews>
46+ <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
47+ <constraints>
48+ <constraint firstItem="ghQ-Jv-1Uo" firstAttribute="leading" secondItem="qeh-vb-wIH" secondAttribute="leading" id="6ue-fN-8T9"/>
49+ <constraint firstAttribute="bottom" secondItem="uNU-TW-vfq" secondAttribute="bottom" constant="20" symbolic="YES" id="CEP-Ac-DSe"/>
50+ <constraint firstItem="uNU-TW-vfq" firstAttribute="leading" secondItem="qeh-vb-wIH" secondAttribute="leading" id="Ff2-mz-GAH"/>
51+ <constraint firstItem="ghQ-Jv-1Uo" firstAttribute="top" secondItem="qeh-vb-wIH" secondAttribute="top" id="MMC-Og-ggL"/>
52+ <constraint firstItem="uNU-TW-vfq" firstAttribute="trailing" secondItem="qeh-vb-wIH" secondAttribute="trailing" id="fRe-ZZ-rez"/>
53+ <constraint firstItem="ghQ-Jv-1Uo" firstAttribute="trailing" secondItem="qeh-vb-wIH" secondAttribute="trailing" id="hPh-8O-if8"/>
54+ <constraint firstItem="uNU-TW-vfq" firstAttribute="top" secondItem="ghQ-Jv-1Uo" secondAttribute="bottom" constant="8" symbolic="YES" id="rDO-oM-rwy"/>
55+ </constraints>
56+ <viewLayoutGuide key="safeArea" id="qeh-vb-wIH"/>
57+ </view>
58+ <connections>
59+ <outlet property="mainContentView" destination="uNU-TW-vfq" id="Fy6-pC-ach"/>
60+ <outlet property="tableContentView" destination="ghQ-Jv-1Uo" id="GN2-MW-a2J"/>
61+ </connections>
62+ </viewController>
63+ <placeholder placeholderIdentifier="IBFirstResponder" id="LNT-df-eny" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
64+ </objects>
65+ <point key="canvasLocation" x="959.20000000000005" y="158.77061469265368"/>
66+ </scene>
2667 </scenes>
2768</document>
Hookah Tau/Controllers/Admin/Reservations/AdminReservationsController.swift → Hookah Tau/Controllers/Admin/Reservations/List of reservations/AdminReservationsController.swiftrenamed+22−13
@@ -31,6 +31,8 @@ class AdminReservationsController: BaseViewController {
3131
3232 var reservationsService: ReservationsService?
3333
34+ weak var coordinator: AdminReservationsCoordinator?
35+
3436 var activeReservations: [ReservationWithUser] = [] {
3537 didSet {
3638 guard let empty = noReservationsView else { return }
@@ -58,6 +60,7 @@ class AdminReservationsController: BaseViewController {
5860 super.viewDidAppear(animated)
5961
6062 performUpdate()
63+ tabBarController?.tabBar.isHidden = false
6164 }
6265
6366 // MARK:- Setup
@@ -119,18 +122,24 @@ class AdminReservationsController: BaseViewController {
119122
120123extension AdminReservationsController: UITableViewDelegate, UITableViewDataSource {
121124
122− func numberOfSections(in tableView: UITableView) -> Int {
123− return 1
124− }
125+ func numberOfSections(in tableView: UITableView) -> Int {
126+ return 1
127+ }
128+
129+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
130+ return activeReservations.count
131+ }
132+
133+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
134+ let cell = tableView.dequeueReusableCell(withIdentifier: adminReservationCellId, for: indexPath) as! AdminReservationCell
135+
136+ cell.bind(withModel: activeReservations[indexPath.row])
137+ return cell
138+ }
139+
140+ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
141+ let reservation = activeReservations[indexPath.row]
142+ coordinator?.seeExistingReservation(data: reservation)
143+ }
125144
126− func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
127− return activeReservations.count
128− }
129−
130− func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
131− let cell = tableView.dequeueReusableCell(withIdentifier: adminReservationCellId, for: indexPath) as! AdminReservationCell
132−
133− cell.bind(withModel: activeReservations[indexPath.row])
134− return cell
135− }
136145}
Hookah Tau/Controllers/Admin/Reservations/AdminReservationsCoordinator.swift → Hookah Tau/Controllers/Admin/Reservations/List of reservations/AdminReservationsCoordinator.swiftrenamed+16
@@ -10,13 +10,29 @@ import UIKit
1010
1111class AdminReservationsCoordinator: BaseCoordinator {
1212
13+ // MARK: - Properties
14+
1315 var establishmentId: Int?
1416
17+ // MARK: - Lifecycle
18+
1519 override func start() {
1620 let storyboard = UIStoryboard(name: "AdminReservations", bundle: nil)
1721 let vc = storyboard.instantiateViewController(withIdentifier: "AdminReservationsController") as! AdminReservationsController
1822 vc.id = establishmentId
23+ vc.coordinator = self
1924
2025 navigationController?.pushViewController(vc, animated: true)
2126 }
27+
28+ func seeExistingReservation(data: ReservationWithUser) {
29+ let reservationCoordinator = AdminReservationEditingCoordinator(navigationController: navigationController)
30+ addDependency(reservationCoordinator)
31+ reservationCoordinator.reservationData = data
32+ reservationCoordinator.didEndFlow = { [weak self] in
33+ self?.removeDependency(reservationCoordinator)
34+ self?.navigationController?.popViewController(animated: true)
35+ }
36+ reservationCoordinator.start()
37+ }
2238}
Hookah Tau/Controllers/Admin/Reservations/Cell/AdminReservationCellView.swift → Hookah Tau/Controllers/Admin/Reservations/List of reservations/Cell/AdminReservationCellView.swiftrenamed

The content is the same.

Hookah Tau/Controllers/Admin/Reservations/Cell/AdminReservationCellView.xib → Hookah Tau/Controllers/Admin/Reservations/List of reservations/Cell/AdminReservationCellView.xibrenamed+2−2
@@ -15,11 +15,11 @@
1515 <rect key="frame" x="0.0" y="0.0" width="414" height="136"/>
1616 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1717 <subviews>
18− <stackView opaque="NO" contentMode="scaleToFill" spacing="160" translatesAutoresizingMaskIntoConstraints="NO" id="au9-nK-XbR">
18+ <stackView opaque="NO" contentMode="scaleToFill" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="au9-nK-XbR">
1919 <rect key="frame" x="17" y="3" width="380" height="133"/>
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="102" height="133"/>
22+ <rect key="frame" x="0.0" y="0.0" width="254" height="133"/>
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"/>
Hookah Tau/Controllers/Admin/Reservations/Views/AdminReservationView.swift+24−8
@@ -21,18 +21,13 @@ class AdminReservationView: UIView {
2121 @IBOutlet weak var cancelButton: Button? {
2222 didSet {
2323 let style = BlackButtonStyle()
24− style.apply(to: cancelButton)
24+ style.apply(to: cancelButton, withTitle: "ОТМЕНИТЬ")
2525 }
2626 }
2727
2828 @IBOutlet weak var nameLabel: UILabel?
2929
30− @IBOutlet weak var callButton: Button? {
31− didSet {
32− let style = BlackButtonStyle()
33− style.apply(to: callButton)
34− }
35− }
30+ @IBOutlet weak var callButton: Button?
3631
3732 @IBOutlet weak var numberOfGuestLabel: UILabel?
3833
@@ -48,9 +43,30 @@ class AdminReservationView: UIView {
4843 /// Обновляем каждый раз когда меняется время и дата
4944 var data: ReservationData?
5045
46+ var model: ReservationWithUser?
47+
5148 // MARK: - Setup
5249
53− func bind(withModel model: ReservationData) {
50+ func bind(withModel model: ReservationWithUser) {
51+ let style = BlackButtonStyle()
52+ style.apply(to: callButton, withTitle: model.owner.phoneNumber.formattedNumber())
53+
54+
55+ let (date, time) = Date.format(model.startTime, model.endTime)
56+ dateLabel?.text = date
57+ timeLabel?.text = time
58+
59+ tableLabel?.text = "\(model.reservedTable) столик"
60+ nameLabel?.text = "\(model.owner.name ?? "❔")"
61+
62+ data = ReservationData(establishment: model.establishment,
63+ startTime: model.startTime,
64+ endTime: model.endTime,
65+ numberOfGuests: model.numberOfGuests,
66+ reservedTable: model.reservedTable)
67+ }
68+
69+ func bind(withIntervals intervals: [ReservationPeriod]) {
5470
5571 }
5672
Hookah Tau/Controllers/Admin/Reservations/Views/AdminReservationView.xib+27−17
@@ -5,7 +5,6 @@
55 <deployment identifier="iOS"/>
66 <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
77 <capability name="Safe area layout guides" minToolsVersion="9.0"/>
8− <capability name="Stack View standard spacing" minToolsVersion="9.0"/>
98 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
109 </dependencies>
1110 <objects>
@@ -16,16 +15,16 @@
1615 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1716 <subviews>
1817 <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" spacing="48" translatesAutoresizingMaskIntoConstraints="NO" id="AEf-R4-K1F">
19− <rect key="frame" x="21" y="21" width="372" height="399"/>
18+ <rect key="frame" x="21" y="16" width="372" height="404"/>
2019 <subviews>
21− <stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" alignment="top" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="oh7-ka-ctS">
22− <rect key="frame" x="0.0" y="0.0" width="372" height="138.5"/>
20+ <stackView opaque="NO" contentMode="scaleToFill" alignment="top" spacing="4" translatesAutoresizingMaskIntoConstraints="NO" id="oh7-ka-ctS">
21+ <rect key="frame" x="0.0" y="0.0" width="372" height="143.5"/>
2322 <subviews>
24− <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="22" translatesAutoresizingMaskIntoConstraints="NO" id="IY6-F4-aln">
25− <rect key="frame" x="0.0" y="0.0" width="109" height="136.5"/>
23+ <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="top" spacing="22" translatesAutoresizingMaskIntoConstraints="NO" id="IY6-F4-aln">
24+ <rect key="frame" x="0.0" y="0.0" width="129" height="136.5"/>
2625 <subviews>
2726 <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="top" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="hEV-kW-bBH">
28− <rect key="frame" x="0.0" y="0.0" width="109" height="77.5"/>
27+ <rect key="frame" x="0.0" y="0.0" width="129" height="77.5"/>
2928 <subviews>
3029 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="7 столик" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qNR-EO-oMK">
3130 <rect key="frame" x="0.0" y="0.0" width="93" height="26.5"/>
@@ -39,13 +38,17 @@
3938 <nil key="textColor"/>
4039 <nil key="highlightedColor"/>
4140 </label>
42− <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="3:00 — 5:00" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gau-aS-vtT">
43− <rect key="frame" x="0.0" y="57" width="102.5" height="20.5"/>
41+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="3:00 — 5:00ffff" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gau-aS-vtT">
42+ <rect key="frame" x="0.0" y="57" width="129" height="20.5"/>
4443 <fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
4544 <nil key="textColor"/>
4645 <nil key="highlightedColor"/>
4746 </label>
4847 </subviews>
48+ <constraints>
49+ <constraint firstAttribute="trailing" secondItem="gau-aS-vtT" secondAttribute="trailing" id="OYu-7e-8pX"/>
50+ <constraint firstItem="gau-aS-vtT" firstAttribute="leading" secondItem="hEV-kW-bBH" secondAttribute="leading" id="egK-i8-r2N"/>
51+ </constraints>
4952 </stackView>
5053 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="iiD-uf-IDp" customClass="Button" customModule="Hookah_Tau" customModuleProvider="target">
5154 <rect key="frame" x="0.0" y="99.5" width="109" height="37"/>
@@ -57,18 +60,23 @@
5760 <state key="normal" title="Button"/>
5861 </button>
5962 </subviews>
63+ <constraints>
64+ <constraint firstAttribute="trailing" secondItem="hEV-kW-bBH" secondAttribute="trailing" id="7MI-YT-uHi"/>
65+ <constraint firstAttribute="width" constant="129" id="BQh-sd-jbL"/>
66+ <constraint firstItem="hEV-kW-bBH" firstAttribute="leading" secondItem="IY6-F4-aln" secondAttribute="leading" id="tsb-PN-YGB"/>
67+ </constraints>
6068 </stackView>
6169 <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="bottom" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="59c-nG-5Fh">
62− <rect key="frame" x="198" y="0.0" width="174" height="71.5"/>
70+ <rect key="frame" x="133" y="0.0" width="239" height="71.5"/>
6371 <subviews>
6472 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Стасик" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OoG-F4-OVu">
65− <rect key="frame" x="95.5" y="0.0" width="78.5" height="26.5"/>
73+ <rect key="frame" x="160.5" y="0.0" width="78.5" height="26.5"/>
6674 <fontDescription key="fontDescription" type="boldSystem" pointSize="22"/>
6775 <nil key="textColor"/>
6876 <nil key="highlightedColor"/>
6977 </label>
7078 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Xkd-xQ-cFd" customClass="Button" customModule="Hookah_Tau" customModuleProvider="target">
71− <rect key="frame" x="0.0" y="34.5" width="174" height="37"/>
79+ <rect key="frame" x="65" y="34.5" width="174" height="37"/>
7280 <color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
7381 <constraints>
7482 <constraint firstAttribute="height" constant="37" id="7Wj-WF-xzD"/>
@@ -80,11 +88,11 @@
8088 </stackView>
8189 </subviews>
8290 </stackView>
83− <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="top" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="9RO-aK-yNh">
84− <rect key="frame" x="0.0" y="186.5" width="372" height="58.5"/>
91+ <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="9RO-aK-yNh">
92+ <rect key="frame" x="0.0" y="191.5" width="372" height="58.5"/>
8593 <subviews>
8694 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Количество гостей: 2" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yTM-U5-XjI">
87− <rect key="frame" x="0.0" y="0.0" width="181" height="20.5"/>
95+ <rect key="frame" x="0.0" y="0.0" width="372" height="20.5"/>
8896 <fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
8997 <nil key="textColor"/>
9098 <nil key="highlightedColor"/>
@@ -95,7 +103,7 @@
95103 </subviews>
96104 </stackView>
97105 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="vKS-ia-RxW">
98− <rect key="frame" x="0.0" y="293" width="372" height="106"/>
106+ <rect key="frame" x="0.0" y="298" width="372" height="106"/>
99107 <color key="backgroundColor" red="0.34509803919999998" green="0.33725490200000002" blue="0.83921568629999999" alpha="0.33104130993150682" colorSpace="custom" customColorSpace="sRGB"/>
100108 <constraints>
101109 <constraint firstAttribute="height" constant="106" id="ebp-l7-k9Z"/>
@@ -105,7 +113,9 @@
105113 <constraints>
106114 <constraint firstItem="vKS-ia-RxW" firstAttribute="leading" secondItem="AEf-R4-K1F" secondAttribute="leading" id="0cO-AV-PJL"/>
107115 <constraint firstAttribute="trailing" secondItem="oh7-ka-ctS" secondAttribute="trailing" id="KeE-6F-h5x"/>
116+ <constraint firstAttribute="trailing" secondItem="9RO-aK-yNh" secondAttribute="trailing" id="Kh6-4l-QJO"/>
108117 <constraint firstAttribute="bottom" secondItem="vKS-ia-RxW" secondAttribute="bottom" id="TKW-xo-b61"/>
118+ <constraint firstItem="9RO-aK-yNh" firstAttribute="leading" secondItem="AEf-R4-K1F" secondAttribute="leading" id="Teg-kp-nZt"/>
109119 <constraint firstItem="oh7-ka-ctS" firstAttribute="leading" secondItem="AEf-R4-K1F" secondAttribute="leading" id="mJ2-gh-vCg"/>
110120 <constraint firstAttribute="trailing" secondItem="vKS-ia-RxW" secondAttribute="trailing" id="uDV-uM-jby"/>
111121 </constraints>
@@ -116,7 +126,7 @@
116126 <constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="AEf-R4-K1F" secondAttribute="bottom" constant="21" id="4MN-Yl-hYv"/>
117127 <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="AEf-R4-K1F" secondAttribute="trailing" constant="21" id="C1h-bA-S6p"/>
118128 <constraint firstItem="AEf-R4-K1F" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="21" id="H1o-ua-Tnn"/>
119− <constraint firstItem="vUN-kp-3ea" firstAttribute="top" secondItem="AEf-R4-K1F" secondAttribute="top" constant="-21" id="eYI-is-YLt"/>
129+ <constraint firstItem="vUN-kp-3ea" firstAttribute="top" secondItem="AEf-R4-K1F" secondAttribute="top" constant="-16" id="eYI-is-YLt"/>
120130 </constraints>
121131 <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
122132 <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
Hookah Tau/Controllers/Client/Reservations/Maps/MapView.swift+1
@@ -33,6 +33,7 @@ class MapImageScroll: UIView {
3333 shadowView.alpha = 1
3434
3535 scrollViewParent.zoom(to: tableButton.frame, animated: true)
36+ scrollViewParent.contentOffset = CGPoint(x: scrollViewParent.contentOffset.x, y: scrollViewParent.contentOffset.y + 100)
3637 scrollViewParent.setZoomScale(zoomScale, animated: true)
3738 }
3839
Hookah Tau/Controllers/Client/Reservations/Steps/change /ChangeReservationViewController.swift+1
@@ -137,6 +137,7 @@ class ChangeReservationViewController: BaseViewController {
137137 numberOfGuests: r.numberOfGuests,
138138 endTime: r.endTime,
139139 uuid: uuid,
140+ isAdmin: false,
140141 completion: { [weak self] (res) in
141142 if res {
142143 self?.coordinator?.finish(Reservation(uuid: uuid, reservationData: r))