Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add UISearchController and footer view to CategoryListViewController 🕵️ #120

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 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
40 changes: 40 additions & 0 deletions Dokan/Dokan.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
objects = {

/* Begin PBXBuildFile section */
2704245B28ACD223002EF7B5 /* CategoryListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2704245928ACD223002EF7B5 /* CategoryListCell.swift */; };
2704245C28ACD223002EF7B5 /* CategoryListCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2704245A28ACD223002EF7B5 /* CategoryListCell.xib */; };
273D3A9828AE11A400860702 /* CategoryListViewModelType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 273D3A9428AE11A400860702 /* CategoryListViewModelType.swift */; };
273D3A9928AE11A400860702 /* CategoryListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 273D3A9528AE11A400860702 /* CategoryListViewController.swift */; };
273D3A9A28AE11A400860702 /* CategoryListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 273D3A9628AE11A400860702 /* CategoryListViewModel.swift */; };
273D3A9B28AE11A400860702 /* CategoryListViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 273D3A9728AE11A400860702 /* CategoryListViewController.xib */; };
276889DC287417730091ACEB /* RegisterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 276889DA287417730091ACEB /* RegisterViewController.swift */; };
276889DD287417730091ACEB /* RegisterViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 276889DB287417730091ACEB /* RegisterViewController.xib */; };
276889DF28741F750091ACEB /* RegisterViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 276889DE28741F750091ACEB /* RegisterViewModel.swift */; };
Expand Down Expand Up @@ -75,6 +81,12 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
2704245928ACD223002EF7B5 /* CategoryListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategoryListCell.swift; sourceTree = "<group>"; };
2704245A28ACD223002EF7B5 /* CategoryListCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CategoryListCell.xib; sourceTree = "<group>"; };
273D3A9428AE11A400860702 /* CategoryListViewModelType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategoryListViewModelType.swift; sourceTree = "<group>"; };
273D3A9528AE11A400860702 /* CategoryListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategoryListViewController.swift; sourceTree = "<group>"; };
273D3A9628AE11A400860702 /* CategoryListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategoryListViewModel.swift; sourceTree = "<group>"; };
273D3A9728AE11A400860702 /* CategoryListViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CategoryListViewController.xib; sourceTree = "<group>"; };
276889DA287417730091ACEB /* RegisterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegisterViewController.swift; sourceTree = "<group>"; };
276889DB287417730091ACEB /* RegisterViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = RegisterViewController.xib; sourceTree = "<group>"; };
276889DE28741F750091ACEB /* RegisterViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegisterViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -154,6 +166,27 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
2704245828ACD1E2002EF7B5 /* CategoryList */ = {
isa = PBXGroup;
children = (
2704245D28ACD79F002EF7B5 /* categoryListCell */,
273D3A9428AE11A400860702 /* CategoryListViewModelType.swift */,
273D3A9528AE11A400860702 /* CategoryListViewController.swift */,
273D3A9628AE11A400860702 /* CategoryListViewModel.swift */,
273D3A9728AE11A400860702 /* CategoryListViewController.xib */,
);
path = CategoryList;
sourceTree = "<group>";
};
2704245D28ACD79F002EF7B5 /* categoryListCell */ = {
isa = PBXGroup;
children = (
2704245928ACD223002EF7B5 /* CategoryListCell.swift */,
2704245A28ACD223002EF7B5 /* CategoryListCell.xib */,
);
path = categoryListCell;
sourceTree = "<group>";
};
276889D92874162B0091ACEB /* Registration */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -393,6 +426,7 @@
AAF5F1DA286F76F2002DA8ED /* Scenes */ = {
isa = PBXGroup;
children = (
2704245828ACD1E2002EF7B5 /* CategoryList */,
85B31DAD2870BD4700B1C9E8 /* Login */,
276889D92874162B0091ACEB /* Registration */,
E2156C24287342F000A92325 /* Verification */,
Expand Down Expand Up @@ -541,10 +575,12 @@
AAA2E17D285CBB9100EAD189 /* GoogleService-Info.plist in Resources */,
AA21B43F28537E0500E4F217 /* Assets.xcassets in Resources */,
99091F1828895D96000FA9C9 /* ProductTitleQuantityView.xib in Resources */,
273D3A9B28AE11A400860702 /* CategoryListViewController.xib in Resources */,
AA57CB312881B21800FE62C8 /* ProductDetailsViewController.xib in Resources */,
AA21B43D28537E0400E4F217 /* Main.storyboard in Resources */,
856E36B1288922EF00735EF2 /* InfoSellerView.xib in Resources */,
437B99A628907F0700F59B06 /* FeaturedProductView.xib in Resources */,
2704245C28ACD223002EF7B5 /* CategoryListCell.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -649,15 +685,19 @@
276889E1287420980091ACEB /* RegisterViewModelType.swift in Sources */,
99091F1A28895DC1000FA9C9 /* ProductTitleQuantityView.swift in Sources */,
276889DF28741F750091ACEB /* RegisterViewModel.swift in Sources */,
2704245B28ACD223002EF7B5 /* CategoryListCell.swift in Sources */,
276889DC287417730091ACEB /* RegisterViewController.swift in Sources */,
AAC39E18289DD9DE0069822D /* ReviewerTableViewCell.swift in Sources */,
273D3A9A28AE11A400860702 /* CategoryListViewModel.swift in Sources */,
437B99AC289082BC00F59B06 /* FeaturedProductCollectionViewCell.swift in Sources */,
AA21B43628537E0400E4F217 /* AppDelegate.swift in Sources */,
AA57CB2E2881B21800FE62C8 /* ProductDetailsViewModelType.swift in Sources */,
E251D04D28784A050065C852 /* VerificationViewModelType.swift in Sources */,
273D3A9828AE11A400860702 /* CategoryListViewModelType.swift in Sources */,
432EF5D8288F2E7D0073FB1D /* Strings+Generated.swift in Sources */,
85DA676428928F1500DCABD2 /* InfoSellerViewDelegate.swift in Sources */,
2768DEF028A422D2004C6A5B /* SliderCollectionViewCell.swift in Sources */,
273D3A9928AE11A400860702 /* CategoryListViewController.swift in Sources */,
519D380728A05B860029B722 /* UIImage+Extension.swift in Sources */,
E251D04F28784A050065C852 /* VerificationViewModel.swift in Sources */,
85F6B6DA28919C87007730AB /* ProductDetailsNavigationBarBehavior.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
//
// CategoryListViewController.swift
// Dokan
//
// Created by heba isaa on 18/08/2022.
//

import UIKit

class CategoryListViewController: UIViewController {

// MARK: Outlets

@IBOutlet weak var categoriesCollectionview: UICollectionView!

// MARK: Properties

private let viewModel: CategoryListViewModelType
private var categoriesviewModel: [CategoryListCell.categoryViewModel]?

// MARK: Init

init(viewModel: CategoryListViewModelType) {
self.viewModel = viewModel
super.init(nibName: nil, bundle: nil)
}

@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: Lifecycle

override func viewDidLoad() {
super.viewDidLoad()

setupCollectionview()
configureSearchController()
}

private func setupCollectionview() {
categoriesCollectionview.register(CategoryListCell.self)
categoriesCollectionview.delegate = self
categoriesCollectionview.dataSource = self
}
}

// MARK: - Actions

//
extension CategoryListViewController {}

// MARK: - Configurations

//
extension CategoryListViewController {
func configureSearchController() {
let searchController = UISearchController()
searchController.searchResultsUpdater = self
searchController.searchBar.delegate = self
searchController.searchBar.placeholder = "Search Product Name"
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = false
}
}

// MARK: - Private Handlers

//
private extension CategoryListViewController {}

extension CategoryListViewController: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
categoriesviewModel?.count ?? 0
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell: CategoryListCell = collectionView.dequeueReusableCell(for: indexPath)
return cell
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {

return CGSize(width: (view.frame.width / 2) - 20, height: 280)
}
}

// MARK: - UISearchBarDelegate Methods

//

extension CategoryListViewController: UISearchResultsUpdating, UISearchBarDelegate {
func updateSearchResults(for searchController: UISearchController) {
#warning("update search results")
}
}
58 changes: 58 additions & 0 deletions Dokan/Dokan/Scenes/CategoryList/CategoryListViewController.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina6_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="CategoryListViewController" customModule="Dokan" customModuleProvider="target">
<connections>
<outlet property="categoriesCollectionview" destination="9UT-iE-HA5" id="Azd-Ut-oks"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="428" height="926"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2L6-3M-TKm">
<rect key="frame" x="0.0" y="0.0" width="428" height="100"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="height" constant="100" id="Gd2-Yi-E5Y"/>
</constraints>
</view>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="9UT-iE-HA5">
<rect key="frame" x="12" y="100" width="404" height="826"/>
<color key="backgroundColor" red="0.98039215686274506" green="0.98039215686274506" blue="0.98039215686274506" alpha="0.0" colorSpace="calibratedRGB"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="cXa-Yt-wsB">
<size key="itemSize" width="128" height="128"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
</collectionView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="9UT-iE-HA5" firstAttribute="top" secondItem="2L6-3M-TKm" secondAttribute="bottom" id="1x6-23-jSb"/>
<constraint firstAttribute="trailing" secondItem="9UT-iE-HA5" secondAttribute="trailing" constant="12" id="JQH-lU-MXu"/>
<constraint firstAttribute="trailing" secondItem="2L6-3M-TKm" secondAttribute="trailing" id="R7f-nF-SfP"/>
<constraint firstItem="2L6-3M-TKm" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="ZJq-WE-XT7"/>
<constraint firstItem="9UT-iE-HA5" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="12" id="fdg-Dq-0IR"/>
<constraint firstAttribute="bottom" secondItem="9UT-iE-HA5" secondAttribute="bottom" id="oXU-pF-be9"/>
<constraint firstItem="2L6-3M-TKm" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="qDU-xu-kly"/>
</constraints>
<point key="canvasLocation" x="91.121495327102792" y="16.846652267818577"/>
</view>
</objects>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
27 changes: 27 additions & 0 deletions Dokan/Dokan/Scenes/CategoryList/CategoryListViewModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// CategoryListViewModel.swift
// Dokan
//
// Created by heba isaa on 18/08/2022.
//

import Foundation

// MARK: CategoryListViewModel

//
class CategoryListViewModel {}

// MARK: CategoryListViewModel

extension CategoryListViewModel: CategoryListViewModelInput {}

// MARK: CategoryListViewModelOutput

//
extension CategoryListViewModel: CategoryListViewModelOutput {}

// MARK: Private Handlers

//
private extension CategoryListViewModel {}
20 changes: 20 additions & 0 deletions Dokan/Dokan/Scenes/CategoryList/CategoryListViewModelType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// CategoryListViewModelType.swift
// Dokan
//
// Created by heba isaa on 18/08/2022.
//

import Foundation

/// CategoryList Input & Output
///
typealias CategoryListViewModelType = CategoryListViewModelInput & CategoryListViewModelOutput

/// CategoryList ViewModel Input
///
protocol CategoryListViewModelInput {}

/// CategoryList ViewModel Output
///
protocol CategoryListViewModelOutput {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// CategoryListCell.swift
// Dokan
//
// Created by heba isaa on 17/08/2022.
//

import UIDokan
import UIKit

class CategoryListCell: UICollectionViewCell, IdentifiableView {

// MARK: - Outlet

@IBOutlet private(set) weak var categoryImage: UIImageView!
@IBOutlet private(set) weak var categoryTitle: UILabel!
@IBOutlet private(set) weak var categoryPrice: UILabel!
@IBOutlet private(set) weak var categoryReview: UILabel!
@IBOutlet private(set) weak var noOfReviewer: UILabel!
@IBOutlet private(set) weak var moreActionBtn: UIButton!

// MARK: - Initialization

override func awakeFromNib() {
super.awakeFromNib()
}

// MARK: - Cell Configuration

func configureCell(viewModel: categoryViewModel) {
categoryImage.image = viewModel.categoryImage
categoryTitle.text = viewModel.categoryTitle
categoryPrice.text = viewModel.categoryPrice
categoryReview.text = viewModel.categoryReview
noOfReviewer.text = "\(viewModel.noOfReviewer)"
}
}

// MARK: - category Model

extension CategoryListCell {

struct categoryViewModel {
let categoryImage: UIImage
let categoryTitle: String
let categoryPrice: String
let categoryReview: String
let noOfReviewer: Int
}
}
Loading