From d42c955716c7b3464137b042456bdbfe6e310081 Mon Sep 17 00:00:00 2001 From: Eddy Date: Tue, 3 May 2022 16:19:42 +0900 Subject: [PATCH] =?UTF-8?q?Feature/bank=20view=20=EA=B5=AC=ED=98=84=20(#15?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- .../project.pbxproj | 8 ++ .../BankController/BankView.swift | 131 ++++++++++++++++++ .../BankController/BankViewController.swift | 6 +- .../BankController/CustomerView.swift | 52 +++++++ 4 files changed, 195 insertions(+), 2 deletions(-) create mode 100644 BankManagerUIApp/BankManagerUIApp/BankController/BankView.swift create mode 100644 BankManagerUIApp/BankManagerUIApp/BankController/CustomerView.swift diff --git a/BankManagerUIApp/BankManagerUIApp.xcodeproj/project.pbxproj b/BankManagerUIApp/BankManagerUIApp.xcodeproj/project.pbxproj index dde1421cd..61a50d7ae 100644 --- a/BankManagerUIApp/BankManagerUIApp.xcodeproj/project.pbxproj +++ b/BankManagerUIApp/BankManagerUIApp.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ 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 */; }; @@ -14,6 +15,7 @@ 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 */; }; @@ -42,6 +44,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 64E9007A282100E500FD415B /* CustomerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomerView.swift; sourceTree = ""; }; 94B54F4A2820F0F500494C1B /* BankCustomer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BankCustomer.swift; sourceTree = ""; }; 94B54F4B2820F0F500494C1B /* BankWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BankWindow.swift; sourceTree = ""; }; 94B54F4C2820F0F500494C1B /* Bank.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Bank.swift; sourceTree = ""; }; @@ -49,6 +52,7 @@ 94B54F4F2820F0F500494C1B /* Queue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Queue.swift; sourceTree = ""; }; 94B54F502820F0F500494C1B /* Node.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Node.swift; sourceTree = ""; }; 94B54F512820F0F500494C1B /* LinkedList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LinkedList.swift; sourceTree = ""; }; + 94B54F5A2820FA5400494C1B /* BankView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BankView.swift; sourceTree = ""; }; 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 = ""; }; C7694E3C259C3E9F0053667F /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -103,6 +107,8 @@ isa = PBXGroup; children = ( C7694E3E259C3E9F0053667F /* BankViewController.swift */, + 94B54F5A2820FA5400494C1B /* BankView.swift */, + 64E9007A282100E500FD415B /* CustomerView.swift */, ); path = BankController; sourceTree = ""; @@ -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 */, diff --git a/BankManagerUIApp/BankManagerUIApp/BankController/BankView.swift b/BankManagerUIApp/BankManagerUIApp/BankController/BankView.swift new file mode 100644 index 000000000..9d34b8479 --- /dev/null +++ b/BankManagerUIApp/BankManagerUIApp/BankController/BankView.swift @@ -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) + ]) + } +} diff --git a/BankManagerUIApp/BankManagerUIApp/BankController/BankViewController.swift b/BankManagerUIApp/BankManagerUIApp/BankController/BankViewController.swift index e7f23cc58..799b6103e 100644 --- a/BankManagerUIApp/BankManagerUIApp/BankController/BankViewController.swift +++ b/BankManagerUIApp/BankManagerUIApp/BankController/BankViewController.swift @@ -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 } } diff --git a/BankManagerUIApp/BankManagerUIApp/BankController/CustomerView.swift b/BankManagerUIApp/BankManagerUIApp/BankController/CustomerView.swift new file mode 100644 index 000000000..fa99a16f4 --- /dev/null +++ b/BankManagerUIApp/BankManagerUIApp/BankController/CustomerView.swift @@ -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) + ]) + } +}