-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from Nexters/feature/attendanceDetailVC
[FEAT][#7] 출석 코드 입력 상세 뷰 구현
- Loading branch information
Showing
11 changed files
with
800 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// Collection+Extension.swift | ||
// momoIOS | ||
// | ||
// Created by 임수현 on 2023/02/11. | ||
// | ||
|
||
import Foundation | ||
|
||
extension Collection { | ||
subscript (safe index: Index) -> Element? { | ||
return indices.contains(index) ? self[index] : nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// Optional+Extension.swift | ||
// momoIOS | ||
// | ||
// Created by 임수현 on 2023/02/11. | ||
// | ||
|
||
import Foundation | ||
|
||
extension Optional { | ||
var isNil: Bool { | ||
self == nil | ||
} | ||
var isNotNil: Bool { | ||
self != nil | ||
} | ||
} | ||
|
||
extension String? { | ||
var isEmptyOrNil: Bool { | ||
self?.isEmpty == true || self.isNil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// String+Extension.swift | ||
// momoIOS | ||
// | ||
// Created by 임수현 on 2023/02/11. | ||
// | ||
|
||
import Foundation | ||
|
||
extension String { | ||
subscript (safe index: Int) -> String? { | ||
guard self.count > index else { return nil } | ||
let index = self.index(self.startIndex, offsetBy: index) | ||
return "\(self[index])" | ||
} | ||
|
||
subscript (range: Range<Int>) -> String? { | ||
let fromIndex = self.index(self.startIndex, offsetBy: max(0, range.lowerBound)) | ||
let toIndex = self.index(self.startIndex, offsetBy: min(range.upperBound, self.count)) | ||
return String(self[fromIndex..<toIndex]) | ||
} | ||
|
||
subscript(_ range: Range<Int>) -> String { | ||
let fromIndex = self.index(self.startIndex, offsetBy: range.startIndex) | ||
let toIndex = self.index(self.startIndex, offsetBy: range.endIndex) | ||
return String(self[fromIndex..<toIndex]) | ||
} | ||
|
||
func replaced(_ string: String, in range: NSRange) -> String? { | ||
guard let range = Range(range, in: self) else { return nil } | ||
return self.replacingCharacters(in: range, with: string) | ||
} | ||
|
||
var isBackspace: Bool { | ||
if let char = self.cString(using: String.Encoding.utf8) { | ||
return strcmp(char, "\\b") == -92 | ||
} | ||
return false | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
momoIOS/Common/Extensions/UINavigationController+Extension.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// UINavigationController+Extension.swift | ||
// momoIOS | ||
// | ||
// Created by 임수현 on 2023/02/11. | ||
// | ||
|
||
import UIKit | ||
|
||
extension UINavigationController: ObservableObject, UIGestureRecognizerDelegate { | ||
override open func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
// backButton을 임의로 변경하면 swipe back 동작이 되지 않기 떄문에 gestureRecognizer를 설정하여 동작하도록 함. | ||
interactivePopGestureRecognizer?.delegate = self | ||
} | ||
|
||
public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { | ||
return viewControllers.count > 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// | ||
// MainAttendanceCodeCell.swift | ||
// momoIOS | ||
// | ||
// Created by 임수현 on 2023/01/31. | ||
// | ||
|
||
import UIKit | ||
import SnapKit | ||
|
||
class MainAttendanceCodeCell: UITableViewCell { | ||
private let cardView: UIView = UIView() | ||
private let titleLabel: UILabel = UILabel() | ||
private let codeStackView: UIStackView = UIStackView() | ||
private let descriptionLabel: UILabel = UILabel() | ||
|
||
// MARK: - Initializer | ||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
super.init(style: style, reuseIdentifier: "MainAttendanceCodeCell") | ||
|
||
self.selectionStyle = .none | ||
self.setupViews() | ||
self.setupLayout() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
super.init(coder: coder) | ||
} | ||
|
||
// MARK: - Setup | ||
private func setupViews() { | ||
// TODO: ViewModel 바라보도록 수정 필요 | ||
self.cardView.backgroundColor = .rgba(128, 135, 201, 1) | ||
self.cardView.layer.cornerRadius = 12 | ||
self.contentView.addSubview(self.cardView) | ||
|
||
self.titleLabel.text = "출석체크 코드 입력" | ||
self.titleLabel.font = .systemFont(ofSize: 17, weight: .medium) | ||
self.titleLabel.textColor = .white | ||
self.cardView.addSubview(self.titleLabel) | ||
|
||
self.codeStackView.axis = .horizontal | ||
self.codeStackView.alignment = .center | ||
self.codeStackView.spacing = 14 | ||
for _ in 0..<4 { | ||
let lineView = UIView() | ||
lineView.backgroundColor = .white | ||
self.codeStackView.addArrangedSubview(lineView) | ||
} | ||
self.cardView.addSubview(self.codeStackView) | ||
|
||
self.descriptionLabel.text = "운영진이 공지해준 출석체크 코드를 입력해주세요!" | ||
self.descriptionLabel.font = .systemFont(ofSize: 14) | ||
self.descriptionLabel.textColor = .white.withAlphaComponent(0.67) | ||
self.cardView.addSubview(self.descriptionLabel) | ||
} | ||
|
||
// MARK: - Layout | ||
private func setupLayout() { | ||
self.cardView.snp.makeConstraints { make in | ||
make.top.equalToSuperview() | ||
make.leading.trailing.equalToSuperview().inset(24) | ||
make.bottom.equalToSuperview().inset(19) | ||
} | ||
|
||
self.titleLabel.snp.makeConstraints { make in | ||
make.top.equalToSuperview().inset(28) | ||
make.centerX.equalToSuperview() | ||
} | ||
|
||
self.codeStackView.snp.makeConstraints { make in | ||
make.top.equalTo(self.titleLabel.snp.bottom).offset(103) | ||
make.centerX.equalToSuperview() | ||
} | ||
|
||
self.codeStackView.arrangedSubviews.forEach { | ||
$0.snp.makeConstraints { make in | ||
make.height.equalTo(1) | ||
make.width.equalTo(44) | ||
} | ||
} | ||
|
||
self.descriptionLabel.snp.makeConstraints { make in | ||
make.top.equalTo(self.codeStackView.snp.bottom).offset(26) | ||
make.bottom.equalToSuperview().inset(35) | ||
make.centerX.equalToSuperview() | ||
} | ||
} | ||
} |
Oops, something went wrong.