Skip to content

Commit

Permalink
Merge pull request #380 from TeamNado-Sunbae/fix/#374-UI-Review-Main
Browse files Browse the repository at this point in the history
๐Ÿ”จ [FIX] ํ›„๊ธฐ ๋ฉ”์ธ ๋ทฐ ๊ธด ๊ธ€์ž์ˆ˜ ๊ฒฝ์šฐ UI ์ˆ˜์ •
  • Loading branch information
jane1choi authored Mar 20, 2022
2 parents 0f86d80 + 245c00b commit fdae796
Show file tree
Hide file tree
Showing 16 changed files with 181 additions and 195 deletions.
40 changes: 40 additions & 0 deletions NadoSunbae-iOS/NadoSunbae-iOS/Global/Extension/String+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,43 @@ extension String {
}
}
}

/// ์ „๊ณต์ •๋ณด String์œผ๋กœ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜
func convertToMajorInfoString(_ firstMajorName: String, _ firstMajorStart: String, _ secondMajorName: String, _ secondMajorStart: String) -> String {
if secondMajorName == "๋ฏธ์ง„์ž…" {
return firstMajorName + " " + firstMajorStart + " " + "|" + " " + secondMajorName
} else {
return firstMajorName + " " + firstMajorStart + " " + "|" + " " + secondMajorName + " " + secondMajorStart
}
}

