Skip to content

Commit

Permalink
[Feat] 마이페이지 UI구현 #8
Browse files Browse the repository at this point in the history
  • Loading branch information
meltsplit committed Apr 28, 2023
1 parent 0b08662 commit d532961
Show file tree
Hide file tree
Showing 8 changed files with 309 additions and 9 deletions.
33 changes: 33 additions & 0 deletions SOPTving/SOPTving/Domain/Entity/Setting.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// Setting.swift
// SOPTving
//
// Created by 장석우 on 2023/04/29.
//

import Foundation



struct MyPageSetting {

enum UserSetting: String, CaseIterable {
case memberShip = "이용권"
case inquiryDetails = "1:1 문의내역"
case reservation = "예약알림"
case changeUserInfo = "회원정보수정"
case acceptMessages = "프로모션정보수신동의"
}

enum AppSetting: String, CaseIterable {
case notice = "공지사항"
case event = "이벤트"
case serviceCenter = "고객센터"
case more = "티빙 알아보기"
}

var userSetting = UserSetting.allCases.map { $0.rawValue }
var appSetting = AppSetting.allCases.map { $0.rawValue }
}


Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ extension MyPageProfileView {
}

nameButton.snp.makeConstraints {
$0.centerY.equalToSuperview()
$0.centerY.equalTo(profileImageView)
$0.leading.equalTo(profileImageView.snp.trailing)
}
profileChangeButton.snp.makeConstraints {
$0.centerY.equalToSuperview()
$0.centerY.equalTo(profileImageView)
$0.trailing.equalToSuperview()
$0.height.equalTo(30)
$0.width.equalTo(80)
Expand All @@ -194,6 +194,7 @@ extension MyPageProfileView {
$0.top.equalTo(profileImageView.snp.bottom).offset(20)
$0.leading.trailing.equalToSuperview()
$0.height.equalTo(100)
$0.bottom.equalToSuperview()
}

darkStackView.snp.makeConstraints {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//
// MyPageSettingFooterView.swift
// SOPTving
//
// Created by 장석우 on 2023/04/29.
//

import UIKit

final class MyPageSettingFooterView: UIView {

//MARK: - Properties

private let isLastSection: Bool

//MARK: - UI Components

private let seperatorView: UIView = {
let view = UIView()
view.backgroundColor = .tvingDarkGray
return view
}()

private let logoutButton : UIButton = {
let button = UIButton()
button.setBorder(width: 1, color: .tvingDarkGray)
button.makeCornerRound(ratio: 20)
button.setTitle("로그아웃", for: .normal)
button.setTitleColor(.tvingLightGray, for: .normal)
button.titleLabel?.font = .tvingMedium(ofSize: 14)
return button
}()

private lazy var vStackView: UIStackView = {
let stackView = UIStackView(arrangedSubviews: [seperatorView,logoutButton])
stackView.axis = .vertical
stackView.alignment = .center
return stackView
}()

//MARK: - Life Cycle


init(isLastSection: Bool) {
self.isLastSection = isLastSection
super.init(frame: .zero)

style()
hierarchy()
layout()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

//MARK: - Custom Method

private func style() {
seperatorView.isHidden = isLastSection
logoutButton.isHidden = !isLastSection
}

private func hierarchy() {
self.addSubviews(vStackView)
}

private func layout() {

vStackView.snp.makeConstraints {
$0.top.bottom.equalToSuperview().inset(20)
$0.leading.trailing.equalToSuperview()
}

seperatorView.snp.makeConstraints {
$0.width.equalToSuperview().inset(10)
$0.height.equalTo(1)
}

logoutButton.snp.makeConstraints {
$0.width.equalToSuperview()
$0.height.equalTo(54)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
//
// MyPageSettingTableViewCell.swift
// SOPTving
//
// Created by 장석우 on 2023/04/29.
//

import UIKit

final class MyPageSettingTableViewCell: UITableViewCell {

//MARK: - Properties


//MARK: - UI Components

private let titleLabel: UILabel = {
let label = UILabel()
label.textColor = .tvingLightGray
label.font = .tvingMedium(ofSize: 16)
return label
}()

private let rightImageView: UIImageView = {
let view = UIImageView()
view.image = UIImage(systemName: "chevron.right")
view.contentMode = .scaleAspectFit
view.tintColor = .tvingLightGray
return view
}()

//MARK: - Life Cycle


override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)

setUI()
hierarchy()
layout()

}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

//MARK: - Custom Method

func dataBind(_ text: String) {
titleLabel.text = text
}
}

extension MyPageSettingTableViewCell {

func setUI() {
contentView.backgroundColor = .black
}

func hierarchy() {
contentView.addSubviews(titleLabel, rightImageView)
}

func layout() {
titleLabel.snp.makeConstraints {
$0.centerY.equalToSuperview()
$0.leading.equalToSuperview().offset(10)
}

rightImageView.snp.makeConstraints {
$0.centerY.equalToSuperview()
$0.trailing.equalToSuperview().offset(-5)
$0.size.equalTo(20)
}
}

}
105 changes: 100 additions & 5 deletions SOPTving/SOPTving/Presentation/MainScene/ViewController/MyPageVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ final class MyPageVC: UIViewController {

//MARK: - Properties

private var myPageSettingData = MyPageSetting()
private let viewModel: MyPageViewModel

//MARK: - UI Components
Expand Down Expand Up @@ -45,6 +46,16 @@ final class MyPageVC: UIViewController {

private let profileView = MyPageProfileView()

private let tableView : UITableView = {
let tableView = UITableView()
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.isScrollEnabled = false
tableView.register(MyPageSettingTableViewCell.self,
forCellReuseIdentifier: MyPageSettingTableViewCell.className)
return tableView
}()


//MARK: - Life Cycle

Expand All @@ -60,7 +71,6 @@ final class MyPageVC: UIViewController {

delegate()


style()
hierarchy()
layout()
Expand All @@ -71,6 +81,13 @@ final class MyPageVC: UIViewController {

}

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
tableView.snp.updateConstraints {
$0.height.equalTo(tableView.contentSize.height)
}
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
Expand All @@ -81,7 +98,8 @@ final class MyPageVC: UIViewController {
extension MyPageVC {

private func delegate() {

tableView.delegate = self
tableView.dataSource = self
}

private func bind() {
Expand Down Expand Up @@ -114,7 +132,7 @@ extension MyPageVC {
navigationView.addSubview(backButton)

scrollView.addSubview(contentView)
contentView.addSubviews(profileView)
contentView.addSubviews(profileView,tableView)
}

private func layout() {
Expand Down Expand Up @@ -145,9 +163,86 @@ extension MyPageVC {
profileView.snp.makeConstraints {
$0.top.equalToSuperview()
$0.leading.trailing.equalToSuperview()
$0.height.equalTo(100)
$0.bottom.equalToSuperview()
}

tableView.snp.makeConstraints {
$0.top.equalTo(profileView.snp.bottom).offset(10)
$0.leading.trailing.equalToSuperview()
$0.height.equalTo(tableView.contentSize.height)
$0.bottom.equalToSuperview().offset(-30)
}


}
}

//MARK: - UITableViewDelegate

extension MyPageVC: UITableViewDelegate {

}

extension MyPageVC: UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return 2
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch section {
case 0:
return myPageSettingData.userSetting.count
case 1:
return myPageSettingData.appSetting.count
default:
return 0
}
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

guard let cell = tableView.dequeueReusableCell(withIdentifier: MyPageSettingTableViewCell.className, for: indexPath) as? MyPageSettingTableViewCell
else { return UITableViewCell()}

switch indexPath.section {
case 0:
cell.dataBind(myPageSettingData.userSetting[indexPath.row])

case 1:
cell.dataBind(myPageSettingData.appSetting[indexPath.row])
default:
fatalError("\(#function)에서 에러가 발생했습니다.")
}
return cell
}

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 54
}
}

extension MyPageVC {

func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
switch section {
case 0:
return MyPageSettingFooterView(isLastSection: false).intrinsicContentSize.height
case 1:
return MyPageSettingFooterView(isLastSection: true).intrinsicContentSize.height
default:
return 0

}
}

func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {

switch section {
case 0:
return MyPageSettingFooterView(isLastSection: false)
case 1:
return MyPageSettingFooterView(isLastSection: true)
default:
return nil
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ final class DefaultMyPageViewModel: MyPageViewModel {

private var profileData: MyProfile



//MARK: - Output


Expand All @@ -35,10 +37,9 @@ final class DefaultMyPageViewModel: MyPageViewModel {
self.profileData = profileData
}



//MARK: - Private


}

//MARK: - Input, Event
Expand Down
Loading

0 comments on commit d532961

Please sign in to comment.