Skip to content

Commit

Permalink
Feature/bank view 구현 (#15)
Browse files Browse the repository at this point in the history
* feat: 고객10명추가 버튼, 초기화 버튼을 view에 추가

* feat: businessHoursLabel를 view에 추가

* feat: waitLabel, workLabel을 BankView에 추가

* feat: CustomView 구현

* feat: customerStackView, waitStackView, workStackView view에 추가

* feat: baseStackView 구현 및 레이아웃 설정

* feat: CustomerView layout 설정

* refactor: baseStackView layout 조정, businessHoursLabel 컬러 변경

Co-authored-by: dudu <whqtkf12@naver.com>
  • Loading branch information
kimkyunghun3 and FirstDo committed May 3, 2022
1 parent fdba3d7 commit d42c955
Show file tree
Hide file tree
Showing 4 changed files with 195 additions and 2 deletions.
8 changes: 8 additions & 0 deletions BankManagerUIApp/BankManagerUIApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
objects = {

/* Begin PBXBuildFile section */
64E9007B282100E500FD415B /* CustomerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64E9007A282100E500FD415B /* CustomerView.swift */; };
94B54F532820F0F500494C1B /* BankCustomer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94B54F4A2820F0F500494C1B /* BankCustomer.swift */; };
94B54F542820F0F500494C1B /* BankWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94B54F4B2820F0F500494C1B /* BankWindow.swift */; };
94B54F552820F0F500494C1B /* Bank.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94B54F4C2820F0F500494C1B /* Bank.swift */; };
94B54F562820F0F500494C1B /* Banking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94B54F4D2820F0F500494C1B /* Banking.swift */; };
94B54F572820F0F500494C1B /* Queue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94B54F4F2820F0F500494C1B /* Queue.swift */; };
94B54F582820F0F500494C1B /* Node.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94B54F502820F0F500494C1B /* Node.swift */; };
94B54F592820F0F500494C1B /* LinkedList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94B54F512820F0F500494C1B /* LinkedList.swift */; };
94B54F5B2820FA5400494C1B /* BankView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94B54F5A2820FA5400494C1B /* BankView.swift */; };
C7694E3B259C3E9F0053667F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7694E3A259C3E9F0053667F /* AppDelegate.swift */; };
C7694E3D259C3E9F0053667F /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7694E3C259C3E9F0053667F /* SceneDelegate.swift */; };
C7694E3F259C3E9F0053667F /* BankViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7694E3E259C3E9F0053667F /* BankViewController.swift */; };
Expand Down Expand Up @@ -42,13 +44,15 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
64E9007A282100E500FD415B /* CustomerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomerView.swift; sourceTree = "<group>"; };
94B54F4A2820F0F500494C1B /* BankCustomer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BankCustomer.swift; sourceTree = "<group>"; };
94B54F4B2820F0F500494C1B /* BankWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BankWindow.swift; sourceTree = "<group>"; };
94B54F4C2820F0F500494C1B /* Bank.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Bank.swift; sourceTree = "<group>"; };
94B54F4D2820F0F500494C1B /* Banking.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Banking.swift; sourceTree = "<group>"; };
94B54F4F2820F0F500494C1B /* Queue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Queue.swift; sourceTree = "<group>"; };
94B54F502820F0F500494C1B /* Node.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Node.swift; sourceTree = "<group>"; };
94B54F512820F0F500494C1B /* LinkedList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LinkedList.swift; sourceTree = "<group>"; };
94B54F5A2820FA5400494C1B /* BankView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BankView.swift; sourceTree = "<group>"; };
C7694E37259C3E9F0053667F /* BankManagerUIApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BankManagerUIApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
C7694E3A259C3E9F0053667F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
C7694E3C259C3E9F0053667F /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -103,6 +107,8 @@
isa = PBXGroup;
children = (
C7694E3E259C3E9F0053667F /* BankViewController.swift */,
94B54F5A2820FA5400494C1B /* BankView.swift */,
64E9007A282100E500FD415B /* CustomerView.swift */,
);
path = BankController;
sourceTree = "<group>";
Expand Down Expand Up @@ -310,11 +316,13 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
94B54F5B2820FA5400494C1B /* BankView.swift in Sources */,
C7694E3F259C3E9F0053667F /* BankViewController.swift in Sources */,
94B54F552820F0F500494C1B /* Bank.swift in Sources */,
94B54F582820F0F500494C1B /* Node.swift in Sources */,
C7694E3B259C3E9F0053667F /* AppDelegate.swift in Sources */,
C7694E3D259C3E9F0053667F /* SceneDelegate.swift in Sources */,
64E9007B282100E500FD415B /* CustomerView.swift in Sources */,
94B54F592820F0F500494C1B /* LinkedList.swift in Sources */,
94B54F572820F0F500494C1B /* Queue.swift in Sources */,
94B54F562820F0F500494C1B /* Banking.swift in Sources */,
Expand Down
131 changes: 131 additions & 0 deletions BankManagerUIApp/BankManagerUIApp/BankController/BankView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
//
// BankView.swift
// BankManagerUIApp
//
// Created by Eddy, dudu.
//

