diff --git a/iBox/Sources/Base/BaseBottomSheetViewController.swift b/iBox/Sources/Base/BaseBottomSheetViewController.swift index ff14c1c..a045b2a 100644 --- a/iBox/Sources/Base/BaseBottomSheetViewController.swift +++ b/iBox/Sources/Base/BaseBottomSheetViewController.swift @@ -28,6 +28,12 @@ class BaseBottomSheetViewController: UIViewController { $0.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner] // 왼쪽 위, 오른쪽 위 둥글게 } + let indicator = UIView().then { + $0.clipsToBounds = true + $0.layer.cornerRadius = 2 + $0.backgroundColor = .darkGray + } + // MARK: - initializer init(bottomSheetHeight: CGFloat) { @@ -58,6 +64,7 @@ class BaseBottomSheetViewController: UIViewController { private func configureUI() { view.addSubview(dimmedView) view.addSubview(sheetView) + sheetView.addSubview(indicator) dimmedView.snp.makeConstraints { $0.edges.equalToSuperview() @@ -68,6 +75,13 @@ class BaseBottomSheetViewController: UIViewController { $0.left.right.equalToSuperview() $0.height.equalTo(bottomSheetHeight) } + + indicator.snp.makeConstraints { + $0.width.equalTo(40) + $0.height.equalTo(4) + $0.top.equalToSuperview().inset(10) + $0.centerX.equalToSuperview() + } } // MARK: - functions diff --git a/iBox/Sources/Base/BaseNavigationBarViewController.swift b/iBox/Sources/Base/BaseNavigationBarViewController.swift index 39fd7b2..e47308e 100644 --- a/iBox/Sources/Base/BaseNavigationBarViewController.swift +++ b/iBox/Sources/Base/BaseNavigationBarViewController.swift @@ -13,6 +13,7 @@ class NavigationBar: UIView { var backButton = UIButton() var titleLabel = UILabel() var addButton = UIButton() + var moreButton = UIButton() } protocol BaseNavigationBarViewControllerProtocol { @@ -25,8 +26,9 @@ protocol BaseNavigationBarViewControllerProtocol { func setNavigationBarTintColor(_ color: UIColor) func setNavigationBarHidden(_ hidden: Bool) func setNavigationBarBackButtonHidden(_ hidden: Bool) - func setNavigationBarAddButtonHidden(_ hidden: Bool) + func setNavigationBarMenuButtonHidden(_ hidden: Bool) func setNavigationBarAddButtonAction(_ selector: Selector) + func setNavigationBarMoreButtonAction(_ selector: Selector) func setNavigationBarTitleLabelText(_ text: String?) func setNavigationBarTitleLabelFont(_ font: UIFont?) func setNavigationBarTitleLabelTextColor(_ color: UIColor?) @@ -45,6 +47,9 @@ class BaseNavigationBarViewController: UIViewController, BaseNav $0.addButton.configuration = .plain() $0.addButton.configuration?.image = UIImage(systemName: "plus") $0.addButton.configuration?.preferredSymbolConfigurationForImage = .init(weight: .bold) + $0.moreButton.configuration = .plain() + $0.moreButton.configuration?.image = UIImage(systemName: "ellipsis.circle") + $0.moreButton.configuration?.preferredSymbolConfigurationForImage = .init(weight: .bold) } let contentView: BaseView = View() @@ -76,6 +81,7 @@ class BaseNavigationBarViewController: UIViewController, BaseNav func setNavigationBarTintColor(_ color: UIColor) { navigationBar.backButton.tintColor = color navigationBar.addButton.tintColor = color + navigationBar.moreButton.tintColor = color } func setNavigationBarHidden(_ hidden: Bool) { @@ -111,14 +117,19 @@ class BaseNavigationBarViewController: UIViewController, BaseNav } } - func setNavigationBarAddButtonHidden(_ hidden: Bool) { + func setNavigationBarMenuButtonHidden(_ hidden: Bool) { navigationBar.addButton.isHidden = hidden + navigationBar.moreButton.isHidden = hidden } func setNavigationBarAddButtonAction(_ selector: Selector) { navigationBar.addButton.addTarget(self, action: selector, for: .touchUpInside) } + func setNavigationBarMoreButtonAction(_ selector: Selector) { + navigationBar.moreButton.addTarget(self, action: selector, for: .touchUpInside) + } + func setNavigationBarTitleLabelText(_ text: String?) { navigationBar.titleLabel.text = text } @@ -140,6 +151,7 @@ class BaseNavigationBarViewController: UIViewController, BaseNav navigationBar.addSubview(navigationBar.backButton) navigationBar.addSubview(navigationBar.titleLabel) navigationBar.addSubview(navigationBar.addButton) + navigationBar.addSubview(navigationBar.moreButton) view.addSubview(contentView) statusBar.snp.makeConstraints { @@ -163,12 +175,18 @@ class BaseNavigationBarViewController: UIViewController, BaseNav $0.center.equalToSuperview() } - navigationBar.addButton.snp.makeConstraints { + navigationBar.moreButton.snp.makeConstraints { $0.right.equalToSuperview().inset(20) $0.centerY.equalToSuperview() $0.width.height.equalTo(24) } + navigationBar.addButton.snp.makeConstraints { + $0.right.equalTo(navigationBar.moreButton.snp.left).offset(-20) + $0.centerY.equalToSuperview() + $0.width.height.equalTo(24) + } + contentView.snp.makeConstraints { $0.top.equalTo(statusBar.snp.bottom).offset(60) $0.left.right.equalToSuperview() @@ -182,7 +200,7 @@ class BaseNavigationBarViewController: UIViewController, BaseNav setNavigationBarTintColor(tintColor) setNavigationBarTitleLabelFont(titleFont) setNavigationBarBackButtonHidden(true) - setNavigationBarAddButtonHidden(true) + setNavigationBarMenuButtonHidden(true) navigationBar.backButton.addTarget(self, action: #selector(backButtonTapped), for: .touchUpInside) } diff --git a/iBox/Sources/Base/BaseViewController.swift b/iBox/Sources/Base/BaseViewController.swift deleted file mode 100644 index c4be0a0..0000000 --- a/iBox/Sources/Base/BaseViewController.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// BaseViewController.swift -// iBox -// -// Created by jiyeon on 12/26/23. -// - -import UIKit - -class BaseViewController: UIViewController { - - let baseView = View(frame: UIScreen.main.bounds) - - override func viewDidLoad() { - super.viewDidLoad() - view.addSubview(baseView) - } - -} diff --git a/iBox/Sources/Model/EditItem.swift b/iBox/Sources/Model/EditItem.swift new file mode 100644 index 0000000..83f5689 --- /dev/null +++ b/iBox/Sources/Model/EditItem.swift @@ -0,0 +1,19 @@ +// +// EditItem.swift +// iBox +// +// Created by jiyeon on 2/29/24. +// + +import Foundation + +enum EditType { + case folder + case bookmark +} + +struct EditItem { + var type: EditType + var imageString: String + var title: String +} diff --git a/iBox/Sources/Presenter/BoxList/BoxListView.swift b/iBox/Sources/Presenter/BoxList/BoxListView.swift index 1850bf2..de27c07 100644 --- a/iBox/Sources/Presenter/BoxList/BoxListView.swift +++ b/iBox/Sources/Presenter/BoxList/BoxListView.swift @@ -12,6 +12,7 @@ import SnapKit protocol BoxListViewDelegate: AnyObject { func didSelectWeb(at url: URL, withName name: String) + func pushViewController(type: EditType) } class BoxListView: BaseView { diff --git a/iBox/Sources/Presenter/BoxList/BoxListViewController.swift b/iBox/Sources/Presenter/BoxList/BoxListViewController.swift index b1cb49d..014cd0e 100644 --- a/iBox/Sources/Presenter/BoxList/BoxListViewController.swift +++ b/iBox/Sources/Presenter/BoxList/BoxListViewController.swift @@ -19,14 +19,21 @@ class BoxListViewController: BaseNavigationBarViewController { override func setupNavigationBar() { setNavigationBarTitleLabelText("iBox") - setNavigationBarAddButtonHidden(false) + setNavigationBarMenuButtonHidden(false) setNavigationBarAddButtonAction(#selector(addButtonTapped)) + setNavigationBarMoreButtonAction(#selector(moreButtonTapped)) } - @objc private func addButtonTapped(_ sender: Any?) { + @objc private func addButtonTapped() { let addBookmarkBottomSheetViewController = AddBookmarkBottomSheetViewController(bottomSheetHeight: 200) present(addBookmarkBottomSheetViewController, animated: false) } + + @objc private func moreButtonTapped() { + let editViewController = EditViewController(bottomSheetHeight: 200) + editViewController.delegate = self + present(editViewController, animated: false) + } } @@ -36,4 +43,13 @@ extension BoxListViewController: BoxListViewDelegate { viewController.title = name navigationController?.pushViewController(viewController, animated: true) } + + func pushViewController(type: EditType) { + switch type { + case .folder: + navigationController?.pushViewController(EditFolderViewController(), animated: true) + case .bookmark: + navigationController?.pushViewController(EditBookmarkViewController(), animated: true) + } + } } diff --git a/iBox/Sources/Presenter/BoxList/Edit/EditCell.swift b/iBox/Sources/Presenter/BoxList/Edit/EditCell.swift new file mode 100644 index 0000000..8bfeeaa --- /dev/null +++ b/iBox/Sources/Presenter/BoxList/Edit/EditCell.swift @@ -0,0 +1,71 @@ +// +// EditCell.swift +// iBox +// +// Created by jiyeon on 2/29/24. +// + +import UIKit + +import SnapKit + +class EditCell: UITableViewCell { + + static let reuseIdentifier = "EditCell" + + // MARK: - UI Components + + private let iconView = UIImageView().then { + $0.tintColor = .label + } + + private let titleLabel = UILabel().then { + $0.textColor = .label + } + + // MARK: - Initializer + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + setupProperty() + setupHierarchy() + setupLayout() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + // MARK: - Setup Methods + + private func setupProperty() { + selectionStyle = .none + backgroundColor = .clear + } + + private func setupHierarchy() { + addSubview(iconView) + addSubview(titleLabel) + } + + private func setupLayout() { + iconView.snp.makeConstraints { make in + make.width.height.equalTo(20) + make.leading.equalToSuperview().inset(30) + make.centerY.equalToSuperview() + } + + titleLabel.snp.makeConstraints{ make in + make.leading.equalTo(iconView.snp.trailing).offset(20) + make.centerY.equalToSuperview() + } + } + + // MARK: - Bind + + func bind(_ editItem: EditItem) { + iconView.image = UIImage(systemName: editItem.imageString) + titleLabel.text = editItem.title + } + +} diff --git a/iBox/Sources/Presenter/BoxList/Edit/EditView.swift b/iBox/Sources/Presenter/BoxList/Edit/EditView.swift new file mode 100644 index 0000000..3a811d9 --- /dev/null +++ b/iBox/Sources/Presenter/BoxList/Edit/EditView.swift @@ -0,0 +1,87 @@ +// +// EditView.swift +// iBox +// +// Created by jiyeon on 2/29/24. +// + +import UIKit + +import SnapKit + +class EditView: BaseView { + + var delegate: EditViewDelegate? + + private let editItems = [ + EditItem(type: .folder, imageString: "folder.fill", title: "폴더 편집"), + EditItem(type: .bookmark, imageString: "bookmark.fill", title: "북마크 편집") + ] + + // MARK: - UI Components + + let tableView = UITableView().then { + $0.backgroundColor = .clear + $0.register(EditCell.self, forCellReuseIdentifier: EditCell.reuseIdentifier) + $0.separatorStyle = .none + } + + // MARK: - Initializer + + override init(frame: CGRect) { + super.init(frame: frame) + setupProperty() + setupHierarchy() + setupLayout() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + // MARK: - Setup Methods + + private func setupProperty() { + backgroundColor = .backgroundColor + tableView.delegate = self + tableView.dataSource = self + } + + private func setupHierarchy() { + addSubview(tableView) + } + + private func setupLayout() { + tableView.snp.makeConstraints { make in + make.top.equalToSuperview().inset(40) + make.leading.bottom.trailing.equalToSuperview() + } + } + +} + +extension EditView: UITableViewDelegate { + + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + return 55 + } + + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + delegate?.pushViewController(type: editItems[indexPath.row].type) + } + +} + +extension EditView: UITableViewDataSource { + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return editItems.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + guard let cell = tableView.dequeueReusableCell(withIdentifier: EditCell.reuseIdentifier) as? EditCell else { return UITableViewCell() } + cell.bind(editItems[indexPath.row]) + return cell + } + +} diff --git a/iBox/Sources/Presenter/BoxList/Edit/EditViewController.swift b/iBox/Sources/Presenter/BoxList/Edit/EditViewController.swift new file mode 100644 index 0000000..b5ae2f5 --- /dev/null +++ b/iBox/Sources/Presenter/BoxList/Edit/EditViewController.swift @@ -0,0 +1,32 @@ +// +// EditViewController.swift +// iBox +// +// Created by jiyeon on 2/29/24. +// + +import UIKit + +protocol EditViewDelegate { + func pushViewController(type: EditType) +} + +class EditViewController: BaseBottomSheetViewController { + + var delegate: BoxListViewDelegate? + + override func viewDidLoad() { + super.viewDidLoad() + sheetView.delegate = self + } + +} + +extension EditViewController: EditViewDelegate { + + func pushViewController(type: EditType) { + delegate?.pushViewController(type: type) + dismiss(animated: false) + } + +} diff --git a/iBox/Sources/Presenter/BoxList/EditBookmark/EditBookmarkView.swift b/iBox/Sources/Presenter/BoxList/EditBookmark/EditBookmarkView.swift new file mode 100644 index 0000000..acefeca --- /dev/null +++ b/iBox/Sources/Presenter/BoxList/EditBookmark/EditBookmarkView.swift @@ -0,0 +1,12 @@ +// +// EditBookmarkView.swift +// iBox +// +// Created by jiyeon on 2/29/24. +// + +import UIKit + +class EditBookmarkView: BaseView { + +} diff --git a/iBox/Sources/Presenter/BoxList/EditBookmark/EditBookmarkViewController.swift b/iBox/Sources/Presenter/BoxList/EditBookmark/EditBookmarkViewController.swift new file mode 100644 index 0000000..0717815 --- /dev/null +++ b/iBox/Sources/Presenter/BoxList/EditBookmark/EditBookmarkViewController.swift @@ -0,0 +1,27 @@ +// +// EditBookmarkViewController.swift +// iBox +// +// Created by jiyeon on 2/29/24. +// + +import UIKit + +class EditBookmarkViewController: BaseNavigationBarViewController { + + // MARK: - Life Cycle + + override func viewDidLoad() { + super.viewDidLoad() + setupNavigationBar() + } + + // MARK: - BaseNavigationBarViewControllerProtocol + + override func setupNavigationBar() { + setNavigationBarTitleLabelText("북마크 편집") + setNavigationBarTitleLabelFont(.systemFont(ofSize: 17, weight: .semibold)) + setNavigationBarBackButtonHidden(false) + } + +} diff --git a/iBox/Sources/Presenter/BoxList/EditFolder/EditFolderView.swift b/iBox/Sources/Presenter/BoxList/EditFolder/EditFolderView.swift new file mode 100644 index 0000000..f88fdb0 --- /dev/null +++ b/iBox/Sources/Presenter/BoxList/EditFolder/EditFolderView.swift @@ -0,0 +1,12 @@ +// +// EditFolderView.swift +// iBox +// +// Created by jiyeon on 2/29/24. +// + +import UIKit + +class EditFolderView: BaseView { + +} diff --git a/iBox/Sources/Presenter/BoxList/EditFolder/EditFolderViewController.swift b/iBox/Sources/Presenter/BoxList/EditFolder/EditFolderViewController.swift new file mode 100644 index 0000000..4160dc7 --- /dev/null +++ b/iBox/Sources/Presenter/BoxList/EditFolder/EditFolderViewController.swift @@ -0,0 +1,27 @@ +// +// EditFolderViewController.swift +// iBox +// +// Created by jiyeon on 2/29/24. +// + +import UIKit + +class EditFolderViewController: BaseNavigationBarViewController { + + // MARK: - Life Cycle + + override func viewDidLoad() { + super.viewDidLoad() + setupNavigationBar() + } + + // MARK: - BaseNavigationBarViewControllerProtocol + + override func setupNavigationBar() { + setNavigationBarTitleLabelText("폴더 편집") + setNavigationBarTitleLabelFont(.systemFont(ofSize: 17, weight: .semibold)) + setNavigationBarBackButtonHidden(false) + } + +}