diff --git a/KkuMulKum/Application/SceneDelegate.swift b/KkuMulKum/Application/SceneDelegate.swift index bd9b87d7..7514337d 100644 --- a/KkuMulKum/Application/SceneDelegate.swift +++ b/KkuMulKum/Application/SceneDelegate.swift @@ -29,7 +29,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { performAutoLogin() } - + private func performAutoLogin() { print("Performing auto login") loginViewModel.autoLogin { [weak self] success in diff --git a/KkuMulKum/Source/Onboarding/Profile/ViewModel/ProfileSetupViewModel.swift b/KkuMulKum/Source/Onboarding/Profile/ViewModel/ProfileSetupViewModel.swift index 5ae5835a..912b36a0 100644 --- a/KkuMulKum/Source/Onboarding/Profile/ViewModel/ProfileSetupViewModel.swift +++ b/KkuMulKum/Source/Onboarding/Profile/ViewModel/ProfileSetupViewModel.swift @@ -86,26 +86,16 @@ class ProfileSetupViewModel { var compression: CGFloat = 1.0 var imageData = originalImageData - var bestImageData = originalImageData - var iterationCount = 0 - while compression > 0.01 { + while imageData.count > maxSizeInBytes && compression > 0.0 { + compression -= 0.1 if let compressedData = image.jpegData(compressionQuality: compression) { imageData = compressedData - iterationCount += 1 - print("압축 시도 #\(iterationCount): 크기 \(imageData.count) bytes (압축률: \(compression))") - - if imageData.count <= maxSizeInBytes { - bestImageData = imageData - break - } else if imageData.count < bestImageData.count { - bestImageData = imageData - } + print("압축 시도: 크기 \(imageData.count) bytes (압축률: \(compression))") } - compression -= 0.1 } - compressedImageData = bestImageData - print("최종 압축 결과: \(bestImageData.count) bytes (원본 대비 \(Int((Double(bestImageData.count) / Double(originalImageData.count)) * 100))% 크기)") + compressedImageData = imageData + print("최종 압축 결과: \(imageData.count) bytes (원본 대비 \(Int((Double(imageData.count) / Double(originalImageData.count)) * 100))% 크기)") } } diff --git a/KkuMulKum/Source/Promise/ReadyStatus/View/ReadyStatusView.swift b/KkuMulKum/Source/Promise/ReadyStatus/View/ReadyStatusView.swift index 3b8c499a..c93c56ed 100644 --- a/KkuMulKum/Source/Promise/ReadyStatus/View/ReadyStatusView.swift +++ b/KkuMulKum/Source/Promise/ReadyStatus/View/ReadyStatusView.swift @@ -6,6 +6,8 @@ // import UIKit +import SnapKit + class ReadyStatusView: BaseView { private let scrollView: UIScrollView = UIScrollView().then { @@ -14,6 +16,8 @@ class ReadyStatusView: BaseView { private let contentView: UIView = UIView() + private var collectionViewHeightConstraint: Constraint? + private let baseStackView: UIStackView = UIStackView(axis: .vertical).then { $0.spacing = 24 $0.backgroundColor = .gray0 @@ -95,6 +99,13 @@ class ReadyStatusView: BaseView { } + func updateCollectionViewHeight() { + ourReadyStatusCollectionView.layoutIfNeeded() + let contentHeight = ourReadyStatusCollectionView.collectionViewLayout.collectionViewContentSize.height + collectionViewHeightConstraint?.update(offset: contentHeight) + layoutIfNeeded() + } + override func setupAutoLayout() { scrollView.snp.makeConstraints { $0.edges.equalToSuperview() @@ -113,11 +124,13 @@ class ReadyStatusView: BaseView { ourReadyStatusCollectionView.snp.makeConstraints { $0.top.equalTo(baseStackView.snp.bottom).offset(22) $0.leading.trailing.equalToSuperview().inset(20) - $0.height.equalTo(Screen.height(72) * 2) + self.collectionViewHeightConstraint = $0.height.equalTo(0).constraint } contentView.snp.makeConstraints { $0.bottom.equalTo(ourReadyStatusCollectionView.snp.bottom).offset(20) } } + + } diff --git a/KkuMulKum/Source/Promise/ReadyStatus/ViewController/ReadyStatusViewController.swift b/KkuMulKum/Source/Promise/ReadyStatus/ViewController/ReadyStatusViewController.swift index 2e1cf651..8c796223 100644 --- a/KkuMulKum/Source/Promise/ReadyStatus/ViewController/ReadyStatusViewController.swift +++ b/KkuMulKum/Source/Promise/ReadyStatus/ViewController/ReadyStatusViewController.swift @@ -43,6 +43,11 @@ class ReadyStatusViewController: BaseViewController { readyStatusViewModel.fetchPromiseParticipantList() } + override func viewDidLayoutSubviews() { + super.viewDidLayoutSubviews() + rootView.updateCollectionViewHeight() + } + override func setupDelegate() { rootView.ourReadyStatusCollectionView.dataSource = self }