Skip to content

Commit

Permalink
Merge pull request #202 from Team-Smeme/feat/#187-mySummary
Browse files Browse the repository at this point in the history
[Feat] #187 성과 UI + API 연결
  • Loading branch information
cchanmi authored May 16, 2024
2 parents 6595419 + 32b7cdf commit f578b15
Show file tree
Hide file tree
Showing 10 changed files with 516 additions and 202 deletions.
34 changes: 19 additions & 15 deletions Smeem-iOS/Smeem-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
371107E52ACBEA69007A4AC2 /* DiaryViewFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 371107E42ACBEA69007A4AC2 /* DiaryViewFactory.swift */; };
371107E72ACBED3C007A4AC2 /* DiaryViewConfigurationBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 371107E62ACBED3C007A4AC2 /* DiaryViewConfigurationBuilder.swift */; };
371107E92ACC7E3A007A4AC2 /* DiaryLayoutConfigurations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 371107E82ACC7E3A007A4AC2 /* DiaryLayoutConfigurations.swift */; };
371C69D32BE112AD000D745D /* BottomSheetPresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 371C69D22BE112AD000D745D /* BottomSheetPresentable.swift */; };
371C69D52BE11926000D745D /* BadgeBottomSheetViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 371C69D42BE11926000D745D /* BadgeBottomSheetViewController.swift */; };
37144C512B88E949008565C4 /* DiaryViewControllerFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37144C502B88E949008565C4 /* DiaryViewControllerFactory.swift */; };
37144C582B890923008565C4 /* DiaryModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37144C572B890923008565C4 /* DiaryModel.swift */; };
371C69D32BE112AD000D745D /* BottomSheetPresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 371C69D22BE112AD000D745D /* BottomSheetPresentable.swift */; };
371C69D52BE11926000D745D /* BadgeBottomSheetViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 371C69D42BE11926000D745D /* BadgeBottomSheetViewController.swift */; };
371E94162A87B83D0098280F /* NextButtonDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 371E94152A87B83D0098280F /* NextButtonDelegate.swift */; };
371E94192A87DA960098280F /* EditHowGoalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 371E94182A87DA960098280F /* EditHowGoalViewController.swift */; };
3728B8D32A2CFED300EF4CF8 /* ForeignDiaryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3728B8D22A2CFED300EF4CF8 /* ForeignDiaryViewController.swift */; };
Expand Down Expand Up @@ -129,6 +129,7 @@
4A9FAB482A4C3D1200C40D5A /* BadgeHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A9FAB432A4C3D1200C40D5A /* BadgeHeaderView.swift */; };
4A9FAB492A4C3D1200C40D5A /* DetailBadgeCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A9FAB442A4C3D1200C40D5A /* DetailBadgeCollectionViewCell.swift */; };
4AA1EEEA2A5873A00017FF97 /* Urbanist-SemiBold.otf in Resources */ = {isa = PBXBuildFile; fileRef = 4AA1EEE92A5870690017FF97 /* Urbanist-SemiBold.otf */; };
4AA5E4B42BF2355300F308C8 /* MySummaryViewModel2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AA5E4B32BF2355300F308C8 /* MySummaryViewModel2.swift */; };
4AA942C22A2767D000A552A0 /* FSCalendar in Frameworks */ = {isa = PBXBuildFile; productRef = 4AA942C12A2767D000A552A0 /* FSCalendar */; };
4AA942C52A2767D900A552A0 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 4AA942C42A2767D900A552A0 /* SnapKit */; };
4AA942CD2A276A9F00A552A0 /* Moya in Frameworks */ = {isa = PBXBuildFile; productRef = 4AA942CC2A276A9F00A552A0 /* Moya */; };
Expand Down Expand Up @@ -246,10 +247,10 @@
371107E42ACBEA69007A4AC2 /* DiaryViewFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryViewFactory.swift; sourceTree = "<group>"; };
371107E62ACBED3C007A4AC2 /* DiaryViewConfigurationBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryViewConfigurationBuilder.swift; sourceTree = "<group>"; };
371107E82ACC7E3A007A4AC2 /* DiaryLayoutConfigurations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryLayoutConfigurations.swift; sourceTree = "<group>"; };
371C69D22BE112AD000D745D /* BottomSheetPresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottomSheetPresentable.swift; sourceTree = "<group>"; };
371C69D42BE11926000D745D /* BadgeBottomSheetViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BadgeBottomSheetViewController.swift; sourceTree = "<group>"; };
37144C502B88E949008565C4 /* DiaryViewControllerFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryViewControllerFactory.swift; sourceTree = "<group>"; };
37144C572B890923008565C4 /* DiaryModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryModel.swift; sourceTree = "<group>"; };
371C69D22BE112AD000D745D /* BottomSheetPresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottomSheetPresentable.swift; sourceTree = "<group>"; };
371C69D42BE11926000D745D /* BadgeBottomSheetViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BadgeBottomSheetViewController.swift; sourceTree = "<group>"; };
371E94152A87B83D0098280F /* NextButtonDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextButtonDelegate.swift; sourceTree = "<group>"; };
371E94182A87DA960098280F /* EditHowGoalViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditHowGoalViewController.swift; sourceTree = "<group>"; };
3728B8D22A2CFED300EF4CF8 /* ForeignDiaryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForeignDiaryViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -368,6 +369,7 @@
4A9FAB432A4C3D1200C40D5A /* BadgeHeaderView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BadgeHeaderView.swift; sourceTree = "<group>"; };
4A9FAB442A4C3D1200C40D5A /* DetailBadgeCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetailBadgeCollectionViewCell.swift; sourceTree = "<group>"; };
4AA1EEE92A5870690017FF97 /* Urbanist-SemiBold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Urbanist-SemiBold.otf"; sourceTree = "<group>"; };
4AA5E4B32BF2355300F308C8 /* MySummaryViewModel2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MySummaryViewModel2.swift; sourceTree = "<group>"; };
4AB7C9182B75F9B500845733 /* GesturePublisher+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "GesturePublisher+.swift"; sourceTree = "<group>"; };
4AB7C91A2B7624CC00845733 /* ServiceAcceptAppData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServiceAcceptAppData.swift; sourceTree = "<group>"; };
4AB7C9252B78914100845733 /* SplashViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -517,15 +519,6 @@
path = View;
sourceTree = "<group>";
};
371C69D12BE1126E000D745D /* BottomSheet */ = {
isa = PBXGroup;
children = (
371C69D22BE112AD000D745D /* BottomSheetPresentable.swift */,
371C69D42BE11926000D745D /* BadgeBottomSheetViewController.swift */,
);
path = BottomSheet;
sourceTree = "<group>";
};
37144C4F2B88E8F4008565C4 /* Model */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -589,9 +582,10 @@
37A574B529FE204500312453 /* Presentation */ = {
isa = PBXGroup;
children = (
4AA5E4B52BF24CEB00F308C8 /* BadgeBottomSheet */,
4AC705A72BECE051003C5310 /* Edit */,
4AC705892BEA0BD3003C5310 /* Setting */,
4ABCBCB82BD6A6E3003138A8 /* MySummary */,
4AC705892BEA0BD3003C5310 /* Setting */,
4ADA41752A556185001C0285 /* LodingView */,
37DCA65E2A48030A00FF8F90 /* DetailDiary */,
37CD0DB32A1DEE64001F03E7 /* Diaries */,
Expand Down Expand Up @@ -629,7 +623,6 @@
37A574B729FE208A00312453 /* UIComponents */ = {
isa = PBXGroup;
children = (
371C69D12BE1126E000D745D /* BottomSheet */,
4A81C2952ACDAB0A0056E815 /* HowLearning */,
4A81C2942ACDAAF80056E815 /* PlanGoal */,
371107DB2ACAB4E3007A4AC2 /* Base */,
Expand Down Expand Up @@ -1206,6 +1199,15 @@
path = MyPage;
sourceTree = "<group>";
};
4AA5E4B52BF24CEB00F308C8 /* BadgeBottomSheet */ = {
isa = PBXGroup;
children = (
371C69D22BE112AD000D745D /* BottomSheetPresentable.swift */,
371C69D42BE11926000D745D /* BadgeBottomSheetViewController.swift */,
);
path = BadgeBottomSheet;
sourceTree = "<group>";
};
4AB7C91C2B7886D000845733 /* View */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1351,6 +1353,7 @@
isa = PBXGroup;
children = (
4ABCBCCF2BDE9BA1003138A8 /* MySummaryViewModel.swift */,
4AA5E4B32BF2355300F308C8 /* MySummaryViewModel2.swift */,
);
path = ViewModel;
sourceTree = "<group>";
Expand Down Expand Up @@ -2066,6 +2069,7 @@
3797891C2AAE11D400C61EF4 /* NavigationBarConfigurationBuilder.swift in Sources */,
4A3373F82A461ABC00EFE6C4 /* OnboardingService.swift in Sources */,
4A9731D72BAAB6E100DEC0C8 /* SplashServiceProtocol.swift in Sources */,
4AA5E4B42BF2355300F308C8 /* MySummaryViewModel2.swift in Sources */,
37A574E82A02424F00312453 /* RandomTopicView.swift in Sources */,
4ABCBCCA2BDD3E3D003138A8 /* MySummaryResponse.swift in Sources */,
4AC7059D2BEA2A8E003C5310 /* SettingEndPoint.swift in Sources */,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,20 @@ struct MySummaryBadgeResponse: Codable {
let imageUrl: String
let badgeAcquisitionRatio: Double
}

enum RatioType: Codable {
case Int
case Double
}

struct MySummaryBadgeAppData: Codable {
let badgeId: Int
let name: String
let type: String
let hasBadge: Bool
let remainingNumber: Int?
let contentForNonBadgeOwner: String?
let contentForBadgeOwner: String?
let imageUrl: String
let badgeAcquisitionRatio: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
//
// BadgeBottomSheetViewController.swift
// Smeem-iOS
//
// Created by Joon Baek on 2024/04/30.
//

import UIKit

import Combine
import SnapKit
import Kingfisher

enum BadgeType {
case welcome
case diaryCount
case dailyDiary
}

// MARK: - BadgeBottomSheet

final class BadgeBottomSheetViewController: BaseViewController {

// MARK: - Properties

private var cancelBag = Set<AnyCancellable>()


// MARK: - UI Properties

private lazy var dismissButton: UIButton = {
let button = UIButton()
button.setBackgroundImage(Constant.Image.icnCancelBlack, for: .normal)
return button
}()

private lazy var badgeImageView: UIImageView = makeImage()

private lazy var contentStackView: UIStackView = makeContentView()
private lazy var headerLabel: UILabel = makeLabel(font: .h3, textColor: .smeemBlack)
private lazy var bodyLabel: UILabel = makeLabel(font: .b3, textColor: .smeemBlack)

private lazy var descriptionLabel: UILabel = makeLabel(font: .b3, textColor: .gray500)

// MARK: - Life Cycle

override func viewDidLoad() {
super.viewDidLoad()

setLayout()
bind()
}

private func bind() {
dismissButton.tapPublisher
.sink { [weak self] _ in
self?.dismiss(animated: true)
}
.store(in: &cancelBag)
}

func setData(data: MySummaryBadgeAppData) {
// 배지 획득시
if data.hasBadge {
let url = URL(string: data.imageUrl)
badgeImageView.kf.setImage(with: url)

switch data.type {
case "EVENT":
headerLabel.text = data.name
bodyLabel.text = data.contentForBadgeOwner
descriptionLabel.text = "100%의 사용자가 획득했어요."
case "COUNTING":
headerLabel.text = data.name
bodyLabel.text = data.contentForBadgeOwner
descriptionLabel.text = "\(data.badgeAcquisitionRatio)%의 사용자가 획득했어요."
case "COMBO":
headerLabel.text = data.name
bodyLabel.text = data.contentForBadgeOwner
descriptionLabel.text = "\(data.badgeAcquisitionRatio)%의 사용자가 획득했어요."
case "EXPLORATION":
headerLabel.text = data.name
bodyLabel.text = data.contentForBadgeOwner
descriptionLabel.text = "\(data.badgeAcquisitionRatio)%의 사용자가 획득했어요."
default: break
}
} else {
switch data.type {
case "EVENT":
headerLabel.text = data.name
bodyLabel.text = data.contentForNonBadgeOwner
descriptionLabel.text = "100%의 사용자가 획득했어요."
case "COUNTING":
headerLabel.text = data.name
guard let number = data.remainingNumber else { return }
bodyLabel.text = "일기를 \(number)번 더 작성해요"
let attributedStr = NSMutableAttributedString(string: bodyLabel.text!)
attributedStr.addAttribute(.foregroundColor, value: UIColor.point, range: (bodyLabel.text! as NSString).range(of: "\(number)"))
bodyLabel.attributedText = attributedStr
descriptionLabel.text = "\(data.badgeAcquisitionRatio)%의 사용자가 획득했어요."
case "COMBO":
headerLabel.text = data.name
bodyLabel.text = data.contentForNonBadgeOwner
descriptionLabel.text = "\(data.badgeAcquisitionRatio)%의 사용자가 획득했어요."
case "EXPLORATION":
headerLabel.text = data.name
bodyLabel.text = data.contentForNonBadgeOwner
descriptionLabel.text = "\(data.badgeAcquisitionRatio)%의 사용자가 획득했어요."
default: break

}
}
}
}

// MARK: - Extensions

extension BadgeBottomSheetViewController {
private func setLayout() {
contentStackView.addArrangedSubviews(headerLabel, bodyLabel)
view.addSubviews(dismissButton,
badgeImageView,
contentStackView,
descriptionLabel)

dismissButton.snp.makeConstraints { make in
make.top.trailing.equalToSuperview().inset(8)
}

badgeImageView.snp.makeConstraints { make in
make.top.equalTo(dismissButton.snp.bottom).offset(5)
make.centerX.equalToSuperview()
make.size.equalTo(120)
}

contentStackView.snp.makeConstraints { make in
make.top.equalTo(badgeImageView.snp.bottom).offset(26)
make.leading.trailing.equalToSuperview().inset(23)
}

descriptionLabel.snp.makeConstraints { make in
make.top.equalTo(contentStackView.snp.bottom).offset(12)
make.centerX.equalToSuperview()
}
}

private func makeContentView() -> UIStackView {
let stackView = UIStackView()
stackView.axis = .vertical
stackView.spacing = 8
stackView.alignment = .center
return stackView
}

private func makeLabel(font: UIFont, textColor: UIColor) -> UILabel {
let label = UILabel()
label.font = font
label.textColor = textColor
return label
}

private func makeImage() -> UIImageView {
let image = UIImageView()
image.image = Constant.Image.btnLockBadge
return image
}
}
Loading

0 comments on commit f578b15

Please sign in to comment.