Skip to content

Commit

Permalink
feat: ✨accommodation result UI 구현(#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lia316 committed Jun 3, 2021
1 parent 2bb95fd commit f551304
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 8 deletions.
Binary file not shown.
29 changes: 28 additions & 1 deletion iOS/Airbnb/Airbnb/ResultPage/View/AccommodationCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,36 @@ class AccommodationCell: UICollectionViewCell {
static let reuseIdentifier = "AccommodationCell"
static let nib = UINib(nibName: AccommodationCell.reuseIdentifier, bundle: nil)

@IBOutlet weak var mainImageView: UIImageView!
@IBOutlet weak var gradeLabel: UILabel!
@IBOutlet weak var reviewLabel: UILabel!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var priceLabel: UILabel!
@IBOutlet weak var totalPriceLabel: UILabel!


override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}

func fillUI(with room: Room) {
self.convert(imageUrlString: room.images.mainImage) { uiimage in
self.mainImageView.image = uiimage
}
self.gradeLabel.text = "\(room.grade)"
self.reviewLabel.text = "후기 \(room.review)"
self.titleLabel.text = room.title
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
let price = numberFormatter.string(from: NSNumber(value: room.price))!
self.priceLabel.text = "\(price) / 박"
}

private func convert(imageUrlString: String, handler: @escaping (UIImage) ->()) {
guard let url = URL(string: imageUrlString) else { return }
DispatchQueue.main.async {
let data = try? Data(contentsOf: url)
handler(UIImage(data: data!) ?? UIImage())
}
}
}
115 changes: 108 additions & 7 deletions iOS/Airbnb/Airbnb/ResultPage/View/AccommodationCell.xib
Original file line number Diff line number Diff line change
@@ -1,21 +1,122 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13142" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12042"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="AccommodationCell" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="AccommodationCell" customModule="Airbnb" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="390" height="390"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<rect key="frame" x="0.0" y="0.0" width="390" height="390"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2Ky-zj-TbH">
<rect key="frame" x="0.0" y="0.0" width="390" height="390"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="4yM-aL-clQ">
<rect key="frame" x="10" y="10" width="370" height="246.5"/>
<constraints>
<constraint firstAttribute="width" secondItem="4yM-aL-clQ" secondAttribute="height" multiplier="3:2" id="8Kd-6K-Az3"/>
</constraints>
</imageView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="top" spacing="7" translatesAutoresizingMaskIntoConstraints="NO" id="zU1-28-Gpe">
<rect key="frame" x="15" y="268.5" width="360" height="106.5"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" spacing="9" translatesAutoresizingMaskIntoConstraints="NO" id="iUw-oW-0fx">
<rect key="frame" x="0.0" y="0.0" width="124" height="15"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="star.fill" catalog="system" translatesAutoresizingMaskIntoConstraints="NO" id="bXC-MG-Xg9">
<rect key="frame" x="0.0" y="-0.5" width="15" height="15"/>
<color key="tintColor" red="0.90980392156862744" green="0.29803921568627451" blue="0.37647058823529411" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" constant="15" id="BdV-sb-xc8"/>
<constraint firstAttribute="height" constant="15" id="NZC-ZQ-MKS"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="4.80" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UcP-iE-bJr">
<rect key="frame" x="24" y="0.0" width="26" height="15"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="(후기 127개)" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="L2y-Zl-8ck">
<rect key="frame" x="59" y="0.0" width="65" height="15"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="65" id="nZ1-ce-7K7"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" systemColor="secondaryLabelColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" text="Spacious and Comfortable cozy house" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hmT-KK-Pcc">
<rect key="frame" x="0.0" y="22" width="337" height="32"/>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="₩82,953 / 박" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Nal-BR-pHI">
<rect key="frame" x="0.0" y="61" width="98" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="총액 ₩1,493,159" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eIY-Yk-nFB">
<rect key="frame" x="0.0" y="88.5" width="109.5" height="18"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" systemColor="secondaryLabelColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="zU1-28-Gpe" secondAttribute="trailing" constant="15" id="BgG-wU-U0o"/>
<constraint firstItem="zU1-28-Gpe" firstAttribute="top" secondItem="4yM-aL-clQ" secondAttribute="bottom" constant="12" id="FTm-RI-kgJ"/>
<constraint firstItem="4yM-aL-clQ" firstAttribute="leading" secondItem="2Ky-zj-TbH" secondAttribute="leading" constant="10" id="G0n-og-pE0"/>
<constraint firstItem="zU1-28-Gpe" firstAttribute="leading" secondItem="2Ky-zj-TbH" secondAttribute="leading" constant="15" id="IQK-mI-IC9"/>
<constraint firstAttribute="bottom" secondItem="zU1-28-Gpe" secondAttribute="bottom" constant="15" id="QaY-2d-AqA"/>
<constraint firstItem="4yM-aL-clQ" firstAttribute="top" secondItem="2Ky-zj-TbH" secondAttribute="top" constant="10" id="gXK-Kd-qPe"/>
<constraint firstAttribute="trailing" secondItem="4yM-aL-clQ" secondAttribute="trailing" constant="10" id="wPc-JZ-UkD"/>
</constraints>
</view>
</subviews>
</view>
<viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="2Ky-zj-TbH" secondAttribute="bottom" id="Kx9-iH-2oC"/>
<constraint firstItem="2Ky-zj-TbH" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="S9l-yi-O70"/>
<constraint firstAttribute="trailing" secondItem="2Ky-zj-TbH" secondAttribute="trailing" id="jEJ-Sx-jmz"/>
<constraint firstItem="2Ky-zj-TbH" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="tkX-fQ-9YD"/>
</constraints>
<size key="customSize" width="419" height="199"/>
<connections>
<outlet property="gradeLabel" destination="UcP-iE-bJr" id="gYk-A5-Ssy"/>
<outlet property="mainImageView" destination="4yM-aL-clQ" id="cn2-nB-hLq"/>
<outlet property="priceLabel" destination="Nal-BR-pHI" id="bQL-CN-g6f"/>
<outlet property="reviewLabel" destination="L2y-Zl-8ck" id="vtF-wu-Ad3"/>
<outlet property="titleLabel" destination="hmT-KK-Pcc" id="Tot-JH-iJ1"/>
<outlet property="totalPriceLabel" destination="eIY-Yk-nFB" id="QNY-tm-0s9"/>
</connections>
<point key="canvasLocation" x="398.55072463768118" y="152.00892857142856"/>
</collectionViewCell>
</objects>
<resources>
<image name="star.fill" catalog="system" width="128" height="116"/>
<systemColor name="secondaryLabelColor">
<color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>

0 comments on commit f551304

Please sign in to comment.