Skip to content

Commit

Permalink
Merge pull request #101 from yw22/feature/김영욱/친구목록
Browse files Browse the repository at this point in the history
[친구 목록] MVVM-C, Clean Architecture 적용했습니다.
  • Loading branch information
yw22 authored Nov 22, 2022
2 parents 9fccf42 + 1acc450 commit d07ca81
Show file tree
Hide file tree
Showing 18 changed files with 424 additions and 205 deletions.
60 changes: 34 additions & 26 deletions NearTalk/NearTalk.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@
1660D24E291DDB3A005F7B24 /* NearTalkUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1660D24D291DDB3A005F7B24 /* NearTalkUITestsLaunchTests.swift */; };
1660D266291DE092005F7B24 /* AppCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1660D265291DE092005F7B24 /* AppCoordinator.swift */; };
1660D27A291E09CE005F7B24 /* .swiftlint.yml in Resources */ = {isa = PBXBuildFile; fileRef = 1660D279291E09CE005F7B24 /* .swiftlint.yml */; };
555A6B2B29236D51001336ED /* FriendsListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 555A6B2A29236D51001336ED /* FriendsListCell.swift */; };
555A6B2D29236D61001336ED /* FriendsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 555A6B2C29236D61001336ED /* FriendsViewController.swift */; };
555A6B2F29236D73001336ED /* FriendsListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 555A6B2E29236D73001336ED /* FriendsListViewModel.swift */; };
555A6B3129236D86001336ED /* FriendsListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 555A6B3029236D86001336ED /* FriendsListModel.swift */; };
555A6B3329236D98001336ED /* FriendsListCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 555A6B3229236D98001336ED /* FriendsListCoordinator.swift */; };
5506CDDB292B4D270002F328 /* FriendListDIContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5506CDDA292B4D270002F328 /* FriendListDIContainer.swift */; };
5506CDDD292B4F810002F328 /* FetchFriendListUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5506CDDC292B4F810002F328 /* FetchFriendListUseCase.swift */; };
5506CDDF292B50D10002F328 /* Friend.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5506CDDE292B50D10002F328 /* Friend.swift */; };
555A6B2B29236D51001336ED /* FriendListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 555A6B2A29236D51001336ED /* FriendListCell.swift */; };
555A6B2D29236D61001336ED /* FriendViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 555A6B2C29236D61001336ED /* FriendViewController.swift */; };
555A6B2F29236D73001336ED /* FriendListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 555A6B2E29236D73001336ED /* FriendListViewModel.swift */; };
555A6B3329236D98001336ED /* FriendListCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 555A6B3229236D98001336ED /* FriendListCoordinator.swift */; };
555A6B3529238C13001336ED /* ChatRoomListDIContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 555A6B3429238C13001336ED /* ChatRoomListDIContainer.swift */; };
555A6B3829238C69001336ED /* ChatRoomList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 555A6B3729238C69001336ED /* ChatRoomList.swift */; };
555A6B3A29238C9B001336ED /* ChatRoomListUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 555A6B3929238C9B001336ED /* ChatRoomListUseCase.swift */; };
555A6B3A29238C9B001336ED /* FetchChatRoomUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 555A6B3929238C9B001336ED /* FetchChatRoomUseCase.swift */; };
555A6B3C29238D26001336ED /* DefaultChatRoomListRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 555A6B3B29238D26001336ED /* DefaultChatRoomListRepository.swift */; };
555A6B3E29238D65001336ED /* ChatRoomListRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 555A6B3D29238D65001336ED /* ChatRoomListRepository.swift */; };
555A6B432924B9E4001336ED /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 555A6B422924B9E4001336ED /* GoogleService-Info.plist */; };
Expand Down Expand Up @@ -223,14 +225,16 @@
3AC46AE5352F041440185296 /* Pods_NearTalkTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NearTalkTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3BDD85385ADBE469FA3E4B6B /* Pods-NearTalkTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NearTalkTests.release.xcconfig"; path = "Target Support Files/Pods-NearTalkTests/Pods-NearTalkTests.release.xcconfig"; sourceTree = "<group>"; };
4585BFB6386FB019591AD279 /* Pods_NearTalk_NearTalkUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NearTalk_NearTalkUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
555A6B2A29236D51001336ED /* FriendsListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FriendsListCell.swift; sourceTree = "<group>"; };
555A6B2C29236D61001336ED /* FriendsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FriendsViewController.swift; sourceTree = "<group>"; };
555A6B2E29236D73001336ED /* FriendsListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FriendsListViewModel.swift; sourceTree = "<group>"; };
555A6B3029236D86001336ED /* FriendsListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FriendsListModel.swift; sourceTree = "<group>"; };
555A6B3229236D98001336ED /* FriendsListCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FriendsListCoordinator.swift; sourceTree = "<group>"; };
5506CDDA292B4D270002F328 /* FriendListDIContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FriendListDIContainer.swift; sourceTree = "<group>"; };
5506CDDC292B4F810002F328 /* FetchFriendListUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FetchFriendListUseCase.swift; sourceTree = "<group>"; };
5506CDDE292B50D10002F328 /* Friend.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Friend.swift; sourceTree = "<group>"; };
555A6B2A29236D51001336ED /* FriendListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FriendListCell.swift; sourceTree = "<group>"; };
555A6B2C29236D61001336ED /* FriendViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FriendViewController.swift; sourceTree = "<group>"; };
555A6B2E29236D73001336ED /* FriendListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FriendListViewModel.swift; sourceTree = "<group>"; };
555A6B3229236D98001336ED /* FriendListCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FriendListCoordinator.swift; sourceTree = "<group>"; };
555A6B3429238C13001336ED /* ChatRoomListDIContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatRoomListDIContainer.swift; sourceTree = "<group>"; };
555A6B3729238C69001336ED /* ChatRoomList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatRoomList.swift; sourceTree = "<group>"; };
555A6B3929238C9B001336ED /* ChatRoomListUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatRoomListUseCase.swift; sourceTree = "<group>"; };
555A6B3929238C9B001336ED /* FetchChatRoomUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FetchChatRoomUseCase.swift; sourceTree = "<group>"; };
555A6B3B29238D26001336ED /* DefaultChatRoomListRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultChatRoomListRepository.swift; sourceTree = "<group>"; };
555A6B3D29238D65001336ED /* ChatRoomListRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ChatRoomListRepository.swift; path = NearTalk/Data/Repositories/ChatRoomListRepository.swift; sourceTree = SOURCE_ROOT; };
555A6B422924B9E4001336ED /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -602,7 +606,7 @@
603EDDAC2926C84E00BEE65C /* TabBar */,
7CFC7D6D2923748E00A249E7 /* ProfileDetail */,
7CFC7D672923709C00A249E7 /* CreatGroupChat */,
555A6B2629236C28001336ED /* FriendsList */,
555A6B2629236C28001336ED /* FriendList */,
1648BA922921D7240076AC35 /* MainMap */,
83E7F8C72922AB750003A2B6 /* MyProfile */,
8375F2202922B043004538AF /* Onboarding */,
Expand Down Expand Up @@ -692,6 +696,7 @@
555A6B472924BE65001336ED /* UserProfile.swift */,
6008FC9C2925DBCF0044F017 /* NCLocation.swift */,
603EDDA22926C01D00BEE65C /* UserChatModel.swift */,
5506CDDE292B50D10002F328 /* Friend.swift */,
603FD38D2929301200687ED4 /* BaseEntity.swift */,
);
path = Entities;
Expand All @@ -700,7 +705,8 @@
1660D26C291DE32F005F7B24 /* UseCases */ = {
isa = PBXGroup;
children = (
555A6B3929238C9B001336ED /* ChatRoomListUseCase.swift */,
555A6B3929238C9B001336ED /* FetchChatRoomUseCase.swift */,
5506CDDC292B4F810002F328 /* FetchFriendListUseCase.swift */,
8330622C2924A3F1000E786E /* OnboardingUseCase.swift */,
7CE806402925528F00D828FF /* CreateGroupChatUseCase.swift */,
7CE8063A2925312100D828FF /* ProfileDetailUseCase.swift */,
Expand Down Expand Up @@ -736,38 +742,37 @@
path = Repositories;
sourceTree = "<group>";
};
555A6B2629236C28001336ED /* FriendsList */ = {
555A6B2629236C28001336ED /* FriendList */ = {
isa = PBXGroup;
children = (
555A6B2929236C65001336ED /* View */,
555A6B2829236C5D001336ED /* ViewModel */,
555A6B2729236C51001336ED /* Coordinator */,
);
path = FriendsList;
path = FriendList;
sourceTree = "<group>";
};
555A6B2729236C51001336ED /* Coordinator */ = {
isa = PBXGroup;
children = (
555A6B3229236D98001336ED /* FriendsListCoordinator.swift */,
555A6B3229236D98001336ED /* FriendListCoordinator.swift */,
);
path = Coordinator;
sourceTree = "<group>";
};
555A6B2829236C5D001336ED /* ViewModel */ = {
isa = PBXGroup;
children = (
555A6B2E29236D73001336ED /* FriendsListViewModel.swift */,
555A6B3029236D86001336ED /* FriendsListModel.swift */,
555A6B2E29236D73001336ED /* FriendListViewModel.swift */,
);
path = ViewModel;
sourceTree = "<group>";
};
555A6B2929236C65001336ED /* View */ = {
isa = PBXGroup;
children = (
555A6B2A29236D51001336ED /* FriendsListCell.swift */,
555A6B2C29236D61001336ED /* FriendsViewController.swift */,
555A6B2A29236D51001336ED /* FriendListCell.swift */,
555A6B2C29236D61001336ED /* FriendViewController.swift */,
);
path = View;
sourceTree = "<group>";
Expand Down Expand Up @@ -923,6 +928,7 @@
555A6B3429238C13001336ED /* ChatRoomListDIContainer.swift */,
83D3543929252F1A00B9236A /* MyProfileDIContainer.swift */,
603EDDA42926C43500BEE65C /* RootTabBarDIContainer.swift */,
5506CDDA292B4D270002F328 /* FriendListDIContainer.swift */,
);
path = DIContainer;
sourceTree = "<group>";
Expand Down Expand Up @@ -1426,14 +1432,14 @@
1653057E291E19150026B815 /* ChatRoomListViewController.swift in Sources */,
603EDDA92926C51100BEE65C /* TabBarRepository.swift in Sources */,
555A6B3529238C13001336ED /* ChatRoomListDIContainer.swift in Sources */,
555A6B3A29238C9B001336ED /* ChatRoomListUseCase.swift in Sources */,
555A6B3A29238C9B001336ED /* FetchChatRoomUseCase.swift in Sources */,
1648BAB1292387100076AC35 /* DmChatRoomAnnotationView.swift in Sources */,
1660D22C291DDB38005F7B24 /* ViewController.swift in Sources */,
555A6B482924BE65001336ED /* UserProfile.swift in Sources */,
8349529E2925FEAE004C5B3B /* ImageRepository.swift in Sources */,
60FD706029238DD400A4C29A /* FirebaseAuthService.swift in Sources */,
834952A02925FEF0004C5B3B /* DefaultImageRepository.swift in Sources */,
555A6B3329236D98001336ED /* FriendsListCoordinator.swift in Sources */,
555A6B3329236D98001336ED /* FriendListCoordinator.swift in Sources */,
6008FC9D2925DBCF0044F017 /* NCLocation.swift in Sources */,
6073A3AE2928AE9800D51CFD /* Codable+Dictionary.swift in Sources */,
603FD39C292B4F4A00687ED4 /* LogoutUseCase.swift in Sources */,
Expand All @@ -1443,14 +1449,15 @@
83D3544C2925623600B9236A /* UIImageView+Rounded.swift in Sources */,
603EDDA72926C4B300BEE65C /* TabBarUseCase.swift in Sources */,
603EDD6329261A2000BEE65C /* FirebaseKey.swift in Sources */,
555A6B2B29236D51001336ED /* FriendsListCell.swift in Sources */,
555A6B2B29236D51001336ED /* FriendListCell.swift in Sources */,
83D35446292541B500B9236A /* MyProfileViewModel.swift in Sources */,
605715A62920AA19004A0904 /* LaunchScreenDIContainer.swift in Sources */,
1648BABC2925CDDE0076AC35 /* BottomSheetViewController.swift in Sources */,
603EDDB12926C87700BEE65C /* RootTabBarController.swift in Sources */,
603EDDA32926C01D00BEE65C /* UserChatModel.swift in Sources */,
5506CDDF292B50D10002F328 /* Friend.swift in Sources */,
60FD706A2924080A00A4C29A /* ChatMessage.swift in Sources */,
555A6B2F29236D73001336ED /* FriendsListViewModel.swift in Sources */,
555A6B2F29236D73001336ED /* FriendListViewModel.swift in Sources */,
16530578291E18560026B815 /* UIViewPreview.swift in Sources */,
833062292924A3D7000E786E /* OnboardingDIContainer.swift in Sources */,
83D3543A29252F1A00B9236A /* MyProfileDIContainer.swift in Sources */,
Expand All @@ -1472,7 +1479,6 @@
83D354412925412400B9236A /* UserProfileRepository.swift in Sources */,
7CFC7D6C2923710200A249E7 /* RangeZoneView.swift in Sources */,
8367AB642922AF6300678669 /* ProfileSettingViewController.swift in Sources */,
555A6B3129236D86001336ED /* FriendsListModel.swift in Sources */,
1660D228291DDB37005F7B24 /* AppDelegate.swift in Sources */,
1660D266291DE092005F7B24 /* AppCoordinator.swift in Sources */,
7CE806412925528F00D828FF /* CreateGroupChatUseCase.swift in Sources */,
Expand All @@ -1486,6 +1492,7 @@
1648BA9B2921D7570076AC35 /* MainMapViewController.swift in Sources */,
603FD388292914EB00687ED4 /* FirestoreService.swift in Sources */,
83E7BBC82922AFED007C390A /* AppSettingViewController.swift in Sources */,
5506CDDB292B4D270002F328 /* FriendListDIContainer.swift in Sources */,
1648BAAF292387020076AC35 /* GroupChatRoomAnnotationView.swift in Sources */,
7CE8063D29253A3800D828FF /* ProfileDetailCoordinator.swift in Sources */,
7C6684AE2924BC9E00A5E10A /* ProfileDetailViewModel.swift in Sources */,
Expand All @@ -1497,6 +1504,7 @@
16530580291E19250026B815 /* ChatRoomListViewModel.swift in Sources */,
603FD39329296B8500687ED4 /* DefaultProfileRepository.swift in Sources */,
60FD705D29238CBB00A4C29A /* RealTimeDatabaseService.swift in Sources */,
5506CDDD292B4F810002F328 /* FetchFriendListUseCase.swift in Sources */,
83D5ECC5292B736500AD1781 /* DefaultAuthRepository.swift in Sources */,
60FD705C29238CBB00A4C29A /* StorageService.swift in Sources */,
83D5ECC3292B714500AD1781 /* AuthRepository.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ final class ChatRoomListDIContainer {
// MARK: - Services

// MARK: - UseCases
func makeChatRoomListUseCase() -> ChatRoomListUseCase {
return DefaultChatRoomListUseCase(chatRoomListRepository: self.makeRepository())
func makeChatRoomListUseCase() -> FetchChatRoomUseCase {
return DefaultFetchChatRoomUseCase(chatRoomListRepository: self.makeRepository())
}

// MARK: - Repositories
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//
// FriendListDIContainer.swift
// NearTalk
//
// Created by 김영욱 on 2022/11/21.
//

import UIKit

final class FriendListDIContainer {

// MARK: - Dependencies
struct Dependencies {
let firestoreService: FirestoreService
let firebaseAuthService: FirebaseAuthService
}

private let dependencies: Dependencies

// MARK: - Persistent Storage
init(dependencies: Dependencies) {
self.dependencies = dependencies
}

// MARK: - Services

// MARK: - UseCases
func makeFetchFriendListUseCase() -> FetchFriendListUseCase {
return DefaultFetchFriendListUseCase(profileRepository: self.makeRepository())
}

func makeProfileDetailUseCaseAble() -> ProfileDetailUseCaseAble {
return ProfileDetailUseCase()
}

// MARK: - Repositories
func makeRepository() -> ProfileRepository {
return DefaultProfileRepository(firestoreService: dependencies.firestoreService, firebaseAuthService: dependencies.firebaseAuthService)
}

// MARK: - Friend Lsit
func makeFriendListViewController(actions: FriendListViewModelActions) -> FriendListViewController {
return FriendListViewController.create(with: self.makeFriendListViewModel(actions: actions))
}

func makeFriendListViewModel(actions: FriendListViewModelActions) -> FriendListViewModel {
return DefaultFriendListViewModel(useCase: self.makeFetchFriendListUseCase(), actions: actions)
}

// MARK: - Profile Detail
// func makeProfileDetailViewController() -> ProfileDetailViewController {
// return ProfileDetailViewController(viewModel: makeProfileDetailViewModel())
// }
//
// func makeProfileDetailViewModel() -> ProfileDetailViewModel {
// return ProfileDetailViewModel(profileDetailUseCase: self.makeProfileDetailUseCaseAble(), profileDetailCoordinator: self.makeProfileDetailCoordinator(makeFriendListCoordinator))
// }

// MARK: - Coordinator
func makeFriendListCoordinator(navigationController: UINavigationController) -> FriendListCoordinator {
return FriendListCoordinator(navigationController: navigationController, dependencies: self)
}

// func makeProfileDetailDIContainer() -> ProfileDetailDIContainer {
// let dependencies = ProfileDetailDIContainer.Dependencies()
// return ProfileDetailDICOntainer(dependencies: dependencies)
// }
}

extension FriendListDIContainer: FriendListCoordinatorDependencies {}
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ final class RootTabBarDIContainer {
// MARK: - Create viewController
func createTabBarController() -> RootTabBarController {
let chatRoomListRepository = DefaultChatRoomListRepository(dataTransferService: DefaultStorageService())
let chatRoomListUseCase: ChatRoomListUseCase = DefaultChatRoomListUseCase(chatRoomListRepository: chatRoomListRepository)
let chatRoomListUseCase: FetchChatRoomUseCase = DefaultFetchChatRoomUseCase(chatRoomListRepository: chatRoomListRepository)

let myProfileDIContainer: MyProfileDIContainer = .init()
let myProfileVC: MyProfileViewController = .init(coordinator: myProfileDIContainer.makeMyProfileCoordinator(), viewModel: myProfileDIContainer.makeViewModel())

let dependency: RootTabBarControllerDependency = .init(
mapViewController: MainMapViewController(),
chatRoomListViewController: ChatRoomListViewController.create(with: DefaultChatRoomListViewModel(useCase: chatRoomListUseCase)),
friendListViewController: FriendsListViewController(),
friendListViewController: FriendListViewController(),
myProfileViewController: myProfileVC
)
return RootTabBarController(viewModel: makeViewModel(), dependency: dependency)
Expand Down
16 changes: 16 additions & 0 deletions NearTalk/NearTalk/Domain/Entities/Friend.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Friends.swift
// NearTalk
//
// Created by 김영욱 on 2022/11/21.
//

import Foundation

struct Friend: Codable, Hashable {
/// 유저 UUID
var userID: String?
var username: String?
var statusMessage: String?
var profileImagePath: String?
}
Loading

0 comments on commit d07ca81

Please sign in to comment.