Commit e0804213 by Angel FS

Code alignment

parent b60514b6
...@@ -7,38 +7,6 @@ ...@@ -7,38 +7,6 @@
<BreakpointProxy <BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent <BreakpointContent
uuid = "98FD6FBA-C326-4F2A-ADC7-D9A40360911F"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Viciknity/MVC/Controller/RegistrationBuisness2VC.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "159"
endingLineNumber = "159"
landmarkName = "getApiData()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "91CA96AE-E7A5-4FAC-90DE-DA73AF6F13DE"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Viciknity/MVC/Controller/SearchResultVC.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "166"
endingLineNumber = "166"
landmarkName = "getApiData(_:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "81A80411-C588-4931-9A98-A0839615040A" uuid = "81A80411-C588-4931-9A98-A0839615040A"
shouldBeEnabled = "Yes" shouldBeEnabled = "Yes"
ignoreCount = "0" ignoreCount = "0"
......
...@@ -17,15 +17,15 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { ...@@ -17,15 +17,15 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
do { do {
let profile = try UserDefaults.standard.getObject(forKey: "profileModel", castTo: LoginModel.self) let profile = try UserDefaults.standard.getObject(forKey: "profileModel", castTo: LoginModel.self)
SingleTon.sharedInstance.profileModel = profile.data SingleTon.sharedInstance.profileModel = profile.data
SingleTon.sharedInstance.profileModel?.userId = profile.data?.userId SingleTon.sharedInstance.profileModel?.userId = profile.data?.userId
if SingleTon.sharedInstance.profileModel != nil if SingleTon.sharedInstance.profileModel != nil
{ {
guard (scene as? UIWindowScene) != nil else { return } guard (scene as? UIWindowScene) != nil else { return }
let mainSB: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) let mainSB: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let loggedInTabController = mainSB.instantiateViewController(identifier: "tab") let loggedInTabController = mainSB.instantiateViewController(identifier: "tab")
self.window!.rootViewController = loggedInTabController self.window!.rootViewController = loggedInTabController
} }
} catch { } catch {
print(error.localizedDescription) print(error.localizedDescription)
...@@ -34,7 +34,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { ...@@ -34,7 +34,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
} }
func sceneDidDisconnect(_ scene: UIScene) { func sceneDidDisconnect(_ scene: UIScene) {
// Called as the scene is being released by the system. // Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded. // This occurs shortly after the scene enters the background, or when its session is discarded.
......
...@@ -15,7 +15,6 @@ class SingleTon ...@@ -15,7 +15,6 @@ class SingleTon
{ {
static let sharedInstance = SingleTon() static let sharedInstance = SingleTon()
var profileModel : Data1! var profileModel : Data1!
var userCateg = [UserCategories]() var userCateg = [UserCategories]()
var subCateg = [SubCategories]() var subCateg = [SubCategories]()
......
...@@ -9,70 +9,70 @@ ...@@ -9,70 +9,70 @@
import Foundation import Foundation
class Time: Comparable, Equatable { class Time: Comparable, Equatable {
init(_ date: Date) { init(_ date: Date) {
//get the current calender //get the current calender
let calendar = Calendar.current let calendar = Calendar.current
//get just the minute and the hour of the day passed to it //get just the minute and the hour of the day passed to it
let dateComponents = calendar.dateComponents([.hour, .minute], from: date) let dateComponents = calendar.dateComponents([.hour, .minute], from: date)
//calculate the seconds since the beggining of the day for comparisions //calculate the seconds since the beggining of the day for comparisions
let dateSeconds = dateComponents.hour! * 3600 + dateComponents.minute! * 60 let dateSeconds = dateComponents.hour! * 3600 + dateComponents.minute! * 60
//set the varibles //set the varibles
secondsSinceBeginningOfDay = dateSeconds secondsSinceBeginningOfDay = dateSeconds
hour = dateComponents.hour! hour = dateComponents.hour!
minute = dateComponents.minute! minute = dateComponents.minute!
} }
init(_ hour: Int, _ minute: Int) { init(_ hour: Int, _ minute: Int) {
//calculate the seconds since the beggining of the day for comparisions //calculate the seconds since the beggining of the day for comparisions
let dateSeconds = hour * 3600 + minute * 60 let dateSeconds = hour * 3600 + minute * 60
//set the varibles //set the varibles
secondsSinceBeginningOfDay = dateSeconds secondsSinceBeginningOfDay = dateSeconds
self.hour = hour self.hour = hour
self.minute = minute self.minute = minute
} }
var hour : Int var hour : Int
var minute: Int var minute: Int
var date: Date { var date: Date {
//get the current calender //get the current calender
let calendar = Calendar.current let calendar = Calendar.current
//create a new date components. //create a new date components.
var dateComponents = DateComponents() var dateComponents = DateComponents()
dateComponents.hour = hour dateComponents.hour = hour
dateComponents.minute = minute dateComponents.minute = minute
return calendar.date(byAdding: dateComponents, to: Date())! return calendar.date(byAdding: dateComponents, to: Date())!
} }
/// the number or seconds since the beggining of the day, this is used for comparisions /// the number or seconds since the beggining of the day, this is used for comparisions
private let secondsSinceBeginningOfDay: Int private let secondsSinceBeginningOfDay: Int
//comparisions so you can compare times //comparisions so you can compare times
static func == (lhs: Time, rhs: Time) -> Bool { static func == (lhs: Time, rhs: Time) -> Bool {
return lhs.secondsSinceBeginningOfDay == rhs.secondsSinceBeginningOfDay return lhs.secondsSinceBeginningOfDay == rhs.secondsSinceBeginningOfDay
} }
static func < (lhs: Time, rhs: Time) -> Bool { static func < (lhs: Time, rhs: Time) -> Bool {
return lhs.secondsSinceBeginningOfDay < rhs.secondsSinceBeginningOfDay return lhs.secondsSinceBeginningOfDay < rhs.secondsSinceBeginningOfDay
} }
static func <= (lhs: Time, rhs: Time) -> Bool { static func <= (lhs: Time, rhs: Time) -> Bool {
return lhs.secondsSinceBeginningOfDay <= rhs.secondsSinceBeginningOfDay return lhs.secondsSinceBeginningOfDay <= rhs.secondsSinceBeginningOfDay
} }
static func >= (lhs: Time, rhs: Time) -> Bool { static func >= (lhs: Time, rhs: Time) -> Bool {
return lhs.secondsSinceBeginningOfDay >= rhs.secondsSinceBeginningOfDay return lhs.secondsSinceBeginningOfDay >= rhs.secondsSinceBeginningOfDay
} }
static func > (lhs: Time, rhs: Time) -> Bool { static func > (lhs: Time, rhs: Time) -> Bool {
return lhs.secondsSinceBeginningOfDay > rhs.secondsSinceBeginningOfDay return lhs.secondsSinceBeginningOfDay > rhs.secondsSinceBeginningOfDay
} }
......
...@@ -53,6 +53,6 @@ class validation { ...@@ -53,6 +53,6 @@ class validation {
let bool = pinPredicate.evaluate(with: postalCode) as Bool let bool = pinPredicate.evaluate(with: postalCode) as Bool
return bool return bool
} }
} }
...@@ -10,19 +10,21 @@ import UIKit ...@@ -10,19 +10,21 @@ import UIKit
class ForgotPasswordVC: UIViewController,UITextFieldDelegate { class ForgotPasswordVC: UIViewController,UITextFieldDelegate {
var valid = validation() var valid = validation()
@IBOutlet weak var EmailField: UITextField! @IBOutlet weak var EmailField: UITextField!
@IBOutlet weak var PopView: UIView! @IBOutlet weak var PopView: UIView!
@IBOutlet weak var ContinueBtn: UIButton! @IBOutlet weak var ContinueBtn: UIButton!
@IBOutlet weak var activityIndic: UIActivityIndicatorView! @IBOutlet weak var activityIndic: UIActivityIndicatorView!
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
setui() setui()
initializeHideKeyboard() initializeHideKeyboard()
} }
//MARK:- View operations
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
self.addKeyboardObserver() self.addKeyboardObserver()
} }
...@@ -30,28 +32,54 @@ class ForgotPasswordVC: UIViewController,UITextFieldDelegate { ...@@ -30,28 +32,54 @@ class ForgotPasswordVC: UIViewController,UITextFieldDelegate {
override func viewWillDisappear(_ animated: Bool) { override func viewWillDisappear(_ animated: Bool) {
self.removeKeyboardObserver() self.removeKeyboardObserver()
} }
//MARK:- Button actions
@IBAction func OnTapContinueBtn(_ sender: Any) {
let mail : String = (self.EmailField.text?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines))!
if EmailField.text == ""
{
self.displayAlert(message: "Please enter mail id")
return
}
let validmail = valid.validateEmailId(emailID: mail)
if validmail == false
{
self.displayAlert(message: "Please enter valid mail id")
return
}
self.ApiData()
}
@IBAction func OnTapCloseBtn(_ sender: Any) {
self.dismiss(animated: false, completion: nil)
}
}
//MARK:- Extra functions
extension ForgotPasswordVC
{
func initializeHideKeyboard(){ func initializeHideKeyboard(){
//Declare a Tap Gesture Recognizer which will trigger our dismissMyKeyboard() function
let tap: UITapGestureRecognizer = UITapGestureRecognizer( let tap: UITapGestureRecognizer = UITapGestureRecognizer(
target: self, target: self,
action: #selector(dismissMyKeyboard)) action: #selector(dismissMyKeyboard))
//Add this tap gesture recognizer to the parent view
view.addGestureRecognizer(tap) view.addGestureRecognizer(tap)
} }
@objc func dismissMyKeyboard(){ @objc func dismissMyKeyboard(){
//endEditing causes the view (or one of its embedded text fields) to resign the first responder status.
//In short- Dismiss the active keyboard.
view.endEditing(true) view.endEditing(true)
} }
func setui()
{ func setui()
EmailField.layer.cornerRadius = 10.0 {
EmailField.setLeftPaddingPoints(10) EmailField.layer.cornerRadius = 10.0
PopView.clipsToBounds = true EmailField.setLeftPaddingPoints(10)
PopView.layer.cornerRadius = 30 PopView.clipsToBounds = true
PopView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner] PopView.layer.cornerRadius = 30
ContinueBtn.layer.cornerRadius = 10.0 PopView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
ContinueBtn.layer.cornerRadius = 10.0
} }
func ApiData() func ApiData()
{ {
...@@ -81,7 +109,7 @@ func setui() ...@@ -81,7 +109,7 @@ func setui()
DispatchQueue.main.async { DispatchQueue.main.async {
if(finaldata.status == true) if(finaldata.status == true)
{ {
let msg = finaldata.message let msg = finaldata.message
var alert = UIAlertController(title: "Alert", message: msg, preferredStyle: .alert) var alert = UIAlertController(title: "Alert", message: msg, preferredStyle: .alert)
let action = UIAlertAction(title: "Ok", style: .default){ let action = UIAlertAction(title: "Ok", style: .default){
...@@ -91,7 +119,7 @@ func setui() ...@@ -91,7 +119,7 @@ func setui()
alert.addAction(action) alert.addAction(action)
self.present(alert, animated: true, completion: nil) self.present(alert, animated: true, completion: nil)
} }
if(finaldata.status == false) if(finaldata.status == false)
{ {
...@@ -100,26 +128,6 @@ func setui() ...@@ -100,26 +128,6 @@ func setui()
return return
} }
} }
}.resume() }.resume()
}
@IBAction func OnTapContinueBtn(_ sender: Any) {
let mail : String = (self.EmailField.text?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines))!
if EmailField.text == ""
{
self.displayAlert(message: "Please enter mail id")
return
}
let validmail = valid.validateEmailId(emailID: mail)
if validmail == false
{
self.displayAlert(message: "Please enter valid mail id")
return
}
self.ApiData()
}
@IBAction func OnTapCloseBtn(_ sender: Any) {
self.dismiss(animated: false, completion: nil)
} }
} }
...@@ -10,36 +10,55 @@ import UIKit ...@@ -10,36 +10,55 @@ import UIKit
class LocationListVC: UIViewController { class LocationListVC: UIViewController {
var locationData = [locationDetail]()
@IBOutlet weak var activityIndicator: UIActivityIndicatorView! @IBOutlet weak var activityIndicator: UIActivityIndicatorView!
@IBOutlet weak var table: UITableView! @IBOutlet weak var table: UITableView!
@IBOutlet weak var addLocationBtn: UIButton! @IBOutlet weak var addLocationBtn: UIButton!
var locationData = [locationDetail]()
//MARK:- View operations
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
self.addLocationBtn.layer.borderWidth = 1 self.addLocationBtn.layer.borderWidth = 1
self.addLocationBtn.layer.borderColor = UIColor.redShade.cgColor self.addLocationBtn.layer.borderColor = UIColor.redShade.cgColor
} }
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
getLocation() getLocation()
} }
//MARK:- Button actions
@IBAction func backBtnTapped(_ sender: Any) { @IBAction func backBtnTapped(_ sender: Any) {
self.navigationController?.popViewController(animated: true) self.navigationController?.popViewController(animated: true)
} }
@IBAction func addLocationTapped(_ sender: Any) { @IBAction func addLocationTapped(_ sender: Any) {
let navVc = (self.storyboard?.instantiateViewController(identifier: "Addlocation"))!as AddlocationVC let navVc = (self.storyboard?.instantiateViewController(identifier: "Addlocation"))!as AddlocationVC
self.navigationController?.pushViewController(navVc, animated: true) self.navigationController?.pushViewController(navVc, animated: true)
} }
}
//MARK:- TableView delegate and datasource
extension LocationListVC:UITableViewDelegate,UITableViewDataSource
{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return locationData.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! LocationListTableViewCell
cell.deleteBtn.tag = indexPath.row
cell.deleteBtn.addTarget(self, action: #selector(self.deleteLocation), for: .touchUpInside)
cell.lbl.text = locationData[indexPath.row].locationName + " , " + locationData[indexPath.row].addressLine + " , " + locationData[indexPath.row].city
return cell
}
}
//MARK:- Extra functions
extension LocationListVC
{
@objc func deleteLocation(_ sender : UIButton) @objc func deleteLocation(_ sender : UIButton)
{ {
DispatchQueue.main.async { DispatchQueue.main.async {
...@@ -59,7 +78,7 @@ class LocationListVC: UIViewController { ...@@ -59,7 +78,7 @@ class LocationListVC: UIViewController {
} }
guard let data = data, guard let data = data,
let response = response as? HTTPURLResponse, let response = response as? HTTPURLResponse,
error == nil else { // check for fundamental networking error error == nil else {
print("error", error ?? "Unknown error") print("error", error ?? "Unknown error")
return return
} }
...@@ -89,9 +108,6 @@ class LocationListVC: UIViewController { ...@@ -89,9 +108,6 @@ class LocationListVC: UIViewController {
} }
} }
}.resume() }.resume()
} }
...@@ -103,8 +119,6 @@ class LocationListVC: UIViewController { ...@@ -103,8 +119,6 @@ class LocationListVC: UIViewController {
} }
let url = RestApiManager.sharedInstance.baseURL + "userController/getLocations?userId=" + (SingleTon.sharedInstance.profileModel.userId?.description ?? "0") let url = RestApiManager.sharedInstance.baseURL + "userController/getLocations?userId=" + (SingleTon.sharedInstance.profileModel.userId?.description ?? "0")
// let url = "http://54.196.215.154:8080/Prox/userController/getLocations?userId=" + (SingleTon.sharedInstance.profileModel.userId?.description ?? "0")
// let url = RestApiManager.sharedInstance.baseURL + "loginController/login?emailId=" + username.text! + "&password=" + password.text!
let obj = URL(string: url) let obj = URL(string: url)
var request = URLRequest(url: obj!) var request = URLRequest(url: obj!)
request.httpMethod = "GET" request.httpMethod = "GET"
...@@ -120,9 +134,6 @@ class LocationListVC: UIViewController { ...@@ -120,9 +134,6 @@ class LocationListVC: UIViewController {
} }
return return
} }
print(data)
let finaldata = try! JSONDecoder().decode(LocationDetailModel.self, from: data) let finaldata = try! JSONDecoder().decode(LocationDetailModel.self, from: data)
DispatchQueue.main.async { DispatchQueue.main.async {
if(finaldata.status == true) if(finaldata.status == true)
...@@ -139,7 +150,6 @@ class LocationListVC: UIViewController { ...@@ -139,7 +150,6 @@ class LocationListVC: UIViewController {
{ {
let alert = UIAlertController(title: "Alert", message: finaldata.message, preferredStyle: .alert) let alert = UIAlertController(title: "Alert", message: finaldata.message, preferredStyle: .alert)
let action = UIAlertAction(title: "OK", style: .default, handler: {_ in let action = UIAlertAction(title: "OK", style: .default, handler: {_ in
// self.navigationController?.popViewController(animated: false)
}) })
alert.addAction(action) alert.addAction(action)
DispatchQueue.main.async { DispatchQueue.main.async {
...@@ -150,26 +160,7 @@ class LocationListVC: UIViewController { ...@@ -150,26 +160,7 @@ class LocationListVC: UIViewController {
} }
} }
}.resume() }.resume()
} }
}
extension LocationListVC:UITableViewDelegate,UITableViewDataSource
{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return locationData.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! LocationListTableViewCell
cell.deleteBtn.tag = indexPath.row
cell.deleteBtn.addTarget(self, action: #selector(self.deleteLocation), for: .touchUpInside)
cell.lbl.text = locationData[indexPath.row].locationName + " , " + locationData[indexPath.row].addressLine + " , " + locationData[indexPath.row].city
return cell
}
} }
...@@ -12,83 +12,26 @@ class NotificationsVC: UIViewController { ...@@ -12,83 +12,26 @@ class NotificationsVC: UIViewController {
@IBOutlet weak var actiivtyIndicator: UIActivityIndicatorView! @IBOutlet weak var actiivtyIndicator: UIActivityIndicatorView!
@IBOutlet weak var Table1 : UITableView!
var notifData = [Data2]() var notifData = [Data2]()
var details = [OfferData]() var details = [OfferData]()
var OfferDetails : OfferData! var OfferDetails : OfferData!
var campId = [Int]()
var campId = [Int]()
//MARK:- View operations
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
getApiData() getApiData()
} }
@IBOutlet weak var Table1 : UITableView!
func getApiData()
{
DispatchQueue.main.async {
self.actiivtyIndicator.startAnimating()
}
let url = RestApiManager.sharedInstance.baseURL + "pushController/getPushDetails?userId=" + String((SingleTon.sharedInstance.profileModel.userId)!)
let obj = URL(string: url)
var request = URLRequest(url: obj!)
request.httpMethod = "GET"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
URLSession.shared.dataTask(with: request ) { (data , response , error) in
guard let data = data,error == nil else{
print("something wrong")
DispatchQueue.main.async {
self.displayAlert(message: "Please check your internet connection")
self.actiivtyIndicator.stopAnimating()
}
return
}
let finaldata = try! JSONDecoder().decode(Notifmodel.self, from: data)
DispatchQueue.main.async {
self.actiivtyIndicator.stopAnimating()
if(finaldata.status == true)
{
if finaldata.data != nil
{
self.notifData = finaldata.data!
for i in 0...(finaldata.data?.count ?? 0)-1
{
let item = finaldata.data?[i]
if item?.messageType == 1
{
self.notifData.remove(at: i)
self.notifData.insert(item! , at: 0)
}
}
self.Table1.reloadData()
}
// perform segue
}
if(finaldata.status == false){
let msg = finaldata.message
let alert = UIAlertController(title: "Alert", message: finaldata.message, preferredStyle: .alert)
let action = UIAlertAction(title: "OK", style: .default) { (action) in
self.navigationController?.popViewController(animated: true)
}
alert.addAction(action)
self.present(alert, animated: true, completion: nil)
self.displayAlert(message: msg!)
return
}
}
}.resume()
}
@IBAction func OnTapBackBtn(_ sender: Any) { @IBAction func OnTapBackBtn(_ sender: Any) {
self.navigationController?.popViewController(animated: true) self.navigationController?.popViewController(animated: true)
} }
} }
//MARK:- TableView delegate and datasource
extension NotificationsVC : UITableViewDelegate,UITableViewDataSource extension NotificationsVC : UITableViewDelegate,UITableViewDataSource
{ {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
...@@ -109,11 +52,9 @@ extension NotificationsVC : UITableViewDelegate,UITableViewDataSource ...@@ -109,11 +52,9 @@ extension NotificationsVC : UITableViewDelegate,UITableViewDataSource
if notifData[indexPath.row].messageType != 1 if notifData[indexPath.row].messageType != 1
{ {
let destViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "OfferDetail") as! OfferDetailVC let destViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "OfferDetail") as! OfferDetailVC
// destViewController.starFlag = self.OfferDetails.starredFlag ?? 0
destViewController.claim = true destViewController.claim = true
destViewController.OfferDetails = self.details[0] destViewController.OfferDetails = self.details[0]
self.navigationController?.pushViewController(destViewController, animated: true) self.navigationController?.pushViewController(destViewController, animated: true)
} }
else{ else{
let destViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "SearchResult") as! SearchResultVC let destViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "SearchResult") as! SearchResultVC
...@@ -121,7 +62,71 @@ extension NotificationsVC : UITableViewDelegate,UITableViewDataSource ...@@ -121,7 +62,71 @@ extension NotificationsVC : UITableViewDelegate,UITableViewDataSource
destViewController.campId = self.campId destViewController.campId = self.campId
self.navigationController?.pushViewController(destViewController, animated: true) self.navigationController?.pushViewController(destViewController, animated: true)
} }
} }
} }
//MARK:- Extra functions
extension NotificationsVC
{
func getApiData()
{
DispatchQueue.main.async {
self.actiivtyIndicator.startAnimating()
}
let url = RestApiManager.sharedInstance.baseURL + "pushController/getPushDetails?userId=" + String((SingleTon.sharedInstance.profileModel.userId)!)
let obj = URL(string: url)
var request = URLRequest(url: obj!)
request.httpMethod = "GET"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
URLSession.shared.dataTask(with: request ) { (data , response , error) in
guard let data = data,error == nil else{
print("something wrong")
DispatchQueue.main.async {
self.displayAlert(message: "Please check your internet connection")
self.actiivtyIndicator.stopAnimating()
}
return
}
let finaldata = try! JSONDecoder().decode(Notifmodel.self, from: data)
DispatchQueue.main.async {
self.actiivtyIndicator.stopAnimating()
if(finaldata.status == true)
{
if finaldata.data != nil
{
self.notifData = finaldata.data!
for i in 0...(finaldata.data?.count ?? 0)-1
{
let item = finaldata.data?[i]
if item?.messageType == 1
{
self.notifData.remove(at: i)
self.notifData.insert(item! , at: 0)
}
}
self.Table1.reloadData()
}
}
if(finaldata.status == false){
let msg = finaldata.message
let alert = UIAlertController(title: "Alert", message: finaldata.message, preferredStyle: .alert)
let action = UIAlertAction(title: "OK", style: .default) { (action) in
self.navigationController?.popViewController(animated: true)
}
alert.addAction(action)
self.present(alert, animated: true, completion: nil)
self.displayAlert(message: msg!)
return
}
}
}.resume()
}
}
...@@ -30,15 +30,13 @@ class RegistrationBuisness2VC: UIViewController { ...@@ -30,15 +30,13 @@ class RegistrationBuisness2VC: UIViewController {
var subCatArr = ["Restaurants/Catering"] var subCatArr = ["Restaurants/Catering"]
var countryArr = ["United States"] var countryArr = ["United States"]
var valid = validation() var valid = validation()
var textFields: [UITextField] { var textFields: [UITextField] {
return [ zipcodeText, buisnessUrlText , buisnessFacebookText] return [ zipcodeText, buisnessUrlText , buisnessFacebookText]
} }
//MARK:- View operations
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
// Do any additional setup after loading the view.
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.dismissKeyboard (_:))) let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.dismissKeyboard (_:)))
self.view.addGestureRecognizer(tapGesture) self.view.addGestureRecognizer(tapGesture)
} }
...@@ -51,8 +49,6 @@ class RegistrationBuisness2VC: UIViewController { ...@@ -51,8 +49,6 @@ class RegistrationBuisness2VC: UIViewController {
self.removeKeyboardObserver() self.removeKeyboardObserver()
} }
@objc func dismissKeyboard (_ sender: UITapGestureRecognizer) { @objc func dismissKeyboard (_ sender: UITapGestureRecognizer) {
self.scrollInnersView.endEditing(true) self.scrollInnersView.endEditing(true)
} }
...@@ -65,7 +61,6 @@ class RegistrationBuisness2VC: UIViewController { ...@@ -65,7 +61,6 @@ class RegistrationBuisness2VC: UIViewController {
dropDown.selectionAction = dropDown.selectionAction =
{ [unowned self] (index: Int, item: String) in { [unowned self] (index: Int, item: String) in
self.countryText.text = item self.countryText.text = item
self.dropDown.hide() self.dropDown.hide()
} }
} }
...@@ -77,7 +72,6 @@ class RegistrationBuisness2VC: UIViewController { ...@@ -77,7 +72,6 @@ class RegistrationBuisness2VC: UIViewController {
dropDown.selectionAction = dropDown.selectionAction =
{ [unowned self] (index: Int, item: String) in { [unowned self] (index: Int, item: String) in
self.categoryText.text = item self.categoryText.text = item
self.dropDown.hide() self.dropDown.hide()
} }
} }
...@@ -89,10 +83,8 @@ class RegistrationBuisness2VC: UIViewController { ...@@ -89,10 +83,8 @@ class RegistrationBuisness2VC: UIViewController {
dropDown.selectionAction = dropDown.selectionAction =
{ [unowned self] (index: Int, item: String) in { [unowned self] (index: Int, item: String) in
self.subCategoryText.text = item self.subCategoryText.text = item
self.dropDown.hide() self.dropDown.hide()
} }
} }
@IBAction func backBtnTapped(_ sender: Any) { @IBAction func backBtnTapped(_ sender: Any) {
...@@ -101,9 +93,6 @@ class RegistrationBuisness2VC: UIViewController { ...@@ -101,9 +93,6 @@ class RegistrationBuisness2VC: UIViewController {
@IBAction func navTapped(_ sender: Any) { @IBAction func navTapped(_ sender: Any) {
navAction() navAction()
// let navVc = (self.storyboard?.instantiateViewController(identifier: "tab"))! as tab
// self.regitration()
// self.navigationController?.pushViewController(navVc, animated: true)
} }
} }
...@@ -113,12 +102,6 @@ extension RegistrationBuisness2VC ...@@ -113,12 +102,6 @@ extension RegistrationBuisness2VC
{ {
func navAction() func navAction()
{ {
// if buisnessUrlText.text == ""
// {
// self.displayAlert(message: "Please enter valid buisness url")
// return
// }
if zipcodeText.text == "" if zipcodeText.text == ""
{ {
self.displayAlert(message: "Please Enter Valid zipcode") self.displayAlert(message: "Please Enter Valid zipcode")
...@@ -137,8 +120,6 @@ extension RegistrationBuisness2VC ...@@ -137,8 +120,6 @@ extension RegistrationBuisness2VC
RegistrationInputModel.sharedInstance.buissnesssubCategory = self.subCategoryText.text RegistrationInputModel.sharedInstance.buissnesssubCategory = self.subCategoryText.text
RegistrationInputModel.sharedInstance.buissnessUrl = self.buisnessUrlText.text RegistrationInputModel.sharedInstance.buissnessUrl = self.buisnessUrlText.text
RegistrationInputModel.sharedInstance.buissnessFacebook = self.buisnessFacebookText.text RegistrationInputModel.sharedInstance.buissnessFacebook = self.buisnessFacebookText.text
// self.regitration()
self.getApiData() self.getApiData()
} }
...@@ -152,12 +133,12 @@ extension RegistrationBuisness2VC ...@@ -152,12 +133,12 @@ extension RegistrationBuisness2VC
let obj = URL(string: url) let obj = URL(string: url)
var request = URLRequest(url: obj!) var request = URLRequest(url: obj!)
let parameters = "{\"userId\":0,\"name\":\"\(RegistrationInputModel.sharedInstance.name ?? "")\",\"emailId\":\"\(RegistrationInputModel.sharedInstance.mail ?? "")\",\"password\":\"\(RegistrationInputModel.sharedInstance.password ?? "")\",\"birthday\":\"\(RegistrationInputModel.sharedInstance.birthday ?? "")\",\"gender\":\"\(RegistrationInputModel.sharedInstance.gender ?? "")\",\"mobile\":\"\(RegistrationInputModel.sharedInstance.mobile ?? "")\",\"address\":\"\(RegistrationInputModel.sharedInstance.address ?? "")\",\"city\":\"\(RegistrationInputModel.sharedInstance.city ?? "")\",\"state\":\"\(RegistrationInputModel.sharedInstance.state ?? "")\",\"zipcode\":\"\(RegistrationInputModel.sharedInstance.zipcode ?? "")\",\"country\":\"\(RegistrationInputModel.sharedInstance.primaryCountry ?? "")\",\"profilePicture\":\"\(RegistrationInputModel.sharedInstance.profile ?? "")\",\"paymentOption\":null,\"postOffers\":\(RegistrationInputModel.sharedInstance.postOffers ?? true),\"latitude\":0.0,\"longitude\":0.0,\"searchDistance\":\(RegistrationInputModel.sharedInstance.searchRadius ?? 0.0),\"geolocationFlag\":\(RegistrationInputModel.sharedInstance.geolocationFlag ?? true),\"facebookFlag\":\(RegistrationInputModel.sharedInstance.connectMessenger ?? true),\"website\":null,\"userCategories\":[{\"categoryId\":1,\"categoryName\":\"Services\",\"subCategories\":[{\"subCategoryId\":1,\"subCategoryName\":\"Restaurants/Catering\"}]}],\"userType\":\"Business User\",\"businessRegistered\":true,\"acceptNotifications\":\(RegistrationInputModel.sharedInstance.notificationEnabled ?? true),\"businessDetails\":[{\"businessId\":0,\"businessName\":\"\(RegistrationInputModel.sharedInstance.name ?? "")\",\"businessImage\":null,\"businessCategories\":[{\"categoryId\":1,\"categoryName\":\"Services\",\"subCategories\":[{\"subCategoryId\":1,\"subCategoryName\":\"Restaurants/Catering\"}]}],\"businessPhone\":\"\(RegistrationInputModel.sharedInstance.buissnessMobile ?? "")\",\"businessEmail\":\"\(RegistrationInputModel.sharedInstance.buissnessMail ?? "")\",\"businessUrl\":\"\(RegistrationInputModel.sharedInstance.buissnessUrl ?? "")\",\"businessFacebook\":\"\(RegistrationInputModel.sharedInstance.buissnessFacebook ?? "")\",\"businessAddress\":\"\(RegistrationInputModel.sharedInstance.address ?? "")\",\"businessState\":\"\(RegistrationInputModel.sharedInstance.buissnessstate ?? "")\",\"businessCity\":\"\(RegistrationInputModel.sharedInstance.buissnessCity ?? "")\",\"businessCountry\":\"\(RegistrationInputModel.sharedInstance.buissnessCountry ?? "")\",\"businessZipCode\":\"\(RegistrationInputModel.sharedInstance.buissnessZipcode ?? "")\",\"userBusinessRelationId\":\(RegistrationInputModel.sharedInstance.relationId ?? 0),\"userBusinessRelationType\":\"\(RegistrationInputModel.sharedInstance.buissnessRelation ?? "")\"}]}" let parameters = "{\"userId\":0,\"name\":\"\(RegistrationInputModel.sharedInstance.name ?? "")\",\"emailId\":\"\(RegistrationInputModel.sharedInstance.mail ?? "")\",\"password\":\"\(RegistrationInputModel.sharedInstance.password ?? "")\",\"birthday\":\"\(RegistrationInputModel.sharedInstance.birthday ?? "")\",\"gender\":\"\(RegistrationInputModel.sharedInstance.gender ?? "")\",\"mobile\":\"\(RegistrationInputModel.sharedInstance.mobile ?? "")\",\"address\":\"\(RegistrationInputModel.sharedInstance.address ?? "")\",\"city\":\"\(RegistrationInputModel.sharedInstance.city ?? "")\",\"state\":\"\(RegistrationInputModel.sharedInstance.state ?? "")\",\"zipcode\":\"\(RegistrationInputModel.sharedInstance.zipcode ?? "")\",\"country\":\"\(RegistrationInputModel.sharedInstance.primaryCountry ?? "")\",\"profilePicture\":\"\(RegistrationInputModel.sharedInstance.profile ?? "")\",\"paymentOption\":null,\"postOffers\":\(RegistrationInputModel.sharedInstance.postOffers ?? true),\"latitude\":0.0,\"longitude\":0.0,\"searchDistance\":\(RegistrationInputModel.sharedInstance.searchRadius ?? 0.0),\"geolocationFlag\":\(RegistrationInputModel.sharedInstance.geolocationFlag ?? true),\"facebookFlag\":\(RegistrationInputModel.sharedInstance.connectMessenger ?? true),\"website\":null,\"userCategories\":[{\"categoryId\":1,\"categoryName\":\"Services\",\"subCategories\":[{\"subCategoryId\":1,\"subCategoryName\":\"Restaurants/Catering\"}]}],\"userType\":\"Business User\",\"businessRegistered\":true,\"acceptNotifications\":\(RegistrationInputModel.sharedInstance.notificationEnabled ?? true),\"businessDetails\":[{\"businessId\":0,\"businessName\":\"\(RegistrationInputModel.sharedInstance.name ?? "")\",\"businessImage\":null,\"businessCategories\":[{\"categoryId\":1,\"categoryName\":\"Services\",\"subCategories\":[{\"subCategoryId\":1,\"subCategoryName\":\"Restaurants/Catering\"}]}],\"businessPhone\":\"\(RegistrationInputModel.sharedInstance.buissnessMobile ?? "")\",\"businessEmail\":\"\(RegistrationInputModel.sharedInstance.buissnessMail ?? "")\",\"businessUrl\":\"\(RegistrationInputModel.sharedInstance.buissnessUrl ?? "")\",\"businessFacebook\":\"\(RegistrationInputModel.sharedInstance.buissnessFacebook ?? "")\",\"businessAddress\":\"\(RegistrationInputModel.sharedInstance.address ?? "")\",\"businessState\":\"\(RegistrationInputModel.sharedInstance.buissnessstate ?? "")\",\"businessCity\":\"\(RegistrationInputModel.sharedInstance.buissnessCity ?? "")\",\"businessCountry\":\"\(RegistrationInputModel.sharedInstance.buissnessCountry ?? "")\",\"businessZipCode\":\"\(RegistrationInputModel.sharedInstance.buissnessZipcode ?? "")\",\"userBusinessRelationId\":\(RegistrationInputModel.sharedInstance.relationId ?? 0),\"userBusinessRelationType\":\"\(RegistrationInputModel.sharedInstance.buissnessRelation ?? "")\"}]}"
let postData = parameters.data(using: .utf8) let postData = parameters.data(using: .utf8)
request.addValue("application/json", forHTTPHeaderField: "Content-Type") request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST" request.httpMethod = "POST"
request.httpBody = postData request.httpBody = postData
...@@ -167,29 +148,25 @@ extension RegistrationBuisness2VC ...@@ -167,29 +148,25 @@ extension RegistrationBuisness2VC
guard let data = data,error == nil else{ guard let data = data,error == nil else{
DispatchQueue.main.async { DispatchQueue.main.async {
self.activityIndicator.stopAnimating() self.activityIndicator.stopAnimating()
self.displayAlert(message: "Please check your internet connection") self.displayAlert(message: "Please check your internet connection")
UIApplication.shared.endIgnoringInteractionEvents() UIApplication.shared.endIgnoringInteractionEvents()
} }
print("something wrong") print("something wrong")
return return
} }
let finaldata = try! JSONDecoder().decode(LoginModel.self, from: data) let finaldata = try! JSONDecoder().decode(LoginModel.self, from: data)
DispatchQueue.main.async { [self] in DispatchQueue.main.async { [self] in
self.activityIndicator.stopAnimating() self.activityIndicator.stopAnimating()
UIApplication.shared.endIgnoringInteractionEvents() UIApplication.shared.endIgnoringInteractionEvents()
if(finaldata.status == true) if(finaldata.status == true)
{ {
let alert = UIAlertController(title: "SUCCESS", message: "User successfully registered", preferredStyle: .alert) let alert = UIAlertController(title: "SUCCESS", message: "User successfully registered", preferredStyle: .alert)
let action = UIAlertAction(title: "OK", style: .default) { (action) in let action = UIAlertAction(title: "OK", style: .default) { (action) in
let navVc = self.storyboard?.instantiateViewController(identifier: "Login")as! LoginVC let navVc = self.storyboard?.instantiateViewController(identifier: "Login")as! LoginVC
self.navigationController?.pushViewController(navVc, animated: true) self.navigationController?.pushViewController(navVc, animated: true)
} }
alert.addAction(action) alert.addAction(action)
self.present(alert, animated: true, completion: nil) self.present(alert, animated: true, completion: nil)
} }
if(finaldata.status == false){ if(finaldata.status == false){
let msg = finaldata.message let msg = finaldata.message
...@@ -202,17 +179,18 @@ extension RegistrationBuisness2VC ...@@ -202,17 +179,18 @@ extension RegistrationBuisness2VC
@objc func doneButtonTappedForMyNumericTextField(_ sender : UITextField) { @objc func doneButtonTappedForMyNumericTextField(_ sender : UITextField) {
self.buisnessUrlText.becomeFirstResponder() self.buisnessUrlText.becomeFirstResponder()
} }
} }
//MARK:- Textfield delegate
extension RegistrationBuisness2VC: UITextFieldDelegate extension RegistrationBuisness2VC: UITextFieldDelegate
{ {
func textFieldShouldReturn(_ textField: UITextField) -> Bool { func textFieldShouldReturn(_ textField: UITextField) -> Bool {
if let selectedTextFieldIndex = textFields.firstIndex(of: textField), selectedTextFieldIndex < textFields.count - 1 { if let selectedTextFieldIndex = textFields.firstIndex(of: textField), selectedTextFieldIndex < textFields.count - 1 {
textFields[selectedTextFieldIndex + 1].becomeFirstResponder() textFields[selectedTextFieldIndex + 1].becomeFirstResponder()
} else { } else {
textField.resignFirstResponder() // last textfield, dismiss keyboard directly textField.resignFirstResponder()
} }
return true return true
} }
......
...@@ -27,23 +27,19 @@ class RegistrationBuisnessVC: UIViewController { ...@@ -27,23 +27,19 @@ class RegistrationBuisnessVC: UIViewController {
let dropDown = DropDown() let dropDown = DropDown()
var stateArr = ["Select state" ,"California"] var stateArr = ["Select state" ,"California"]
var AR = [BusRelData]() var AR = [BusRelData]()
var relation = [String]() var relation = [String]()
var id = [Int]() var id = [Int]()
var relationId = 0 var relationId = 0
var valid = validation() var valid = validation()
var textFields: [UITextField] { var textFields: [UITextField] {
return [nameText, mobileText, mailIdText,addressText, cityText] return [nameText, mobileText, mailIdText,addressText, cityText]
} }
//MARK:- View operations
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
getBusRelationData() getBusRelationData()
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.dismissKeyboard (_:))) let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.dismissKeyboard (_:)))
self.view.addGestureRecognizer(tapGesture) self.view.addGestureRecognizer(tapGesture)
} }
...@@ -57,7 +53,6 @@ class RegistrationBuisnessVC: UIViewController { ...@@ -57,7 +53,6 @@ class RegistrationBuisnessVC: UIViewController {
} }
@objc func dismissKeyboard (_ sender: UITapGestureRecognizer) { @objc func dismissKeyboard (_ sender: UITapGestureRecognizer) {
self.scrollInnersView.endEditing(true) self.scrollInnersView.endEditing(true)
} }
...@@ -69,7 +64,6 @@ class RegistrationBuisnessVC: UIViewController { ...@@ -69,7 +64,6 @@ class RegistrationBuisnessVC: UIViewController {
dropDown.selectionAction = dropDown.selectionAction =
{ [unowned self] (index: Int, item: String) in { [unowned self] (index: Int, item: String) in
self.stateText.text = item self.stateText.text = item
self.dropDown.hide() self.dropDown.hide()
} }
} }
...@@ -91,8 +85,6 @@ class RegistrationBuisnessVC: UIViewController { ...@@ -91,8 +85,6 @@ class RegistrationBuisnessVC: UIViewController {
} }
@IBAction func navTapped(_ sender: Any) { @IBAction func navTapped(_ sender: Any) {
self.navAction() self.navAction()
// let navVc = (self.storyboard?.instantiateViewController(identifier: "RegistrationBuisness2"))! as RegistrationBuisness2VC
// self.navigationController?.pushViewController(navVc, animated: true)
} }
} }
...@@ -103,9 +95,7 @@ extension RegistrationBuisnessVC ...@@ -103,9 +95,7 @@ extension RegistrationBuisnessVC
func getBusRelationData() func getBusRelationData()
{ {
let url = RestApiManager.sharedInstance.baseURL + "userController/getBusinessRelationMaster" let url = RestApiManager.sharedInstance.baseURL + "userController/getBusinessRelationMaster"
let obj = URL(string: url) let obj = URL(string: url)
var request = URLRequest(url: obj!) var request = URLRequest(url: obj!)
request.httpMethod = "GET" request.httpMethod = "GET"
...@@ -117,9 +107,6 @@ extension RegistrationBuisnessVC ...@@ -117,9 +107,6 @@ extension RegistrationBuisnessVC
print("something wrong") print("something wrong")
return return
} }
print(data)
let finaldata = try! JSONDecoder().decode(BusRelModel.self, from: data) let finaldata = try! JSONDecoder().decode(BusRelModel.self, from: data)
DispatchQueue.main.async { [self] in DispatchQueue.main.async { [self] in
if(finaldata.status == true) if(finaldata.status == true)
...@@ -129,28 +116,24 @@ extension RegistrationBuisnessVC ...@@ -129,28 +116,24 @@ extension RegistrationBuisnessVC
self.id.removeAll() self.id.removeAll()
for i in 0...(self.AR.count-1) for i in 0...(self.AR.count-1)
{ {
self.relation.append(self.AR[i].relationTypeDescription!) self.relation.append(self.AR[i].relationTypeDescription!)
self.id.append(self.AR[i].relationTypeId!) self.id.append(self.AR[i].relationTypeId!)
} }
self.relationId = id[0] self.relationId = id[0]
self.buisnessRelationText.text = relation[0] self.buisnessRelationText.text = relation[0]
} }
if(finaldata.status == false){ if(finaldata.status == false){
} }
} }
}.resume() }.resume()
} }
func navAction() func navAction()
{ {
var message = "" let message = ""
let validmail = valid.validateEmailId(emailID: mailIdText.text!) let validmail = valid.validateEmailId(emailID: mailIdText.text!)
let validmobile = valid.isValidPhone(phone: mobileText.text ?? "") let validmobile = valid.isValidPhone(phone: mobileText.text ?? "")
if nameText.text == "" if nameText.text == ""
{ {
self.displayAlert(message: "Please enter valid name") self.displayAlert(message: "Please enter valid name")
...@@ -161,13 +144,11 @@ extension RegistrationBuisnessVC ...@@ -161,13 +144,11 @@ extension RegistrationBuisnessVC
self.displayAlert(message: "Please enter valid mobile number") self.displayAlert(message: "Please enter valid mobile number")
return return
} }
if validmobile == false if validmobile == false
{ {
self.displayAlert(message: "Please enter valid mobile number") self.displayAlert(message: "Please enter valid mobile number")
return return
} }
if mailIdText.text != "" if mailIdText.text != ""
{ {
if validmail == false if validmail == false
...@@ -175,10 +156,8 @@ extension RegistrationBuisnessVC ...@@ -175,10 +156,8 @@ extension RegistrationBuisnessVC
self.displayAlert(message: "Please enter valid mail id") self.displayAlert(message: "Please enter valid mail id")
return return
} }
} }
if message != "" if message != ""
{ {
let alert = UIAlertController(title: "Alert", message: message, preferredStyle: .alert) let alert = UIAlertController(title: "Alert", message: message, preferredStyle: .alert)
...@@ -196,7 +175,6 @@ extension RegistrationBuisnessVC ...@@ -196,7 +175,6 @@ extension RegistrationBuisnessVC
RegistrationInputModel.sharedInstance.buissnessstate = self.stateText.text RegistrationInputModel.sharedInstance.buissnessstate = self.stateText.text
RegistrationInputModel.sharedInstance.buissnessRelation = self.buisnessRelationText.text RegistrationInputModel.sharedInstance.buissnessRelation = self.buisnessRelationText.text
RegistrationInputModel.sharedInstance.relationId = self.relationId RegistrationInputModel.sharedInstance.relationId = self.relationId
let navVc = (self.storyboard?.instantiateViewController(identifier: "RegistrationBuisness2"))! as RegistrationBuisness2VC let navVc = (self.storyboard?.instantiateViewController(identifier: "RegistrationBuisness2"))! as RegistrationBuisness2VC
self.navigationController?.pushViewController(navVc, animated: true) self.navigationController?.pushViewController(navVc, animated: true)
...@@ -205,19 +183,17 @@ extension RegistrationBuisnessVC ...@@ -205,19 +183,17 @@ extension RegistrationBuisnessVC
@objc func doneButtonTappedForMyNumericTextField(_ sender : UITextField) { @objc func doneButtonTappedForMyNumericTextField(_ sender : UITextField) {
self.mailIdText.becomeFirstResponder() self.mailIdText.becomeFirstResponder()
} }
} }
//MARK:- Textfield delegate
extension RegistrationBuisnessVC: UITextFieldDelegate extension RegistrationBuisnessVC: UITextFieldDelegate
{ {
func textFieldShouldReturn(_ textField: UITextField) -> Bool { func textFieldShouldReturn(_ textField: UITextField) -> Bool {
if let selectedTextFieldIndex = textFields.firstIndex(of: textField), selectedTextFieldIndex < textFields.count - 1 { if let selectedTextFieldIndex = textFields.firstIndex(of: textField), selectedTextFieldIndex < textFields.count - 1 {
textFields[selectedTextFieldIndex + 1].becomeFirstResponder() textFields[selectedTextFieldIndex + 1].becomeFirstResponder()
} else { } else {
textField.resignFirstResponder() // last textfield, dismiss keyboard directly textField.resignFirstResponder()
} }
return true return true
} }
...@@ -226,16 +202,13 @@ extension RegistrationBuisnessVC: UITextFieldDelegate ...@@ -226,16 +202,13 @@ extension RegistrationBuisnessVC: UITextFieldDelegate
if textField == nameText || textField == cityText || textField == stateText if textField == nameText || textField == cityText || textField == stateText
{ {
if range.location == 0 && string == " " { // prevent space on first character if range.location == 0 && string == " " {
return false return false
} }
if textField.text?.last == " " && string == " " {
if textField.text?.last == " " && string == " " { // allowed only single space
return false return false
} }
if string == " " { return true }
if string == " " { return true } // now allowing space between name
if string.rangeOfCharacter(from: CharacterSet.letters.inverted) != nil { if string.rangeOfCharacter(from: CharacterSet.letters.inverted) != nil {
return false return false
} }
......
...@@ -10,18 +10,18 @@ import UIKit ...@@ -10,18 +10,18 @@ import UIKit
import Kingfisher import Kingfisher
class SettingsVC: UIViewController { class SettingsVC: UIViewController {
@IBOutlet weak var dpImage: UIImageView! @IBOutlet weak var dpImage: UIImageView!
@IBOutlet weak var name: UILabel! @IBOutlet weak var name: UILabel!
@IBOutlet weak var mail: UILabel! @IBOutlet weak var mail: UILabel!
@IBOutlet weak var activityIndicator: UIActivityIndicatorView! @IBOutlet weak var activityIndicator: UIActivityIndicatorView!
//MARK:- View operations
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
} }
override func viewDidAppear(_ animated: Bool) { override func viewDidAppear(_ animated: Bool) {
setui() setui()
} }
...@@ -29,11 +29,32 @@ class SettingsVC: UIViewController { ...@@ -29,11 +29,32 @@ class SettingsVC: UIViewController {
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
let profile = SingleTon.sharedInstance.profileModel let profile = SingleTon.sharedInstance.profileModel
if profile != nil{ if profile != nil{
LoadValues() LoadValues()
} }
} }
//MARK:- Button actions
@IBAction func OnTapInbox(_ sender: Any) {
let navVc = self.storyboard?.instantiateViewController(identifier: "Notifications")as! NotificationsVC
navVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(navVc, animated: true)
}
@IBAction func OnTapViewProfile(_ sender: Any) {
let navVc = self.storyboard?.instantiateViewController(identifier: "ViewProfile")as! ViewProfileVC
navVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(navVc, animated: true)
}
@IBAction func OnTapLogOut(_ sender: Any) {
logoutFromdevice()
}
}
//MARK:- Extra functions
extension SettingsVC
{
func setui() func setui()
{ {
dpImage.layer.cornerRadius = dpImage.frame.height/2 dpImage.layer.cornerRadius = dpImage.frame.height/2
...@@ -43,10 +64,10 @@ class SettingsVC: UIViewController { ...@@ -43,10 +64,10 @@ class SettingsVC: UIViewController {
func LoadValues() func LoadValues()
{ {
let profile = SingleTon.sharedInstance.profileModel let profile = SingleTon.sharedInstance.profileModel
self.name.text = profile?.name self.name.text = profile?.name
self.mail.text = profile?.emailId self.mail.text = profile?.emailId
let link = profile?.profilePicture let link = profile?.profilePicture
if link != nil if link != nil
{ {
...@@ -59,12 +80,12 @@ class SettingsVC: UIViewController { ...@@ -59,12 +80,12 @@ class SettingsVC: UIViewController {
{ {
self.dpImage.image = UIImage(named: "profPic") self.dpImage.image = UIImage(named: "profPic")
} }
} }
func logoutFromdevice() func logoutFromdevice()
{ {
UserDefaults.standard.set(false, forKey: "isLoggedIn") UserDefaults.standard.set(false, forKey: "isLoggedIn")
UserDefaults.standard.removeObject(forKey: "profileModel") UserDefaults.standard.removeObject(forKey: "profileModel")
let mainStoryboard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil) let mainStoryboard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
...@@ -75,21 +96,4 @@ class SettingsVC: UIViewController { ...@@ -75,21 +96,4 @@ class SettingsVC: UIViewController {
self.present(navigationController, animated: false, completion: nil) self.present(navigationController, animated: false, completion: nil)
} }
@IBAction func OnTapInbox(_ sender: Any) {
let navVc = self.storyboard?.instantiateViewController(identifier: "Notifications")as! NotificationsVC
navVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(navVc, animated: true)
}
@IBAction func OnTapViewProfile(_ sender: Any) {
let navVc = self.storyboard?.instantiateViewController(identifier: "ViewProfile")as! ViewProfileVC
navVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(navVc, animated: true)
}
@IBAction func OnTapLogOut(_ sender: Any) {
logoutFromdevice()
}
} }
...@@ -11,8 +11,6 @@ import UIKit ...@@ -11,8 +11,6 @@ import UIKit
class ViewBusProfile: UIViewController { class ViewBusProfile: UIViewController {
var Busprofile = SingleTon.sharedInstance.profileModel.businessDetails?[0]
@IBOutlet weak var name: UILabel! @IBOutlet weak var name: UILabel!
@IBOutlet weak var mail: UILabel! @IBOutlet weak var mail: UILabel!
@IBOutlet weak var phone: UILabel! @IBOutlet weak var phone: UILabel!
...@@ -25,8 +23,9 @@ class ViewBusProfile: UIViewController { ...@@ -25,8 +23,9 @@ class ViewBusProfile: UIViewController {
@IBOutlet weak var busURL: UILabel! @IBOutlet weak var busURL: UILabel!
@IBOutlet weak var busFB: UILabel! @IBOutlet weak var busFB: UILabel!
var Busprofile = SingleTon.sharedInstance.profileModel.businessDetails?[0]
//MARK:- View operations
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
if Busprofile != nil if Busprofile != nil
...@@ -35,7 +34,7 @@ if Busprofile != nil ...@@ -35,7 +34,7 @@ if Busprofile != nil
} }
} }
//MARK:- Button actions
@IBAction func editBtnTapped(_ sender: Any) { @IBAction func editBtnTapped(_ sender: Any) {
let navVc = self.storyboard?.instantiateViewController(identifier: "EditProfile")as! EditProfileVC let navVc = self.storyboard?.instantiateViewController(identifier: "EditProfile")as! EditProfileVC
self.navigationController?.pushViewController(navVc, animated: true) self.navigationController?.pushViewController(navVc, animated: true)
...@@ -44,95 +43,89 @@ if Busprofile != nil ...@@ -44,95 +43,89 @@ if Busprofile != nil
@IBAction func backTapped(_ sender: Any) { @IBAction func backTapped(_ sender: Any) {
self.navigationController?.popViewController(animated: true) self.navigationController?.popViewController(animated: true)
} }
}
func LoadValues()
//MARK:- Extra functions
extension ViewBusProfile
{ {
self.name.text = Busprofile?.businessName func LoadValues()
self.mail.text = Busprofile?.businessEmail
self.phone.text = Busprofile?.businessPhone
self.city.text = Busprofile?.businessCity
self.state.text = Busprofile?.businessState
if Busprofile?.businessName != ""
{ {
self.name.text = Busprofile?.businessName self.name.text = Busprofile?.businessName
}
else
{
self.name.text = "--"
}
if (Busprofile?.businessEmail == "" || Busprofile?.businessEmail == nil)
{
self.mail.text = "--"
}
else
{
self.mail.text = Busprofile?.businessEmail self.mail.text = Busprofile?.businessEmail
}
if (Busprofile?.businessPhone == "" || Busprofile?.businessPhone == nil)
{
self.phone.text = "--"
}
else
{
self.phone.text = Busprofile?.businessPhone self.phone.text = Busprofile?.businessPhone
}
if (Busprofile?.businessCity == "" || Busprofile?.businessCity == nil)
{
self.city.text = "--"
}
else
{
self.city.text = Busprofile?.businessCity self.city.text = Busprofile?.businessCity
self.state.text = Busprofile?.businessState
} if Busprofile?.businessName != ""
if (Busprofile?.businessZipCode == "" || Busprofile?.businessZipCode == nil) {
{ self.name.text = Busprofile?.businessName
self.zipcode.text = "--" }
} else
else {
{ self.name.text = "--"
self.zipcode.text = Busprofile?.businessZipCode }
if (Busprofile?.businessEmail == "" || Busprofile?.businessEmail == nil)
} {
self.mail.text = "--"
// if Busprofile?.businessCategories?[0] != nil }
// { else
// self.categ.text = Busprofile?.businessCategories?[0].categoryName ?? "" {
// self.subcateg.text = Busprofile?.businessCategories![0].subCategories![0].subCategoryName ?? "" self.mail.text = Busprofile?.businessEmail
// }
if (Busprofile?.userBusinessRelationType == "" || Busprofile?.userBusinessRelationType == nil) }
{ if (Busprofile?.businessPhone == "" || Busprofile?.businessPhone == nil)
self.busRel.text = "--" {
} self.phone.text = "--"
else }
{ else
self.busRel.text = Busprofile?.userBusinessRelationType {
self.phone.text = Busprofile?.businessPhone
}
if (Busprofile?.businessUrl == "" || Busprofile?.businessUrl == nil) }
{ if (Busprofile?.businessCity == "" || Busprofile?.businessCity == nil)
self.busURL.text = "--" {
} self.city.text = "--"
else }
{ else
self.busURL.text = Busprofile?.businessUrl {
self.city.text = Busprofile?.businessCity
}
if (Busprofile?.businessFacebook == "" || Busprofile?.businessFacebook == nil) }
{ if (Busprofile?.businessZipCode == "" || Busprofile?.businessZipCode == nil)
self.busFB.text = "--" {
} self.zipcode.text = "--"
else }
{ else
self.busFB.text = Busprofile?.businessFacebook {
self.zipcode.text = Busprofile?.businessZipCode
}
} }
if (Busprofile?.userBusinessRelationType == "" || Busprofile?.userBusinessRelationType == nil)
{
self.busRel.text = "--"
}
else
{
self.busRel.text = Busprofile?.userBusinessRelationType
}
if (Busprofile?.businessUrl == "" || Busprofile?.businessUrl == nil)
{
self.busURL.text = "--"
}
else
{
self.busURL.text = Busprofile?.businessUrl
}
if (Busprofile?.businessFacebook == "" || Busprofile?.businessFacebook == nil)
{
self.busFB.text = "--"
}
else
{
self.busFB.text = Busprofile?.businessFacebook
}
}
} }
...@@ -11,17 +11,13 @@ import Kingfisher ...@@ -11,17 +11,13 @@ import Kingfisher
class ViewProfileVC: UIViewController { class ViewProfileVC: UIViewController {
var profile = SingleTon.sharedInstance.profileModel
@IBOutlet weak var ProfPic : UIImageView! @IBOutlet weak var ProfPic : UIImageView!
@IBOutlet weak var PostOffersBtn: UIButton! @IBOutlet weak var PostOffersBtn: UIButton!
@IBOutlet weak var NotificationsBtn: UIButton! @IBOutlet weak var NotificationsBtn: UIButton!
@IBOutlet weak var ConnectFbBtn: UIButton! @IBOutlet weak var ConnectFbBtn: UIButton!
@IBOutlet weak var CaptureLocBtn: UIButton! @IBOutlet weak var CaptureLocBtn: UIButton!
@IBOutlet weak var ProfilePicView: UIView! @IBOutlet weak var ProfilePicView: UIView!
@IBOutlet weak var EditProfBtn: UIButton! @IBOutlet weak var EditProfBtn: UIButton!
@IBOutlet weak var Name: UILabel! @IBOutlet weak var Name: UILabel!
@IBOutlet weak var Address: UILabel! @IBOutlet weak var Address: UILabel!
@IBOutlet weak var mailId: UILabel! @IBOutlet weak var mailId: UILabel!
...@@ -32,11 +28,13 @@ class ViewProfileVC: UIViewController { ...@@ -32,11 +28,13 @@ class ViewProfileVC: UIViewController {
@IBOutlet weak var SubCategory: UILabel! @IBOutlet weak var SubCategory: UILabel!
@IBOutlet weak var SearchRadius: UILabel! @IBOutlet weak var SearchRadius: UILabel!
@IBOutlet weak var locationBtnOutlet: UIButton! @IBOutlet weak var locationBtnOutlet: UIButton!
@IBOutlet weak var buisnessdetailBtn: UIButton! @IBOutlet weak var buisnessdetailBtn: UIButton!
var profile = SingleTon.sharedInstance.profileModel
//MARK:- View operations
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
locationBtnOutlet.layer.borderWidth = 1 locationBtnOutlet.layer.borderWidth = 1
locationBtnOutlet.layer.borderColor = UIColor.redShade.cgColor locationBtnOutlet.layer.borderColor = UIColor.redShade.cgColor
buisnessdetailBtn.layer.borderWidth = 1 buisnessdetailBtn.layer.borderWidth = 1
...@@ -54,32 +52,84 @@ class ViewProfileVC: UIViewController { ...@@ -54,32 +52,84 @@ class ViewProfileVC: UIViewController {
self.EditProfBtn.isHidden = false self.EditProfBtn.isHidden = false
} }
} }
} }
override func viewDidAppear(_ animated: Bool) { override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated) super.viewDidAppear(animated)
setui() setui()
} }
func setui()
{
ProfilePicView.layer.cornerRadius = ProfilePicView.frame.height/2
ProfPic.layer.cornerRadius = ProfPic.frame.height/2
ProfPic.layer.masksToBounds = true
}
//MARK:- Button actions
@IBAction func editProfiletapped(_ sender: Any) { @IBAction func editProfiletapped(_ sender: Any) {
let navVc = self.storyboard?.instantiateViewController(identifier: "EditProfile")as! EditProfileVC let navVc = self.storyboard?.instantiateViewController(identifier: "EditProfile")as! EditProfileVC
self.navigationController?.pushViewController(navVc, animated: true) self.navigationController?.pushViewController(navVc, animated: true)
} }
@IBAction func buisnessDetailTapped(_ sender: Any) {
let navVC = self.storyboard?.instantiateViewController(identifier: "ViewBusProfile")as! ViewBusProfile
self.navigationController?.pushViewController(navVC, animated: true)
}
@IBAction func ToggleButtonsOnTap(_ sender: UIButton) {
if sender.tag == 1
{
if PostOffersBtn.isSelected
{
PostOffersBtn.isSelected = false
}
else
{
PostOffersBtn.isSelected = true
}
}
if sender.tag == 2
{
if NotificationsBtn.isSelected
{
NotificationsBtn.isSelected = false
}
else
{
NotificationsBtn.isSelected = true
}
}
if sender.tag == 3
{
if ConnectFbBtn.isSelected
{
ConnectFbBtn.isSelected = false
}
else
{
ConnectFbBtn.isSelected = true
}
}
}
@IBAction func backBtnTapped(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
@IBAction func viewLocationTapped(_ sender: Any) {
let navVc = self.storyboard?.instantiateViewController(identifier: "LocationList")as! LocationListVC
self.navigationController?.pushViewController(navVc, animated: true)
}
}
//MARK:- Extra functions
extension ViewProfileVC
{
func setui()
{
ProfilePicView.layer.cornerRadius = ProfilePicView.frame.height/2
ProfPic.layer.cornerRadius = ProfPic.frame.height/2
ProfPic.layer.masksToBounds = true
}
func LoadValues() func LoadValues()
{ {
self.Name.text = profile?.name self.Name.text = profile?.name
let link = profile?.profilePicture let link = profile?.profilePicture
if link != nil if link != nil
{ {
...@@ -95,16 +145,10 @@ class ViewProfileVC: UIViewController { ...@@ -95,16 +145,10 @@ class ViewProfileVC: UIViewController {
} }
var addrss = "" var addrss = ""
if profile?.address != "" if profile?.address != ""
{ {
addrss = addrss + (profile?.address ?? "") addrss = addrss + (profile?.address ?? "")
} }
// city : String?
// let state : String?
// let zipcode : String?
// let country
if profile?.city != "" if profile?.city != ""
{ {
if addrss != "" if addrss != ""
...@@ -163,7 +207,6 @@ class ViewProfileVC: UIViewController { ...@@ -163,7 +207,6 @@ class ViewProfileVC: UIViewController {
if (profile?.emailId == "" || profile?.emailId == nil) if (profile?.emailId == "" || profile?.emailId == nil)
{ {
self.mailId.text = "--" self.mailId.text = "--"
} }
else else
{ {
...@@ -172,7 +215,6 @@ class ViewProfileVC: UIViewController { ...@@ -172,7 +215,6 @@ class ViewProfileVC: UIViewController {
if (profile?.mobile == "" || profile?.mobile == nil) if (profile?.mobile == "" || profile?.mobile == nil)
{ {
self.Phone.text = "--" self.Phone.text = "--"
} }
else else
{ {
...@@ -181,12 +223,10 @@ class ViewProfileVC: UIViewController { ...@@ -181,12 +223,10 @@ class ViewProfileVC: UIViewController {
if (profile?.gender == "" || profile?.gender == nil ) if (profile?.gender == "" || profile?.gender == nil )
{ {
self.gender.text = "--" self.gender.text = "--"
} }
else else
{ {
self.gender.text = profile?.gender self.gender.text = profile?.gender
} }
if (profile?.birthday == "" || profile?.birthday == nil) if (profile?.birthday == "" || profile?.birthday == nil)
{ {
...@@ -195,11 +235,8 @@ class ViewProfileVC: UIViewController { ...@@ -195,11 +235,8 @@ class ViewProfileVC: UIViewController {
else else
{ {
self.Birthday.text = profile?.birthday?.replacingOccurrences(of: "00:00", with: "") self.Birthday.text = profile?.birthday?.replacingOccurrences(of: "00:00", with: "")
} }
if (profile?.acceptNotifications)! if (profile?.acceptNotifications)!
{ {
NotificationsBtn.isSelected = false NotificationsBtn.isSelected = false
...@@ -235,64 +272,7 @@ class ViewProfileVC: UIViewController { ...@@ -235,64 +272,7 @@ class ViewProfileVC: UIViewController {
CaptureLocBtn.isSelected = true CaptureLocBtn.isSelected = true
} }
// self.Category.text = profile?.userCategories?[0].categoryName
//
// self.SubCategory.text = profile?.userCategories?[0].subCategories?[0].subCategoryName
//self.SubCategory.text = subcateg[0].subCategoryName
self.SearchRadius.text = profile?.searchDistance?.description ?? "" self.SearchRadius.text = profile?.searchDistance?.description ?? ""
}
@IBAction func buisnessDetailTapped(_ sender: Any) {
let navVC = self.storyboard?.instantiateViewController(identifier: "ViewBusProfile")as! ViewBusProfile
self.navigationController?.pushViewController(navVC, animated: true)
}
@IBAction func ToggleButtonsOnTap(_ sender: UIButton) {
if sender.tag == 1
{
if PostOffersBtn.isSelected
{
PostOffersBtn.isSelected = false
}
else
{
PostOffersBtn.isSelected = true
}
}
if sender.tag == 2
{
if NotificationsBtn.isSelected
{
NotificationsBtn.isSelected = false
}
else
{
NotificationsBtn.isSelected = true
}
}
if sender.tag == 3
{
if ConnectFbBtn.isSelected
{
ConnectFbBtn.isSelected = false
}
else
{
ConnectFbBtn.isSelected = true
}
}
}
@IBAction func backBtnTapped(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
@IBAction func viewLocationTapped(_ sender: Any) {
let navVc = self.storyboard?.instantiateViewController(identifier: "LocationList")as! LocationListVC
self.navigationController?.pushViewController(navVc, animated: true)
} }
} }
...@@ -13,12 +13,6 @@ class tab: UITabBarController { ...@@ -13,12 +13,6 @@ class tab: UITabBarController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
// self.tabBar.items?.forEach({ tbi in
//// tbi.image = tbi.image?.withRenderingMode(.alwaysOriginal)
//// self.tabBar.unselectedItemTintColor = UIColor(red: 239/255.0, green: 64/255.0, blue: 77/255.0, alpha: 1.0)
//
//
// });
} }
......
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