Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
bb554f0
feat(*): DetailChatViewUserInputSectionStackView구현
Apr 11, 2024
9c4788d
feat(*): Cell구현을 위한 Cell요소 StackView 구현
happykwon Apr 11, 2024
d128b8e
feat(*): DetailMessage화면CollectionViewCell Custom구현
happykwon Apr 11, 2024
661714b
feat(*): 채팅화면 messageCollectionView 구현
happykwon Apr 11, 2024
f53ddf8
chore(*): CollectionViewCell 파일 네이밍 수정
happykwon Apr 11, 2024
ba9ca40
refactor(*): ViewController 이전 코드 삭제
happykwon Apr 11, 2024
5f011f5
feat(*): DetailChatViewController-UserInputSection 구현
happykwon Apr 11, 2024
fef9140
feat(*): 키보드에 따른 동적 View움직임 구현
happykwon Apr 11, 2024
a702ed4
refactor(*): DetailChatViewUserInputSectionStackView autolayout수정
happykwon Apr 11, 2024
d7c7e24
feat(*): ChatMessageCollectionView Autolayout 적용
happykwon Apr 11, 2024
575bd5f
feat(*): DetailMessageCollectionViewCell에 동적cell높이 로직구현
happykwon Apr 11, 2024
f1b0e64
chatView CollectionViewDelegate,DataSource 구현
happykwon Apr 12, 2024
aa16957
MessageRepository Delegate패턴 구현
happykwon Apr 12, 2024
992aeca
refactor(*): Delegate 패턴 수정
happykwon Apr 12, 2024
07c9df0
feat(*): UICollectionViewDelegateFlowLayout 프로토콜 구현
happykwon Apr 12, 2024
0d168c2
feat(*): Button클릭 시 API통신 구현
happykwon Apr 12, 2024
bafe2b6
feat(*): doneButton클릭 시 기존내용 삭제 구현
happykwon Apr 12, 2024
9ca2aa5
dataReload를 위한 bindViewModel 구현
happykwon Apr 12, 2024
a0b5d6b
refactor(*): cell autolayout재설정 및 불필요한 코드 삭제
happykwon Apr 12, 2024
150001d
MessageCellStackView backgroundColor 삭제
happykwon Apr 12, 2024
36201a5
refactor(*): CollectionViewCell 동적 높이 할당을 위해 UICollectionViewDelegate…
happykwon Apr 12, 2024
c209916
refactor(*): autolayout충돌 수정
happykwon Apr 12, 2024
73e0108
feat(*): API통신 Indicator구현
happykwon Apr 12, 2024
985e2f0
indicator구현
happykwon Apr 14, 2024
c9b4b05
CollectionViewCell크기 동적 조절 로직 구현 및 viewModel코드 수정
happykwon Apr 14, 2024
700f95c
refactor(*): UICollectionViewDelegateFlowLayout width 조정
happykwon Apr 15, 2024
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
32 changes: 28 additions & 4 deletions ChatBot/ChatBot.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@
70E87ED22BBAA6F800E27E43 /* RequestDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70E87ED12BBAA6F800E27E43 /* RequestDTO.swift */; };
B4B3E2BD2B42D1BB00818B3C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4B3E2BC2B42D1BB00818B3C /* AppDelegate.swift */; };
B4B3E2BF2B42D1BB00818B3C /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4B3E2BE2B42D1BB00818B3C /* SceneDelegate.swift */; };
B4B3E2C12B42D1BB00818B3C /* ChatbotMainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4B3E2C02B42D1BB00818B3C /* ChatbotMainViewController.swift */; };
B4B3E2C12B42D1BB00818B3C /* DetailChatViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4B3E2C02B42D1BB00818B3C /* DetailChatViewController.swift */; };
B4B3E2C62B42D1BC00818B3C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B4B3E2C52B42D1BC00818B3C /* Assets.xcassets */; };
B4B3E2C92B42D1BC00818B3C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B4B3E2C72B42D1BC00818B3C /* LaunchScreen.storyboard */; };
E67855E82BC7B35500488352 /* DetailChatViewUserInputSectionStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E67855E72BC7B35500488352 /* DetailChatViewUserInputSectionStackView.swift */; };
E67855EA2BC7B84400488352 /* MessageCellStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E67855E92BC7B84400488352 /* MessageCellStackView.swift */; };
E67855EC2BC7B9AB00488352 /* DetailMessageCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E67855EB2BC7B9AB00488352 /* DetailMessageCollectionViewCell.swift */; };
E67855EE2BC7BA9700488352 /* ChatMessageCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E67855ED2BC7BA9700488352 /* ChatMessageCollectionView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -38,10 +42,14 @@
B4B3E2B92B42D1BB00818B3C /* ChatBot.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ChatBot.app; sourceTree = BUILT_PRODUCTS_DIR; };
B4B3E2BC2B42D1BB00818B3C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
B4B3E2BE2B42D1BB00818B3C /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
B4B3E2C02B42D1BB00818B3C /* ChatbotMainViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatbotMainViewController.swift; sourceTree = "<group>"; };
B4B3E2C02B42D1BB00818B3C /* DetailChatViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailChatViewController.swift; sourceTree = "<group>"; };
B4B3E2C52B42D1BC00818B3C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
B4B3E2C82B42D1BC00818B3C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
B4B3E2CA2B42D1BC00818B3C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
E67855E72BC7B35500488352 /* DetailChatViewUserInputSectionStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailChatViewUserInputSectionStackView.swift; sourceTree = "<group>"; };
E67855E92BC7B84400488352 /* MessageCellStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageCellStackView.swift; sourceTree = "<group>"; };
E67855EB2BC7B9AB00488352 /* DetailMessageCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailMessageCollectionViewCell.swift; sourceTree = "<group>"; };
E67855ED2BC7BA9700488352 /* ChatMessageCollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatMessageCollectionView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -136,12 +144,24 @@
70E483A32BB5AB3900931F01 /* Model */,
70E483A22BB5AB3700931F01 /* Repository */,
70E483A12BB5AB3400931F01 /* Network */,
B4B3E2C02B42D1BB00818B3C /* ChatbotMainViewController.swift */,
E67855E62BC7B31700488352 /* View */,
B4B3E2CA2B42D1BC00818B3C /* Info.plist */,
);
path = ChatBot;
sourceTree = "<group>";
};
E67855E62BC7B31700488352 /* View */ = {
isa = PBXGroup;
children = (
B4B3E2C02B42D1BB00818B3C /* DetailChatViewController.swift */,
E67855E72BC7B35500488352 /* DetailChatViewUserInputSectionStackView.swift */,
E67855E92BC7B84400488352 /* MessageCellStackView.swift */,
E67855EB2BC7B9AB00488352 /* DetailMessageCollectionViewCell.swift */,
E67855ED2BC7BA9700488352 /* ChatMessageCollectionView.swift */,
);
path = View;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -212,19 +232,23 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B4B3E2C12B42D1BB00818B3C /* ChatbotMainViewController.swift in Sources */,
E67855EE2BC7BA9700488352 /* ChatMessageCollectionView.swift in Sources */,
B4B3E2C12B42D1BB00818B3C /* DetailChatViewController.swift in Sources */,
70A610432BBE6061009B08ED /* NetworkErrorEnum.swift in Sources */,
70E87ED22BBAA6F800E27E43 /* RequestDTO.swift in Sources */,
70E4839C2BB5A88900931F01 /* RequestMessageModel.swift in Sources */,
B4B3E2BD2B42D1BB00818B3C /* AppDelegate.swift in Sources */,
70E483A72BB5ABBA00931F01 /* APIKeyManager.swift in Sources */,
70A610412BBE6034009B08ED /* URLRequestBuilder.swift in Sources */,
70E483A02BB5A8E700931F01 /* MessageRepository.swift in Sources */,
E67855EA2BC7B84400488352 /* MessageCellStackView.swift in Sources */,
70E4839A2BB5A88000931F01 /* OpenAICheatResponseDTO.swift in Sources */,
70E483AB2BB5AC7900931F01 /* OpenAIService.swift in Sources */,
70E483A92BB5ABC400931F01 /* OpenAIEndPoint.swift in Sources */,
E67855E82BC7B35500488352 /* DetailChatViewUserInputSectionStackView.swift in Sources */,
70E483AE2BB5AEB100931F01 /* ChatViewModel.swift in Sources */,
B4B3E2BF2B42D1BB00818B3C /* SceneDelegate.swift in Sources */,
E67855EC2BC7B9AB00488352 /* DetailMessageCollectionViewCell.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
78 changes: 78 additions & 0 deletions ChatBot/ChatBot.xcodeproj/xcshareddata/xcschemes/ChatBot.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B4B3E2B82B42D1BB00818B3C"
BuildableName = "ChatBot.app"
BlueprintName = "ChatBot"
ReferencedContainer = "container:ChatBot.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B4B3E2B82B42D1BB00818B3C"
BuildableName = "ChatBot.app"
BlueprintName = "ChatBot"
ReferencedContainer = "container:ChatBot.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B4B3E2B82B42D1BB00818B3C"
BuildableName = "ChatBot.app"
BlueprintName = "ChatBot"
ReferencedContainer = "container:ChatBot.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
2 changes: 1 addition & 1 deletion ChatBot/ChatBot/App/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
let repo = MessageRepository()
let apiService = OpenAIService()
let viewModel = ChatViewModel(repository: repo, apiService: apiService)
let rootViewController = ChatbotMainViewController(viewModel: viewModel, repo: repo, apiService: apiService)
let rootViewController = DetailChatViewController(viewModel: viewModel, repo: repo, apiService: apiService)

self.window?.rootViewController = rootViewController
self.window?.makeKeyAndVisible()
Expand Down
117 changes: 0 additions & 117 deletions ChatBot/ChatBot/ChatbotMainViewController.swift

This file was deleted.

7 changes: 7 additions & 0 deletions ChatBot/ChatBot/Repository/MessageRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@

import Foundation

protocol MessageRepositoryDeletage: AnyObject {
func messageDidUpdate()
}

class MessageRepository {
private var messagesStorage: [RequestMessageModel] = []
private let repoQueue = DispatchQueue(label: "repoQueue")
weak var delegate: MessageRepositoryDeletage?

func addMessage(_ message: RequestMessageModel) {
repoQueue.async {
self.messagesStorage.append(message)
self.delegate?.messageDidUpdate()
}
}

Expand All @@ -26,6 +32,7 @@ class MessageRepository {
func clearStorage() {
repoQueue.sync {
self.messagesStorage.removeAll()
self.delegate?.messageDidUpdate()
}
}
}
33 changes: 33 additions & 0 deletions ChatBot/ChatBot/View/ChatMessageCollectionView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// ChatMessageCollectionView.swift
// ChatBot
//
// Created by 권태호 on 4/11/24.
//

import UIKit

class ChatMessageCollectionView: UICollectionView {
init() {
let layout = UICollectionViewFlowLayout()
layout.scrollDirection = .vertical
super.init(frame: .zero, collectionViewLayout: layout)

self.register(DetailMessageCollectionViewCell.self, forCellWithReuseIdentifier: DetailMessageCollectionViewCell.identifier)
self.translatesAutoresizingMaskIntoConstraints = false
self.backgroundColor = .systemBackground

layout.estimatedItemSize = UICollectionViewFlowLayout.automaticSize
layout.minimumLineSpacing = 5
}

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

override func layoutSubviews() {
super.layoutSubviews()
guard let flowLayout = collectionViewLayout as? UICollectionViewFlowLayout else { return }
flowLayout.sectionInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10) // 상, 하, 좌, 우 여백 설정
}
}
Loading