-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #226 from PLUB2022/feat/130-MyPage/Setting
[FEAT] 설정 UI 작업
- Loading branch information
Showing
9 changed files
with
328 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
PLUB/Assets.xcassets/MyPage/arrowRightGray.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "arrowRightGray.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+278 Bytes
PLUB/Assets.xcassets/MyPage/arrowRightGray.imageset/arrowRightGray.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+342 Bytes
PLUB/Assets.xcassets/MyPage/arrowRightGray.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+427 Bytes
PLUB/Assets.xcassets/MyPage/arrowRightGray.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
PLUB/Sources/Views/MyPage/Setting/Component/SettingDetailSubView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// | ||
// SettingDetailSubView.swift | ||
// PLUB | ||
// | ||
// Created by 김수빈 on 2023/03/19. | ||
// | ||
|
||
import UIKit | ||
|
||
import SnapKit | ||
import RxCocoa | ||
import RxSwift | ||
|
||
final class SettingDetailSubView: UIView { | ||
private let label = UILabel().then { | ||
$0.font = .body1 | ||
$0.textColor = .black | ||
} | ||
|
||
private let arrowImageView = UIImageView().then { | ||
$0.image = UIImage(named: "arrowRightGray") | ||
} | ||
|
||
private let lineView = UIView().then { | ||
$0.backgroundColor = .lightGray | ||
} | ||
|
||
init(_ title: String, isLast: Bool = false) { | ||
label.text = title | ||
super.init(frame: .zero) | ||
setupLayouts(isLast: isLast) | ||
setupConstraints(isLast: isLast) | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
private func setupLayouts(isLast: Bool) { | ||
[label, arrowImageView].forEach { | ||
addSubview($0) | ||
} | ||
|
||
if !isLast { | ||
addSubview(lineView) | ||
} | ||
} | ||
|
||
private func setupConstraints(isLast: Bool) { | ||
label.snp.makeConstraints { | ||
$0.leading.equalToSuperview().inset(12) | ||
$0.centerY.equalToSuperview() | ||
$0.height.equalTo(21) | ||
$0.top.bottom.equalToSuperview().inset(8) | ||
} | ||
|
||
arrowImageView.snp.makeConstraints { | ||
$0.trailing.equalToSuperview().inset(12) | ||
$0.centerY.equalToSuperview() | ||
$0.size.equalTo(20) | ||
} | ||
|
||
if !isLast { | ||
lineView.snp.makeConstraints { | ||
$0.leading.trailing.equalToSuperview().inset(10) | ||
$0.bottom.equalToSuperview() | ||
$0.height.equalTo(1) | ||
} | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
PLUB/Sources/Views/MyPage/Setting/Component/SettingSubview.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// SettingSubview.swift | ||
// PLUB | ||
// | ||
// Created by 김수빈 on 2023/03/19. | ||
// | ||
|
||
import UIKit | ||
|
||
import SnapKit | ||
import RxCocoa | ||
import RxSwift | ||
|
||
final class SettingSubview: UIView { | ||
private let label = UILabel().then { | ||
$0.font = .appFont(family: .pretendard(option: .bold), size: 18) | ||
$0.textColor = .black | ||
} | ||
|
||
init(_ title: String) { | ||
label.text = title | ||
super.init(frame: .zero) | ||
setupLayouts() | ||
setupConstraints() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
private func setupLayouts() { | ||
addSubview(label) | ||
} | ||
|
||
private func setupConstraints() { | ||
label.snp.makeConstraints { | ||
$0.leading.equalToSuperview().inset(12) | ||
$0.centerY.equalToSuperview() | ||
$0.height.equalTo(21) | ||
$0.top.equalToSuperview().inset(19) | ||
$0.bottom.equalToSuperview().inset(10) | ||
} | ||
} | ||
} |
156 changes: 156 additions & 0 deletions
156
PLUB/Sources/Views/MyPage/Setting/SettingViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
// | ||
// SettingViewController.swift | ||
// PLUB | ||
// | ||
// Created by 김수빈 on 2023/03/19. | ||
// | ||
|
||
import UIKit | ||
|
||
import RxSwift | ||
import RxCocoa | ||
|
||
enum SettingType: String, CaseIterable { | ||
case use = "PLUB 이용" | ||
case account = "계정" | ||
case version = "버전" | ||
} | ||
|
||
enum SettingUseType: String, CaseIterable { | ||
case notice = "공지사항" | ||
case email = "이메일로 문의하기" | ||
case qna = "Q&A" | ||
case alarm = "알림 설정" | ||
} | ||
|
||
enum SettingAccountType: String, CaseIterable { | ||
case logout = "로그아웃" | ||
case inactive = "비활성화" | ||
case withdraw = "탈퇴" | ||
} | ||
|
||
enum SettingVersionType: String, CaseIterable { | ||
case termsOfService = "서비스 이용 약관" | ||
case privacyPolicy = "개인정보 처리 방침" | ||
} | ||
|
||
final class SettingViewController: BaseViewController { | ||
|
||
private let scrollView = UIScrollView().then { | ||
$0.bounces = false | ||
$0.showsVerticalScrollIndicator = false | ||
} | ||
|
||
private let contentStackView = UIStackView().then { | ||
$0.axis = .vertical | ||
$0.spacing = 16 | ||
$0.isLayoutMarginsRelativeArrangement = true | ||
$0.layoutMargins = .init(top: 15, left: 0, bottom: 15, right: 0) | ||
} | ||
|
||
private let titleLabel = UILabel().then { | ||
$0.text = "설정" | ||
$0.font = .h2 | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
} | ||
|
||
override func setupLayouts() { | ||
super.setupLayouts() | ||
[scrollView].forEach { | ||
view.addSubview($0) | ||
} | ||
scrollView.addSubview(contentStackView) | ||
|
||
contentStackView.addArrangedSubview(titleLabel) | ||
|
||
SettingType.allCases.forEach { | ||
let subStackView = UIStackView().then { | ||
$0.axis = .vertical | ||
$0.spacing = 0 | ||
$0.layer.cornerRadius = 10 | ||
$0.backgroundColor = .white | ||
} | ||
contentStackView.addArrangedSubview(subStackView) | ||
|
||
let subView = SettingSubview($0.rawValue) | ||
subStackView.addArrangedSubview(subView) | ||
subView.snp.makeConstraints { | ||
$0.height.equalTo(50) | ||
} | ||
|
||
addSubViews(stackView: subStackView, type: $0) | ||
} | ||
} | ||
|
||
override func setupConstraints() { | ||
super.setupConstraints() | ||
|
||
scrollView.snp.makeConstraints { | ||
$0.leading.trailing.equalToSuperview().inset(16) | ||
$0.top.equalToSuperview() | ||
$0.bottom.equalTo(view.safeAreaLayoutGuide) | ||
} | ||
|
||
contentStackView.snp.makeConstraints { | ||
$0.directionalEdges.equalToSuperview() | ||
$0.width.equalTo(scrollView.snp.width) | ||
} | ||
|
||
titleLabel.snp.makeConstraints { | ||
$0.height.equalTo(33) | ||
} | ||
|
||
contentStackView.setCustomSpacing(32, after: titleLabel) | ||
} | ||
|
||
override func setupStyles() { | ||
super.setupStyles() | ||
setupNavigationBar() | ||
} | ||
|
||
private func addSubViews(stackView: UIStackView, type: SettingType) { | ||
switch type { | ||
case .use: | ||
SettingUseType.allCases.forEach { | ||
let detailSubview = SettingDetailSubView($0.rawValue) | ||
stackView.addArrangedSubview(detailSubview) | ||
detailSubview.snp.makeConstraints { | ||
$0.height.equalTo(52) | ||
} | ||
} | ||
case .account: | ||
SettingAccountType.allCases.forEach { | ||
let detailSubview = SettingDetailSubView($0.rawValue) | ||
stackView.addArrangedSubview(detailSubview) | ||
detailSubview.snp.makeConstraints { | ||
$0.height.equalTo(52) | ||
} | ||
} | ||
case .version: | ||
SettingVersionType.allCases.forEach { | ||
let detailSubview = SettingDetailSubView($0.rawValue) | ||
stackView.addArrangedSubview(detailSubview) | ||
detailSubview.snp.makeConstraints { | ||
$0.height.equalTo(52) | ||
} | ||
} | ||
} | ||
} | ||
|
||
private func setupNavigationBar() { | ||
navigationItem.leftBarButtonItem = UIBarButtonItem( | ||
image: UIImage(named: "backButton"), | ||
style: .plain, | ||
target: self, | ||
action: #selector(didTappedBackButton) | ||
) | ||
} | ||
|
||
@objc | ||
private func didTappedBackButton() { | ||
navigationController?.popViewController(animated: true) | ||
} | ||
} |