Skip to content

Commit

Permalink
Merge pull request #6 from KNU-CSE-APP/#3/ViewSetUp
Browse files Browse the repository at this point in the history
#3/view set up
  • Loading branch information
JunseokNoh authored Aug 2, 2021
2 parents 3057389 + 5da9767 commit 27c20c8
Show file tree
Hide file tree
Showing 181 changed files with 14,292 additions and 709 deletions.
440 changes: 436 additions & 4 deletions KNU_CSE/KNU_CSE.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion KNU_CSE/KNU_CSE/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}


func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
if UserDefaults.standard.bool(forKey: "checkState") == false{
if StorageManager.shared.deleteUser(){
print("Success remove UserAccount")
}else{
print("Fail remove UserAccount")
}
}
}
}

308 changes: 304 additions & 4 deletions KNU_CSE/KNU_CSE/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion KNU_CSE/KNU_CSE/Color/Color.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,23 @@ import UIKit

struct Color{
static let mainColor : UIColor = UIColor.red
static let subColor : UIColor = UIColor.systemRed
static let subColor : UIColor = UIColor(red: 51/255, green: 13/255, blue: 0/255, alpha: 1)
static let green : UIColor = UIColor(red: 149/255, green: 241/255, blue: 159/255, alpha: 1)
static let gray : UIColor = UIColor.init(red: 168/255, green: 168/255, blue: 168/255, alpha: 1)
}

extension UIColor{
convenience init(red: Int, green: Int, blue: Int, a: Int = 0xFF) {
self.init(
red: CGFloat(red) / 255.0,
green: CGFloat(green) / 255.0,
blue: CGFloat(blue) / 255.0,
alpha: CGFloat(a) / 255.0
)
}
}





36 changes: 36 additions & 0 deletions KNU_CSE/KNU_CSE/Custom/Alert/Alert.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// Alert.swift
// KNU_CSE
//
// Created by junseok on 2021/07/17.
//

import UIKit

struct Alert{
var alert : UIAlertController
var title : String
var message : String
var viewController : UIViewController

init(title:String, message:String, viewController:UIViewController) {
self.title = title
self.message = message
self.alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
self.viewController = viewController
}

func popUpDefaultAlert(action:((UIAlertAction)->())?){
let actionDefault = UIAlertAction(title: "확인", style: .default,handler: action)
self.alert.addAction(actionDefault)
self.viewController.present(alert, animated: true, completion: nil)
}

func popUpNormalAlert(action:((UIAlertAction)->())?){
let actionCancel = UIAlertAction(title: "취소", style: .destructive, handler: nil)
let actionDefault = UIAlertAction(title: "확인", style: .default,handler: action)
self.alert.addAction(actionCancel)
self.alert.addAction(actionDefault)
self.viewController.present(alert, animated: true, completion: nil)
}
}
66 changes: 66 additions & 0 deletions KNU_CSE/KNU_CSE/Custom/Cell/BoardTitleCollectionCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//
// BoardTitleCell.swift
// KNU_CSE
//
// Created by junseok on 2021/07/21.
//

import UIKit

class BoardTitleCell : UICollectionViewCell {
var titleLabel = UILabel()
static let identifier = "BoardTitleCell"

override var isSelected: Bool {
willSet {
if newValue {
titleLabel.textColor = .black
} else {
titleLabel.textColor = .lightGray
}
}
}

override func prepareForReuse() {
//isSelected = false
}

override init(frame: CGRect) {
super.init(frame: frame)
draw()
self.isSelected = false
}

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

func draw(){
initUI()
addView()
setUpConstraints()
}

func initUI(){

}

func addView(){
self.contentView.addSubview(titleLabel)
}

func setUpConstraints(){
titleLabel.snp.makeConstraints{ make in
make.width.equalToSuperview()
make.height.equalToSuperview()
}
}
}

extension BoardTitleCell{
func setTitle(title: String) {
titleLabel.text = title
titleLabel.textAlignment = .center
titleLabel.font = UIFont.systemFont(ofSize: 15, weight: .semibold)
}
}
55 changes: 55 additions & 0 deletions KNU_CSE/KNU_CSE/Custom/Cell/ClassRoomCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// SeatReservationCell.swift
// KNU_CSE
//
// Created by junseok on 2021/07/18.
//

import UIKit
import SnapKit

class ClassRoomCell : UITableViewCell {
static let identifier = "ClassRoomCell"
var titleLabel = UILabel()

var action :()->() = {}

var classRoom : ClassRoom!{
didSet{
let title = "\(classRoom.building)-\(classRoom.roomNum)호(\(classRoom.currentSeat)/\(classRoom.totalSeat))"
self.setTitle(title: title)
}
}

func setTitle(title: String) {
titleLabel.text = title
titleLabel.textAlignment = .center
}

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.initUI()
self.addView()
self.setUpConstraints()
}

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

func initUI(){

}

func addView(){
self.contentView.addSubview(titleLabel)
}

func setUpConstraints(){

titleLabel.snp.makeConstraints{ make in
make.width.equalToSuperview()
make.height.equalToSuperview()
}
}
}
89 changes: 89 additions & 0 deletions KNU_CSE/KNU_CSE/Custom/Cell/ClassSeatCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
//
// ClassSeatCell.swift
// KNU_CSE
//
// Created by junseok on 2021/07/19.
//

import UIKit
import SnapKit

class ClassSeatCell:UICollectionViewCell{
static let identifier = "ClassSeatCell"
var action:()->() = {}
var _classSeat:ClassSeat!

var classSeat: ClassSeat{
get{
return _classSeat
}set(newValue){
_classSeat = newValue
self.isUsable = newValue.status
self.seatBtn.setTitle(String(self.classSeat.seatNumber), for: .normal)
}
}

var seatBtn:UIButton!{
didSet{
seatBtn.layer.cornerRadius = 10
}
}

var _isUsable : Bool!
var isUsable : Bool{
get{
return _isUsable
}set(newValue){
_isUsable = newValue
if _isUsable{
setUsable()
}else{
setUnUsable()
}
}
}
override init(frame: CGRect) {
super.init(frame: frame)
draw()
}

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

func draw(){
initUI()
addView()
setUpConstraints()
}

func initUI(){
seatBtn = UIButton()
}

func addView(){
self.contentView.addSubview(seatBtn)
}

func setUpConstraints(){
seatBtn.snp.makeConstraints{ make in
make.left.right.top.bottom.equalToSuperview()
}
}

func setUsable(){
seatBtn.backgroundColor = Color.green
seatBtn.setTitleColor(UIColor.init(white: 1, alpha: 0.3), for: .highlighted)
seatBtn.addAction {
self.action()
}
}

func setUnUsable(){
seatBtn.backgroundColor = Color.gray
}

func setBtnAction(action:@escaping()->()){
self.action = action
}
}
Loading

0 comments on commit 27c20c8

Please sign in to comment.