diff --git a/KNU_CSE/KNU_CSE.xcodeproj/project.pbxproj b/KNU_CSE/KNU_CSE.xcodeproj/project.pbxproj index 49d8b5c..cd8528c 100644 --- a/KNU_CSE/KNU_CSE.xcodeproj/project.pbxproj +++ b/KNU_CSE/KNU_CSE.xcodeproj/project.pbxproj @@ -36,6 +36,11 @@ 681D37F426A737AE000D9FE8 /* SignInNavigationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 681D37F326A737AE000D9FE8 /* SignInNavigationView.swift */; }; 681D37F726A73D3E000D9FE8 /* BoardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 681D37F626A73D3E000D9FE8 /* BoardView.swift */; }; 681D37F926A73F71000D9FE8 /* BoardTitleCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 681D37F826A73F70000D9FE8 /* BoardTitleCell.swift */; }; + 681D37FD26A99454000D9FE8 /* BoardDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 681D37FC26A99454000D9FE8 /* BoardDetailView.swift */; }; + 681D380926A9C5BE000D9FE8 /* BoardDetailModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 681D380826A9C5BE000D9FE8 /* BoardDetailModel.swift */; }; + 681D380B26A9C642000D9FE8 /* BoardDetailViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 681D380A26A9C642000D9FE8 /* BoardDetailViewModel.swift */; }; + 681D380D26A9CDA1000D9FE8 /* BoardDataDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 681D380C26A9CDA1000D9FE8 /* BoardDataDelegate.swift */; }; + 681D380F26A9FC51000D9FE8 /* CommentTableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 681D380E26A9FC51000D9FE8 /* CommentTableCell.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 */; }; @@ -117,6 +122,11 @@ 681D37F326A737AE000D9FE8 /* SignInNavigationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignInNavigationView.swift; sourceTree = ""; }; 681D37F626A73D3E000D9FE8 /* BoardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoardView.swift; sourceTree = ""; }; 681D37F826A73F70000D9FE8 /* BoardTitleCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoardTitleCell.swift; sourceTree = ""; }; + 681D37FC26A99454000D9FE8 /* BoardDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoardDetailView.swift; sourceTree = ""; }; + 681D380826A9C5BE000D9FE8 /* BoardDetailModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoardDetailModel.swift; sourceTree = ""; }; + 681D380A26A9C642000D9FE8 /* BoardDetailViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoardDetailViewModel.swift; sourceTree = ""; }; + 681D380C26A9CDA1000D9FE8 /* BoardDataDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoardDataDelegate.swift; sourceTree = ""; }; + 681D380E26A9FC51000D9FE8 /* CommentTableCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommentTableCell.swift; sourceTree = ""; }; 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 = ""; }; 68F1A5B926A0088B007B4B86 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -198,7 +208,9 @@ isa = PBXGroup; children = ( 681D37F626A73D3E000D9FE8 /* BoardView.swift */, + 681D37FB26A99406000D9FE8 /* BoardDetail */, 681D37F526A73CC8000D9FE8 /* FreeBoard */, + 681D37FA26A8BB92000D9FE8 /* NoticeBoard */, ); path = Board; sourceTree = ""; @@ -221,6 +233,7 @@ 681D37DC26A5BF2D000D9FE8 /* ClassSeatCell.swift */, 681D37EB26A6CD87000D9FE8 /* ReservationCheckCell.swift */, 681D37F826A73F70000D9FE8 /* BoardTitleCell.swift */, + 681D380E26A9FC51000D9FE8 /* CommentTableCell.swift */, ); path = Cell; sourceTree = ""; @@ -253,6 +266,7 @@ 681D37D826A4A75F000D9FE8 /* ClassDataDelegate.swift */, 681D37E426A6AD36000D9FE8 /* ViewProtocol.swift */, 681D37F126A70FE2000D9FE8 /* ReservationCheckDelegate.swift */, + 681D380C26A9CDA1000D9FE8 /* BoardDataDelegate.swift */, ); path = Delegate; sourceTree = ""; @@ -277,6 +291,23 @@ path = FreeBoard; sourceTree = ""; }; + 681D37FA26A8BB92000D9FE8 /* NoticeBoard */ = { + isa = PBXGroup; + children = ( + ); + path = NoticeBoard; + sourceTree = ""; + }; + 681D37FB26A99406000D9FE8 /* BoardDetail */ = { + isa = PBXGroup; + children = ( + 681D37FC26A99454000D9FE8 /* BoardDetailView.swift */, + 681D380A26A9C642000D9FE8 /* BoardDetailViewModel.swift */, + 681D380826A9C5BE000D9FE8 /* BoardDetailModel.swift */, + ); + path = BoardDetail; + sourceTree = ""; + }; 68D5448F26A40E220072C2A4 /* KNU Notice */ = { isa = PBXGroup; children = ( @@ -729,6 +760,7 @@ 681D37D926A4A75F000D9FE8 /* ClassDataDelegate.swift in Sources */, 68F1A60F26A30D07007B4B86 /* Alert.swift in Sources */, 681D37BB26A4279F000D9FE8 /* FreeBoardView.swift in Sources */, + 681D380D26A9CDA1000D9FE8 /* BoardDataDelegate.swift in Sources */, 681D37D526A48A6F000D9FE8 /* MyPageModel.swift in Sources */, 681D37CA26A467CA000D9FE8 /* ReservationView.swift in Sources */, 68F1A5F826A0090B007B4B86 /* SignUpViewModel.swift in Sources */, @@ -743,13 +775,16 @@ 681D37C426A45442000D9FE8 /* ClassRoomCell.swift in Sources */, 68F1A61226A3120D007B4B86 /* TabView.swift in Sources */, 68F1A5BA26A0088B007B4B86 /* SceneDelegate.swift in Sources */, + 681D380F26A9FC51000D9FE8 /* CommentTableCell.swift in Sources */, 68F1A5F626A0090B007B4B86 /* SignUpModel.swift in Sources */, 68F1A60326A0A73B007B4B86 /* Color.swift in Sources */, 681D37EC26A6CD87000D9FE8 /* ReservationCheckCell.swift in Sources */, 681D37DF26A5DABC000D9FE8 /* ReservationModel.swift in Sources */, 68F1A5FC26A01080007B4B86 /* SignInViewModel.swift in Sources */, 68F1A5F926A0090B007B4B86 /* BindingTextField.swift in Sources */, + 681D37FD26A99454000D9FE8 /* BoardDetailView.swift in Sources */, 681D37B526A419F3000D9FE8 /* MyPageView.swift in Sources */, + 681D380926A9C5BE000D9FE8 /* BoardDetailModel.swift in Sources */, 681D37DB26A4AAAC000D9FE8 /* ReservationViewModel.swift in Sources */, 68F1A60026A07FE7007B4B86 /* CheckBox.swift in Sources */, 68F1A5EC26A008FF007B4B86 /* Request.swift in Sources */, @@ -765,6 +800,7 @@ 681D37F726A73D3E000D9FE8 /* BoardView.swift in Sources */, 681D37EE26A70493000D9FE8 /* ReservationCheckViewModel.swift in Sources */, 681D37D326A48A64000D9FE8 /* MyPageViewModel.swift in Sources */, + 681D380B26A9C642000D9FE8 /* BoardDetailViewModel.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/KNU_CSE/KNU_CSE/Base.lproj/Main.storyboard b/KNU_CSE/KNU_CSE/Base.lproj/Main.storyboard index bce9ea3..48e0273 100644 --- a/KNU_CSE/KNU_CSE/Base.lproj/Main.storyboard +++ b/KNU_CSE/KNU_CSE/Base.lproj/Main.storyboard @@ -200,6 +200,21 @@ + + + + + + + + + + + + + + + diff --git a/KNU_CSE/KNU_CSE/Custom/Cell/CommentTableCell.swift b/KNU_CSE/KNU_CSE/Custom/Cell/CommentTableCell.swift new file mode 100644 index 0000000..44d0fb0 --- /dev/null +++ b/KNU_CSE/KNU_CSE/Custom/Cell/CommentTableCell.swift @@ -0,0 +1,84 @@ +// +// CommentTableCell.swift +// KNU_CSE +// +// Created by junseok on 2021/07/23. +// + +import UIKit + +class CommentTableCell : UITableViewCell { + static let identifier = "CommentTableCell" + var titleView = UIView() + + var titleLabel:UILabel!{ + didSet{ + titleLabel.font = UIFont.systemFont(ofSize: 13, weight: .light) + titleLabel.textAlignment = .right + } + } + + var contentLabel:UILabel!{ + didSet{ + contentLabel.font = UIFont.systemFont(ofSize: 13, weight: .semibold) + contentLabel.textAlignment = .left + } + } + + var action :()->() = {} + + var comment:Comment!{ + didSet{ + titleLabel.text = comment.author + contentLabel.text = comment.content + + self.setUpConstraints() + } + } + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + self.initUI() + self.addView() + + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + func initUI(){ + self.titleLabel = UILabel() + self.contentLabel = UILabel() + } + + func addView(){ + self.contentView.addSubview(titleView) + self.contentView.addSubview(contentLabel) + + self.titleView.addSubview(titleLabel) + } + + func setUpConstraints(){ + titleView.snp.makeConstraints{ make in + make.left.equalToSuperview() + make.top.equalToSuperview() + make.bottom.equalToSuperview() + make.width.equalToSuperview().multipliedBy(0.3) + } + + titleLabel.snp.makeConstraints{ make in + make.left.equalToSuperview() + make.top.equalToSuperview() + make.bottom.equalToSuperview() + make.right.equalToSuperview().offset(-20) + } + + contentLabel.snp.makeConstraints{ make in + make.left.equalTo(titleView.snp.right).offset(0) + make.top.equalToSuperview() + make.bottom.equalToSuperview() + make.right.equalToSuperview().offset(0) + } + } +} diff --git a/KNU_CSE/KNU_CSE/Custom/Cell/FreeBoardCell.swift b/KNU_CSE/KNU_CSE/Custom/Cell/FreeBoardCell.swift index 2b72050..b51de8e 100644 --- a/KNU_CSE/KNU_CSE/Custom/Cell/FreeBoardCell.swift +++ b/KNU_CSE/KNU_CSE/Custom/Cell/FreeBoardCell.swift @@ -69,13 +69,13 @@ class FreeBoardCell : UITableViewCell { var action :()->() = {} var cellBtn = UIButton() - var viewModel : Board!{ + var board : Board!{ didSet{ - self.setAuthorText(title: viewModel.author) - self.setDateText(title: viewModel.date) - self.setTitleText(title: viewModel.title) - self.setContentText(title: viewModel.content) - self.setCommentText(title: String(viewModel.numberOfcomment)) + self.setAuthorText(title: board.author) + self.setDateText(title: board.date) + self.setTitleText(title: board.title) + self.setContentText(title: board.content) + self.setCommentText(title: String(board.numberOfcomment)) } } diff --git a/KNU_CSE/KNU_CSE/Custom/Delegate/BoardDataDelegate.swift b/KNU_CSE/KNU_CSE/Custom/Delegate/BoardDataDelegate.swift new file mode 100644 index 0000000..2b9f132 --- /dev/null +++ b/KNU_CSE/KNU_CSE/Custom/Delegate/BoardDataDelegate.swift @@ -0,0 +1,12 @@ +// +// BoardDataDelegate.swift +// KNU_CSE +// +// Created by junseok on 2021/07/23. +// + +import Foundation + +protocol BoardDataDelegate{ + func sendBoard(board:Board) +} diff --git a/KNU_CSE/KNU_CSE/Main Tab/Board/BoardDetail/BoardDetailModel.swift b/KNU_CSE/KNU_CSE/Main Tab/Board/BoardDetail/BoardDetailModel.swift new file mode 100644 index 0000000..916e033 --- /dev/null +++ b/KNU_CSE/KNU_CSE/Main Tab/Board/BoardDetail/BoardDetailModel.swift @@ -0,0 +1,46 @@ +// +// BoardDetailModel.swift +// KNU_CSE +// +// Created by junseok on 2021/07/23. +// + +import Foundation + +class Comment:BaseObject{ + var commentId:Int! + var content:String! + var date:String! + var author:String! + var replyList:[Reply]! + + init(commentId:Int, content:String, date:String, author:String) { + self.commentId = commentId + self.content = content + self.date = date + self.author = author + super.init() + } + + required init(from decoder: Decoder) throws { + fatalError("init(from:) has not been implemented") + } + + func setReplyList(replyList:[Reply]){ + self.replyList = replyList + } +} + +struct Reply:Codable{ + var replyId:Int! + var content:String! + var date:String! + var author:String! + + init(replyId:Int, content:String, date:String, author:String) { + self.replyId = replyId + self.content = content + self.date = date + self.author = author + } +} diff --git a/KNU_CSE/KNU_CSE/Main Tab/Board/BoardDetail/BoardDetailView.swift b/KNU_CSE/KNU_CSE/Main Tab/Board/BoardDetail/BoardDetailView.swift new file mode 100644 index 0000000..a5553e1 --- /dev/null +++ b/KNU_CSE/KNU_CSE/Main Tab/Board/BoardDetail/BoardDetailView.swift @@ -0,0 +1,228 @@ +// +// DetailView.swift +// KNU_CSE +// +// Created by junseok on 2021/07/22. +// + +import UIKit + +class BoardDetailView:UIViewController, ViewProtocol, BoardDataDelegate, UITableViewDelegate{ + + var boardDetailViewModel = BoardDetailViewModel() + + var scrollView:UIScrollView!{ + didSet{ + scrollView.alwaysBounceVertical = true + } + } + + var boardContentView:UIView = UIView() + + var authorLabel:UILabel!{ + didSet{ + authorLabel.text = boardDetailViewModel.board.author + authorLabel.textAlignment = .left + authorLabel.textColor = UIColor.black + authorLabel.font = UIFont.systemFont(ofSize: 15, weight: .light) + } + } + + var dateLabel:UILabel!{ + didSet{ + dateLabel.text = boardDetailViewModel.board.date + dateLabel.textAlignment = .right + dateLabel.textColor = UIColor.black + dateLabel.font = UIFont.systemFont(ofSize: 14, weight: .thin) + } + } + + var titleLabel:UILabel!{ + didSet{ + titleLabel.text = boardDetailViewModel.board.title + titleLabel.textAlignment = .left + titleLabel.textColor = UIColor.black + titleLabel.font = UIFont.systemFont(ofSize: 20, weight: .bold) + titleLabel.numberOfLines = 0 + titleLabel.sizeToFit() + } + } + + var contentLabel:UILabel!{ + didSet{ + contentLabel.text = boardDetailViewModel.board.content + contentLabel.textAlignment = .left + contentLabel.textColor = UIColor.black + contentLabel.font = UIFont.systemFont(ofSize: 16, weight: .regular) + contentLabel.numberOfLines = 0 + contentLabel.sizeToFit() + } + } + + var commentImage:UIImageView!{ + didSet{ + let image = UIImage(systemName: "text.bubble.fill") + commentImage.image = image + commentImage.tintColor = .lightGray + } + } + + var commentLabel:UILabel!{ + didSet{ + commentLabel.text = String(boardDetailViewModel.board.numberOfcomment) + commentLabel.textAlignment = .left + commentLabel.textColor = UIColor.black + commentLabel.font = UIFont.systemFont(ofSize: 16, weight: .regular) + } + } + + var borderLine:UIView!{ + didSet{ + borderLine.layer.borderWidth = 1 + borderLine.layer.borderColor = UIColor.lightGray.cgColor + } + } + + var commentTableView:UITableView!{ + didSet{ + commentTableView.register(CommentTableCell.self, forCellReuseIdentifier: CommentTableCell.identifier) + commentTableView.rowHeight = self.view.frame.height * 0.1 + commentTableView.dataSource = self + commentTableView.separatorInset.left = 0 + } + } + + override func viewWillAppear(_ animated: Bool) { + //self.hideBackBtnTitle() + } + + override func viewDidLoad() { + self.initUI() + self.addView() + self.setUpConstraints() + } + + func initUI(){ + scrollView = UIScrollView() + + authorLabel = UILabel() + dateLabel = UILabel() + titleLabel = UILabel() + contentLabel = UILabel() + commentImage = UIImageView() + commentLabel = UILabel() + borderLine = UIView() + + commentTableView = UITableView() + } + + func addView(){ + self.view.addSubview(scrollView) + self.scrollView.addSubview(boardContentView) + _ = [authorLabel, dateLabel, titleLabel, contentLabel, commentImage, commentLabel, borderLine, commentTableView].map { self.boardContentView.addSubview($0)} + } + + func setUpConstraints(){ + let height = self.view.frame.height * 0.2 + let tableHeight = self.view.frame.height * 0.1 * CGFloat(self.boardDetailViewModel.comments.count) + + self.scrollView.snp.makeConstraints{ make in + make.top.equalTo(self.view.safeAreaLayoutGuide) + make.left.equalTo(self.view.safeAreaLayoutGuide) + make.right.equalTo(self.view.safeAreaLayoutGuide) + make.bottom.equalTo(self.view.safeAreaLayoutGuide) + } + + self.boardContentView.snp.makeConstraints{ make in + make.top.equalToSuperview() + make.left.equalTo(self.view.safeAreaLayoutGuide) + make.right.equalTo(self.view.safeAreaLayoutGuide) + make.bottom.equalToSuperview()//필수 + } + + self.authorLabel.snp.makeConstraints{ make in + make.top.equalTo(boardContentView.snp.top).offset(15) + make.left.equalToSuperview().offset(20) + make.width.equalToSuperview().multipliedBy(0.5) + make.height.equalTo(height*0.1) + } + + self.dateLabel.snp.makeConstraints{ make in + make.top.equalTo(authorLabel.snp.top) + make.left.equalTo(self.authorLabel.snp.right) + make.right.equalTo(self.view.safeAreaLayoutGuide).offset(-20) + make.height.equalTo(height*0.1) + } + + self.titleLabel.snp.makeConstraints{ make in + make.top.equalTo(authorLabel.snp.bottom).offset(5) + make.left.equalTo(self.view.safeAreaLayoutGuide).offset(20) + make.right.equalTo(self.view.safeAreaLayoutGuide).offset(-20) + } + + self.contentLabel.snp.makeConstraints{ make in + make.top.equalTo(titleLabel.snp.bottom).offset(5) + make.left.equalTo(self.view.safeAreaLayoutGuide).offset(20) + make.right.equalTo(self.view.safeAreaLayoutGuide).offset(-20) + } + + self.commentLabel.snp.makeConstraints{ make in + make.top.equalTo(self.contentLabel.snp.bottom).offset(0) + make.right.equalTo(self.view.safeAreaLayoutGuide).offset(-20) + make.height.equalTo(height*0.1) + make.width.equalTo(height*0.1) + } + + self.commentImage.snp.makeConstraints{ make in + make.top.equalTo(self.contentLabel.snp.bottom).offset(0) + make.right.equalTo(commentLabel.snp.left).offset(-5) + make.height.equalTo(height*0.1) + make.width.equalTo(height*0.1) + } + + self.borderLine.snp.makeConstraints{ make in + make.top.equalTo(commentLabel.snp.bottom).offset(15) + make.left.equalTo(self.view.safeAreaLayoutGuide).offset(0) + make.right.equalTo(self.view.safeAreaLayoutGuide).offset(0) + make.height.equalTo(0.5) + //make.bottom.equalToSuperview()//필수 + } + + self.commentTableView.snp.makeConstraints{make in + make.top.equalTo(borderLine.snp.bottom).offset(0) + make.left.equalTo(self.view.safeAreaLayoutGuide).offset(0) + make.right.equalTo(self.view.safeAreaLayoutGuide).offset(0) + make.height.equalTo(tableHeight) + make.bottom.equalToSuperview().offset(-20)//아래 여백 주기 + } + + } +} + +extension BoardDetailView{ + func sendBoard(board: Board) { + self.boardDetailViewModel.board = board + } + + func hideBackBtnTitle(){ + let backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: self, action: nil) + self.navigationController?.navigationBar.topItem?.backBarButtonItem = backBarButtonItem + } +} + +extension BoardDetailView:UITableViewDataSource{ + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return self.boardDetailViewModel.comments.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: CommentTableCell.identifier, for: indexPath) as! CommentTableCell + cell.comment = self.boardDetailViewModel.comments[indexPath.row] + let testView = UIView() + testView.backgroundColor = .yellow + testView + return cell + } + + +} diff --git a/KNU_CSE/KNU_CSE/Main Tab/Board/BoardDetail/BoardDetailViewModel.swift b/KNU_CSE/KNU_CSE/Main Tab/Board/BoardDetail/BoardDetailViewModel.swift new file mode 100644 index 0000000..93c9f40 --- /dev/null +++ b/KNU_CSE/KNU_CSE/Main Tab/Board/BoardDetail/BoardDetailViewModel.swift @@ -0,0 +1,27 @@ +// +// BoardViewDetailViewModel.swift +// KNU_CSE +// +// Created by junseok on 2021/07/23. +// + +import Foundation + +struct BoardDetailViewModel{ + var board:Board! + var comments:[Comment] = [] + + init(){ + self.setComment() + } + + mutating func setComment(){ + self.comments.append(Comment(commentId: 123, content: "hihi zz", date: "2021 07.24 23:16", author: "노준석")) + var replys:[Reply] = [] + replys.append(Reply(replyId: 1, content: "ㅅㅂ", date: "2021 07.24 23:16", author: "ㅅㅂ롬")) + replys.append(Reply(replyId: 1, content: "ㅅㅂ", date: "2021 07.24 23:16", author: "ㅅㅂ롬")) + replys.append(Reply(replyId: 1, content: "ㅅㅂ", date: "2021 07.24 23:16", author: "ㅅㅂ롬")) + replys.append(Reply(replyId: 1, content: "ㅅㅂ", date: "2021 07.24 23:16", author: "ㅅㅂ롬")) + self.comments[0].setReplyList(replyList: replys) + } +} diff --git a/KNU_CSE/KNU_CSE/Main Tab/Board/BoardView.swift b/KNU_CSE/KNU_CSE/Main Tab/Board/BoardView.swift index ee0276a..83b93de 100644 --- a/KNU_CSE/KNU_CSE/Main Tab/Board/BoardView.swift +++ b/KNU_CSE/KNU_CSE/Main Tab/Board/BoardView.swift @@ -132,6 +132,7 @@ extension BoardView{ } func addFreeBoardVC(){ + self.addChild(freeBoardVC) pageView.addSubview(freeBoardVC.view) freeBoardVC.view.snp.makeConstraints{ make in make.left.right.top.bottom.equalToSuperview() @@ -146,6 +147,7 @@ extension BoardView{ } func addNoticeBoardVC(){ + self.addChild(noticeBoardVC) pageView.addSubview(noticeBoardVC.view) noticeBoardVC.view.snp.makeConstraints{ make in make.left.right.top.bottom.equalToSuperview() diff --git a/KNU_CSE/KNU_CSE/Main Tab/Board/FreeBoard/FreeBoardView.swift b/KNU_CSE/KNU_CSE/Main Tab/Board/FreeBoard/FreeBoardView.swift index c27bf80..2b60cf6 100644 --- a/KNU_CSE/KNU_CSE/Main Tab/Board/FreeBoard/FreeBoardView.swift +++ b/KNU_CSE/KNU_CSE/Main Tab/Board/FreeBoard/FreeBoardView.swift @@ -8,11 +8,12 @@ import Foundation import UIKit -class FreeBoardView : UIViewController{ +class FreeBoardView : UINavigationController{ let freeBordViewModel : FreeBoardViewModel = FreeBoardViewModel() var cellRowHeight : CGFloat! + var boardDelegate:BoardDataDelegate? var freeboardTableView :UITableView!{ didSet{ @@ -24,12 +25,12 @@ class FreeBoardView : UIViewController{ } } - override func viewWillAppear(_ animated: Bool) { self.navigationController?.navigationBar.topItem?.title = "자유게시판" } override func viewDidLoad() { + super.viewDidLoad() self.initUI() self.addView() self.setupConstraints() @@ -62,12 +63,27 @@ extension FreeBoardView : UITableViewDataSource{ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: FreeBoardCell.identifier, for: indexPath) as! FreeBoardCell + let board = freeBordViewModel.boards[indexPath.row] + cell.selectionStyle = .none - cell.viewModel = freeBordViewModel.boards[indexPath.row] + cell.board = board cell.height = cellRowHeight * 0.115 cell.cellBtn.addAction { - print("\(indexPath.row)") + self.pushDetaiView(board: board) } return cell } } + + +extension FreeBoardView{ + func pushDetaiView(board:Board){ + let pushVC = (self.storyboard?.instantiateViewController(withIdentifier: "BoardDetailView")) as? BoardDetailView + self.boardDelegate = pushVC + self.boardDelegate?.sendBoard(board: board) + + if let parentVC = self.parent as? BoardView { + parentVC.navigationController?.pushViewController(pushVC!, animated: true) + } + } +} diff --git a/KNU_CSE/KNU_CSE/Main Tab/Board/FreeBoard/FreeBoardViewModel.swift b/KNU_CSE/KNU_CSE/Main Tab/Board/FreeBoard/FreeBoardViewModel.swift index 6d5809c..7566bb3 100644 --- a/KNU_CSE/KNU_CSE/Main Tab/Board/FreeBoard/FreeBoardViewModel.swift +++ b/KNU_CSE/KNU_CSE/Main Tab/Board/FreeBoard/FreeBoardViewModel.swift @@ -16,7 +16,7 @@ struct FreeBoardViewModel{ mutating func setUpBoards(){ boards.append(Board(boardId: 1, category: 0, title: "테스트 게시판1", content: "테스트 게시판1", author: "노준석", date: "2021 07.24 23:11",numberOfcomment: 1)) - boards.append(Board(boardId: 1, category: 0, title: "테스트 게시판2", content: "ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss", author: "노준석", date: "2021 07.24 23:12",numberOfcomment: 1)) + boards.append(Board(boardId: 1, category: 0, title: "테스트 게시판2", content: "ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\nsssssss\nssssssssssss\nsssssssssssss\nsssssssssssss\nsssssssssssaazzzzzzzzzzㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋsssssssㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋsssssssssㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋsssstqtqtqt\nqtqtqtqtqt\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\ntqtqtqtqttqtqtqtqttqtqtqtqttqtqtqtqttqtqtqtqttqtqtqtqttqtqtqtqttqtqtqtqttqtqtqtqttqtqtqtqt", author: "노준석", date: "2021 07.24 23:12",numberOfcomment: 1)) boards.append(Board(boardId: 1, category: 0, title: "테스트 게시판3", content: "테스트 게시판3", author: "노준석", date: "2021 07.24 23:13",numberOfcomment: 1)) boards.append(Board(boardId: 1, category: 0, title: "테스트 게시판4", content: "테스트 게시판4", author: "노준석", date: "2021 07.24 23:14",numberOfcomment: 1)) boards.append(Board(boardId: 1, category: 0, title: "테스트 게시판5", content: "테스트 게시판5", author: "노준석", date: "2021 07.24 23:15",numberOfcomment: 1)) diff --git a/KNU_CSE/KNU_CSE/Main Tab/ReservationCheck/ReservationCheckView.swift b/KNU_CSE/KNU_CSE/Main Tab/ReservationCheck/ReservationCheckView.swift index 246f050..9e12028 100644 --- a/KNU_CSE/KNU_CSE/Main Tab/ReservationCheck/ReservationCheckView.swift +++ b/KNU_CSE/KNU_CSE/Main Tab/ReservationCheck/ReservationCheckView.swift @@ -75,6 +75,7 @@ class ReservationCheckView: UIViewController, ViewProtocol{ } override func viewDidLoad() { + super.viewDidLoad() initUI() addView() setUpConstraints()