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

[Feat] 채팅 구현 #77

Merged
merged 24 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
49c0dca
[Feat] 채팅 탭 채팅 리스트 UI구현
Hansangjin98 Aug 31, 2022
7cbaada
[Rename] 채팅 탭 관련 파일/클래스명 변경
Hansangjin98 Aug 31, 2022
14d90d1
[Add] SocketIO 패키지 추가
Hansangjin98 Aug 31, 2022
58d3046
[Feat] SocketIOManger 구현
Hansangjin98 Aug 31, 2022
be53f8d
[Feat] 채팅 탭 채팅 리스트 뷰모델 구현, 셀 UI수정
Hansangjin98 Aug 31, 2022
9db0181
[Feat] 채팅방 뷰 관련 파일들 생성
Hansangjin98 Aug 31, 2022
b25562d
[Resolved] Merge Conflict
Hansangjin98 Aug 31, 2022
1f88c1a
[Add] 채팅 송신 버튼 이미지 에셋 추가
Hansangjin98 Aug 31, 2022
6162f4b
[Feat] 채팅방 뷰 UI구현 및 네비 연동
Hansangjin98 Aug 31, 2022
8c01e35
[Feat] 채팅방 네트워킹 서비스 구현, 네이밍 일부 수정
Hansangjin98 Sep 1, 2022
8db2ec8
[Feat] 채팅 뷰 서비스 구현 및 테이블 뷰 셀 UI 구현
Hansangjin98 Sep 2, 2022
21bee2f
[Feat] 커스텀 라벨 네이밍 변경 및 채팅방 라벨에 적용
Hansangjin98 Sep 2, 2022
d380bb2
[Feat] 채팅방 리스트 뷰 레이아웃 수정
Hansangjin98 Sep 2, 2022
0bbe771
[Feat] 채팅방 테이블 뷰 레이아웃 수정
Hansangjin98 Sep 2, 2022
a609c6c
[Feat] 소켓통신 채팅방 입장 및 채팅 보내기 구현
Hansangjin98 Sep 2, 2022
dbd177d
[Feat] 소켓통신 채팅 보내기 구현
Hansangjin98 Sep 2, 2022
03d1014
[Resolved] Pull Merge Conflict
Hansangjin98 Sep 2, 2022
6a55026
[Feat] 채팅방 테이블뷰 셀 재사용 이슈 해결, 채팅입력 textView로 변경, 화면 조정 로직 변경
Hansangjin98 Sep 2, 2022
cfa0fa4
[Feat] 채팅방 테이블뷰 스크롤 이동 이슈 해결
Hansangjin98 Sep 2, 2022
6cd85a7
[Feat] 채팅방 메세지 송수진 구현
Hansangjin98 Sep 2, 2022
c4a3ab9
[Feat] 채팅방 입장 전 채팅 수신 기능 구현
Hansangjin98 Sep 3, 2022
7c20a53
[Feat] 채팅 말풍선 짤림 및 UI관련 이슈 수정
Hansangjin98 Sep 3, 2022
472d29a
[Feat] 테이블뷰 셀 Extension으로 dateParser 기능 구현
Hansangjin98 Sep 3, 2022
1bcff95
Merge branch 'develop' into feature/63
Hansangjin98 Oct 7, 2022
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
130 changes: 119 additions & 11 deletions PlayTogether/PlayTogether.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@
"revision" : "07c5d1f6044701d97e94dc11157259e8811977be"
}
},
{
"identity" : "socket.io-client-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/socketio/socket.io-client-swift",
"state" : {
"branch" : "master",
"revision" : "a1ed825835a2d8c2555938e96557ccc05e4bebf3"
}
},
{
"identity" : "starscream",
"kind" : "remoteSourceControl",
"location" : "https://github.com/daltoniam/Starscream",
"state" : {
"revision" : "df8d82047f6654d8e4b655d1b1525c64e1059d21",
"version" : "4.0.4"
}
},
{
"identity" : "then",
"kind" : "remoteSourceControl",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1340"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4096A295287F5F3F00F1E27C"
BuildableName = "PlayTogether.app"
BlueprintName = "PlayTogether"
ReferencedContainer = "container:PlayTogether.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</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 = "4096A295287F5F3F00F1E27C"
BuildableName = "PlayTogether.app"
BlueprintName = "PlayTogether"
ReferencedContainer = "container:PlayTogether.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4096A295287F5F3F00F1E27C"
BuildableName = "PlayTogether.app"
BlueprintName = "PlayTogether"
ReferencedContainer = "container:PlayTogether.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
4 changes: 4 additions & 0 deletions PlayTogether/PlayTogether/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}

