Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/iOS/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
chopmozzi committed Jan 11, 2024
2 parents 7514c1f + eea4d87 commit 8a355fd
Show file tree
Hide file tree
Showing 13 changed files with 649 additions and 44 deletions.
24 changes: 24 additions & 0 deletions iOS/Layover/Layover.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
19AE482A2B2A127E00DD4612 /* HLSAssetResourceLoaderDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AE48292B2A127E00DD4612 /* HLSAssetResourceLoaderDelegate.swift */; };
19AE482C2B2A1A8B00DD4612 /* HLSSliceResourceLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AE482B2B2A1A8B00DD4612 /* HLSSliceResourceLoader.swift */; };
19AE482E2B2A24C700DD4612 /* URL+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AE482D2B2A24C700DD4612 /* URL+.swift */; };
19B665D92B4EEDDD0083E63C /* SignUpWorkerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19B665D52B4EEDDD0083E63C /* SignUpWorkerTests.swift */; };
19B665DA2B4EEDDD0083E63C /* SignUpInteractorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19B665D62B4EEDDD0083E63C /* SignUpInteractorTests.swift */; };
19B665DB2B4EEDDD0083E63C /* SignUpPresenterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19B665D72B4EEDDD0083E63C /* SignUpPresenterTests.swift */; };
19B665DD2B4F0A7B0083E63C /* MockSignUpWorker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19B665DC2B4F0A7B0083E63C /* MockSignUpWorker.swift */; };
19C7AFCE2B02410F003B35F2 /* AuthManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19C7AFCD2B02410F003B35F2 /* AuthManager.swift */; };
19C7AFD62B02584D003B35F2 /* KeychainStored.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19C7AFD52B02584D003B35F2 /* KeychainStored.swift */; };
19E79AC02B0A85D0009EA9ED /* LoopingPlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19E79ABF2B0A85D0009EA9ED /* LoopingPlayerView.swift */; };
Expand Down Expand Up @@ -371,6 +375,10 @@
19AE48292B2A127E00DD4612 /* HLSAssetResourceLoaderDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HLSAssetResourceLoaderDelegate.swift; sourceTree = "<group>"; };
19AE482B2B2A1A8B00DD4612 /* HLSSliceResourceLoader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HLSSliceResourceLoader.swift; sourceTree = "<group>"; };
19AE482D2B2A24C700DD4612 /* URL+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URL+.swift"; sourceTree = "<group>"; };
19B665D52B4EEDDD0083E63C /* SignUpWorkerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignUpWorkerTests.swift; sourceTree = "<group>"; };
19B665D62B4EEDDD0083E63C /* SignUpInteractorTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignUpInteractorTests.swift; sourceTree = "<group>"; };
19B665D72B4EEDDD0083E63C /* SignUpPresenterTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignUpPresenterTests.swift; sourceTree = "<group>"; };
19B665DC2B4F0A7B0083E63C /* MockSignUpWorker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockSignUpWorker.swift; sourceTree = "<group>"; };
19C7AFCD2B02410F003B35F2 /* AuthManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthManager.swift; sourceTree = "<group>"; };
19C7AFD52B02584D003B35F2 /* KeychainStored.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainStored.swift; sourceTree = "<group>"; };
19E79ABF2B0A85D0009EA9ED /* LoopingPlayerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoopingPlayerView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -626,6 +634,7 @@
isa = PBXGroup;
children = (
8363A32B2B4C1C6900772DDF /* Playback */,
19B665D32B4EEDDD0083E63C /* SignUp */,
19AE481D2B29D02700DD4612 /* EditProfile */,
19AE48122B28C2A800DD4612 /* Setting */,
192513632B26F7BB001533FA /* TagPlayList */,
Expand Down Expand Up @@ -655,6 +664,7 @@
192513842B27852C001533FA /* MockUserWorker.swift */,
19AE481B2B28C53800DD4612 /* MockSettingWorker.swift */,
8363A3322B4D6E9B00772DDF /* MockPlaybackWorker.swift */,
19B665DC2B4F0A7B0083E63C /* MockSignUpWorker.swift */,
);
path = Workers;
sourceTree = "<group>";
Expand Down Expand Up @@ -801,6 +811,16 @@
path = HLSResourceLoader;
sourceTree = "<group>";
};
19B665D32B4EEDDD0083E63C /* SignUp */ = {
isa = PBXGroup;
children = (
19B665D62B4EEDDD0083E63C /* SignUpInteractorTests.swift */,
19B665D72B4EEDDD0083E63C /* SignUpPresenterTests.swift */,
19B665D52B4EEDDD0083E63C /* SignUpWorkerTests.swift */,
);
path = SignUp;
sourceTree = "<group>";
};
19BB8A572B07BEE30070B922 /* UIComponents */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1597,6 +1617,7 @@
files = (
192513852B27852C001533FA /* MockUserWorker.swift in Sources */,
192513832B277CD7001533FA /* ProfilePresenterTests.swift in Sources */,
19B665DD2B4F0A7B0083E63C /* MockSignUpWorker.swift in Sources */,
192513812B277CD7001533FA /* ProfileInteractorTests.swift in Sources */,
194C21C42B1DEE6B00C62645 /* HomeInteractorTests.swift in Sources */,
FC4E0C0F2B282AE500152596 /* UploadPostPresenterTests.swift in Sources */,
Expand All @@ -1618,12 +1639,15 @@
1925136D2B26F84E001533FA /* MockTagPlayListWorker.swift in Sources */,
19AE481A2B28C2B700DD4612 /* SettingPresenterTests.swift in Sources */,
19AE48172B28C2B700DD4612 /* SettingViewControllerTests.swift in Sources */,
19B665DA2B4EEDDD0083E63C /* SignUpInteractorTests.swift in Sources */,
19B665DB2B4EEDDD0083E63C /* SignUpPresenterTests.swift in Sources */,
194C21C32B1DEE6B00C62645 /* HomeViewControllerTests.swift in Sources */,
8363A32F2B4C329100772DDF /* PlaybackInteractorTests.swift in Sources */,
192513692B26F7CE001533FA /* TagPlayListInteractorTests.swift in Sources */,
19AE48232B29D03D00DD4612 /* EditProfileInteractorTests.swift in Sources */,
194C21CC2B1DF39200C62645 /* MockHomeWorker.swift in Sources */,
FC4E0C0E2B282AE500152596 /* UploadPostWorkerTests.swift in Sources */,
19B665D92B4EEDDD0083E63C /* SignUpWorkerTests.swift in Sources */,
FC4E0C112B28595200152596 /* MockUploadPostWorker.swift in Sources */,
FC4E0C0D2B282AE500152596 /* UploadPostInteractorTests.swift in Sources */,
);
Expand Down
15 changes: 8 additions & 7 deletions iOS/Layover/Layover/Scenes/Map/MapViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ final class MapViewController: BaseViewController {
let maximumZoomScale: CGFloat = 1.0
let inset = (screenSize.width - screenSize.width * groupWidthDimension) / 2
let section: NSCollectionLayoutSection = .makeCarouselSection(groupWidthDimension: groupWidthDimension)
section.orthogonalScrollingBehavior = .groupPagingCentered
section.orthogonalScrollingBehavior = .groupPaging
section.interGroupSpacing = 0
section.contentInsets = NSDirectionalEdgeInsets(top: 0,
leading: inset,
Expand All @@ -173,12 +173,11 @@ final class MapViewController: BaseViewController {
let distanceFromCenter = abs((item.center.x - offset.x) - environment.container.contentSize.width / 2.0)
let scale = max(maximumZoomScale - (distanceFromCenter / containerWidth), minumumZoomScale)
item.transform = CGAffineTransform(scaleX: scale, y: scale)
let cell = self?.carouselCollectionView.cellForItem(at: item.indexPath) as? MapCarouselCollectionViewCell
guard let cell = self?.carouselCollectionView.cellForItem(at: item.indexPath) as? MapCarouselCollectionViewCell else { return }
if scale >= maximumZoomScale * 0.9 {
cell?.play()
self?.selectAnnotation(at: item.indexPath)
} else {
cell?.pause()
cell.pause()
}
}
}
Expand All @@ -197,7 +196,6 @@ final class MapViewController: BaseViewController {
carouselCollectionViewHeight.constant = isSelected ? 151 : 0
UIView.animate(withDuration: 0.3) {
annotationView.transform = isSelected ? CGAffineTransform(scaleX: 1.3, y: 1.3) : .identity
self.view.layoutIfNeeded()
}
}

Expand Down Expand Up @@ -256,15 +254,18 @@ extension MapViewController: MKMapViewDelegate {
if let annotaion = annotation as? LOAnnotation {
// 선택된 pin 정보와 datasource를 비교해 selected item을 찾음
let snapshot = carouselDatasource.snapshot()
guard let selectedItemIdentifiers = carouselDatasource.snapshot().itemIdentifiers.filter({ post in
guard let selectedItemIdentifiers = snapshot.itemIdentifiers.filter({ post in
return post.boardID == annotaion.boardID
}).first else { return }
guard let section = snapshot.sectionIdentifier(containingItem: selectedItemIdentifiers),
let itemIndex = snapshot.indexOfItem(selectedItemIdentifiers),
let sectionIndex = snapshot.indexOfSection(section) else { return }
carouselCollectionView.scrollToItem(at: IndexPath(item: itemIndex, section: sectionIndex),
let indexPath = IndexPath(item: itemIndex, section: sectionIndex)
carouselCollectionView.scrollToItem(at: indexPath,
at: .centeredHorizontally,
animated: false)
guard let cell = carouselCollectionView.cellForItem(at: indexPath) as? MapCarouselCollectionViewCell else { return }
cell.play()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ final class MapCarouselCollectionViewCell: UICollectionViewCell {
spinner.stopAnimating()
loopingPlayerView.disable()
loopingPlayerView.prepareVideo(with: url,
timeRange: CMTimeRange(start: .zero, duration: CMTime(value: 1800, timescale: 600)))
assetResourceLoaderDelegate: HLSAssetResourceLoaderDelegate(resourceLoader: HLSSliceResourceLoader()),
loopStart: .zero,
duration: 3.0)
loopingPlayerView.player?.isMuted = true
}

Expand Down
38 changes: 17 additions & 21 deletions iOS/Layover/Layover/Scenes/SignUpScene/SignUpInteractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import UIKit

protocol SignUpBusinessLogic {
func validateNickname(with request: SignUpModels.ValidateNickname.Request)
func checkDuplication(with request: SignUpModels.CheckDuplication.Request)
func signUp(with request: SignUpModels.SignUp.Request)
func checkDuplication(with request: SignUpModels.CheckDuplication.Request) async
func signUp(with request: SignUpModels.SignUp.Request) async
}

protocol SignUpDataStore: AnyObject {
Expand Down Expand Up @@ -40,33 +40,29 @@ final class SignUpInteractor: SignUpBusinessLogic, SignUpDataStore {
presenter?.presentNicknameValidation(with: SignUpModels.ValidateNickname.Response(nicknameState: response))
}

func checkDuplication(with request: SignUpModels.CheckDuplication.Request) {
Task {
let response = await userWorker?.checkNotDuplication(for: request.nickname)
await MainActor.run {
presenter?.presentNicknameDuplication(with: SignUpModels.CheckDuplication.Response(isValid: response ?? false))
}
func checkDuplication(with request: SignUpModels.CheckDuplication.Request) async {
let response = await userWorker?.checkNotDuplication(for: request.nickname)
await MainActor.run {
presenter?.presentNicknameDuplication(with: SignUpModels.CheckDuplication.Response(isValid: response ?? false))
}
}

// MARK: - UseCase: SignUp

func signUp(with request: SignUpModels.SignUp.Request) {
func signUp(with request: SignUpModels.SignUp.Request) async {
guard let signUpType, let socialToken else { return }

Task {
switch signUpType {
case .kakao:
if await signUpWorker?.signUp(withKakao: socialToken, username: request.nickname) == true {
await MainActor.run {
presenter?.presentSignUpSuccess()
}
switch signUpType {
case .kakao:
if await signUpWorker?.signUp(withKakao: socialToken, username: request.nickname) == true {
await MainActor.run {
presenter?.presentSignUpSuccess()
}
case .apple:
if await signUpWorker?.signUp(withApple: socialToken, username: request.nickname) == true {
await MainActor.run {
presenter?.presentSignUpSuccess()
}
}
case .apple:
if await signUpWorker?.signUp(withApple: socialToken, username: request.nickname) == true {
await MainActor.run {
presenter?.presentSignUpSuccess()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class SignUpPresenter: SignUpPresentationLogic {

func presentNicknameDuplication(with response: SignUpModels.CheckDuplication.Response) {
let viewModel = Models.CheckDuplication.ViewModel(canSignUp: response.isValid)
viewController?.displayNickanmeDuplication(response: viewModel)
viewController?.displayNicknameDuplication(response: viewModel)
}

func presentSignUpSuccess() {
Expand Down
12 changes: 8 additions & 4 deletions iOS/Layover/Layover/Scenes/SignUpViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UIKit

protocol SignUpDisplayLogic: AnyObject {
func displayNicknameValidation(response: SignUpModels.ValidateNickname.ViewModel)
func displayNickanmeDuplication(response: SignUpModels.CheckDuplication.ViewModel)
func displayNicknameDuplication(response: SignUpModels.CheckDuplication.ViewModel)
func navigateToMain()
}

Expand Down Expand Up @@ -137,7 +137,9 @@ final class SignUpViewController: BaseViewController {
@objc private func checkDuplicateNicknameButtonDidTap(_ sender: UIButton) {
guard let nickname = nicknameTextfield.text else { return }
checkDuplicateNicknameButton.isEnabled = false
interactor?.checkDuplication(with: SignUpModels.CheckDuplication.Request(nickname: nickname))
Task {
await interactor?.checkDuplication(with: SignUpModels.CheckDuplication.Request(nickname: nickname))
}
}

@objc private func popViewController() {
Expand All @@ -146,7 +148,9 @@ final class SignUpViewController: BaseViewController {

@objc private func signUpButtonDidTap(_ sender: UIButton) {
guard let nickname = nicknameTextfield.text else { return }
interactor?.signUp(with: SignUpModels.SignUp.Request(nickname: nickname))
Task {
await interactor?.signUp(with: SignUpModels.SignUp.Request(nickname: nickname))
}
}
}

Expand All @@ -159,7 +163,7 @@ extension SignUpViewController: SignUpDisplayLogic {
nicknameAlertLabel.textColor = .error
}

func displayNickanmeDuplication(response: SignUpModels.CheckDuplication.ViewModel) {
func displayNicknameDuplication(response: SignUpModels.CheckDuplication.ViewModel) {
nicknameAlertLabel.isHidden = false
nicknameAlertLabel.text = response.alertDescription
nicknameAlertLabel.textColor = response.canSignUp ? .correct : .error
Expand Down
8 changes: 1 addition & 7 deletions iOS/Layover/Layover/Workers/Mocks/MockSignUpWorker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import OSLog

final class MockSignUpWorker {
class MockSignUpWorker: SignUpWorkerProtocol {

// MARK: - Properties

Expand All @@ -21,11 +21,6 @@ final class MockSignUpWorker {
authManager: StubAuthManager())) {
self.provider = provider
}
}

// MARK: - SignUpWorkerProtocol

extension MockSignUpWorker: SignUpWorkerProtocol {

func signUp(withKakao socialToken: String, username: String) async -> Bool {
guard let mockFileLocation = Bundle.main.url(forResource: "LoginData", withExtension: "json"),
Expand Down Expand Up @@ -86,5 +81,4 @@ extension MockSignUpWorker: SignUpWorkerProtocol {
return false
}
}

}
85 changes: 85 additions & 0 deletions iOS/Layover/LayoverTests/Mocks/Workers/MockSignUpWorker.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//
// MockSignUpWorker.swift
// LayoverTests
//
// Created by 김인환 on 1/11/24.
// Copyright © 2024 CodeBomber. All rights reserved.
//

@testable import Layover
import Foundation
import OSLog

class MockSignUpWorker: SignUpWorkerProtocol {

// MARK: - Properties

private let provider: ProviderType

// MARK: - Initializer

init(provider: ProviderType = Provider(session: .initMockSession(),
authManager: StubAuthManager())) {
self.provider = provider
}

func signUp(withKakao socialToken: String, username: String) async -> Bool {
guard let mockFileLocation = Bundle(for: type(of: self)).url(forResource: "LoginData", withExtension: "json"),
let mockData = try? Data(contentsOf: mockFileLocation) else {
return false
}

MockURLProtocol.requestHandler = { request in
let response = HTTPURLResponse(url: request.url!,
statusCode: 200,
httpVersion: nil,
headerFields: nil)
return (response, mockData, nil)
}

do {
var bodyParameters = [String: String]()
bodyParameters.updateValue(socialToken, forKey: "accessToken")
bodyParameters.updateValue(username, forKey: "username")

let endPoint = EndPoint<Response<LoginDTO>>(path: "/oauth/signup/kakao",
method: .POST,
bodyParameters: bodyParameters)
let response = try await provider.request(with: endPoint, authenticationIfNeeded: false, retryCount: 0)
return true
} catch {
os_log(.error, log: .data, "%@", error.localizedDescription)
return false
}
}

func signUp(withApple identityToken: String, username: String) async -> Bool {
guard let fileLocation: URL = Bundle(for: type(of: self)).url(forResource: "LoginData", withExtension: "json") else {
return false
}
guard let mockData: Data = try? Data(contentsOf: fileLocation) else {
return false
}
MockURLProtocol.requestHandler = { request in
let response = HTTPURLResponse(url: request.url!,
statusCode: 200,
httpVersion: nil,
headerFields: nil)
return (response, mockData, nil)
}
do {
var bodyParameters: [String: String] = [:]
bodyParameters.updateValue(identityToken, forKey: "identityToken")
bodyParameters.updateValue(username, forKey: "username")

let endPoint = EndPoint<Response<LoginDTO>>(path: "/oauth/signup/apple",
method: .POST,
bodyParameters: bodyParameters)
let response = try await provider.request(with: endPoint, authenticationIfNeeded: false, retryCount: 0)
return true
} catch {
os_log(.error, log: .data, "%@", error.localizedDescription)
return false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import OSLog

final class MockUserWorker: UserWorkerProtocol {
class MockUserWorker: UserWorkerProtocol {

// MARK: - Properties

Expand Down
Loading

0 comments on commit 8a355fd

Please sign in to comment.