forked from TeamNADA/NADA-iOS-ForRelease
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/TeamNADA#85' of https://github.com/dlwns33/NADA…
…-iOS-ForRelease into feature/TeamNADA#88
- Loading branch information
Showing
10 changed files
with
371 additions
and
19 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
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
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
111 changes: 111 additions & 0 deletions
111
...forRelease/Sources/ViewControllers/BottomSheet/SelectGroupBottomSheetViewController.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,111 @@ | ||
// | ||
// SelectGroupBottomSheetViewController.swift | ||
// NADA-iOS-forRelease | ||
// | ||
// Created by Yi Joon Choi on 2021/11/28. | ||
// | ||
|
||
import UIKit | ||
|
||
class SelectGroupBottomSheetViewController: CommonBottomSheetViewController { | ||
|
||
// MARK: - Properties | ||
var groupList = ["미분류", "SOPT", "동아리", "인하대학교"] | ||
var selectedGroup = "" | ||
|
||
private let groupPicker: UIPickerView = { | ||
let pickerView = UIPickerView() | ||
pickerView.autoresizingMask = .flexibleWidth | ||
|
||
return pickerView | ||
}() | ||
|
||
private let doneButton: UIButton = { | ||
let button = UIButton() | ||
button.setImage(UIImage(named: "btnMainDone"), for: .normal) | ||
button.addTarget(self, action: #selector(presentCardInfoViewController), for: .touchUpInside) | ||
|
||
return button | ||
}() | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
setupUI() | ||
} | ||
|
||
// MARK: - @Functions | ||
// UI 세팅 작업 | ||
private func setupUI() { | ||
view.addSubview(groupPicker) | ||
view.addSubview(doneButton) | ||
selectedGroup = groupList[0] | ||
groupPicker.delegate = self | ||
groupPicker.dataSource = self | ||
setupLayout() | ||
} | ||
|
||
// 레이아웃 세팅 | ||
private func setupLayout() { | ||
groupPicker.selectedRow(inComponent: 0) | ||
groupPicker.translatesAutoresizingMaskIntoConstraints = false | ||
NSLayoutConstraint.activate([ | ||
groupPicker.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 14), | ||
groupPicker.centerXAnchor.constraint(equalTo: bottomSheetView.centerXAnchor) | ||
]) | ||
|
||
doneButton.translatesAutoresizingMaskIntoConstraints = false | ||
NSLayoutConstraint.activate([ | ||
doneButton.topAnchor.constraint(equalTo: groupPicker.bottomAnchor, constant: 0), | ||
doneButton.centerXAnchor.constraint(equalTo: bottomSheetView.centerXAnchor) | ||
]) | ||
} | ||
|
||
@objc func presentCardInfoViewController() { | ||
print("presentCardInfoViewController") | ||
print(selectedGroup) | ||
} | ||
|
||
} | ||
|
||
extension SelectGroupBottomSheetViewController: UIPickerViewDelegate, UIPickerViewDataSource { | ||
func numberOfComponents(in pickerView: UIPickerView) -> Int { | ||
return 1 | ||
} | ||
|
||
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { | ||
return groupList.count | ||
} | ||
|
||
func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView { | ||
let label = (view as? UILabel) ?? UILabel() | ||
|
||
label.textColor = .quaternary | ||
label.textAlignment = .center | ||
label.font = UIFont(name: "SpoqaHanSansNeo-Regular", size: 16) | ||
|
||
if pickerView.selectedRow(inComponent: component) == row { | ||
label.attributedText = NSAttributedString(string: groupList[row], attributes: [NSAttributedString.Key.font: UIFont(name: "SpoqaHanSansNeo-Bold", size: 16.0)!, NSAttributedString.Key.foregroundColor: UIColor.mainColorNadaMain]) | ||
|
||
} else { | ||
label.attributedText = NSAttributedString(string: groupList[row], attributes: [NSAttributedString.Key.font: UIFont(name: "SpoqaHanSansNeo-Regular", size: 16.0)!, NSAttributedString.Key.foregroundColor: UIColor.quaternary]) | ||
} | ||
|
||
label.text = groupList[row] | ||
|
||
return label | ||
} | ||
|
||
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { | ||
print("select=\(groupList[row])") | ||
selectedGroup = groupList[row] | ||
pickerView.reloadAllComponents() | ||
} | ||
|
||
func pickerView(_ pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat { | ||
return 44 | ||
} | ||
|
||
func pickerView(_ pickerView: UIPickerView, widthForComponent component: Int) -> CGFloat { | ||
return 200 | ||
} | ||
} |
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,51 @@ | ||
// | ||
// CardView.swift | ||
// NADA-iOS-forRelease | ||
// | ||
// Created by Yi Joon Choi on 2021/11/28. | ||
// | ||
|
||
import UIKit | ||
|
||
class CardView: UIView { | ||
|
||
@IBOutlet weak var backgroundImageView: UIImageView! | ||
@IBOutlet weak var titleLabel: UILabel! | ||
@IBOutlet weak var descriptionLabel: UILabel! | ||
@IBOutlet weak var userNameLabel: UILabel! | ||
@IBOutlet weak var birthLabel: UILabel! | ||
@IBOutlet weak var mbtiLabel: UILabel! | ||
|
||
@IBOutlet weak var instagramIDLabel: UILabel! | ||
@IBOutlet weak var lineURLLabel: UILabel! | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
xibSetup() | ||
} | ||
|
||
override func prepareForInterfaceBuilder() { | ||
super.prepareForInterfaceBuilder() | ||
} | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
super.init(coder: aDecoder) | ||
xibSetup() | ||
} | ||
|
||
func xibSetup() { | ||
guard let view = loadViewFromNib(nib: Const.Xib.cardView) else { | ||
return | ||
} | ||
view.frame = bounds | ||
view.layer.cornerRadius = 15 | ||
view.autoresizingMask = [.flexibleWidth, .flexibleHeight] | ||
addSubview(view) | ||
} | ||
|
||
func loadViewFromNib(nib: String) -> UIView? { | ||
let bundle = Bundle(for: type(of: self)) | ||
let nib = UINib(nibName: nib, bundle: bundle) | ||
return nib.instantiate(withOwner: self, options: nil).first as? UIView | ||
} | ||
} |
Oops, something went wrong.