- Added checks and error for the name, username and password - On gender select adding values to the post reg struct. - Handled the interest selection into a array to post to the reg struct - Finalised the Age Select vc with gender select, date select, interest select - Added Avatar API
56 lines
2.0 KiB
Swift
56 lines
2.0 KiB
Swift
//
|
|
// SelectAvatarVM.swift
|
|
// WOKA
|
|
//
|
|
// Created by MacBook Pro on 02/05/24.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class SelectAvatarVM{
|
|
|
|
weak var vc : SelectAvatarVC!
|
|
var avatarData = [AvatarDM.ResultRecords]()
|
|
func initView(){
|
|
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()
|
|
setupCell()
|
|
getAvatarListing()
|
|
}
|
|
|
|
func setupCell(){
|
|
vc.collectionView.register(UINib(nibName: K.CellIdentifier.Authentication.selectAvatarCell, bundle: nil), forCellWithReuseIdentifier: K.CellIdentifier.Authentication.selectAvatarCell)
|
|
vc.collectionView.delegate = self.vc
|
|
vc.collectionView.dataSource = self.vc
|
|
}
|
|
|
|
// MARK: - Get Intrests
|
|
|
|
func getAvatarListing(){
|
|
Utilities.startProgressHUD()
|
|
NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Auth.avatar_listing, method: .get) {(result : Result<BaseResponseModel<AvatarDM>, NetworkManager.APIError>) in
|
|
switch result{
|
|
case .success(let data):
|
|
switch data.success{
|
|
case 0:
|
|
Utilities.dismissProgressHUD()
|
|
self.vc.toast(msg: data.message ?? "Unrecognised error" , time: 2)
|
|
case 1:
|
|
Utilities.dismissProgressHUD()
|
|
if let avatarData = data.data?.result{
|
|
self.avatarData = avatarData
|
|
self.vc.collectionView.reloadData()
|
|
}
|
|
default:
|
|
break
|
|
}
|
|
case .failure(let error):
|
|
Utilities.dismissProgressHUD()
|
|
self.vc.toast(msg: error.localizedDescription, time: 2)
|
|
}
|
|
}
|
|
}
|
|
}
|