diff --git a/ParentAssistant/ParentAssistant.xcodeproj/project.pbxproj b/ParentAssistant/ParentAssistant.xcodeproj/project.pbxproj index 55708f8..70c9db8 100644 --- a/ParentAssistant/ParentAssistant.xcodeproj/project.pbxproj +++ b/ParentAssistant/ParentAssistant.xcodeproj/project.pbxproj @@ -43,6 +43,7 @@ ADAEA3982064960300A47D2C /* SceneDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADAEA3972064960300A47D2C /* SceneDetailViewController.swift */; }; ADAEA39A2064C44900A47D2C /* LineChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADAEA3992064C44900A47D2C /* LineChartView.swift */; }; ADE33B312062202300BEA6E6 /* Macro.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADE33B302062202300BEA6E6 /* Macro.swift */; }; + ADF159612069E00000A9485D /* CalendarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADF159602069E00000A9485D /* CalendarView.swift */; }; BF388469205A4DE900A240EF /* StudentClassInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF388468205A4DE900A240EF /* StudentClassInfo.swift */; }; BF38846C205A58F800A240EF /* YXMessageManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF38846B205A58F800A240EF /* YXMessageManager.swift */; }; BF38846E205A5A0000A240EF /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF38846D205A59FE00A240EF /* MobileCoreServices.framework */; }; @@ -188,6 +189,7 @@ ADAEA3972064960300A47D2C /* SceneDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SceneDetailViewController.swift; sourceTree = ""; }; ADAEA3992064C44900A47D2C /* LineChartView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineChartView.swift; sourceTree = ""; }; ADE33B302062202300BEA6E6 /* Macro.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Macro.swift; sourceTree = ""; }; + ADF159602069E00000A9485D /* CalendarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarView.swift; sourceTree = ""; }; BF388468205A4DE900A240EF /* StudentClassInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudentClassInfo.swift; sourceTree = ""; }; BF38846B205A58F800A240EF /* YXMessageManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YXMessageManager.swift; sourceTree = ""; }; BF38846D205A59FE00A240EF /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; }; @@ -514,6 +516,7 @@ isa = PBXGroup; children = ( BF3B829F2050CC8B002078EA /* ReportHeaderView.swift */, + ADF159602069E00000A9485D /* CalendarView.swift */, BF3B82A32050DA75002078EA /* ReportHeaderView.xib */, BFEAAAA8205248AC0072FAAF /* TaskPresentationTableViewCell.swift */, BFEAAAAA205249B50072FAAF /* ReportDateCollectionViewCell.swift */, @@ -979,6 +982,7 @@ BFEAAAC4205257460072FAAF /* LXCalendarMonthModel.m in Sources */, BF38847E205CDE2D00A240EF /* JSViewController.swift in Sources */, ADE33B312062202300BEA6E6 /* Macro.swift in Sources */, + ADF159612069E00000A9485D /* CalendarView.swift in Sources */, BF406CD82057B529000A6681 /* MessageTableViewCell.swift in Sources */, 599364EC204E62E700C8B371 /* EvaluationViewController.swift in Sources */, 599364F0204E62E700C8B371 /* ReportViewController.swift in Sources */, diff --git a/ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate b/ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate index 7864b77..43d6d6d 100644 Binary files a/ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate and b/ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/ParentAssistant/ParentAssistant/Classes/controllers/report/ReportViewController.swift b/ParentAssistant/ParentAssistant/Classes/controllers/report/ReportViewController.swift index 0d923fd..14d86df 100644 --- a/ParentAssistant/ParentAssistant/Classes/controllers/report/ReportViewController.swift +++ b/ParentAssistant/ParentAssistant/Classes/controllers/report/ReportViewController.swift @@ -11,11 +11,17 @@ import UIKit class ReportViewController: UIViewController { var titleView:ReportHeaderView!//navigationBar自定义view @IBOutlet weak var reportTable: UITableView! - @IBOutlet var dateViewHeight: NSLayoutConstraint!//顶部固定日期的高度 -// @IBOutlet var calendarView: UIView! + //空白页 var EmptyView: UIView! - var dateView:LXCalendarView! - var dateAry:(weeks:[String],days:[String]) = ([],[]) + + //膜板 + var keyWindow = UIWindow() + var backBotton = UIButton() + //日历 + var calendar = CalendarView() + +// var dateAry:(weeks:[String],days:[String]) = ([],[]) + override func viewDidLoad() { super.viewDidLoad() @@ -33,7 +39,7 @@ class ReportViewController: UIViewController { //设置顶部按钮 setupNavigationBar() //设置日期页面 -// setupDateView() + setupDateView() } } // MARK: - 设置顶部按钮 @@ -42,61 +48,72 @@ class ReportViewController: UIViewController { let backImage = UIImage(named: "navigationBar_backgrounImage") self.navigationController?.navigationBar.setBackgroundImage(backImage, for: UIBarMetrics.default) self.configTheme() - self.navigationItem.title = "报告" +// self.navigationItem.title = "报告" setuptitleView() } func setuptitleView(){ - // MARK: - 设置顶部的titleView - titleView = Bundle.main.loadNibNamed("ReportHeaderView", owner: nil, options: nil)![0] as! ReportHeaderView - titleView.delegate = self - titleView.frame = CGRect(x: 0, y: 0, width: screenWidth, height: 44) - self.navigationItem.titleView = titleView - titleView.layoutSubviews() - //navigation左上角显示名称 家长未绑定孩子 - if AccountManager.shared.isOnline() { - if AccountManager.shared.rawUserInfo!.contentData()["studentClass"].arrayValue.count == 0 { - titleView.nameButton.setTitle("未绑定", for: UIControlState.normal) - }else{ - titleView.nameButton.setTitle(AccountManager.shared.rawUserInfo!.contentData()["studentClass"][0]["studentName"].stringValue, for: UIControlState.normal) - } - }else{ - titleView.nameButton.setTitle("未登录", for: UIControlState.normal) - } + + +// // MARK: - 设置顶部的titleView +// titleView = Bundle.main.loadNibNamed("ReportHeaderView", owner: nil, options: nil)![0] as! ReportHeaderView +//// titleView.delegate = self +// titleView.frame = CGRect(x: 0, y: 0, width: screenWidth, height: 44) +// self.navigationItem.titleView = titleView +// titleView.layoutSubviews() +// //navigation左上角显示名称 家长未绑定孩子 +// if AccountManager.shared.isOnline() { +// if AccountManager.shared.rawUserInfo!.contentData()["studentClass"].arrayValue.count == 0 { +// titleView.nameButton.setTitle("未绑定", for: UIControlState.normal) +// }else{ +// titleView.nameButton.setTitle(AccountManager.shared.rawUserInfo!.contentData()["studentClass"][0]["studentName"].stringValue, for: UIControlState.normal) +// } +// }else{ +// titleView.nameButton.setTitle("未登录", for: UIControlState.normal) +// } } // MARK: - 设置日期页面 func setupDateView(){ -// titleView.dateButton.setTitle("\(getCurrentDate())", for: UIControlState.normal) -// dateViewHeight.constant = getScreenWidth()/7 -// //添加顶部固定一周日期 -// dateAry = getCurrentWeeks() -// //添加日历 -// dateView = LXCalendarView(frame: CGRect(x: 0, y: 0, width: screenWidth, height: screenWidth/2)) -// dateView.isHaveAnimation = true -// dateView.isCanScroll = true -// dateView.isShowLastAndNextBtn = false -// dateView.isShowLastAndNextDate = true -// -// dateView.todayTitleColor = UIColor.red -// dateView.selectBackColor = UIColorFromRGB(0xC5DAFF) -// dateView.dealData() -// dateView.backgroundColor = UIColor.white -// calendarView.addSubview(dateView) -// dateView.selectBlock = { (year:NSInteger,month:NSInteger,day:NSInteger) -> () in -// self.calendarView.isHidden = true -// self.titleView.dateButton.setTitle("\(month)月\(day)日", for: UIControlState.normal) -// //选择日期后应隐藏日历并刷新界面 -// appDelegate.window!.makeToast("\(year)年\(month)月\(day)日", duration: 2, position: CSToastPositionCenter) -// -// } + + let headView = UIView.init(frame: CGRect.init(x: 0, y: 0, width: screenWidth, height: 60)) + self.view.addSubview(headView) + + //添加手势 + let recognizer = UISwipeGestureRecognizer.init(target: self, action: #selector(showView)) + recognizer.direction = UISwipeGestureRecognizerDirection.down + headView.addGestureRecognizer(recognizer) + + calendar = CalendarView.init(frame: CGRect.init(x: 0, y: 30, width: screenWidth, height: 260)) + } + + @objc func showView(){ + keyWindow = UIApplication.shared.keyWindow! + let backBtn = UIButton.init(frame: CGRect.init(x: 0, y: calendar.frame.origin.y+260+22, width: screenWidth, height: screenHeight)) + backBtn.backgroundColor = UIColor.black + backBtn.alpha = 0.4 + + backBtn.addTarget(self, action: #selector(closeView(btn:)), for: UIControlEvents.allEvents) + reportTable.isUserInteractionEnabled = false + + keyWindow.addSubview(backBtn) + keyWindow.addSubview(calendar) + calendar.isHidden = false + } + @objc func closeView(btn:UIButton) { + + reportTable.isUserInteractionEnabled = true + UIView.animate(withDuration: 0.3) { + btn.removeFromSuperview() + self.calendar.isHidden = true + } } + // MARK: - 页面将要显示时替换navigation的titleView override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) } override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) -// self.calendarView.isHidden = true } override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() @@ -111,66 +128,59 @@ class ReportViewController: UIViewController { } // MARK: - 点击顶部titleView按钮的代理方法 -extension ReportViewController: ReportHeaderViewDelegate{ - //点击孩子姓名 - func selectStudentButton() { - appDelegate.window!.makeToast("该功能暂不开放", duration: 1, position: CSToastPositionCenter) - return - //如果家长未绑定孩子 - if AccountManager.shared.isOnline() { - if AccountManager.shared.rawUserInfo!.contentData()["studentClass"].arrayValue.count == 0 { - appDelegate.window!.makeToast("请先绑定孩子", duration: 1, position: CSToastPositionCenter) - }else{ - //切换孩子 - let alert = UIAlertController(title: "切换孩子", message: "", preferredStyle: UIAlertControllerStyle.actionSheet) - for item in AccountManager.shared.rawUserInfo!.contentData()["studentClass"].arrayValue { - let action = UIAlertAction(title: item["studentName"].stringValue, style: UIAlertActionStyle.default, handler: { (action) in - //选择完孩子切换数据 - }) - alert.addAction(action) - } - self.present(alert, animated: true, completion: nil) - } - }else{ - appDelegate.window!.makeToast("请先登录", duration: 1, position: CSToastPositionCenter) - } - } - //点击日期 - func selectDateButton() { - - appDelegate.window!.makeToast("该功能暂不开放", duration: 1, position: CSToastPositionCenter) - return - -// let isHidden = calendarView.isHidden -// if isHidden { -// calendarView.isHidden = false +//extension ReportViewController: ReportHeaderViewDelegate{ +// //点击孩子姓名 +// func selectStudentButton() { +// appDelegate.window!.makeToast("该功能暂不开放", duration: 1, position: CSToastPositionCenter) +// return +// //如果家长未绑定孩子 +// if AccountManager.shared.isOnline() { +// if AccountManager.shared.rawUserInfo!.contentData()["studentClass"].arrayValue.count == 0 { +// appDelegate.window!.makeToast("请先绑定孩子", duration: 1, position: CSToastPositionCenter) +// }else{ +// //切换孩子 +// let alert = UIAlertController(title: "切换孩子", message: "", preferredStyle: UIAlertControllerStyle.actionSheet) +// for item in AccountManager.shared.rawUserInfo!.contentData()["studentClass"].arrayValue { +// let action = UIAlertAction(title: item["studentName"].stringValue, style: UIAlertActionStyle.default, handler: { (action) in +// //选择完孩子切换数据 +// }) +// alert.addAction(action) +// } +// self.present(alert, animated: true, completion: nil) +// } // }else{ -// calendarView.isHidden = true +// appDelegate.window!.makeToast("请先登录", duration: 1, position: CSToastPositionCenter) // } - } - //点击筛选 - func selectTypeButton() { - appDelegate.window!.makeToast("该功能暂不开放", duration: 1, position: CSToastPositionCenter) - return - } -} -// MARK: - 顶部展示日期 -extension ReportViewController: UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout { - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - return CGSize(width: getScreenWidth()/7, height: getScreenWidth()/7) - } - func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return 0 - } - - func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ReportDateCollectionViewCell", for: indexPath) as! ReportDateCollectionViewCell - cell.setupWithDate(week: dateAry.weeks[indexPath.row], date: dateAry.days[indexPath.row]) - return cell - } - - -} +// } +// //点击日期 +// func selectDateButton() { +// +// appDelegate.window!.makeToast("该功能暂不开放", duration: 1, position: CSToastPositionCenter) +// return +// } +// //点击筛选 +// func selectTypeButton() { +// appDelegate.window!.makeToast("该功能暂不开放", duration: 1, position: CSToastPositionCenter) +// return +// } +//} +//// MARK: - 顶部展示日期 +//extension ReportViewController: UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout { +// func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { +// return CGSize(width: getScreenWidth()/7, height: getScreenWidth()/7) +// } +// func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { +// return 0 +// } +// +// func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { +// let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ReportDateCollectionViewCell", for: indexPath) as! ReportDateCollectionViewCell +// cell.setupWithDate(week: dateAry.weeks[indexPath.row], date: dateAry.days[indexPath.row]) +// return cell +// } +// +// +//} // MARK: - 作业报告列表 extension ReportViewController: UITableViewDelegate,UITableViewDataSource{ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { diff --git a/ParentAssistant/ParentAssistant/Classes/controllers/report/View/CalendarView.swift b/ParentAssistant/ParentAssistant/Classes/controllers/report/View/CalendarView.swift new file mode 100644 index 0000000..2192eea --- /dev/null +++ b/ParentAssistant/ParentAssistant/Classes/controllers/report/View/CalendarView.swift @@ -0,0 +1,72 @@ +// +// CalendarView.swift +// ParentAssistant +// +// Created by Cao yang on 2018/3/27. +// Copyright © 2018年 HANGZHOUTEAM. All rights reserved. +// + +import UIKit + +class CalendarView: UIView,UICollectionViewDelegate,UICollectionViewDataSource { + + + var weekLab = ["日","一","二","三","四","五","六"] + + override init(frame: CGRect) { + super.init(frame: frame) + self.drawCalendarView(frame: frame) + } + + func drawCalendarView(frame:CGRect) { + //TODO: 数据源待完成 + let dayLab = ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"] + weekLab.append(contentsOf: dayLab) + //设置layout + let flowlayout = UICollectionViewFlowLayout() + flowlayout.itemSize = CGSize.init(width: screenWidth/7, height:40) + flowlayout.minimumLineSpacing = 0 + flowlayout.minimumInteritemSpacing = 0 + flowlayout.headerReferenceSize = CGSize.init(width: 0, height: 0) + flowlayout.footerReferenceSize = CGSize.init(width: 0, height: 0) + flowlayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0) + + let calendarView = UICollectionView.init(frame: frame, collectionViewLayout: flowlayout) + calendarView.delegate = self + calendarView.dataSource = self + calendarView.backgroundColor = UIColor.white + calendarView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "calendarCell") + self.addSubview(calendarView) + } + + //MARK: - Delegate + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return weekLab.count + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "calendarCell", for: indexPath) + let lab = UILabel.init(frame: cell.bounds) + lab.text = weekLab[indexPath.row] + lab.textAlignment = .center + cell.addSubview(lab) + return cell + + } + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + print("点击了 第 \(weekLab[indexPath.row])") + } + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + /* + // Only override draw() if you perform custom drawing. + // An empty implementation adversely affects performance during animation. + override func draw(_ rect: CGRect) { + // Drawing code + } + */ + +} diff --git a/ParentAssistant/ParentAssistant/Supporting Files/Base.lproj/Main.storyboard b/ParentAssistant/ParentAssistant/Supporting Files/Base.lproj/Main.storyboard index 510e7fc..8499fa7 100644 --- a/ParentAssistant/ParentAssistant/Supporting Files/Base.lproj/Main.storyboard +++ b/ParentAssistant/ParentAssistant/Supporting Files/Base.lproj/Main.storyboard @@ -532,70 +532,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -821,19 +759,15 @@ - - - - - - - + + + + - -- libgit2 0.21.0