Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions iBox/Sources/Base/BaseBottomSheetViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ class BaseBottomSheetViewController<View: BaseView>: 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) {
Expand Down Expand Up @@ -58,6 +64,7 @@ class BaseBottomSheetViewController<View: BaseView>: UIViewController {
private func configureUI() {
view.addSubview(dimmedView)
view.addSubview(sheetView)
sheetView.addSubview(indicator)

dimmedView.snp.makeConstraints {
$0.edges.equalToSuperview()
Expand All @@ -68,6 +75,13 @@ class BaseBottomSheetViewController<View: BaseView>: 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
Expand Down
26 changes: 22 additions & 4 deletions iBox/Sources/Base/BaseNavigationBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class NavigationBar: UIView {
var backButton = UIButton()
var titleLabel = UILabel()
var addButton = UIButton()
var moreButton = UIButton()
}

protocol BaseNavigationBarViewControllerProtocol {
Expand All @@ -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?)
Expand All @@ -45,6 +47,9 @@ class BaseNavigationBarViewController<View: BaseView>: 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()
Expand Down Expand Up @@ -76,6 +81,7 @@ class BaseNavigationBarViewController<View: BaseView>: UIViewController, BaseNav
func setNavigationBarTintColor(_ color: UIColor) {
navigationBar.backButton.tintColor = color
navigationBar.addButton.tintColor = color
navigationBar.moreButton.tintColor = color
}

func setNavigationBarHidden(_ hidden: Bool) {
Expand Down Expand Up @@ -111,14 +117,19 @@ class BaseNavigationBarViewController<View: BaseView>: 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
}
Expand All @@ -140,6 +151,7 @@ class BaseNavigationBarViewController<View: BaseView>: UIViewController, BaseNav
navigationBar.addSubview(navigationBar.backButton)
navigationBar.addSubview(navigationBar.titleLabel)
navigationBar.addSubview(navigationBar.addButton)
navigationBar.addSubview(navigationBar.moreButton)
view.addSubview(contentView)

statusBar.snp.makeConstraints {
Expand All @@ -163,12 +175,18 @@ class BaseNavigationBarViewController<View: BaseView>: 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()
Expand All @@ -182,7 +200,7 @@ class BaseNavigationBarViewController<View: BaseView>: UIViewController, BaseNav
setNavigationBarTintColor(tintColor)
setNavigationBarTitleLabelFont(titleFont)
setNavigationBarBackButtonHidden(true)
setNavigationBarAddButtonHidden(true)
setNavigationBarMenuButtonHidden(true)

navigationBar.backButton.addTarget(self, action: #selector(backButtonTapped), for: .touchUpInside)
}
Expand Down
19 changes: 0 additions & 19 deletions iBox/Sources/Base/BaseViewController.swift

This file was deleted.

19 changes: 19 additions & 0 deletions iBox/Sources/Model/EditItem.swift
Original file line number Diff line number Diff line change
@@ -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
}
1 change: 1 addition & 0 deletions iBox/Sources/Presenter/BoxList/BoxListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import SnapKit

protocol BoxListViewDelegate: AnyObject {
func didSelectWeb(at url: URL, withName name: String)
func pushViewController(type: EditType)
}

class BoxListView: BaseView {
Expand Down
20 changes: 18 additions & 2 deletions iBox/Sources/Presenter/BoxList/BoxListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,21 @@ class BoxListViewController: BaseNavigationBarViewController<BoxListView> {

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)
}

}

Expand All @@ -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)
}
}
}
71 changes: 71 additions & 0 deletions iBox/Sources/Presenter/BoxList/Edit/EditCell.swift
Original file line number Diff line number Diff line change
@@ -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
}

}
87 changes: 87 additions & 0 deletions iBox/Sources/Presenter/BoxList/Edit/EditView.swift
Original file line number Diff line number Diff line change
@@ -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
}

}
Loading