func applicationWillTerminate(_ application: UIApplication) {
SocketIOManager.shared.closeConnection()
}


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class TabBarController: UITabBarController {
image: .ptImage(.thunInactive).withRenderingMode(.alwaysOriginal),
selectedImage: .ptImage(.thunActive).withRenderingMode(.alwaysOriginal))
}
private let chatViewController = ChatViewController().then {
private let chatViewController = ChattingListViewController().then {
$0.tabBarItem = UITabBarItem(
title: "채팅",
image: .ptImage(.chatInactive).withRenderingMode(.alwaysOriginal),
Expand Down
3 changes: 3 additions & 0 deletions PlayTogether/PlayTogether/Extensions/UIImage+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,8 @@ enum ImageCase: String {
case showIconBlack = "showIconBlack"
case introduceLabelIcon = "introduceLabelIcon"
case clearIcon = "clearIcon"

case sendInActiveIcon = "sendInActiveIcon"
case sendActiveIcon = "sendActiveIcon"
case optionIcon = "optionIcon"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// UITableView+Extension.swift
// PlayTogether
//
// Created by 한상진 on 2022/09/04.
//

import UIKit

extension UITableViewCell {
func dateParser(_ dateString: String) -> String {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
guard let convertDate = dateFormatter.date(from: dateString) else { return String.init() }

dateFormatter.dateFormat = "yyyy.MM.dd. HH:mm"
return dateFormatter.string(from: convertDate)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "btn_send_active.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "btn_send_inactive.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 0 additions & 12 deletions PlayTogether/PlayTogether/Sources/Chat/ChatViewController.swift

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
//
// ChattingRoomTableViewCell.swift
// PlayTogether
//
// Created by 한상진 on 2022/08/31.
//

import UIKit

final class ChattingListTableViewCell: UITableViewCell {
private let profileImageView = UIImageView().then {
$0.image = .ptImage(.profileIcon)
}

private let nameLabel = UILabel().then {
$0.textColor = .ptBlack01
$0.font = .pretendardBold(size: 16)
}

private let pointView = UIView().then {
$0.backgroundColor = .ptGreen
$0.layer.cornerRadius = 3
}

private let lastChatLabel = UILabel().then {
$0.textColor = .ptBlack01
$0.font = .pretendardRegular(size: 14)
$0.lineBreakMode = .byTruncatingTail
}

private let dateLabel = UILabel().then {
$0.textColor = .ptGray01
$0.font = .pretendardRegular(size: 14)
}

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}

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

func setupCell(
profileImage: UIImage?,
name: String,
lastChat: String,
date: String,
send: Bool,
read: Bool
) {
if let profileImage = profileImage {
profileImageView.image = profileImage
}

nameLabel.text = name
lastChatLabel.text = lastChat
dateLabel.text = dateParser(date)

if send || read {
nameLabel.textColor = .ptGray01
lastChatLabel.textColor = .ptGray01
pointView.isHidden = true
}
}
}

private extension ChattingListTableViewCell {
func setupUI() {
backgroundColor = .white
selectionStyle = .none
separatorInset = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20)

addSubview(profileImageView)
addSubview(nameLabel)
addSubview(pointView)
addSubview(lastChatLabel)
addSubview(dateLabel)

profileImageView.snp.makeConstraints {
$0.centerY.equalToSuperview()
$0.leading.equalToSuperview().offset(20)
$0.size.equalTo(UIScreen.main.bounds.width * 0.106)
}

nameLabel.snp.makeConstraints {
$0.top.equalTo(profileImageView).offset(1)
$0.leading.equalTo(profileImageView.snp.trailing).offset(12)
}

pointView.snp.makeConstraints {
$0.leading.equalTo(nameLabel.snp.trailing).offset(8)
$0.centerY.equalTo(nameLabel)
$0.size.equalTo(6)
}

lastChatLabel.snp.makeConstraints {
$0.leading.equalTo(nameLabel)
$0.trailing.equalToSuperview().inset(20)
$0.bottom.equalTo(profileImageView).offset(1)
}

dateLabel.snp.makeConstraints {
$0.top.equalTo(nameLabel)
$0.trailing.equalToSuperview().inset(20)
}
}
}
Loading