Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Rahmet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
AB20632442E66626A0D78CB3 /* Pods_Rahmet.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A7E2C126E18E96CEF8D587C /* Pods_Rahmet.framework */; };
C210BA0E27D9B6EC00BBE34D /* DateFormatterLocal.swift in Sources */ = {isa = PBXBuildFile; fileRef = C210BA0D27D9B6EC00BBE34D /* DateFormatterLocal.swift */; };
C242351227D656CE00AE2D70 /* UCollectionView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C242351127D656CE00AE2D70 /* UCollectionView+Extension.swift */; };
C25EA18327D7BC290020D3BA /* CategoriesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C25EA18227D7BC290020D3BA /* CategoriesViewController.swift */; };
C25EA18527D7C16E0020D3BA /* CategoryTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C25EA18427D7C16E0020D3BA /* CategoryTableViewCell.swift */; };
Expand Down Expand Up @@ -98,6 +99,7 @@
/* Begin PBXFileReference section */
1F34CB717506F012A307DEDF /* Pods-Rahmet.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Rahmet.release.xcconfig"; path = "Target Support Files/Pods-Rahmet/Pods-Rahmet.release.xcconfig"; sourceTree = "<group>"; };
5A7E2C126E18E96CEF8D587C /* Pods_Rahmet.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Rahmet.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C210BA0D27D9B6EC00BBE34D /* DateFormatterLocal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateFormatterLocal.swift; sourceTree = "<group>"; };
C242351127D656CE00AE2D70 /* UCollectionView+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UCollectionView+Extension.swift"; sourceTree = "<group>"; };
C25EA18227D7BC290020D3BA /* CategoriesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategoriesViewController.swift; sourceTree = "<group>"; };
C25EA18427D7C16E0020D3BA /* CategoryTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategoryTableViewCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -411,6 +413,7 @@
isa = PBXGroup;
children = (
E5A1257927CCA3AA006508E9 /* Response.swift */,
C210BA0D27D9B6EC00BBE34D /* DateFormatterLocal.swift */,
);
path = Utilities;
sourceTree = "<group>";
Expand Down Expand Up @@ -605,6 +608,7 @@
E584EBC327CA57F60072AC0D /* MenuData.swift in Sources */,
C275C8EE27B39D05001AF463 /* NavigationVCGenerator.swift in Sources */,
E5A1259A27D5FDDD006508E9 /* CartChangingDelegate.swift in Sources */,
C210BA0E27D9B6EC00BBE34D /* DateFormatterLocal.swift in Sources */,
E584EBB927CA55110072AC0D /* Restaurant.swift in Sources */,
E584EBBB27CA55B00072AC0D /* RestaurantData.swift in Sources */,
E5B251DA27B14DA800543C24 /* Registration.swift in Sources */,
Expand Down
13 changes: 13 additions & 0 deletions Rahmet/Model/Utilities/DateFormatterLocal.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// DateFormatterLocal.swift
// Rahmet
//
// Created by Arman on 10.03.2022.
//

import Foundation


class DateFormatterLocal: DateFormatter {

}
55 changes: 51 additions & 4 deletions Rahmet/View/TabBarViews/OrderDetailed.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@
//

import UIKit
import Alamofire
import JGProgressHUD

class OrderDetailed: UIViewController {
let spinner = JGProgressHUD(style: .dark)

var order: OrdersData
var products: [ProductCategories] = []

override func viewDidLoad() {
super.viewDidLoad()
fetchMenu()
setupNavigationBar()
setupViews()
setupConstraints()
Expand Down Expand Up @@ -79,15 +84,18 @@ extension OrderDetailed: UITableViewDelegate, UITableViewDataSource {

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: OrderPositionsCell.reuseId, for: indexPath) as! OrderPositionsCell
if let items = order.orderDetail {
cell.item = items[indexPath.row]
}
if indexPath.row == order.orderDetail?.count {
cell.leftLabel.text = "Итого"
cell.leftLabel.font = .boldSystemFont(ofSize: 14)
cell.rightLabel.text = "\(order.total) тг"
cell.rightLabel.text = "\(order.total ?? 0) тг"
cell.rightLabel.font = .boldSystemFont(ofSize: 14)
return cell
}
if let items = order.orderDetail {
cell.item = items[indexPath.row]
} else {
cell.rightLabel.text = "\(self.findProduct(id: order.orderDetail?[indexPath.row].id ?? 0).name ?? "")"
cell.leftLabel.text = "\(self.findProduct(id: order.orderDetail?[indexPath.row].id ?? 0).price ?? 0)"
}
return cell
}
Expand Down Expand Up @@ -141,6 +149,45 @@ extension OrderDetailed: LayoutForNavigationVC {
}
}

func setupData() {
cafeNameView.subLabel.text = order.restaurant?.name
var statusTitle: String = ""
switch order.orderStatus {
case 0: statusTitle = "В обработке"; statusView.subLabel.textColor = #colorLiteral(red: 0, green: 0.6025887132, blue: 1, alpha: 1)
case 1: statusTitle = "На кухне" ; statusView.subLabel.textColor = #colorLiteral(red: 0.9535714984, green: 0.4975312352, blue: 0.1409159303, alpha: 1)
case 2: statusTitle = "Готов" ; statusView.subLabel.textColor = #colorLiteral(red: 0.2856111825, green: 0.6951665282, blue: 0.3649486899, alpha: 1)
case 4: statusTitle = "Завершен" ; statusView.subLabel.textColor = .gray
default: break
}

statusView.subLabel.text = statusTitle
dateView.subLabel.text = order.createdAt
orderNumView.subLabel.text = "№\(String(describing: order.id))"

}

func fetchMenu() {
spinner.show(in: view)
guard let url = URL(string: Constants.baseURL + "/menu/\(String(describing: order.restaurantID))") else { return }
AF.request(url).validate().responseDecodable(of: Menu.self) {
guard let menu = $0.value else { return }
self.spinner.dismiss(animated: true)
self.products = menu.data?.productCategories ?? []
}
}

func findProduct(id: Int) -> Product {
let product = Product(id: 0, name: "", price: 0, description: "", image: "")
for sect in products {
for prod in sect.products! {
if id == prod.id {
return prod
}
}
}
return product
}

func countTotalSum() -> Double {
var sum = 0.0
if let items = order.orderDetail {
Expand Down