Skip to content

Commit

Permalink
Refactor [#269] 불필요한 코드 삭제 및 BaseVC, BaseView로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
chaentopia committed Oct 25, 2023
1 parent 299de27 commit ba5643a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ final class FriendProfileView: BaseView {
// MARK: - Variables
// MARK: Component
weak var handleBottomSheetButtonDelegate: HandleBottomSheetButtonDelegate?

// var indexNumber: Int = -1
weak var handleDeleteFriendButtonDelegate: HandleDeleteFriendButtonDelegate?

private let profileImageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 72.adjusted, height: 72.adjusted))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ extension MyProfileHeaderView {
self.friendCountView.friendCountLabel.text = String(data.friendCount) + ""
self.friendCountView.friendCountLabel.asColor(targetString: "", color: .grayscales500)


Amplitude.instance().setUserProperties(["user_friends": data.friendCount,
"user_message_received": data.yelloCount,
"user_name": data.name])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ import Amplitude
import SnapKit
import Then

final class MyProfileView: UIView {
final class MyProfileView: BaseView {

// MARK: - Variables
// MARK: Component
let mainProfileView = UIView()

let profileImageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 48
.adjusted, height: 48.adjusted))
let profileStarGradientView = UIView(frame: CGRect(x: 0, y: 0, width: 344.adjusted, height: 6.adjustedHeight))
Expand All @@ -33,7 +32,6 @@ final class MyProfileView: UIView {
private let addGroupButton = UIButton(frame: CGRect(x: 0, y: 0, width: 129.adjustedWidth, height: 48.adjustedHeight))
lazy var shopButton = UIButton(frame: CGRect(x: 0, y: 0, width: 202.adjustedWidth, height: 44.adjustedHeight))
let shopBackgroundView = UIView(frame: CGRect(x: 0, y: 0, width: 206.adjustedWidth, height: 48.adjustedHeight))

let nameSkeletonLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 66.adjustedWidth, height: 16.adjustedHeight))
let schoolSkeletonLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 66.adjustedWidth, height: 16.adjustedHeight))

Expand All @@ -44,29 +42,8 @@ final class MyProfileView: UIView {
}
}

// MARK: - Function
// MARK: LifeCycle
override init(frame: CGRect) {
super.init(frame: frame)
setUI()
}

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

// MARK: - extension
extension MyProfileView {

// MARK: Layout Helpers
private func setUI() {
setStyle()
setLayout()
}

private func setStyle() {
override func setStyle() {

mainProfileView.do {
$0.backgroundColor = .grayscales900
Expand Down Expand Up @@ -171,11 +148,10 @@ extension MyProfileView {
$0.makeCornerRound(radius: 2.adjustedHeight)
$0.isHidden = true
}

updateProfileView()
}

private func setLayout() {
override func setLayout() {
self.addSubviews(
mainProfileView,
profileStarGradientView,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protocol NavigationBarViewDelegate: AnyObject {
func settingButtonTapped()
}

final class NavigationBarView: UIView {
final class NavigationBarView: BaseView {

// MARK: - Variables
// MARK: Property
Expand All @@ -25,34 +25,8 @@ final class NavigationBarView: UIView {
private let profileLabel = UILabel()
lazy var settingButton = UIButton()

// MARK: - Function
// MARK: LifeCycle
override init(frame: CGRect) {
super.init(frame: frame)
setUI()
}

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

// MARK: - extension
extension NavigationBarView {

// MARK: Objc Function
@objc private func settingButtonTapped() {
delegate?.settingButtonTapped()
}

// MARK: Layout Helpers
private func setUI() {
setStyle()
setLayout()
}

private func setStyle() {
override func setStyle() {
self.backgroundColor = .black

profileLabel.do {
Expand All @@ -69,16 +43,10 @@ extension NavigationBarView {
}
}

private func setLayout() {
override func setLayout() {
self.addSubviews(profileLabel,
settingButton)

let statusBarHeight = UIApplication.shared.connectedScenes
.compactMap { $0 as? UIWindowScene }
.first?
.statusBarManager?
.statusBarFrame.height ?? 20

profileLabel.snp.makeConstraints {
$0.centerY.equalToSuperview()
$0.leading.equalToSuperview().offset(16.adjustedWidth)
Expand All @@ -91,4 +59,9 @@ extension NavigationBarView {
$0.height.equalTo(28.adjustedHeight)
}
}

// MARK: Objc Function
@objc private func settingButtonTapped() {
delegate?.settingButtonTapped()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protocol HandleFriendCellDelegate: AnyObject {
func presentModal(index: Int)
}

final class ProfileView: UIView {
final class ProfileView: BaseView {

// MARK: - Variables
// MARK: Property
Expand Down Expand Up @@ -52,26 +52,10 @@ final class ProfileView: UIView {
// MARK: LifeCycle
override init(frame: CGRect) {
super.init(frame: frame)
setUI()
setDelegate()
}

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

// MARK: - extension
extension ProfileView {

// MARK: Layout Helpers
private func setUI() {
setStyle()
setLayout()
}

private func setStyle() {
override func setStyle() {
self.backgroundColor = .black

refreshControl.do {
Expand Down Expand Up @@ -105,7 +89,7 @@ extension ProfileView {
}
}

private func setLayout() {
override func setLayout() {
self.addSubviews(navigationBarView,
myFriendTableView,
topButton)
Expand Down

0 comments on commit ba5643a

Please sign in to comment.