Skip to content

Commit

Permalink
Merge pull request #257 from OMZigak/hotfix/#254-profileRemake
Browse files Browse the repository at this point in the history
fix/#254 준비현황 레이아웃 수정
  • Loading branch information
hooni0918 authored Jul 19, 2024
2 parents 883460a + 22ae586 commit 93ca9f0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion KkuMulKum/Application/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {

performAutoLogin()
}

private func performAutoLogin() {
print("Performing auto login")
loginViewModel.autoLogin { [weak self] success in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))% 크기)")
}
}
15 changes: 14 additions & 1 deletion KkuMulKum/Source/Promise/ReadyStatus/View/ReadyStatusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
//

import UIKit
import SnapKit


class ReadyStatusView: BaseView {
private let scrollView: UIScrollView = UIScrollView().then {
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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)
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class ReadyStatusViewController: BaseViewController {
readyStatusViewModel.fetchPromiseParticipantList()
}

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
rootView.updateCollectionViewHeight()
}

override func setupDelegate() {
rootView.ourReadyStatusCollectionView.dataSource = self
}
Expand Down

0 comments on commit 93ca9f0

Please sign in to comment.