Manos Chorianopoulos

fix PopupMerchantsViewController dynamic height

......@@ -7,7 +7,7 @@
<key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
......@@ -7,7 +7,7 @@
<key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
......@@ -6398,7 +6398,7 @@
<constraint firstAttribute="bottom" secondItem="kH9-FC-wgF" secondAttribute="bottom" id="cNA-DV-1fn"/>
</constraints>
</view>
<tableView clipsSubviews="YES" contentMode="scaleToFill" ambiguous="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="vet-Po-Bmf" customClass="DynamicSizeTableView" customModule="SwiftWarplyFramework" customModuleProvider="target">
<tableView clipsSubviews="YES" contentMode="scaleToFill" ambiguous="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="vet-Po-Bmf" customClass="DynamicSizeMerchantsTableView" customModule="SwiftWarplyFramework" customModuleProvider="target">
<rect key="frame" x="0.0" y="50" width="414" height="250"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="separatorColor" red="0.68235294120000001" green="0.68235294120000001" blue="0.68235294120000001" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
......@@ -6406,10 +6406,10 @@
<color key="sectionIndexBackgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="MerchantTableViewCellId" id="fym-iB-q6x" customClass="MerchantTableViewCell" customModule="SwiftWarplyFramework" customModuleProvider="target">
<rect key="frame" x="0.0" y="50" width="414" height="56"/>
<rect key="frame" x="0.0" y="50" width="414" height="88"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="fym-iB-q6x" id="jOZ-KL-eu1">
<rect key="frame" x="0.0" y="0.0" width="414" height="56"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="88"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="TQn-b5-U6q">
......@@ -6479,7 +6479,7 @@
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="TQn-b5-U6q" secondAttribute="bottom" id="DlG-eC-Miw"/>
<constraint firstAttribute="bottom" secondItem="TQn-b5-U6q" secondAttribute="bottom" constant="32" id="DlG-eC-Miw"/>
<constraint firstItem="TQn-b5-U6q" firstAttribute="top" secondItem="jOZ-KL-eu1" secondAttribute="top" id="Znl-Kn-l4H"/>
<constraint firstItem="TQn-b5-U6q" firstAttribute="leading" secondItem="jOZ-KL-eu1" secondAttribute="leading" constant="18" id="dsI-sU-JVJ"/>
<constraint firstAttribute="trailing" secondItem="TQn-b5-U6q" secondAttribute="trailing" constant="18" id="prx-5Z-TVo"/>
......@@ -6496,7 +6496,7 @@
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="PopupMerchantsFooterTableViewCellId" id="f5f-VE-AbI" customClass="PopupMerchantsFooterTableViewCell" customModule="SwiftWarplyFramework" customModuleProvider="target">
<rect key="frame" x="0.0" y="106" width="414" height="50"/>
<rect key="frame" x="0.0" y="138" width="414" height="50"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="f5f-VE-AbI" id="YhO-v9-8eO">
<rect key="frame" x="0.0" y="0.0" width="414" height="50"/>
......@@ -6549,7 +6549,6 @@
<constraint firstAttribute="bottom" secondItem="vet-Po-Bmf" secondAttribute="bottom" id="B03-fG-aC2"/>
<constraint firstItem="vet-Po-Bmf" firstAttribute="leading" secondItem="cSR-WK-qb0" secondAttribute="leading" id="F8e-cg-wdq"/>
<constraint firstItem="MNf-7L-OWL" firstAttribute="top" secondItem="cSR-WK-qb0" secondAttribute="top" constant="15" id="N8O-in-CB3"/>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="320" id="c1w-Ub-vF7"/>
<constraint firstItem="vet-Po-Bmf" firstAttribute="top" secondItem="MNf-7L-OWL" secondAttribute="bottom" constant="15" id="hl9-87-bJ7"/>
<constraint firstAttribute="trailing" secondItem="vet-Po-Bmf" secondAttribute="trailing" id="lgN-8i-jJk"/>
</constraints>
......
......@@ -66,12 +66,12 @@ class MerchantTableViewCell: UITableViewCell {
// Configure the view for the selected state
}
public override func layoutSubviews() {
super.layoutSubviews()
//set the values for top,left,bottom,right margins
let margins = UIEdgeInsets(top: 0, left: 0, bottom: 32, right: 0)
contentView.frame = contentView.frame.inset(by: margins)
}
// public override func layoutSubviews() {
// super.layoutSubviews()
// //set the values for top,left,bottom,right margins
// let margins = UIEdgeInsets(top: 0, left: 0, bottom: 32, right: 0)
// contentView.frame = contentView.frame.inset(by: margins)
// }
func configureCell(shop: swiftApi.ShopAvailabilityItemModel, buttonTitle: String, iconImage: String?, showEshops: Bool?) {
......
......@@ -188,8 +188,12 @@ extension NumberPopupViewController: UITableViewDelegate, UITableViewDataSource{
}
}
// override public var intrinsicContentSize: CGSize {
// return contentSize
// }
override public var intrinsicContentSize: CGSize {
return contentSize
return CGSize(width: UIView.noIntrinsicMetric, height: contentSize.height + contentInset.top + contentInset.bottom)
}
}
......
......@@ -11,7 +11,7 @@ class PopupMerchantsViewController: UIViewController {
@IBOutlet weak var popupView: UIView!
@IBOutlet weak var headerLabel: UILabel!
@IBOutlet weak var closeButton: UIButton!
@IBOutlet weak var tableView: DynamicSizeTableView!
@IBOutlet weak var tableView: DynamicSizeMerchantsTableView!
public var availableShopsList:Array<swiftApi.ShopAvailabilityItemModel> = []
// public var coupon: swiftApi.CouponItemModel?
......@@ -45,6 +45,8 @@ class PopupMerchantsViewController: UIViewController {
self.headerLabel.text = self.headerText
headerLabel.font = UIFont(name: "BTCosmo-Bold", size: 18)
headerLabel.textColor = UIColor(rgb: 0x000000)
// setupFooterView()
}
// MARK: - Functions
......@@ -60,6 +62,38 @@ class PopupMerchantsViewController: UIViewController {
availableShopsList.append(tempShop2)
}
// private func setupFooterView() {
// // Create a footer view container
// let footerView = UIView()
// footerView.backgroundColor = .clear
//
// // Create a label for the footer
// let footerLabel = UILabel()
// footerLabel.text = "Η διαθεσιμότητα ενδέχεται να διαφέρει ανάλογα με την τοποθεσία."
// footerLabel.textAlignment = .center
// footerLabel.font = UIFont(name: "PeridotPE-Regular", size: 13)
// footerLabel.textColor = UIColor(rgb: 0x000000)
// footerLabel.numberOfLines = 0 // Allow for multiline text
//
// // Add label to the footer view
// footerView.addSubview(footerLabel)
// footerLabel.translatesAutoresizingMaskIntoConstraints = false
//
// // Set constraints for the label inside the footer view
// NSLayoutConstraint.activate([
// footerLabel.leadingAnchor.constraint(equalTo: footerView.leadingAnchor, constant: 16),
// footerLabel.trailingAnchor.constraint(equalTo: footerView.trailingAnchor, constant: -16),
// footerLabel.topAnchor.constraint(equalTo: footerView.topAnchor, constant: 10),
// footerLabel.bottomAnchor.constraint(equalTo: footerView.bottomAnchor, constant: -10)
// ])
//
// // Set the footer view's frame size to fit the content
// footerView.frame = CGRect(x: 0, y: 0, width: tableView.frame.width, height: 50)
//
// // Assign the footer view to the table view's footer
// tableView.tableFooterView = footerView
// }
// MARK: - UIButton Actions
@IBAction func closeButtonAction(_ sender: Any) {
self.dismiss(animated: true, completion: {})
......@@ -155,3 +189,23 @@ extension PopupMerchantsViewController: MerchantTableViewCellDelegate {
}
}
// Class for dynamic height table view
@objc public class DynamicSizeMerchantsTableView: UITableView
{
override public func layoutSubviews() {
super.layoutSubviews()
if bounds.size != intrinsicContentSize {
invalidateIntrinsicContentSize()
}
}
// override public var intrinsicContentSize: CGSize {
// return contentSize
// }
override public var intrinsicContentSize: CGSize {
return CGSize(width: UIView.noIntrinsicMetric, height: contentSize.height + contentInset.top + contentInset.bottom + 30)
}
}
......