Skip to content

Commit

Permalink
Merge pull request #128 from Busan-Dinosaur/feature/127-follower-paging
Browse files Browse the repository at this point in the history
[FEAT] 팔로워/팔로잉 페이징 구현
  • Loading branch information
coby5502 authored Dec 21, 2023
2 parents a832302 + a5c367a commit 1fe56c7
Show file tree
Hide file tree
Showing 22 changed files with 920 additions and 374 deletions.
46 changes: 37 additions & 9 deletions FoodBowl.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion FoodBowl/Data/DTO/Response/FollowMemberResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct FollowMemberResponse: Codable {
}

// MARK: - Content
struct MemberByFollow: Codable {
struct MemberByFollow: Codable, Hashable {
let memberId: Int
let profileImageUrl: String?
let nickname: String
Expand Down
8 changes: 4 additions & 4 deletions FoodBowl/Presentation/Common/Base/BaseViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ class BaseViewController: UIViewController {
func setupNavigationBar() {
guard let navigationBar = navigationController?.navigationBar else { return }
let appearance = UINavigationBarAppearance()
let font = UIFont.systemFont(ofSize: 17, weight: .regular)
let largeFont = UIFont.systemFont(ofSize: 34, weight: .semibold)

let font = UIFont.font(.regular, ofSize: 19)
let largeFont = UIFont.font(.regular, ofSize: 34)
appearance.titleTextAttributes = [.font: font]
appearance.largeTitleTextAttributes = [.font: largeFont]
appearance.shadowColor = .clear
appearance.backgroundColor = .mainBackgroundColor

navigationBar.standardAppearance = appearance
navigationBar.compactAppearance = appearance
navigationBar.scrollEdgeAppearance = appearance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ final class BackButton: UIButton {
// MARK: - life cycle
private func configureUI() {
setImage(ImageLiteral.btnBack, for: .normal)
tintColor = .mainPink
tintColor = .mainTextColor
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
//
// UserInfoCollectionViewCell.swift
// FoodBowl
//
// Created by COBY_PRO on 2023/01/18.
//

import Combine
import UIKit

import Kingfisher
import SnapKit
import Then

final class UserInfoCollectionViewCell: UICollectionViewCell, BaseViewType {

// MARK: - ui component

let userImageButton = UIButton().then {
$0.backgroundColor = .grey003
$0.layer.cornerRadius = 20
$0.layer.masksToBounds = true
$0.layer.borderColor = UIColor.grey002.cgColor
$0.layer.borderWidth = 1
}
let userNameButton = UIButton().then {
$0.setTitleColor(.mainTextColor, for: .normal)
$0.titleLabel?.font = .preferredFont(forTextStyle: .subheadline, weight: .medium)
}
let userFollowerLabel = UILabel().then {
$0.font = UIFont.preferredFont(forTextStyle: .footnote, weight: .light)
$0.textColor = .subTextColor
$0.text = "팔로워 100명"
}
let followButton = FollowButton()

// MARK: - property

var userButtonTapAction: ((UserInfoCollectionViewCell) -> Void)?
var followButtonTapAction: ((UserInfoCollectionViewCell) -> Void)?

// MARK: - init

override init(frame: CGRect) {
super.init(frame: frame)
self.baseInit()
self.setupAction()
}

@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

func setupLayout() {
contentView.addSubviews(userImageButton, userNameButton, userFollowerLabel, followButton)

userImageButton.snp.makeConstraints {
$0.leading.equalToSuperview().inset(SizeLiteral.horizantalPadding)
$0.top.bottom.equalToSuperview().inset(12)
$0.width.height.equalTo(40)
}

userNameButton.snp.makeConstraints {
$0.leading.equalTo(userImageButton.snp.trailing).offset(12)
$0.top.equalToSuperview().inset(14)
$0.height.equalTo(18)
}

userFollowerLabel.snp.makeConstraints {
$0.leading.equalTo(userImageButton.snp.trailing).offset(12)
$0.top.equalTo(userNameButton.snp.bottom).offset(2)
}

followButton.snp.makeConstraints {
$0.trailing.equalToSuperview().inset(SizeLiteral.horizantalPadding)
$0.centerY.equalToSuperview()
$0.width.equalTo(50)
$0.height.equalTo(30)
}
}

func configureUI() {
self.backgroundColor = .mainBackgroundColor
}

private func setupAction() {
userImageButton.addAction(UIAction { _ in self.userButtonTapAction?(self) }, for: .touchUpInside)
userNameButton.addAction(UIAction { _ in self.userButtonTapAction?(self) }, for: .touchUpInside)
followButton.addAction(UIAction { _ in self.followButtonTapAction?(self) }, for: .touchUpInside)
}
}

// MARK: - Public - func
extension UserInfoCollectionViewCell {
func setupData(_ member: Member) {
if let url = member.profileImageUrl {
userImageButton.kf.setImage(with: URL(string: url), for: .normal)
} else {
userImageButton.setImage(ImageLiteral.defaultProfile, for: .normal)
}

userNameButton.setTitle(member.nickname, for: .normal)
userFollowerLabel.text = "팔로워 \(member.followerCount.prettyNumber)"
}

func setupDataByMemberByFollow(_ member: MemberByFollow) {
if let url = member.profileImageUrl {
userImageButton.kf.setImage(with: URL(string: url), for: .normal)
} else {
userImageButton.setImage(ImageLiteral.defaultProfile, for: .normal)
}

userNameButton.setTitle(member.nickname, for: .normal)
userFollowerLabel.text = "팔로워 \(member.followerCount.prettyNumber)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import SnapKit
import Then

final class UserInfoTableViewCell: BaseTableViewCell {

var followButtonTapAction: ((UserInfoTableViewCell) -> Void)?

// MARK: - property
Expand Down
42 changes: 0 additions & 42 deletions FoodBowl/Presentation/Common/Component/View/Feed/EmptyView.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import SnapKit
import Then

final class UserInfoView: UIView {
// MARK: - property

// MARK: - ui component

let userImageButton = UIButton().then {
$0.backgroundColor = .grey003
$0.layer.cornerRadius = 20
Expand Down Expand Up @@ -82,6 +84,7 @@ extension UserInfoView {
} else {
userImageButton.setImage(ImageLiteral.defaultProfile, for: .normal)
}

userNameButton.setTitle(member.nickname, for: .normal)
userFollowerLabel.text = "팔로워 \(member.followerCount.prettyNumber)"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ final class ImageViewController: UIViewController {
}

func configureUI() {
view.backgroundColor = .black
view.backgroundColor = .mainBackgroundColor
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,12 @@ final class FindResultViewController: BaseViewController {
$0.separatorInset = UIEdgeInsets(top: 0, left: 0, bottom: 20, right: 0)
$0.backgroundColor = .mainBackgroundColor
}
let emptyView = EmptyView()

override func setupLayout() {
view.addSubviews(searchResultTableView, emptyView)
view.addSubviews(searchResultTableView)

searchResultTableView.snp.makeConstraints {
$0.edges.equalToSuperview()
}

emptyView.snp.makeConstraints {
$0.edges.equalToSuperview()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -219,18 +219,8 @@ extension FindViewController: UICollectionViewDataSource, UICollectionViewDelega
extension FindViewController: UITableViewDataSource, UITableViewDelegate {
func tableView(_: UITableView, numberOfRowsInSection _: Int) -> Int {
if scope == 0 {
if stores.isEmpty {
self.findResultViewController.emptyView.isHidden = false
} else {
self.findResultViewController.emptyView.isHidden = true
}
return stores.count
} else {
if members.isEmpty {
self.findResultViewController.emptyView.isHidden = false
} else {
self.findResultViewController.emptyView.isHidden = true
}
return members.count
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ final class FeedListView: UIView, BaseViewType {
$0.register(FeedCollectionViewCell.self, forCellWithReuseIdentifier: FeedCollectionViewCell.className)
$0.backgroundColor = .mainBackgroundColor
}
let emptyView = EmptyView()

// MARK: - property

Expand Down Expand Up @@ -68,7 +67,7 @@ final class FeedListView: UIView, BaseViewType {
// MARK: - base func

func setupLayout() {
addSubviews(borderLineView, listCollectionView, emptyView)
addSubviews(borderLineView, listCollectionView)

borderLineView.snp.makeConstraints {
$0.top.leading.trailing.equalToSuperview()
Expand All @@ -79,11 +78,6 @@ final class FeedListView: UIView, BaseViewType {
$0.top.equalTo(borderLineView.snp.bottom)
$0.leading.trailing.bottom.equalToSuperview()
}

emptyView.snp.makeConstraints {
$0.top.equalTo(borderLineView.snp.bottom)
$0.leading.trailing.bottom.equalToSuperview()
}
}

func configureUI() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class MapViewController: UIViewController, Navigationable, Optionable {
private func transformedOutput() -> MapViewModel.Output {
let input = MapViewModel.Input(
customLocation: self.customLocationPublisher.eraseToAnyPublisher(),
scrolledToBottom: self.feedListView.listCollectionView.scrolledToBottomPublisher.eraseToAnyPublisher(),
scrolledToBottom: self.feedListView.collectionView().scrolledToBottomPublisher.eraseToAnyPublisher(),
refreshControl: self.feedListView.refreshPublisher.eraseToAnyPublisher()
)

Expand Down Expand Up @@ -373,7 +373,6 @@ extension MapViewController {
self.snapshot.deleteItems(previousReviewsData)
self.snapshot.appendItems(items, toSection: .main)
self.dataSource.applySnapshotUsingReloadData(self.snapshot)
self.feedListView.emptyView.isHidden = !items.isEmpty
}

private func loadMoreReviews(_ items: [Review]) {
Expand All @@ -384,9 +383,6 @@ extension MapViewController {
private func updateBookmark(_ storeId: Int) {
let previousReviewsData = self.snapshot.itemIdentifiers(inSection: .main)
let items = previousReviewsData
// .filter { customItem in
// return customItem.store.id == storeId
// }
.map { customItem in
var updatedItem = customItem
if customItem.store.id == storeId {
Expand Down Expand Up @@ -508,15 +504,13 @@ extension MapViewController {
grabbarView.showResult()
feedListView.listCollectionView.isHidden = true
feedListView.borderLineView.isHidden = true
feedListView.emptyView.isHidden = true
tabBarController?.tabBar.frame.origin = CGPoint(x: 0, y: UIScreen.main.bounds.maxY)
}

func modalMidState() {
grabbarView.showContent()
feedListView.listCollectionView.isHidden = false
feedListView.borderLineView.isHidden = false
feedListView.emptyView.isHidden = !self.snapshot.itemIdentifiers(inSection: .main).isEmpty
tabBarController?.tabBar.frame.origin = CGPoint(x: 0, y: UIScreen.main.bounds.maxY - tabBarHeight)
grabbarView.layer.cornerRadius = 15
}
Expand Down
Loading

0 comments on commit 1fe56c7

Please sign in to comment.