Showing
6 changed files
with
468 additions
and
25 deletions
| ... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
| 7 | <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key> | 7 | <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key> |
| 8 | <dict> | 8 | <dict> |
| 9 | <key>orderHint</key> | 9 | <key>orderHint</key> |
| 10 | - <integer>1</integer> | 10 | + <integer>0</integer> |
| 11 | </dict> | 11 | </dict> |
| 12 | </dict> | 12 | </dict> |
| 13 | </dict> | 13 | </dict> | ... | ... |
| ... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
| 7 | <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key> | 7 | <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key> |
| 8 | <dict> | 8 | <dict> |
| 9 | <key>orderHint</key> | 9 | <key>orderHint</key> |
| 10 | - <integer>0</integer> | 10 | + <integer>1</integer> |
| 11 | </dict> | 11 | </dict> |
| 12 | </dict> | 12 | </dict> |
| 13 | </dict> | 13 | </dict> | ... | ... |
No preview for this file type
| ... | @@ -20,12 +20,32 @@ import UIKit | ... | @@ -20,12 +20,32 @@ import UIKit |
| 20 | @IBOutlet weak var expirationRedImage: UIImageView! | 20 | @IBOutlet weak var expirationRedImage: UIImageView! |
| 21 | @IBOutlet weak var expirationRedLabel: UILabel! | 21 | @IBOutlet weak var expirationRedLabel: UILabel! |
| 22 | 22 | ||
| 23 | + | ||
| 24 | + // Variables for the view, image, and button | ||
| 25 | + var selectView: UIView! | ||
| 26 | + var selectImageView: UIImageView! | ||
| 27 | + var selectButton: UIButton! | ||
| 28 | + | ||
| 29 | + // Boolean to track if the selectView should be visible | ||
| 30 | + var isSelectViewVisible: Bool = false { | ||
| 31 | + didSet { | ||
| 32 | + selectView.isHidden = !isSelectViewVisible | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + // Boolean to track the selection state of the cell | ||
| 37 | + var isSelectedCell: Bool = false { | ||
| 38 | + didSet { | ||
| 39 | + updateSelectionState() | ||
| 40 | + } | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + // Action closure for button tap inside the cell | ||
| 44 | + var selectButtonAction: (() -> Void)? | ||
| 45 | + | ||
| 23 | var postImageURL: String? { | 46 | var postImageURL: String? { |
| 24 | didSet { | 47 | didSet { |
| 25 | if let url = postImageURL { | 48 | if let url = postImageURL { |
| 26 | - // TODO: DELETE LOGS | ||
| 27 | - print("=== postImageURL: ",url) | ||
| 28 | - | ||
| 29 | self.couponImage.image = UIImage() // UIImage(named: "loading") | 49 | self.couponImage.image = UIImage() // UIImage(named: "loading") |
| 30 | 50 | ||
| 31 | UIImage.loadImageUsingCacheWithUrlString(url) { image in | 51 | UIImage.loadImageUsingCacheWithUrlString(url) { image in |
| ... | @@ -49,6 +69,8 @@ import UIKit | ... | @@ -49,6 +69,8 @@ import UIKit |
| 49 | couponBgImage.image = UIImage(named: "coupon_bg_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) | 69 | couponBgImage.image = UIImage(named: "coupon_bg_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) |
| 50 | 70 | ||
| 51 | borderView.addDashedBorderVertical(color: UIColor(red: 0.62, green: 0.62, blue: 0.61, alpha: 1.00), width: 1.0, height: 110.0) | 71 | borderView.addDashedBorderVertical(color: UIColor(red: 0.62, green: 0.62, blue: 0.61, alpha: 1.00), width: 1.0, height: 110.0) |
| 72 | + | ||
| 73 | + setupSelectButton() | ||
| 52 | } | 74 | } |
| 53 | 75 | ||
| 54 | public override func setSelected(_ selected: Bool, animated: Bool) { | 76 | public override func setSelected(_ selected: Bool, animated: Bool) { |
| ... | @@ -64,6 +86,69 @@ import UIKit | ... | @@ -64,6 +86,69 @@ import UIKit |
| 64 | contentView.frame = contentView.frame.inset(by: margins) | 86 | contentView.frame = contentView.frame.inset(by: margins) |
| 65 | } | 87 | } |
| 66 | 88 | ||
| 89 | + // Setup Select Button UI and layout | ||
| 90 | + func setupSelectButton() { | ||
| 91 | + // Create the container view (selectView) | ||
| 92 | + selectView = UIView() | ||
| 93 | + selectView.translatesAutoresizingMaskIntoConstraints = false | ||
| 94 | + contentView.addSubview(selectView) | ||
| 95 | + | ||
| 96 | + // Set selectView constraints | ||
| 97 | + NSLayoutConstraint.activate([ | ||
| 98 | + selectView.widthAnchor.constraint(equalToConstant: 26), | ||
| 99 | + selectView.heightAnchor.constraint(equalToConstant: 26), | ||
| 100 | + selectView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 6), | ||
| 101 | + selectView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -16) | ||
| 102 | + ]) | ||
| 103 | + | ||
| 104 | + // Create the UIImageView inside selectView | ||
| 105 | + selectImageView = UIImageView() | ||
| 106 | + selectImageView.contentMode = .scaleAspectFit | ||
| 107 | + selectImageView.translatesAutoresizingMaskIntoConstraints = false | ||
| 108 | + selectView.addSubview(selectImageView) | ||
| 109 | + | ||
| 110 | + // Set imageView constraints to match the size of the selectView | ||
| 111 | + NSLayoutConstraint.activate([ | ||
| 112 | + selectImageView.leadingAnchor.constraint(equalTo: selectView.leadingAnchor), | ||
| 113 | + selectImageView.trailingAnchor.constraint(equalTo: selectView.trailingAnchor), | ||
| 114 | + selectImageView.topAnchor.constraint(equalTo: selectView.topAnchor), | ||
| 115 | + selectImageView.bottomAnchor.constraint(equalTo: selectView.bottomAnchor) | ||
| 116 | + ]) | ||
| 117 | + | ||
| 118 | + // Create the transparent button on top of the imageView | ||
| 119 | + selectButton = UIButton(type: .custom) | ||
| 120 | + selectButton.backgroundColor = .clear // Make the button transparent | ||
| 121 | + selectButton.translatesAutoresizingMaskIntoConstraints = false | ||
| 122 | + selectButton.addTarget(self, action: #selector(selectButtonTapped), for: .touchUpInside) | ||
| 123 | + selectView.addSubview(selectButton) | ||
| 124 | + | ||
| 125 | + // Set button constraints to match the size of the selectView | ||
| 126 | + NSLayoutConstraint.activate([ | ||
| 127 | + selectButton.leadingAnchor.constraint(equalTo: selectView.leadingAnchor), | ||
| 128 | + selectButton.trailingAnchor.constraint(equalTo: selectView.trailingAnchor), | ||
| 129 | + selectButton.topAnchor.constraint(equalTo: selectView.topAnchor), | ||
| 130 | + selectButton.bottomAnchor.constraint(equalTo: selectView.bottomAnchor) | ||
| 131 | + ]) | ||
| 132 | + | ||
| 133 | + // Initially hide the selectView (selectView) | ||
| 134 | + selectView.isHidden = true | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + // Button action handler | ||
| 138 | + @objc func selectButtonTapped() { | ||
| 139 | + // Trigger the action closure when the button is pressed | ||
| 140 | + selectButtonAction?() | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + // Update the cell's appearance based on selection state | ||
| 144 | + func updateSelectionState() { | ||
| 145 | + // Update the image based on the new state | ||
| 146 | + if (isSelectedCell) { | ||
| 147 | + selectImageView.image = UIImage(named: "circle_checked", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) // Selected image | ||
| 148 | + } else { | ||
| 149 | + selectImageView.image = UIImage(named: "circle_unchecked", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) // Unselected image | ||
| 150 | + } | ||
| 151 | + } | ||
| 67 | 152 | ||
| 68 | func configureCell(coupon: swiftApi.CouponItemModel) { | 153 | func configureCell(coupon: swiftApi.CouponItemModel) { |
| 69 | // COUPONSET: desc, img_preview, name, terms, merchant_uuid, discount_type, final_price | 154 | // COUPONSET: desc, img_preview, name, terms, merchant_uuid, discount_type, final_price |
| ... | @@ -240,4 +325,22 @@ import UIKit | ... | @@ -240,4 +325,22 @@ import UIKit |
| 240 | 325 | ||
| 241 | } | 326 | } |
| 242 | 327 | ||
| 328 | + // Configure the cell with visibility of the selectView, a selected state, and select Button Action | ||
| 329 | + func showSelectButton(isSelectViewVisible: Bool, isSelected: Bool, buttonAction: @escaping () -> Void) { | ||
| 330 | + self.isSelectViewVisible = isSelectViewVisible | ||
| 331 | + self.isSelectedCell = isSelected | ||
| 332 | + self.selectButtonAction = buttonAction | ||
| 333 | + | ||
| 334 | + if (isSelected) { | ||
| 335 | + couponBgImage.image = UIImage(named: "coupon_bg_2_selected", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) | ||
| 336 | + } else { | ||
| 337 | + couponBgImage.image = UIImage(named: "coupon_bg_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) | ||
| 338 | + } | ||
| 339 | + | ||
| 340 | + // Set nameLabel constraints to not overlap selectView | ||
| 341 | + NSLayoutConstraint.activate([ | ||
| 342 | + nameLabel.trailingAnchor.constraint(equalTo: selectView.leadingAnchor, constant: -5) | ||
| 343 | + ]) | ||
| 344 | + | ||
| 345 | + } | ||
| 243 | } | 346 | } | ... | ... |
| ... | @@ -4651,13 +4651,14 @@ | ... | @@ -4651,13 +4651,14 @@ |
| 4651 | <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="coupons_scrollview_dark" translatesAutoresizingMaskIntoConstraints="NO" id="QKV-Lk-E2a"> | 4651 | <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="coupons_scrollview_dark" translatesAutoresizingMaskIntoConstraints="NO" id="QKV-Lk-E2a"> |
| 4652 | <rect key="frame" x="0.0" y="0.0" width="414" height="848"/> | 4652 | <rect key="frame" x="0.0" y="0.0" width="414" height="848"/> |
| 4653 | </imageView> | 4653 | </imageView> |
| 4654 | - <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="YVv-xm-y2W"> | 4654 | + <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="1" estimatedSectionFooterHeight="-1" contentViewInsetsToSafeArea="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YVv-xm-y2W"> |
| 4655 | <rect key="frame" x="0.0" y="2" width="414" height="846"/> | 4655 | <rect key="frame" x="0.0" y="2" width="414" height="846"/> |
| 4656 | <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | 4656 | <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> |
| 4657 | + <color key="separatorColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | ||
| 4657 | <color key="sectionIndexBackgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | 4658 | <color key="sectionIndexBackgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> |
| 4658 | <prototypes> | 4659 | <prototypes> |
| 4659 | <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="UnifiedCouponsTableViewCellId" id="D63-Nr-YbN" customClass="UnifiedCouponsTableViewCell" customModule="SwiftWarplyFramework"> | 4660 | <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="UnifiedCouponsTableViewCellId" id="D63-Nr-YbN" customClass="UnifiedCouponsTableViewCell" customModule="SwiftWarplyFramework"> |
| 4660 | - <rect key="frame" x="0.0" y="50" width="414" height="64.5"/> | 4661 | + <rect key="frame" x="0.0" y="55.5" width="414" height="64.5"/> |
| 4661 | <autoresizingMask key="autoresizingMask"/> | 4662 | <autoresizingMask key="autoresizingMask"/> |
| 4662 | <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="D63-Nr-YbN" id="Fzs-bb-ogj"> | 4663 | <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="D63-Nr-YbN" id="Fzs-bb-ogj"> |
| 4663 | <rect key="frame" x="0.0" y="0.0" width="414" height="64.5"/> | 4664 | <rect key="frame" x="0.0" y="0.0" width="414" height="64.5"/> |
| ... | @@ -4754,6 +4755,108 @@ | ... | @@ -4754,6 +4755,108 @@ |
| 4754 | <outlet property="nameLabel" destination="GFK-EC-8kT" id="Bbm-E9-hGO"/> | 4755 | <outlet property="nameLabel" destination="GFK-EC-8kT" id="Bbm-E9-hGO"/> |
| 4755 | </connections> | 4756 | </connections> |
| 4756 | </tableViewCell> | 4757 | </tableViewCell> |
| 4758 | + <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="none" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="CouponsTableViewCellId" id="PIt-2t-7fO" customClass="CouponsTableViewCell" customModule="SwiftWarplyFramework" customModuleProvider="target"> | ||
| 4759 | + <rect key="frame" x="0.0" y="120" width="414" height="64.5"/> | ||
| 4760 | + <autoresizingMask key="autoresizingMask"/> | ||
| 4761 | + <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="PIt-2t-7fO" id="ECe-u7-APW"> | ||
| 4762 | + <rect key="frame" x="0.0" y="0.0" width="414" height="64.5"/> | ||
| 4763 | + <autoresizingMask key="autoresizingMask"/> | ||
| 4764 | + <subviews> | ||
| 4765 | + <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="rvV-78-dYR"> | ||
| 4766 | + <rect key="frame" x="10" y="0.0" width="394" height="64.5"/> | ||
| 4767 | + <subviews> | ||
| 4768 | + <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="coupon_bg" translatesAutoresizingMaskIntoConstraints="NO" id="ayq-SS-U8t"> | ||
| 4769 | + <rect key="frame" x="0.0" y="0.0" width="394" height="64.5"/> | ||
| 4770 | + </imageView> | ||
| 4771 | + <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="x8f-2v-Jao"> | ||
| 4772 | + <rect key="frame" x="20" y="10" width="79" height="44.5"/> | ||
| 4773 | + <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | ||
| 4774 | + </imageView> | ||
| 4775 | + <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="oIZ-eF-M5Z"> | ||
| 4776 | + <rect key="frame" x="104" y="10" width="10" height="44.5"/> | ||
| 4777 | + <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | ||
| 4778 | + <constraints> | ||
| 4779 | + <constraint firstAttribute="width" constant="10" id="rkI-WU-bsK"/> | ||
| 4780 | + </constraints> | ||
| 4781 | + </view> | ||
| 4782 | + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wRq-jP-x8E"> | ||
| 4783 | + <rect key="frame" x="119" y="-13" width="255" height="20"/> | ||
| 4784 | + <fontDescription key="fontDescription" name="BTCosmo-Bold" family="BTCosmo" pointSize="17"/> | ||
| 4785 | + <color key="textColor" red="0.12941176469999999" green="0.12941176469999999" blue="0.12941176469999999" alpha="1" colorSpace="calibratedRGB"/> | ||
| 4786 | + <nil key="highlightedColor"/> | ||
| 4787 | + </label> | ||
| 4788 | + <stackView opaque="NO" contentMode="scaleToFill" alignment="center" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="pAV-li-7RR"> | ||
| 4789 | + <rect key="frame" x="119" y="12" width="255" height="40.5"/> | ||
| 4790 | + <subviews> | ||
| 4791 | + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3HE-ik-tKt"> | ||
| 4792 | + <rect key="frame" x="0.0" y="0.0" width="127.5" height="40.5"/> | ||
| 4793 | + <fontDescription key="fontDescription" name="BTCosmo-Bold" family="BTCosmo" pointSize="35"/> | ||
| 4794 | + <color key="textColor" red="0.12941176469999999" green="0.12941176469999999" blue="0.12941176469999999" alpha="1" colorSpace="calibratedRGB"/> | ||
| 4795 | + <nil key="highlightedColor"/> | ||
| 4796 | + </label> | ||
| 4797 | + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WcV-JM-VIz"> | ||
| 4798 | + <rect key="frame" x="132.5" y="13" width="122.5" height="15"/> | ||
| 4799 | + <fontDescription key="fontDescription" name="PeridotPE-Regular" family="Peridot PE" pointSize="12"/> | ||
| 4800 | + <color key="textColor" red="0.12941176469999999" green="0.12941176469999999" blue="0.12941176469999999" alpha="1" colorSpace="calibratedRGB"/> | ||
| 4801 | + <nil key="highlightedColor"/> | ||
| 4802 | + </label> | ||
| 4803 | + </subviews> | ||
| 4804 | + <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | ||
| 4805 | + <constraints> | ||
| 4806 | + <constraint firstItem="3HE-ik-tKt" firstAttribute="width" secondItem="pAV-li-7RR" secondAttribute="width" multiplier="0.5" id="1J7-Ed-pvc"/> | ||
| 4807 | + </constraints> | ||
| 4808 | + </stackView> | ||
| 4809 | + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="O37-kL-mV9"> | ||
| 4810 | + <rect key="frame" x="119" y="57.5" width="255" height="15"/> | ||
| 4811 | + <fontDescription key="fontDescription" name="PeridotPE-Regular" family="Peridot PE" pointSize="12"/> | ||
| 4812 | + <color key="textColor" red="0.12941176469999999" green="0.12941176469999999" blue="0.12941176469999999" alpha="1" colorSpace="calibratedRGB"/> | ||
| 4813 | + <nil key="highlightedColor"/> | ||
| 4814 | + </label> | ||
| 4815 | + </subviews> | ||
| 4816 | + <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | ||
| 4817 | + <constraints> | ||
| 4818 | + <constraint firstItem="O37-kL-mV9" firstAttribute="leading" secondItem="oIZ-eF-M5Z" secondAttribute="trailing" constant="5" id="0wP-g6-tOx"/> | ||
| 4819 | + <constraint firstItem="ayq-SS-U8t" firstAttribute="top" secondItem="rvV-78-dYR" secondAttribute="top" id="4CK-ZW-x7Q"/> | ||
| 4820 | + <constraint firstItem="pAV-li-7RR" firstAttribute="leading" secondItem="oIZ-eF-M5Z" secondAttribute="trailing" constant="5" id="5in-wK-Zg5"/> | ||
| 4821 | + <constraint firstItem="oIZ-eF-M5Z" firstAttribute="top" secondItem="rvV-78-dYR" secondAttribute="top" constant="10" id="FYN-gf-brd"/> | ||
| 4822 | + <constraint firstItem="pAV-li-7RR" firstAttribute="top" secondItem="wRq-jP-x8E" secondAttribute="bottom" constant="5" id="FbO-ru-ycd"/> | ||
| 4823 | + <constraint firstAttribute="trailing" secondItem="O37-kL-mV9" secondAttribute="trailing" constant="20" id="Gee-F6-bBT"/> | ||
| 4824 | + <constraint firstItem="ayq-SS-U8t" firstAttribute="leading" secondItem="rvV-78-dYR" secondAttribute="leading" id="M37-JQ-ufI"/> | ||
| 4825 | + <constraint firstItem="oIZ-eF-M5Z" firstAttribute="leading" secondItem="x8f-2v-Jao" secondAttribute="trailing" constant="5" id="Py3-9p-Twv"/> | ||
| 4826 | + <constraint firstAttribute="bottom" secondItem="oIZ-eF-M5Z" secondAttribute="bottom" constant="10" id="VXN-mF-iuh"/> | ||
| 4827 | + <constraint firstAttribute="trailing" secondItem="ayq-SS-U8t" secondAttribute="trailing" id="WT9-Mq-vNm"/> | ||
| 4828 | + <constraint firstItem="x8f-2v-Jao" firstAttribute="leading" secondItem="rvV-78-dYR" secondAttribute="leading" constant="20" id="Whf-Fb-Kaz"/> | ||
| 4829 | + <constraint firstAttribute="bottom" secondItem="ayq-SS-U8t" secondAttribute="bottom" id="XYp-ov-MHb"/> | ||
| 4830 | + <constraint firstAttribute="trailing" secondItem="pAV-li-7RR" secondAttribute="trailing" constant="20" id="dXA-Lj-qLC"/> | ||
| 4831 | + <constraint firstAttribute="trailing" secondItem="wRq-jP-x8E" secondAttribute="trailing" constant="20" id="hM1-BX-baT"/> | ||
| 4832 | + <constraint firstItem="O37-kL-mV9" firstAttribute="top" secondItem="pAV-li-7RR" secondAttribute="bottom" constant="5" id="iZl-tJ-qE7"/> | ||
| 4833 | + <constraint firstItem="wRq-jP-x8E" firstAttribute="leading" secondItem="oIZ-eF-M5Z" secondAttribute="trailing" constant="5" id="m3u-Om-cxu"/> | ||
| 4834 | + <constraint firstItem="x8f-2v-Jao" firstAttribute="width" secondItem="rvV-78-dYR" secondAttribute="width" multiplier="0.2" id="mu0-QV-68e"/> | ||
| 4835 | + <constraint firstItem="pAV-li-7RR" firstAttribute="centerY" secondItem="rvV-78-dYR" secondAttribute="centerY" id="rPj-ld-u6g"/> | ||
| 4836 | + <constraint firstAttribute="bottom" secondItem="x8f-2v-Jao" secondAttribute="bottom" constant="10" id="w2y-KM-3as"/> | ||
| 4837 | + <constraint firstItem="x8f-2v-Jao" firstAttribute="top" secondItem="rvV-78-dYR" secondAttribute="top" constant="10" id="wZT-ye-Ybt"/> | ||
| 4838 | + </constraints> | ||
| 4839 | + </view> | ||
| 4840 | + </subviews> | ||
| 4841 | + <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | ||
| 4842 | + <constraints> | ||
| 4843 | + <constraint firstAttribute="trailing" secondItem="rvV-78-dYR" secondAttribute="trailing" constant="10" id="S6z-tz-kfM"/> | ||
| 4844 | + <constraint firstAttribute="bottom" secondItem="rvV-78-dYR" secondAttribute="bottom" id="kgH-YM-XNm"/> | ||
| 4845 | + <constraint firstItem="rvV-78-dYR" firstAttribute="top" secondItem="ECe-u7-APW" secondAttribute="top" id="pq8-g0-5sp"/> | ||
| 4846 | + <constraint firstItem="rvV-78-dYR" firstAttribute="leading" secondItem="ECe-u7-APW" secondAttribute="leading" constant="10" id="yop-7a-7O1"/> | ||
| 4847 | + </constraints> | ||
| 4848 | + </tableViewCellContentView> | ||
| 4849 | + <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | ||
| 4850 | + <connections> | ||
| 4851 | + <outlet property="borderView" destination="oIZ-eF-M5Z" id="3yn-Ck-n9c"/> | ||
| 4852 | + <outlet property="couponBgImage" destination="ayq-SS-U8t" id="Xkb-00-8LO"/> | ||
| 4853 | + <outlet property="couponImage" destination="x8f-2v-Jao" id="Nar-6D-BkI"/> | ||
| 4854 | + <outlet property="dicountLabel" destination="3HE-ik-tKt" id="HRc-lF-Erm"/> | ||
| 4855 | + <outlet property="discriptionLabel" destination="WcV-JM-VIz" id="raY-xP-Duz"/> | ||
| 4856 | + <outlet property="expirationLabel" destination="O37-kL-mV9" id="lBr-9Y-C4f"/> | ||
| 4857 | + <outlet property="nameLabel" destination="wRq-jP-x8E" id="W7L-DZ-95L"/> | ||
| 4858 | + </connections> | ||
| 4859 | + </tableViewCell> | ||
| 4757 | </prototypes> | 4860 | </prototypes> |
| 4758 | <connections> | 4861 | <connections> |
| 4759 | <outlet property="dataSource" destination="3uV-Le-crf" id="Qf4-jf-XhM"/> | 4862 | <outlet property="dataSource" destination="3uV-Le-crf" id="Qf4-jf-XhM"/> | ... | ... |
| ... | @@ -17,6 +17,15 @@ import SwiftEventBus | ... | @@ -17,6 +17,15 @@ import SwiftEventBus |
| 17 | @IBOutlet weak var emptyLabel: UILabel! | 17 | @IBOutlet weak var emptyLabel: UILabel! |
| 18 | 18 | ||
| 19 | public var unifiedCoupons:Array<swiftApi.UnifiedCouponModel> = [] | 19 | public var unifiedCoupons:Array<swiftApi.UnifiedCouponModel> = [] |
| 20 | + public var smCoupons:Array<swiftApi.CouponItemModel> = [] | ||
| 21 | + public var smCouponsSelected:Array<swiftApi.CouponItemModel> = [] | ||
| 22 | + | ||
| 23 | + // A reference to the Select All image view for later use | ||
| 24 | + var circleImageView: UIImageView! | ||
| 25 | + | ||
| 26 | + // Track the selection state | ||
| 27 | + var isSelectAllActive: Bool = false | ||
| 28 | + | ||
| 20 | 29 | ||
| 21 | public override func viewDidLoad() { | 30 | public override func viewDidLoad() { |
| 22 | super.viewDidLoad() | 31 | super.viewDidLoad() |
| ... | @@ -29,7 +38,23 @@ import SwiftEventBus | ... | @@ -29,7 +38,23 @@ import SwiftEventBus |
| 29 | self.unifiedCoupons = swiftApi().getUnifiedCouponList() | 38 | self.unifiedCoupons = swiftApi().getUnifiedCouponList() |
| 30 | self.tableView.reloadData() | 39 | self.tableView.reloadData() |
| 31 | 40 | ||
| 32 | - if (self.unifiedCoupons.count == 0) { | 41 | + if (self.unifiedCoupons.count == 0 && self.smCoupons.count == 0) { |
| 42 | + self.emptyView.isHidden = false | ||
| 43 | + self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height | ||
| 44 | + } else { | ||
| 45 | + self.emptyView.isHidden = true | ||
| 46 | + self.emptyViewHeight.constant = 0 | ||
| 47 | + } | ||
| 48 | + } | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + SwiftEventBus.onBackgroundThread(self, name: "sm_coupons_fetched") { result in | ||
| 52 | + | ||
| 53 | + DispatchQueue.main.async { | ||
| 54 | + self.smCoupons = swiftApi().getSMCouponList() | ||
| 55 | + self.tableView.reloadData() | ||
| 56 | + | ||
| 57 | + if (self.unifiedCoupons.count == 0 && self.smCoupons.count == 0) { | ||
| 33 | self.emptyView.isHidden = false | 58 | self.emptyView.isHidden = false |
| 34 | self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height | 59 | self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height |
| 35 | } else { | 60 | } else { |
| ... | @@ -50,7 +75,9 @@ import SwiftEventBus | ... | @@ -50,7 +75,9 @@ import SwiftEventBus |
| 50 | // tableView.clipsToBounds = true | 75 | // tableView.clipsToBounds = true |
| 51 | // tableView.layer.cornerRadius = 30 | 76 | // tableView.layer.cornerRadius = 30 |
| 52 | // tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius | 77 | // tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius |
| 53 | - tableView.contentInset.top = 30 | 78 | +// tableView.contentInset.top = 30 |
| 79 | + // TODO: Change | ||
| 80 | + tableView.contentInset.bottom = 115 | ||
| 54 | 81 | ||
| 55 | emptyLabel.text = "Αυτήν τη στιγμή δεν έχεις κάποιο ενεργό κουπόνι. Στην ενότητα FOR YOU μπορείς να βρεις κουπόνια αποκλειστικά για σένα!" | 82 | emptyLabel.text = "Αυτήν τη στιγμή δεν έχεις κάποιο ενεργό κουπόνι. Στην ενότητα FOR YOU μπορείς να βρεις κουπόνια αποκλειστικά για σένα!" |
| 56 | } | 83 | } |
| ... | @@ -61,9 +88,10 @@ import SwiftEventBus | ... | @@ -61,9 +88,10 @@ import SwiftEventBus |
| 61 | swiftApi().logTrackersEvent("screen", "ActiveUnifiedCouponsScreen") | 88 | swiftApi().logTrackersEvent("screen", "ActiveUnifiedCouponsScreen") |
| 62 | 89 | ||
| 63 | self.unifiedCoupons = swiftApi().getUnifiedCouponList() | 90 | self.unifiedCoupons = swiftApi().getUnifiedCouponList() |
| 91 | + self.smCoupons = swiftApi().getSMCouponList() | ||
| 64 | self.tableView.reloadData() | 92 | self.tableView.reloadData() |
| 65 | 93 | ||
| 66 | - if (self.unifiedCoupons.count == 0) { | 94 | + if (self.unifiedCoupons.count == 0 && self.smCoupons.count == 0) { |
| 67 | self.emptyView.isHidden = false | 95 | self.emptyView.isHidden = false |
| 68 | self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height | 96 | self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height |
| 69 | } else { | 97 | } else { |
| ... | @@ -75,39 +103,248 @@ import SwiftEventBus | ... | @@ -75,39 +103,248 @@ import SwiftEventBus |
| 75 | } | 103 | } |
| 76 | 104 | ||
| 77 | // MARK: - Functions | 105 | // MARK: - Functions |
| 106 | + // Button action for "select all" | ||
| 107 | + @objc func selectAllTapped() { | ||
| 108 | + // Toggle the selection state | ||
| 109 | + isSelectAllActive.toggle() | ||
| 110 | + | ||
| 111 | + // Update the image based on the new state | ||
| 112 | + if (isSelectAllActive) { | ||
| 113 | + circleImageView.image = UIImage(named: "circle_checked", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) // Selected image | ||
| 114 | + smCouponsSelected = smCoupons | ||
| 115 | + } else { | ||
| 116 | + circleImageView.image = UIImage(named: "circle_unchecked", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) // Unselected image | ||
| 117 | + smCouponsSelected = [] | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + // Reload the SM Coupons section only | ||
| 121 | + tableView.reloadSections(IndexSet(integer: 1), with: .automatic) | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + func handleSelectCouponAction(indexPath: IndexPath) { | ||
| 125 | + let currentCoupon = self.smCoupons[indexPath.row] | ||
| 126 | + let isCouponSelected = self.smCouponsSelected.contains { $0.coupon == currentCoupon.coupon } | ||
| 127 | + | ||
| 128 | + if (isCouponSelected) { | ||
| 129 | + self.smCouponsSelected = self.smCouponsSelected.filter({ return $0.coupon != currentCoupon.coupon }) | ||
| 130 | + if (isSelectAllActive) { | ||
| 131 | + isSelectAllActive = false | ||
| 132 | + // Reload the SM Coupons section only | ||
| 133 | + tableView.reloadSections(IndexSet(integer: 1), with: .automatic) | ||
| 134 | + | ||
| 135 | + } else { | ||
| 136 | + tableView.reloadRows(at: [indexPath], with: .automatic) // Reload the specific row | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + } else { | ||
| 140 | + self.smCouponsSelected.append(currentCoupon) | ||
| 141 | + if (self.smCouponsSelected.count == self.smCoupons.count) { | ||
| 142 | + isSelectAllActive = true | ||
| 143 | + // Reload the SM Coupons section only | ||
| 144 | + tableView.reloadSections(IndexSet(integer: 1), with: .automatic) | ||
| 145 | + | ||
| 146 | + } else { | ||
| 147 | + tableView.reloadRows(at: [indexPath], with: .automatic) // Reload the specific row | ||
| 148 | + } | ||
| 149 | + } | ||
| 150 | + | ||
| 151 | + } | ||
| 78 | } | 152 | } |
| 79 | 153 | ||
| 80 | // MARK: - TableView | 154 | // MARK: - TableView |
| 81 | extension UnifiedCouponsViewController: UITableViewDelegate, UITableViewDataSource{ | 155 | extension UnifiedCouponsViewController: UITableViewDelegate, UITableViewDataSource{ |
| 82 | 156 | ||
| 83 | public func numberOfSections(in tableView: UITableView) -> Int { | 157 | public func numberOfSections(in tableView: UITableView) -> Int { |
| 84 | - return 1 | 158 | + return 2 |
| 85 | } | 159 | } |
| 86 | 160 | ||
| 87 | public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | 161 | public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
| 88 | - return self.unifiedCoupons.count | 162 | + if (section == 0) { |
| 163 | + return self.unifiedCoupons.count | ||
| 164 | + } else if (section == 1) { | ||
| 165 | + return self.smCoupons.count | ||
| 166 | + } else { | ||
| 167 | + return 0 | ||
| 168 | + } | ||
| 89 | } | 169 | } |
| 90 | 170 | ||
| 91 | public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { | 171 | public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { |
| 92 | - return 130.0 + 8.0 | 172 | + if (indexPath.section == 0) { |
| 93 | -// return UITableViewAutomaticDimension | 173 | + return 130.0 + 8.0 |
| 174 | + // return UITableViewAutomaticDimension | ||
| 175 | + } else if (indexPath.section == 1) { | ||
| 176 | + return 130.0 + 8.0 | ||
| 177 | + } else { | ||
| 178 | + return 0.0 | ||
| 179 | + } | ||
| 94 | } | 180 | } |
| 95 | 181 | ||
| 96 | public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | 182 | public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
| 97 | - let cell = tableView.dequeueReusableCell(withIdentifier: "UnifiedCouponsTableViewCellId", for: indexPath) as! UnifiedCouponsTableViewCell | 183 | + if (indexPath.section == 0) { |
| 98 | - cell.configureCell(coupon: unifiedCoupons[indexPath.row]) | 184 | + let cell = tableView.dequeueReusableCell(withIdentifier: "UnifiedCouponsTableViewCellId", for: indexPath) as! UnifiedCouponsTableViewCell |
| 99 | - return cell | 185 | + cell.configureCell(coupon: unifiedCoupons[indexPath.row]) |
| 186 | + return cell | ||
| 187 | + | ||
| 188 | + } else { | ||
| 189 | + let currentCoupon = self.smCoupons[indexPath.row] | ||
| 190 | + let isCouponSelected = self.smCouponsSelected.contains { $0.coupon == currentCoupon.coupon } | ||
| 191 | + | ||
| 192 | + let cell = tableView.dequeueReusableCell(withIdentifier: "CouponsTableViewCellId", for: indexPath) as! CouponsTableViewCell | ||
| 193 | + cell.configureCell(coupon: smCoupons[indexPath.row]) | ||
| 194 | + cell.showSelectButton(isSelectViewVisible: true, isSelected: isCouponSelected) { | ||
| 195 | + self.handleSelectCouponAction(indexPath: indexPath) | ||
| 196 | + } | ||
| 197 | + return cell | ||
| 198 | + } | ||
| 100 | } | 199 | } |
| 101 | 200 | ||
| 102 | public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | 201 | public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { |
| 103 | - let couponBarcode = unifiedCoupons[indexPath.row]._barcode | 202 | + if (indexPath.section == 0) { |
| 104 | - swiftApi().logTrackersEvent("click", ("UnifiedCoupon:" + couponBarcode)) | 203 | + let couponBarcode = unifiedCoupons[indexPath.row]._barcode |
| 105 | - | 204 | + swiftApi().logTrackersEvent("click", ("UnifiedCoupon:" + couponBarcode)) |
| 106 | - let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 205 | + |
| 107 | - let vc = storyboard.instantiateViewController(withIdentifier: "UnifiedCouponBarcodeViewController") as! SwiftWarplyFramework.UnifiedCouponBarcodeViewController | 206 | + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
| 108 | - vc.coupon = unifiedCoupons[indexPath.row] | 207 | + let vc = storyboard.instantiateViewController(withIdentifier: "UnifiedCouponBarcodeViewController") as! SwiftWarplyFramework.UnifiedCouponBarcodeViewController |
| 109 | - vc.isFromWallet = true | 208 | + vc.coupon = unifiedCoupons[indexPath.row] |
| 110 | - self.navigationController?.pushViewController(vc, animated: true) | 209 | + vc.isFromWallet = true |
| 210 | + self.navigationController?.pushViewController(vc, animated: true) | ||
| 211 | + | ||
| 212 | + } else if (indexPath.section == 1) { | ||
| 213 | + let couponSetData: swiftApi.CouponSetItemModel? = smCoupons[indexPath.row].couponset_data | ||
| 214 | + let couponName = couponSetData?.name ?? "" | ||
| 215 | + swiftApi().logTrackersEvent("click", ("Coupon:" + couponName)) | ||
| 216 | + | ||
| 217 | + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | ||
| 218 | + let vc = storyboard.instantiateViewController(withIdentifier: "CouponBarcodeViewController") as! SwiftWarplyFramework.CouponBarcodeViewController | ||
| 219 | + vc.coupon = smCoupons[indexPath.row] | ||
| 220 | + vc.isFromWallet = true | ||
| 221 | + self.navigationController?.pushViewController(vc, animated: true) | ||
| 222 | + | ||
| 223 | + } else { | ||
| 224 | + // Do nothing | ||
| 225 | + } | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { | ||
| 229 | + if (section == 0) { | ||
| 230 | + if (self.unifiedCoupons.count > 0) { | ||
| 231 | + let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 70)) | ||
| 232 | + view.backgroundColor = .clear | ||
| 233 | + | ||
| 234 | + let titleLabel = UILabel(frame: CGRect(x: 16, y: 25, width: view.frame.width - 32, height: 25)) | ||
| 235 | + titleLabel.font = UIFont(name: "BTCosmo-Bold", size: 17) | ||
| 236 | +// titleLabel.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00) | ||
| 237 | + titleLabel.textColor = UIColor(rgb: 0x212121) | ||
| 238 | + titleLabel.text = "Ενιαία κουπόνια" | ||
| 239 | + | ||
| 240 | + view.addSubview(titleLabel) | ||
| 241 | + return view | ||
| 242 | + } else { | ||
| 243 | + return nil | ||
| 244 | + } | ||
| 245 | + | ||
| 246 | + } else if (section == 1) { | ||
| 247 | + if (self.smCoupons.count > 0) { | ||
| 248 | + let headerView = UIView() | ||
| 249 | + headerView.backgroundColor = .clear | ||
| 250 | + | ||
| 251 | + // Create the title label (Κουπόνια) | ||
| 252 | + let titleLabel = UILabel() | ||
| 253 | + titleLabel.text = "Κουπόνια" | ||
| 254 | + titleLabel.font = UIFont(name: "BTCosmo-Bold", size: 17) | ||
| 255 | + | ||
| 256 | + // Create the select-all label (Επιλογή όλων) | ||
| 257 | + let selectAllLabel = UILabel() | ||
| 258 | + selectAllLabel.text = "Επιλογή όλων" | ||
| 259 | + selectAllLabel.font = UIFont(name: "PeridotPE-SBold", size: 17) | ||
| 260 | + | ||
| 261 | + // Create a UIImageView for the circle image | ||
| 262 | + circleImageView = UIImageView() | ||
| 263 | +// let circleImage = UIImage(named: "circle_unchecked", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) | ||
| 264 | + | ||
| 265 | + // Update the image based on the new state | ||
| 266 | + if (isSelectAllActive) { | ||
| 267 | + circleImageView.image = UIImage(named: "circle_checked", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) // Selected image | ||
| 268 | + } else { | ||
| 269 | + circleImageView.image = UIImage(named: "circle_unchecked", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) // Unselected image | ||
| 270 | + } | ||
| 271 | +// circleImageView.image = circleImage | ||
| 272 | + circleImageView.contentMode = .scaleAspectFit | ||
| 273 | + circleImageView.translatesAutoresizingMaskIntoConstraints = false | ||
| 274 | + | ||
| 275 | + // Set size for the imageView | ||
| 276 | + circleImageView.widthAnchor.constraint(equalToConstant: 30).isActive = true | ||
| 277 | + circleImageView.heightAnchor.constraint(equalToConstant: 30).isActive = true | ||
| 278 | + | ||
| 279 | + // Create a transparent UIButton on top of the image | ||
| 280 | + let selectAllButton = UIButton(type: .custom) | ||
| 281 | + selectAllButton.backgroundColor = .clear // Keep it transparent | ||
| 282 | + selectAllButton.addTarget(self, action: #selector(selectAllTapped), for: .touchUpInside) | ||
| 283 | + selectAllButton.translatesAutoresizingMaskIntoConstraints = false | ||
| 284 | + | ||
| 285 | + // Set the button size to match the image size | ||
| 286 | + selectAllButton.widthAnchor.constraint(equalToConstant: 30).isActive = true | ||
| 287 | + selectAllButton.heightAnchor.constraint(equalToConstant: 30).isActive = true | ||
| 288 | + | ||
| 289 | + // Create a horizontal stack view to align the title, label, and image | ||
| 290 | + let mainStackView = UIStackView(arrangedSubviews: [titleLabel, selectAllLabel, circleImageView]) | ||
| 291 | + mainStackView.axis = .horizontal | ||
| 292 | + mainStackView.alignment = .center // Centers them vertically | ||
| 293 | + mainStackView.spacing = 10 | ||
| 294 | + | ||
| 295 | + // Add the stack view to the header view | ||
| 296 | + headerView.addSubview(mainStackView) | ||
| 297 | + headerView.addSubview(selectAllButton) // Add the button separately on top of the image view | ||
| 298 | + | ||
| 299 | + // Set constraints for stack view | ||
| 300 | + mainStackView.translatesAutoresizingMaskIntoConstraints = false | ||
| 301 | + mainStackView.leadingAnchor.constraint(equalTo: headerView.leadingAnchor, constant: 16).isActive = true | ||
| 302 | + mainStackView.trailingAnchor.constraint(equalTo: headerView.trailingAnchor, constant: -16).isActive = true | ||
| 303 | + mainStackView.topAnchor.constraint(equalTo: headerView.topAnchor, constant: 8).isActive = true | ||
| 304 | + mainStackView.bottomAnchor.constraint(equalTo: headerView.bottomAnchor, constant: -8).isActive = true | ||
| 305 | + | ||
| 306 | + // Set button position on top of the imageView | ||
| 307 | + selectAllButton.centerXAnchor.constraint(equalTo: circleImageView.centerXAnchor).isActive = true | ||
| 308 | + selectAllButton.centerYAnchor.constraint(equalTo: circleImageView.centerYAnchor).isActive = true | ||
| 309 | + | ||
| 310 | + return headerView | ||
| 311 | + | ||
| 312 | + } else { | ||
| 313 | + return nil | ||
| 314 | + } | ||
| 315 | + | ||
| 316 | + } else { | ||
| 317 | + return nil | ||
| 318 | + } | ||
| 319 | + } | ||
| 320 | + | ||
| 321 | + public func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { | ||
| 322 | + if (section == 0) { | ||
| 323 | + if (self.unifiedCoupons.count > 0) { | ||
| 324 | + return 70.0 | ||
| 325 | + } else { | ||
| 326 | + return 0.0 | ||
| 327 | + } | ||
| 328 | + | ||
| 329 | + } else if (section == 1) { | ||
| 330 | + if (self.smCoupons.count > 0) { | ||
| 331 | + return 70.0 | ||
| 332 | + } else { | ||
| 333 | + return 0.0 | ||
| 334 | + } | ||
| 335 | + | ||
| 336 | + } else { | ||
| 337 | + return 0.0 | ||
| 338 | + } | ||
| 339 | + } | ||
| 340 | + | ||
| 341 | + public func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { | ||
| 342 | +// return CGFloat.leastNormalMagnitude | ||
| 343 | + return 0.0 | ||
| 344 | + } | ||
| 345 | + | ||
| 346 | + public func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { | ||
| 347 | + return nil | ||
| 111 | } | 348 | } |
| 112 | 349 | ||
| 113 | } | 350 | } | ... | ... |
-
Please register or login to post a comment