Commit a42b8808 by Angel FS

Address list API and service completed

parent 8b4c5e85
......@@ -27,6 +27,7 @@
0428094C27FEB8F800468752 /* MyOrderItemsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0428094B27FEB8F800468752 /* MyOrderItemsTableViewCell.swift */; };
0428095627FEF20300468752 /* MyAddressTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0428095527FEF20300468752 /* MyAddressTableViewCell.swift */; };
0429944527FAF6B2007C4A29 /* EditProfileVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0429944427FAF6B2007C4A29 /* EditProfileVC.swift */; };
042B9A0F287C1E2500A535F6 /* AddressModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B5036F2847385D0046B350 /* AddressModel.swift */; };
042E8624286B0E1200BB12FC /* SearchModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 042E8623286B0E1200BB12FC /* SearchModel.swift */; };
042F85312823E31300C8D995 /* ReviewImageCVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 042F85302823E31300C8D995 /* ReviewImageCVC.swift */; };
0431513627FDACFC00634714 /* MyOrdersVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0431513527FDACFC00634714 /* MyOrdersVC.swift */; };
......@@ -87,6 +88,7 @@
04B52CF127FD6FFD00968B97 /* ItemsCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B52CF027FD6FFD00968B97 /* ItemsCollectionViewCell.swift */; };
04BD608C286F034500379038 /* SearchVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BD608B286F034500379038 /* SearchVC.swift */; };
04BD608F286F048E00379038 /* SearchCVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BD608E286F048E00379038 /* SearchCVC.swift */; };
04C9EEE9287C236500A9F075 /* AddressListVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C9EEE8287C236500A9F075 /* AddressListVM.swift */; };
04D333C4283F5955002BE271 /* Home1VC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04D333C3283F5955002BE271 /* Home1VC.swift */; };
04D333C8283F5B50002BE271 /* HomeCategCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04D333C7283F5B50002BE271 /* HomeCategCollectionViewCell.swift */; };
04D970BB2804484A0043090B /* ProductDetailVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04D970BA2804484A0043090B /* ProductDetailVC.swift */; };
......@@ -106,7 +108,7 @@
040098EF2806BDA900E76FD4 /* DMSans-Medium.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "DMSans-Medium.ttf"; sourceTree = "<group>"; };
040098F02806BDA900E76FD4 /* DMSans-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "DMSans-Regular.ttf"; sourceTree = "<group>"; };
0401017D28619F1400163067 /* ProductDetailViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductDetailViewModel.swift; sourceTree = "<group>"; };
0406A583280ED7F00052C0E5 /* MyAddressVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MyAddressVC.swift; path = Garmentoo/Controller/MyAddressVC.swift; sourceTree = SOURCE_ROOT; };
0406A583280ED7F00052C0E5 /* MyAddressVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MyAddressVC.swift; path = Garmentoo/Controller/Modules/Settings/MyAddressVC.swift; sourceTree = SOURCE_ROOT; };
040E9A982803F015001D8D44 /* OrderReviewTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderReviewTableViewCell.swift; sourceTree = "<group>"; };
040E9A9C2803FF9B001D8D44 /* OrderSuccessVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderSuccessVC.swift; sourceTree = "<group>"; };
040E9A9F28040077001D8D44 /* AddOrderReviewVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddOrderReviewVC.swift; sourceTree = "<group>"; };
......@@ -178,7 +180,6 @@
04AC8EC428217FF70035CDA1 /* SeeAllItemsCollectionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeeAllItemsCollectionCell.swift; sourceTree = "<group>"; };
04AC8EC8282180D80035CDA1 /* SeeAllItemsVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeeAllItemsVC.swift; sourceTree = "<group>"; };
04B353FB280D88A800959551 /* Bindable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Bindable.swift; sourceTree = "<group>"; };
04B50361284733370046B350 /* HomeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeModel.swift; sourceTree = "<group>"; };
04B50368284736930046B350 /* OnboardingModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingModel.swift; sourceTree = "<group>"; };
04B5036F2847385D0046B350 /* AddressModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressModel.swift; sourceTree = "<group>"; };
04B5037228473CE90046B350 /* FavouriteModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavouriteModel.swift; sourceTree = "<group>"; };
......@@ -188,6 +189,7 @@
04B52CF027FD6FFD00968B97 /* ItemsCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemsCollectionViewCell.swift; sourceTree = "<group>"; };
04BD608B286F034500379038 /* SearchVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchVC.swift; sourceTree = "<group>"; };
04BD608E286F048E00379038 /* SearchCVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchCVC.swift; sourceTree = "<group>"; };
04C9EEE8287C236500A9F075 /* AddressListVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressListVM.swift; sourceTree = "<group>"; };
04D333C3283F5955002BE271 /* Home1VC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Home1VC.swift; sourceTree = "<group>"; };
04D333C7283F5B50002BE271 /* HomeCategCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = HomeCategCollectionViewCell.swift; path = Garmentoo/Controller/Modules/Home/Cells/CVC/HomeCategCollectionViewCell.swift; sourceTree = SOURCE_ROOT; };
04D970BA2804484A0043090B /* ProductDetailVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductDetailVC.swift; sourceTree = "<group>"; };
......@@ -225,10 +227,21 @@
path = "Product Detail";
sourceTree = "<group>";
};
042B9A13287C1E6F00A535F6 /* VM */ = {
isa = PBXGroup;
children = (
046D44582872B82A0097BFF0 /* SearchViewModel.swift */,
043366D6286037A600B10DCB /* HomeViewModel.swift */,
);
path = VM;
sourceTree = "<group>";
};
0443FE9728774940000112AD /* Settings */ = {
isa = PBXGroup;
children = (
0484173927EC69A8003E396F /* ProfileVC.swift */,
0406A583280ED7F00052C0E5 /* MyAddressVC.swift */,
04C9EEE7287C230600A9F075 /* VM */,
0443FE9828774954000112AD /* Model */,
);
path = Settings;
......@@ -238,7 +251,7 @@
isa = PBXGroup;
children = (
0443FEAA28774CAF000112AD /* ProfileModel.swift */,
0443FE992877496C000112AD /* ProfleVM.swift */,
04B5036F2847385D0046B350 /* AddressModel.swift */,
);
path = Model;
sourceTree = "<group>";
......@@ -330,8 +343,8 @@
04754C3A286EF84C003E812B /* Model */ = {
isa = PBXGroup;
children = (
043366D6286037A600B10DCB /* HomeViewModel.swift */,
046D44582872B82A0097BFF0 /* SearchViewModel.swift */,
042E8623286B0E1200BB12FC /* SearchModel.swift */,
043366DA286038C600B10DCB /* Home2Model.swift */,
);
path = Model;
sourceTree = "<group>";
......@@ -437,17 +450,22 @@
04B5036028472FD20046B350 /* Model */ = {
isa = PBXGroup;
children = (
04B50361284733370046B350 /* HomeModel.swift */,
04B5036F2847385D0046B350 /* AddressModel.swift */,
04B5037228473CE90046B350 /* FavouriteModel.swift */,
04B5037528473EB50046B350 /* CartModel.swift */,
04B50378284747670046B350 /* OrderDetailModel.swift */,
043366DA286038C600B10DCB /* Home2Model.swift */,
042E8623286B0E1200BB12FC /* SearchModel.swift */,
);
path = Model;
sourceTree = "<group>";
};
04C9EEE7287C230600A9F075 /* VM */ = {
isa = PBXGroup;
children = (
0443FE992877496C000112AD /* ProfleVM.swift */,
04C9EEE8287C236500A9F075 /* AddressListVM.swift */,
);
path = VM;
sourceTree = "<group>";
};
04D333C1283F5110002BE271 /* Modules */ = {
isa = PBXGroup;
children = (
......@@ -466,6 +484,7 @@
04AC8EC8282180D80035CDA1 /* SeeAllItemsVC.swift */,
04BD608B286F034500379038 /* SearchVC.swift */,
04754C37286EF817003E812B /* Cells */,
042B9A13287C1E6F00A535F6 /* VM */,
04754C3A286EF84C003E812B /* Model */,
);
path = Home;
......@@ -489,7 +508,6 @@
04114CAD2803E75000110839 /* OrderReviewVC.swift */,
041CEE8E2849E75C00D05C61 /* SubCategoryVC.swift */,
0429944427FAF6B2007C4A29 /* EditProfileVC.swift */,
0406A583280ED7F00052C0E5 /* MyAddressVC.swift */,
0431513527FDACFC00634714 /* MyOrdersVC.swift */,
040E9A9C2803FF9B001D8D44 /* OrderSuccessVC.swift */,
040E9A9F28040077001D8D44 /* AddOrderReviewVC.swift */,
......@@ -725,8 +743,10 @@
044C03AC27EDA4BD0036D21B /* OnboardingNavVC.swift in Sources */,
041CEE8F2849E75C00D05C61 /* SubCategoryVC.swift in Sources */,
046618D027EC2CD800D65702 /* SceneDelegate.swift in Sources */,
04C9EEE9287C236500A9F075 /* AddressListVM.swift in Sources */,
04F83D2128044B7A00043E8E /* SizeCollectionViewCell.swift in Sources */,
0466828C27F4262400696FB4 /* ItemListCollectionViewCell.swift in Sources */,
042B9A0F287C1E2500A535F6 /* AddressModel.swift in Sources */,
043366C4286033B400B10DCB /* APIServices.swift in Sources */,
041E8687280FF093002AF111 /* AddAddress2.swift in Sources */,
04605B8F284094C000A15B84 /* HomePopularCollectionViewCell.swift in Sources */,
......
......@@ -7,18 +7,34 @@
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "5C2CD6BD-042E-442D-881E-D49A27FC7D76"
shouldBeEnabled = "Yes"
uuid = "8C329D8F-83CE-433D-94C2-208F9959F5D9"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Garmentoo/Controller/Modules/Home/Cells/CVC/SearchCVC.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "22"
endingLineNumber = "22"
startingLineNumber = "25"
endingLineNumber = "25"
landmarkName = "searchData"
landmarkType = "24">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "B2FD754A-83F2-46C5-B1C9-9C61227BA20E"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Garmentoo/Global/Services/APIServices.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "147"
endingLineNumber = "147"
landmarkName = "loadAddressData(complete:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
......@@ -10,7 +10,18 @@ import UIKit
class MyAddressTableViewCell: UITableViewCell {
@IBOutlet weak var outerview:UIView!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var addressLabel: UILabel!
var addressData : Address_list?
{
didSet
{
self.nameLabel.text = addressData?.firstname
let completeAddress = (addressData?.street ?? "") + (addressData?.city ?? "") + (addressData?.region ?? "")
self.addressLabel.text = completeAddress + " - " + (addressData?.postcode ?? "")
}
}
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
......
......@@ -21,7 +21,7 @@ class SearchCVC: UICollectionViewCell {
{
self.name.text = searchData?.name
self.priceLabel.text = searchData?.price
let imagelink = searchData?.image?[0]
let imagelink = searchData?.images?[0]
if imagelink != nil
{
let url = URL(string:(imagelink!))
......
......@@ -44,6 +44,10 @@ class Home1VC: UIViewController {
refreshControl.addTarget(self, action: #selector(self.refresh(_:)), for: .valueChanged)
self.searchbar.backgroundImage = UIImage()
self.mainScroll.addSubview(refreshControl) // Do any additional setup after loading the view.
if let accessToken = UserDefaults.standard.value(forKey: "AccessToken")as? String
{
print("Access token ------->",accessToken)
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
......
......@@ -33,7 +33,7 @@ struct Search_list : Codable {
let entity_id : String?
let sku : String?
let name : String?
let image : [String]?
let images : [String]?
let price : String?
enum CodingKeys: String, CodingKey {
......@@ -41,7 +41,7 @@ struct Search_list : Codable {
case entity_id = "entity_id"
case sku = "sku"
case name = "name"
case image = "image"
case images = "images"
case price = "price"
}
......@@ -50,7 +50,7 @@ struct Search_list : Codable {
entity_id = try values.decodeIfPresent(String.self, forKey: .entity_id)
sku = try values.decodeIfPresent(String.self, forKey: .sku)
name = try values.decodeIfPresent(String.self, forKey: .name)
image = try values.decodeIfPresent([String].self, forKey: .image)
images = try values.decodeIfPresent([String].self, forKey: .images)
price = try values.decodeIfPresent(String.self, forKey: .price)
}
......
......@@ -63,6 +63,7 @@ extension SearchVC
PostApiService.searchData(params: postData) { (success, data, message) in
if success
{
print("search data", data)
self.noItemsView.isHidden = true
self.searchViewModel = data?[0].search_list ?? []
self.searchItemCollection.reloadData()
......
......@@ -35,7 +35,7 @@ class HomeViewModel {
}
print("Model issue")
print(string ?? "Something went wrong")
return
}
......
......@@ -35,7 +35,7 @@ class SearchViewModel {
AppInstance.hideLoader()
}
print("else")
print(message ?? "Something went wrong")
return
}
......
......@@ -16,10 +16,14 @@ class LoginPopVC: UIViewController {
@IBOutlet weak var nameText: UITextField!
@IBOutlet weak var proceedBtnOutlet: UIButton!
@IBOutlet weak var signupHeaderLabel: UILabel!
@IBOutlet weak var signupBodyLabel: UILabel!
@IBOutlet weak var genderView: UIView!
@IBOutlet weak var genderViewHeight: NSLayoutConstraint!
@IBOutlet weak var maleRadioImage: UIImageView!
@IBOutlet weak var femaleRadioImage: UIImageView!
var isMobileEntered = true
let loginPopupVM = LoginPopViewModel()
var selectedGender = 1
override func viewDidLoad() {
super.viewDidLoad()
......@@ -36,6 +40,24 @@ class LoginPopVC: UIViewController {
}
@IBAction func genderTapped(_ sender: UIButton) {
if sender.tag == 1
{
self.selectedGender = 1
self.maleRadioImage.image = UIImage(named: "radio-button-2")
self.femaleRadioImage.image = UIImage(named: "radio-button")
}
else
{
self.selectedGender = 2
self.femaleRadioImage.image = UIImage(named: "radio-button-2")
self.maleRadioImage.image = UIImage(named: "radio-button")
}
}
@IBAction func proceedBtnAction(_ sender: UIButton) {
if self.proceedBtnOutlet.titleLabel?.text == "Proceed"
......@@ -97,6 +119,8 @@ extension LoginPopVC
self.nameText.isHidden = true
self.proceedBtnOutlet.setTitle("Verify", for: .normal)
self.signupHeaderLabel.text = "OTP Verification"
self.genderView.isHidden = true
self.genderViewHeight.constant = 0
}
else
{
......@@ -105,6 +129,8 @@ extension LoginPopVC
self.mobileText.isUserInteractionEnabled = false
self.proceedBtnOutlet.setTitle("Signup", for: .normal)
self.signupHeaderLabel.text = "SignUp"
self.genderView.isHidden = false
self.genderViewHeight.constant = 60
}
}
}
......@@ -115,7 +141,7 @@ extension LoginPopVC
{
DispatchQueue.main.async {
AppInstance.showLoader()
self.loginPopupVM.registerUser(fName: fName, email: email, phone: phoneNumber, gender: "")
self.loginPopupVM.registerUser(fName: fName, email: email, phone: phoneNumber, gender: self.selectedGender)
self.loginPopupVM.onboardingData.bind(observer: { (signupData) in
if signupData?.status == true
{
......@@ -125,16 +151,20 @@ extension LoginPopVC
DispatchQueue.main.async {
AppInstance.hideLoader()
}
// self.mobileText.text = ""
// self.mobileText.isUserInteractionEnabled = true
// self.mobileText.placeholder = "Enter OTP"
// self.mailText.isHidden = true
// self.nameText.isHidden = true
// self.proceedBtnOutlet.setTitle("Verify", for: .normal)
// self.signupHeaderLabel.text = "OTP Verification"
self.mobileText.text = ""
self.mobileText.isUserInteractionEnabled = true
self.mobileText.placeholder = "Enter OTP"
self.mailText.isHidden = true
self.nameText.isHidden = true
self.proceedBtnOutlet.setTitle("Verify", for: .normal)
self.signupHeaderLabel.text = "OTP Verification"
self.genderView.isHidden = true
self.genderViewHeight.constant = 0
}
else
{
self.genderView.isHidden = false
self.genderViewHeight.constant = 60
AppInstance.hideLoader()
self.showSnackBar(Message: "Something went wrong", duration: .middle)
......
......@@ -18,10 +18,10 @@ class LoginPopViewModel
}
}
func registerUser(fName : String , email : String, phone: String , gender: String)
func registerUser(fName : String , email : String, phone: String , gender: Int)
{
// "{\"search_key\":\"\(searcKey)\"}"
let parameters = "{\"firstName\": \"\(fName)\",\"email\": \"\(email)\",\"phonenumber\": \(phone),\"gender\":1}"
let parameters = "{\"firstName\": \"\(fName)\",\"email\": \"\(email)\",\"phonenumber\": \(phone),\"gender\":\(gender)}"
print(parameters)
let postData = parameters.data(using: .utf8)
PostApiService.userRegistration(params: postData!) { (status, data, message) in
......
......@@ -46,7 +46,7 @@ class ProductDetailVC: UIViewController,UIScrollViewDelegate {
@IBOutlet weak var productListCollection: UICollectionView!
@IBOutlet weak var descLbl: UILabel!
var dummyImgArr = ["dummy", "dummy 1","dummy 3","dummy 1","dummy"]
var imgArr = [String]()
let scrollTopEdgeInsets:CGFloat = 200 //scrollView Top insets size
......@@ -91,7 +91,6 @@ class ProductDetailVC: UIViewController,UIScrollViewDelegate {
AppInstance.showLoader()
self.productViewModel.loadProductDetails(id: self.product_id)
}
do{
self.productViewModel.ProdData.bind {[weak self] (ProdModel) in
DispatchQueue.main.async {
......@@ -102,16 +101,11 @@ class ProductDetailVC: UIViewController,UIScrollViewDelegate {
}
AppInstance.hideLoader()
self?.reloadData()
}
}
}
catch
{
AppInstance.hideLoader()
self.showSnackBar(Message: "Something went wrong", duration: .middle)
}
}
func updateUI(Product: Product_detail)
......@@ -121,18 +115,27 @@ class ProductDetailVC: UIViewController,UIScrollViewDelegate {
let imagelink = Product.image
if !(imagelink!.isEmpty)
{
let url = URL(string:(RestApiManager.sharedInstance.baseURL + imagelink![0]))
let urlStr = imagelink![0]
let url = URL(string:(urlStr))
self.productImage.kf.indicatorType = .activity
self.productImage.kf.setImage(with: url, placeholder: UIImage(named: "placeholderImage"), options: .none, completionHandler: nil)
}
self.descLbl.text = Product.description ?? ""
let description = Product.description
let a = description?.replacingOccurrences(of: "<[^>]+>", with: "", options: String.CompareOptions.regularExpression, range: nil)
let b = a?.replacingOccurrences(of: "&[^;]+;", with: "", options: String.CompareOptions.regularExpression, range: nil)
self.descLbl.text = b
let x = Double(Product.price ?? "0.00")!
let y = Double(round(100 * x) / 100)
self.newPrice.text = "\(y)"
self.newPrice.text = "Rs : \(y)"
self.oldPrice.text = "\(y)"
// self.imgArr = Product.image ?? [""]
// DispatchQueue.main.async {
// self.productListCollection.reloadData()
// }
}
func reloadData()
......@@ -183,7 +186,7 @@ class ProductDetailVC: UIViewController,UIScrollViewDelegate {
}
else
{
print("AccessToken----->", accessToken)
print("AccessToken----->", accessToken!)
}
......@@ -215,7 +218,7 @@ extension ProductDetailVC:UICollectionViewDelegate,UICollectionViewDataSource ,
else
if collectionView == self.productListCollection
{
return 5
return self.imgArr.count
}
return bulk.count
}
......@@ -258,7 +261,10 @@ extension ProductDetailVC:UICollectionViewDelegate,UICollectionViewDataSource ,
{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "produtImageList", for: indexPath) as! ProductImageListCVC
cell.productImage.image = UIImage(named: self.dummyImgArr[indexPath.row])
if !(self.imgArr.isEmpty)
{
cell.productImage.image = UIImage(named: self.imgArr[indexPath.row])
}
return cell
}
......@@ -293,7 +299,7 @@ extension ProductDetailVC:UICollectionViewDelegate,UICollectionViewDataSource ,
}
else if collectionView == self.productListCollection
{
self.productImage.image = UIImage(named: self.dummyImgArr[indexPath.row])
self.productImage.image = UIImage(named: self.imgArr[indexPath.row])
}
else
{
......
......@@ -53,7 +53,7 @@ class ProductDetailViewModel
}
print("else")
print(string ?? "Something went wrong")
return
}
......
//
// AddressModel.swift
// Garmentoo
//
// Created by Angel F Syrus on 01/06/22.
//
import Foundation
struct AddressListModel: Codable {
let status : Bool?
let message : String?
let default_billing_address_id : String?
let default_shipping_address_id : String?
let address_list : [Address_list]?
enum CodingKeys: String, CodingKey {
case status = "status"
case message = "message"
case default_billing_address_id = "default_billing_address_id"
case default_shipping_address_id = "default_shipping_address_id"
case address_list = "address_list"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
status = try values.decodeIfPresent(Bool.self, forKey: .status)
message = try values.decodeIfPresent(String.self, forKey: .message)
default_billing_address_id = try values.decodeIfPresent(String.self, forKey: .default_billing_address_id)
default_shipping_address_id = try values.decodeIfPresent(String.self, forKey: .default_shipping_address_id)
address_list = try values.decodeIfPresent([Address_list].self, forKey: .address_list)
}
}
struct Address_list : Codable {
let address_id : String?
let firstname : String?
let street : String?
let city : String?
let region : String?
let country_id : String?
let postcode : String?
let telephone : String?
enum CodingKeys: String, CodingKey {
case address_id = "address_id"
case firstname = "firstname"
case street = "street"
case city = "city"
case region = "region"
case country_id = "country_id"
case postcode = "postcode"
case telephone = "telephone"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
address_id = try values.decodeIfPresent(String.self, forKey: .address_id)
firstname = try values.decodeIfPresent(String.self, forKey: .firstname)
street = try values.decodeIfPresent(String.self, forKey: .street)
city = try values.decodeIfPresent(String.self, forKey: .city)
region = try values.decodeIfPresent(String.self, forKey: .region)
country_id = try values.decodeIfPresent(String.self, forKey: .country_id)
postcode = try values.decodeIfPresent(String.self, forKey: .postcode)
telephone = try values.decodeIfPresent(String.self, forKey: .telephone)
}
}
......@@ -8,7 +8,7 @@
import UIKit
class MyAddressVC: UIViewController {
@IBOutlet weak var table: UITableView!
@IBOutlet weak var tableHeight: NSLayoutConstraint!
@IBOutlet weak var currentName: UILabel!
......@@ -16,38 +16,28 @@ class MyAddressVC: UIViewController {
@IBOutlet weak var deliverBtnOutlet: UIButton!
@IBOutlet weak var deliverBtnHeight: NSLayoutConstraint!
@IBOutlet weak var deliverBtnBottom: NSLayoutConstraint!
@IBOutlet weak var topOuterView: UIView!
var isFromCart = false
var addressModel = AddressListVM()
var addressList = [Address_list]()
override func viewDidLoad() {
super.viewDidLoad()
setui()
}
func setui()
{
if self.isFromCart
{
self.deliverBtnOutlet.isHidden = false
self.deliverBtnHeight.constant = 50
self.deliverBtnBottom.constant = 30
}
else
{
self.deliverBtnOutlet.isHidden = true
self.deliverBtnHeight.constant = 0
self.deliverBtnBottom.constant = 0
}
setui()
self.topOuterView.backgroundColor = UIColor.viewBg
}
override func viewWillLayoutSubviews() {
// self.tableHeight.constant = self.table.contentSize.height
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(true)
self.loadAddressData()
}
override func viewWillLayoutSubviews() {
// self.tableHeight.constant = self.table.contentSize.height
}
@IBAction func onTapBackBtn(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
......@@ -91,7 +81,7 @@ setui()
extension MyAddressVC:UITableViewDelegate,UITableViewDataSource
{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
return self.addressList.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
......@@ -107,3 +97,56 @@ extension MyAddressVC:UITableViewDelegate,UITableViewDataSource
}
extension MyAddressVC
{
func setui()
{
if self.isFromCart
{
self.deliverBtnOutlet.isHidden = false
self.deliverBtnHeight.constant = 50
self.deliverBtnBottom.constant = 30
}
else
{
self.deliverBtnOutlet.isHidden = true
self.deliverBtnHeight.constant = 0
self.deliverBtnBottom.constant = 0
}
self.topOuterView.backgroundColor = UIColor.viewBg
}
func loadAddressData()
{
DispatchQueue.main.async {
AppInstance.showLoader()
self.addressModel.getAddressList()
}
do{
self.addressModel.addressData.bind { [weak self](addressData) in
DispatchQueue.main.async {
AppInstance.hideLoader()
}
if addressData != nil
{
if addressData?.status == true
{
self?.addressList = (addressData?.address_list)!
DispatchQueue.main.async {
self?.table.reloadData()
}
}
}
else
{
}
}
}
}
}
......@@ -65,24 +65,34 @@ extension ProfileVC
self.profileModel.profileData.bind {[weak self] (profileData) in
DispatchQueue.main.async {
AppInstance.hideLoader()
}
if profileData?.status == true
{
self?.mailText.text = profileData?.email
// self?.phoneText.text = profileData.
self?.locationText.text = profileData?.address
self?.zipcodeText.text = profileData?.pincode
let imagelink = profileData?.profile_image
if !(imagelink!.isEmpty)
{
let url = URL(string:(RestApiManager.sharedInstance.baseURL + imagelink!))
self?.profPic.kf.indicatorType = .activity
self?.profPic.kf.setImage(with: url, placeholder: UIImage(named: "placeholderImage"), options: .none, completionHandler: nil)
}
self?.updateValue(profileData!)
}
else
{
self?.showSnackBar(Message: profileData?.message ?? "Something went wrong!!!", duration: .middle)
}
}
}
}
func updateValue(_ response : ProfileModel)
{
self.mailText.text = response.email
// self?.phoneText.text = profileData.
self.locationText.text = response.address
self.zipcodeText.text = response.pincode
let imagelink = response.profile_image
if !(imagelink!.isEmpty)
{
let url = URL(string:(imagelink!))
self.profPic.kf.indicatorType = .activity
self.profPic.kf.setImage(with: url, placeholder: UIImage(named: "placeholderImage"), options: .none, completionHandler: nil)
}
}
}
//
// AddressListVM.swift
// Garmentoo
//
// Created by Angel F Syrus on 11/07/22.
//
import Foundation
class AddressListVM
{
let apiDataParser = APIServices()
var addressData = Bindable<AddressListModel>()
var model: AddressListModel? {
didSet {
self.addressData.value = model
}
}
func getAddressList()
{
APIServices.loadAddressData { (success, data, message) in
if success && data?[0].status == true
{
self.model = data?[0]
}
else
{
DispatchQueue.main.async {
AppInstance.hideLoader()
}
self.model = nil
print(message ?? "something went wrong")
return
}
}
}
}
......@@ -20,28 +20,28 @@ class ProfileVM
func loadProfileData()
{
APIServices.getProfileDetails{(success, data, string) in
if success && data?[0].status == true
{
self.model = data?[0]
}
else
{
DispatchQueue.main.async {
AppInstance.hideLoader()
}
print(string ?? "something went wrong")
return
}
}
APIServices.getProfileDetails{(success, data, message) in
if success && data?[0].status == true
{
self.model = data?[0]
}
else
{
DispatchQueue.main.async {
AppInstance.hideLoader()
}
print(message ?? "something went wrong")
return
}
}
}
}
......@@ -9,7 +9,23 @@ import Foundation
import Alamofire
struct APIServices
{
//MARK:- Home details
static func getAccessToken() -> String
{
let accessToken = UserDefaults.standard.value(forKey: "AccessToken")as! String
if accessToken != ""
{
let token = "Bearer " + accessToken
return token
}
else
{
return ""
}
}
// Home details
static func getHomeData(complete:@escaping ( Bool , _ serviceList:[HomeModel]?,_ errorString : String?) -> ())
{
// let URL = RestApiManager.sharedInstance.baseURL + "model3/orders"
......@@ -34,19 +50,19 @@ struct APIServices
complete(true, responseOBJ, responseOBJ[0].message)
}catch _{
complete(false,nil, "String")
complete(false,nil, response.error?.localizedDescription)
}
}
}
case .failure( _):
complete( false,nil,"Something went wrong")
complete( false,nil,response.error?.localizedDescription ?? "Something went wrong")
}
}
}
//MARK:- ProfileData
//ProfileData
static func getProfileDetails(complete:@escaping ( Bool , _ serviceList:[ProfileModel]?,_ errorString : String?) -> ())
{
// let URL = RestApiManager.sharedInstance.baseURL + "model3/orders"
......@@ -58,7 +74,6 @@ struct APIServices
request.httpMethod = "GET"
AF.request(request).validate().responseJSON { response in
print("response json called")
switch response.result
{
case .success( _):
......@@ -75,12 +90,12 @@ struct APIServices
}
else
{
complete(false,nil, "String")
complete(false,nil, response.error?.localizedDescription)
}
}catch _{
complete(false,nil, "String")
complete(false,nil, response.error?.localizedDescription)
}
}
}
......@@ -92,4 +107,49 @@ struct APIServices
}
//AddressData
static func loadAddressData(complete:@escaping ( Bool , _ serviceList:[AddressListModel]?,_ errorString : String?) -> ())
{
// let URL = RestApiManager.sharedInstance.baseURL + "model3/orders"
let URL = RestApiManager.sharedInstance.baseURL + "/rest/V2/address_view"
var request = URLRequest(url: NSURL.init(string: URL)! as URL)
request.addValue(self.getAccessToken(), forHTTPHeaderField: "Authorization")
request.httpMethod = "GET"
AF.request(request).validate().responseJSON { response in
switch response.result
{
case .success( _):
if response.response?.statusCode == 200
{
if let jsonData = response.data {
let jsonDecoder = JSONDecoder()
do {
_ = String(data: response.data!, encoding: String.Encoding.utf8)
let responseOBJ = try jsonDecoder.decode([AddressListModel].self, from: jsonData)
if !responseOBJ.isEmpty
{
complete(true, responseOBJ, responseOBJ[0].message)
}
else
{
complete(false,nil, response.error?.localizedDescription)
}
}catch _{
complete(false,nil, response.error?.localizedDescription)
}
}
}
case .failure( _):
complete( false,nil,"Something went wrong")
}
}
}
}
......@@ -37,13 +37,13 @@ struct PostApiService {
complete(true, responseOBJ, responseOBJ[0].message)
}catch _{
complete(false,[], "String")
complete(false,[], response.error?.localizedDescription)
}
}
}
case .failure( _):
complete( false,[],"Something went wrong")
complete( false,[],response.error?.localizedDescription)
}
}
}
......@@ -76,8 +76,8 @@ struct PostApiService {
complete(true, responseOBJ, responseOBJ[0].message)
}catch _{
complete(false,nil, "String")
complete(false,[], response.error?.localizedDescription)
}
}
}
......@@ -113,8 +113,8 @@ struct PostApiService {
complete(true, responseOBJ, responseOBJ[0].message)
}catch _{
complete(false,nil, "String")
complete(false,[], response.error?.localizedDescription)
}
}
}
......@@ -147,8 +147,8 @@ struct PostApiService {
complete(responseOBJ[0].status ?? false, responseOBJ, responseOBJ[0].message)
}catch _{
complete(false,nil, "String")
complete(false,[], response.error?.localizedDescription)
}
}
}
......@@ -184,8 +184,8 @@ struct PostApiService {
complete(true, responseOBJ, responseOBJ[0].message)
}catch _{
complete(false,nil, "String")
complete(false,[], response.error?.localizedDescription)
}
}
}
......
//
// AddressModel.swift
// Garmentoo
//
// Created by Angel F Syrus on 01/06/22.
//
import Foundation
struct AddressListModel: Codable {
let status: Bool
let message: String
let addressList: [AddressList]
enum CodingKeys: String, CodingKey {
case status, message
case addressList = "address_list"
}
}
// MARK: - AddressList
struct AddressList: Codable {
let addressID: Int
let name, address, mobile, email: String
enum CodingKeys: String, CodingKey {
case addressID = "address_id"
case name, address, mobile, email
}
}
//
// HomeModel.swift
// Garmentoo
//
// Created by Angel F Syrus on 01/06/22.
//
import Foundation
// MARK: - WelcomeElement
struct HomeModel: Codable {
let status, message: String
let categories: [Category]
let popularProducts, recommendedProducts: [Product]
let dealsForYou: [DealsForYou]
enum CodingKeys: String, CodingKey {
case status, message, categories
case popularProducts = "popular_products"
case recommendedProducts = "recommended_products"
case dealsForYou = "deals_for_you"
}
}
// MARK: - Category
struct Category: Codable {
let category, categoryID, categoryImage: String
enum CodingKeys: String, CodingKey {
case category
case categoryID = "category_id"
case categoryImage = "category_image"
}
}
// MARK: - DealsForYou
struct DealsForYou: Codable {
let url, type, image: String
}
// MARK: - Product
struct Product: Codable {
let productID, sku, productName, price: String
let productImage: String
enum CodingKeys: String, CodingKey {
case productID = "product_id"
case sku
case productName = "product_name"
case price
case productImage = "product_image"
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment