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
3 changes: 3 additions & 0 deletions ByeBoo-iOS/ByeBoo-iOS/Core/ByeBooError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ enum ByeBooError: Error, LocalizedError, Equatable {
case configError
case fileNotFound
case nicknameViolation
case questViolation

var errorDescription: String? {
switch self {
Expand Down Expand Up @@ -68,6 +69,8 @@ enum ByeBooError: Error, LocalizedError, Equatable {
return "파일을 찾을 수 없음"
case .nicknameViolation:
return "비속어나 부적절한 단어가 포함된 닉네임"
case .questViolation:
return "비속어나 부적절한 단어가 포함된 답변"
}
}
}
4 changes: 4 additions & 0 deletions ByeBoo-iOS/ByeBoo-iOS/Data/DataDependencyAssembler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ struct DataDependencyAssembler: DependencyAssembler {
DIContainer.shared.register(type: ForbiddenWordInterface.self) { _ in
return DefaultForbiddenWordRepository()
}

DIContainer.shared.register(type: CommonQuestInterface.self) { _ in
return DefaultCommonQuestRepository(network: networkService)
}
}
}

Expand Down
12 changes: 12 additions & 0 deletions ByeBoo-iOS/ByeBoo-iOS/Data/Model/SaveCommonQuestRequestDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// SaveCommonQuest.swift
// ByeBoo-iOS
//
// Created by 이나연 on 3/1/26.
//

import Foundation

struct SaveCommonQuestRequestDTO: Encodable {
let answer: String
}
61 changes: 61 additions & 0 deletions ByeBoo-iOS/ByeBoo-iOS/Data/Network/EndPoint/CommonQuestAPI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// CommonQuestAPI.swift
// ByeBoo-iOS
//
// Created by 이나연 on 3/1/26.
//

import Foundation

import Alamofire

enum CommonQuestAPI {
case postCommonQuest(questID: Int, dto: SaveCommonQuestRequestDTO)
}

extension CommonQuestAPI: EndPoint {

var basePath: String {
return "/api/v1/common-quests"
}

var path: String {
switch self {
case .postCommonQuest(let questID, _):
return "/\(questID)"
}
}

var method: HTTPMethod {
switch self {
case .postCommonQuest:
return .post
}
}

var headers: HeaderType {
switch self {
case .postCommonQuest:
let keychainService = DefaultKeychainService()
return .withAuth(acessToken: keychainService.load(key: .accessToken))
}
}

var parameterEncoding: any ParameterEncoding {
switch self {
case .postCommonQuest:
return JSONEncoding.default
}
}

var queryParameters: [String : String]? {
nil
}

var bodyParameters: Parameters? {
switch self {
case .postCommonQuest(_, let dto):
return try? dto.toDictionary()
}
}
}
26 changes: 26 additions & 0 deletions ByeBoo-iOS/ByeBoo-iOS/Data/Repository/CommonQuestRepository.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// CommonQuestRepository.swift
// ByeBoo-iOS
//
// Created by 이나연 on 3/1/26.
//

import Foundation

struct DefaultCommonQuestRepository: CommonQuestInterface {
private let network: NetworkService

init(
network: NetworkService
) {
self.network = network
}

func saveCommonQuest(questID: Int, answer: String) async throws {
let saveCommonQuestRequestDTO: SaveCommonQuestRequestDTO = .init(answer: answer)

let _ = try await network.request(
CommonQuestAPI.postCommonQuest(questID: questID, dto: saveCommonQuestRequestDTO)
)
}
}
16 changes: 10 additions & 6 deletions ByeBoo-iOS/ByeBoo-iOS/Domain/DomainDependencyAssembler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ struct DomainDependencyAssembler: DependencyAssembler {
guard let userRepository = DIContainer.shared.resolve(type: UsersInterface.self),
let questRepository = DIContainer.shared.resolve(type: QuestsInterface.self),
let authRepository = DIContainer.shared.resolve(type: AuthInterface.self),
let forbiddenWordRepository = DIContainer.shared.resolve(type: ForbiddenWordInterface.self)
else {
ByeBooLogger.error(ByeBooError.DIFailedError)
return
}
let forbiddenWordRepository = DIContainer.shared.resolve(type: ForbiddenWordInterface.self),
let commonQuestRepository = DIContainer.shared.resolve(type: CommonQuestInterface.self) else {
ByeBooLogger.error(ByeBooError.DIFailedError)
return
}

DIContainer.shared.register(type: FetchUserJourneyUseCase.self) { _ in
return DefaultFetchUserJourneyUseCase(repository: userRepository)
Expand Down Expand Up @@ -141,7 +141,7 @@ struct DomainDependencyAssembler: DependencyAssembler {
DIContainer.shared.register(type: FetchCommonQuestByDateUseCase.self) { _ in
return DefaultFetchCommonQuestByDateUseCase(repository: questRepository)
}

DIContainer.shared.register(type: AutoLoginUseCase.self) { _ in
return DefaultAutoLoginUseCase(repository: authRepository)
}
Expand Down Expand Up @@ -169,5 +169,9 @@ struct DomainDependencyAssembler: DependencyAssembler {
DIContainer.shared.register(type: IsForbiddenWordUseCase.self) { _ in
return DefaultIsForbiddenWordUseCase(repository: forbiddenWordRepository)
}

DIContainer.shared.register(type: SaveCommonQuestUseCase.self) { _ in
return DefaultSaveCommonQuestUseCase(repository: commonQuestRepository)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Foundation

struct CommonQuestAnswersEntity {
let question: String
let questID: Int
let answerCount: Int
let isAnswered: Bool
let answers: [CommonQuestAnswerEntity]
Expand All @@ -26,6 +27,7 @@ extension CommonQuestAnswersEntity {
static func stub() -> Self {
.init(
question: "연애에서 반복된 문제 패턴 3가지를 생각해보아요",
questID: 1,
answerCount: 5,
isAnswered: false,
answers: [.stub(), .stub(), .stub(), .stub(), .stub()]
Expand Down
12 changes: 12 additions & 0 deletions ByeBoo-iOS/ByeBoo-iOS/Domain/Interface/CommonQuestInterface.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// CommonQuestInterface.swift
// ByeBoo-iOS
//
// Created by 이나연 on 3/1/26.
//

import Foundation

protocol CommonQuestInterface {
func saveCommonQuest(questID: Int, answer: String) async throws
}
24 changes: 24 additions & 0 deletions ByeBoo-iOS/ByeBoo-iOS/Domain/UseCase/SaveCommonQuestUseCase.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// SaveCommonQuestUseCase.swift
// ByeBoo-iOS
//
// Created by 이나연 on 3/3/26.
//

import Foundation

protocol SaveCommonQuestUseCase {
func execute(questID: Int, answer: String) async throws
}

struct DefaultSaveCommonQuestUseCase: SaveCommonQuestUseCase {
private let repository: CommonQuestInterface

init(repository: CommonQuestInterface) {
self.repository = repository
}

func execute(questID: Int, answer: String) async throws {
try await repository.saveCommonQuest(questID: questID, answer: answer)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ final class EmotionBottomSheetViewController: BaseViewController {
}

self.delegate?.saveEmotionState(emotionState: selectedEmotion)
self.delegate?.saveQuest()
self.delegate?.saveQuest(isEdit: false, isCommonQuest: false)
rootView.confirmButton.isEnabled = false

let property = QuestEvents.QuestWriteFinishWithEmotionProperty(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ struct ModalBuilder {
}

func dismiss() {
modalViewController.dismiss(animated: false)
modalViewController.dismiss(animated: true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ final class TopTabBar: UIStackView {
}

extension TopTabBar {

func select(index: Int) {
guard itemViews.indices.contains(index) else { return }
updateTabBar(tag: index)
}

@objc
private func barDidTap(_ sender: UITapGestureRecognizer) {
guard let tag = sender.view?.tag else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ final class QuestCheckCoordinator: QuestCheckCoordinating {

private func moveToWriteQuestion(questID: Int, questNumber: Int, questType: QuestType) {
let questionQuestViewController = ViewControllerFactory.shared.makeWriteQuestionTypeQuestViewController()
questionQuestViewController.configure(questID, questNumber, questType)
questionQuestViewController.configure(questID, questNumber, questType, nil)
rootViewController?.tabBarController?.tabBar.isHidden = true
rootViewController?.navigationController?.pushViewController(questionQuestViewController, animated: false)
}

private func moveToWriteActivity(questID: Int, questNumber: Int, questType: QuestType) {
let activationQuestViewController = ViewControllerFactory.shared.makeWriteActiveTypeQuestViewController()
activationQuestViewController.configure(questID, questNumber, questType)
activationQuestViewController.configure(questID, questNumber, questType, nil)
rootViewController?.tabBarController?.tabBar.isHidden = true
rootViewController?.navigationController?.pushViewController(activationQuestViewController, animated: false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ final class ArchiveQuestHeaderView: BaseView {
color: .grayscale100,
numberOfLines: 0
)
$0.lineBreakMode = .byWordWrapping
$0.lineBreakStrategy = .hangulWordPriority
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ final class ArchiveQuestView: BaseView {
}

contentView.snp.makeConstraints {
$0.edges.equalToSuperview()
$0.width.equalToSuperview()
$0.edges.equalTo(scrollView.contentLayoutGuide)
$0.width.equalTo(scrollView.frameLayoutGuide)
$0.height.greaterThanOrEqualTo(scrollView.frameLayoutGuide)
}

Expand All @@ -108,15 +108,13 @@ final class ArchiveQuestView: BaseView {

textBoxView.snp.makeConstraints {
if let photoBoxView {
if !descriptionText.isEmpty {
$0.top.equalTo(photoBoxView.snp.bottom).offset(20.adjustedH)
}
$0.top.equalTo(photoBoxView.snp.bottom).offset(20.adjustedH)
} else {
$0.top.equalTo(headerView.snp.bottom).offset(20.adjustedH)
}
$0.horizontalEdges.equalToSuperview().inset(24.adjustedW)
}

feelView.snp.makeConstraints {
$0.top.equalTo(textBoxView.snp.bottom).offset(20.adjustedH)
$0.horizontalEdges.equalToSuperview()
Expand Down Expand Up @@ -150,9 +148,9 @@ extension ArchiveQuestView {
case .activation:
guard let photoBoxView else { return }

if let url = URL(string: entity.imageUrl!) {
photoBoxView.kf.setImage(with: url)
}
guard let imageUrl = entity.imageUrl,
let url = URL(string: imageUrl) else { return }
photoBoxView.kf.setImage(with: url)

if entity.answer.isEmpty {
textBoxView.removeFromSuperview()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ final class CommonQuestContentCell: UITableViewCell {
}

private func setUI() {
addSubviews(
contentView.addSubviews(
questionView,
guideTimeLabel,
moveWriteAnswerButton,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,14 @@ extension WriteActiveTypeQuestView: WriteQuestBaseProtocol {
questTextField.textCountLabel
}
var tipTagView: UIView {
headerView.tipTag
headerView.tipTag ?? UIView()
}
}

extension WriteActiveTypeQuestView {
func updateQuestTitle(
questScope: QuestScope? = nil,
questNumber: Int,
questStyle: String,
question: String
) {
headerView.bind(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class WriteQuestionTypeQuestView: BaseView {
private let questScope: QuestScope
private(set) var scrollView = UIScrollView()
private let contentView = UIView()
private(set) var headerView = WriteQuestTitleView(questScope: .personal, questNum: 0, title: "")
private(set) var headerView = WriteQuestTitleView(questNum: 0, title: "")
private let divider = UIView()
private(set) var questTextField = QuestTextField(type: .question)

Expand Down Expand Up @@ -100,15 +100,14 @@ extension WriteQuestionTypeQuestView: WriteQuestBaseProtocol {
questTextField.textCountLabel
}
var tipTagView: UIView {
headerView.tipTag
headerView.tipTag ?? UIView()
}
}

extension WriteQuestionTypeQuestView {
func updateQuestTitle(
questScope: QuestScope,
questNumber: Int,
questStyle: String,
question: String
) {
headerView.bind(
Expand Down
Loading
Loading