Commit 0fd51ab0 by Angel FS

Initial commit

parents
File added
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "D6BF3AE9-97E3-4BC9-BDDE-943D0F8509C7"
type = "1"
version = "2.0">
</Bucket>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Garmentoo.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>6</integer>
</dict>
</dict>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:Garmentoo.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "EDE2791B-41B4-4C02-ADA8-16680C0F4AA5"
type = "0"
version = "2.0">
</Bucket>
import Foundation
class Bindable<T>{
init(initialValue:T? = nil) {
value = initialValue
}
var value: T?{
didSet{
observers.forEach({$0?(value)})
}
}
fileprivate var observers:[((T?)->())?] = []
func bind(observer: @escaping (T?)->()){
self.observers.append(observer)
}
}
//
// Binder.swift
// Garmentoo
//
// Created by Vijith on 18/04/22.
//
import Foundation
//
// BulkCollectionViewCell.swift
// Garmentoo
//
// Created by MAC on 11/04/22.
//
import UIKit
class BulkCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var outerView:UIView!
@IBOutlet weak var lbl:UILabel!
}
//
// CAtegSelectCV.swift
// Garmentoo
//
// Created by Vijith on 29/03/22.
//
import UIKit
class CategSelectCVCell: UICollectionViewCell {
@IBOutlet weak var outerView:UIView!
@IBOutlet weak var txtLabel:UILabel!
}
//
// ImageCollectionViewCell.swift
// Garmentoo
//
// Created by Vijith on 21/04/22.
//
import UIKit
class ImageCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var btn: UIButton!
@IBOutlet weak var imgView: UIImageView!
}
//
// ItemListCollectionViewCell.swift
// Garmentoo
//
// Created by Vijith on 30/03/22.
//
import UIKit
class ItemListCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var img: UIImageView!
@IBOutlet weak var productname: UILabel!
override func setNeedsLayout() {
img.layer.cornerRadius = 12.0
}
}
//
// ItemsCollectionViewCell.swift
// Garmentoo
//
// Created by MAC on 06/04/22.
//
import UIKit
class ItemsCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var pic:UIImageView!
@IBOutlet weak var product:UILabel!
@IBOutlet weak var price:UILabel!
}
class AllItemsCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var pic:UIImageView!
@IBOutlet weak var product:UILabel!
@IBOutlet weak var price:UILabel!
}
//
// MyOrderCategCollectionViewCell.swift
// Garmentoo
//
// Created by Vijith on 06/04/22.
//
import UIKit
class MyOrderCategCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var outerView:UIView!
@IBOutlet weak var lbl:UILabel!
override func setNeedsLayout() {
self.outerView.layer.cornerRadius = self.outerView.frame.height/2
}
}
//
// ProductImageListCVC.swift
// Garmentoo
//
// Created by Angel F Syrus on 06/05/22.
//
import UIKit
class ProductImageListCVC: UICollectionViewCell {
@IBOutlet weak var productImage: UIImageView!
}
//
// ReviewImageCVC.swift
// Garmentoo
//
// Created by Angel F Syrus on 05/05/22.
//
import UIKit
class ReviewImageCVC: UICollectionViewCell {
@IBOutlet weak var reviewImage: UIImageView!
@IBOutlet weak var seeMoreView: UIView!
}
//
// SeeAllItemsCollectionViewCell.swift
// Garmentoo
//
// Created by Vijith on 03/05/22.
//
import Foundation
import UIKit
class SeeAllItemsCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var pic:UIImageView!
@IBOutlet weak var product:UILabel!
@IBOutlet weak var price:UILabel!
}
//
// SizeCollectionViewCell.swift
// Garmentoo
//
// Created by MAC on 11/04/22.
//
import UIKit
class SizeCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var outerView:UIView!
@IBOutlet weak var lbl:UILabel!
}
//
// AddressListTVC.swift
// Garmentoo
//
// Created by ANGEL FS on 31/03/22.
//
import UIKit
class AddressListTVC: UITableViewCell {
@IBOutlet weak var menuView: UIView!
@IBOutlet weak var menuBtn: UIButton!
@IBOutlet weak var menuCloseBtn: UIButton!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
//
// FavTableViewCell.swift
// Garmentoo
//
// Created by Vijith on 30/03/22.
//
import UIKit
class FavTableViewCell: UITableViewCell {
@IBOutlet weak var outerView: UIView!
override func awakeFromNib() {
super.awakeFromNib()
setui()
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func setui()
{
self.outerView.backgroundColor = UIColor.viewBg
//
// // Initialization code
// if #available(iOS 13.0, *) {
// outerView.backgroundColor =
// // 1
// UIColor { traitCollection in
// // 2
// switch traitCollection.userInterfaceStyle {
// case .dark:
// // 3
// //return UIColor(white: 0.3, alpha: 1.0)
// return UIColor.darkGray
// default:
// // 4
// //return UIColor(white: 0.7, alpha: 1.0)
// return UIColor.tabcolor
// }
// }
// } else {
// // Fallback on earlier versions
// outerView.backgroundColor = UIColor.tabcolor
// }
}
}
//
// ItemsListTableViewCell.swift
// Garmentoo
//
// Created by Vijith on 30/03/22.
//
import UIKit
protocol collectionCellselect
{
func navigateAction(index:Int)
}
class ItemsListTableViewCell: UITableViewCell {
var parent: UIViewController?
var delegate: collectionCellselect?
@IBOutlet weak var headTitle: UILabel!
@IBOutlet weak var seeAllBtn:UIButton!
@IBOutlet weak var allitemsCollectionView: UICollectionView!
let margin: CGFloat = 10
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
allitemsCollectionView.delegate = self
allitemsCollectionView.dataSource = self
flowlayout()
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
func flowlayout()
{
guard let collectionView = allitemsCollectionView, let flowLayout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout else { return }
flowLayout.minimumInteritemSpacing = margin
flowLayout.minimumLineSpacing = margin
flowLayout.sectionInset = UIEdgeInsets(top: margin, left: margin, bottom: margin, right: margin)
}
}
extension ItemsListTableViewCell : UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout{
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 5
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "allitemscell", for: indexPath) as! AllItemsCollectionViewCell
return cell
// // change the image height and ratio to adjust cell size
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "ProductDetailVC") as! ProductDetailVC
nextVc.hidesBottomBarWhenPushed = true
parent?.navigationController!.pushViewController(nextVc, animated: true)
// self.delegate?.navigateAction(index: indexPath.row)
}
/*
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let noOfCellsInRow = 2
let flowLayout = collectionViewLayout as! UICollectionViewFlowLayout
let totalSpace = flowLayout.sectionInset.left
+ flowLayout.sectionInset.right
+ (flowLayout.minimumInteritemSpacing * CGFloat(noOfCellsInRow - 1))
let size = Int((collectionView.bounds.width - totalSpace ) / CGFloat(noOfCellsInRow))
return CGSize(width: size , height: (size + 50) )
}
*/
func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: 150, height: 190)
}
/*
func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
return 8.0
}
func collectionView(_ collectionView: UICollectionView, layout
collectionViewLayout: UICollectionViewLayout,
minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 8.0
}
*/
}
//
// MyAddressTableViewCell.swift
// Garmentoo
//
// Created by Vijith on 07/04/22.
//
import UIKit
class MyAddressTableViewCell: UITableViewCell {
@IBOutlet weak var outerview:UIView!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
outerview.backgroundColor = UIColor.viewBg
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
//
// MyCartTableViewCell.swift
// Garmentoo
//
// Created by Vijith on 31/03/22.
//
import UIKit
import Cosmos
class MyCartTableViewCell: UITableViewCell {
@IBOutlet weak var ratingsView: CosmosView!
@IBOutlet weak var outerView: UIView!
override func awakeFromNib() {
super.awakeFromNib()
setui()
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func setui(){
self.outerView.backgroundColor = UIColor.viewBg
// // Initialization code
// if #available(iOS 13.0, *) {
// self.outerView.backgroundColor =
// // 1
// UIColor { traitCollection in
// // 2
// switch traitCollection.userInterfaceStyle {
// case .dark:
// // 3
// //return UIColor(white: 0.3, alpha: 1.0)
// return UIColor.darkGray
// default:
// // 4
// //return UIColor(white: 0.7, alpha: 1.0)
// return UIColor.tabcolor
// }
// }
// } else {
// // Fallback on earlier versions
// self.outerView.backgroundColor = UIColor.tabcolor
// }
}
}
/*
class MyCartItemsTableViewCell: UITableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
*/
//
// MyCartItemsTableViewCell.swift
// Pods
//
// Created by Vijith on 07/04/22.
//
import UIKit
class MyOrderItemsTableViewCell: UITableViewCell {
@IBOutlet weak var img: UIImageView!
@IBOutlet weak var deliverTitleLabel: UILabel!
@IBOutlet weak var trackOrderBtn: UIButton!
@IBOutlet weak var outerView:UIView!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
// let views = [img, deliverTitleLabel,trackOrderBtn]
setui()
// views.forEach {$0?.startShimmeringAnimation()}
//
// DispatchQueue.main.asyncAfter(deadline: .now()+3) {
// views.forEach {$0?.stopShimmeringAnimation()}
// }
self.deliverTitleLabel.textColor = UIColor.textcolor1
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func setui()
{
self.outerView.backgroundColor = UIColor.viewBg
}
}
//
// NotificationsTableViewCell.swift
// Garmentoo
//
// Created by Vijith on 08/04/22.
//
import UIKit
class NotificationsTableViewCell: UITableViewCell {
@IBOutlet weak var outerview:UIView!
@IBOutlet weak var title:UILabel!
@IBOutlet weak var subtitle:UILabel!
@IBOutlet weak var content:UILabel!
@IBOutlet weak var enableDisableBtn: UIButton!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
outerview.backgroundColor = UIColor.viewBg
// content.textColor = UIColor.textcolor1
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
//
// OrderDetailListTVC.swift
// Garmentoo
//
// Created by Vijith on 20/04/22.
//
import UIKit
class OrderDetailListTVC: UITableViewCell {
@IBOutlet weak var addReviewView: UIView!
@IBOutlet weak var addReviewBtn: UIButton!
@IBOutlet weak var outerView: UIView!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
outerView.backgroundColor = UIColor.viewBg
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
//
// OrderReviewTableViewCell.swift
//
//
// Created by MAC on 11/04/22.
//
import UIKit
class OrderReviewTableViewCell: UITableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
//
// ReviewsTableViewCell.swift
// Garmentoo
//
// Created by MAC on 11/04/22.
//
import UIKit
import Cosmos
class ReviewsTableViewCell: UITableViewCell {
@IBOutlet weak var ratingsView: CosmosView!
@IBOutlet weak var reviewText: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
//
// SettingsTableViewCell.swift
// Garmentoo
//
// Created by Vijith on 30/03/22.
//
import UIKit
class SettingsTableViewCell: UITableViewCell {
@IBOutlet weak var outerView:UIView!
@IBOutlet weak var img: UIImageView!
@IBOutlet weak var lbl: UILabel!
@IBOutlet weak var notifBtn: UIButton!
@IBOutlet weak var downImg: UIImageView!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
setui()
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func setui()
{
self.outerView.backgroundColor = UIColor.viewBg
// // Initialization code
// if #available(iOS 13.0, *) {
// self.outerView.backgroundColor =
// // 1
// UIColor { traitCollection in
// // 2
// switch traitCollection.userInterfaceStyle {
// case .dark:
// // 3
// //return UIColor(white: 0.3, alpha: 1.0)
// return UIColor.darkGray
// default:
// // 4
// //return UIColor(white: 0.7, alpha: 1.0)
// return UIColor.tabcolor
// }
// }
// } else {
// // Fallback on earlier versions
// self.outerView.backgroundColor = UIColor.tabcolor
// }
}
}
class SettingsHeaderTableViewCell: UITableViewCell {
@IBOutlet weak var lbl: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
//
// HomeCategCollectionViewCell.swift
// Garmentoo
//
// Created by Vijith on 26/05/22.
//
import UIKit
class HomeCategCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var img:UIImageView!
@IBOutlet weak var titleText:UILabel!
override func setNeedsLayout() {
}
}
//
// AddAddressVC2.swift
// Garmentoo
//
// Created by Vijith on 20/04/22.
//
import UIKit
class AddAddressVC2: UIViewController {
@IBOutlet weak var nameTF:UITextField!
@IBOutlet weak var add1TF:UITextField!
@IBOutlet weak var add2TF:UITextField!
@IBOutlet weak var pinTF:UITextField!
@IBOutlet weak var landmarkTF:UITextField!
@IBOutlet weak var headerTitle:UILabel!
let padding : CGFloat = 15.0
var currentName = ""
var currentAddress = ""
var header = "Add Address"
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
setui()
}
func setui()
{
let textFields = [nameTF,add1TF,add2TF,pinTF,landmarkTF]
// self.nameTF.setLeftPaddingPoints(padding)
// self.add1TF.setLeftPaddingPoints(padding)
// self.add2TF.setLeftPaddingPoints(padding)
// self.pinTF.setLeftPaddingPoints(padding)
// self.landmarkTF.setLeftPaddingPoints(padding)
textFields.forEach {$0?.setLeftPaddingPoints(padding)}
textFields.forEach{
$0?.backgroundColor = UIColor.viewBg
}
self.nameTF.text = self.currentName
self.add1TF.text = self.currentAddress
self.headerTitle.text = header
}
@IBAction func OnTapSubmitBtn(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
@IBAction func OnTapBackBtn(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
}
//
// AddOrderReviewVC.swift
// Garmentoo
//
// Created by MAC on 11/04/22.
//
import UIKit
class AddOrderReviewVC: UIViewController, UITextViewDelegate,UIImagePickerControllerDelegate, UINavigationControllerDelegate {
@IBOutlet weak var reviewBox:UITextView!
@IBOutlet weak var imageCollectionView: UICollectionView!
@IBOutlet weak var img: UIImageView!
@IBOutlet weak var previewView: UIView!
@IBOutlet weak var previewViewHeight: NSLayoutConstraint!
var images = [UIImage]()
var picker = UIImagePickerController()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
self.reviewBox.text = "Write an enquiry"
self.reviewBox.textColor = UIColor.lightGray
ShowPreviewView()
let longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPressed(longPressGesture:)))
longPressGesture.minimumPressDuration = 0.5
self.imageCollectionView.addGestureRecognizer(longPressGesture)
}
func textViewDidBeginEditing(_ textView: UITextView)
{
if textView.textColor == UIColor.lightGray {
textView.text = nil
textView.textColor = UIColor.black
}
}
@IBAction func onTapBackBtn(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
@IBAction func OnTapAddImage(_ sender: Any) {
addImage()
}
func ShowPreviewView()
{
if (images.count == 0) {
self.previewView.isHidden = true
self.previewViewHeight.constant = 0
}
else
{
self.previewView.isHidden = false
self.previewViewHeight.constant = 100
}
}
}
extension AddOrderReviewVC:UICollectionViewDelegate,UICollectionViewDataSource
{
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return images.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "imagecell", for: indexPath) as! ImageCollectionViewCell
cell.imgView.image = images[indexPath.row]
return cell
}
}
extension AddOrderReviewVC
{
func addImage()
{
let alert:UIAlertController=UIAlertController(title: "Choose Image", message: nil, preferredStyle: UIAlertController.Style.actionSheet)
let cameraAction = UIAlertAction(title: "Camera", style: .default)
{
UIAlertAction in
self.openCamera()
}
let gallaryAction = UIAlertAction(title: "Gallery", style: .default)
{
UIAlertAction in
self.openGallery()
}
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)
{
UIAlertAction in
}
// Add the actions
picker.delegate = self
alert.addAction(cameraAction)
alert.addAction(gallaryAction)
alert.addAction(cancelAction)
self.present(alert, animated: true, completion: nil)
}
func openCamera(){
if(UIImagePickerController .isSourceTypeAvailable(UIImagePickerController.SourceType.camera)){
picker.sourceType = UIImagePickerController.SourceType.camera
self .present(picker, animated: true, completion: nil)
}else{
let alert = UIAlertView()
alert.title = "Warning"
alert.message = "You don't have camera"
alert.addButton(withTitle: "OK")
alert.show()
}
}
func openGallery(){
picker.sourceType = UIImagePickerController.SourceType.photoLibrary
self.present(picker, animated: true, completion: nil)
}
@objc func longPressed(longPressGesture: UILongPressGestureRecognizer)
{
let p = longPressGesture.location(in: self.imageCollectionView)
let indexPath = self.imageCollectionView.indexPathForItem(at: p)
if indexPath == nil {
print("Long press on table view, not row.")
} else if longPressGesture.state == UIGestureRecognizer.State.began {
let alert = UIAlertController(title: "Alert", message: "Are you sure you want to delete the selected image?", preferredStyle: .alert)
let okAction = UIAlertAction(title: "OK", style: .default) { (action) in
self.images.remove(at: indexPath!.row)
self.ShowPreviewView()
self.imageCollectionView.reloadData()
}
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
alert.addAction(okAction)
alert.addAction(cancelAction)
self.present(alert, animated: true, completion: nil)
}
}
//MARK:UIImagePickerControllerDelegate
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
picker.dismiss(animated: true, completion: nil)
if let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
self.images.append(image)
// self.img.image = images[0]
self.ShowPreviewView()
self.imageCollectionView.reloadData()
}
}
func imagePickerControllerDidCancel(picker: UIImagePickerController){
print("picker cancel.")
}
}
//
// EditProfileVC.swift
// Garmentoo
//
// Created by Vijith on 04/04/22.
//
import UIKit
class EditProfileVC: UIViewController {
@IBOutlet weak var imageOuterView:UIView!
@IBOutlet weak var profPic: UIImageView!
@IBOutlet weak var mailTF: UITextField!
@IBOutlet weak var phoneTF: UITextField!
@IBOutlet weak var locationTF: UITextField!
@IBOutlet weak var zipcodeTF: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
setui()
}
func setui()
{
self.imageOuterView.layer.cornerRadius = self.imageOuterView.frame.height / 2
self.profPic.layer.cornerRadius = self.profPic.frame.height / 2
self.mailTF.addBottomBorder()
self.phoneTF.addBottomBorder()
self.locationTF.addBottomBorder()
self.zipcodeTF.addBottomBorder()
}
@IBAction func OnTapBackBtn(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
@IBAction func onTapSaveBtn(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
}
//
// FavouritesVC.swift
// Garmentoo
//
// Created by Vijith on 30/03/22.
//
import UIKit
class FavouritesVC: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
}
extension FavouritesVC: UITableViewDelegate,UITableViewDataSource
{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 5
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "favCell", for: indexPath) as! FavTableViewCell
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 140
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "ProductDetailVC") as! ProductDetailVC
nextVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(nextVc, animated: true)
}
}
// for hiding tabbar when scrolls
extension FavouritesVC:UIScrollViewDelegate{
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if scrollView.panGestureRecognizer.translation(in: scrollView).y < 0{
//scrolling down
//self.scrollBottomConstraint.constant = 0
changeTabBar(hidden: true, animated: true)
}
else{
//scrolling up
// self.scrollBottomConstraint.constant = 20
changeTabBar(hidden: false, animated: true)
}
}
func changeTabBar(hidden:Bool, animated: Bool){
let tabBar = self.tabBarController?.tabBar
let offset = (hidden ? UIScreen.main.bounds.size.height : UIScreen.main.bounds.size.height - (tabBar?.frame.size.height)! )
if offset == tabBar?.frame.origin.y {return}
print("changing origin y position")
let duration:TimeInterval = (animated ? 0.5 : 0.0)
UIView.animate(withDuration: duration,
animations: {tabBar!.frame.origin.y = offset},
completion:nil)
}
}
//
// HomeVC.swift
// Garmentoo
//
// Created by Vijith on 29/03/22.
//
import UIKit
class HomeVC: UIViewController {
@IBOutlet weak var profPic: UIImageView!
@IBOutlet weak var viewTable: UIView!
@IBOutlet weak var table: UITableView!
@IBOutlet weak var viewCollection: UIView!
@IBOutlet weak var itemsCollectionView: UICollectionView!
@IBOutlet weak var categCollectionView:UICollectionView!
// for categ selection
var categ = ["All","Kids","Men","Women"]
var categIndex = 0
let margin: CGFloat = 10
// for categ list
var productType = ["Popular Products","Recommended Products"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func viewWillAppear(_ animated: Bool) {
flowlayout()
flowlayout2()
setui()
selectedView()
}
func flowlayout()
{
guard let collectionView = itemsCollectionView, let flowLayout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout else { return }
flowLayout.minimumInteritemSpacing = margin
flowLayout.minimumLineSpacing = margin
flowLayout.sectionInset = UIEdgeInsets(top: margin, left: margin, bottom: margin, right: margin)
}
func flowlayout2()
{
guard let collectionView = categCollectionView, let flowLayout2 = collectionView.collectionViewLayout as? UICollectionViewFlowLayout else { return }
flowLayout2.minimumInteritemSpacing = margin
flowLayout2.minimumLineSpacing = margin
flowLayout2.sectionInset = UIEdgeInsets(top: margin, left: margin, bottom: margin, right: margin)
}
func setui(){
self.profPic.layer.cornerRadius = self.profPic.frame.height/2
self.table.layer.cornerRadius = 12.0
self.table.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMinXMinYCorner] // Top right corner, Top left corner respectively
self.viewCollection.layer.cornerRadius = 12.0
self.viewCollection.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMinXMinYCorner] // Top right corner, Top left corner respectively
}
func selectedView(){
if (categIndex == 0)
{
self.viewTable.isHidden = false
self.viewCollection.isHidden = true
DispatchQueue.main.async {
self.table.reloadData()
}
}
else{
self.viewTable.isHidden = true
self.viewCollection.isHidden = false
DispatchQueue.main.async {
self.itemsCollectionView.reloadData()
}
}
}
}
extension HomeVC:UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout
{
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
if (collectionView == itemsCollectionView)
{
return 10
}
return categ.count // categ collection view
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if (collectionView == itemsCollectionView)
{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "itemscell", for: indexPath) as! ItemsCollectionViewCell
return cell
}
// if collectionView ==
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "typeCell", for: indexPath) as! CategSelectCVCell
cell.txtLabel.text = categ[indexPath.row]
if (categIndex == indexPath.row)
{
cell.outerView.backgroundColor = UIColor.neonOrange
cell.txtLabel.textColor = UIColor.white
}
else
{
cell.outerView.backgroundColor = UIColor.white
cell.txtLabel.textColor = UIColor.darkGray
}
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if (collectionView == categCollectionView)
{
categIndex = indexPath.row
DispatchQueue.main.async {
self.categCollectionView.reloadData()
}
selectedView()
}
else //if (collectionView == itemsCollectionView)
{
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "ProductDetailVC") as! ProductDetailVC
nextVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(nextVc, animated: true)
}
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
if (collectionView == itemsCollectionView)
{
let noOfCellsInRow = 2
let flowLayout = collectionViewLayout as! UICollectionViewFlowLayout
let totalSpace = flowLayout.sectionInset.left
+ flowLayout.sectionInset.right
+ (flowLayout.minimumInteritemSpacing * CGFloat(noOfCellsInRow - 1))
let size = Int((collectionView.bounds.width - totalSpace ) / CGFloat(noOfCellsInRow))
return CGSize(width: size , height: (size + 50) )
}
let noOfCellsInRow = 4
let flowLayout = collectionViewLayout as! UICollectionViewFlowLayout
let totalSpace = flowLayout.sectionInset.left
+ flowLayout.sectionInset.right
+ (flowLayout.minimumInteritemSpacing * CGFloat(noOfCellsInRow - 1))
let size = Int((collectionView.bounds.width - totalSpace ) / CGFloat(noOfCellsInRow))
return CGSize(width: size , height: 40 )
}
}
extension HomeVC:UITableViewDelegate,UITableViewDataSource{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return productType.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "listTableCell", for: indexPath) as! ItemsListTableViewCell
cell.headTitle.text = productType[indexPath.row]
cell.seeAllBtn.tag = indexPath.row
cell.seeAllBtn.addTarget(self, action: #selector(self.seeAllBtnTap(_:)), for: .touchUpInside)
cell.parent = self
return cell
}
@objc func seeAllBtnTap(_ sender: UIButton?)
{
switch sender?.tag {
case 0:
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "SeeAllItemsVC") as! SeeAllItemsVC
nextVc.hidesBottomBarWhenPushed = true
nextVc.header = productType[sender?.tag ?? 0]
self.navigationController?.pushViewController(nextVc, animated: true)
default:
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "SeeAllItemsVC") as! SeeAllItemsVC
nextVc.hidesBottomBarWhenPushed = true
nextVc.header = productType[sender?.tag ?? 0]
self.navigationController?.pushViewController(nextVc, animated: true)
}
}
}
// to give cell action for collection cell inside table cell
extension HomeVC: collectionCellselect
{
func navigateAction(index: Int) {
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "ProductDetailVC") as! ProductDetailVC
nextVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(nextVc, animated: true)
}
}
//
// ImageListVC.swift
// Garmentoo
//
// Created by MAC on 10/05/22.
//
import UIKit
import ImageViewer_swift
class ImageListVC: UIViewController {
let margin: CGFloat = 0
let imageNames:[String] = [
"dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image","dummy","dummy 3","image",
]
var images: [UIImage] = []
// var images : [UIImage] = [UIImage(named: "dummy"),UIImage(named: "dummy"),UIImage(named: "dummy"),UIImage(named: "dummy"),UIImage(named: "dummy"),UIImage(named: "dummy"),UIImage(named: "dummy"),UIImage(named: "dummy"),UIImage(named: "dummy"),UIImage(named: "dummy"),UIImage(named: "dummy"),UIImage(named: "dummy"),UIImage(named: "dummy"),UIImage(named: "dummy"),UIImage(named: "dummy"),UIImage(named: "dummy"),UIImage(named: "dummy"),UIImage(named: "dummy"),UIImage(named: "dummy"),UIImage(named: "dummy")]
@IBOutlet weak var imageCollection: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
images = self.imageNames.compactMap { UIImage(named: $0)! }
flowlayout()
}
func flowlayout()
{
guard let collectionView = imageCollection, let flowLayout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout else { return }
flowLayout.minimumInteritemSpacing = margin
flowLayout.minimumLineSpacing = margin
flowLayout.sectionInset = UIEdgeInsets(top: margin, left: margin, bottom: margin, right: margin)
}
@IBAction func OnTapBackBtn(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
}
extension ImageListVC:UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout
{
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return images.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "imagecell", for: indexPath) as! ImagesListCollectionViewCell
cell.imgView.image = images[indexPath.row]
// Setup Image Viewer with [UIImage]
cell.imgView.setupImageViewer(
images: images,
initialIndex: indexPath.row)
return cell
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
var noOfCellsInRow = Int()
let screenSize = view.frame.size
if screenSize.width > screenSize.height
{
noOfCellsInRow = 4
}
else
{
noOfCellsInRow = 3
}
let flowLayout = collectionViewLayout as! UICollectionViewFlowLayout
let totalSpace = flowLayout.sectionInset.left
+ flowLayout.sectionInset.right
+ (flowLayout.minimumInteritemSpacing * CGFloat(noOfCellsInRow - 1))
let size = Int((collectionView.bounds.width - totalSpace ) / CGFloat(noOfCellsInRow))
return CGSize(width: size , height: size )
}
}
//
// ImagesCollectionViewCell.swift
// Garmentoo
//
// Created by MAC on 10/05/22.
//
import UIKit
class ImagesListCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var imgView:UIImageView!
}
//
// LoginPopVC.swift
// Garmentoo
//
// Created by Vijith on 19/04/22.
//
import UIKit
class LoginPopVC: UIViewController {
@IBOutlet weak var outerView: UIView!
@IBOutlet weak var mobileText: UITextField!
@IBOutlet weak var mailText: UITextField!
@IBOutlet weak var nameText: UITextField!
@IBOutlet weak var proceedBtnOutlet: UIButton!
@IBOutlet weak var signupHeaderLabel: UILabel!
@IBOutlet weak var signupBodyLabel: UILabel!
var isMobileEntered = true
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
setui()
}
func setui(){
self.outerView.layer.cornerRadius = 20
self.outerView.layer.maskedCorners = [.layerMinXMinYCorner,.layerMaxXMinYCorner]
self.outerView.backgroundColor = UIColor.viewBg
}
@IBAction func proceedBtnAction(_ sender: UIButton) {
if self.proceedBtnOutlet.titleLabel?.text == "Proceed"
{
if self.mobileText.text?.count == 10
{
self.mailText.isHidden = false
self.nameText.isHidden = false
self.mobileText.isUserInteractionEnabled = false
self.proceedBtnOutlet.setTitle("Signup", for: .normal)
self.signupHeaderLabel.text = "SignUp"
}
else
{
self.mobileText.text = ""
self.mobileText.isUserInteractionEnabled = true
self.mobileText.placeholder = "Enter OTP"
self.proceedBtnOutlet.setTitle("Verify", for: .normal)
self.signupHeaderLabel.text = "OTP Verification"
}
}
else if self.proceedBtnOutlet.titleLabel?.text == "Signup"
{
self.mobileText.text = ""
self.mobileText.isUserInteractionEnabled = true
self.mobileText.placeholder = "Enter OTP"
self.mailText.isHidden = true
self.nameText.isHidden = true
self.proceedBtnOutlet.setTitle("Verify", for: .normal)
self.signupHeaderLabel.text = "OTP Verification"
}
else if self.proceedBtnOutlet.titleLabel?.text == "Verify"
{
self.dismiss(animated: false, completion: nil)
}
}
@IBAction func closeBtnTapped(_ sender: Any) {
self.dismiss(animated: false, completion: nil)
}
}
//
// MyCartVC.swift
// Garmentoo
//
// Created by Vijith on 31/03/22.
//
import UIKit
class MyCartVC: UIViewController {
@IBOutlet weak var bottomView:UIView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func viewWillAppear(_ animated: Bool) {
setui()
}
@IBAction func OnTapPayments(_ sender: Any) {
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "MyAddressVC")as! MyAddressVC
nextVc.isFromCart = true
nextVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(nextVc, animated: true)
}
}
extension MyCartVC: UITableViewDelegate,UITableViewDataSource
{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 5
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cartCell", for: indexPath) as! MyCartTableViewCell
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 140
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "ProductDetailVC") as! ProductDetailVC
nextVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(nextVc, animated: true)
}
// for swpe to delete function
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let deleteAction = UIContextualAction(style: .destructive, title: "") { (contextualAction, view, boolValue) in
self.deleteData(at: indexPath)
}
// deleteAction.backgroundColor = UIColor(patternImage: UIImage(named: "delete_background")!)
// let editAction = UIContextualAction(style: .normal, title: "Edit") { (contextualAction, view, boolValue) in
// self.editData(at: indexPath)
// }
// editAction.backgroundColor = .purple
deleteAction.image = UIImage(named: "delete1")
deleteAction.backgroundColor = UIColor.red
let swipeActions = UISwipeActionsConfiguration(actions: [deleteAction])
return swipeActions
}
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
}
func deleteData(at indexPath: IndexPath) {
print(indexPath.row)
}
}
extension MyCartVC
{
func setui(){
bottomView.layer.cornerRadius = 20
bottomView.clipsToBounds = true
bottomView.layer.masksToBounds = false
bottomView.layer.shadowRadius = 4
bottomView.layer.shadowColor = UIColor.tabcolor.cgColor
bottomView.layer.shadowOpacity = 0.4
bottomView.layer.shadowOffset = CGSize(width: 0, height: -1)
bottomView.layer.maskedCorners = [.layerMinXMinYCorner,.layerMaxXMinYCorner]
bottomView.layer.shadowColor = UIColor.red.cgColor
self.bottomView.backgroundColor = UIColor.viewBg
}
}
//
// MyOrdersVC.swift
// Garmentoo
//
// Created by MAC on 06/04/22.
//
import UIKit
class MyOrdersVC: UIViewController {
@IBOutlet weak var categCollectionView:UICollectionView!
@IBOutlet weak var orderListTable: UITableView!
var categ = ["Upcoming","History"]
var categIndex = 0
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
swipeGest()
}
@IBAction func onTapBackBtn(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
func swipeGest()
{
let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(respondToSwipeGesture))
swipeRight.direction = .right
self.orderListTable.addGestureRecognizer(swipeRight)
let swipeLeft = UISwipeGestureRecognizer(target: self, action: #selector(respondToSwipeGesture))
swipeLeft.direction = .left
self.orderListTable.addGestureRecognizer(swipeLeft)
}
@objc func respondToSwipeGesture(gesture: UIGestureRecognizer) {
if let swipeGesture = gesture as? UISwipeGestureRecognizer {
switch swipeGesture.direction {
case .right:
print("Swiped right")
if categIndex != 0
{
categIndex -= 1
DispatchQueue.main.async {
self.orderListTable.layer.rightAnimation(duration: 0.3)
self.categCollectionView.reloadData()
self.orderListTable.reloadWithAnimation()
}
}
case .left:
print("Swiped left")
if categIndex != (categ.count - 1)
{
categIndex += 1
DispatchQueue.main.async {
self.orderListTable.layer.leftAnimation(duration: 0.3)
self.categCollectionView.reloadData()
self.orderListTable.reloadWithAnimation()
}
}
default:
break
}
}
}
}
// collection view for categ select
extension MyOrdersVC : UICollectionViewDelegate,UICollectionViewDataSource
{
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return categ.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "orderCateg", for: indexPath) as! MyOrderCategCollectionViewCell
cell.lbl.text = categ[indexPath.row]
if (categIndex == indexPath.row)
{
cell.outerView.backgroundColor = UIColor.neonOrange
cell.lbl.textColor = UIColor.white
}
else
{
cell.outerView.backgroundColor = UIColor.viewBg
cell.lbl.textColor = UIColor.textcolor1
}
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if !(categIndex == indexPath.row)
{
if (categIndex < indexPath.row) // left transition
{
self.orderListTable.layer.leftAnimation(duration: 0.3)
}
else // right transition
{
self.orderListTable.layer.rightAnimation(duration: 0.3)
}
categIndex = indexPath.row
DispatchQueue.main.async {
self.categCollectionView.reloadData()
// self.orderListTable.reloadData()
self.orderListTable.reloadWithAnimation()
}
}
}
}
// table view for orders list
extension MyOrdersVC:UITableViewDelegate,UITableViewDataSource{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 6
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "orderItems", for: indexPath) as! MyOrderItemsTableViewCell
cell.trackOrderBtn.tag = indexPath.row
cell.trackOrderBtn.addTarget(self, action: #selector(self.trackOrder(_:)), for: .touchUpInside)
if self.categIndex == 1
{
cell.deliverTitleLabel.text = "Delivered On:"
cell.trackOrderBtn.isHidden = true
}
else
{
cell.deliverTitleLabel.text = "Expected Delivery:"
cell.trackOrderBtn.isHidden = false
}
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let destViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "orderDetail") as! OrderDetailPage
destViewController.selectedCatIndex = self.categIndex
destViewController.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(destViewController, animated: true)
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 150
}
@objc func trackOrder(_ sender: UIButton?)
{
let destViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "TrackingVC") as! TrackingVC
destViewController.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(destViewController, animated: true)
}
/*
@objc func detailOrder(_ sender: UIButton?)
{
let destViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "orderDetail") as! OrderDetailPage
destViewController.selectedCatIndex = self.categIndex
destViewController.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(destViewController, animated: true)
}
*/
}
//
// NotificationVC.swift
// Garmentoo
//
// Created by Vijith on 08/04/22.
//
import UIKit
class NotificationVC: UIViewController {
@IBOutlet weak var notificationTable: UITableView!
var notifData = [NotificationData]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
notifData = [NotificationData(title: "Your Account", subtitle: "Get notified for account alerts", content: "Important Message Alerts", enabled: false),
NotificationData(title: "Your Recommendations", subtitle: "Receive recommendations based on your shopping history", content: "Personalised Notifications", enabled: false),
NotificationData(title: "Your Shipments", subtitle: "Find out when packages ship & arrive", content: "Shipment Notifications", enabled: false),
NotificationData(title: "Your Garmentoo Community", subtitle: "Receive updates from customer Q&A, Review and More", content: "Community Notifications", enabled: false),
]
}
@objc func notifBtnTap(sender: UIButton){
if(notifData[sender.tag].enabled)
{
notifData[sender.tag].enabled = false
DispatchQueue.main.async {
self.notificationTable.reloadData()
}
}
else
{
notifData[sender.tag].enabled = true
DispatchQueue.main.async {
self.notificationTable.reloadData()
}
}
}
@IBAction func onTapBackBtn(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
}
extension NotificationVC: UITableViewDelegate,UITableViewDataSource
{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return notifData.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "notificationcell", for: indexPath) as! NotificationsTableViewCell
cell.title.text = notifData[indexPath.row].title
cell.subtitle.text = notifData[indexPath.row].subtitle
cell.content.text = notifData[indexPath.row].content
cell.enableDisableBtn.tag = indexPath.row
if notifData[indexPath.row].enabled
{
cell.enableDisableBtn.setImage(UIImage(named: "able"), for: .normal)
}
else
{
cell.enableDisableBtn.setImage(UIImage(named: "disable"), for: .normal)
}
cell.enableDisableBtn.addTarget(self, action: #selector(notifBtnTap(sender:)), for: .touchUpInside)
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
}
struct NotificationData {
var title : String?
var subtitle : String?
var content : String?
var enabled = false
}
//
// OrderDetailPage.swift
// Garmentoo
//
// Created by ANGEL on 20/04/22.
//
import UIKit
class OrderDetailPage: UIViewController {
@IBOutlet weak var statusLabel: UILabel!
@IBOutlet weak var submitBtnOutlet: UIButton!
@IBOutlet weak var ratingReminderView: UIView!
var selectedCatIndex = 0
@IBOutlet weak var itemTable: UITableView!
@IBOutlet weak var tableHeight: NSLayoutConstraint!
@IBOutlet weak var deliverDateLabel: UILabel!
@IBOutlet weak var deliverAddressHeaderLbl: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
if self.selectedCatIndex == 1
{
statusLabel.text = "Delivered"
self.submitBtnOutlet.isHidden = true
self.ratingReminderView.isHidden = false
self.deliverDateLabel.isHidden = false
self.deliverAddressHeaderLbl.text = "Delivered To"
}
else
{
statusLabel.text = "Ongoing"
self.submitBtnOutlet.isHidden = false
self.ratingReminderView.isHidden = true
self.deliverDateLabel.isHidden = true
self.deliverAddressHeaderLbl.text = "Delivery To"
}
}
override func viewWillLayoutSubviews() {
self.tableHeight.constant = self.itemTable.contentSize.height
}
@IBAction func backBtnTapped(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
@IBAction func finalBtnTapped(_ sender: Any) {
if self.submitBtnOutlet.titleLabel?.text == "Track Your Order"
{
let destViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "TrackingVC") as! TrackingVC
destViewController.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(destViewController, animated: true)
}
}
}
extension OrderDetailPage : UITableViewDelegate, UITableViewDataSource
{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "orderDetailList")as! OrderDetailListTVC
if self.selectedCatIndex == 0
{
cell.addReviewView.isHidden = true
}
else
{
cell.addReviewView.isHidden = false
}
cell.addReviewBtn.addTarget(self, action: #selector(reviewOrder(_:)), for: .touchUpInside)
return cell
}
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
viewWillLayoutSubviews()
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 140
}
@objc func reviewOrder(_ sender: UIButton?)
{
let destViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "AddOrderReviewVC") as! AddOrderReviewVC
destViewController.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(destViewController, animated: true)
}
}
//
// OrderReviewVC.swift
// Garmentoo
//
// Created by Vijith on 11/04/22.
//
import UIKit
class OrderReviewVC: UIViewController {
@IBOutlet weak var itemsTableView: UITableView!
@IBOutlet weak var tableheight: NSLayoutConstraint!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func viewWillLayoutSubviews() {
self.tableheight.constant = self.itemsTableView.contentSize.height
}
@IBAction func onTapBackBtn(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
@IBAction func OnTapPlaceOrder(_ sender: Any) {
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "OrderSuccessVC")as! OrderSuccessVC
nextVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(nextVc, animated: true)
}
}
extension OrderReviewVC:UITableViewDelegate,UITableViewDataSource{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "itemcell", for: indexPath) as! OrderReviewTableViewCell
return cell
}
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
viewWillLayoutSubviews()
}
}
//
// OrderSuccessVC.swift
// Garmentoo
//
// Created by MAC on 11/04/22.
//
import UIKit
class OrderSuccessVC: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func OnTapPlaceOrder(_ sender: Any) {
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "TabVC")as! TabVC
// nextVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(nextVc, animated: true)
}
}
//
// ProfileVC.swift
// Garmentoo
//
// Created by Vijith on 24/03/22.
//
import UIKit
class ProfileVC: UIViewController {
@IBOutlet weak var profPic: UIImageView!
@IBOutlet weak var textFieldView1: UIView!
@IBOutlet weak var textFieldView2: UIView!
@IBOutlet weak var textFieldView3: UIView!
@IBOutlet weak var textFieldView4: UIView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
setui()
}
func setui(){
self.profPic.layer.cornerRadius = self.profPic.frame.height/2
let textFieldViews = [textFieldView1, textFieldView2,textFieldView3,textFieldView4]
textFieldViews.forEach {$0?.backgroundColor = UIColor.viewBg}
}
@IBAction func OnTapBackBtn(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
@IBAction func OnTapEditBtn(_ sender: Any) {
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "editprofile")as! EditProfileVC
nextVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(nextVc, animated: true)
}
@IBAction func starBtm(_ sender: Any) {
AppInstance.showLoader()
}
@IBAction func stopBtn(_ sender: Any) {
AppInstance.hideLoader()
}
}
//
// SeeAllItemsVC.swift
// Garmentoo
//
// Created by Vijith on 03/05/22.
//
import UIKit
class SeeAllItemsVC: UIViewController {
let margin: CGFloat = 10
@IBOutlet weak var headerTitle:UILabel!
@IBOutlet weak var itemsCollectionView:UICollectionView!
var header = ""
let dummyImages = [UIImage(named: "Garmentoo Bodycon"),UIImage(named: "Garmentoo jeans"),UIImage(named: "Garmentoo Kurta"),UIImage(named: "Garmentoo Palazzos"),UIImage(named: "Garmentoo Bodycon"),UIImage(named: "Garmentoo jeans"),UIImage(named: "Garmentoo Kurta"),UIImage(named: "Garmentoo Palazzos"),UIImage(named: "Garmentoo Bodycon"),UIImage(named: "Garmentoo jeans"),UIImage(named: "Garmentoo Kurta"),UIImage(named: "Garmentoo Palazzos"),UIImage(named: "Garmentoo Bodycon"),UIImage(named: "Garmentoo jeans"),UIImage(named: "Garmentoo Kurta"),UIImage(named: "Garmentoo Palazzos")]
let dummyNames = ["Garmentoo Bodycon","Garmentoo jeans","Garmentoo Kurta","Garmentoo Palazzos","Garmentoo Bodycon","Garmentoo jeans","Garmentoo Kurta","Garmentoo Palazzos","Garmentoo Bodycon","Garmentoo jeans","Garmentoo Kurta","Garmentoo Palazzos","Garmentoo Bodycon","Garmentoo jeans","Garmentoo Kurta","Garmentoo Palazzos"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
flowlayout()
headerTitle.text = header
setui()
}
@IBAction func OnTapBackBtn(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
func flowlayout()
{
guard let collectionView = itemsCollectionView, let flowLayout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout else { return }
flowLayout.minimumInteritemSpacing = margin
flowLayout.minimumLineSpacing = margin
flowLayout.sectionInset = UIEdgeInsets(top: margin, left: margin, bottom: margin, right: margin)
}
func setui()
{
self.itemsCollectionView.backgroundColor = UIColor.viewBg
}
}
extension SeeAllItemsVC:UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout
{
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return dummyNames.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "allitemscell", for: indexPath) as! SeeAllItemsCollectionViewCell
cell.pic.image = dummyImages[indexPath.row]
cell.product.text = dummyNames[indexPath.row]
return cell
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let noOfCellsInRow = 2
let flowLayout = collectionViewLayout as! UICollectionViewFlowLayout
let totalSpace = flowLayout.sectionInset.left
+ flowLayout.sectionInset.right
+ (flowLayout.minimumInteritemSpacing * CGFloat(noOfCellsInRow - 1))
let size = Int((collectionView.bounds.width - totalSpace ) / CGFloat(noOfCellsInRow))
return CGSize(width: size , height: (size + 50) )
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "ProductDetailVC") as! ProductDetailVC
nextVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(nextVc, animated: true)
}
}
//
// SettingsVC.swift
// Garmentoo
//
// Created by Vijith on 30/03/22.
//
import UIKit
struct settingsData
{
var action = [Int]()
var title = String()
var sectionData = [String]()
var image = [String]()
}
class SettingsVC: UIViewController {
@IBOutlet weak var settingsTable: UITableView!
var settings = [settingsData]()
// var settingsTitle = ["Notification","Change Address","My Purchases","My Wallet","Logout"]
// var settingsIcons = [UIImage(named: "notification"),UIImage(named: "location"),UIImage(named: "purchase"),UIImage(named: "wallet"),UIImage(named: "logout"),]
var isNotification = false
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
settings = [settingsData(action:[0,1] , title: "Account", sectionData: ["View Profile","My Orders"],image: ["profile","purchase"]),
settingsData(action: [2], title: "Notifications", sectionData: ["Notification"], image: ["notification"]),
settingsData(action: [1,1], title: "More", sectionData: ["Address Management","Privacy Policy"], image: ["location","privacy"])
]
}
@objc func notifBtnTap(sender: UIButton){
isNotification = !isNotification
DispatchQueue.main.async {
self.settingsTable.reloadData()
}
}
/*
func moveToVC(section:Int,index:Int)
{
switch section {
case 0:
switch index {
case 0:
//go to profile page
default:
//go to orders page
}
default:
<#code#>
}
}
*/
}
extension SettingsVC:UITableViewDelegate,UITableViewDataSource
{
func numberOfSections(in tableView: UITableView) -> Int {
settings.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return settings[section].sectionData.count + 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if (indexPath.row == 0)
{
guard let cell = tableView.dequeueReusableCell(withIdentifier: "headerCell", for: indexPath) as? SettingsHeaderTableViewCell
else {
return UITableViewCell()
}
cell.lbl.text = settings[indexPath.section].title
return cell
}
else
{
guard let cell = tableView.dequeueReusableCell(withIdentifier: "settingsCell", for: indexPath) as? SettingsTableViewCell
else {
return UITableViewCell()
}
cell.lbl.text = settings[indexPath.section].sectionData[indexPath.row - 1]
cell.img.image = UIImage(named: settings[indexPath.section].image[indexPath.row - 1])
if isNotification {
cell.notifBtn.setImage(UIImage(named: "able"), for: .normal)
}
else
{
cell.notifBtn.setImage(UIImage(named: "disable"), for: .normal)
}
// to set image according to each type
switch (settings[indexPath.section].action[indexPath.row - 1]) {
case 2:
cell.downImg.isHidden = false
// cell.notifBtn.isHidden = false
cell.notifBtn.isHidden = true
case 1:
cell.downImg.isHidden = false
cell.notifBtn.isHidden = true
default:
cell.downImg.isHidden = false
cell.notifBtn.isHidden = true
}
cell.notifBtn.addTarget(self, action: #selector(notifBtnTap(sender:)), for: .touchUpInside)
return cell
}
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if !(indexPath.row == 0)
{
switch indexPath.section {
case 0:
switch indexPath.row {
case 1:
print("profile")
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "ProfileVC")as! ProfileVC
nextVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(nextVc, animated: true)
default:
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "MyOrdersVC")as! MyOrdersVC
nextVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(nextVc, animated: true)
}
case 1 :
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "NotificationVC")as! NotificationVC
nextVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(nextVc, animated: true)
default:
switch (indexPath.row) {
case 1:
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "MyAddressVC")as! MyAddressVC
nextVc.isFromCart = false
nextVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(nextVc, animated: true)
default:
print("123")
}
}
}
}
}
/*
extension SettingsVC:UITableViewDelegate,UITableViewDataSource{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return settingsTitle.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "settingsCell", for: indexPath) as! SettingsTableViewCell
cell.lbl.text = settingsTitle[indexPath.row]
cell.img.image = settingsIcons[indexPath.row]
if isNotification {
cell.notifBtn.setImage(UIImage(named: "radio-button"), for: .normal)
}
else
{
cell.notifBtn.setImage(UIImage(named: "radio-button-2"), for: .normal)
}
// to set image according to each type
switch indexPath.row {
case 0:
cell.downImg.isHidden = true
cell.notifBtn.isHidden = false
case 1,2,3:
cell.downImg.isHidden = false
cell.notifBtn.isHidden = true
default:
cell.downImg.isHidden = true
cell.notifBtn.isHidden = true
}
cell.notifBtn.addTarget(self, action: #selector(notifBtnTap(sender:)), for: .touchUpInside)
return cell
}
@objc func notifBtnTap(sender: UIButton){
isNotification = !isNotification
DispatchQueue.main.async {
self.settingsTable.reloadData()
}
}
}
*/
// for hiding tabbar when scrolls
extension SettingsVC:UIScrollViewDelegate{
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if scrollView.panGestureRecognizer.translation(in: scrollView).y < 0{
//scrolling down
//self.scrollBottomConstraint.constant = 0
changeTabBar(hidden: true, animated: true)
}
else{
//scrolling up
// self.scrollBottomConstraint.constant = 20
changeTabBar(hidden: false, animated: true)
}
}
func changeTabBar(hidden:Bool, animated: Bool){
let tabBar = self.tabBarController?.tabBar
let offset = (hidden ? UIScreen.main.bounds.size.height : UIScreen.main.bounds.size.height - (tabBar?.frame.size.height)! )
if offset == tabBar?.frame.origin.y {return}
print("changing origin y position")
let duration:TimeInterval = (animated ? 0.5 : 0.0)
UIView.animate(withDuration: duration,
animations: {tabBar!.frame.origin.y = offset},
completion:nil)
}
}
//
// SubcategoryCollectionViewCell.swift
// Garmentoo
//
// Created by MAC on 03/06/22.
//
import UIKit
class SubcategoryCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var img:UIImageView!
@IBOutlet weak var titleText:UILabel!
}
//
// TabVC.swift
// Garmentoo
//
// Created by Vijith on 31/05/22.
//
import UIKit
class TabVC: UITabBarController {
// let arrayOfImageNameForUnselectedState = ["home","fav","cart","setting","searchinactive"]
//
let arrayOfImageNameForUnselectedState = ["lightHome","lightFav","lightCart","lightSettings","lightSearch"]
// let arrayOfImageNameForUnselectedStateDark = ["homedark","favdark","cartdark","settingdark","searchdark"]
let arrayOfImageNameForUnselectedStateDark = ["darkHome","darkFav","darkCart","darkSettings","darkSearch"]
// let arrayOfImageNameForSelectedState = ["activeHome","activeFav","cart3","activeSetting","searchactive"]
let arrayOfImageNameForSelectedState = ["activeHome_","activeFav_","activeCart_","activeSettings_","activeSearch_"]
override func viewDidLoad() {
super.viewDidLoad()
setTabBar()
// let titlesArray = ["Home","About Us"]
// Do any additional setup after loading the view.
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
setTabBar()
}
func setTabBar()
{
if let count = self.tabBar.items?.count {
for i in 0...(count-1) {
// for light mode
let imageNameForSelectedState = arrayOfImageNameForSelectedState[i]
// for dark mode
let imageNameForUnselectedStateDark = arrayOfImageNameForUnselectedStateDark[i]
let imageNameForUnselectedState = arrayOfImageNameForUnselectedState[i]
//self.tabBar.items?[i].title = titlesArray[i]
self.tabBar.items?[i].selectedImage = UIImage(named: imageNameForSelectedState )?.withRenderingMode(.alwaysOriginal)
if #available(iOS 13, *) {
switch traitCollection.userInterfaceStyle {
case .dark:
self.tabBar.items?[i].image = UIImage(named: imageNameForUnselectedStateDark )?.withRenderingMode(.alwaysOriginal)
default:
self.tabBar.items?[i].image = UIImage(named: imageNameForUnselectedState )?.withRenderingMode(.alwaysOriginal)
}
}
else{
self.tabBar.items?[i].image = UIImage(named: imageNameForUnselectedState )?.withRenderingMode(.alwaysOriginal)
}
}
}
}
}
//
// TrackingVC.swift
// Garmentoo
//
// Created by MAC on 13/04/22.
//
import UIKit
class TrackingVC: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func OnTapBackBtn(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
//
// Home1VC.swift
// Garmentoo
//
// Created by Vijith on 26/05/22.
//
import UIKit
class Home1VC: UIViewController {
let categ = ["Men","Women","Boys","Girls"]
let categImg = [UIImage(named: "men"),UIImage(named: "women"),UIImage(named: "boy"),UIImage(named: "girl")]
let madeforu = ["New Arrivals","Offers","Discounts"]
let madeforuIcons = [UIImage(named: "newarrivals"),UIImage(named: "offers"),UIImage(named: "discount")]
let dummyImages = [UIImage(named: "Garmentoo Bodycon"),UIImage(named: "garmentoo jeans"),UIImage(named: "Garmentoo Kurta"),UIImage(named: "Garmentoo Palazzos")]
let dummyNames = ["Garmentoo Bodycon","Garmentoo jeans","Garmentoo Kurta","Garmentoo Palazzos"]
@IBOutlet weak var headerHeight:NSLayoutConstraint!
@IBOutlet weak var scrollBottomConstraint: NSLayoutConstraint!
var initialHeaderHeight :CGFloat = 100
@IBOutlet weak var categCV: UICollectionView!
@IBOutlet weak var popularCV: UICollectionView!
@IBOutlet weak var madeForCV: UICollectionView!
@IBOutlet weak var recommendedCV: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func OnTapSeeAllBtn(_ sender: UIButton) {
switch sender.tag {
case 0:
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "SeeAllItemsVC") as! SeeAllItemsVC
nextVc.hidesBottomBarWhenPushed = true
nextVc.header = "Popular Products"
self.navigationController?.pushViewController(nextVc, animated: true)
default:
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "SeeAllItemsVC") as! SeeAllItemsVC
nextVc.hidesBottomBarWhenPushed = true
nextVc.header = "Recommended"
self.navigationController?.pushViewController(nextVc, animated: true)
}
}
}
extension Home1VC:UICollectionViewDelegate,UICollectionViewDataSource
{
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
if (collectionView == recommendedCV)
{
return dummyNames.count
}
if (collectionView == madeForCV)
{
return madeforu.count
}
if (collectionView == popularCV)
{
return dummyNames.count
}
return categ.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if (collectionView == recommendedCV)
{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "recommendedcell", for: indexPath) as! HomeRecommendedCollectionViewCell
cell.img.image = dummyImages[indexPath.row]
cell.name.text = dummyNames[indexPath.row]
return cell
}
if (collectionView == madeForCV)
{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "madecell", for: indexPath) as! HomemadeforyouCollectionViewCell
cell.lbl.text = madeforu[indexPath.row]
cell.img.image = madeforuIcons[indexPath.row]
return cell
}
if (collectionView == popularCV)
{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "popularcell", for: indexPath) as! HomePopularCollectionViewCell
cell.img.image = dummyImages[indexPath.row]
cell.name.text = dummyNames[indexPath.row]
return cell
}
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "categCell", for: indexPath) as! HomeCategCollectionViewCell
cell.titleText.text = categ[indexPath.row]
cell.img.image = categImg[indexPath.row]
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if (collectionView == categCV)
{
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "SubCategoryVC") as! SubCategoryVC
nextVc.header = categ[indexPath.item]
nextVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(nextVc, animated: true)
}
else if(collectionView == madeForCV)
{
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "SubCategoryVC") as! SubCategoryVC
nextVc.header = madeforu[indexPath.item]
nextVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(nextVc, animated: true)
}
else
{
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "ProductDetailVC") as! ProductDetailVC
nextVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(nextVc, animated: true)
}
}
}
extension Home1VC:UICollectionViewDelegateFlowLayout
{
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
if (collectionView == madeForCV)
{
let cellSize = self.view.frame.size
return CGSize(width:
(cellSize.width/3)-15, height: 90)
}
if (collectionView == popularCV) || (collectionView == recommendedCV)
{
return CGSize(width: 160, height: 250)
}
// for categoriesCV
let width = ((collectionView.frame.width - 15) / 5) // 15 because of paddings
print("cell width : \(width)")
return CGSize(width: 80, height: 128)
}
// Distance Between Item Cells
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
if (collectionView == madeForCV)
{
return 5
}
if (collectionView == popularCV)
{
return 10
}
// for categoriesCV,made for you CV
return 20
}
// Cell Margin
// func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
// return UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
// }
}
/*
extension Home1VC:UIScrollViewDelegate
{
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if scrollView.contentOffset.y > 50 {// the value when you want the headerview to hide
view.layoutIfNeeded()
headerViewHeightConstraint.constant = 0
UIView.animate(withDuration: 0.5, delay: 0, options: [.allowUserInteraction], animations: {
self.view.layoutIfNeeded()
}, completion: nil)
}else {
// expand the header
view.layoutIfNeeded()
headerViewHeightConstraint.constant = 100 // Your initial height of header view
UIView.animate(withDuration: 0.5, delay: 0, options: [.allowUserInteraction], animations: {
self.view.layoutIfNeeded()
}, completion: nil)
}
}
}
*/
// for hiding tabbar when scrolls
extension Home1VC:UIScrollViewDelegate{
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if scrollView.panGestureRecognizer.translation(in: scrollView).y < 0{
//scrolling down
//self.scrollBottomConstraint.constant = 0
changeTabBar(hidden: true, animated: true)
}
else{
//scrolling up
// self.scrollBottomConstraint.constant = 20
changeTabBar(hidden: false, animated: true)
}
}
func changeTabBar(hidden:Bool, animated: Bool){
let tabBar = self.tabBarController?.tabBar
let offset = (hidden ? UIScreen.main.bounds.size.height : UIScreen.main.bounds.size.height - (tabBar?.frame.size.height)! )
if offset == tabBar?.frame.origin.y {return}
print("changing origin y position")
let duration:TimeInterval = (animated ? 0.5 : 0.0)
UIView.animate(withDuration: duration,
animations: {tabBar!.frame.origin.y = offset},
completion:nil)
}
}
//
// HomePopularCollectionViewCell.swift
// Garmentoo
//
// Created by Vijith on 27/05/22.
//
import UIKit
class HomePopularCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var outerView: UIView!
@IBOutlet weak var img:UIImageView!
@IBOutlet weak var name:UILabel!
override func setNeedsLayout() {
self.outerView.backgroundColor = UIColor.viewBg
// if #available(iOS 13.0, *) {
// outerView.backgroundColor =
// // 1
// UIColor { traitCollection in
// // 2
// switch traitCollection.userInterfaceStyle {
// case .dark:
// // 3
// //return UIColor(white: 0.3, alpha: 1.0)
// return UIColor.darkGray
// default:
// // 4
// //return UIColor(white: 0.7, alpha: 1.0)
// return UIColor.tabcolor
// }
// }
// } else {
// // Fallback on earlier versions
// outerView.backgroundColor = UIColor.tabcolor
// }
}
}
//
// HomeRecommendedCollectionViewCell.swift
// Garmentoo
//
// Created by Vijith on 27/05/22.
//
import UIKit
class HomeRecommendedCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var outerView: UIView!
@IBOutlet weak var img:UIImageView!
@IBOutlet weak var name:UILabel!
override func setNeedsLayout() {
self.outerView.backgroundColor = UIColor.viewBg
// if #available(iOS 13.0, *) {
// outerView.backgroundColor =
// // 1
// UIColor { traitCollection in
// // 2
// switch traitCollection.userInterfaceStyle {
// case .dark:
// // 3
// //return UIColor(white: 0.3, alpha: 1.0)
// return UIColor.darkGray
// default:
// // 4
// //return UIColor(white: 0.7, alpha: 1.0)
// return UIColor.tabcolor
// }
// }
// } else {
// // Fallback on earlier versions
// outerView.backgroundColor = UIColor.tabcolor
// }
}
}
//
// HomemadeforyouCollectionViewCell.swift
// Garmentoo
//
// Created by Vijith on 27/05/22.
//
import UIKit
class HomemadeforyouCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var img:UIImageView!
@IBOutlet weak var lbl:UILabel!
}
//
// MyAddressVC.swift
//
//
// Created by Vijith on 07/04/22.
//
import UIKit
class MyAddressVC: UIViewController {
@IBOutlet weak var table: UITableView!
@IBOutlet weak var tableHeight: NSLayoutConstraint!
@IBOutlet weak var currentName: UILabel!
@IBOutlet weak var currentAddress: UILabel!
@IBOutlet weak var deliverBtnOutlet: UIButton!
@IBOutlet weak var deliverBtnHeight: NSLayoutConstraint!
@IBOutlet weak var deliverBtnBottom: NSLayoutConstraint!
@IBOutlet weak var topOuterView: UIView!
var isFromCart = false
override func viewDidLoad() {
super.viewDidLoad()
setui()
}
func setui()
{
if self.isFromCart
{
self.deliverBtnOutlet.isHidden = false
self.deliverBtnHeight.constant = 50
self.deliverBtnBottom.constant = 30
}
else
{
self.deliverBtnOutlet.isHidden = true
self.deliverBtnHeight.constant = 0
self.deliverBtnBottom.constant = 0
}
self.topOuterView.backgroundColor = UIColor.viewBg
}
override func viewWillLayoutSubviews() {
// self.tableHeight.constant = self.table.contentSize.height
}
@IBAction func onTapBackBtn(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
@IBAction func OnTapAddBtn(_ sender: Any) {
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "AddAddressVC2")as! AddAddressVC2
nextVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(nextVc, animated: true)
}
@IBAction func deleteBtnTapped(_ sender: Any) {
let alert = UIAlertController(title: "Delete", message: "Do you want to delete the current address", preferredStyle: .alert)
let okAction = UIAlertAction(title: "OK", style: .default) { (action) in
print("Address deleted")
}
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
alert.addAction(okAction)
alert.addAction(cancelAction)
self.present(alert, animated: true, completion: nil)
}
@IBAction func editBtnTapped(_ sender: Any) {
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "AddAddressVC2")as! AddAddressVC2
nextVc.currentName = self.currentName.text ?? ""
nextVc.currentAddress = self.currentAddress.text ?? ""
nextVc.header = "Edit Address"
nextVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(nextVc, animated: true)
}
@IBAction func OnTapDeliverBtn(_ sender: Any) {
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "OrderSuccessVC")as! OrderSuccessVC
nextVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(nextVc, animated: true)
}
}
extension MyAddressVC:UITableViewDelegate,UITableViewDataSource
{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "addresscell", for: indexPath) as! MyAddressTableViewCell
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return max(UITableView.automaticDimension, 85)
}
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
viewWillLayoutSubviews()
}
}
//
// AddressListVC.swift
// Garmentoo
//
// Created by ANGEL FS on 31/03/22.
//
import UIKit
class AddressListVC: UIViewController {
@IBOutlet weak var addressTable: UITableView!
var menuSelectedIndex = 0
override func viewDidLoad() {
super.viewDidLoad()
self.viewLoadingProperties()
}
//Button actions
@IBAction func backBtnTapped(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
}
extension AddressListVC
{
func viewLoadingProperties()
{
self.addressTable.register(UINib(nibName: "AddressListTVC", bundle: nil), forCellReuseIdentifier: "addressListCell")
}
@objc func tableCellMenuAction()
{
}
}
extension AddressListVC : UITableViewDelegate, UITableViewDataSource
{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 5
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "addressListCell")as! AddressListTVC
cell.menuBtn.tag = indexPath.row
cell.menuCloseBtn.tag = indexPath.row
cell.menuBtn.addTarget(self, action: #selector(tableCellMenuAction), for: .touchUpInside)
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 100
}
}
//
// ConfirmAddressVC.swift
// Garmentoo
//
// Created by ANGEL FS on 25/03/22.
//
import UIKit
class ConfirmAddressVC: UIViewController {
@IBOutlet weak var bottomAddressView: UIView!
@IBOutlet weak var bottomEditAddressView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
self.viewLoadingProperties()
}
//Button actions
@IBAction func editBtnTapped(_ sender: Any) {
self.bottomAddressView.isHidden = true
self.bottomEditAddressView.isHidden = false
}
@IBAction func saveAddressTappd(_ sender: Any) {
self.bottomAddressView.isHidden = false
self.bottomEditAddressView.isHidden = true
}
@IBAction func procedBtnAction(_ sender: Any) {
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "TabVC")as! TabVC
self.navigationController?.pushViewController(nextVc, animated: true)
}
@IBAction func OnTapBackBtn(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
}
extension ConfirmAddressVC{
func viewLoadingProperties(){
}
}
//
// OnboardingNavVC.swift
// Garmentoo
//
// Created by ANGEL FS on 25/03/22.
//
import UIKit
class OnboardingNavVC: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
//
// SignUpVC.swift
// Garmentoo
//
// Created by ANGEL FS on 25/03/22.
//
import UIKit
import MJSnackBar
class SignUpVC: UIViewController {
@IBOutlet weak var nameText: UITextField!
@IBOutlet weak var mailText: UITextField!
@IBOutlet weak var mobileText: UITextField!
@IBOutlet weak var maleRadioImage: UIImageView!
@IBOutlet weak var femaleRadioImage: UIImageView!
var snackBar: MJSnackBar!
let validation = Validation()
var genderIndex = 0
override func viewDidLoad() {
super.viewDidLoad()
self.viewLoadingProperties()
}
//Button actions
@IBAction func backBtnTapped(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
@IBAction func signupTapped(_ sender: Any) {
let mob : String = (self.mobileText.text?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines))!
let validMobile = self.validation.validPhoneNumber(phoneNumber: mob)
let validMail = self.validation.validateEmailId(emailID: self.mailText.text ?? "")
// if nameText.text == "" || mailText.text == "" || mobileText.text == ""
// {
// self.showSnackBar(Message: "All fields are mandatory", snackbar: self.snackBar)
// return
//
// }
// else if (validMail == false)
// {
// self.showSnackBar(Message:"Invalid email id" , snackbar: self.snackBar)
// return
// }
// else if (validMobile == false)
// {
// self.showSnackBar(Message:"Invalid mobile number" , snackbar: self.snackBar)
// return
// }
// else if self.genderIndex == 0
// {
// self.showSnackBar(Message:"Please select your gender" , snackbar: self.snackBar)
// return
// }
let sb = UIStoryboard(name: "Onboarding", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "verificationVC")as! VerificationVC
self.navigationController?.pushViewController(nextVc, animated: true)
}
@IBAction func genderBtnTapped(_ sender: UIButton) {
if sender.tag == 1
{
self.genderIndex = 1
self.maleRadioImage.isHighlighted = true
self.femaleRadioImage.isHighlighted = false
}
else
{
self.genderIndex = 1
self.maleRadioImage.isHighlighted = false
self.femaleRadioImage.isHighlighted = true
}
}
}
extension SignUpVC
{
func viewLoadingProperties()
{
self.snackBar = MJSnackBar(onView: self.view)
}
}
extension SignUpVC : UITextFieldDelegate
{
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
if textField == self.nameText
{
self.nameText.resignFirstResponder()
self.mailText.becomeFirstResponder()
}
else if textField == self.mailText
{
self.mailText.resignFirstResponder()
self.mobileText.becomeFirstResponder()
}
else if textField == self.mobileText
{
self.mobileText.resignFirstResponder()
}
return true
}
}
//
// SigninVC.swift
// Garmentoo
//
// Created by ANGEL FS on 24/03/22.
//
import UIKit
import MJSnackBar
class SigninVC: UIViewController {
@IBOutlet weak var mobText: UITextField!
let validation = Validation()
var snackBar: MJSnackBar!
override func viewDidLoad() {
super.viewDidLoad()
self.viewLoadingProperties()
}
//Button Actions
@IBAction func signupPressed(_ sender: Any) {
let sb = UIStoryboard(name: "Onboarding", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "signup")as! SignUpVC
self.navigationController?.pushViewController(nextVc, animated: true)
}
@IBAction func loginTapped(_ sender: Any) {
let mob : String = (self.mobText.text?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines))!
let validMobile = self.validation.validPhoneNumber(phoneNumber: mob)
if mobText.text == ""
{
self.showSnackBar(Message:"Please enter the mobile number" , snackbar: self.snackBar)
return
}
else if (validMobile == false)
{
self.showSnackBar(Message:"Invalid mobile number" , snackbar: self.snackBar)
return
}
let sb = UIStoryboard(name: "Onboarding", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "verificationVC")as! VerificationVC
self.navigationController?.pushViewController(nextVc, animated: true)
}
}
extension SigninVC
{
func viewLoadingProperties()
{
self.snackBar = MJSnackBar(onView: self.view)
self.navigationController?.navigationBar.isHidden = true
}
}
//
// VerificationVC.swift
// Garmentoo
//
// Created by ANGEL FS on 25/03/22.
//
import UIKit
import MJSnackBar
class VerificationVC: UIViewController {
@IBOutlet weak var otpText: UITextField!
@IBOutlet weak var timerLabel: UILabel!
var snackBar: MJSnackBar!
var count = 60
override func viewDidLoad() {
super.viewDidLoad()
self.viewLoadingProperties()
}
//Button actions
@IBAction func verifyBtnTapped(_ sender: Any) {
if self.otpText.text == ""
{
self.showSnackBar(Message:"Enter OTP" , snackbar: self.snackBar)
return
}
let sb = UIStoryboard(name: "Onboarding", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "ConfirmAddressVC")as! ConfirmAddressVC
self.navigationController?.pushViewController(nextVc, animated: true)
}
}
extension VerificationVC
{
func viewLoadingProperties()
{
self.snackBar = MJSnackBar(onView: self.view)
Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(self.update), userInfo: nil, repeats: true)
}
@objc func update() {
if count > 0 {
count -= 1
self.timerLabel.text = count.description
}
}
}
extension VerificationVC : UITextFieldDelegate
{
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
let maxLength = 6
let currentString: NSString = (textField.text ?? "") as NSString
let newString: NSString =
currentString.replacingCharacters(in: range, with: string) as NSString
return newString.length <= maxLength
}
}
//
// SubCategoryVC.swift
// Garmentoo
//
// Created by Vijith on 03/06/22.
//
import UIKit
class SubCategoryVC: UIViewController {
let margin: CGFloat = 10
@IBOutlet weak var headerTitle:UILabel!
@IBOutlet weak var subcategCV:UICollectionView!
// var subcategName = []
// var subcategImage = []
var header = ""
override func viewDidLoad() {
super.viewDidLoad()
flowlayout()
// Do any additional setup after loading the view.
subcategCV.backgroundColor = UIColor.viewBg
headerTitle.text = header
}
func flowlayout()
{
guard let collectionView = subcategCV, let flowLayout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout else { return }
flowLayout.minimumInteritemSpacing = margin
flowLayout.minimumLineSpacing = margin
flowLayout.sectionInset = UIEdgeInsets(top: margin, left: margin, bottom: margin, right: margin)
}
@IBAction func OnTapBackBtn(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
}
extension SubCategoryVC:UICollectionViewDelegate,UICollectionViewDataSource
{
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 5
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "subcategCell", for: indexPath) as! SubcategoryCollectionViewCell
// cell.titleText.text = subcategName[indexPath.row]
// cell.img.image = categImg[indexPath.row]
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let sb = UIStoryboard(name: "Main", bundle: nil)
let nextVc = sb.instantiateViewController(withIdentifier: "ProductDetailVC") as! ProductDetailVC
nextVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(nextVc, animated: true)
}
}
extension SubCategoryVC:UICollectionViewDelegateFlowLayout
{
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let noOfCellsInRow = 3
let flowLayout = collectionViewLayout as! UICollectionViewFlowLayout
let totalSpace = flowLayout.sectionInset.left
+ flowLayout.sectionInset.right
+ (flowLayout.minimumInteritemSpacing * CGFloat(noOfCellsInRow - 1))
let size = Int((collectionView.bounds.width - totalSpace ) / CGFloat(noOfCellsInRow))
return CGSize(width: size , height: (size + 10 ) )
}
}
//
// Colors.swift
// Garmentoo
//
// Created by Vijith on 24/03/22.
//
import Foundation
import UIKit
extension UIColor{
static var tabcolor = UIColor(red: 241/255, green: 241/255, blue: 241/255, alpha: 1)
static var shadeColor = UIColor(red: 0/255, green: 0/255, blue: 0/255, alpha: 0.25)
static var neonOrange = UIColor(red: 250/255, green: 116/255, blue: 101/255, alpha: 1)
static var navBarcolor = UIColor(red: 243/255, green: 244/255, blue: 244/255, alpha: 1)
static var tabbackground: UIColor {
if #available(iOS 13, *) {
return UIColor { (traitCollection: UITraitCollection) -> UIColor in
if traitCollection.userInterfaceStyle == .dark {
return
UIColor(white: 0.2, alpha: 1.0)
} else {
return UIColor.tabcolor
}
}
} else {
return UIColor.tabcolor
}
}
static var viewBg: UIColor {
if #available(iOS 13, *) {
return UIColor { (traitCollection: UITraitCollection) -> UIColor in
if traitCollection.userInterfaceStyle == .dark {
return
UIColor.darkGray
} else {
return UIColor.tabcolor
}
}
} else {
return UIColor.tabcolor
}
}
static var textcolor1: UIColor {
if #available(iOS 13, *) {
return UIColor { (traitCollection: UITraitCollection) -> UIColor in
if traitCollection.userInterfaceStyle == .dark {
return
UIColor.lightGray
} else {
return UIColor.darkGray
}
}
} else {
return UIColor.darkGray
}
}
}
//
// RoundedShadow.swift
// Garmentoo
//
// Created by Vijith on 31/03/22.
//
import Foundation
import UIKit
class RoundShadowView: UIView {
let containerView = UIView()
let cornerRRadius: CGFloat = 12.0
override init(frame: CGRect) {
super.init(frame: frame)
layoutView()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func layoutView() {
// set the shadow of the view's layer
layer.backgroundColor = UIColor.clear.cgColor
layer.shadowColor = UIColor.tabcolor.cgColor
layer.shadowOffset = CGSize(width: 0, height: 0)
layer.shadowOpacity = 0.2
layer.shadowRadius = 4.0
// set the cornerRadius of the containerView's layer
containerView.layer.cornerRadius = cornerRRadius
containerView.layer.masksToBounds = true
addSubview(containerView)
//
// add additional views to the containerView here
//
// add constraints
containerView.translatesAutoresizingMaskIntoConstraints = false
// pin the containerView to the edges to the view
containerView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
containerView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true
containerView.topAnchor.constraint(equalTo: topAnchor).isActive = true
containerView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
}
}
//
// extensions.swift
// Garmentoo
//
// Created by MAC on 24/03/22.
//
import Foundation
import UIKit
import MJSnackBar
// for showing data in table cell with animation
extension UITableView {
func reloadWithAnimation() {
self.reloadData()
let tableViewHeight = self.bounds.size.height
let cells = self.visibleCells
var delayCounter = 0
for cell in cells {
cell.transform = CGAffineTransform(translationX: 0, y: tableViewHeight)
}
for cell in cells {
UIView.animate(withDuration: 1.6, delay: 0.08 * Double(delayCounter),usingSpringWithDamping: 0.6, initialSpringVelocity: 0, options: .curveEaseInOut, animations: {
cell.transform = CGAffineTransform.identity
}, completion: nil)
delayCounter += 1
}
}
}
extension UILabel {
func strikeThrough(_ isStrikeThrough:Bool) {
if isStrikeThrough {
if let lblText = self.text {
let attributeString = NSMutableAttributedString(string: lblText)
attributeString.addAttribute(NSAttributedString.Key.strikethroughStyle, value: NSUnderlineStyle.single.rawValue, range: NSMakeRange(0,attributeString.length))
self.attributedText = attributeString
}
} else {
if let attributedStringText = self.attributedText {
let txt = attributedStringText.string
self.attributedText = nil
self.text = txt
return
}
}
}
}
extension UITextField {
func setLeftPaddingPoints(_ amount:CGFloat){
let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: amount, height: self.frame.size.height))
self.leftView = paddingView
self.leftViewMode = .always
}
func setRightPaddingPoints(_ amount:CGFloat) {
let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: amount, height: self.frame.size.height))
self.rightView = paddingView
self.rightViewMode = .always
}
}
extension UITextField {
func addBottomBorder(){
let bottomLine = CALayer()
bottomLine.frame = CGRect(x: 0, y: self.frame.size.height - 1, width: self.frame.size.width, height: 1)
bottomLine.backgroundColor = UIColor.lightGray.cgColor
borderStyle = .none
layer.addSublayer(bottomLine)
}
}
extension UIImageView {
func enableZoom() {
let pinchGesture = UIPinchGestureRecognizer(target: self, action: #selector(startZooming(_:)))
isUserInteractionEnabled = true
addGestureRecognizer(pinchGesture)
}
@objc
private func startZooming(_ sender: UIPinchGestureRecognizer) {
let scaleResult = sender.view?.transform.scaledBy(x: sender.scale, y: sender.scale)
guard let scale = scaleResult, scale.a > 1, scale.d > 1 else { return }
sender.view?.transform = scale
sender.scale = 1
}
}
extension UIImage {
static func from(color: UIColor) -> UIImage {
let rect = CGRect(x: 0, y: 0, width: 1, height: 1)
UIGraphicsBeginImageContext(rect.size)
let context = UIGraphicsGetCurrentContext()
context!.setFillColor(color.cgColor)
context!.fill(rect)
let img = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return img!
}
}
extension UIView {
func roundCorners(by radius: CGFloat) {
self.layer.cornerRadius = radius
self.layer.masksToBounds = true
}
}
extension UIView {
@IBInspectable
var cornerRadius: CGFloat {
get {
return layer.cornerRadius
}
set {
layer.cornerRadius = newValue
}
}
@IBInspectable
var borderWidth: CGFloat {
get {
return layer.borderWidth
}
set {
layer.borderWidth = newValue
}
}
@IBInspectable
var borderColor: UIColor? {
get {
let color = UIColor.init(cgColor: layer.borderColor!)
return color
}
set {
layer.borderColor = newValue?.cgColor
}
}
@IBInspectable
var shadowRadius: CGFloat {
get {
return layer.shadowRadius
}
set {
layer.shadowRadius = newValue
}
}
@IBInspectable
var shadowOffset : CGSize{
get{
return layer.shadowOffset
}set{
layer.shadowOffset = newValue
}
}
@IBInspectable
var shadowColor : UIColor{
get{
return UIColor.init(cgColor: layer.shadowColor!)
}
set {
layer.shadowColor = newValue.cgColor
}
}
@IBInspectable
var shadowOpacity : Float {
get{
return layer.shadowOpacity
}
set {
layer.shadowOpacity = newValue
}
}
}
extension UIViewController {
func showSnackBar(Message : String,snackbar : MJSnackBar)
{
let data = MJSnackBarData(withIdentifier: 1, message: Message, andActionMessage: "", objectSaved: nil)
DispatchQueue.main.async {
snackbar.backgroundColor = UIColor.white
//snackbar.actionColorColor = UIColor.black
snackbar.messageFont = UIFont.systemFont(ofSize: 14)
snackbar.messageColor = UIColor.black
snackbar.show(data: data, onView: self.view)
}
}
}
// for transition animations
extension CALayer {
func leftAnimation(duration:CFTimeInterval) {
let animation = CATransition()
animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
animation.duration = duration
animation.type = CATransitionType.push
animation.subtype = CATransitionSubtype.fromRight
self.add(animation, forKey: CATransitionType.push.rawValue)
}
func rightAnimation(duration:CFTimeInterval) {
let animation = CATransition()
animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
animation.duration = duration
animation.type = CATransitionType.push
animation.subtype = CATransitionSubtype.fromLeft
self.add(animation, forKey: CATransitionType.push.rawValue)
}
}
//
// tabBar.swift
// Garmentoo
//
// Created by Vijith on 24/03/22.
//
import UIKit
/*
class CustomTabBar: UITabBar {
override func awakeFromNib() {
super.awakeFromNib()
layer.masksToBounds = false
layer.cornerRadius = 20
layer.maskedCorners = [.layerMinXMinYCorner,.layerMaxXMinYCorner]
layer.shadowColor = UIColor.black.cgColor
layer.shadowRadius = 2
layer.shadowPath = UIBezierPath(roundedRect: self.bounds, cornerRadius: layer.cornerRadius).cgPath
layer.shadowOffset = CGSize(width: 0, height: -1)
layer.shadowOpacity = 1
}
}
*/
@IBDesignable class CustomTabBar: UITabBar {
@IBInspectable var color: UIColor?
@IBInspectable var radii: CGFloat = 20.0
// override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
// addShape()
// }
//
// var background: UIColor {
// if #available(iOS 13, *) {
// return UIColor { (traitCollection: UITraitCollection) -> UIColor in
// if traitCollection.userInterfaceStyle == .dark {
// return
// UIColor(white: 0.2, alpha: 1.0)
// } else {
// return UIColor.tabcolor
// }
// }
// } else {
// return UIColor.tabcolor
//
// }
// }
private var shapeLayer: CALayer?
override func draw(_ rect: CGRect) {
addShape()
}
private func addShape() {
let shapeLayer = CAShapeLayer()
shapeLayer.path = createPath()
shapeLayer.strokeColor = UIColor.gray.withAlphaComponent(0.1).cgColor
// shapeLayer.fillColor = color?.cgColor ?? UIColor.white.cgColor
shapeLayer.fillColor = UIColor.tabbackground.cgColor
shapeLayer.lineWidth = 2
shapeLayer.shadowColor = UIColor.tabcolor.cgColor
shapeLayer.shadowOffset = CGSize(width: 0 , height: -1);
shapeLayer.shadowOpacity = 0.2
shapeLayer.shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: radii).cgPath
if let oldShapeLayer = self.shapeLayer {
layer.replaceSublayer(oldShapeLayer, with: shapeLayer)
} else {
layer.insertSublayer(shapeLayer, at: 0)
}
self.shapeLayer = shapeLayer
}
private func createPath() -> CGPath {
let path = UIBezierPath(
roundedRect: bounds,
byRoundingCorners: [.topLeft, .topRight],
cornerRadii: CGSize(width: radii, height: 0.0))
return path.cgPath
}
override func layoutSubviews() {
super.layoutSubviews()
self.isTranslucent = true
var tabFrame = self.frame
tabFrame.size.height = 65 + (UIApplication.shared.keyWindow?.safeAreaInsets.bottom ?? CGFloat.zero)
tabFrame.origin.y = self.frame.origin.y + ( self.frame.height - 65 - (UIApplication.shared.keyWindow?.safeAreaInsets.bottom ?? CGFloat.zero))
self.layer.cornerRadius = 20
self.layer.maskedCorners = [.layerMinXMinYCorner,.layerMaxXMinYCorner]
self.frame = tabFrame
self.items?.forEach({ $0.titlePositionAdjustment = UIOffset(horizontal: 0.0, vertical: -5.0) })
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>Garmentoo.xcdatamodel</string>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="1" systemVersion="11A491" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithCloudKit="false" userDefinedModelVersionIdentifier="">
<elements/>
</model>
\ No newline at end of file
//
// AppDelegate.swift
// Garmentoo
//
// Created by ANGEL FS on 24/03/22.
//
import UIKit
import CoreData
import IQKeyboardManagerSwift
var AppInstance: AppDelegate!
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
IQKeyboardManager.shared.enable = true
AppInstance = self
/*
self.window = UIWindow(frame: UIScreen.main.bounds)
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Onboarding", bundle: nil)
let exampleViewController = mainStoryboard.instantiateViewController(withIdentifier: "onboardingNavVC") as! SigninVC
self.window?.rootViewController = exampleViewController
self.window?.makeKeyAndVisible()
*/
return true
}
func showLoader()
{
CustomLoader.sharedInstance.startAnimation()
}
func hideLoader()
{
CustomLoader.sharedInstance.stopAnimation()
}
// MARK: UISceneSession Lifecycle
@available(iOS 13.0, *)
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
@available(iOS 13.0, *)
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
// MARK: - Core Data stack
lazy var persistentContainer: NSPersistentContainer = {
/*
The persistent container for the application. This implementation
creates and returns a container, having loaded the store for the
application to it. This property is optional since there are legitimate
error conditions that could cause the creation of the store to fail.
*/
let container = NSPersistentContainer(name: "Garmentoo")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
/*
Typical reasons for an error here include:
* The parent directory does not exist, cannot be created, or disallows writing.
* The persistent store is not accessible, due to permissions or data protection when the device is locked.
* The device is out of space.
* The store could not be migrated to the current model version.
Check the error message to determine what the actual problem was.
*/
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()
// MARK: - Core Data Saving support
func saveContext () {
let context = persistentContainer.viewContext
if context.hasChanges {
do {
try context.save()
} catch {
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
let nserror = error as NSError
fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
}
}
}
}
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "Battery-white.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "Battery.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "Combined Shape-white.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "Combined Shape.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "draw.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "Ellipse 260.pdf",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment