Skip to content

Commit

Permalink
fix: Tab Bar issues fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dheerajadev committed Oct 24, 2023
1 parent b9cf20e commit ebdebe7
Show file tree
Hide file tree
Showing 24 changed files with 127 additions and 21 deletions.
8 changes: 0 additions & 8 deletions SwiggyClone.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -326,18 +326,10 @@
children = (
4466D28527D478B9009A5BB6 /* View */,
4466D27F27D471C1009A5BB6 /* Controllers */,
4466D27E27D471BB009A5BB6 /* Views */,
);
path = Search;
sourceTree = "<group>";
};
4466D27E27D471BB009A5BB6 /* Views */ = {
isa = PBXGroup;
children = (
);
path = Views;
sourceTree = "<group>";
};
4466D27F27D471C1009A5BB6 /* Controllers */ = {
isa = PBXGroup;
children = (
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "A5C46C5D-AF97-4B10-8CA4-25A0CB51BE63"
type = "1"
version = "2.0">
</Bucket>
10 changes: 5 additions & 5 deletions SwiggyClone/AppBase/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
window = UIWindow(frame: UIScreen.main.bounds)
window?.windowScene = windowScene

// let VC = TabBarViewController()
// window?.rootViewController = VC
let VC = TabBarViewController()
window?.rootViewController = VC

let VC = SearchViewController()
let navVC = UINavigationController(rootViewController: VC)
window?.rootViewController = navVC
// let VC = SearchViewController()
// let navVC = UINavigationController(rootViewController: VC)
// window?.rootViewController = navVC

window?.makeKeyAndVisible()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "ic_food_tab.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "ic_food_tab_selected.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "ic_search_tab.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "ic_search_tab_selected.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion SwiggyClone/Scenes/Model/AppLayouts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AppLayouts {

let section = NSCollectionLayoutSection(group: group)
section.contentInsets = NSDirectionalEdgeInsets(top: 10, leading: 15, bottom: 10, trailing: 0)
section.orthogonalScrollingBehavior = .paging
section.orthogonalScrollingBehavior = .continuous

return section
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Dheeraj Kumar Sharma on 06/03/22.
//

import Foundation
import UIKit

extension SearchViewController: SearchContainerViewActionDelegate, SearchedContentActionDelegate {

Expand Down Expand Up @@ -51,3 +51,12 @@ extension SearchViewController: SearchContainerViewActionDelegate, SearchedConte
}

}

extension SearchViewController: UITextFieldDelegate {

func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
return true
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class SearchViewController: UIViewController {
view.translatesAutoresizingMaskIntoConstraints = false
view.backgroundColor = .white
view.delegate = self
view.searchTextField.delegate = self
return view
}()

Expand Down Expand Up @@ -46,6 +47,10 @@ class SearchViewController: UIViewController {
setUpConstraints()
}

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
self.view.endEditing(true)
}

// MARK: FUNCTIONS -

func setUpNavigations(){
Expand Down
14 changes: 8 additions & 6 deletions SwiggyClone/Scenes/Views/Tab/TabBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ class TabBarViewController: UITabBarController, UITabBarControllerDelegate{

viewControllers = [foodViewController , searchViewController]

self.tabBar.isTranslucent = false
// self.tabBar.isTranslucent = false
self.tabBar.backgroundImage = UIImage()
self.tabBar.barTintColor = .white
UITabBar.appearance().backgroundColor = .white

customTab(selectedImage: "ic_food", deselectedImage: "ic_food_selected", indexOfTab: 0 , tabTitle: "")
customTab(selectedImage: "ic_search", deselectedImage: "ic_search_selected", indexOfTab: 1 , tabTitle: "")
customTab(selectedImage: "ic_food_tab_selected", deselectedImage: "ic_food_tab", indexOfTab: 0 , tabTitle: "")
customTab(selectedImage: "ic_search_tab_selected", deselectedImage: "ic_search_tab", indexOfTab: 1 , tabTitle: "")
}

func customTab(selectedImage image1 : String , deselectedImage image2: String , indexOfTab index: Int , tabTitle title: String ){

let selectedImage = UIImage(named: image1)
let deselectedImage = UIImage(named: image2)
let selectedImage = UIImage(named: image1)?.withRenderingMode(.alwaysOriginal)
let deselectedImage = UIImage(named: image2)?.withRenderingMode(.alwaysOriginal)

tabItem = self.tabBar.items![index]
tabItem.image = deselectedImage
Expand All @@ -57,3 +57,5 @@ class TabBarViewController: UITabBarController, UITabBarControllerDelegate{
}

}


0 comments on commit ebdebe7

Please sign in to comment.