2024-05-02 13:20:40 +05:30
|
|
|
//
|
|
|
|
|
// UserIntrestVM.swift
|
|
|
|
|
// WOKA
|
|
|
|
|
//
|
|
|
|
|
// Created by MacBook Pro on 30/04/24.
|
|
|
|
|
//
|
|
|
|
|
|
2024-05-02 19:30:09 +05:30
|
|
|
import UIKit
|
2024-05-02 13:20:40 +05:30
|
|
|
|
|
|
|
|
class UserIntrestVM{
|
|
|
|
|
|
|
|
|
|
weak var vc : UserIntrestVC!
|
2024-05-02 19:30:09 +05:30
|
|
|
var gender = GenderEnum.none
|
2024-05-02 13:20:40 +05:30
|
|
|
|
|
|
|
|
func initView(){
|
2024-05-02 19:30:09 +05:30
|
|
|
setupCell()
|
2024-05-02 13:20:40 +05:30
|
|
|
|
2024-05-02 19:30:09 +05:30
|
|
|
let bottomPadding: CGFloat = 60 // Adjust this value as needed
|
|
|
|
|
|
|
|
|
|
// Get the current content inset
|
|
|
|
|
var contentInset = vc.scrollView.contentInset
|
|
|
|
|
|
|
|
|
|
// Add bottom padding
|
|
|
|
|
contentInset.bottom = bottomPadding
|
|
|
|
|
|
|
|
|
|
// Set the updated content inset
|
|
|
|
|
vc.scrollView.contentInset = contentInset
|
|
|
|
|
|
|
|
|
|
let color1 = #colorLiteral(red: 0.144693464, green: 0.1426281333, blue: 0.6686832905, alpha: 1)
|
|
|
|
|
let color2 = #colorLiteral(red: 0.6901960784, green: 0.2745098039, blue: 0.7568627451, alpha: 1)
|
|
|
|
|
vc.nextBtn.applyGradient(colors: [color1, color2], startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0.8, y: 0))
|
|
|
|
|
vc.nextBtn.roundCorner()
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Set the collectionview height
|
|
|
|
|
*/
|
|
|
|
|
let height = self.vc.collectionView.collectionViewLayout.collectionViewContentSize.height
|
|
|
|
|
self.vc.contentHeight.constant = height
|
|
|
|
|
vc.view.layoutIfNeeded()
|
|
|
|
|
|
|
|
|
|
// Add tap gesture recognizer to the view
|
|
|
|
|
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(boyBtnTapped))
|
|
|
|
|
vc.boyView.addGestureRecognizer(tapGesture)
|
|
|
|
|
|
|
|
|
|
// Add tap gesture recognizer to the view
|
|
|
|
|
let tapGesture2 = UITapGestureRecognizer(target: self, action: #selector(girlBtnTapped))
|
|
|
|
|
vc.girlView.addGestureRecognizer(tapGesture2)
|
|
|
|
|
|
|
|
|
|
setGender()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func setGender(){
|
|
|
|
|
let alphaComp = 0.6
|
|
|
|
|
switch gender{
|
|
|
|
|
case .boy:
|
|
|
|
|
vc.boyView.backgroundColor = UIColor.white
|
|
|
|
|
vc.girlView.backgroundColor = UIColor.white.withAlphaComponent(alphaComp)
|
|
|
|
|
case .girl:
|
|
|
|
|
vc.girlView.backgroundColor = UIColor.white
|
|
|
|
|
vc.boyView.backgroundColor = UIColor.white.withAlphaComponent(alphaComp)
|
|
|
|
|
case .none:
|
|
|
|
|
vc.girlView.backgroundColor = UIColor.white.withAlphaComponent(alphaComp)
|
|
|
|
|
vc.boyView.backgroundColor = UIColor.white.withAlphaComponent(alphaComp)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc func boyBtnTapped() {
|
|
|
|
|
// Apply click effect animation
|
|
|
|
|
gender = .boy
|
|
|
|
|
UIView.animate(withDuration: 0.1, animations: {
|
|
|
|
|
self.vc.boyView.transform = CGAffineTransform(scaleX: 0.9, y: 0.9)
|
|
|
|
|
}) { _ in
|
|
|
|
|
UIView.animate(withDuration: 0.1) {
|
|
|
|
|
self.vc.boyView.transform = .identity
|
|
|
|
|
self.setGender()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc func girlBtnTapped() {
|
|
|
|
|
gender = .girl
|
|
|
|
|
// Apply click effect animation
|
|
|
|
|
UIView.animate(withDuration: 0.1, animations: {
|
|
|
|
|
self.vc.girlView.transform = CGAffineTransform(scaleX: 0.9, y: 0.9)
|
|
|
|
|
}) { _ in
|
|
|
|
|
UIView.animate(withDuration: 0.1) {
|
|
|
|
|
self.vc.girlView.transform = .identity
|
|
|
|
|
self.setGender()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func setupCell(){
|
|
|
|
|
vc.collectionView.register(UINib(nibName: K.CellIdentifier.Authentication.yourIntrestCell, bundle: nil), forCellWithReuseIdentifier: K.CellIdentifier.Authentication.yourIntrestCell)
|
|
|
|
|
vc.collectionView.delegate = self.vc
|
|
|
|
|
vc.collectionView.dataSource = self.vc
|
2024-05-02 13:20:40 +05:30
|
|
|
}
|
|
|
|
|
}
|