Skip to content

Commit

Permalink
#5 add ClassRoom data transfer with delegate
Browse files Browse the repository at this point in the history
  • Loading branch information
JunseokNoh committed Jul 18, 2021
1 parent 30aabbd commit e205e38
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 4 deletions.
4 changes: 4 additions & 0 deletions KNU_CSE/KNU_CSE.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
681D37D326A48A64000D9FE8 /* MyPageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 681D37D226A48A64000D9FE8 /* MyPageViewModel.swift */; };
681D37D526A48A6F000D9FE8 /* MyPageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 681D37D426A48A6F000D9FE8 /* MyPageModel.swift */; };
681D37D726A48B37000D9FE8 /* BoardCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 681D37D626A48B37000D9FE8 /* BoardCell.swift */; };
681D37D926A4A75F000D9FE8 /* ClassDataDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 681D37D826A4A75F000D9FE8 /* ClassDataDelegate.swift */; };
68F1A5B826A0088B007B4B86 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68F1A5B726A0088B007B4B86 /* AppDelegate.swift */; };
68F1A5BA26A0088B007B4B86 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68F1A5B926A0088B007B4B86 /* SceneDelegate.swift */; };
68F1A5BC26A0088B007B4B86 /* SignInView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68F1A5BB26A0088B007B4B86 /* SignInView.swift */; };
Expand Down Expand Up @@ -85,6 +86,7 @@
681D37D226A48A64000D9FE8 /* MyPageViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageViewModel.swift; sourceTree = "<group>"; };
681D37D426A48A6F000D9FE8 /* MyPageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageModel.swift; sourceTree = "<group>"; };
681D37D626A48B37000D9FE8 /* BoardCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoardCell.swift; sourceTree = "<group>"; };
681D37D826A4A75F000D9FE8 /* ClassDataDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClassDataDelegate.swift; sourceTree = "<group>"; };
68F1A5B426A0088B007B4B86 /* KNU_CSE.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = KNU_CSE.app; sourceTree = BUILT_PRODUCTS_DIR; };
68F1A5B726A0088B007B4B86 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
68F1A5B926A0088B007B4B86 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -212,6 +214,7 @@
681D37CB26A47FC7000D9FE8 /* Delegate */ = {
isa = PBXGroup;
children = (
681D37D826A4A75F000D9FE8 /* ClassDataDelegate.swift */,
);
path = Delegate;
sourceTree = "<group>";
Expand Down Expand Up @@ -660,6 +663,7 @@
68F1A5ED26A008FF007B4B86 /* GetEventListApiRequest.swift in Sources */,
68F1A61426A32356007B4B86 /* StorageManager.swift in Sources */,
68F1A60C26A307AB007B4B86 /* StringSet.swift in Sources */,
681D37D926A4A75F000D9FE8 /* ClassDataDelegate.swift in Sources */,
68F1A60F26A30D07007B4B86 /* Alert.swift in Sources */,
681D37BB26A4279F000D9FE8 /* BoardView.swift in Sources */,
681D37D526A48A6F000D9FE8 /* MyPageModel.swift in Sources */,
Expand Down
15 changes: 15 additions & 0 deletions KNU_CSE/KNU_CSE/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,21 @@
</objects>
<point key="canvasLocation" x="432" y="109"/>
</scene>
<!--Reservation View-->
<scene sceneID="nEe-yW-XSV">
<objects>
<viewController storyboardIdentifier="ReservationView" useStoryboardIdentifierAsRestorationIdentifier="YES" id="2AY-2Z-OAL" customClass="ReservationView" customModule="KNU_CSE" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="n5J-FJ-x7r">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<viewLayoutGuide key="safeArea" id="ef4-mu-DxO"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="mZa-60-qRb" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2996" y="975"/>
</scene>
</scenes>
<resources>
<image name="arrow.up.bin.fill" catalog="system" width="128" height="93"/>
Expand Down
13 changes: 13 additions & 0 deletions KNU_CSE/KNU_CSE/Custom/Delegate/ClassDataDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// ClassDataDelegate.swift
// KNU_CSE
//
// Created by junseok on 2021/07/19.
//

import Foundation

protocol ClassDataDelegate {
func sendData(data: ClassRoom)
}

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import UIKit
class ClassRoomView : UIViewController{

let classRoomViewModel : ClassRoomViewModel = ClassRoomViewModel()
var delegate: ClassDataDelegate?

var cellRowHeight : CGFloat!

Expand Down Expand Up @@ -64,9 +65,11 @@ extension ClassRoomView : UITableViewDataSource{
cell.selectionStyle = .none
cell.classRoom = classRoomViewModel.classrooms[indexPath.row]
cell.setAction{
let pushVC = self.storyboard?.instantiateViewController(withIdentifier: "SignUpView")
let pushVC = self.storyboard?.instantiateViewController(withIdentifier: "ReservationView") as? ReservationView
self.navigationController?.pushViewController(pushVC!, animated: true)
print("click")
self.delegate = pushVC
self.delegate?.sendData(data: self.classRoomViewModel.classrooms[indexPath.row])

}
return cell
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import Foundation
import UIKit

class ReservationView : UIViewController{

class ReservationView : UIViewController, ClassDataDelegate{
override func viewWillAppear(_ animated: Bool) {
// self.navigationController?.navigationBar.topItem?.title = "강의실 예약"
}
Expand All @@ -18,6 +18,7 @@ class ReservationView : UIViewController{
initUI()
addView()
setupConstraints()

}

func initUI(){
Expand All @@ -32,4 +33,7 @@ class ReservationView : UIViewController{

}

func sendData(data: ClassRoom) {
print(data.building, data.roomId)
}
}

0 comments on commit e205e38

Please sign in to comment.