From de436b5b78c9112ed9747f50dc86bc774b5c0ea1 Mon Sep 17 00:00:00 2001 From: Yurim Kim Date: Fri, 14 Feb 2025 01:04:41 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[Chore]=20=EB=B9=84=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=EC=8B=9C=20=EB=8F=84=ED=86=A0=EB=A6=AC=20=EA=B0=9C?= =?UTF-8?q?=EC=88=98=20"=3F=3F/25"=20=EB=90=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20(#18)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Global/Literals/StringLiterals.swift | 2 ++ .../Profile/View/ProfileView.swift | 24 +++++++++++++++---- .../Profile/View/ProfileViewController.swift | 1 + 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ACON-iOS/ACON-iOS/Global/Literals/StringLiterals.swift b/ACON-iOS/ACON-iOS/Global/Literals/StringLiterals.swift index 5218a980..948c128d 100644 --- a/ACON-iOS/ACON-iOS/Global/Literals/StringLiterals.swift +++ b/ACON-iOS/ACON-iOS/Global/Literals/StringLiterals.swift @@ -311,6 +311,8 @@ enum StringLiterals { static let needLogin = "로그인이 필요해요" + static let twoQuestionMarks = "??" + static let notVerified = "미인증" static let acornPossession = "보유한 도토리 수" diff --git a/ACON-iOS/ACON-iOS/Presentation/Profile/View/ProfileView.swift b/ACON-iOS/ACON-iOS/Presentation/Profile/View/ProfileView.swift index 7fbd33ad..9522b033 100644 --- a/ACON-iOS/ACON-iOS/Presentation/Profile/View/ProfileView.swift +++ b/ACON-iOS/ACON-iOS/Presentation/Profile/View/ProfileView.swift @@ -80,10 +80,22 @@ final class ProfileView: BaseView { $0.spacing = boxStackSpacing } - acornCountBox.setStyle( - title: StringLiterals.Profile.acornPossession, - icon: .icLocalAconG20 - ) + acornCountBox.do { + $0.setStyle( + title: StringLiterals.Profile.acornPossession, + icon: .icLocalAconG20 + ) + + let notVerifiedLabel = UILabel() + notVerifiedLabel.setPartialText( + fullText: StringLiterals.Profile.twoQuestionMarks + "/" + String(totalAcornCount), + textStyles: [ + (text: StringLiterals.Profile.twoQuestionMarks, style: .t2, color: .org1), + (text: "/" + String(totalAcornCount), style: .s2, color: .gray5) + ] + ) + $0.setSecondaryContentView(to: notVerifiedLabel) + } verifiedAreaBox.do { $0.setStyle( @@ -207,6 +219,10 @@ extension ProfileView { acornCountBox.setContentView(to: acornCountabel) } + func setAcornCountBox(onLoginSuccess: Bool) { + acornCountBox.switchContentView(toSecondary: !onLoginSuccess) + } + func setVerifiedAreaBox(areaName: String) { let label = UILabel() label.setLabel(text: areaName, diff --git a/ACON-iOS/ACON-iOS/Presentation/Profile/View/ProfileViewController.swift b/ACON-iOS/ACON-iOS/Presentation/Profile/View/ProfileViewController.swift index 9dff804e..2ad927c3 100644 --- a/ACON-iOS/ACON-iOS/Presentation/Profile/View/ProfileViewController.swift +++ b/ACON-iOS/ACON-iOS/Presentation/Profile/View/ProfileViewController.swift @@ -84,6 +84,7 @@ private extension ProfileViewController { self.profileView.do { $0.needLoginButton.isHidden = onLoginSuccess + $0.setAcornCountBox(onLoginSuccess: onLoginSuccess) $0.setVerifiedAreaBox(onLoginSuccess: onLoginSuccess) } } From 2420ef383fdef97acc3a9299932684a65612c845 Mon Sep 17 00:00:00 2001 From: Yurim Kim Date: Fri, 14 Feb 2025 02:32:46 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[Chore]=20=ED=94=84=EB=A1=9C=ED=95=84?= =?UTF-8?q?=EB=B7=B0=20=EB=8F=84=ED=86=A0=EB=A6=AC=20=EA=B0=9C=EC=88=98=20?= =?UTF-8?q?UI=20=EA=B5=AC=EC=A1=B0=20=EC=88=98=EC=A0=95=20(partialText=20-?= =?UTF-8?q?>=20stackView)=20(#18)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Profile/View/ProfileView.swift | 41 +++++++------------ .../Profile/View/ProfileViewController.swift | 5 ++- 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/ACON-iOS/ACON-iOS/Presentation/Profile/View/ProfileView.swift b/ACON-iOS/ACON-iOS/Presentation/Profile/View/ProfileView.swift index 9522b033..5fc57446 100644 --- a/ACON-iOS/ACON-iOS/Presentation/Profile/View/ProfileView.swift +++ b/ACON-iOS/ACON-iOS/Presentation/Profile/View/ProfileView.swift @@ -85,16 +85,6 @@ final class ProfileView: BaseView { title: StringLiterals.Profile.acornPossession, icon: .icLocalAconG20 ) - - let notVerifiedLabel = UILabel() - notVerifiedLabel.setPartialText( - fullText: StringLiterals.Profile.twoQuestionMarks + "/" + String(totalAcornCount), - textStyles: [ - (text: StringLiterals.Profile.twoQuestionMarks, style: .t2, color: .org1), - (text: "/" + String(totalAcornCount), style: .s2, color: .gray5) - ] - ) - $0.setSecondaryContentView(to: notVerifiedLabel) } verifiedAreaBox.do { @@ -204,23 +194,22 @@ extension ProfileView { nicknameLabel.setLabel(text: text, style: .h5) } - func setAcornCountBox(_ possessingCount: Int) { - let acornCountabel = UILabel() - let possessingString = possessingCount == 0 ? "00" : String(possessingCount) - // TODO: partialText 가운데 정렬 되도록 수정 (바닥 정렬인 partialText도 있어서 메소드 하나 더 만들어야 할 듯) - acornCountabel.setPartialText( - fullText: "\(possessingString)/\(String(totalAcornCount))", - textStyles: [ - (text: possessingString, style: .t2, color: .org1), - (text: "/\(String(totalAcornCount))", style: .s2, color: .gray5) - ] - ) + func setAcornCountBox(_ possessingString: String) { + let labelStack = UIStackView() + let possessingLabel = UILabel() + let totalLabel = UILabel() - acornCountBox.setContentView(to: acornCountabel) - } - - func setAcornCountBox(onLoginSuccess: Bool) { - acornCountBox.switchContentView(toSecondary: !onLoginSuccess) + labelStack.do { + $0.axis = .horizontal + $0.alignment = .center + $0.spacing = 2 + } + possessingLabel.setLabel(text: possessingString, style: .t2, color: .org1) + totalLabel.setLabel(text: "/" + String(totalAcornCount), style: .s2, color: .gray5) + + labelStack.addArrangedSubviews(possessingLabel, totalLabel) + + acornCountBox.setContentView(to: labelStack) } func setVerifiedAreaBox(areaName: String) { diff --git a/ACON-iOS/ACON-iOS/Presentation/Profile/View/ProfileViewController.swift b/ACON-iOS/ACON-iOS/Presentation/Profile/View/ProfileViewController.swift index 2ad927c3..1b7a189e 100644 --- a/ACON-iOS/ACON-iOS/Presentation/Profile/View/ProfileViewController.swift +++ b/ACON-iOS/ACON-iOS/Presentation/Profile/View/ProfileViewController.swift @@ -84,7 +84,7 @@ private extension ProfileViewController { self.profileView.do { $0.needLoginButton.isHidden = onLoginSuccess - $0.setAcornCountBox(onLoginSuccess: onLoginSuccess) + $0.setAcornCountBox("??") $0.setVerifiedAreaBox(onLoginSuccess: onLoginSuccess) } } @@ -97,9 +97,10 @@ private extension ProfileViewController { let firstAreaName: String = self.viewModel.userInfo.value?.verifiedAreaList.first?.name ?? "impossible" profileView.do { + let possessingAcornStr = userInfo.possessingAcorns == 0 ? "00" : String(userInfo.possessingAcorns) $0.setProfileImage(userInfo.profileImageURL) $0.setNicknameLabel(userInfo.nickname) - $0.setAcornCountBox(userInfo.possessingAcorns) + $0.setAcornCountBox(possessingAcornStr) $0.setVerifiedAreaBox(areaName: firstAreaName) } } From 38e900c3592e41a9e8fcb95f513afcd72ae8bf08 Mon Sep 17 00:00:00 2001 From: Yurim Kim Date: Fri, 14 Feb 2025 02:32:46 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[Chore]=20=ED=94=84=EB=A1=9C=ED=95=84?= =?UTF-8?q?=EB=B7=B0=20=EB=8F=84=ED=86=A0=EB=A6=AC=20=EA=B0=9C=EC=88=98=20?= =?UTF-8?q?UI=20=EA=B5=AC=EC=A1=B0=20=EC=88=98=EC=A0=95=20(partialText=20-?= =?UTF-8?q?>=20stackView)=20(#18)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Global/Literals/StringLiterals.swift | 2 +- .../Profile/View/ProfileView.swift | 64 +++++++++++++------ 2 files changed, 45 insertions(+), 21 deletions(-) diff --git a/ACON-iOS/ACON-iOS/Global/Literals/StringLiterals.swift b/ACON-iOS/ACON-iOS/Global/Literals/StringLiterals.swift index 948c128d..61f662d3 100644 --- a/ACON-iOS/ACON-iOS/Global/Literals/StringLiterals.swift +++ b/ACON-iOS/ACON-iOS/Global/Literals/StringLiterals.swift @@ -311,7 +311,7 @@ enum StringLiterals { static let needLogin = "로그인이 필요해요" - static let twoQuestionMarks = "??" + static let doubleQuestionMarks = "??" static let notVerified = "미인증" diff --git a/ACON-iOS/ACON-iOS/Presentation/Profile/View/ProfileView.swift b/ACON-iOS/ACON-iOS/Presentation/Profile/View/ProfileView.swift index 9522b033..fc131a23 100644 --- a/ACON-iOS/ACON-iOS/Presentation/Profile/View/ProfileView.swift +++ b/ACON-iOS/ACON-iOS/Presentation/Profile/View/ProfileView.swift @@ -86,14 +86,9 @@ final class ProfileView: BaseView { icon: .icLocalAconG20 ) - let notVerifiedLabel = UILabel() - notVerifiedLabel.setPartialText( - fullText: StringLiterals.Profile.twoQuestionMarks + "/" + String(totalAcornCount), - textStyles: [ - (text: StringLiterals.Profile.twoQuestionMarks, style: .t2, color: .org1), - (text: "/" + String(totalAcornCount), style: .s2, color: .gray5) - ] - ) + let notVerifiedLabel = makeCountLabels( + StringLiterals.Profile.doubleQuestionMarks, + String(totalAcornCount)) $0.setSecondaryContentView(to: notVerifiedLabel) } @@ -189,6 +184,42 @@ final class ProfileView: BaseView { } +// MARK: - Helpers + +private extension ProfileView { + + func makeCountLabels(_ currentString: String, _ totalString: String) -> UIView { + let contentView = UIView() + let labelStack = UIStackView() + let currentLabel = UILabel() + let totalLabel = UILabel() + + labelStack.do { + $0.axis = .horizontal + $0.alignment = .center + $0.spacing = 2 + } + currentLabel.setLabel(text: currentString, style: .t2, color: .org1) + totalLabel.setLabel(text: "/" + String(totalString), style: .s2, color: .gray5) + + contentView.addSubview(labelStack) + labelStack.addArrangedSubviews(currentLabel, totalLabel) + + labelStack.snp.makeConstraints { + $0.center.equalToSuperview() + } + + // TODO: contentView - Width and horizontal position are ambiguous + contentView.snp.makeConstraints { + $0.width.height.greaterThanOrEqualTo(labelStack) + } + + return contentView + } + +} + + // MARK: - Internal Methods extension ProfileView { @@ -204,19 +235,12 @@ extension ProfileView { nicknameLabel.setLabel(text: text, style: .h5) } - func setAcornCountBox(_ possessingCount: Int) { - let acornCountabel = UILabel() - let possessingString = possessingCount == 0 ? "00" : String(possessingCount) - // TODO: partialText 가운데 정렬 되도록 수정 (바닥 정렬인 partialText도 있어서 메소드 하나 더 만들어야 할 듯) - acornCountabel.setPartialText( - fullText: "\(possessingString)/\(String(totalAcornCount))", - textStyles: [ - (text: possessingString, style: .t2, color: .org1), - (text: "/\(String(totalAcornCount))", style: .s2, color: .gray5) - ] - ) + func setAcornCountBox(_ currentCount: Int) { + let currentString = currentCount == 0 ? "00" : String(currentCount) + let totalString = String(totalAcornCount) + let countLabelStack = makeCountLabels(currentString, totalString) - acornCountBox.setContentView(to: acornCountabel) + acornCountBox.setContentView(to: countLabelStack) } func setAcornCountBox(onLoginSuccess: Bool) {