Commit e0804213 by Angel FS

Code alignment

parent b60514b6
......@@ -7,38 +7,6 @@
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<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"
shouldBeEnabled = "Yes"
ignoreCount = "0"
......
......@@ -17,15 +17,15 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
do {
let profile = try UserDefaults.standard.getObject(forKey: "profileModel", castTo: LoginModel.self)
SingleTon.sharedInstance.profileModel = profile.data
SingleTon.sharedInstance.profileModel?.userId = profile.data?.userId
SingleTon.sharedInstance.profileModel = profile.data
SingleTon.sharedInstance.profileModel?.userId = profile.data?.userId
if SingleTon.sharedInstance.profileModel != nil
{
guard (scene as? UIWindowScene) != nil else { return }
let mainSB: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let loggedInTabController = mainSB.instantiateViewController(identifier: "tab")
self.window!.rootViewController = loggedInTabController
let loggedInTabController = mainSB.instantiateViewController(identifier: "tab")
self.window!.rootViewController = loggedInTabController
}
} catch {
print(error.localizedDescription)
......@@ -34,7 +34,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
}
func sceneDidDisconnect(_ scene: UIScene) {
// 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.
......
......@@ -15,7 +15,6 @@ class SingleTon
{
static let sharedInstance = SingleTon()
var profileModel : Data1!
var userCateg = [UserCategories]()
var subCateg = [SubCategories]()
......
......@@ -9,70 +9,70 @@
import Foundation
class Time: Comparable, Equatable {
init(_ date: Date) {
//get the current calender
let calendar = Calendar.current
//get just the minute and the hour of the day passed to it
let dateComponents = calendar.dateComponents([.hour, .minute], from: date)
init(_ date: Date) {
//get the current calender
let calendar = Calendar.current
//get just the minute and the hour of the day passed to it
let dateComponents = calendar.dateComponents([.hour, .minute], from: date)
//calculate the seconds since the beggining of the day for comparisions
let dateSeconds = dateComponents.hour! * 3600 + dateComponents.minute! * 60
//set the varibles
secondsSinceBeginningOfDay = dateSeconds
hour = dateComponents.hour!
minute = dateComponents.minute!
}
init(_ hour: Int, _ minute: Int) {
//calculate the seconds since the beggining of the day for comparisions
let dateSeconds = hour * 3600 + minute * 60
//set the varibles
secondsSinceBeginningOfDay = dateSeconds
self.hour = hour
self.minute = minute
}
var hour : Int
var minute: Int
var date: Date {
//get the current calender
let calendar = Calendar.current
//create a new date components.
var dateComponents = DateComponents()
dateComponents.hour = hour
dateComponents.minute = minute
return calendar.date(byAdding: dateComponents, to: Date())!
}
/// the number or seconds since the beggining of the day, this is used for comparisions
private let secondsSinceBeginningOfDay: Int
//comparisions so you can compare times
static func == (lhs: Time, rhs: Time) -> Bool {
return lhs.secondsSinceBeginningOfDay == rhs.secondsSinceBeginningOfDay
}
static func < (lhs: Time, rhs: Time) -> Bool {
return lhs.secondsSinceBeginningOfDay < rhs.secondsSinceBeginningOfDay
}
static func <= (lhs: Time, rhs: Time) -> Bool {
return lhs.secondsSinceBeginningOfDay <= rhs.secondsSinceBeginningOfDay
}
static func >= (lhs: Time, rhs: Time) -> Bool {
return lhs.secondsSinceBeginningOfDay >= rhs.secondsSinceBeginningOfDay
}
static func > (lhs: Time, rhs: Time) -> Bool {
return lhs.secondsSinceBeginningOfDay > rhs.secondsSinceBeginningOfDay
}
......
......@@ -53,6 +53,6 @@ class validation {
let bool = pinPredicate.evaluate(with: postalCode) as Bool
return bool
}
}
......@@ -10,19 +10,21 @@ import UIKit
class ForgotPasswordVC: UIViewController,UITextFieldDelegate {
var valid = validation()
var valid = validation()
@IBOutlet weak var EmailField: UITextField!
@IBOutlet weak var PopView: UIView!
@IBOutlet weak var ContinueBtn: UIButton!
@IBOutlet weak var activityIndic: UIActivityIndicatorView!
@IBOutlet weak var activityIndic: UIActivityIndicatorView!
override func viewDidLoad() {
super.viewDidLoad()
setui()
initializeHideKeyboard()
}
//MARK:- View operations
override func viewWillAppear(_ animated: Bool) {
self.addKeyboardObserver()
}
......@@ -30,28 +32,54 @@ class ForgotPasswordVC: UIViewController,UITextFieldDelegate {
override func viewWillDisappear(_ animated: Bool) {
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(){
//Declare a Tap Gesture Recognizer which will trigger our dismissMyKeyboard() function
let tap: UITapGestureRecognizer = UITapGestureRecognizer(
target: self,
action: #selector(dismissMyKeyboard))
//Add this tap gesture recognizer to the parent view
view.addGestureRecognizer(tap)
}
@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)
}
func setui()
{
EmailField.layer.cornerRadius = 10.0
EmailField.setLeftPaddingPoints(10)
PopView.clipsToBounds = true
PopView.layer.cornerRadius = 30
PopView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
ContinueBtn.layer.cornerRadius = 10.0
func setui()
{
EmailField.layer.cornerRadius = 10.0
EmailField.setLeftPaddingPoints(10)
PopView.clipsToBounds = true
PopView.layer.cornerRadius = 30
PopView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
ContinueBtn.layer.cornerRadius = 10.0
}
func ApiData()
{
......@@ -81,7 +109,7 @@ func setui()
DispatchQueue.main.async {
if(finaldata.status == true)
{
let msg = finaldata.message
var alert = UIAlertController(title: "Alert", message: msg, preferredStyle: .alert)
let action = UIAlertAction(title: "Ok", style: .default){
......@@ -91,7 +119,7 @@ func setui()
alert.addAction(action)
self.present(alert, animated: true, completion: nil)
}
if(finaldata.status == false)
{
......@@ -100,26 +128,6 @@ func setui()
return
}
}
}.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)
}.resume()
}
}
......@@ -10,36 +10,55 @@ import UIKit
class LocationListVC: UIViewController {
var locationData = [locationDetail]()
@IBOutlet weak var activityIndicator: UIActivityIndicatorView!
@IBOutlet weak var table: UITableView!
@IBOutlet weak var addLocationBtn: UIButton!
var locationData = [locationDetail]()
//MARK:- View operations
override func viewDidLoad() {
super.viewDidLoad()
self.addLocationBtn.layer.borderWidth = 1
self.addLocationBtn.layer.borderColor = UIColor.redShade.cgColor
}
override func viewWillAppear(_ animated: Bool) {
getLocation()
}
//MARK:- Button actions
@IBAction func backBtnTapped(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
@IBAction func addLocationTapped(_ sender: Any) {
let navVc = (self.storyboard?.instantiateViewController(identifier: "Addlocation"))!as AddlocationVC
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)
{
DispatchQueue.main.async {
......@@ -59,7 +78,7 @@ class LocationListVC: UIViewController {
}
guard let data = data,
let response = response as? HTTPURLResponse,
error == nil else { // check for fundamental networking error
error == nil else {
print("error", error ?? "Unknown error")
return
}
......@@ -89,9 +108,6 @@ class LocationListVC: UIViewController {
}
}
}.resume()
}
......@@ -103,8 +119,6 @@ class LocationListVC: UIViewController {
}
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)
var request = URLRequest(url: obj!)
request.httpMethod = "GET"
......@@ -120,9 +134,6 @@ class LocationListVC: UIViewController {
}
return
}
print(data)
let finaldata = try! JSONDecoder().decode(LocationDetailModel.self, from: data)
DispatchQueue.main.async {
if(finaldata.status == true)
......@@ -139,7 +150,6 @@ class LocationListVC: UIViewController {
{
let alert = UIAlertController(title: "Alert", message: finaldata.message, preferredStyle: .alert)
let action = UIAlertAction(title: "OK", style: .default, handler: {_ in
// self.navigationController?.popViewController(animated: false)
})
alert.addAction(action)
DispatchQueue.main.async {
......@@ -150,26 +160,7 @@ class LocationListVC: UIViewController {
}
}
}.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 {
@IBOutlet weak var actiivtyIndicator: UIActivityIndicatorView!
@IBOutlet weak var Table1 : UITableView!
var notifData = [Data2]()
var details = [OfferData]()
var OfferDetails : OfferData!
var campId = [Int]()
var OfferDetails : OfferData!
var campId = [Int]()
//MARK:- View operations
override func viewDidLoad() {
super.viewDidLoad()
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) {
self.navigationController?.popViewController(animated: true)
}
}
//MARK:- TableView delegate and datasource
extension NotificationsVC : UITableViewDelegate,UITableViewDataSource
{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
......@@ -109,11 +52,9 @@ extension NotificationsVC : UITableViewDelegate,UITableViewDataSource
if notifData[indexPath.row].messageType != 1
{
let destViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "OfferDetail") as! OfferDetailVC
// destViewController.starFlag = self.OfferDetails.starredFlag ?? 0
destViewController.claim = true
destViewController.OfferDetails = self.details[0]
self.navigationController?.pushViewController(destViewController, animated: true)
self.navigationController?.pushViewController(destViewController, animated: true)
}
else{
let destViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "SearchResult") as! SearchResultVC
......@@ -121,7 +62,71 @@ extension NotificationsVC : UITableViewDelegate,UITableViewDataSource
destViewController.campId = self.campId
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 {
var subCatArr = ["Restaurants/Catering"]
var countryArr = ["United States"]
var valid = validation()
var textFields: [UITextField] {
return [ zipcodeText, buisnessUrlText , buisnessFacebookText]
}
//MARK:- View operations
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.dismissKeyboard (_:)))
self.view.addGestureRecognizer(tapGesture)
}
......@@ -51,8 +49,6 @@ class RegistrationBuisness2VC: UIViewController {
self.removeKeyboardObserver()
}
@objc func dismissKeyboard (_ sender: UITapGestureRecognizer) {
self.scrollInnersView.endEditing(true)
}
......@@ -65,7 +61,6 @@ class RegistrationBuisness2VC: UIViewController {
dropDown.selectionAction =
{ [unowned self] (index: Int, item: String) in
self.countryText.text = item
self.dropDown.hide()
}
}
......@@ -77,7 +72,6 @@ class RegistrationBuisness2VC: UIViewController {
dropDown.selectionAction =
{ [unowned self] (index: Int, item: String) in
self.categoryText.text = item
self.dropDown.hide()
}
}
......@@ -89,10 +83,8 @@ class RegistrationBuisness2VC: UIViewController {
dropDown.selectionAction =
{ [unowned self] (index: Int, item: String) in
self.subCategoryText.text = item
self.dropDown.hide()
}
}
@IBAction func backBtnTapped(_ sender: Any) {
......@@ -101,9 +93,6 @@ class RegistrationBuisness2VC: UIViewController {
@IBAction func navTapped(_ sender: Any) {
navAction()
// let navVc = (self.storyboard?.instantiateViewController(identifier: "tab"))! as tab
// self.regitration()
// self.navigationController?.pushViewController(navVc, animated: true)
}
}
......@@ -113,12 +102,6 @@ extension RegistrationBuisness2VC
{
func navAction()
{
// if buisnessUrlText.text == ""
// {
// self.displayAlert(message: "Please enter valid buisness url")
// return
// }
if zipcodeText.text == ""
{
self.displayAlert(message: "Please Enter Valid zipcode")
......@@ -137,8 +120,6 @@ extension RegistrationBuisness2VC
RegistrationInputModel.sharedInstance.buissnesssubCategory = self.subCategoryText.text
RegistrationInputModel.sharedInstance.buissnessUrl = self.buisnessUrlText.text
RegistrationInputModel.sharedInstance.buissnessFacebook = self.buisnessFacebookText.text
// self.regitration()
self.getApiData()
}
......@@ -152,12 +133,12 @@ extension RegistrationBuisness2VC
let obj = URL(string: url)
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 postData = parameters.data(using: .utf8)
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
request.httpBody = postData
......@@ -167,29 +148,25 @@ extension RegistrationBuisness2VC
guard let data = data,error == nil else{
DispatchQueue.main.async {
self.activityIndicator.stopAnimating()
self.displayAlert(message: "Please check your internet connection")
self.displayAlert(message: "Please check your internet connection")
UIApplication.shared.endIgnoringInteractionEvents()
}
print("something wrong")
return
}
let finaldata = try! JSONDecoder().decode(LoginModel.self, from: data)
DispatchQueue.main.async { [self] in
self.activityIndicator.stopAnimating()
UIApplication.shared.endIgnoringInteractionEvents()
self.activityIndicator.stopAnimating()
UIApplication.shared.endIgnoringInteractionEvents()
if(finaldata.status == true)
{
let alert = UIAlertController(title: "SUCCESS", message: "User successfully registered", preferredStyle: .alert)
let action = UIAlertAction(title: "OK", style: .default) { (action) in
let navVc = self.storyboard?.instantiateViewController(identifier: "Login")as! LoginVC
self.navigationController?.pushViewController(navVc, animated: true)
}
alert.addAction(action)
self.present(alert, animated: true, completion: nil)
}
if(finaldata.status == false){
let msg = finaldata.message
......@@ -202,17 +179,18 @@ extension RegistrationBuisness2VC
@objc func doneButtonTappedForMyNumericTextField(_ sender : UITextField) {
self.buisnessUrlText.becomeFirstResponder()
}
}
}
//MARK:- Textfield delegate
extension RegistrationBuisness2VC: UITextFieldDelegate
{
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
if let selectedTextFieldIndex = textFields.firstIndex(of: textField), selectedTextFieldIndex < textFields.count - 1 {
textFields[selectedTextFieldIndex + 1].becomeFirstResponder()
} else {
textField.resignFirstResponder() // last textfield, dismiss keyboard directly
textField.resignFirstResponder()
}
return true
}
......
......@@ -27,23 +27,19 @@ class RegistrationBuisnessVC: UIViewController {
let dropDown = DropDown()
var stateArr = ["Select state" ,"California"]
var AR = [BusRelData]()
var relation = [String]()
var id = [Int]()
var relationId = 0
var valid = validation()
var textFields: [UITextField] {
return [nameText, mobileText, mailIdText,addressText, cityText]
}
//MARK:- View operations
override func viewDidLoad() {
super.viewDidLoad()
getBusRelationData()
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.dismissKeyboard (_:)))
self.view.addGestureRecognizer(tapGesture)
}
......@@ -57,7 +53,6 @@ class RegistrationBuisnessVC: UIViewController {
}
@objc func dismissKeyboard (_ sender: UITapGestureRecognizer) {
self.scrollInnersView.endEditing(true)
}
......@@ -69,7 +64,6 @@ class RegistrationBuisnessVC: UIViewController {
dropDown.selectionAction =
{ [unowned self] (index: Int, item: String) in
self.stateText.text = item
self.dropDown.hide()
}
}
......@@ -91,8 +85,6 @@ class RegistrationBuisnessVC: UIViewController {
}
@IBAction func navTapped(_ sender: Any) {
self.navAction()
// let navVc = (self.storyboard?.instantiateViewController(identifier: "RegistrationBuisness2"))! as RegistrationBuisness2VC
// self.navigationController?.pushViewController(navVc, animated: true)
}
}
......@@ -103,9 +95,7 @@ extension RegistrationBuisnessVC
func getBusRelationData()
{
let url = RestApiManager.sharedInstance.baseURL + "userController/getBusinessRelationMaster"
let obj = URL(string: url)
var request = URLRequest(url: obj!)
request.httpMethod = "GET"
......@@ -117,9 +107,6 @@ extension RegistrationBuisnessVC
print("something wrong")
return
}
print(data)
let finaldata = try! JSONDecoder().decode(BusRelModel.self, from: data)
DispatchQueue.main.async { [self] in
if(finaldata.status == true)
......@@ -129,28 +116,24 @@ extension RegistrationBuisnessVC
self.id.removeAll()
for i in 0...(self.AR.count-1)
{
self.relation.append(self.AR[i].relationTypeDescription!)
self.id.append(self.AR[i].relationTypeId!)
}
self.relationId = id[0]
self.buisnessRelationText.text = relation[0]
}
if(finaldata.status == false){
}
}
}.resume()
}.resume()
}
func navAction()
{
var message = ""
let message = ""
let validmail = valid.validateEmailId(emailID: mailIdText.text!)
let validmobile = valid.isValidPhone(phone: mobileText.text ?? "")
if nameText.text == ""
{
self.displayAlert(message: "Please enter valid name")
......@@ -161,13 +144,11 @@ extension RegistrationBuisnessVC
self.displayAlert(message: "Please enter valid mobile number")
return
}
if validmobile == false
{
self.displayAlert(message: "Please enter valid mobile number")
return
}
if mailIdText.text != ""
{
if validmail == false
......@@ -175,10 +156,8 @@ extension RegistrationBuisnessVC
self.displayAlert(message: "Please enter valid mail id")
return
}
}
if message != ""
{
let alert = UIAlertController(title: "Alert", message: message, preferredStyle: .alert)
......@@ -196,7 +175,6 @@ extension RegistrationBuisnessVC
RegistrationInputModel.sharedInstance.buissnessstate = self.stateText.text
RegistrationInputModel.sharedInstance.buissnessRelation = self.buisnessRelationText.text
RegistrationInputModel.sharedInstance.relationId = self.relationId
let navVc = (self.storyboard?.instantiateViewController(identifier: "RegistrationBuisness2"))! as RegistrationBuisness2VC
self.navigationController?.pushViewController(navVc, animated: true)
......@@ -205,19 +183,17 @@ extension RegistrationBuisnessVC
@objc func doneButtonTappedForMyNumericTextField(_ sender : UITextField) {
self.mailIdText.becomeFirstResponder()
}
}
}
//MARK:- Textfield delegate
extension RegistrationBuisnessVC: UITextFieldDelegate
{
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
if let selectedTextFieldIndex = textFields.firstIndex(of: textField), selectedTextFieldIndex < textFields.count - 1 {
textFields[selectedTextFieldIndex + 1].becomeFirstResponder()
} else {
textField.resignFirstResponder() // last textfield, dismiss keyboard directly
textField.resignFirstResponder()
}
return true
}
......@@ -226,16 +202,13 @@ extension RegistrationBuisnessVC: UITextFieldDelegate
if textField == nameText || textField == cityText || textField == stateText
{
if range.location == 0 && string == " " { // prevent space on first character
if range.location == 0 && string == " " {
return false
}
if textField.text?.last == " " && string == " " { // allowed only single space
if textField.text?.last == " " && string == " " {
return false
}
if string == " " { return true } // now allowing space between name
if string == " " { return true }
if string.rangeOfCharacter(from: CharacterSet.letters.inverted) != nil {
return false
}
......
......@@ -10,18 +10,18 @@ import UIKit
import Kingfisher
class SettingsVC: UIViewController {
@IBOutlet weak var dpImage: UIImageView!
@IBOutlet weak var name: UILabel!
@IBOutlet weak var mail: UILabel!
@IBOutlet weak var activityIndicator: UIActivityIndicatorView!
//MARK:- View operations
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewDidAppear(_ animated: Bool) {
setui()
}
......@@ -29,11 +29,32 @@ class SettingsVC: UIViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let profile = SingleTon.sharedInstance.profileModel
if profile != nil{
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()
{
dpImage.layer.cornerRadius = dpImage.frame.height/2
......@@ -43,10 +64,10 @@ class SettingsVC: UIViewController {
func LoadValues()
{
let profile = SingleTon.sharedInstance.profileModel
self.name.text = profile?.name
self.mail.text = profile?.emailId
let link = profile?.profilePicture
if link != nil
{
......@@ -59,12 +80,12 @@ class SettingsVC: UIViewController {
{
self.dpImage.image = UIImage(named: "profPic")
}
}
func logoutFromdevice()
{
UserDefaults.standard.set(false, forKey: "isLoggedIn")
UserDefaults.standard.removeObject(forKey: "profileModel")
let mainStoryboard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
......@@ -75,21 +96,4 @@ class SettingsVC: UIViewController {
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
class ViewBusProfile: UIViewController {
var Busprofile = SingleTon.sharedInstance.profileModel.businessDetails?[0]
@IBOutlet weak var name: UILabel!
@IBOutlet weak var mail: UILabel!
@IBOutlet weak var phone: UILabel!
......@@ -25,8 +23,9 @@ class ViewBusProfile: UIViewController {
@IBOutlet weak var busURL: UILabel!
@IBOutlet weak var busFB: UILabel!
var Busprofile = SingleTon.sharedInstance.profileModel.businessDetails?[0]
//MARK:- View operations
override func viewDidLoad() {
super.viewDidLoad()
if Busprofile != nil
......@@ -35,7 +34,7 @@ if Busprofile != nil
}
}
//MARK:- Button actions
@IBAction func editBtnTapped(_ sender: Any) {
let navVc = self.storyboard?.instantiateViewController(identifier: "EditProfile")as! EditProfileVC
self.navigationController?.pushViewController(navVc, animated: true)
......@@ -44,95 +43,89 @@ if Busprofile != nil
@IBAction func backTapped(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
func LoadValues()
}
//MARK:- Extra functions
extension ViewBusProfile
{
self.name.text = Busprofile?.businessName
self.mail.text = Busprofile?.businessEmail
self.phone.text = Busprofile?.businessPhone
self.city.text = Busprofile?.businessCity
self.state.text = Busprofile?.businessState
if Busprofile?.businessName != ""
func LoadValues()
{
self.name.text = Busprofile?.businessName
}
else
{
self.name.text = "--"
}
if (Busprofile?.businessEmail == "" || Busprofile?.businessEmail == nil)
{
self.mail.text = "--"
}
else
{
self.mail.text = Busprofile?.businessEmail
}
if (Busprofile?.businessPhone == "" || Busprofile?.businessPhone == nil)
{
self.phone.text = "--"
}
else
{
self.phone.text = Busprofile?.businessPhone
}
if (Busprofile?.businessCity == "" || Busprofile?.businessCity == nil)
{
self.city.text = "--"
}
else
{
self.city.text = Busprofile?.businessCity
self.state.text = Busprofile?.businessState
}
if (Busprofile?.businessZipCode == "" || Busprofile?.businessZipCode == nil)
{
self.zipcode.text = "--"
}
else
{
self.zipcode.text = Busprofile?.businessZipCode
}
// if Busprofile?.businessCategories?[0] != nil
// {
// self.categ.text = Busprofile?.businessCategories?[0].categoryName ?? ""
// self.subcateg.text = Busprofile?.businessCategories![0].subCategories![0].subCategoryName ?? ""
// }
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
}
}
if 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
}
if (Busprofile?.businessPhone == "" || Busprofile?.businessPhone == nil)
{
self.phone.text = "--"
}
else
{
self.phone.text = Busprofile?.businessPhone
}
if (Busprofile?.businessCity == "" || Busprofile?.businessCity == nil)
{
self.city.text = "--"
}
else
{
self.city.text = Busprofile?.businessCity
}
if (Busprofile?.businessZipCode == "" || Busprofile?.businessZipCode == nil)
{
self.zipcode.text = "--"
}
else
{
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
class ViewProfileVC: UIViewController {
var profile = SingleTon.sharedInstance.profileModel
@IBOutlet weak var ProfPic : UIImageView!
@IBOutlet weak var PostOffersBtn: UIButton!
@IBOutlet weak var NotificationsBtn: UIButton!
@IBOutlet weak var ConnectFbBtn: UIButton!
@IBOutlet weak var CaptureLocBtn: UIButton!
@IBOutlet weak var ProfilePicView: UIView!
@IBOutlet weak var EditProfBtn: UIButton!
@IBOutlet weak var Name: UILabel!
@IBOutlet weak var Address: UILabel!
@IBOutlet weak var mailId: UILabel!
......@@ -32,11 +28,13 @@ class ViewProfileVC: UIViewController {
@IBOutlet weak var SubCategory: UILabel!
@IBOutlet weak var SearchRadius: UILabel!
@IBOutlet weak var locationBtnOutlet: UIButton!
@IBOutlet weak var buisnessdetailBtn: UIButton!
var profile = SingleTon.sharedInstance.profileModel
//MARK:- View operations
override func viewDidLoad() {
super.viewDidLoad()
locationBtnOutlet.layer.borderWidth = 1
locationBtnOutlet.layer.borderColor = UIColor.redShade.cgColor
buisnessdetailBtn.layer.borderWidth = 1
......@@ -54,32 +52,84 @@ class ViewProfileVC: UIViewController {
self.EditProfBtn.isHidden = false
}
}
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
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) {
let navVc = self.storyboard?.instantiateViewController(identifier: "EditProfile")as! EditProfileVC
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()
{
self.Name.text = profile?.name
let link = profile?.profilePicture
if link != nil
{
......@@ -95,16 +145,10 @@ class ViewProfileVC: UIViewController {
}
var addrss = ""
if profile?.address != ""
{
addrss = addrss + (profile?.address ?? "")
}
// city : String?
// let state : String?
// let zipcode : String?
// let country
if profile?.city != ""
{
if addrss != ""
......@@ -163,7 +207,6 @@ class ViewProfileVC: UIViewController {
if (profile?.emailId == "" || profile?.emailId == nil)
{
self.mailId.text = "--"
}
else
{
......@@ -172,7 +215,6 @@ class ViewProfileVC: UIViewController {
if (profile?.mobile == "" || profile?.mobile == nil)
{
self.Phone.text = "--"
}
else
{
......@@ -181,12 +223,10 @@ class ViewProfileVC: UIViewController {
if (profile?.gender == "" || profile?.gender == nil )
{
self.gender.text = "--"
}
else
{
self.gender.text = profile?.gender
}
if (profile?.birthday == "" || profile?.birthday == nil)
{
......@@ -195,11 +235,8 @@ class ViewProfileVC: UIViewController {
else
{
self.Birthday.text = profile?.birthday?.replacingOccurrences(of: "00:00", with: "")
}
if (profile?.acceptNotifications)!
{
NotificationsBtn.isSelected = false
......@@ -235,64 +272,7 @@ class ViewProfileVC: UIViewController {
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 ?? ""
}
@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 {
override func 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