ChandanAppdesk

ArtistDetailsVC+Methods.swift

Mar 6th, 2024
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 37.80 KB | Source Code | 0 0
  1. //
  2. // ArtistDetailsVC+Methods.swift
  3. // hubble-ios
  4. //
  5. // Created by Appdesk Services PVT. LTD. on 03/07/23.
  6. // Copyright (c) 2023 Hubble. All rights reserved.
  7. //
  8.  
  9. import Foundation
  10. import GoogleMaps
  11. import AVFoundation
  12. import SDWebImage
  13. import SnapshotKit
  14. import TagListView
  15.  
  16. // MARK: - Targets Methods
  17. extension ArtistDetailsVC {
  18.  
  19.     @objc func backHomeTapped() {
  20.         navigationController?.popViewController(animated: true)
  21.     }
  22.  
  23.     @objc func threeDotMenuButtonTapped() {
  24.         threeDotMenu.anchorView = self.threeDotMenuButton
  25.         threeDotMenu.bottomOffset = CGPoint(x: .zero, y: (threeDotMenu.anchorView?.plainView.bounds.height) ?? .zero)
  26.         threeDotMenu.show()
  27.         threeDotMenu.selectionAction = { [weak self] index, title in
  28.             self?.threeDotMenu.deselectRow(at: index)
  29.             switch index {
  30.             case .zero:
  31.                 self?.takeScreenShortAndShareImage()
  32.             case 1:
  33.                 self?.reportArtistProfile()
  34.             default: break
  35.             }
  36.             self?.threeDotMenu.removeFromSuperview()
  37.         }
  38.     }
  39.  
  40.     func reportArtistProfile() {
  41.         let reportType: [String] = [
  42.             "Inappropriate Content",
  43.             "Inappropriate Behavior",
  44.             "Misrepresentation",
  45.             "Spam",
  46.             "Suspicious Activity",
  47.             "Unsafe or Unsanitary environment",
  48.             "Unprofessional Communication",
  49.             "Other"
  50.         ]
  51.         let reportSheet = ReportOptionSheetVC()
  52.         reportSheet.options = reportType
  53.         reportSheet.artistId = self.artistID ?? K.emptyString
  54.         if let sheet = reportSheet.sheetPresentationController {
  55.             sheet.detents = [.custom(resolver: { context in
  56.                 context.maximumDetentValue * 0.65
  57.             })]
  58.             sheet.preferredCornerRadius = 12.0
  59.         }
  60.         reportSheet.reportSuccessCallback = { [weak self] message in
  61.             reportSheet.dismiss(animated: true)
  62.             DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: {
  63.                 self?.showMessage(message: message)
  64.             })
  65.         }
  66.         self.present(reportSheet, animated: true)
  67.     }
  68.    
  69.     func showMessage(message: String) {
  70.         self.showSnackbar(message: "snakebar_message_profile_detail_Reported_successfully".myLocalizedString)
  71.     }
  72.  
  73.     func takeScreenShortAndShareImage() {
  74.         backButton.isHidden = true
  75.         threeDotMenu.hide()
  76.         self.contentView.asyncTakeSnapshotOfFullContent { [weak self] screenshot in
  77.             guard let self = self else { return }
  78.             let waterMarked = addWatermark(to: screenshot ?? UIImage(), with: .waterMark ?? UIImage(), at: .init(x: contentView.x + 30, y: self.contentView.centerY))
  79.             let sharesheet = UIActivityViewController(activityItems: [waterMarked], applicationActivities: .none)
  80.             self.present(sharesheet, animated: true) {
  81.                 self.backButton.isHidden = false
  82.             }
  83.         }
  84.     }
  85.    
  86.     @objc func seeMoreAllServicesButtonTapped() {
  87.         let allServicesVC = AllServicesVC()
  88.         allServicesVC.allservicelist = allServiceDetails
  89.         allServicesVC.artistId = self.artistID
  90.         navigationController?.pushViewController(allServicesVC, animated: true)
  91.     }
  92.  
  93.     @objc func seeAboutButtonTapped() {
  94.         let seeMoreDetailsVC = SeeMoreDetailsVC()
  95.         seeMoreDetailsVC.seeMoreTitle = "service_detail_see_more_about_text".myLocalizedString
  96.         seeMoreDetailsVC.seeMoreDetials = seeAboutDetails
  97.         if let sheet = seeMoreDetailsVC.sheetPresentationController {
  98.             sheet.detents = [.medium()]
  99.             sheet.largestUndimmedDetentIdentifier = .medium
  100.             sheet.prefersScrollingExpandsWhenScrolledToEdge = false
  101.             sheet.prefersEdgeAttachedInCompactHeight = true
  102.             sheet.widthFollowsPreferredContentSizeWhenEdgeAttached = true
  103.         }
  104.         self.present(seeMoreDetailsVC, animated: true)
  105.     }
  106.  
  107.     @objc func termAndConditionButtonTapped() {
  108.   //      let seeMoreDetailsVC = SeeMoreDetailsVC()
  109. //        seeMoreDetailsVC.seeMoreTitle = "service_detail_see_more_termCondition_text".myLocalizedString
  110. //        seeMoreDetailsVC.seeMoreDetials = K.emptyString
  111. //        if let sheet = seeMoreDetailsVC.sheetPresentationController {
  112. //            sheet.detents = [.medium()]
  113. //            sheet.largestUndimmedDetentIdentifier = .medium
  114. //            sheet.prefersScrollingExpandsWhenScrolledToEdge = false
  115. //            sheet.prefersEdgeAttachedInCompactHeight = true
  116. //            sheet.widthFollowsPreferredContentSizeWhenEdgeAttached = true
  117. //        }
  118. //        self.present(seeMoreDetailsVC, animated: true)
  119.         self.pushToWebScreen(title: K.termsConditionsTitle, urlString: K.termsConditionsUrl)
  120.     }
  121.  
  122.     @objc func requestBookingButtonTapped() {
  123.         if allServices.isEmpty {
  124.             self.showSnackbar(message: "artist_about_no_services_snackbar_message".myLocalizedString)
  125.         } else {
  126.             let selectServiceVC = SelectServiceVC()
  127.             selectServiceVC.allservicelist = allServiceDetails
  128.             selectServiceVC.artistId = self.artistID
  129.             selectServiceVC.willingToNegotiate = self.willingToNegotiate
  130.             navigationController?.pushViewController(selectServiceVC, animated: true)
  131.         }
  132.     }
  133.  
  134.     func pushToWebScreen(title: String, urlString: String) {
  135.         let webContentVC = WebContentVC()
  136.         webContentVC.webTitle = title
  137.         webContentVC.webUrl = urlString
  138.         self.navigationController?.pushViewController(webContentVC, animated: true)
  139.     }
  140. }
  141.  
  142. // MARK: - Private Methods
  143. extension ArtistDetailsVC {
  144.     private func getVideoPhotoURLFromFileKey(_ data: ArtistDetails) {
  145.         // Profile Picture
  146.         if let profileImageURL = URL(string: data.profilePictureKey) {
  147.             self.profileBackgroundImageView.sd_setImage(with: profileImageURL)
  148.         }
  149.         // Photos
  150.         let photoUrls = data.portfolioPhotos.map { $0.mediaURL }
  151.         for photoKey in photoUrls {
  152.             let url = URL(string: photoKey) ?? K.compnyUrl
  153.             SDWebImageManager.shared.loadImage(with: url, progress: .none) { image, _, _, _, _, _ in
  154.                 if let image = image {
  155.                     self.allImagesArtistDetails.append(image)
  156.                 }
  157.             }
  158.         }
  159.         // Videos
  160.         for videoKey in data.portfolioVideos {
  161.             Task {
  162.                 let videoURL = URL(string: videoKey.mediaURL) ?? K.compnyUrl
  163.                 let thumbnail = await AVAsset(url: videoURL).generateThumbnailAsync(seconds: 1)
  164.                 self.allVideosArtistDetails.append(.init(videoUrl: videoURL, videoKey: videoKey.fileName, thumbnail: thumbnail, status: .uploaded))
  165.                 self.videoCollection.collectionViewLayout = self.createLayoutVideos()
  166.                 self.videoCollection.reloadData()
  167.             }
  168.         }
  169.     }
  170.  
  171.     func loadMapUI(latitude: Double, logitude: Double) {
  172.         let camera = GMSCameraPosition.camera(withLatitude: latitude, longitude: logitude, zoom: 19.0)
  173.         self.mapView.camera = camera
  174.         self.mapView.isMyLocationEnabled = true
  175.         mapView.isUserInteractionEnabled = false
  176.         DispatchQueue.main.async {
  177.             let maker = GMSMarker()
  178.             maker.tracksViewChanges = false
  179.             let markerImage = UIImage(named: "locationPin")
  180.             let markerView = UIImageView(image: markerImage)
  181.             markerView.frame = CGRect(x: 0, y: 0, width: 25, height: 30)
  182.             maker.iconView = markerView
  183.             maker.position = CLLocationCoordinate2D(latitude: latitude, longitude: logitude)
  184.             maker.map = self.mapView
  185.         }
  186.     }
  187.  
  188.     func getUserArtistDetails(data: ArtistDetails) {
  189.         allServiceDetails = data.services
  190.         loadMapUI(latitude: data.primaryLocation.coordinates[1], logitude: data.primaryLocation.coordinates[0])
  191.         userTypeNameLabel.text = data.userType
  192.         let name = data.showLastName ? "\(data.firstName) \(data.lastName)" : data.firstName
  193.         artistName.text = data.userType == UserType.artist ? name : data.organizationName
  194.         artistUserName.text = "@\(data.userName)"
  195.         let reviews = data.rating ?? .zero
  196.         let roundedValue = (reviews * 10).rounded() / 10
  197.         reatingsTextlabel.text = String(roundedValue)
  198.         memberSinceLabel.text = convertTimestampToMonthAndYear(timestamp: data.createdAt)
  199.         priceLabel.text = String("$\(data.price ?? 0)") + "/\(data.rate ?? "0.0")"
  200.         noOfBookingLabel.text = String(data.numberOfBooking ?? 0)
  201.         aboutLabel.text = data.about
  202.         var serviceName: [String] = []
  203.         data.services.forEach { service in
  204.             if serviceName.count > 3 { return }
  205.             serviceName.append(service.serviceName)
  206.         }
  207.         self.allServices = serviceName
  208.         self.reviewDetails = data.reviews
  209.         self.setUpUI()
  210.         let ratingStar = data.rating ?? .zero
  211.         if ratingStar < 0.5 {
  212.             reatingsTextlabel.isHidden = true
  213.             reatingStarImageView.isHidden = true
  214.         } else {
  215.             reatingsTextlabel.text = String(roundedValue)
  216.             reviewRatingLabel.text = String(roundedValue)
  217.             self.reatingStarImageView.isHidden = false
  218.         }
  219.         fromCountryChipsView.addTag(data.primaryLocation.address)
  220.         fromCountryChipsView.cornerRadius = 8.0
  221.         spokenLanguageChipsView.addTags(data.languages)
  222.         spokenLanguageChipsView.cornerRadius = 8.0
  223.         if let availability = data.availability {
  224.             self.allAbilibilityMondayChipText = availability.monday
  225.             handleHeightOfAbilibility(
  226.                 tagView: abilibilityMondayChipsView,
  227.                 tagData: allAbilibilityMondayChipText,
  228.                 titleLabel: abilibilityMondayTitleText,
  229.                 upperLabel: abilibilityTitleText
  230.             )
  231.             self.allAbilibilityTuesdayChipText = availability.tuesday
  232.             handleHeightOfAbilibility(
  233.                 tagView: abilibilityTuesdayChipsView,
  234.                 tagData: allAbilibilityTuesdayChipText,
  235.                 titleLabel: abilibilityTuesdayTitleText,
  236.                 upperLabel: abilibilityMondayTitleText
  237.             )
  238.             self.allAbilibilityWednesdayChipText = availability.wednesday
  239.             handleHeightOfAbilibility(
  240.                 tagView: abilibilityWednesdayChipsView,
  241.                 tagData: allAbilibilityWednesdayChipText,
  242.                 titleLabel: abilibilityWednesdayTitleText,
  243.                 upperLabel: abilibilityTuesdayTitleText
  244.             )
  245.             self.allAbilibilityThusdayChipText = availability.thursday
  246.             handleHeightOfAbilibility(
  247.                 tagView: abilibilityThusdayChipsView,
  248.                 tagData: allAbilibilityThusdayChipText,
  249.                 titleLabel: abilibilityThusdayTitleText,
  250.                 upperLabel: abilibilityWednesdayTitleText
  251.             )
  252.             self.allAbilibilityFridayChipText = availability.friday
  253.             handleHeightOfAbilibility(
  254.                 tagView: abilibilityFridayChipsView,
  255.                 tagData: allAbilibilityFridayChipText,
  256.                 titleLabel: abilibilityFridayTitleText,
  257.                 upperLabel: abilibilityThusdayTitleText
  258.             )
  259.             self.allAbilibilitySaturdayChipText = availability.saturday
  260.             handleHeightOfAbilibility(
  261.                 tagView: abilibilitySaturdayChipsView,
  262.                 tagData: allAbilibilitySaturdayChipText,
  263.                 titleLabel: abilibilitySaturdayTitleText,
  264.                 upperLabel: abilibilityFridayTitleText
  265.             )
  266.             self.allAbilibilitySundayChipText = availability.sunday
  267.             handleHeightOfAbilibility(
  268.                 tagView: abilibilitySundayChipsView,
  269.                 tagData: allAbilibilitySundayChipText,
  270.                 titleLabel: abilibilitySundayTitleText,
  271.                 upperLabel: abilibilitySaturdayTitleText
  272.             )
  273.         }
  274.         willingnessToTravelTitelText.snp.remakeConstraints { make in
  275.             make.left.equalTo(avilivilityBgView).offset(12)
  276.             make.right.equalTo(avilivilityBgView).inset(12)
  277.             if allAbilibilitySundayChipText.isEmpty {
  278.                 make.top.equalTo(arrayOfAbilibilitysChipView[lastDisplayedArrayIndexOfAbilibilitysChipView - 1].bottom).offset(topOffset)
  279.             } else {
  280.                 make.top.equalTo(abilibilitySundayChipsView.snp.bottom).offset(topOffset)
  281.             }
  282.         }
  283.         willingnessToTravelChipsView.addTag(data.willingToTravel ? "Yes" : "No")
  284.         willingnessToTravelChipsView.cornerRadius = 8.0
  285.         willingnessToNegotiateChipsView.addTag(data.willingToNegotiate ? "Yes": "No")
  286.         willingnessToNegotiateChipsView.cornerRadius = 8.0
  287.         equipmentOnHandChipsView.addTags(data.equipmentsOnHand)
  288.         equipmentOnHandChipsView.cornerRadius = 8.0
  289.         technicalRiderChipsView.addTags(data.technicalRider)
  290.         technicalRiderChipsView.cornerRadius = 8.0
  291.         seeAboutDetails = data.about
  292.         willingToNegotiate = data.willingToNegotiate
  293.         updateConstraints(data: data)
  294.         getVideoPhotoURLFromFileKey(data)
  295.     }
  296.  
  297.     func handleHeightOfAbilibility(tagView: TagListView, tagData: [String], titleLabel: UILabel, upperLabel: UILabel) {
  298.         if tagData.isEmpty {
  299.             titleLabel.snp.remakeConstraints { make in
  300.                 make.bottom.equalTo(upperLabel)
  301.             }
  302.             tagView.snp.remakeConstraints { make in
  303.                 make.bottom.equalTo(upperLabel)
  304.             }
  305.             titleLabel.isHidden = true
  306.             tagView.isHidden = true
  307.         } else {
  308.             titleLabel.snp.remakeConstraints { make in
  309.                 make.top.equalTo(
  310.                     self.lastDisplayedArrayIndexOfAbilibilitysChipView == .zero ?
  311.                     abilibilityTitleText.bottom :
  312.                         arrayOfAbilibilitysChipView[
  313.                             self.lastDisplayedArrayIndexOfAbilibilitysChipView - 1
  314.                         ].bottom
  315.                 ).offset(topOffset)
  316.                 make.left.equalTo(avilivilityBgView).offset(12)
  317.                 make.right.equalTo(avilivilityBgView).inset(12)
  318.             }
  319.             tagView.cornerRadius = 8.0
  320.             tagView.addTags(tagData)
  321.             self.lastDisplayedArrayIndexOfAbilibilitysChipView = tagView.tag
  322.         }
  323.     }
  324.  
  325.     func updateConstraints(data: ArtistDetails) {
  326.         let maxWidth = UIScreen.main.bounds.size.width - 40
  327.         let dummyAboutTextLabelHeight = self.dummyAboutTextLabel.sizeThatFits(CGSize(width: maxWidth, height: CGFloat.greatestFiniteMagnitude))
  328.         let aboutLabelHeight = self.aboutLabel.sizeThatFits(CGSize(width: maxWidth, height: CGFloat.greatestFiniteMagnitude))
  329.  
  330.         if dummyAboutTextLabelHeight.height > aboutLabelHeight.height {
  331.             seeMoreAboutButton.snp.removeConstraints()
  332.             seeMoreAboutButton.isHidden = true
  333.         } else {
  334.             seeMoreAboutButton.isHidden = false
  335.         }
  336.         if reviewDetails.isEmpty {
  337.             ratingStackView.isHidden = true
  338.             contentView.snp.updateConstraints { make in
  339.                 make.height.equalTo(contentViewHeight - 170)
  340.             }
  341.         }
  342.         let height = calculateSizeOfServicesStack()
  343.         contentView.snp.updateConstraints { make in
  344.             make.height.equalTo(contentViewHeight + height)
  345.        }
  346.  
  347.         let languageHeight = calculateSizeOfLanguagesStack()
  348.         aboutView.snp.updateConstraints { make in
  349.             make.height.equalTo(aboutView.height + languageHeight + aboutLabel.intrinsicContentSize.height)
  350.         }
  351.         self.contentView.snp.updateConstraints { make in
  352.             make.height.equalTo(contentViewHeight + languageHeight + aboutLabel.intrinsicContentSize.height + seeMoreAboutButton.height)
  353.         }
  354.        
  355.         avilivilityBgView.snp.updateConstraints { make in
  356.             make.height.equalTo(calculateTagViewHeight() + 600)
  357.         }
  358.         let finalContentViewHeight = self.contentViewHeight + avilivilityBgView.height + calculateTagViewHeight() + 100 + (reviewDetails.isEmpty ? 0 : 250)
  359.         contentView.snp.updateConstraints { make in
  360.             make.height.equalTo(finalContentViewHeight)
  361.         }
  362.         contentView.setNeedsLayout()
  363.         contentView.updateConstraints()
  364.         if data.portfolioPhotos.isEmpty && data.portfolioVideos.isEmpty {
  365.             portfolioBgView.isHidden = true
  366.             servicesTextLabel.snp.remakeConstraints { make in
  367.                 make.top.equalTo(aboutView.bottom).offset(12)
  368.                 make.left.equalTo(contentView).offset(16)
  369.                 make.height.equalTo(24)
  370.             }
  371.             contentView.snp.updateConstraints { make in
  372.                 make.height.equalTo(finalContentViewHeight - 600)
  373.             }
  374.             return
  375.         }
  376.  
  377.         if data.portfolioPhotos.isEmpty {
  378.             photosTextLabel.isHidden = true
  379.             photoCollection.isHidden = true
  380.             videosTextLabel.snp.remakeConstraints { make in
  381.                 make.top.equalTo(portfolioTextLabel.bottom).offset(topOffset)
  382.                 make.left.equalTo(portfolioTextLabel.left)
  383.             }
  384.             videoCollection.snp.remakeConstraints { make in
  385.                 make.top.equalTo(videosTextLabel.snp.bottom).offset(topOffset)
  386.                 make.left.equalTo(portfolioBgView).offset(leftOffset)
  387.                 make.right.equalTo(portfolioBgView).inset(rightInset)
  388.                 make.height.equalTo(230)
  389.             }
  390.             portfolioBgView.snp.updateConstraints { make in
  391.                 let portfolioTextMargin = 50.0
  392.                 make.height.equalTo((portfolioBgView.height/2) + portfolioTextMargin)
  393.             }
  394.             contentView.snp.updateConstraints { make in
  395.                 make.height.equalTo(finalContentViewHeight - 250)
  396.             }
  397.         }
  398.         if data.portfolioVideos.isEmpty {
  399.             videosTextLabel.isHidden = true
  400.             videoCollection.isHidden = true
  401.             portfolioBgView.snp.updateConstraints { make in
  402.                 let portfolioTextMargin = 50.0
  403.                 make.height.equalTo((portfolioBgView.height/2) + portfolioTextMargin)
  404.             }
  405.             contentView.snp.updateConstraints { make in
  406.                 make.height.equalTo(finalContentViewHeight - 250)
  407.             }
  408.         }
  409.         contentView.setNeedsLayout()
  410.         contentView.updateConstraints()
  411.     }
  412.  
  413.     func setUpUI() {
  414.         self.view.addSubview(scrollView)
  415.         scrollView.snp.makeConstraints { make in
  416.             make.top.equalTo(self.view.safeAreaLayoutGuide)
  417.             make.bottom.left.right.equalTo(self.view)
  418.             make.width.equalTo(self.view)
  419.             make.bottom.equalTo(self.view.safeAreaLayoutGuide).inset(96)
  420.         }
  421.         self.view.addSubview(requestBooking.container)
  422.         requestBooking.container.snp.makeConstraints { make in
  423.             make.left.right.equalTo(self.view)
  424.             make.top.equalTo(scrollView.snp.bottom)
  425.             make.bottom.equalTo(self.view.safeAreaLayoutGuide)
  426.             make.height.equalTo(Common.containerHeight96)
  427.         }
  428.         contentView.addSubview(profileBackgroundImageView)
  429.         profileBackgroundImageView.snp.makeConstraints { make in
  430.             make.top.equalTo(0)
  431.             make.left.right.equalTo(contentView)
  432.             make.height.width.equalTo(300)
  433.         }
  434.         profileBackgroundImageView.addSubview(backButton)
  435.         backButton.snp.makeConstraints { make in
  436.             make.top.equalTo(profileBackgroundImageView.snp.top).offset(24)
  437.             make.left.equalTo(profileBackgroundImageView.snp.left).offset(24)
  438.             make.width.height.equalTo(32)
  439.         }
  440.         profileBackgroundImageView.addSubview(threeDotMenuButton)
  441.         threeDotMenuButton.snp.makeConstraints { make in
  442.             make.top.equalTo(profileBackgroundImageView).offset(24)
  443.             make.right.equalTo(profileBackgroundImageView.right).inset(24)
  444.             make.width.height.equalTo(32)
  445.         }
  446.         profileBackgroundImageView.addSubview(userTypeNameLabel)
  447.         userTypeNameLabel.snp.makeConstraints { make in
  448.             make.top.equalTo(backButton.snp.top).offset(104)
  449.             make.left.equalTo(profileBackgroundImageView.snp.left).offset(12)
  450.             make.width.equalTo(80)
  451.             make.height.equalTo(28)
  452.         }
  453.         profileBackgroundImageView.addSubview(artistName)
  454.         artistName.snp.makeConstraints { make in
  455.             make.top.equalTo(userTypeNameLabel.snp.bottom).offset(1)
  456.             make.left.equalTo(profileBackgroundImageView.snp.left).offset(12)
  457.             make.right.equalTo(profileBackgroundImageView)
  458.             make.height.equalTo(51)
  459.         }
  460.         profileBackgroundImageView.addSubview(artistUserName)
  461.         artistUserName.snp.makeConstraints { make in
  462.             make.top.equalTo(artistName.snp.bottom).offset(0)
  463.             make.left.equalTo(profileBackgroundImageView.snp.left).offset(12)
  464.             make.height.equalTo(27)
  465.         }
  466.  
  467.         profileBackgroundImageView.addSubview(reatingsTextlabel)
  468.         reatingsTextlabel.snp.makeConstraints { make in
  469.             make.top.equalTo(artistUserName.snp.bottom).offset(2)
  470.             make.left.equalTo(profileBackgroundImageView.snp.left).offset(12)
  471.             make.height.equalTo(16)
  472.         }
  473.         profileBackgroundImageView.addSubview(reatingStarImageView)
  474.         reatingStarImageView.snp.makeConstraints { make in
  475.             make.top.equalTo(artistUserName.snp.bottom).offset(4)
  476.             make.left.equalTo(reatingsTextlabel.snp.right).offset(2)
  477.             make.width.height.equalTo(12)
  478.         }
  479.         profileBackgroundImageView.addSubview(sepraterLabel)
  480.         sepraterLabel.snp.makeConstraints { make in
  481.             make.bottom.equalTo(profileBackgroundImageView.snp.bottom).inset(0)
  482.             make.left.equalTo(profileBackgroundImageView.snp.left).offset(10)
  483.             make.right.equalTo(profileBackgroundImageView.snp.right).inset(10)
  484.             make.height.equalTo(1)
  485.         }
  486.         contentView.addSubview(memberPriceStackView)
  487.         memberPriceStackView.snp.makeConstraints { make in
  488.             make.top.equalTo(profileBackgroundImageView.snp.bottom).offset(16)
  489.             make.left.equalTo(contentView).offset(16)
  490.             make.right.equalTo(contentView).inset(16)
  491.             make.height.equalTo(64)
  492.         }
  493.         memberBgView.addSubview(memberSinceTextLabel)
  494.         memberSinceTextLabel.snp.makeConstraints { make in
  495.             make.top.equalTo(memberBgView.snp.top).offset(8)
  496.             make.left.equalTo(memberBgView).offset(8)
  497.             make.height.equalTo(18)
  498.         }
  499.         memberBgView.addSubview(memberSinceLabel)
  500.         memberSinceLabel.snp.makeConstraints { make in
  501.             make.top.equalTo(memberSinceTextLabel.snp.bottom).offset(8)
  502.             make.left.equalTo(memberBgView).offset(8)
  503.             make.height.equalTo(18)
  504.         }
  505.         priceBgView.addSubview(priceTextLabel)
  506.         priceTextLabel.snp.makeConstraints { make in
  507.             make.top.equalTo(priceBgView.snp.top).offset(14)
  508.             make.left.equalTo(priceBgView).offset(16)
  509.             make.height.equalTo(18)
  510.         }
  511.         priceBgView.addSubview(priceLabel)
  512.         priceLabel.snp.makeConstraints { make in
  513.             make.top.equalTo(priceTextLabel.snp.bottom).offset(2)
  514.             make.left.equalTo(priceTextLabel)
  515.             make.height.equalTo(18)
  516.         }
  517.         priceBgView.addSubview(termConditionBgView)
  518.         termConditionBgView.snp.makeConstraints { make in
  519.             make.top.equalTo(priceBgView.snp.top).offset(20)
  520.             make.right.equalTo(priceBgView).inset(10)
  521.             make.width.equalTo(75)
  522.             make.height.equalTo(24)
  523.         }
  524.         termConditionBgView.addSubview(termAndConditionButton)
  525.         termAndConditionButton.snp.makeConstraints { make in
  526.             make.top.equalTo(termConditionBgView.snp.top).offset(4)
  527.             make.right.equalTo(termConditionBgView).inset(1)
  528.             make.width.equalTo(72)
  529.             make.height.equalTo(18)
  530.         }
  531.         contentView.addSubview(noOfBookingBgView)
  532.         noOfBookingBgView.snp.makeConstraints { make in
  533.             make.top.equalTo(memberBgView.snp.bottom).offset(16)
  534.             make.left.equalTo(contentView).offset(16)
  535.             make.right.equalTo(contentView).inset(16)
  536.             make.height.equalTo(64)
  537.         }
  538.         noOfBookingBgView.addSubview(noOfBookingTextLabel)
  539.         noOfBookingTextLabel.snp.makeConstraints { make in
  540.             make.top.equalTo(noOfBookingBgView.snp.top).offset(10)
  541.             make.centerX.equalTo(noOfBookingBgView)
  542.             make.height.equalTo(18)
  543.         }
  544.         noOfBookingBgView.addSubview(noOfBookingLabel)
  545.         noOfBookingLabel.snp.makeConstraints { make in
  546.             make.top.equalTo(noOfBookingTextLabel.snp.bottom).offset(8)
  547.             make.centerX.equalTo(noOfBookingBgView)
  548.             make.height.equalTo(18)
  549.         }
  550.         contentView.addSubview(aboutView)
  551.         aboutView.snp.makeConstraints { make in
  552.             make.top.equalTo(noOfBookingBgView.snp.bottom).offset(16)
  553.             make.left.equalTo(contentView).offset(16)
  554.             make.right.equalTo(contentView).inset(16)
  555.             make.height.equalTo(220)
  556.         }
  557.         aboutView.addSubview(aboutTextLabel)
  558.         aboutTextLabel.snp.makeConstraints { make in
  559.             make.top.equalTo(aboutView.snp.top).offset(16)
  560.             make.left.equalTo(aboutView).offset(16)
  561.             make.height.equalTo(21)
  562.         }
  563.         aboutView.addSubview(aboutLabel)
  564.         aboutLabel.snp.makeConstraints { make in
  565.             make.top.equalTo(aboutTextLabel.snp.bottom).offset(8)
  566.             make.left.equalTo(aboutView).offset(16)
  567.             make.right.equalTo(aboutView).inset(16)
  568.         }
  569.         aboutView.addSubview(dummyAboutTextLabel)
  570.         dummyAboutTextLabel.snp.makeConstraints { make in
  571.             make.top.equalTo(aboutLabel.snp.bottom).offset(16)
  572.             make.left.equalTo(aboutView).offset(16)
  573.             make.right.equalTo(aboutView).inset(16)
  574.         }
  575.         aboutView.addSubview(seeMoreAboutButton)
  576.         seeMoreAboutButton.snp.makeConstraints { make in
  577.             make.top.equalTo(aboutLabel.snp.bottom)
  578.             make.left.equalTo(aboutView).offset(16)
  579.         }
  580.         aboutView.addSubview(fromtTextLabel)
  581.         fromtTextLabel.snp.makeConstraints { make in
  582.             make.left.equalTo(aboutView).offset(16)
  583.             make.right.equalTo(aboutView).inset(16)
  584.             make.top.equalTo(aboutLabel.snp.bottom).offset(36)
  585.         }
  586.         aboutView.addSubview(fromCountryChipsView)
  587.         fromCountryChipsView.snp.makeConstraints { make in
  588.             make.top.equalTo(fromtTextLabel.snp.bottom).offset(16)
  589.         }
  590.         aboutView.addSubview(spokenLanguageTextLabel)
  591.         spokenLanguageTextLabel.snp.makeConstraints { make in
  592.             make.left.equalTo(aboutView).offset(16)
  593.             make.right.equalTo(aboutView).inset(16)
  594.             make.top.equalTo(fromCountryChipsView.snp.bottom).offset(24)
  595.         }
  596.         aboutView.addSubview(spokenLanguageChipsView)
  597.         spokenLanguageChipsView.snp.makeConstraints { make in
  598.             make.top.equalTo(spokenLanguageTextLabel.snp.bottom).offset(16)
  599.         }
  600.         let languageHeight = calculateSizeOfLanguagesStack()
  601.         self.contentView.snp.updateConstraints { make in
  602.             make.height.equalTo(contentViewHeight + languageHeight)
  603.         }
  604.         contentView.addSubview(portfolioBgView)
  605.         portfolioBgView.snp.makeConstraints { make in
  606.             make.top.equalTo(aboutView.snp.bottom).offset(16)
  607.             make.left.equalTo(contentView).offset(16)
  608.             make.right.equalTo(contentView).inset(16)
  609.             make.height.equalTo(600)
  610.         }
  611.         contentView.addSubview(servicesTextLabel)
  612.         servicesTextLabel.snp.makeConstraints { make in
  613.             make.top.equalTo(portfolioBgView.snp.bottom).offset(12)
  614.             make.left.equalTo(contentView).offset(16)
  615.             make.height.equalTo(24)
  616.         }
  617.         serviceBgView.addSubview(seeMoreServicesButton)
  618.         if allServices.count <= 3 {
  619.             seeMoreServicesButton.snp.removeConstraints()
  620.         } else {
  621.             seeMoreServicesButton.snp.makeConstraints { make in
  622.                 make.left.equalTo(serviceBgView.snp.left).offset(24)
  623.                 make.bottom.equalTo(serviceBgView.snp.bottom).inset(8)
  624.                 make.width.equalTo(82)
  625.                 make.height.equalTo(20)
  626.             }
  627.         }
  628.         let height = calculateSizeOfServicesStack()
  629.         contentView.addSubview(serviceBgView)
  630.         serviceBgView.snp.makeConstraints { make in
  631.             make.top.equalTo(servicesTextLabel.snp.bottom).offset(16)
  632.             make.left.equalTo(contentView).offset(16)
  633.             make.right.equalTo(contentView).inset(16)
  634.             make.height.equalTo(32 + height)
  635.         }
  636.         contentView.snp.updateConstraints { make in
  637.             make.height.equalTo(contentViewHeight + height)
  638.         }
  639.         serviceBgView.addSubview(servicesStack)
  640.         servicesStack.snp.makeConstraints { make in
  641.             make.top.equalTo(serviceBgView.snp.top).offset(12)
  642.             make.left.equalTo(serviceBgView).offset(24)
  643.             make.right.equalTo(serviceBgView).inset(16)
  644.             if allServices.count <= 3 {
  645.                 make.bottom.equalTo(serviceBgView.snp.bottom).inset(16)
  646.             } else {
  647.                 make.bottom.equalTo(seeMoreServicesButton.snp.top).inset(-12)
  648.             }
  649.         }
  650.         contentView.addSubview(avilivilityBgView)
  651.         avilivilityBgView.snp.makeConstraints { make in
  652.             make.top.equalTo(serviceBgView.snp.bottom).offset(16.0 * 2)
  653.             make.left.equalTo(contentView.snp.left).offset(16.0)
  654.             make.right.equalTo(contentView.snp.right).inset(16.0)
  655.             make.height.equalTo(600)
  656.         }
  657.         avilivilityBgView.addSubview(abilibilityTitleText)
  658.         abilibilityTitleText.snp.makeConstraints { make in
  659.             make.left.equalTo(avilivilityBgView).offset(12)
  660.             make.right.equalTo(avilivilityBgView).inset(12)
  661.             make.top.equalTo(avilivilityBgView).offset(16)
  662.         }
  663.         // Monday
  664.         avilivilityBgView.addSubview(abilibilityMondayTitleText)
  665.         avilivilityBgView.addSubview(abilibilityMondayChipsView)
  666.         abilibilityMondayTitleText.snp.makeConstraints { make in
  667.             make.left.equalTo(avilivilityBgView).offset(12)
  668.             make.right.equalTo(avilivilityBgView).inset(12)
  669.             make.top.equalTo(abilibilityTitleText.bottom).offset(16)
  670.         }
  671.         abilibilityMondayChipsView.snp.makeConstraints { make in
  672.             make.top.equalTo(abilibilityMondayTitleText.bottom).offset(16)
  673.         }
  674.         // Tuesday
  675.         avilivilityBgView.addSubview(abilibilityTuesdayTitleText)
  676.         abilibilityTuesdayTitleText.snp.makeConstraints { make in
  677.             make.left.equalTo(avilivilityBgView).offset(12)
  678.             make.right.equalTo(avilivilityBgView).inset(12)
  679.             make.top.equalTo(abilibilityMondayChipsView.bottom).offset(16)
  680.         }
  681.         avilivilityBgView.addSubview(abilibilityTuesdayChipsView)
  682.         abilibilityTuesdayChipsView.snp.makeConstraints { make in
  683.             make.top.equalTo(abilibilityTuesdayTitleText.bottom).offset(16)
  684.         }
  685.  
  686.         // Wednesday
  687.         avilivilityBgView.addSubview(abilibilityWednesdayTitleText)
  688.         abilibilityWednesdayTitleText.snp.makeConstraints { make in
  689.             make.left.equalTo(avilivilityBgView).offset(12)
  690.             make.right.equalTo(avilivilityBgView).inset(12)
  691.             make.top.equalTo(abilibilityTuesdayChipsView.bottom).offset(16)
  692.         }
  693.         avilivilityBgView.addSubview(abilibilityWednesdayChipsView)
  694.         abilibilityWednesdayChipsView.snp.makeConstraints { make in
  695.             make.top.equalTo(abilibilityWednesdayTitleText.bottom).offset(16)
  696.         }
  697.  
  698.         // Thusday
  699.         avilivilityBgView.addSubview(abilibilityThusdayTitleText)
  700.         abilibilityThusdayTitleText.snp.makeConstraints { make in
  701.             make.left.equalTo(avilivilityBgView).offset(12)
  702.             make.right.equalTo(avilivilityBgView).inset(12)
  703.             make.top.equalTo(abilibilityWednesdayChipsView.bottom).offset(16)
  704.         }
  705.         avilivilityBgView.addSubview(abilibilityThusdayChipsView)
  706.         abilibilityThusdayChipsView.snp.makeConstraints { make in
  707.             make.top.equalTo(abilibilityThusdayTitleText.bottom).offset(16)
  708.         }
  709.  
  710.         // Friday
  711.         avilivilityBgView.addSubview(abilibilityFridayTitleText)
  712.         abilibilityFridayTitleText.snp.makeConstraints { make in
  713.             make.left.equalTo(avilivilityBgView).offset(12)
  714.             make.right.equalTo(avilivilityBgView).inset(12)
  715.             make.top.equalTo(abilibilityThusdayChipsView.bottom).offset(16)
  716.         }
  717.         avilivilityBgView.addSubview(abilibilityFridayChipsView)
  718.         abilibilityFridayChipsView.snp.makeConstraints { make in
  719.             make.top.equalTo(abilibilityFridayTitleText.bottom).offset(16)
  720.         }
  721.         // Saturday
  722.         avilivilityBgView.addSubview(abilibilitySaturdayTitleText)
  723.         abilibilitySaturdayTitleText.snp.makeConstraints { make in
  724.             make.left.equalTo(avilivilityBgView).offset(12)
  725.             make.right.equalTo(avilivilityBgView).inset(12)
  726.             make.top.equalTo(abilibilityFridayChipsView.bottom).offset(16)
  727.         }
  728.         avilivilityBgView.addSubview(abilibilitySaturdayChipsView)
  729.         abilibilitySaturdayChipsView.snp.makeConstraints { make in
  730.             make.top.equalTo(abilibilitySaturdayTitleText.bottom).offset(16)
  731.         }
  732.         // Sunday
  733.         avilivilityBgView.addSubview(abilibilitySundayTitleText)
  734.         abilibilitySundayTitleText.snp.makeConstraints { make in
  735.             make.left.equalTo(avilivilityBgView).offset(12)
  736.             make.right.equalTo(avilivilityBgView).inset(12)
  737.             make.top.equalTo(abilibilitySaturdayChipsView.bottom).offset(16)
  738.         }
  739.         avilivilityBgView.addSubview(abilibilitySundayChipsView)
  740.         abilibilitySundayChipsView.snp.makeConstraints { make in
  741.             make.top.equalTo(abilibilitySundayTitleText.bottom).offset(16)
  742.         }
  743.         // Willingness to Travel
  744.         avilivilityBgView.addSubview(willingnessToTravelTitelText)
  745.         willingnessToTravelTitelText.snp.makeConstraints { make in
  746.             make.left.equalTo(avilivilityBgView).offset(12)
  747.             make.right.equalTo(avilivilityBgView).inset(12)
  748.             make.top.equalTo(abilibilitySundayChipsView.snp.bottom).offset(16)
  749.         }
  750.         avilivilityBgView.addSubview(willingnessToTravelChipsView)
  751.         willingnessToTravelChipsView.snp.makeConstraints { make in
  752.             make.top.equalTo(willingnessToTravelTitelText.snp.bottom).offset(16)
  753.         }
  754.         // Willingness to Negotiate
  755.         avilivilityBgView.addSubview(willingnessToNegotiateTitleText)
  756.         willingnessToNegotiateTitleText.snp.makeConstraints { make in
  757.             make.left.equalTo(avilivilityBgView).offset(12)
  758.             make.right.equalTo(avilivilityBgView).inset(12)
  759.             make.top.equalTo(willingnessToTravelChipsView.snp.bottom).offset(16)
  760.         }
  761.         avilivilityBgView.addSubview(willingnessToNegotiateChipsView)
  762.         willingnessToNegotiateChipsView.snp.makeConstraints { make in
  763.             make.top.equalTo(willingnessToNegotiateTitleText.snp.bottom).offset(16)
  764.         }
  765.         // Equipment
  766.         avilivilityBgView.addSubview(equipmentOnHandTitleText)
  767.         equipmentOnHandTitleText.snp.makeConstraints { make in
  768.             make.left.equalTo(avilivilityBgView).offset(12)
  769.             make.right.equalTo(avilivilityBgView).inset(12)
  770.             make.top.equalTo(willingnessToNegotiateChipsView.snp.bottom).offset(16)
  771.         }
  772.         avilivilityBgView.addSubview(equipmentOnHandChipsView)
  773.         equipmentOnHandChipsView.snp.makeConstraints { make in
  774.             make.top.equalTo(equipmentOnHandTitleText.snp.bottom).offset(16)
  775.         }
  776.         // Technical Rider
  777.         avilivilityBgView.addSubview(technicalRiderTitleText)
  778.         technicalRiderTitleText.snp.makeConstraints { make in
  779.             make.left.equalTo(avilivilityBgView).offset(12)
  780.             make.right.equalTo(avilivilityBgView).inset(12)
  781.             make.top.equalTo(equipmentOnHandChipsView.snp.bottom).offset(16)
  782.         }
  783.         avilivilityBgView.addSubview(technicalRiderChipsView)
  784.         technicalRiderChipsView.snp.makeConstraints { make in
  785.             make.top.equalTo(technicalRiderTitleText.snp.bottom).offset(16)
  786.         }
  787.         avilivilityBgView.snp.updateConstraints { make in
  788.             make.height.equalTo(calculateTagViewHeight() + 286)
  789.         }
  790.         contentView.snp.updateConstraints { make in
  791.             make.height.equalTo(contentViewHeight + calculateTagViewHeight())
  792.         }
  793.         self.contentView.setNeedsLayout()
  794.         self.contentView.layoutIfNeeded()
  795.         contentView.addSubview(mapView)
  796.         mapView.snp.makeConstraints { make in
  797.             make.top.equalTo(avilivilityBgView.snp.bottom).offset(16)
  798.             make.left.equalTo(contentView).offset(16)
  799.             make.right.equalTo(contentView).inset(16)
  800.             make.height.equalTo(274)
  801.         }
  802.         contentView.addSubview(ratingStackView)
  803.         ratingStackView.snp.makeConstraints { make in
  804.             make.top.equalTo(mapView.snp.bottom).offset(16)
  805.             make.left.equalTo(contentView).offset(16)
  806.             make.height.equalTo(15)
  807.         }
  808.         contentView.addSubview(ratingCollection)
  809.         ratingCollection.snp.makeConstraints { make in
  810.             make.top.equalTo(ratingStackView.snp.bottom).offset(16)
  811.             make.left.equalTo(contentView).offset(16)
  812.             make.right.equalTo(contentView).inset(16)
  813.             make.height.equalTo(170)
  814.         }
  815.     }
  816. }
  817.  
Advertisement
Add Comment
Please, Sign In to add comment