Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Projects/CommonUI/CommonUI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
537F80B2F39FD73F6F78F9B2 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47AA88AB7E000E21ED0BD7D8 /* HomeView.swift */; };
7D319882A302F75CCE46A48C /* HomeQuizView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39A77FC9A0E2D7F62CA16E90 /* HomeQuizView.swift */; };
951226DA2E2340E3000FDE3D /* QuizView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 951226D92E2340DC000FDE3D /* QuizView.swift */; };
951226E02E268D72000FDE3D /* OptionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 951226DF2E268D6F000FDE3D /* OptionView.swift */; };
951226E22E2690B9000FDE3D /* AnswerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 951226E12E2690B2000FDE3D /* AnswerView.swift */; };
951226E82E270A75000FDE3D /* QuizCompleteAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 951226E72E270A75000FDE3D /* QuizCompleteAlertView.swift */; };
BAD8B768F782046D4AA1C073 /* RxCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F3DE048BEDCB92B48F401061 /* RxCocoa.framework */; };
BE81B1F3E60D37D75A058D2B /* SnapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9CCDC15081A22BAED6318E3E /* SnapKit.framework */; };
CEADBDD98AC9921C05AAC1DA /* QuizCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7A9CE581345578C7C0F1F1A /* QuizCollectionViewCell.swift */; };
Expand Down Expand Up @@ -52,6 +55,9 @@
951226D62E233E3E000FDE3D /* Colors.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Colors.xcassets; sourceTree = "<group>"; };
951226D72E233E3E000FDE3D /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
951226D92E2340DC000FDE3D /* QuizView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizView.swift; sourceTree = "<group>"; };
951226DF2E268D6F000FDE3D /* OptionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OptionView.swift; sourceTree = "<group>"; };
951226E12E2690B2000FDE3D /* AnswerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnswerView.swift; sourceTree = "<group>"; };
951226E72E270A75000FDE3D /* QuizCompleteAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizCompleteAlertView.swift; sourceTree = "<group>"; };
9CCDC15081A22BAED6318E3E /* SnapKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SnapKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C28FE6392E1612667826E5C5 /* DiaryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryView.swift; sourceTree = "<group>"; };
C69A8F84966D9255A07CB9B1 /* DefaultNavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultNavigationBar.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -175,11 +181,14 @@
DFA6DB2905DB98838A8AEA6F /* Home */ = {
isa = PBXGroup;
children = (
951226E72E270A75000FDE3D /* QuizCompleteAlertView.swift */,
7CE59FBFD1AAA1B5E7B45FD5 /* HomeProgressView.swift */,
39A77FC9A0E2D7F62CA16E90 /* HomeQuizView.swift */,
47AA88AB7E000E21ED0BD7D8 /* HomeView.swift */,
E7A9CE581345578C7C0F1F1A /* QuizCollectionViewCell.swift */,
951226D92E2340DC000FDE3D /* QuizView.swift */,
951226DF2E268D6F000FDE3D /* OptionView.swift */,
951226E12E2690B2000FDE3D /* AnswerView.swift */,
);
path = Home;
sourceTree = "<group>";
Expand Down Expand Up @@ -272,12 +281,15 @@
files = (
F3DA12FF4D18AE405F2F6B08 /* BaseViewController.swift in Sources */,
E0865F2849CCB89CC83D3B77 /* Coordinator.swift in Sources */,
951226E22E2690B9000FDE3D /* AnswerView.swift in Sources */,
E055AA66777B1D4CC8C884E4 /* CommonUIAssets.swift in Sources */,
F7673E4248628D67F3542848 /* ChatView.swift in Sources */,
FB3FE0AB8AE6868B6D5E241C /* DiaryView.swift in Sources */,
951226E82E270A75000FDE3D /* QuizCompleteAlertView.swift in Sources */,
951226DA2E2340E3000FDE3D /* QuizView.swift in Sources */,
416C58AEE5E4491991982CFF /* HomeProgressView.swift in Sources */,
7D319882A302F75CCE46A48C /* HomeQuizView.swift in Sources */,
951226E02E268D72000FDE3D /* OptionView.swift in Sources */,
537F80B2F39FD73F6F78F9B2 /* HomeView.swift in Sources */,
CEADBDD98AC9921C05AAC1DA /* QuizCollectionViewCell.swift in Sources */,
473C96577A92DD6F71241A76 /* MyPageView.swift in Sources */,
Expand Down
116 changes: 116 additions & 0 deletions Projects/CommonUI/Sources/View/Home/AnswerView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
//
// AnswerView.swift
// CommonUI
//
// Created by 박지윤 on 7/15/25.
//

import Domain
import UIKit
import SnapKit
import RxSwift
import Then

open class AnswerView: UIView {
var correctView = UIView()
var correctLabel = UILabel()
var wrongView = UIView()
var wrongLabel = UILabel()

public enum AnswerType {
case correct
case wrong
}

public init(text: String, type: AnswerType) {
super.init(frame: .zero)
initAttribute(type: type)
initUI(type: type)
bindDatas(text: text, type: type)
}

public func bind(course: CourseVO) {
}

public func bindDatas(text: String, type: AnswerType) {
switch type {
case .correct:
correctLabel.text = text
case .wrong:
wrongLabel.text = text
}
}

func initAttribute(type: AnswerType) {
switch type {
case .correct:
correctView = correctView.then {
$0.layer.borderColor = UIColor.black.cgColor
$0.layer.borderWidth = 1
// $0.backgroundColor = CommonUIAssets.LMGray6
$0.layer.cornerRadius = 12
}

correctLabel = correctLabel.then {
$0.textColor = .black
// $0.textColor = CommonUIAssets.LMGray1
$0.textAlignment = .center
$0.font = .systemFont(ofSize: 13, weight: .regular)
$0.numberOfLines = 0
$0.setContentHuggingPriority(.required, for: .vertical)
$0.setContentCompressionResistancePriority(.required, for: .vertical)
}
case .wrong:
wrongView = wrongView.then {
$0.layer.borderColor = UIColor.black.cgColor
$0.layer.borderWidth = 1
// $0.backgroundColor = CommonUIAssets.LMBlue
$0.layer.cornerRadius = 12
}

wrongLabel = wrongLabel.then {
$0.textColor = .black
// $0.textColor = CommonUIAssets.LMGray1
$0.font = .systemFont(ofSize: 14, weight: .regular)
$0.numberOfLines = 0
$0.setContentHuggingPriority(.required, for: .vertical)
$0.setContentCompressionResistancePriority(.required, for: .vertical)
}
}
}

func initUI(type: AnswerType) {
switch type {
case .correct:
self.addSubview(correctView)
correctView.addSubview(correctLabel)

correctView.snp.makeConstraints {
$0.verticalEdges.equalToSuperview()
$0.leading.equalToSuperview().inset(20)
}

correctLabel.snp.makeConstraints {
$0.horizontalEdges.equalToSuperview().inset(16)
$0.verticalEdges.equalToSuperview().inset(12)
}
case .wrong:
self.addSubview(wrongView)
wrongView.addSubview(wrongLabel)

wrongView.snp.makeConstraints {
$0.verticalEdges.equalToSuperview()
$0.leading.equalToSuperview().inset(20)
}

wrongLabel.snp.makeConstraints {
$0.horizontalEdges.equalToSuperview().inset(16)
$0.verticalEdges.equalToSuperview().inset(12)
}
}
}

required public init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
76 changes: 76 additions & 0 deletions Projects/CommonUI/Sources/View/Home/OptionView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//
// OptionView.swift
// CommonUI
//
// Created by 박지윤 on 7/15/25.
//

import Domain
import UIKit
import SnapKit
import RxSwift
import Then

open class OptionView: UIView {
var optionView = UIView()
var optionLabel = UILabel()

private let options = [
"응. 너는 누구야?",
"네, 안녕하세요. 처음 뵙겠습니다.",
"왜요?"
]

public init(text: String) {
super.init(frame: .zero)
initAttribute()
initUI()
bindDatas(text: text)
}

public func bindDatas(text: String) {
optionLabel.text = text
}

public func bind(course: CourseVO) {
}

func initAttribute() {
optionView = optionView.then {
$0.layer.borderColor = UIColor.black.cgColor
$0.layer.borderWidth = 1
// $0.backgroundColor = CommonUIAssets.LMGray6
$0.layer.cornerRadius = 12
}

optionLabel = optionLabel.then {
$0.textColor = .black
// $0.textColor = CommonUIAssets.LMGray1
$0.textAlignment = .center
$0.font = .systemFont(ofSize: 13, weight: .regular)
$0.numberOfLines = 0
$0.setContentHuggingPriority(.required, for: .vertical)
$0.setContentCompressionResistancePriority(.required, for: .vertical)
}
}

func initUI() {
self.addSubview(optionView)
optionView.addSubview(optionLabel)

optionView.snp.makeConstraints {
$0.top.bottom.equalToSuperview()
$0.leading.equalToSuperview().inset(100)
$0.trailing.equalToSuperview().inset(20)
}

optionLabel.snp.makeConstraints {
$0.horizontalEdges.equalToSuperview().inset(16)
$0.verticalEdges.equalToSuperview().inset(12)
}
}

required public init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
132 changes: 132 additions & 0 deletions Projects/CommonUI/Sources/View/Home/QuizCompleteAlertView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
//
// QuizCompleteAlertView.swift
// CommonUI
//
// Created by 박지윤 on 7/16/25.
//

import UIKit
import SnapKit
import Then

public final class QuizCompleteAlertView: UIView {

private let backgroundView = UIView().then {
$0.backgroundColor = UIColor.black.withAlphaComponent(0.4)
$0.alpha = 0.0
}

private let containerView = UIView().then {
$0.backgroundColor = .white
$0.layer.cornerRadius = 16
$0.clipsToBounds = true
}

private let titleLabel = UILabel().then {
$0.text = "퀴즈 완료!"
$0.textColor = .black
$0.font = .boldSystemFont(ofSize: 20)
$0.textAlignment = .center
$0.numberOfLines = 0
}

private let messageLabel = UILabel().then {
$0.text = "모든 질문에 잘 답변했어요 👏"
$0.textColor = .darkGray
$0.font = .systemFont(ofSize: 16)
$0.textAlignment = .center
$0.numberOfLines = 0
}

private let confirmButton = UIButton(type: .system).then {
$0.setTitle("확인", for: .normal)
$0.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
$0.setTitleColor(.white, for: .normal)
$0.backgroundColor = .systemBlue
$0.layer.cornerRadius = 8
}

public override init(frame: CGRect) {
super.init(frame: frame)
setupView()
setupLayout()
confirmButton.addTarget(self, action: #selector(dismiss), for: .touchUpInside)
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func setupView() {
self.addSubview(backgroundView)
self.addSubview(containerView)

[titleLabel, messageLabel, confirmButton].forEach {
containerView.addSubview($0)
}
}

private func setupLayout() {
backgroundView.snp.makeConstraints {
$0.edges.equalToSuperview()
}

containerView.snp.makeConstraints {
$0.center.equalToSuperview()
$0.width.equalToSuperview().multipliedBy(0.8)
}

titleLabel.snp.makeConstraints {
$0.top.equalToSuperview().inset(24)
$0.leading.trailing.equalToSuperview().inset(16)
}

messageLabel.snp.makeConstraints {
$0.top.equalTo(titleLabel.snp.bottom).offset(12)
$0.leading.trailing.equalToSuperview().inset(16)
}

confirmButton.snp.makeConstraints {
$0.top.equalTo(messageLabel.snp.bottom).offset(20)
$0.bottom.equalToSuperview().inset(20)
$0.centerX.equalToSuperview()
$0.width.equalTo(100)
$0.height.equalTo(40)
}
}

public func show(in parentView: UIView) {
parentView.addSubview(self)
self.snp.makeConstraints { $0.edges.equalToSuperview() }

UIView.animate(withDuration: 0.3) {
self.backgroundView.alpha = 1.0
}
}

@objc private func dismiss() {
UIView.animate(withDuration: 0.3, animations: {
self.backgroundView.alpha = 0.0
}) { _ in
self.removeFromSuperview()
if let viewController = self.findViewController() {
if let navigationController = viewController.navigationController {
navigationController.popViewController(animated: true)
} else {
viewController.dismiss(animated: true, completion: nil)
}
}
}
}

private func findViewController() -> UIViewController? {
var responder: UIResponder? = self
while responder != nil {
if let vc = responder as? UIViewController {
return vc
}
responder = responder?.next
}
return nil
}
}
Loading
Loading