Skip to content

Commit

Permalink
refactor: 빌드 위한 주석 처리(#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
sozohoy committed Oct 16, 2024
1 parent 51bce12 commit 36db2f4
Show file tree
Hide file tree
Showing 10 changed files with 233 additions and 232 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ extension FollowViewController: UITableViewDataSource, UITableViewDelegate {
) as! FollowerCell

let follower = viewModel.followers[indexPath.row]
cell.configure(with: follower)
// cell.configure(with: follower)

cell.followButton.do {
if indexPath.row == 0 && followType == .following {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public class MyRecordViewController: UIViewController {
setStyle()
setUI()
setAutoLayout()
bindViewModel()
viewModel.fetchRecords()
// bindViewModel()
// viewModel.fetchRecords()
}

public func setStyle() {
Expand Down Expand Up @@ -136,35 +136,36 @@ public class MyRecordViewController: UIViewController {

}

private func bindViewModel() {
viewModel.isEmpty.bind { [weak self] isEmpty in
self?.emptyRecordView.isHidden = !isEmpty
self?.emptyRecordText.isHidden = !isEmpty
self?.recordButton.isHidden = !isEmpty
self?.countLabel.isHidden = isEmpty
self?.collectionView.isHidden = isEmpty
}

viewModel.records.bind { [weak self] records in
self?.updateUI(with: records)
}
}
// private func bindViewModel() {
// viewModel.isEmpty.bind { [weak self] isEmpty in
// self?.emptyRecordView.isHidden = !isEmpty
// self?.emptyRecordText.isHidden = !isEmpty
// self?.recordButton.isHidden = !isEmpty
// self?.countLabel.isHidden = isEmpty
// self?.collectionView.isHidden = isEmpty
// }
//
// viewModel.records.bind { [weak self] records in
// self?.updateUI(with: records)
// }
// }

private func updateUI(with records: [FeedModel]) {
countLabel.text = "\(records.count)개의 기록"
collectionView.reloadData()
}
// private func updateUI(with records: [FeedModel]) {
// countLabel.text = "• \(records.count)개의 기록"
// collectionView.reloadData()
// }
}

extension MyRecordViewController: UICollectionViewDataSource {
public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return viewModel.records.value.count
// return viewModel.records.value.count
return 0
}

public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "RecordCell", for: indexPath) as! RecordCollectionViewCell
let record = viewModel.records.value[indexPath.item]
cell.configure(with: record)
// let record = viewModel.records.value[indexPath.item]
// cell.configure(with: record)
return cell
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,23 +174,23 @@ public class OtherUserProfileViewController: UIViewController, UICollectionViewD
func getUserInfo() {
let apiProvider = APIProvider<APITarget.Users>()
let request = DTO.GetProfileRequest(otherUserId: id)
apiProvider.requestResponsable(.getProfile(request), DTO.GetProfileResponse.self) { [weak self] result in
guard let self = self else { return }
switch result {
case .success(let response):
self.user = User(
isMine: response.id,
id: response.nickname,
nickname: response.followerCount,
follower: response.followingCount,
following: response.isFollowing,
isFollowing: response.profileImageUrl
)
self.setUserProfile()
case .failure(let failure):
print(failure)
}
}
// apiProvider.requestResponsable(.getProfile(request), DTO.GetProfileResponse.self) { [weak self] result in
// guard let self = self else { return }
// switch result {
// case .success(let response):
// self.user = User(
// isMine: response.id,
// id: response.nickname,
// nickname: response.followerCount,
// follower: response.followingCount,
// following: response.isFollowing,
// isFollowing: response.profileImageUrl
// )
// self.setUserProfile()
// case .failure(let failure):
// print(failure)
// }
// }
}

func getOtherRecordList() {
Expand All @@ -200,33 +200,33 @@ public class OtherUserProfileViewController: UIViewController, UICollectionViewD
cursorId: cursorId,
size: 100
)
apiProvider.requestResponsable(.getUserRecordList(request), DTO.GetUserRecordListResponse.self) { [weak self]
result in
guard let self = self else {return}
switch result {
case .success(let response):
let feeds = response.content.map {
Feed(
id: $0.recordInfo.id,
userId: $0.recordInfo.uploaderId,
location: $0.recordInfo.location, placeInfo: <#PlaceInfo#>,
nickname: $0.recordInfo.uploaderNickname,
description: $0.recordInfo.content,
isBookmarked: $0.isBookmark, bookmarkCount: $0.recordInfo.bookmarkCount,
videoLink: $0.recordInfo.fileUrl.videoUrl,
thumbnailLink: $0.recordInfo.fileUrl.thumbnailUrl,
isMine: $0.recordInfo.isMine
)
}
self.feeds += feeds
DispatchQueue.main.async {
self.collectionView!.reloadData()
self.setCountLabelText()
}
case .failure(let failure):
print(failure.localizedDescription)
}
}
// apiProvider.requestResponsable(.getUserRecordList(request), DTO.GetUserRecordListResponse.self) { [weak self]
// result in
// guard let self = self else {return}
// switch result {
// case .success(let response):
// let feeds = response.content.map {
// Feed(
// id: $0.recordInfo.id,
// userId: $0.recordInfo.uploaderId,
// location: $0.recordInfo.location, placeInfo: <#PlaceInfo#>,
// nickname: $0.recordInfo.uploaderNickname,
// description: $0.recordInfo.content,
// isBookmarked: $0.isBookmark, bookmarkCount: $0.recordInfo.bookmarkCount,
// videoLink: $0.recordInfo.fileUrl.videoUrl,
// thumbnailLink: $0.recordInfo.fileUrl.thumbnailUrl,
// isMine: $0.recordInfo.isMine
// )
// }
// self.feeds += feeds
// DispatchQueue.main.async {
// self.collectionView!.reloadData()
// self.setCountLabelText()
// }
// case .failure(let failure):
// print(failure.localizedDescription)
// }
// }
}

@objc private func followButtonTap() {
Expand Down
18 changes: 9 additions & 9 deletions Presentation/Sources/MyProfile/View/FollowerCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ class FollowerCell: UITableViewCell {
@objc private func followButtonTapped() {
self.followButtonEvent?()
}

func configure(with follower: Follower) {
let url = URL(string: follower.profileImage)
profileImageView.kf.setImage(with: url)
usernameLabel.text = follower.username
followButton.isHidden = follower.username == "유영"
updateFollowButton(isFollowed: follower.isFollowing)
}

//
// func configure(with follower: Follower) {
// let url = URL(string: follower.profileImage)
// profileImageView.kf.setImage(with: url)
// usernameLabel.text = follower.username
// followButton.isHidden = follower.username == "유영"
// updateFollowButton(isFollowed: follower.isFollowing)
// }
//
func updateFollowButton(isFollowed: Bool) {
followButton.mediumState = isFollowed ? .active : .inactive
}
Expand Down
22 changes: 11 additions & 11 deletions Presentation/Sources/MyProfile/View/ProfileInfoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ public class ProfileInfoView: UIView {
}
}

func updateView(with model: ProfileUserModel) {
userName.text = model.name

let followerAttributedText = NSMutableAttributedString(string: "\(model.followerCount)", attributes: [.font: RecordyFont.body2.font])
followerAttributedText.append(NSAttributedString(string: " 명의 팔로워", attributes: [.font: RecordyFont.body2.font, .foregroundColor: CommonAsset.recordyGrey03.color]))
followerButton.setAttributedTitle(followerAttributedText, for: .normal)

let followingAttributedText = NSMutableAttributedString(string: "\(model.followingCount)", attributes: [.font: RecordyFont.body2.font])
followingAttributedText.append(NSAttributedString(string: " 명의 팔로잉", attributes: [.font: RecordyFont.body2.font, .foregroundColor: CommonAsset.recordyGrey03.color]))
followingButton.setAttributedTitle(followingAttributedText, for: .normal)
}
// func updateView(with model: ProfileUserModel) {
// userName.text = model.name
//
// let followerAttributedText = NSMutableAttributedString(string: "\(model.followerCount)", attributes: [.font: RecordyFont.body2.font])
// followerAttributedText.append(NSAttributedString(string: " 명의 팔로워", attributes: [.font: RecordyFont.body2.font, .foregroundColor: CommonAsset.recordyGrey03.color]))
// followerButton.setAttributedTitle(followerAttributedText, for: .normal)
//
// let followingAttributedText = NSMutableAttributedString(string: "\(model.followingCount)", attributes: [.font: RecordyFont.body2.font])
// followingAttributedText.append(NSAttributedString(string: " 명의 팔로잉", attributes: [.font: RecordyFont.body2.font, .foregroundColor: CommonAsset.recordyGrey03.color]))
// followingButton.setAttributedTitle(followingAttributedText, for: .normal)
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ class RecordCollectionViewCell: UICollectionViewCell {
locationLabel.textAlignment = .left
}

func configure(with record: FeedModel) {
if let image = UIImage(named: record.thumbnail) {
imageView.image = image
} else {
imageView.image = UIImage(named: "placeholder_image")
}
locationLabel.text = record.location
}
// func configure(with record: FeedModel) {
// if let image = UIImage(named: record.thumbnail) {
// imageView.image = image
// } else {
// imageView.image = UIImage(named: "placeholder_image")
// }
// locationLabel.text = record.location
// }
}
106 changes: 53 additions & 53 deletions Presentation/Sources/MyProfile/ViewModel/MyRecordViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,59 +12,59 @@ import Common
import Core

class MyRecordViewModel {
var records: Bindable<[FeedModel]> = Bindable([])
// var records: Bindable<[FeedModel]> = Bindable([])
var isEmpty: Bindable<Bool> = Bindable(true)

func fetchRecords() {
// Example records, you can replace this with your actual data fetching logic
let fetchedRecords: [FeedModel] = [
FeedModel(
id: 1,
thumbnail: "thumbnail1.jpg",
isbookmarked: true,
location: "Seoul",
video: nil,
keywords: [],
nickname: "User1",
description: "Description 1",
bookmarkCount: 10
),
FeedModel(
id: 2,
thumbnail: "thumbnail2.jpg",
isbookmarked: false,
location: "Busan",
video: nil,
keywords: [],
nickname: "User2",
description: "Description 2",
bookmarkCount: 20
),
FeedModel(
id: 3,
thumbnail: "thumbnail3.jpg",
isbookmarked: true,
location: "Incheon",
video: nil,
keywords: [],
nickname: "User3",
description: "Description 3",
bookmarkCount: 5
),
FeedModel(
id: 4,
thumbnail: "thumbnail4.jpg",
isbookmarked: false,
location: "Daegu",
video: nil,
keywords: [],
nickname: "User4",
description: "Description 4",
bookmarkCount: 8
)
]

records.value = fetchedRecords
isEmpty.value = fetchedRecords.isEmpty
}
// func fetchRecords() {
// // Example records, you can replace this with your actual data fetching logic
// let fetchedRecords: [FeedModel] = [
// FeedModel(
// id: 1,
// thumbnail: "thumbnail1.jpg",
// isbookmarked: true,
// location: "Seoul",
// video: nil,
// keywords: [],
// nickname: "User1",
// description: "Description 1",
// bookmarkCount: 10
// ),
// FeedModel(
// id: 2,
// thumbnail: "thumbnail2.jpg",
// isbookmarked: false,
// location: "Busan",
// video: nil,
// keywords: [],
// nickname: "User2",
// description: "Description 2",
// bookmarkCount: 20
// ),
// FeedModel(
// id: 3,
// thumbnail: "thumbnail3.jpg",
// isbookmarked: true,
// location: "Incheon",
// video: nil,
// keywords: [],
// nickname: "User3",
// description: "Description 3",
// bookmarkCount: 5
// ),
// FeedModel(
// id: 4,
// thumbnail: "thumbnail4.jpg",
// isbookmarked: false,
// location: "Daegu",
// video: nil,
// keywords: [],
// nickname: "User4",
// description: "Description 4",
// bookmarkCount: 8
// )
// ]
//
// records.value = fetchedRecords
// isEmpty.value = fetchedRecords.isEmpty
// }
}
Loading

0 comments on commit 36db2f4

Please sign in to comment.