- Fixed series

This commit is contained in:
Bilal
2024-07-23 00:09:35 +05:30
parent 1ce505391c
commit 7a2a8e786b
8 changed files with 161 additions and 29 deletions

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Rectangle Copy 5.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

View File

@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@@ -90,16 +90,28 @@ class ShopProductsVC: UIViewController {
extension ShopProductsVC : CollectionViewSRC{
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return vm.subCategoryData.count
if collectionView == subCategoryCV{
return vm.subCategoryData.count
}else{
return vm.shopProductsData.count
}
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: K.CellIdentifier.WebSeries.seasonCategoryCell, for: indexPath) as! SeasonCategoryCell
let data = vm.subCategoryData[indexPath.row]
// cell.setData(title: data.seasonNumber ?? "Season", iselected: data.id == vm.episodeSelectedCateogory)
cell.setSubCategory(data: data, isSelected: data.id == vm.selectedSubCategory)
return cell
if collectionView == subCategoryCV{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: K.CellIdentifier.WebSeries.seasonCategoryCell, for: indexPath) as! SeasonCategoryCell
let data = vm.subCategoryData[indexPath.row]
// cell.setData(title: data.seasonNumber ?? "Season", iselected: data.id == vm.episodeSelectedCateogory)
cell.setSubCategory(data: data, isSelected: data.id == vm.selectedSubCategory)
return cell
}else{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: K.CellIdentifier.Shop.shopProductsCell, for: indexPath) as! ShopProductsCell
let data = vm.shopProductsData[indexPath.row]
cell.setData(data: data)
return cell
}
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
@@ -118,21 +130,27 @@ extension ShopProductsVC : CollectionViewSRC{
extension ShopProductsVC : UICollectionViewDelegateFlowLayout{
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
// Generate a random string for testing purposes
let randomText = vm.subCategoryData[indexPath.row].subCategoryName!
if collectionView == subCategoryCV{
// Generate a random string for testing purposes
let randomText = vm.subCategoryData[indexPath.row].subCategoryName!
// Define the font for the text
let font = FontCustom.shareInstance.customFont(fontName: .Exo2_Bold, size: 18) // Adjust the font size as needed
// Define the font for the text
let font = FontCustom.shareInstance.customFont(fontName: .Exo2_Bold, size: 18) // Adjust the font size as needed
// Calculate the width of the text
let attributes = [NSAttributedString.Key.font: font]
let textWidth = (randomText as NSString).size(withAttributes: attributes).width
// Calculate the width of the text
let attributes = [NSAttributedString.Key.font: font]
let textWidth = (randomText as NSString).size(withAttributes: attributes).width
// Set the cell width based on the text width and any additional padding
// 14 for container view + 10 for inside spacing.
let padding: CGFloat = 24 + 20 // Adjust padding as needed
let cellWidth = textWidth + padding
return CGSize(width: cellWidth , height: 50)
// Set the cell width based on the text width and any additional padding
// 14 for container view + 10 for inside spacing.
let padding: CGFloat = 24 + 20 // Adjust padding as needed
let cellWidth = textWidth + padding
return CGSize(width: cellWidth , height: 60)
}else{
return CGSize(width: 100, height: 100)
}
}
}

View File

@@ -105,10 +105,10 @@
<rect key="frame" x="0.0" y="557.33333333333337" width="393" height="294.66666666666663"/>
</imageView>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="ibd-Ky-5QZ">
<rect key="frame" x="10" y="69" width="383" height="50"/>
<rect key="frame" x="10" y="69" width="383" height="60"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="hgB-eB-epB"/>
<constraint firstAttribute="height" constant="60" id="hgB-eB-epB"/>
</constraints>
<collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="10" minimumInteritemSpacing="10" id="Pad-jm-O98">
<size key="itemSize" width="128" height="70"/>
@@ -119,7 +119,7 @@
<cells/>
</collectionView>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="qrc-nF-3bM">
<rect key="frame" x="0.0" y="134" width="393" height="718"/>
<rect key="frame" x="0.0" y="144" width="393" height="708"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<collectionViewFlowLayout key="collectionViewLayout" automaticEstimatedItemSize="YES" minimumLineSpacing="10" minimumInteritemSpacing="10" id="Akd-Zt-0d3">
<size key="itemSize" width="128" height="128"/>
@@ -150,7 +150,6 @@
</constraints>
</view>
<connections>
<outlet property="collectionView" destination="qrc-nF-3bM" id="5UB-pP-lI4"/>
<outlet property="productCV" destination="qrc-nF-3bM" id="0dx-wj-O2z"/>
<outlet property="subCategoryCV" destination="ibd-Ky-5QZ" id="0j8-y0-HeP"/>
</connections>

View File

@@ -9,9 +9,22 @@ import UIKit
class ShopProductsCell: UICollectionViewCell {
@IBOutlet weak var productImage: UIImageView!
@IBOutlet weak var productTitle: UILabel!
@IBOutlet weak var productPrice: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
func setData(data : ShopProductDM.SabakDegiNaniSery){
self.productTitle.text = data.productName
self.productPrice.text = data.productPrice
if let url = data.productThumbnail{
self.productImage.imageURL(url, color: .black)
}
}
}

View File

