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
38 changes: 38 additions & 0 deletions ByeBoo-iOS/ByeBoo-iOS/Presentation/Enum/AIAnswerState.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// AIAnswerState.swift
// ByeBoo-iOS
//
// Created by 최주리 on 2/18/26.
//

import UIKit

enum AIAnswerState {
case loading
case fail
case success
}

extension AIAnswerState {
var text: String {
switch self {
case .loading:
"보리가 열심히 답변을 작성하고 있어요!"
case .fail:
"답변 생성을 실패했어요.\n잠시 뒤에 다시 시도해 주세요."
case .success:
""
}
}

var image: UIImage {
switch self {
case .loading:
.boriWriting
case .fail:
.boriRetry
case .success:
.boriLetter
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ final class ArchiveQuestView: BaseView {
private let thinkView: ThinkView?
private let actionView: ActionView?
private let feelView = FeelView(emotionType: "", descriptionText: "")
private let AIAnswerButton = ByeBooButton(
titleText: "보리의 답장 보러가기",
type: .enabled
)


private(set) var type: QuestType

Expand Down Expand Up @@ -62,7 +67,8 @@ final class ArchiveQuestView: BaseView {
scrollView.addSubview(contentView)
contentView.addSubviews(
headerView,
feelView
feelView,
AIAnswerButton
)

switch type {
Expand All @@ -77,17 +83,17 @@ final class ArchiveQuestView: BaseView {

override func setLayout() {
scrollView.snp.makeConstraints {
$0.edges.equalToSuperview()
$0.edges.equalTo(safeAreaLayoutGuide)
}

contentView.snp.makeConstraints {
$0.edges.equalToSuperview()
$0.width.equalToSuperview()
$0.bottom.equalTo(feelView.snp.bottom).offset(24.adjustedH)
$0.height.greaterThanOrEqualTo(scrollView.frameLayoutGuide)
}

headerView.snp.makeConstraints {
$0.top.equalTo(16.adjustedH)
$0.top.equalToSuperview().offset(16.adjustedH)
$0.horizontalEdges.equalToSuperview()
}

Expand All @@ -112,6 +118,12 @@ final class ArchiveQuestView: BaseView {
$0.horizontalEdges.equalToSuperview()
}
}

AIAnswerButton.snp.makeConstraints {
$0.top.greaterThanOrEqualTo(feelView.snp.bottom).offset(44.adjustedH)
$0.horizontalEdges.equalToSuperview().inset(24.adjustedW)
$0.bottom.equalTo(contentView.snp.bottom).inset(36.adjustedH)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//
// AIAnswerCardView.swift
// ByeBoo-iOS
//
// Created by 최주리 on 2/18/26.
//

import UIKit

final class AIAnswerCardView: BaseView {

private let cardImageView = UIImageView()
private let scrollView = UIScrollView()
private let contentView = UIView()
private let contentLabel = UILabel()
private let boriLabel = UILabel()

override func setStyle() {
backgroundColor = .grayscale900

cardImageView.do {
$0.image = .boriLetter
$0.isUserInteractionEnabled = true
}
scrollView.do {
$0.showsVerticalScrollIndicator = false
}
contentLabel.do {
$0.applyByeBooFont(
style: .body3R16,
text: "",
color: .primary50
)
$0.numberOfLines = 0
}
boriLabel.do {
$0.applyByeBooFont(
style: .boriVoiceR18,
text: "보리의 답장",
color: .primary50
)
}
}

override func setUI() {
addSubviews(cardImageView)
cardImageView.addSubviews(scrollView, boriLabel)
scrollView.addSubview(contentView)
contentView.addSubview(contentLabel)
}

override func setLayout() {
cardImageView.snp.makeConstraints {
$0.edges.equalToSuperview()
}
scrollView.snp.makeConstraints {
$0.top.equalToSuperview().inset(217.adjustedH)
$0.horizontalEdges.equalToSuperview().inset(24.adjustedW)
$0.bottom.equalToSuperview().inset(98.adjustedH)
}
contentView.snp.makeConstraints {
$0.edges.equalToSuperview()
$0.width.equalToSuperview()
$0.height.greaterThanOrEqualTo(scrollView.frameLayoutGuide)
}
contentLabel.snp.makeConstraints {
$0.horizontalEdges.equalToSuperview()
$0.verticalEdges.equalToSuperview()
}
boriLabel.snp.makeConstraints {
$0.top.equalTo(scrollView.snp.bottom).offset(44.adjustedH)
$0.trailing.equalToSuperview().inset(24.adjustedW)
}
}
}

extension AIAnswerCardView {
func updateText(answer: String) {
contentLabel.applyByeBooFont(
style: .boriVoiceR18,
text: answer,
color: .primary50
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
//
// AIAnswerView.swift
// ByeBoo-iOS
//
// Created by 최주리 on 2/18/26.
//

import UIKit

final class AIAnswerView: BaseView {

private let answerState: AIAnswerState

private let stackView = UIStackView()
private let imageView = UIImageView()
private let textLabel = UILabel()
private let cardView = AIAnswerCardView()

init(answerState: AIAnswerState) {
self.answerState = answerState

super.init(frame: .zero)
updateState(state: answerState)
}

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

override func setStyle() {
backgroundColor = .grayscale900

stackView.do {
$0.axis = .vertical
$0.spacing = 8.adjustedH
$0.alignment = .center
}
textLabel.do {
$0.applyByeBooFont(
style: .body3R16,
text: answerState.text,
color: .grayscale100,
textAlignment: .center
)
$0.numberOfLines = 0
}
imageView.do {
$0.image = .boriWriting
}
cardView.do {
$0.isHidden = true
}
}

override func setUI() {
addSubviews(stackView, cardView)
stackView.addArrangedSubviews(imageView, textLabel)
}

override func setLayout() {
stackView.snp.makeConstraints {
$0.horizontalEdges.equalToSuperview().inset(48.adjustedW)
$0.centerY.equalToSuperview()
}
imageView.snp.makeConstraints {
$0.size.equalTo(100)
}
cardView.snp.makeConstraints {
$0.horizontalEdges.equalToSuperview().inset(24.adjustedW)
$0.centerY.equalToSuperview()
}
}
}

extension AIAnswerView {
func updateState(state: AIAnswerState) {
textLabel.applyByeBooFont(
style: .body3R16,
text: state.text,
color: .grayscale100,
textAlignment: .center
)
imageView.image = state.image

switch state {
case .loading:
stackView.isHidden = false
cardView.isHidden = true
case .fail:
stackView.isHidden = false
cardView.isHidden = true
case .success:
stackView.isHidden = true
cardView.isHidden = false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// AIAnswerViewController.swift
// ByeBoo-iOS
//
// Created by 최주리 on 2/18/26.
//

import Combine
import UIKit

final class AIAnswerViewController: BaseViewController {

private let rootView = AIAnswerView(answerState: .success)

override func loadView() {
view = rootView
}

override func viewDidLoad() {
super.viewDidLoad()

self.navigationItem.hidesBackButton = true

ByeBooNavigationBar.makeNavigationBar(
navigationItem: self.navigationItem,
navigationController: self.navigationController,
type: .close(header: .black),
action: #selector(close)
)
}
}

extension AIAnswerViewController: Dismissible {
func close() {
tabBarController?.tabBar.isHidden = false
self.navigationController?.popToRootViewController(animated: false)
}
}

extension AIAnswerViewController {
func configure( ) { }
}
Loading