import UIKit

class BankView: UIView {
private lazy var baseStackView: UIStackView = {
let stackView = UIStackView(arrangedSubviews: [
buttonStackView,
businessHoursLabel,
workStateStackView,
customerStackView])

stackView.axis = .vertical
stackView.spacing = 15

return stackView
}()

private lazy var buttonStackView: UIStackView = {
let stackView = UIStackView(arrangedSubviews: [addCustomerbutton, resetButton])
stackView.distribution = .fillEqually

return stackView
}()

private lazy var addCustomerbutton: UIButton = {
let button = UIButton()
button.setTitle("고객 10명 추가", for: .normal)
button.setTitleColor(.systemBlue, for: .normal)

return button
}()

private lazy var resetButton: UIButton = {
let button = UIButton()
button.setTitle("초기화", for: .normal)
button.setTitleColor(.systemRed, for: .normal)

return button
}()

private lazy var businessHoursLabel: UILabel = {
let label = UILabel()
label.text = "업무시간 - 00:00:000"
label.textAlignment = .center
label.font = .preferredFont(forTextStyle: .title3)

return label
}()

private lazy var workStateStackView: UIStackView = {
let stackView = UIStackView(arrangedSubviews: [waitLabel, workLabel])
stackView.distribution = .fillEqually

return stackView
}()

private lazy var waitLabel: UILabel = {
let label = UILabel()
label.text = "대기중"
label.textAlignment = .center
label.textColor = .white
label.font = .preferredFont(forTextStyle: .title1)
label.backgroundColor = .systemGreen

return label
}()

private lazy var workLabel: UILabel = {
let label = UILabel()
label.text = "업무중"
label.textAlignment = .center
label.textColor = .white
label.font = .preferredFont(forTextStyle: .title1)
label.backgroundColor = .systemIndigo

return label
}()

private lazy var customerStackView: UIStackView = {
let stackView = UIStackView(arrangedSubviews: [waitStackView, workStackView])

return stackView
}()

private lazy var waitStackView: UIStackView = {
let stackView = UIStackView()
stackView.axis = .vertical

return stackView
}()

private lazy var workStackView: UIStackView = {
let stackView = UIStackView()
stackView.axis = .vertical

return stackView
}()

override init(frame: CGRect) {
super.init(frame: frame)
layout()
}

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

// MARK: - layout

extension BankView {
private func layout() {
baseStackView.translatesAutoresizingMaskIntoConstraints = false
addSubview(baseStackView)

// MARK: - baseStackView

NSLayoutConstraint.activate([
baseStackView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor),
baseStackView.bottomAnchor.constraint(equalTo: safeAreaLayoutGuide.bottomAnchor),
baseStackView.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor),
baseStackView.trailingAnchor.constraint(equalTo: safeAreaLayoutGuide.trailingAnchor)
])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import UIKit

final class BankViewController: UIViewController {

private lazy var bankView = BankView(frame: view.bounds)

override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .systemBackground
view = bankView
bankView.backgroundColor = .systemBackground
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// CustomerView.swift
// BankManagerUIApp
//
// Created by Eddy on 2022/05/03.
//

import UIKit

class CustomerView: UIView {
let customer: Customer

init(customer: Customer) {
self.customer = customer
super.init()
}

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

private lazy var customerLabel: UILabel = {
let label = UILabel()

if customer.workType == .loan {
label.textColor = .systemPurple
}

label.text = "\(customer.waitingNumber) - \(customer.workType.name)"

return label
}()
}

// MARK: - layout

extension CustomerView {

private func layout() {
customerLabel.translatesAutoresizingMaskIntoConstraints = false
addSubview(customerLabel)

// MARK: - customerLabel

NSLayoutConstraint.activate([
customerLabel.topAnchor.constraint(equalTo: self.topAnchor),
customerLabel.bottomAnchor.constraint(equalTo: self.bottomAnchor),
customerLabel.leadingAnchor.constraint(equalTo: self.leadingAnchor),
customerLabel.trailingAnchor.constraint(equalTo: self.trailingAnchor)
])
}
}

0 comments on commit d42c955

Please sign in to comment.