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 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
57 changes: 57 additions & 0 deletions Dokan/Dokan.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
objects = {

/* Begin PBXBuildFile section */
2704245B28ACD223002EF7B5 /* CategoryCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2704245928ACD223002EF7B5 /* CategoryCollectionViewCell.swift */; };
2704245C28ACD223002EF7B5 /* CategoryCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2704245A28ACD223002EF7B5 /* CategoryCollectionViewCell.xib */; };
270E12ED28C1E0DC00E3D8EB /* CategoryListTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 270E12EC28C1E0DC00E3D8EB /* CategoryListTests.swift */; };
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 @@ -63,6 +70,7 @@
E251D04E28784A050065C852 /* VerificationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E251D04A28784A050065C852 /* VerificationViewController.swift */; };
E251D04F28784A050065C852 /* VerificationViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = E251D04B28784A050065C852 /* VerificationViewModel.swift */; };
E251D05028784A050065C852 /* VerificationViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E251D04C28784A050065C852 /* VerificationViewController.xib */; };
E2F353F528B8E45E00E47566 /* CategoryFooterReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F353F428B8E45E00E47566 /* CategoryFooterReusableView.swift */; };
E2CC398828A4A933008AE48B /* LoadingButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2CC398728A4A933008AE48B /* LoadingButton.swift */; };
E2DADBAC288A5445005E483A /* ButtonsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2DADBAB288A5445005E483A /* ButtonsView.swift */; };
E2DADBAE288A5463005E483A /* ButtonsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = E2DADBAD288A5463005E483A /* ButtonsView.xib */; };
Expand All @@ -79,6 +87,13 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
2704245928ACD223002EF7B5 /* CategoryCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategoryCollectionViewCell.swift; sourceTree = "<group>"; };
2704245A28ACD223002EF7B5 /* CategoryCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CategoryCollectionViewCell.xib; sourceTree = "<group>"; };
270E12EC28C1E0DC00E3D8EB /* CategoryListTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategoryListTests.swift; 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 @@ -134,6 +149,7 @@
E251D04A28784A050065C852 /* VerificationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VerificationViewController.swift; sourceTree = "<group>"; };
E251D04B28784A050065C852 /* VerificationViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VerificationViewModel.swift; sourceTree = "<group>"; };
E251D04C28784A050065C852 /* VerificationViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = VerificationViewController.xib; sourceTree = "<group>"; };
E2F353F428B8E45E00E47566 /* CategoryFooterReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategoryFooterReusableView.swift; sourceTree = "<group>"; };
E2CC398728A4A933008AE48B /* LoadingButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingButton.swift; sourceTree = "<group>"; };
E2DADBAB288A5445005E483A /* ButtonsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonsView.swift; sourceTree = "<group>"; };
E2DADBAD288A5463005E483A /* ButtonsView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ButtonsView.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -164,6 +180,28 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
2704245828ACD1E2002EF7B5 /* CategoryList */ = {
isa = PBXGroup;
children = (
E2F353F328B8E41700E47566 /* CategoryListFooterView */,
2704245D28ACD79F002EF7B5 /* categoryListCell */,
273D3A9428AE11A400860702 /* CategoryListViewModelType.swift */,
273D3A9528AE11A400860702 /* CategoryListViewController.swift */,
273D3A9628AE11A400860702 /* CategoryListViewModel.swift */,
273D3A9728AE11A400860702 /* CategoryListViewController.xib */,
);
path = CategoryList;
sourceTree = "<group>";
};
2704245D28ACD79F002EF7B5 /* categoryListCell */ = {
isa = PBXGroup;
children = (
2704245928ACD223002EF7B5 /* CategoryCollectionViewCell.swift */,
2704245A28ACD223002EF7B5 /* CategoryCollectionViewCell.xib */,
);
path = categoryListCell;
sourceTree = "<group>";
};
276889D92874162B0091ACEB /* Registration */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -419,6 +457,7 @@
AAF5F1DA286F76F2002DA8ED /* Scenes */ = {
isa = PBXGroup;
children = (
2704245828ACD1E2002EF7B5 /* CategoryList */,
85B31DAD2870BD4700B1C9E8 /* Login */,
276889D92874162B0091ACEB /* Registration */,
E2156C24287342F000A92325 /* Verification */,
Expand All @@ -439,6 +478,7 @@
children = (
43D4BF0628918F160023190F /* ProductDetails */,
AADC5BAD289ADFF300C9AA12 /* Registration */,
270E12EC28C1E0DC00E3D8EB /* CategoryListTests.swift */,
);
path = Scenes;
sourceTree = "<group>";
Expand All @@ -454,6 +494,14 @@
path = Verification;
sourceTree = "<group>";
};
E2F353F328B8E41700E47566 /* CategoryListFooterView */ = {
isa = PBXGroup;
children = (
E2F353F428B8E45E00E47566 /* CategoryFooterReusableView.swift */,
);
path = CategoryListFooterView;
sourceTree = "<group>";
};
E2DADBAA288A53D9005E483A /* ButtonsView */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -577,11 +625,13 @@
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 */,
E2DADBAE288A5463005E483A /* ButtonsView.xib in Resources */,
AA21B43D28537E0400E4F217 /* Main.storyboard in Resources */,
856E36B1288922EF00735EF2 /* InfoSellerView.xib in Resources */,
437B99A628907F0700F59B06 /* FeaturedProductView.xib in Resources */,
2704245C28ACD223002EF7B5 /* CategoryCollectionViewCell.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -679,6 +729,7 @@
E2CC398828A4A933008AE48B /* LoadingButton.swift in Sources */,
85B31DBB2870BEDE00B1C9E8 /* LoginViewController.swift in Sources */,
85B31DBA2870BEDE00B1C9E8 /* LoginViewModelType.swift in Sources */,
E2F353F528B8E45E00E47566 /* CategoryFooterReusableView.swift in Sources */,
856E36AF2889229B00735EF2 /* InfoSellerView.swift in Sources */,
E251D04E28784A050065C852 /* VerificationViewController.swift in Sources */,
AA6BBD0C28A5CB2A00A66078 /* ServiceLocator.swift in Sources */,
Expand All @@ -689,16 +740,21 @@
276889E1287420980091ACEB /* RegisterViewModelType.swift in Sources */,
99091F1A28895DC1000FA9C9 /* ProductTitleQuantityView.swift in Sources */,
276889DF28741F750091ACEB /* RegisterViewModel.swift in Sources */,
2704245B28ACD223002EF7B5 /* CategoryCollectionViewCell.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 */,
E2DADBAC288A5445005E483A /* ButtonsView.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 */,
B803A84428AFECEE0005C8B9 /* ReviewsView.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 All @@ -718,6 +774,7 @@
AADC5BB1289ADFF300C9AA12 /* RegisterViewControllerTests.swift in Sources */,
43D4BF0B2891A5C50023190F /* FeaturedProductCollectionViewCellTests.swift in Sources */,
43D4BF0928918F9A0023190F /* FeaturedProductTests.swift in Sources */,
270E12ED28C1E0DC00E3D8EB /* CategoryListTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// CategoryFooterReusableView.swift
// Dokan
//
// Created by Ahmed Nagy on 26/08/2022.
//

import UIDokan
import UIKit

class CategoryFooterReusableView: UICollectionReusableView, IdentifiableView {

private let button: UIButton = {
let button = UIButton(type: .system)
button.translatesAutoresizingMaskIntoConstraints = false
button.layer.cornerRadius = 10
button.layer.borderColor = UIColor(red: 0, green: 0, blue: 0, alpha: 1).cgColor
button.layer.borderWidth = 5
button.setTitleColor(UIColor(red: 0, green: 0, blue: 0, alpha: 1), for: .normal)
button.titleLabel?.font = UIFont.preferredFont(forTextStyle: .headline)
button.setTitle("Filter & Sorting", for: .normal)
return button
}()

override init(frame: CGRect) {
super.init(frame: frame)
configure()
}

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

private func configure() {
addSubview(button)
}

override func layoutSubviews() {
super.layoutSubviews()
button.frame = bounds
}
}
115 changes: 115 additions & 0 deletions Dokan/Dokan/Scenes/CategoryList/CategoryListViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
//
// 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: [CategoryCollectionViewCell.ViewModel]?

// 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()
}
}

// 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
}

private func setupCollectionview() {
categoriesCollectionview.register(CategoryCollectionViewCell.self)
categoriesCollectionview.register(CategoryFooterReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: CategoryFooterReusableView.reuseIdentifier)
categoriesCollectionview.delegate = self
categoriesCollectionview.dataSource = self
}
}

// MARK: - conform to UICollectionView protocols

extension CategoryListViewController: UICollectionViewDelegate {}

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

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

extension CategoryListViewController: UICollectionViewDelegateFlowLayout {

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

return CGSize(width: (collectionView.bounds.width / 2) - 20, height: Metrics.height)
}

func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
let footer = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: CategoryFooterReusableView.reuseIdentifier, for: indexPath) as! CategoryFooterReusableView
return footer
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
return CGSize(width: view.frame.width * 0.8, height: 44)
}
}

// MARK: - UISearchBarDelegate Methods

//

extension CategoryListViewController: UISearchResultsUpdating, UISearchBarDelegate {
func updateSearchResults(for searchController: UISearchController) {
#warning("update search results")
}
}

private extension CategoryListViewController {
enum Metrics {
static let height: CGFloat = 280
}
}
42 changes: 42 additions & 0 deletions Dokan/Dokan/Scenes/CategoryList/CategoryListViewController.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?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="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>
<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="44" width="404" height="882"/>
<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="5" maxX="0.0" maxY="5"/>
</collectionViewFlowLayout>
</collectionView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="9UT-iE-HA5" secondAttribute="trailing" constant="12" id="JQH-lU-MXu"/>
<constraint firstItem="9UT-iE-HA5" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" constant="44" id="Y4L-8x-55b"/>
<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"/>
</constraints>
<point key="canvasLocation" x="91.121495327102792" y="16.846652267818577"/>
</view>
</objects>
</document>
Loading