/// ๋‹‰๋„ค์ž„ + ์ „๊ณต์ •๋ณด String์œผ๋กœ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜
func convertToUserInfoString(_ nickname: String, _ firstMajorName: String, _ firstMajorStart: String, _ secondMajorName: String, _ secondMajorStart: String) -> String {
if secondMajorName == "๋ฏธ์ง„์ž…" {
return nickname + " " + firstMajorName + " " + firstMajorStart + " | " + secondMajorName
} else {
/// ๋‹‰๋„ค์ž„ + ๋ณธ์ „๊ณต๋ช… + ๋ณธ์ „๊ณต์ง„์ž…์‹œ๊ธฐ + ์ œ2์ „๊ณต + ์ œ2์ „๊ณต์ง„์ž…์‹œ๊ธฐ ๊ธ€์ž์ˆ˜ 32์ž ๋„˜์„ ๋•Œ (๋‹‰๋„ค์ž„ ํ…์ŠคํŠธ ํฌ๊ธฐ ๊ณ ๋ ค)
if (nickname.count + firstMajorName.count + firstMajorStart.count + secondMajorName.count + secondMajorStart.count) > 30 {

if screenWidth == 375 {
/// ๋ณธ์ „๊ณต๋ช… + ๋ณธ์ „๊ณต์ง„์ž…์‹œ๊ธฐ + ์ œ2์ „๊ณต + ์ œ2์ „๊ณต์ง„์ž…์‹œ๊ธฐ ๊ธ€์ž์ˆ˜ 35์ž ๋„˜์„ ๋•Œ
if (firstMajorName.count + firstMajorStart.count + secondMajorName.count + secondMajorStart.count) > 35 {
return nickname + "\n" + firstMajorName + " " + firstMajorStart + " |\n" + secondMajorName + " " + secondMajorStart
} else {
/// ๋ณธ์ „๊ณต๋ช… + ๋ณธ์ „๊ณต์ง„์ž…์‹œ๊ธฐ + ์ œ2์ „๊ณต + ์ œ2์ „๊ณต์ง„์ž…์‹œ๊ธฐ ๊ธ€์ž์ˆ˜ 35์ž ๋„˜์ง€ ์•Š์„ ๋•Œ
return nickname + "\n" + firstMajorName + " " + firstMajorStart + " | " + secondMajorName + " " + secondMajorStart
}
} else {
/// ๋ณธ์ „๊ณต๋ช… + ๋ณธ์ „๊ณต์ง„์ž…์‹œ๊ธฐ + ์ œ2์ „๊ณต + ์ œ2์ „๊ณต์ง„์ž…์‹œ๊ธฐ ๊ธ€์ž์ˆ˜ 37์ž ๋„˜์„ ๋•Œ
if (firstMajorName.count + firstMajorStart.count + secondMajorName.count + secondMajorStart.count) > 37 {
return nickname + "\n" + firstMajorName + " " + firstMajorStart + " |\n" + secondMajorName + " " + secondMajorStart
} else {
/// ๋ณธ์ „๊ณต๋ช… + ๋ณธ์ „๊ณต์ง„์ž…์‹œ๊ธฐ + ์ œ2์ „๊ณต + ์ œ2์ „๊ณต์ง„์ž…์‹œ๊ธฐ ๊ธ€์ž์ˆ˜ 37์ž ๋„˜์ง€ ์•Š์„ ๋•Œ
return nickname + "\n" + firstMajorName + " " + firstMajorStart + " | " + secondMajorName + " " + secondMajorStart
}
}
} else {
return nickname + " " + firstMajorName + " " + firstMajorStart + " | " + secondMajorName + " " + secondMajorStart
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import Foundation

struct APIConstants {

//MARK: Base URL
// MARK: Base URL
#if DEBUG
static let baseURL = "https://asia-northeast3-nadosunbae-server-dev-90ac3.cloudfunctions.net/api"
#else
static let baseURL = "https://asia-northeast3-nadosunbae-server.cloudfunctions.net/api"
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,3 @@ struct ClassroomQuestionWriter: Codable {
}
}

func convertToMajorInfoString(_ firstMajorName: String, _ firstMajorStart: String, _ secondMajorName: String, _ secondMajorStart: String) -> String {
if secondMajorName == "๋ฏธ์ง„์ž…" {
return firstMajorName + " " + firstMajorStart + " " + "|" + " " + secondMajorName
} else {
return firstMajorName + " " + firstMajorStart + " " + "|" + " " + secondMajorName + " " + secondMajorStart
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
//

import Foundation
import UIKit

let screenSize: CGRect = UIScreen.main.bounds
let screenWidth = screenSize.width

// MARK: - ReviewMainPostListData
struct ReviewMainPostListData: Codable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="์ƒ์ƒํ•œ ํ•™๊ณผ ํ›„๊ธฐ" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2kv-Vh-R6u">
<rect key="frame" x="111" y="83" width="153" height="29"/>
<rect key="frame" x="111" y="96" width="153" height="29"/>
<fontDescription key="fontDescription" name="Pretendard-SemiBold" family="Pretendard" pointSize="23.399999618530273"/>
<color key="textColor" name="mainDefault"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="749" image="group687" translatesAutoresizingMaskIntoConstraints="NO" id="jwr-rW-5X5">
<rect key="frame" x="24" y="202" width="327" height="412"/>
<rect key="frame" x="24" y="215" width="327" height="399"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="GSB-6A-eFV">
<rect key="frame" x="73" y="144" width="229" height="34"/>
<rect key="frame" x="73" y="157" width="229" height="34"/>
<string key="text">์žฅ๋‹จ์ , ๋ญ˜๋ฐฐ์šฐ๋‚˜์š”?, ์ถ”์ฒœ์ˆ˜์—…, ๋น„์ถ”์ˆ˜์—…,
ํ–ฅํ›„์ง„๋กœ, ๊ฟ€ํŒ ๋“ฑ์œผ๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์–ด์š”.</string>
<fontDescription key="fontDescription" name="Pretendard-Regular" family="Pretendard" pointSize="14"/>
Expand All @@ -51,6 +51,7 @@
<constraint firstItem="2kv-Vh-R6u" firstAttribute="centerX" secondItem="ZTg-uK-7eu" secondAttribute="centerX" id="3YE-pP-fYu"/>
<constraint firstItem="jwr-rW-5X5" firstAttribute="top" secondItem="GSB-6A-eFV" secondAttribute="bottom" constant="24" id="AX2-y5-zfv"/>
<constraint firstItem="GSB-6A-eFV" firstAttribute="top" secondItem="2kv-Vh-R6u" secondAttribute="bottom" constant="32" id="HIE-NI-dzD"/>
<constraint firstItem="2kv-Vh-R6u" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" constant="96" id="U5I-yh-OJ8"/>
<constraint firstAttribute="bottom" secondItem="jwr-rW-5X5" secondAttribute="bottom" constant="198" id="kJ7-89-eaI"/>
</constraints>
<connections>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="749" image="thirdPage" translatesAutoresizingMaskIntoConstraints="NO" id="Jf0-XJ-ash">
<rect key="frame" x="24" y="202" width="327" height="412"/>
<rect key="frame" x="24" y="224.5" width="327" height="389.5"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1:1 ์งˆ๋ฌธ, ์ „์ฒด์—๊ฒŒ ์งˆ๋ฌธ" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BhN-Bv-m8B">
<rect key="frame" x="81" y="73.5" width="213" height="29"/>
<rect key="frame" x="81" y="96" width="213" height="29"/>
<fontDescription key="fontDescription" name="Pretendard-SemiBold" family="Pretendard" pointSize="23.399999618530273"/>
<color key="textColor" name="mainDefault"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4nf-rn-NWu">
<rect key="frame" x="76.5" y="122.5" width="222" height="50.5"/>
<rect key="frame" x="76.5" y="145" width="222" height="50.5"/>
<string key="text">๊ถ๊ธˆํ•œ๊ฒŒ ์žˆ๋Š” ํ•™๊ณผ ์„ ๋ฐฐ์—๊ฒ 1:1 ์งˆ๋ฌธ์„,
ํ•™๊ณผ ๊ตฌ์„ฑ์› ๋ชจ๋‘์˜ ์˜๊ฒฌ์„ ๋“ฃ๊ณ  ์‹ถ์„ ๋•
์ „์ฒด์—๊ฒŒ ์งˆ๋ฌธ์„ ํ•ด๋ณด์„ธ์š”.</string>
Expand All @@ -53,6 +53,7 @@
<constraint firstItem="Jf0-XJ-ash" firstAttribute="centerX" secondItem="ZTg-uK-7eu" secondAttribute="centerX" id="CBn-CG-obq"/>
<constraint firstItem="4nf-rn-NWu" firstAttribute="top" secondItem="BhN-Bv-m8B" secondAttribute="bottom" constant="20" id="NEb-1i-V9R"/>
<constraint firstItem="4nf-rn-NWu" firstAttribute="centerX" secondItem="ZTg-uK-7eu" secondAttribute="centerX" id="UxW-1c-QSF"/>
<constraint firstItem="BhN-Bv-m8B" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" constant="96" id="jJp-S2-J7s"/>
</constraints>
<connections>
<outlet property="subTitleLabel" destination="4nf-rn-NWu" id="MvF-av-TqH"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ class ReviewMainPostTVC: BaseTVC {
// MARK: IBOutlet
@IBOutlet weak var dateLabel: UILabel!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var nickNameLabel: UILabel!
@IBOutlet weak var likeCountLabel: UILabel!
@IBOutlet weak var majorNameLabel: UILabel!
@IBOutlet weak var firstMajorStartLabel: UILabel!
@IBOutlet weak var secondMajorNameLabel: UILabel!
@IBOutlet weak var secondMajorStartLabel: UILabel!
@IBOutlet weak var majorLabel: UILabel!
@IBOutlet weak var likeImgView: UIImageView!
@IBOutlet weak var majorSeparatorView: UIView!
@IBOutlet weak var reviewContentView: UIView!
@IBOutlet weak var tagCV: UICollectionView!

// MARK: Properties
Expand All @@ -46,56 +42,57 @@ class ReviewMainPostTVC: BaseTVC {
// MARK: - UI
extension ReviewMainPostTVC {
private func configureUI() {
contentView.layer.cornerRadius = 8
contentView.layer.borderWidth = 1
contentView.layer.borderColor = UIColor.gray0.cgColor
contentView.backgroundColor = .white
}

/// TVC ์‚ฌ์ด ๊ฐ„๊ฒฉ ์„ค์ •
override func layoutSubviews() {
super.layoutSubviews()
contentView.frame = contentView.frame.inset(by: UIEdgeInsets(top: 16, left: 16, bottom: 0, right: 16))
reviewContentView.layer.cornerRadius = 8
reviewContentView.layer.borderWidth = 1
reviewContentView.layer.borderColor = UIColor.gray0.cgColor
reviewContentView.backgroundColor = .white
}
}

// MARK: - Custom Methods
extension ReviewMainPostTVC {

/// ๋ฆฌ์ŠคํŠธ ๋ฐ์ดํ„ฐ ์„ธํŒ… ํ•จ์ˆ˜
func setData(postData: ReviewMainPostListData) {
func setPostData(postData: ReviewMainPostListData) {
dateLabel.text = postData.createdAt.serverTimeToString(forUse: .forDefault)
titleLabel.text = postData.oneLineReview
nickNameLabel.text = postData.writer.nickname
likeCountLabel.text = "\(postData.like.likeCount)"
majorNameLabel.text = postData.writer.firstMajorName
secondMajorNameLabel.text = postData.writer.secondMajorName
firstMajorStartLabel.text = postData.writer.firstMajorStart
secondMajorStartLabel.text = postData.writer.secondMajorStart == "๋ฏธ์ง„์ž…" ? "" : postData.writer.secondMajorStart
likeImgView.image = postData.like.isLiked ? UIImage(named: "heart_filled") : UIImage(named: "btn_heart")
}

/// ์œ ์ € ์ •๋ณด ๋ฐ์ดํ„ฐ ์„ธํŒ… ํ•จ์ˆ˜
func setUserData(postData: ReviewMainPostListData) {
let majorText = convertToUserInfoString(postData.writer.nickname, postData.writer.firstMajorName, postData.writer.firstMajorStart, postData.writer.secondMajorName, postData.writer.secondMajorStart)
let attributedString = NSMutableAttributedString(string: majorText)
attributedString.addAttribute(.foregroundColor, value: UIColor.gray4, range: (majorText as NSString).range(of: postData.writer.nickname))
attributedString.addAttribute(.font, value: UIFont.PretendardSB(size: 14), range: (majorText as NSString).range(of: postData.writer.nickname))
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 6
attributedString.addAttribute(NSAttributedString.Key.paragraphStyle, value: paragraphStyle, range: NSMakeRange(0, attributedString.length))
majorLabel.attributedText = attributedString
majorLabel.lineBreakStrategy = .hangulWordPriority
majorLabel.sizeToFit()
}

/// ๋งˆ์ดํŽ˜์ด์ง€ ํ›„๊ธฐ ๋ฆฌ์ŠคํŠธ ๋ฐ์ดํ„ฐ ์„ธํŒ… ํ•จ์ˆ˜
func setUserReviewData(postData: MypageMyReviewPostModel) {
dateLabel.text = postData.createdAt.serverTimeToString(forUse: .forDefault)
titleLabel.text = postData.oneLineReview
nickNameLabel.text = postData.majorName
majorLabel.text = postData.majorName
majorLabel.font = .PretendardSB(size: 14)
majorLabel.textColor = .gray4
likeCountLabel.text = "\(postData.like.likeCount)"
[majorNameLabel, secondMajorNameLabel, firstMajorStartLabel, secondMajorStartLabel, majorSeparatorView].forEach { view in
view?.isHidden = true
}
likeImgView.image = postData.like.isLiked ? UIImage(named: "heart_filled") : UIImage(named: "btn_heart")
}

/// ๋งˆ์ดํŽ˜์ด์ง€ ํ›„๊ธฐ ์ข‹์•„์š” ๋ฆฌ์ŠคํŠธ ๋ฐ์ดํ„ฐ ์„ธํŒ… ํ•จ์ˆ˜
func setMypageReviewLikeData(postData: MypageLikeReviewDataModel) {
dateLabel.text = postData.createdAt.serverTimeToString(forUse: .forDefault)
titleLabel.text = postData.title
nickNameLabel.text = postData.writer.nickname
majorLabel.text = postData.writer.nickname
majorLabel.font = .PretendardSB(size: 14)
majorLabel.textColor = .gray4
likeCountLabel.text = "\(postData.like.likeCount)"
[majorNameLabel, secondMajorNameLabel, firstMajorStartLabel, secondMajorStartLabel, majorSeparatorView].forEach { view in
view?.isHidden = true
}
likeImgView.image = postData.like.isLiked ? UIImage(named: "heart_filled") : UIImage(named: "btn_heart")
}

Expand Down
Loading

0 comments on commit fdae796

Please sign in to comment.