@@ -4,9 +4,15 @@
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<customFonts key="customFonts">
<array key="Exo2-Bold.ttf">
<string>Exo2-Bold</string>
</array>
</customFonts>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
@@ -16,10 +22,73 @@
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="167" height="167"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Card" translatesAutoresizingMaskIntoConstraints="NO" id="gxB-sF-vrU">
<rect key="frame" x="0.0" y="0.0" width="167" height="167"/>
</imageView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="jcb-xQ-0XB">
<rect key="frame" x="4" y="10" width="157" height="137"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="MasilaComingSoon" translatesAutoresizingMaskIntoConstraints="NO" id="Qxf-XT-JWX">
<rect key="frame" x="0.0" y="0.0" width="157" height="80"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="80" id="Asx-t9-17g"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
<integer key="value" value="10"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</imageView>
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="b3X-u9-HF2">
<rect key="frame" x="0.0" y="90" width="157" height="47"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5VD-VF-Ean">
<rect key="frame" x="0.0" y="0.0" width="107.66666666666667" height="47"/>
<string key="text">Labelsadasdasd
sadasdasd</string>
<fontDescription key="fontDescription" name="Exo2-Bold" family="Exo 2" pointSize="14"/>
<color key="textColor" name="ImageDarkBlue"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="Rs. 110" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sNE-QZ-rn6">
<rect key="frame" x="107.66666666666667" y="0.0" width="49.333333333333329" height="47"/>
<fontDescription key="fontDescription" name="Exo2-Bold" family="Exo 2" pointSize="10"/>
<color key="textColor" name="ImageDarkBlue"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
</subviews>
</stackView>
</subviews>
</view>
<viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/>
<constraints>
<constraint firstItem="jcb-xQ-0XB" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" constant="10" id="6ez-E9-5MV"/>
<constraint firstAttribute="trailing" secondItem="gxB-sF-vrU" secondAttribute="trailing" id="Q50-fw-aNj"/>
<constraint firstAttribute="bottom" secondItem="gxB-sF-vrU" secondAttribute="bottom" id="QmC-1D-OIq"/>
<constraint firstAttribute="bottom" secondItem="jcb-xQ-0XB" secondAttribute="bottom" constant="20" id="aLr-99-xbT"/>
<constraint firstItem="gxB-sF-vrU" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="dHy-Vn-aaJ"/>
<constraint firstAttribute="trailing" secondItem="jcb-xQ-0XB" secondAttribute="trailing" constant="6" id="fdk-Wc-0SS"/>
<constraint firstItem="jcb-xQ-0XB" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="4" id="g2Z-Py-Pfn"/>
<constraint firstItem="gxB-sF-vrU" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="zs4-bk-oMq"/>
</constraints>
<size key="customSize" width="167" height="167"/>
<connections>
<outlet property="productImage" destination="Qxf-XT-JWX" id="Pgy-wv-fLp"/>
<outlet property="productPrice" destination="sNE-QZ-rn6" id="zJk-Mf-ui1"/>
<outlet property="productTitle" destination="5VD-VF-Ean" id="JyL-aG-PFw"/>
</connections>
<point key="canvasLocation" x="129.00763358778624" y="29.929577464788736"/>
</collectionViewCell>
</objects>
<resources>
<image name="Card" width="273.33334350585938" height="250.66667175292969"/>
<image name="MasilaComingSoon" width="200" height="100"/>
<namedColor name="ImageDarkBlue">
<color red="0.035000000149011612" green="0.0" blue="0.36500000953674316" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
</resources>
</document>

View File

@@ -12,7 +12,7 @@ class ShopProductsVM{
weak var vc : ShopProductsVC!
var subCategoryData = [ShopSubCategoryDM.ResultData]()
var shopProducts = [ShopProductDM.ResultData]()
var shopProductsData = [ShopProductDM.SabakDegiNaniSery]()
var categoryID : Int?
var selectedSubCategory = 0
@@ -35,6 +35,10 @@ class ShopProductsVM{
vc.subCategoryCV.register(UINib(nibName: K.CellIdentifier.WebSeries.seasonCategoryCell, bundle: nil), forCellWithReuseIdentifier: K.CellIdentifier.WebSeries.seasonCategoryCell)
vc.subCategoryCV.delegate = vc.self
vc.subCategoryCV.dataSource = vc.self
vc.productCV.register(UINib(nibName: K.CellIdentifier.Shop.shopProductsCell, bundle: nil), forCellWithReuseIdentifier: K.CellIdentifier.Shop.shopProductsCell)
vc.productCV.delegate = vc.self
vc.productCV.dataSource = vc.self
}
// MARK: - Get SuperCategory
@@ -66,13 +70,13 @@ class ShopProductsVM{
case 1:
Utilities.dismissProgressHUD()
guard let data = data.data?.result else{return}
self.subCategoryData.append(ShopSubCategoryDM.ResultData(id: 0, categoryMasterID: 0, subCategoryName: "All", subCategoryThumbnail: ""))
self.subCategoryData.append(ShopSubCategoryDM.ResultData(id: 0, categoryMasterID: 0, subCategoryName: " All ", subCategoryThumbnail: ""))
self.subCategoryData.append(contentsOf: data)
self.selectedSubCategory = data.first?.id ?? 0
self.vc.subCategoryCV.reloadData()
// if let subCatID = data.first?.id{
// self.getShopProducts(subCategoryID: nil)
// }
if let subCatID = data.first?.id{
self.getShopProducts(subCategoryID: subCatID)
}
default:
Utilities.dismissProgressHUD()
break
@@ -119,7 +123,9 @@ class ShopProductsVM{
}
case 1:
Utilities.dismissProgressHUD()
guard let data = data.data?.result else{return}
guard let data = data.data?.result?.sabakDegiNaniSeries else{return}
self.shopProductsData = data
self.vc.productCV.reloadData()
print(data)
default:
Utilities.dismissProgressHUD()