Skip to content

Commit 635f838

Browse files
committed
πŸ› [fix] λ‚΄ ν”„λ‘œν•„ κΉœλΉ‘μ΄λŠ” μ• λ‹ˆλ©”μ΄μ…˜ ν•΄κ²°
1 parent 3c60f89 commit 635f838

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

β€ŽFitfty/Projects/Profile/Sources/Profile/ViewControllers/ProfileViewController.swiftβ€Ž

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ final public class ProfileViewController: UIViewController {
1919
private var profileType: ProfileType
2020
private var presentType: ProfilePresentType
2121
private var nickname: String?
22+
private var isRefreshProfileImage = false
2223
private var dataSource: UICollectionViewDiffableDataSource<ProfileSectionKind, ProfileCellModel>?
2324

2425
private lazy var collectionView: UICollectionView = {
@@ -38,7 +39,7 @@ final public class ProfileViewController: UIViewController {
3839
}()
3940

4041
private lazy var loadingIndicatorView: LoadingView = {
41-
let loadingView: LoadingView = .init(backgroundColor: .white.withAlphaComponent(0.2), alpha: 1)
42+
let loadingView: LoadingView = .init(backgroundColor: .white.withAlphaComponent(0), alpha: 1)
4243
loadingView.stopAnimating()
4344
return loadingView
4445
}()
@@ -106,6 +107,7 @@ final public class ProfileViewController: UIViewController {
106107
}
107108
viewModel.input.viewWillAppearWithoutMenu(nickname: nickname)
108109
case .myProfile:
110+
isRefreshProfileImage = true
109111
viewModel.input.viewWillAppearWithMenu(menuType: menuType)
110112
}
111113
}
@@ -130,13 +132,15 @@ final public class ProfileViewController: UIViewController {
130132
}
131133

132134
@objc func didTapMyFitftyMenu(_ sender: Any?) {
135+
isRefreshProfileImage = false
133136
collectionView.isScrollEnabled = true
134137
emptyView.isHidden = true
135138
menuType = .myFitfty
136139
viewModel.input.didTapMenu(.myFitfty)
137140
}
138141

139142
@objc func didTapBookmarkMenu(_ sender: Any?) {
143+
isRefreshProfileImage = false
140144
collectionView.isScrollEnabled = true
141145
emptyView.isHidden = true
142146
menuType = .bookmark
@@ -299,7 +303,8 @@ private extension ProfileViewController {
299303
supplementaryView.profileView.setUp(
300304
nickname: nickname,
301305
content: content,
302-
filepath: self?.profileFilePath
306+
filepath: self?.profileFilePath,
307+
refresh: self?.isRefreshProfileImage ?? true
303308
)
304309
}
305310
return supplementaryView
@@ -316,7 +321,8 @@ private extension ProfileViewController {
316321
supplementaryView.profileView.setUp(
317322
nickname: nickname,
318323
content: content,
319-
filepath: self?.profileFilePath
324+
filepath: self?.profileFilePath,
325+
refresh: self?.isRefreshProfileImage ?? true
320326
)
321327
}
322328
supplementaryView.menuView.setMyFitftyButtonTarget(self, action: #selector(self?.didTapMyFitftyMenu))
@@ -345,7 +351,6 @@ private extension ProfileViewController {
345351
snapshot.appendSections([$0.sectionKind])
346352
snapshot.appendItems($0.items)
347353
}
348-
snapshot.reloadSections([.feed])
349354
dataSource?.apply(snapshot, animatingDifferences: true) {
350355
guard sections.first?.items.count == 0 else {
351356
return
@@ -355,6 +360,11 @@ private extension ProfileViewController {
355360
self.emptyView.setUp(self.menuType)
356361
}
357362

363+
guard var currentSnapshot = dataSource?.snapshot() else {
364+
return
365+
}
366+
currentSnapshot.reloadSections([.feed])
367+
dataSource?.apply(currentSnapshot, animatingDifferences: false)
358368
}
359369

360370
func postLayout() -> UICollectionViewLayout {

β€ŽFitfty/Projects/Profile/Sources/Profile/Views/ProfileView.swiftβ€Ž

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,18 @@ final class ProfileView: UIView {
6262
}
6363

6464
extension ProfileView {
65-
func setUp(nickname: String, content: String, filepath: String?) {
65+
func setUp(nickname: String, content: String, filepath: String?, refresh: Bool) {
6666
if let filepath = filepath {
6767
let url = URL(string: filepath)
68-
imageView.kf.setImage(with: url)
68+
if refresh {
69+
imageView.kf.indicatorType = .activity
70+
imageView.kf.setImage(
71+
with: url,
72+
options: [.forceRefresh]
73+
)
74+
} else {
75+
imageView.kf.setImage(with: url)
76+
}
6977
} else {
7078
imageView.image = CommonAsset.Images.profileDummy.image
7179
}

0 commit comments

Comments
Β (0)