Skip to content

Commit

Permalink
feat(DesignSystem): Add a NofficeList component
Browse files Browse the repository at this point in the history
  • Loading branch information
dodo849 committed Jul 15, 2024
1 parent 24b899d commit 1dc9d2c
Show file tree
Hide file tree
Showing 5 changed files with 255 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
//
// NofficeList.swift
// DesignSystem
//
// Created by DOYEON LEE on 7/16/24.
//

import UIKit

import Assets

import RxSwift
import RxCocoa
import SnapKit
import Then

public class NofficeList: UIControl {
// MARK: Event
public var _onTap: PublishSubject<Void> = PublishSubject()
public var onTap: Observable<Void> {
return _onTap.asObservable()
}

// MARK: Data source
public var text: String = "" {
didSet {
label.text = text
}
}

public var status: NofficeList.Status = .unselected {
didSet {
updateByStatus()
}
}

// MARK: UI Component
private lazy var backgroundView = UIView().then {
$0.layer.cornerRadius = RoundedOffset.medium.same
$0.clipsToBounds = true
$0.isUserInteractionEnabled = false
}

private lazy var stackView = UIStackView(arrangedSubviews: [label, icon]).then {
$0.axis = .horizontal
$0.spacing = 8
$0.alignment = .center
}

private lazy var label = UILabel().then {
$0.text = ""
$0.setTypo(.body2b)
$0.textColor = .blue500
$0.numberOfLines = 10
}

private lazy var icon = UIImageView(image: .iconCheck).then {
$0.tintColor = .grey300
$0.setSize(width: 16, height: 16)
}

// MARK: Initializer
public init() {
super.init(frame: .zero)

setupHierarchy()
setupLayout()
setupBind()
}

required init?(coder: NSCoder) {
super.init(coder: coder)

setupHierarchy()
setupLayout()
setupBind()
}

// MARK: Public
public func stateToggle() {
status = status == .selected ? .unselected : .selected
}

// MARK: Setup
private func setupHierarchy() {
addSubview(backgroundView)
backgroundView.addSubview(stackView)
}

private func setupLayout() {
backgroundView.snp.makeConstraints {
$0.edges.equalToSuperview()
}

stackView.snp.makeConstraints {
$0.top.bottom.equalToSuperview().inset(Self.verticalPadding)
$0.leading.trailing.equalToSuperview().inset(Self.horizontalPadding)
}
}

private func setupBind() { }

// MARK: Update
private func updateByStatus() {
switch status {
case .selected:
UIView.transition(
with: self,
duration: 0.2,
options: [.transitionCrossDissolve]
) { [weak self] in
guard let self = self else { return }

self.backgroundView.backgroundColor = .green100
self.label.textColor = .green500
self.icon.tintColor = .green500
}
case .unselected:
self.icon.isHidden = false
UIView.transition(
with: self,
duration: 0.2,
options: [.transitionCrossDissolve]
) { [weak self] in
guard let self = self else { return }

self.backgroundView.backgroundColor = .grey100
self.label.textColor = .grey400
self.icon.tintColor = .grey400
}
}
}

// MARK: UIControl
public override func endTracking(_ touch: UITouch?, with event: UIEvent?) {
_onTap.onNext(())
sendActions(for: .touchUpInside)
}
}

// MARK: - Display model
public extension NofficeList {
enum Status: String, CaseIterable {
case unselected, selected
}
}

// MARK: - Constant
private extension NofficeList {
static let verticalPadding = 12
static let horizontalPadding = 16
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ public class NofficeTodo: UIControl {

// MARK: UIControl
public override func endTracking(_ touch: UITouch?, with event: UIEvent?) {
print("dpd..")
_onTap.onNext(())
sendActions(for: .touchUpInside)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
//
// NofficeListBookViewController.swift
// DesignSystem
//
// Created by DOYEON LEE on 7/16/24.
//

import UIKit

import DesignSystem

import RxSwift
import SnapKit
import Then

class NofficeListBookViewController: UIViewController {
// MARK: UI Components
private lazy var scrollView = UIScrollView()

private lazy var contentView = UIView()

private lazy var stackView = UIStackView().then {
$0.axis = .vertical
$0.spacing = 16
$0.alignment = .fill
$0.distribution = .fill
}

private lazy var stateSegmentedControl = UISegmentedControl(
items: Array(NofficeList.Status.allCases).map { $0.rawValue }
).then {
$0.selectedSegmentIndex = 0
}

private let listView = NofficeList().then {
$0.text = "팀원 리스트 제출"
}

// MARK: DisposeBag
private let disposeBag = DisposeBag()

// MARK: Life Cycle
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white

setupHierarchy()
setupLayout()
setupBind()
}

// MARK: Setup
private func setupHierarchy() {
view.addSubview(scrollView)
scrollView.addSubview(contentView)
contentView.addSubview(stackView)

stackView.addArrangedSubview(stateSegmentedControl)

stackView.addArrangedSubview(listView)
}

private func setupLayout() {
scrollView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}

contentView.snp.makeConstraints { make in
make.edges.equalToSuperview()
make.width.equalTo(scrollView)
}

stackView.snp.makeConstraints { make in
make.edges.equalToSuperview().inset(16)
}
}

private func setupBind() {
stateSegmentedControl.rx.selectedSegmentIndex
.map { NofficeList.Status.allCases[$0] }
.subscribe(onNext: { [weak self] state in
self?.listView.status = state
})
.disposed(by: disposeBag)

listView.onTap
.subscribe(onNext: { [weak self] _ in
self?.listView.stateToggle()
})
.disposed(by: disposeBag)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ class ViewController: UIViewController {
$0.setTitleColor(.systemBlue, for: .normal)
},
viewController: NofficeBannerBookViewController.self
),
Example(
label: "List",
button: UIButton().then {
$0.setTitle("Example", for: .normal)
$0.setTitleColor(.systemBlue, for: .normal)
},
viewController: NofficeListBookViewController.self
)
]
)
Expand Down
16 changes: 3 additions & 13 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ platform :ios do
readonly: true
)

increment_minor_build_number(
xcodeproj: "./Projects/Noffice/Noffice.xcodeproj"
increment_build_number(
xcodeproj: "./Projects/Noffice/Noffice.xcodeproj",
build_number: (last_testflight_build_number.to_i + 1).to_s
)

build_app(
Expand Down Expand Up @@ -56,14 +57,3 @@ platform :ios do
build_app(scheme: "prod")
end
end

private_lane :increment_minor_build_number do |options|
project_path = options[:xcodeproj]
current_version = get_build_number(xcodeproj: project_path)
new_version = (current_version.to_f + 0.1).round(1)
puts "Current build number: #{current_version}, new build number: #{new_version}"
increment_build_number(
xcodeproj: project_path,
build_number: new_version.to_s
)
end

0 comments on commit 1dc9d2c

Please sign in to comment.