git.iko.soy/dashared/hookah-tau
on develop help sign in
Перефигачила экран бронирований для админа

добавила noReservations view

commit87fcf7eb4c8813e6c354fbe743ccf743d3faeb9d authorDarya Rednikina <rednikina.com@yandex.ru> dateFri 20 Dec 2019, 00:51 (7 years ago) parentca49517
8 files changed+314−119
Hookah Tau.xcodeproj/project.pbxproj+24−4 Hookah Tau/API/Reservations api/Resolvers/Admin/AReservationsResolver.swift+2−2 Hookah Tau/Controllers/Admin/Reservations/AdminReservations.storyboard+9−92 Hookah Tau/Controllers/Admin/Reservations/AdminReservationsController.swift+80−21 Hookah Tau/Controllers/Admin/Reservations/Cell/AdminReservationCell.swift → Hookah Tau/Controllers/Admin/Reservations/Cell/AdminReservationCellView.swift+31 Hookah Tau/Controllers/Admin/Reservations/Cell/AdminReservationCellView.xib+93 Hookah Tau/Controllers/Admin/Reservations/Views/No reserv/AdminNoReservationsView.swift+22 Hookah Tau/Controllers/Admin/Reservations/Views/No reserv/AdminNoReservationsView.xib+53
Hookah Tau.xcodeproj/project.pbxproj+24−4
@@ -63,9 +63,12 @@
6363 12B3A79F23ABCA21009E2FA6 /* AdminReservationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A79E23ABCA21009E2FA6 /* AdminReservationView.swift */; };
6464 12B3A7A323ABD594009E2FA6 /* AdminReservationsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7A223ABD594009E2FA6 /* AdminReservationsController.swift */; };
6565 12B3A7A523ABDA25009E2FA6 /* AdminReservationsCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7A423ABDA25009E2FA6 /* AdminReservationsCoordinator.swift */; };
66− 12B3A7A823ABDDB1009E2FA6 /* AdminReservationCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7A723ABDDB1009E2FA6 /* AdminReservationCell.swift */; };
66+ 12B3A7A823ABDDB1009E2FA6 /* AdminReservationCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7A723ABDDB1009E2FA6 /* AdminReservationCellView.swift */; };
6767 12B3A7AA23ABDDC1009E2FA6 /* AdminReservations.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 12B3A7A923ABDDC1009E2FA6 /* AdminReservations.storyboard */; };
6868 12B3A7AD23ABEABF009E2FA6 /* AReservationsResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7AC23ABEABF009E2FA6 /* AReservationsResolver.swift */; };
69+ 12B3A7AF23AC1872009E2FA6 /* AdminNoReservationsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7AE23AC1872009E2FA6 /* AdminNoReservationsView.swift */; };
70+ 12B3A7B123AC1885009E2FA6 /* AdminNoReservationsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 12B3A7B023AC1885009E2FA6 /* AdminNoReservationsView.xib */; };
71+ 12B3A7B423AC1D09009E2FA6 /* AdminReservationCellView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 12B3A7B323AC1D09009E2FA6 /* AdminReservationCellView.xib */; };
6972 12B4447C238EF25C000B6B16 /* CreateReservationResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B4447B238EF25C000B6B16 /* CreateReservationResolver.swift */; };
7073 12B6A60F235B857A00898B31 /* ProfileChangeCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B6A60E235B857A00898B31 /* ProfileChangeCoordinator.swift */; };
7174 12B6A611235B8EC500898B31 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B6A610235B8EC500898B31 /* User.swift */; };
@@ -208,9 +211,12 @@
208211 12B3A79E23ABCA21009E2FA6 /* AdminReservationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminReservationView.swift; sourceTree = "<group>"; };
209212 12B3A7A223ABD594009E2FA6 /* AdminReservationsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminReservationsController.swift; sourceTree = "<group>"; };
210213 12B3A7A423ABDA25009E2FA6 /* AdminReservationsCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminReservationsCoordinator.swift; sourceTree = "<group>"; };
211− 12B3A7A723ABDDB1009E2FA6 /* AdminReservationCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminReservationCell.swift; sourceTree = "<group>"; };
214+ 12B3A7A723ABDDB1009E2FA6 /* AdminReservationCellView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminReservationCellView.swift; sourceTree = "<group>"; };
212215 12B3A7A923ABDDC1009E2FA6 /* AdminReservations.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = AdminReservations.storyboard; sourceTree = "<group>"; };
213216 12B3A7AC23ABEABF009E2FA6 /* AReservationsResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AReservationsResolver.swift; sourceTree = "<group>"; };
217+ 12B3A7AE23AC1872009E2FA6 /* AdminNoReservationsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminNoReservationsView.swift; sourceTree = "<group>"; };
218+ 12B3A7B023AC1885009E2FA6 /* AdminNoReservationsView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AdminNoReservationsView.xib; sourceTree = "<group>"; };
219+ 12B3A7B323AC1D09009E2FA6 /* AdminReservationCellView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AdminReservationCellView.xib; sourceTree = "<group>"; };
214220 12B4447B238EF25C000B6B16 /* CreateReservationResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateReservationResolver.swift; sourceTree = "<group>"; };
215221 12B6A60E235B857A00898B31 /* ProfileChangeCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileChangeCoordinator.swift; sourceTree = "<group>"; };
216222 12B6A610235B8EC500898B31 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
@@ -541,6 +547,7 @@
541547 12B3A79623ABAD9A009E2FA6 /* Views */ = {
542548 isa = PBXGroup;
543549 children = (
550+ 12B3A7B223AC1A1F009E2FA6 /* No reserv */,
544551 12B3A79723ABADB9009E2FA6 /* AdminReservationView.xib */,
545552 12B3A79E23ABCA21009E2FA6 /* AdminReservationView.swift */,
546553 );
@@ -559,7 +566,8 @@
559566 12B3A7A623ABDD92009E2FA6 /* Cell */ = {
560567 isa = PBXGroup;
561568 children = (
562− 12B3A7A723ABDDB1009E2FA6 /* AdminReservationCell.swift */,
569+ 12B3A7A723ABDDB1009E2FA6 /* AdminReservationCellView.swift */,
570+ 12B3A7B323AC1D09009E2FA6 /* AdminReservationCellView.xib */,
563571 );
564572 path = Cell;
565573 sourceTree = "<group>";
@@ -572,6 +580,15 @@
572580 path = Admin;
573581 sourceTree = "<group>";
574582 };
583+ 12B3A7B223AC1A1F009E2FA6 /* No reserv */ = {
584+ isa = PBXGroup;
585+ children = (
586+ 12B3A7AE23AC1872009E2FA6 /* AdminNoReservationsView.swift */,
587+ 12B3A7B023AC1885009E2FA6 /* AdminNoReservationsView.xib */,
588+ );
589+ path = "No reserv";
590+ sourceTree = "<group>";
591+ };
575592 12BD95AE237EBE52009614D8 /* Maps */ = {
576593 isa = PBXGroup;
577594 children = (
@@ -1025,6 +1042,7 @@
10251042 files = (
10261043 F3199E5B233FE08200F3C17A /* PhoneView.xib in Resources */,
10271044 12B3A7AA23ABDDC1009E2FA6 /* AdminReservations.storyboard in Resources */,
1045+ 12B3A7B423AC1D09009E2FA6 /* AdminReservationCellView.xib in Resources */,
10281046 12C0B4BB239E5A3A00562BA3 /* ClientList.storyboard in Resources */,
10291047 12BE4B372399A98200FC974B /* Admin.storyboard in Resources */,
10301048 12DBEEB223539F2100AF1BB6 /* Client.storyboard in Resources */,
@@ -1043,6 +1061,7 @@
10431061 12BD95B0237EBEDF009614D8 /* FirstStepView.xib in Resources */,
10441062 F30369B5233679EA00A8EA84 /* LaunchScreen.storyboard in Resources */,
10451063 1246B717235CD186004CBFA1 /* NoReservationsView.xib in Resources */,
1064+ 12B3A7B123AC1885009E2FA6 /* AdminNoReservationsView.xib in Resources */,
10461065 12B3A79823ABADB9009E2FA6 /* AdminReservationView.xib in Resources */,
10471066 F3FC7DD42315BE630080D851 /* Assets.xcassets in Resources */,
10481067 12EA994C2362F8EF005D9FE9 /* AddressView.xib in Resources */,
@@ -1088,7 +1107,7 @@
10881107 12B6A613235B9B4300898B31 /* BaseViewController.swift in Sources */,
10891108 12BE4B332399A52E00FC974B /* AdminTabbarCoordinator.swift in Sources */,
10901109 12230AFA23901029004A01E5 /* DataStorage.swift in Sources */,
1091− 12B3A7A823ABDDB1009E2FA6 /* AdminReservationCell.swift in Sources */,
1110+ 12B3A7A823ABDDB1009E2FA6 /* AdminReservationCellView.swift in Sources */,
10921111 F3FC7DFF2315C8D70080D851 /* NameCoordinator.swift in Sources */,
10931112 123D25F7239E5839002FA32B /* ClientTableViewCell.swift in Sources */,
10941113 120BFC7C23891965001EBE89 /* ThirdStepView.swift in Sources */,
@@ -1141,6 +1160,7 @@
11411160 F30369C02336925800A8EA84 /* ClientTabbarController.swift in Sources */,
11421161 F31E20C72348DDB900BEA215 /* Extensions+UIView.swift in Sources */,
11431162 F3851B302340A513009EE0B6 /* RegistationViewModel.swift in Sources */,
1163+ 12B3A7AF23AC1872009E2FA6 /* AdminNoReservationsView.swift in Sources */,
11441164 12838EAE2367701300CEF108 /* AuthorizationService.swift in Sources */,
11451165 12C72EDF23537D1B00AD7004 /* ProfileCoordinator.swift in Sources */,
11461166 12E3507D239FD1F3004BB188 /* ClientReservationsResolver.swift in Sources */,
Hookah Tau/API/Reservations api/Resolvers/Admin/AReservationsResolver.swift+2−2
@@ -16,11 +16,11 @@ struct AReservationResponse: MyCodable {
1616class AReservationsResolver<Response: MyCodable>: ApiResolver {
1717
1818 var name: String {
19− return "/admin"
19+ return "/reservations/\(establishmentId)"
2020 }
2121
2222 var groupName: String? {
23− return "/reservations/\(establishmentId)"
23+ return "/admin"
2424 }
2525
2626 var establishmentId: Int
Hookah Tau/Controllers/Admin/Reservations/AdminReservations.storyboard+9−92
@@ -4,107 +4,24 @@
44 <dependencies>
55 <deployment identifier="iOS"/>
66 <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
7− <capability name="Stack View standard spacing" minToolsVersion="9.0"/>
7+ <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>
1111 <!--Admin Reservations Controller-->
12− <scene sceneID="Sf2-Df-Xlc">
12+ <scene sceneID="3G1-PQ-PoW">
1313 <objects>
14− <tableViewController storyboardIdentifier="AdminReservationsController" id="YIa-Ku-gIA" customClass="AdminReservationsController" customModule="Hookah_Tau" customModuleProvider="target" sceneMemberID="viewController">
15− <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="3Gt-v4-mQR">
14+ <viewController storyboardIdentifier="AdminReservationsController" id="Imn-L1-YIQ" customClass="AdminReservationsController" customModule="Hookah_Tau" customModuleProvider="target" sceneMemberID="viewController">
15+ <view key="view" contentMode="scaleToFill" id="DoI-oD-1Zy">
1616 <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
1717 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1818 <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
19− <prototypes>
20− <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="AdminReservationCell" rowHeight="136" id="AYd-eR-46K" customClass="AdminReservationCell" customModule="Hookah_Tau" customModuleProvider="target">
21− <rect key="frame" x="0.0" y="28" width="375" height="136"/>
22− <autoresizingMask key="autoresizingMask"/>
23− <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="AYd-eR-46K" id="mrQ-aD-CgR">
24− <rect key="frame" x="0.0" y="0.0" width="375" height="136"/>
25− <autoresizingMask key="autoresizingMask"/>
26− <subviews>
27− <stackView opaque="NO" contentMode="scaleToFill" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="blr-ad-ozM">
28− <rect key="frame" x="16" y="8" width="343" height="120"/>
29− <subviews>
30− <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" alignment="top" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="mCl-Of-iIS">
31− <rect key="frame" x="0.0" y="0.0" width="217" height="120"/>
32− <subviews>
33− <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Стасик" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5ef-FS-6NW">
34− <rect key="frame" x="0.0" y="0.0" width="54" height="19.5"/>
35− <fontDescription key="fontDescription" type="system" pointSize="16"/>
36− <color key="textColor" red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="calibratedRGB"/>
37− <nil key="highlightedColor"/>
38− </label>
39− <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="top" spacing="4" translatesAutoresizingMaskIntoConstraints="NO" id="Ob1-jK-UaO">
40− <rect key="frame" x="0.0" y="37" width="102" height="45"/>
41− <subviews>
42− <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="JHC-xy-xNO">
43− <rect key="frame" x="0.0" y="0.0" width="76.5" height="20.5"/>
44− <fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
45− <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
46− <nil key="highlightedColor"/>
47− </label>
48− <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="3:00 — 5:30" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Xii-MO-mz4">
49− <rect key="frame" x="0.0" y="24.5" width="102" height="20.5"/>
50− <fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
51− <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
52− <nil key="highlightedColor"/>
53− </label>
54− </subviews>
55− </stackView>
56− <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="3 человека" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FRo-NH-yGn">
57− <rect key="frame" x="0.0" y="99.5" width="89" height="20.5"/>
58− <fontDescription key="fontDescription" type="system" pointSize="17"/>
59− <nil key="textColor"/>
60− <nil key="highlightedColor"/>
61− </label>
62− </subviews>
63− </stackView>
64− <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="1_7" translatesAutoresizingMaskIntoConstraints="NO" id="7TJ-je-a9o">
65− <rect key="frame" x="225" y="0.0" width="118" height="120"/>
66− </imageView>
67− </subviews>
68− </stackView>
69− <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="rfg-EE-4qb">
70− <rect key="frame" x="0.0" y="135" width="375" height="1"/>
71− <color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
72− <constraints>
73− <constraint firstAttribute="height" constant="1" id="HpV-dD-Uq9"/>
74− </constraints>
75− </view>
76− </subviews>
77− <constraints>
78− <constraint firstItem="blr-ad-ozM" firstAttribute="leading" secondItem="mrQ-aD-CgR" secondAttribute="leading" constant="16" id="DrG-Z0-r00"/>
79− <constraint firstItem="blr-ad-ozM" firstAttribute="top" secondItem="mrQ-aD-CgR" secondAttribute="top" constant="8" id="Quo-kM-c9W"/>
80− <constraint firstAttribute="trailing" secondItem="rfg-EE-4qb" secondAttribute="trailing" id="ecB-z2-075"/>
81− <constraint firstAttribute="trailing" secondItem="blr-ad-ozM" secondAttribute="trailing" constant="16" id="fUB-Zd-k0b"/>
82− <constraint firstItem="rfg-EE-4qb" firstAttribute="leading" secondItem="mrQ-aD-CgR" secondAttribute="leading" id="ieL-f9-hXL"/>
83− <constraint firstAttribute="bottom" secondItem="blr-ad-ozM" secondAttribute="bottom" constant="8" id="vLU-74-Tte"/>
84− <constraint firstAttribute="bottom" secondItem="rfg-EE-4qb" secondAttribute="bottom" id="vb9-9X-My3"/>
85− </constraints>
86− </tableViewCellContentView>
87− <connections>
88− <outlet property="dateLabel" destination="JHC-xy-xNO" id="CSB-tt-Y9f"/>
89− <outlet property="guestNumber" destination="FRo-NH-yGn" id="VO2-jq-rOA"/>
90− <outlet property="personLabel" destination="5ef-FS-6NW" id="5iw-md-7zq"/>
91− <outlet property="tableImage" destination="7TJ-je-a9o" id="joX-6c-N1H"/>
92− <outlet property="timeLabel" destination="Xii-MO-mz4" id="21k-eZ-ZHy"/>
93− </connections>
94− </tableViewCell>
95− </prototypes>
96− <connections>
97− <outlet property="dataSource" destination="YIa-Ku-gIA" id="I7u-K4-GYW"/>
98− <outlet property="delegate" destination="YIa-Ku-gIA" id="ib4-vG-8hB"/>
99− </connections>
100− </tableView>
101− </tableViewController>
102− <placeholder placeholderIdentifier="IBFirstResponder" id="oln-WZ-Fmy" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
19+ <viewLayoutGuide key="safeArea" id="QBQ-KH-Pid"/>
20+ </view>
21+ </viewController>
22+ <placeholder placeholderIdentifier="IBFirstResponder" id="Rnh-3m-3dv" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
10323 </objects>
104− <point key="canvasLocation" x="-666.39999999999998" y="158.77061469265368"/>
24+ <point key="canvasLocation" x="111" y="159"/>
10525 </scene>
10626 </scenes>
107− <resources>
108− <image name="1_7" width="118" height="133"/>
109− </resources>
11027</document>
Hookah Tau/Controllers/Admin/Reservations/AdminReservationsController.swift+80−21
@@ -8,21 +8,37 @@
88
99import UIKit
1010
11−class AdminReservationsController: UITableViewController {
11+class AdminReservationsController: BaseViewController {
1212
1313 // MARK:- Properties
1414
1515 /// Establishment id
1616 var id: Int?
17+
18+ var tableView: UITableView? = {
19+ let tableView = UITableView()
20+ tableView.backgroundColor = .white
21+ return tableView
22+ }()
23+
24+ var contentView: UIView = {
25+ let view = UIView()
26+ view.translatesAutoresizingMaskIntoConstraints = false
27+ return view
28+ }()
29+
30+ var noReservationsView: AdminNoReservationsView?
31+
1732 var reservationsService: ReservationsService?
33+
1834 var activeReservations: [ReservationWithUser] = [] {
1935 didSet {
20− //guard let empty = noReservationsView else { return }
36+ guard let empty = noReservationsView else { return }
2137 if activeReservations.isEmpty {
22− //contentView.bringSubviewToFront(empty)
23− //empty.alpha = 1
38+ contentView.bringSubviewToFront(empty)
39+ empty.alpha = 1
2440 } else {
25− //contentView.sendSubviewToBack(empty)
41+ contentView.sendSubviewToBack(empty)
2642 tableView?.alpha = 1
2743 }
2844
@@ -34,6 +50,8 @@ class AdminReservationsController: UITableViewController {
3450 super.viewDidLoad()
3551
3652 reservationsService = ReservationsService(apiClient: APIClient.shared)
53+ setUpContentView()
54+ setupNavBar()
3755 }
3856
3957 override func viewDidAppear(_ animated: Bool) {
@@ -42,6 +60,38 @@ class AdminReservationsController: UITableViewController {
4260 performUpdate()
4361 }
4462
63+ // MARK:- Setup
64+
65+ func setupNavBar() {
66+ self.navigationItem.title = "Брони"
67+ navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(book))
68+ }
69+
70+ func setUpContentView() {
71+ self.view.addSubviewThatFills(contentView)
72+
73+ // empty
74+ noReservationsView = AdminNoReservationsView.loadFromNib()
75+ contentView.addSubviewThatFills(noReservationsView)
76+ noReservationsView?.bookButton?.addTarget(self, action: #selector(book), for: .touchUpInside)
77+
78+ noReservationsView?.alpha = 0
79+
80+ // table
81+ contentView.addSubviewThatFills(tableView)
82+
83+ setUpTableView()
84+ }
85+
86+ func setUpTableView() {
87+ tableView?.delegate = self
88+ tableView?.dataSource = self
89+
90+ tableView?.alpha = 0
91+
92+ tableView?.register(AdminReservationCell.self, forCellReuseIdentifier: adminReservationCellId)
93+ }
94+
4595 func performUpdate() {
4696
4797 guard let id = id else { return }
@@ -51,27 +101,36 @@ class AdminReservationsController: UITableViewController {
51101 case .success(let reservations):
52102 self?.activeReservations = reservations
53103 case .failure(let err):
54− //self?.displayAlert(forError: err)
55− print(err)
104+ self?.displayAlert(forError: err)
56105 }
57106 })
58107 }
59−
60− // MARK: - Table view data source
61−
62− override func numberOfSections(in tableView: UITableView) -> Int {
63− return 1
64− }
65−
66− override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
67− return activeReservations.count
68− }
69108
70− override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
71− let cell = tableView.dequeueReusableCell(withIdentifier: "AdminReservationCell", for: indexPath) as! AdminReservationCell
109+ // MARK:- Button handler
110+
111+ @objc func book() {
72112
73− cell.bind(withModel: activeReservations[indexPath.row])
74− return cell
75113 }
76114
77115}
116+
117+
118+// MARK: - Table view data source
119+
120+extension AdminReservationsController: UITableViewDelegate, UITableViewDataSource {
121+
122+ func numberOfSections(in tableView: UITableView) -> Int {
123+ return 1
124+ }
125+
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+ }
136+}
Hookah Tau/Controllers/Admin/Reservations/Cell/AdminReservationCell.swift → Hookah Tau/Controllers/Admin/Reservations/Cell/AdminReservationCellView.swiftrenamed+31
@@ -8,7 +8,38 @@
88
99import UIKit
1010
11+let adminReservationCellId = "AdminReservationCell"
12+
1113class AdminReservationCell: UITableViewCell {
14+ // MARK: - Properties
15+
16+ var reservationCellView: AdminReservationCellView?
17+
18+ // MARK: - Init
19+
20+ override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?)
21+ {
22+ super.init(style: style, reuseIdentifier: reuseIdentifier)
23+
24+ reservationCellView = AdminReservationCellView.loadFromNib()
25+ contentView.addSubviewThatFills(reservationCellView)
26+
27+ self.selectionStyle = .none
28+ }
29+
30+ required init?(coder aDecoder: NSCoder)
31+ {
32+ fatalError("init(coder:) has not been implemented")
33+ }
34+
35+ // MARK: - Data
36+
37+ func bind(withModel model: ReservationWithUser) {
38+ reservationCellView?.bind(withModel: model)
39+ }
40+}
41+
42+class AdminReservationCellView: UIView {
1243
1344 // MARK:- IBAOutlets
1445
Hookah Tau/Controllers/Admin/Reservations/Cell/AdminReservationCellView.xibnew file+93
@@ -0,0 +1,93 @@
1+<?xml version="1.0" encoding="UTF-8"?>
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">
3+ <device id="retina4_7" orientation="portrait" appearance="light"/>
4+ <dependencies>
5+ <deployment identifier="iOS"/>
6+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
7+ <capability name="Safe area layout guides" minToolsVersion="9.0"/>
8+ <capability name="Stack View standard spacing" minToolsVersion="9.0"/>
9+ <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
10+ </dependencies>
11+ <objects>
12+ <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
13+ <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
14+ <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"/>
16+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
17+ <subviews>
18+ <stackView opaque="NO" contentMode="scaleToFill" spacing="160" translatesAutoresizingMaskIntoConstraints="NO" id="au9-nK-XbR">
19+ <rect key="frame" x="17" y="3" width="380" height="133"/>
20+ <subviews>
21+ <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"/>
23+ <subviews>
24+ <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">
25+ <rect key="frame" x="0.0" y="0.0" width="54" height="19.5"/>
26+ <fontDescription key="fontDescription" type="system" pointSize="16"/>
27+ <color key="textColor" red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="calibratedRGB"/>
28+ <nil key="highlightedColor"/>
29+ </label>
30+ <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"/>
32+ <subviews>
33+ <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">
34+ <rect key="frame" x="0.0" y="0.0" width="76.5" height="20.5"/>
35+ <fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
36+ <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
37+ <nil key="highlightedColor"/>
38+ </label>
39+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="3:00 — 5:30" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IdW-5d-DS0">
40+ <rect key="frame" x="0.0" y="24.5" width="102" height="20.5"/>
41+ <fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
42+ <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
43+ <nil key="highlightedColor"/>
44+ </label>
45+ </subviews>
46+ </stackView>
47+ <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"/>
49+ <fontDescription key="fontDescription" type="system" pointSize="17"/>
50+ <nil key="textColor"/>
51+ <nil key="highlightedColor"/>
52+ </label>
53+ </subviews>
54+ </stackView>
55+ <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"/>
57+ </imageView>
58+ </subviews>
59+ </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>
67+ </subviews>
68+ <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
69+ <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"/>
77+ </constraints>
78+ <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
79+ <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
80+ <connections>
81+ <outlet property="dateLabel" destination="9k3-E5-XKR" id="wBe-yq-PN9"/>
82+ <outlet property="guestNumber" destination="VhL-qH-zM9" id="Ent-pM-uER"/>
83+ <outlet property="personLabel" destination="KV8-UG-2ws" id="eYB-qn-fJL"/>
84+ <outlet property="tableImage" destination="Oa6-n7-joV" id="cyD-bY-OpP"/>
85+ <outlet property="timeLabel" destination="IdW-5d-DS0" id="ddO-Dx-LDK"/>
86+ </connections>
87+ <point key="canvasLocation" x="137.59999999999999" y="90.854572713643179"/>
88+ </view>
89+ </objects>
90+ <resources>
91+ <image name="1_7" width="118" height="133"/>
92+ </resources>
93+</document>
Hookah Tau/Controllers/Admin/Reservations/Views/No reserv/AdminNoReservationsView.swiftnew file+22
@@ -0,0 +1,22 @@
1+//
2+// AdminNoReservationsView.swift
3+// Hookah Tau
4+//
5+// Created by cstore on 19/12/2019.
6+// Copyright © 2019 Daria Rednikina. All rights reserved.
7+//
8+
9+import UIKit
10+
11+class AdminNoReservationsView: UIView {
12+
13+ // MARK: - IBAOutlets
14+
15+ @IBOutlet weak var bookButton: Button? {
16+ didSet {
17+ let style = BlackButtonStyle()
18+ style.apply(to: bookButton)
19+ }
20+ }
21+
22+}
Hookah Tau/Controllers/Admin/Reservations/Views/No reserv/AdminNoReservationsView.xibnew file+53
@@ -0,0 +1,53 @@
1+<?xml version="1.0" encoding="UTF-8"?>
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">
3+ <device id="retina6_1" orientation="portrait" appearance="light"/>
4+ <dependencies>
5+ <deployment identifier="iOS"/>
6+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
7+ <capability name="Safe area layout guides" minToolsVersion="9.0"/>
8+ <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
9+ </dependencies>
10+ <objects>
11+ <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
12+ <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
13+ <view contentMode="scaleToFill" id="iN0-l3-epB" customClass="AdminNoReservationsView" customModule="Hookah_Tau" customModuleProvider="target">
14+ <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
15+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16+ <subviews>
17+ <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" spacing="46" translatesAutoresizingMaskIntoConstraints="NO" id="Ytd-08-vB9">
18+ <rect key="frame" x="107" y="382" width="200" height="142"/>
19+ <subviews>
20+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="В вашем заведении пока не забронирован ни один столик :(" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Svd-DB-3Zu">
21+ <rect key="frame" x="4" y="0.0" width="192" height="61"/>
22+ <fontDescription key="fontDescription" type="system" weight="semibold" pointSize="17"/>
23+ <nil key="textColor"/>
24+ <nil key="highlightedColor"/>
25+ </label>
26+ <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="y3F-ua-mLb" customClass="Button" customModule="Hookah_Tau" customModuleProvider="target">
27+ <rect key="frame" x="12.5" y="107" width="175" height="35"/>
28+ <color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
29+ <constraints>
30+ <constraint firstAttribute="width" constant="175" id="LnY-Iu-4e6"/>
31+ <constraint firstAttribute="height" constant="35" id="oN3-oc-fHx"/>
32+ </constraints>
33+ <state key="normal" title="Button"/>
34+ </button>
35+ </subviews>
36+ <constraints>
37+ <constraint firstAttribute="width" constant="200" id="pgG-jg-faG"/>
38+ </constraints>
39+ </stackView>
40+ </subviews>
41+ <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
42+ <constraints>
43+ <constraint firstItem="Ytd-08-vB9" firstAttribute="centerY" secondItem="vUN-kp-3ea" secondAttribute="centerY" id="ewL-z8-YVD"/>
44+ <constraint firstItem="Ytd-08-vB9" firstAttribute="centerX" secondItem="vUN-kp-3ea" secondAttribute="centerX" id="txy-j9-mF1"/>
45+ </constraints>
46+ <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
47+ <connections>
48+ <outlet property="bookButton" destination="y3F-ua-mLb" id="aC4-gz-Gqd"/>
49+ </connections>
50+ <point key="canvasLocation" x="137.68115942028987" y="91.741071428571431"/>
51+ </view>
52+ </objects>
53+</document>