Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AI 챗봇 앱 [STEP 3] Matthew, L #49

Open
wants to merge 25 commits into
base: d_Matthew
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4316016
docs: apiKey ignore 추가
kimbs5899 Mar 27, 2024
33a4996
chore: 파일명 수정
kimbs5899 Mar 27, 2024
5f86331
remove: APIToken 삭제
kimbs5899 Mar 27, 2024
f485a63
test: APIToken Test
LeeSe0ngYe0n Apr 2, 2024
45e44f9
Merge pull request #1 from kimbs5899/Step1
kimbs5899 Apr 2, 2024
0cb1b0c
feat: RxSwift, Snapkit, Then, RxAlamofire 라이브러리 추가
kimbs5899 Apr 4, 2024
e80553b
feat: RxAlamofire를 활용하여 Network 기능 구현
kimbs5899 Apr 4, 2024
801a846
refactor: Network 생성 리팩토링
LeeSe0ngYe0n Apr 4, 2024
876e834
refactor: 메세지 파라미터 추가
LeeSe0ngYe0n Apr 4, 2024
59cca5b
refactor: 네트워크 request 리팩토링
LeeSe0ngYe0n Apr 4, 2024
bdf568d
refactor: 트리거 타입 변경
LeeSe0ngYe0n Apr 4, 2024
b9f4b88
refactor: 네트워크 리팩토링
LeeSe0ngYe0n Apr 4, 2024
a4f0abe
feat: RxAlamofire를 활용하여 Network 기능 구현
kimbs5899 Apr 5, 2024
9dc283f
docs: gitignore Pods 삭제
kimbs5899 Apr 5, 2024
a34ffb1
feat: RxAlamofire Network Error Alert대응 구현
kimbs5899 Apr 5, 2024
086b36d
feat: RxAlamofire ChatList 생성 및 저장 로직 구현
kimbs5899 Apr 5, 2024
b76022b
feat: collectionView cell 구현
LeeSe0ngYe0n Apr 9, 2024
9e6f9a4
feat: 텍스트입력필드 및 전송버튼 구현
kimbs5899 Apr 9, 2024
1c40565
feat: autolayout 적용
LeeSe0ngYe0n Apr 11, 2024
be12648
feat: 사용자 텍스트 필드 입력 구현
kimbs5899 Apr 11, 2024
d256224
feat: MessageView 구현
kimbs5899 Apr 12, 2024
a21ecce
feat: ChatBubbleView 구현
kimbs5899 Apr 12, 2024
3697649
feat: CollectionView CustomCell 구현
kimbs5899 Apr 12, 2024
291b6e7
feat: CollectionView에 CustomCell 추가
kimbs5899 Apr 12, 2024
b8bbda0
refactor: View 리팩토링
kimbs5899 Apr 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 1 addition & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
# Created by https://www.toptal.com/developers/gitignore/api/xcode,swift,cocoapods
# Edit at https://www.toptal.com/developers/gitignore?templates=xcode,swift,cocoapods

### CocoaPods ###
## CocoaPods GitIgnore Template

# CocoaPods - Only use to conserve bandwidth / Save time on Pushing
# - Also handy if you have a large number of dependant pods
# - AS PER https://guides.cocoapods.org/using/using-cocoapods.html NEVER IGNORE THE LOCK FILE
Pods/

### Swift ###
# Xcode
#
Expand Down Expand Up @@ -100,6 +92,7 @@ iOSInjectionProject/

### DS_Store ###
.DS_Store
APIToken.plist

### APIToken ###
APIToken.plist
Expand Down
182 changes: 141 additions & 41 deletions ChatBot/ChatBot.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions ChatBot/ChatBot.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
6 changes: 2 additions & 4 deletions ChatBot/ChatBot/App/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?

let chatManger = ChatManager()
let chatViewModel = ChatBotViewModel(chatRepository: ChatRepository(provider: NetworkProvider()))

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard
Expand All @@ -19,8 +18,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
return
}
window = UIWindow(windowScene: windowScene)

let mainViewController = ChatBotViewController(chatManager: chatManger)
let mainViewController = ChatBotViewController(chatBotViewModel: chatViewModel)
window?.rootViewController = mainViewController
window?.makeKeyAndVisible()
}
Expand Down
54 changes: 0 additions & 54 deletions ChatBot/ChatBot/Controller/ChatBotViewController.swift

This file was deleted.

16 changes: 16 additions & 0 deletions ChatBot/ChatBot/Extension/UITextField+Extension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// UITextField+Extension.swift
// ChatBot
//
// Created by Matthew on 4/12/24.
//

import UIKit

extension UITextField {
func addLeftPadding() {
let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: 10, height: self.frame.height))
self.leftView = paddingView
self.leftViewMode = ViewMode.always
}
}
14 changes: 0 additions & 14 deletions ChatBot/ChatBot/Extension/URLSession+Extension.swift

This file was deleted.

26 changes: 0 additions & 26 deletions ChatBot/ChatBot/Model/ChatManager.swift

This file was deleted.

49 changes: 0 additions & 49 deletions ChatBot/ChatBot/Model/ChatRepository.swift

This file was deleted.

51 changes: 0 additions & 51 deletions ChatBot/ChatBot/Network/APIService.swift

This file was deleted.

22 changes: 22 additions & 0 deletions ChatBot/ChatBot/Network/ChatBotNetwork.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// ChatBotNetwork.swift
// ChatBot
//
// Created by Matthew on 4/4/24.
//

import Foundation
import RxSwift

final class ChatBotNetwork {
private let network: Network<ResponseChatDTO>

init(network: Network<ResponseChatDTO>) {
self.network = network
}

func requestChatBotMessage(message: Message) -> Observable<ResponseChatDTO> {
return network.fetchData(message: message)
}
}

29 changes: 29 additions & 0 deletions ChatBot/ChatBot/Network/Network.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// Network.swift
// ChatBot
//
// Created by Matthew on 4/4/24.
//

import RxSwift
import RxAlamofire
import Foundation

class Network<T: Decodable> {
private let queue: ConcurrentDispatchQueueScheduler

init() {
self.queue = ConcurrentDispatchQueueScheduler(qos: .background)
}

func fetchData(message: Message) -> Observable<T> {
let urlRequest = NetworkURL.makeURLRequest(type: .chatGPT, chat: RequestChatDTO(messages: [message]), httpMethod: .post)!
let result = RxAlamofire.requestData(urlRequest)
.observe(on: queue)
.debug()
.map { (response, data) -> T in
return try JSONDecoder().decode(T.self, from: data)
}
return result
}
}
43 changes: 0 additions & 43 deletions ChatBot/ChatBot/Network/NetworkError.swift

This file was deleted.

15 changes: 15 additions & 0 deletions ChatBot/ChatBot/Network/NetworkProvider.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// NetworkProvider.swift
// ChatBot
//
// Created by Matthew on 4/4/24.
//

import Foundation

final class NetworkProvider {
func makeChatNetwork() -> ChatBotNetwork {
let network = Network<ResponseChatDTO>()
return ChatBotNetwork(network: network)
}
}
Loading