Commit fe840a498e89aae8061d9274d3786e5ac2c27027

Authored by Cao yang
1 parent c33c3ada
Exists in parentassistant

报告页面中日历的添加

ParentAssistant/ParentAssistant.xcodeproj/project.pbxproj
... ... @@ -41,6 +41,9 @@
41 41 AD34D11A2064C79D00989F8D /* MoralDetailCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD34D1192064C79D00989F8D /* MoralDetailCell.swift */; };
42 42 AD34D11C2064C7AE00989F8D /* EducationDetailCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD34D11B2064C7AE00989F8D /* EducationDetailCell.swift */; };
43 43 AD34D11E2064C7C300989F8D /* BehaviorDetailCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD34D11D2064C7C300989F8D /* BehaviorDetailCell.swift */; };
  44 + AD4BA4A920819AB000F83F13 /* ReportHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD4BA4A820819AB000F83F13 /* ReportHeaderView.swift */; };
  45 + AD4BA4AC20819CAD00F83F13 /* ReportHeaderCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD4BA4AA20819CAD00F83F13 /* ReportHeaderCollectionViewCell.swift */; };
  46 + AD4BA4AD20819CAD00F83F13 /* ReportHeaderCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD4BA4AB20819CAD00F83F13 /* ReportHeaderCollectionViewCell.xib */; };
44 47 AD5681CA208044860034A948 /* GrowCheckUpTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD5681C8208044860034A948 /* GrowCheckUpTableViewCell.swift */; };
45 48 AD5681CB208044860034A948 /* GrowCheckUpTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD5681C9208044860034A948 /* GrowCheckUpTableViewCell.xib */; };
46 49 AD5681CE2080449A0034A948 /* GrowCheckDownTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD5681CC2080449A0034A948 /* GrowCheckDownTableViewCell.swift */; };
... ... @@ -80,7 +83,6 @@
80 83 BF388480205CDFBE00A240EF /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF38847F205CDFBE00A240EF /* WebKit.framework */; };
81 84 BF388482205F5BC800A240EF /* MessageManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF388481205F5BC800A240EF /* MessageManager.swift */; };
82 85 BF3B8298204FC80D002078EA /* UMCommon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF3B8297204FC80D002078EA /* UMCommon.framework */; };
83   - BF3B82A02050CC8B002078EA /* ReportHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3B829F2050CC8B002078EA /* ReportHeaderView.swift */; };
84 86 BF406CD62057B03A000A6681 /* MessageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF406CD52057B03A000A6681 /* MessageViewController.swift */; };
85 87 BF406CD82057B529000A6681 /* MessageTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF406CD72057B529000A6681 /* MessageTableViewCell.swift */; };
86 88 BF406CDA2057BEB8000A6681 /* OrderDetailModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF406CD92057BEB8000A6681 /* OrderDetailModel.swift */; };
... ... @@ -207,6 +209,9 @@
207 209 AD34D1192064C79D00989F8D /* MoralDetailCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoralDetailCell.swift; sourceTree = "<group>"; };
208 210 AD34D11B2064C7AE00989F8D /* EducationDetailCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EducationDetailCell.swift; sourceTree = "<group>"; };
209 211 AD34D11D2064C7C300989F8D /* BehaviorDetailCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BehaviorDetailCell.swift; sourceTree = "<group>"; };
  212 + AD4BA4A820819AB000F83F13 /* ReportHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportHeaderView.swift; sourceTree = "<group>"; };
  213 + AD4BA4AA20819CAD00F83F13 /* ReportHeaderCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportHeaderCollectionViewCell.swift; sourceTree = "<group>"; };
  214 + AD4BA4AB20819CAD00F83F13 /* ReportHeaderCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ReportHeaderCollectionViewCell.xib; sourceTree = "<group>"; };
210 215 AD5681C8208044860034A948 /* GrowCheckUpTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GrowCheckUpTableViewCell.swift; sourceTree = "<group>"; };
211 216 AD5681C9208044860034A948 /* GrowCheckUpTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = GrowCheckUpTableViewCell.xib; sourceTree = "<group>"; };
212 217 AD5681CC2080449A0034A948 /* GrowCheckDownTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GrowCheckDownTableViewCell.swift; sourceTree = "<group>"; };
... ... @@ -246,7 +251,6 @@
246 251 BF38847F205CDFBE00A240EF /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
247 252 BF388481205F5BC800A240EF /* MessageManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageManager.swift; sourceTree = "<group>"; };
248 253 BF3B8297204FC80D002078EA /* UMCommon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UMCommon.framework; path = Pods/UMCCommon/UMCommon.framework; sourceTree = "<group>"; };
249   - BF3B829F2050CC8B002078EA /* ReportHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportHeaderView.swift; sourceTree = "<group>"; };
250 254 BF406CD52057B03A000A6681 /* MessageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageViewController.swift; sourceTree = "<group>"; };
251 255 BF406CD72057B529000A6681 /* MessageTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageTableViewCell.swift; sourceTree = "<group>"; };
252 256 BF406CD92057BEB8000A6681 /* OrderDetailModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderDetailModel.swift; sourceTree = "<group>"; };
... ... @@ -585,8 +589,10 @@
585 589 BF3B829E2050CC7E002078EA /* View */ = {
586 590 isa = PBXGroup;
587 591 children = (
588   - BF3B829F2050CC8B002078EA /* ReportHeaderView.swift */,
589 592 ADF159602069E00000A9485D /* CalendarView.swift */,
  593 + AD4BA4A820819AB000F83F13 /* ReportHeaderView.swift */,
  594 + AD4BA4AA20819CAD00F83F13 /* ReportHeaderCollectionViewCell.swift */,
  595 + AD4BA4AB20819CAD00F83F13 /* ReportHeaderCollectionViewCell.xib */,
590 596 ADC9AB75207C65FC00348EF1 /* GrowSubjectCell.swift */,
591 597 ADC9AB76207C65FC00348EF1 /* GrowSubjectCell.xib */,
592 598 AD65FB77206354220052415B /* MoralTableViewCell.swift */,
... ... @@ -939,6 +945,7 @@
939 945 BF67F3BD20590A2F002FDC61 /* Info-OSX.plist in Resources */,
940 946 BF621CAC205660E90040D2C1 /* My.storyboard in Resources */,
941 947 BF67F3BC20590A2F002FDC61 /* Info-iOS.plist in Resources */,
  948 + AD4BA4AD20819CAD00F83F13 /* ReportHeaderCollectionViewCell.xib in Resources */,
942 949 AD64A2C5207F28EB00B25E80 /* ProgramVacateBodyTableViewCell.xib in Resources */,
943 950 BF7A4C84204E338500460463 /* Assets.xcassets in Resources */,
944 951 BF7A4C85204E338500460463 /* LaunchScreen.storyboard in Resources */,
... ... @@ -1036,7 +1043,6 @@
1036 1043 BFEAAAD620525D620072FAAF /* LxButton.m in Sources */,
1037 1044 5993652C20528D5700C8B371 /* MainViewController.swift in Sources */,
1038 1045 5993652A2052553900C8B371 /* pinyin.c in Sources */,
1039   - BF3B82A02050CC8B002078EA /* ReportHeaderView.swift in Sources */,
1040 1046 BFF9B7EF20577CD300F39B3E /* MyChildrenTableViewCell.swift in Sources */,
1041 1047 590944E22057DA73004478B5 /* utils.swift in Sources */,
1042 1048 BFEAAAC9205257460072FAAF /* NSDate+GFCalendar.m in Sources */,
... ... @@ -1056,6 +1062,7 @@
1056 1062 5980BF682061048A00F4A35E /* LZCityPickerController.m in Sources */,
1057 1063 AD198173207D9FB4009AB8B5 /* ProgramCheckViewController.swift in Sources */,
1058 1064 BFCED88B20528DE700055373 /* MyViewControllerModel.swift in Sources */,
  1065 + AD4BA4A920819AB000F83F13 /* ReportHeaderView.swift in Sources */,
1059 1066 BFF9B7E92056852A00F39B3E /* RegisterViewController.swift in Sources */,
1060 1067 BFBC06C72063AE8900CCFAFF /* ZLaunchAdButton.swift in Sources */,
1061 1068 ADAEA3982064960300A47D2C /* SceneDetailViewController.swift in Sources */,
... ... @@ -1069,6 +1076,7 @@
1069 1076 BFEAAAD720525D620072FAAF /* UIColor+Expanded.m in Sources */,
1070 1077 BFF9B7ED2057776100F39B3E /* MyChildrenViewController.swift in Sources */,
1071 1078 BFEAAAC1205257460072FAAF /* LXCalendarDayModel.m in Sources */,
  1079 + AD4BA4AC20819CAD00F83F13 /* ReportHeaderCollectionViewCell.swift in Sources */,
1072 1080 599364EF204E62E700C8B371 /* MyTableViewCell.swift in Sources */,
1073 1081 BFF9B7EB205772E100F39B3E /* GetBackPasswordViewController.swift in Sources */,
1074 1082 BFF9B7F22057A28900F39B3E /* TableEmptyView.swift in Sources */,
... ...
ParentAssistant/ParentAssistant.xcodeproj/xcuserdata/caoyang.xcuserdatad/xcschemes/xcschememanagement.plist
... ... @@ -7,7 +7,7 @@
7 7 <key>ParentAssistant.xcscheme</key>
8 8 <dict>
9 9 <key>orderHint</key>
10   - <integer>9</integer>
  10 + <integer>1</integer>
11 11 </dict>
12 12 </dict>
13 13 </dict>
... ...
ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate
No preview for this file type
ParentAssistant/ParentAssistant/Classes/controllers/Grow/GrowViewController.swift
... ... @@ -194,7 +194,6 @@ class GrowViewController: UIViewController,UIScrollViewDelegate {
194 194 let offsetX = scrollView.contentOffset.x
195 195 let index = Int(offsetX/getScreenWidth())
196 196 let btn = titleBtnArr[index]
197   -
198 197 clickTitleAction(btn: btn)
199 198 }
200 199 }
... ...
ParentAssistant/ParentAssistant/Classes/controllers/Grow/Report/ReportViewController.swift
... ... @@ -38,19 +38,20 @@ class ReportViewController: UIViewController,UITableViewDelegate,UITableViewData
38 38 // MARK: - 设置日期View
39 39 func setupDateView(){
40 40  
41   - let headView = UIView.init(frame: CGRect.init(x: 0, y: 0, width: screenWidth, height: 60))
  41 + let headView = ReportHeaderView.init(frame: CGRect.init(x: 0, y: 0, width: screenWidth, height: 60))
  42 +
42 43 self.view.addSubview(headView)
43 44 //添加手势
44 45 let recognizer = UISwipeGestureRecognizer.init(target: self, action: #selector(showView))
45 46 recognizer.direction = UISwipeGestureRecognizerDirection.down
46 47 headView.addGestureRecognizer(recognizer)
47 48  
48   - calendar = CalendarView.init(frame: CGRect.init(x: 0, y: 30, width: screenWidth, height: 260))
  49 + calendar = CalendarView.init(frame: CGRect.init(x: 0, y: 32, width: screenWidth, height: 280))
49 50 }
50 51  
51 52 @objc func showView(){
52 53 keyWindow = UIApplication.shared.keyWindow!
53   - let backBtn = UIButton.init(frame: CGRect.init(x: 0, y: calendar.frame.origin.y+260+22, width: screenWidth, height: screenHeight))
  54 + let backBtn = UIButton.init(frame: CGRect.init(x: 0, y: calendar.frame.origin.y+280+22, width: screenWidth, height: screenHeight))
54 55 backBtn.backgroundColor = UIColor.black
55 56 backBtn.alpha = 0.4
56 57  
... ...
ParentAssistant/ParentAssistant/Classes/controllers/Grow/View/CalendarView.swift
... ... @@ -12,6 +12,9 @@ class CalendarView: UIView,UICollectionViewDelegate,UICollectionViewDataSource {
12 12  
13 13  
14 14 var weekLab = ["日","一","二","三","四","五","六"]
  15 + var firstDay = Int()
  16 + var monthDay = Int()
  17 + var todayDay = Int()
15 18  
16 19 override init(frame: CGRect) {
17 20 super.init(frame: frame)
... ... @@ -19,9 +22,11 @@ class CalendarView: UIView,UICollectionViewDelegate,UICollectionViewDataSource {
19 22 }
20 23  
21 24 func drawCalendarView(frame:CGRect) {
22   - //TODO: 数据源待完成
23   - 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"]
24   - weekLab.append(contentsOf: dayLab)
  25 +
  26 +
  27 + self.firstDay = CalendarDateManager.shared.getFirstMonthDays()
  28 + self.monthDay = CalendarDateManager.shared.getCurrentMonthDay()
  29 + self.todayDay = CalendarDateManager.shared.getTodayDate()
25 30 //设置layout
26 31 let flowlayout = UICollectionViewFlowLayout()
27 32 flowlayout.itemSize = CGSize.init(width: screenWidth/7, height:40)
... ... @@ -41,21 +46,43 @@ class CalendarView: UIView,UICollectionViewDelegate,UICollectionViewDataSource {
41 46  
42 47 //MARK: - Delegate
43 48 func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
44   - return weekLab.count
  49 + return weekLab.count + monthDay + firstDay - 1
45 50 }
46 51  
47 52 func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
48 53  
49 54 let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "calendarCell", for: indexPath)
50 55 let lab = UILabel.init(frame: cell.bounds)
51   - lab.text = weekLab[indexPath.row]
  56 +
  57 + if indexPath.row < weekLab.count {
  58 + lab.text = weekLab[indexPath.row]
  59 + }else{
  60 + // 超出这个月显示为空
  61 + if indexPath.row+1 >= firstDay+7 && indexPath.row < monthDay+7+firstDay {
  62 + lab.text = "\(indexPath.row+1-firstDay-7+1)"
  63 + }else{
  64 + lab.text = ""
  65 + }
  66 + }
  67 + // 设置日期颜色
  68 + if indexPath.row+1 > todayDay+7+firstDay-1{
  69 + lab.textColor = UIColor.gray
  70 + }else
  71 + if indexPath.row+1 == todayDay+7+firstDay-1 {
  72 + lab.textColor = UIColor.red
  73 + }else{
  74 + lab.textColor = UIColor.black
  75 + }
  76 +
52 77 lab.textAlignment = .center
53 78 cell.addSubview(lab)
54 79 return cell
55 80  
56 81 }
57 82 func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
58   - print("点击了 第 \(weekLab[indexPath.row])")
  83 + if indexPath.row >= firstDay-1+7 && indexPath.row < todayDay+7+firstDay-1 {
  84 + print("点击了 ...\(indexPath.row+1-7-firstDay+1)号")
  85 + }
59 86 }
60 87 required init?(coder aDecoder: NSCoder) {
61 88 fatalError("init(coder:) has not been implemented")
... ...
ParentAssistant/ParentAssistant/Classes/controllers/Grow/View/ReportHeaderCollectionViewCell.swift 0 → 100644
... ... @@ -0,0 +1,42 @@
  1 +//
  2 +// ReportHeaderCollectionViewCell.swift
  3 +// ParentAssistant
  4 +//
  5 +// Created by Cao yang on 2018/4/14.
  6 +// Copyright © 2018年 HANGZHOUTEAM. All rights reserved.
  7 +//
  8 +
  9 +import UIKit
  10 +
  11 +class ReportHeaderCollectionViewCell: UICollectionViewCell {
  12 +
  13 + @IBOutlet weak var weekLab: UILabel!
  14 + @IBOutlet weak var dataLab: UILabel!
  15 + override func awakeFromNib() {
  16 + super.awakeFromNib()
  17 + // Initialization code
  18 + }
  19 + func setCellData(index:IndexPath){
  20 + if index.row%7 == 0 || index.row == 0 {
  21 + self.weekLab.text = "日"
  22 + }
  23 + if index.row == 1 || index.row%7 == 1 {
  24 + self.weekLab.text = "一"
  25 + }
  26 + if index.row == 2 || index.row%7 == 2 {
  27 + self.weekLab.text = "二"
  28 + }
  29 + if index.row == 3 || index.row%7 == 3 {
  30 + self.weekLab.text = "三"
  31 + }
  32 + if index.row == 4 || index.row%7 == 4 {
  33 + self.weekLab.text = "四"
  34 + }
  35 + if index.row == 5 || index.row%7 == 5 {
  36 + self.weekLab.text = "五"
  37 + }
  38 + if index.row == 6 || index.row%7 == 6 {
  39 + self.weekLab.text = "六"
  40 + }
  41 + }
  42 +}
... ...
ParentAssistant/ParentAssistant/Classes/controllers/Grow/View/ReportHeaderCollectionViewCell.xib 0 → 100644
... ... @@ -0,0 +1,51 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
  3 + <device id="retina4_7" orientation="portrait">
  4 + <adaptation id="fullscreen"/>
  5 + </device>
  6 + <dependencies>
  7 + <deployment identifier="iOS"/>
  8 + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
  9 + <capability name="Safe area layout guides" minToolsVersion="9.0"/>
  10 + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
  11 + </dependencies>
  12 + <objects>
  13 + <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
  14 + <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
  15 + <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="ReportHeaderCollectionViewCell" id="gTV-IL-0wX" customClass="ReportHeaderCollectionViewCell" customModule="ParentAssistant" customModuleProvider="target">
  16 + <rect key="frame" x="0.0" y="0.0" width="70" height="59"/>
  17 + <autoresizingMask key="autoresizingMask"/>
  18 + <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
  19 + <rect key="frame" x="0.0" y="0.0" width="70" height="59"/>
  20 + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
  21 + <subviews>
  22 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="25" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7Tv-VB-dq1">
  23 + <rect key="frame" x="24.5" y="34" width="21" height="21"/>
  24 + <fontDescription key="fontDescription" type="system" pointSize="17"/>
  25 + <nil key="textColor"/>
  26 + <nil key="highlightedColor"/>
  27 + </label>
  28 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="日" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Lgs-Ns-ePp">
  29 + <rect key="frame" x="26" y="8" width="18" height="21"/>
  30 + <fontDescription key="fontDescription" type="system" pointSize="17"/>
  31 + <nil key="textColor"/>
  32 + <nil key="highlightedColor"/>
  33 + </label>
  34 + </subviews>
  35 + </view>
  36 + <constraints>
  37 + <constraint firstItem="Lgs-Ns-ePp" firstAttribute="centerX" secondItem="gTV-IL-0wX" secondAttribute="centerX" id="EFF-k3-MkL"/>
  38 + <constraint firstItem="7Tv-VB-dq1" firstAttribute="centerX" secondItem="gTV-IL-0wX" secondAttribute="centerX" id="Vod-EB-QVH"/>
  39 + <constraint firstItem="Lgs-Ns-ePp" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" constant="8" id="Zr1-E2-Kug"/>
  40 + <constraint firstItem="7Tv-VB-dq1" firstAttribute="top" secondItem="Lgs-Ns-ePp" secondAttribute="bottom" constant="5" id="gcw-MZ-fhS"/>
  41 + </constraints>
  42 + <viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/>
  43 + <size key="customSize" width="70" height="59"/>
  44 + <connections>
  45 + <outlet property="dataLab" destination="7Tv-VB-dq1" id="Nqk-R7-IeZ"/>
  46 + <outlet property="weekLab" destination="Lgs-Ns-ePp" id="YtY-jK-uwb"/>
  47 + </connections>
  48 + <point key="canvasLocation" x="52" y="-23.5"/>
  49 + </collectionViewCell>
  50 + </objects>
  51 +</document>
... ...
ParentAssistant/ParentAssistant/Classes/controllers/Grow/View/ReportHeaderView.swift
... ... @@ -2,47 +2,141 @@
2 2 // ReportHeaderView.swift
3 3 // ParentAssistant
4 4 //
5   -// Created by 葛建军 on 2018/3/8.
  5 +// Created by Cao yang on 2018/4/14.
6 6 // Copyright © 2018年 HANGZHOUTEAM. All rights reserved.
7 7 //
8 8  
9 9 import UIKit
10 10  
11   -class ReportHeaderView: UIView {
12   - var delegate:ReportHeaderViewDelegate!
13   - @IBOutlet var nameButton: UIButton!//学生名字按钮
14   - @IBOutlet var dateButton: UIButton!//日期按钮
15   - @IBOutlet var typeButton: UIButton!//筛选按钮
16   - override func awakeFromNib() {
17   - super.awakeFromNib()
18   - }
19   - override func layoutSubviews() {
20   - super.layoutSubviews()
21   - nameButton.frame.origin = CGPoint(x: 15, y: 7)
22   - dateButton.frame.origin = CGPoint(x: (getScreenWidth()-dateButton.frame.size.width)/2, y: 7)
23   - typeButton.frame.origin = CGPoint(x: getScreenWidth()-typeButton.frame.size.width-30, y: 7)
  11 +class ReportHeaderView: UIView,UICollectionViewDelegate,UICollectionViewDataSource {
  12 +
  13 + lazy var collectionView = {()-> UICollectionView in
  14 +
  15 + let flowlayout = UICollectionViewFlowLayout()
  16 + flowlayout.itemSize = CGSize.init(width: screenWidth/7, height:60)
  17 + flowlayout.minimumLineSpacing = 0
  18 + flowlayout.minimumInteritemSpacing = 0
  19 + flowlayout.scrollDirection = UICollectionViewScrollDirection.horizontal
  20 + flowlayout.headerReferenceSize = CGSize.init(width: 0, height: 0)
  21 + flowlayout.footerReferenceSize = CGSize.init(width: 0, height: 0)
  22 + flowlayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0)
  23 +
  24 + let collect = UICollectionView.init(frame: CGRect.init(x: 0, y: 0, width: self.bounds.size.width, height: self.bounds.size.height), collectionViewLayout: flowlayout)
  25 + collect.delegate = self
  26 + collect.dataSource = self
  27 + collect.showsHorizontalScrollIndicator = true
  28 + collect.scrollsToTop = false
  29 + collect.showsVerticalScrollIndicator = false
  30 + collect.isPagingEnabled = true
  31 + collect.backgroundColor = UIColor.white
  32 + collect.register(UINib.init(nibName: "ReportHeaderCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "ReportHeaderCollectionViewCell")
  33 + return collect
  34 + }()
  35 +
  36 + //Data
  37 +
  38 + /// 展示
  39 + var count = Int()
  40 + /// 当月1号 周几
  41 + var firstDay = Int()
  42 + /// 当月天数
  43 + var monthDays = Int()
  44 + /// 今天日期
  45 + var todayDate = Int()
  46 +
  47 + override init(frame: CGRect) {
  48 + super.init(frame: frame)
  49 + self.addSubview(self.collectionView)
  50 +
  51 + self.count = CalendarDateManager.shared.getMonthDayCount()*7
  52 + self.firstDay = CalendarDateManager.shared.getFirstMonthDays()
  53 + self.monthDays = CalendarDateManager.shared.getCurrentMonthDay()
  54 + self.todayDate = CalendarDateManager.shared.getTodayDate()
  55 +
  56 + //初始位置:显示本周
  57 + collectionView.scrollToItem(at: [0,count-1], at: UICollectionViewScrollPosition.right, animated: true)
24 58 }
25   - //点击学生姓名按钮
26   - @IBAction func changeStudentAction(_ sender: UIButton) {
27   - delegate.selectStudentButton()
  59 +
  60 + //MARK: - Collection Delegate && DataSource
  61 + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
  62 + return count
28 63 }
29   - //点击日期按钮
30   - @IBAction func changeDateAction(_ sender: UIButton) {
31   - delegate.selectDateButton()
  64 + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
  65 +
  66 + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ReportHeaderCollectionViewCell", for: indexPath) as! ReportHeaderCollectionViewCell
  67 + cell.setCellData(index: indexPath)
  68 +
  69 + // 超出这个月显示为空
  70 + if indexPath.row+1 >= firstDay && indexPath.row <= monthDays {
  71 + cell.dataLab.text = "\(indexPath.row+1-firstDay+1)"
  72 + }else{
  73 + cell.dataLab.text = ""
  74 + }
  75 + // 设置日期颜色
  76 + if indexPath.row+1 > todayDate+firstDay-1{
  77 + cell.dataLab.textColor = UIColor.gray
  78 + }else
  79 + if indexPath.row+1 == todayDate+firstDay-1 {
  80 + cell.dataLab.textColor = UIColor.red
  81 + }else{
  82 + cell.dataLab.textColor = UIColor.black
  83 + }
  84 + return cell
32 85 }
33   - //点击筛选按钮
34   - @IBAction func changeTypeAction(_ sender: UIButton) {
35   - delegate.selectTypeButton()
  86 + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
  87 + if indexPath.row >= firstDay-1 && indexPath.row < todayDate+firstDay-1 {
  88 + print("点击了 ...\(indexPath.row+1-firstDay+1)号")
  89 + }
36 90 }
37 91  
  92 + required init?(coder aDecoder: NSCoder) {
  93 + fatalError("init(coder:) has not been implemented")
  94 + }
38 95 }
39   -protocol ReportHeaderViewDelegate {
40   - func selectStudentButton()
41   - func selectDateButton()
42   - func selectTypeButton()
43   -}
44   -extension ReportHeaderView {
45   - class func titleView() -> ReportHeaderView {
46   - return Bundle.main.loadNibNamed("ReportHeaderView", owner: nil, options: nil)?.first as! ReportHeaderView
  96 +class CalendarDateManager: NSObject {
  97 +
  98 + static let shared = CalendarDateManager()
  99 +
  100 + private var date = Date.init(timeInterval: 150*86400, since: Date())
  101 +// private var date = Date()
  102 + override init() {}
  103 +
  104 + /// 获取当前周ofMonth
  105 + ///
  106 + /// - Returns: 第几周
  107 + func getMonthDayCount() -> Int {
  108 + let comps = Calendar.current.dateComponents([.weekOfMonth], from: date)
  109 + return comps.weekOfMonth!
  110 + }
  111 +
  112 + /// 获取当前月第一天周几
  113 + ///
  114 + /// - Returns: 月1号周几
  115 + func getFirstMonthDays() -> Int{
  116 + let comps = Calendar.current.dateComponents([.day], from: date)
  117 + let dayDate = comps.day!-1
  118 + let firstDay = Date.init(timeInterval: TimeInterval(-dayDate*86400), since: date)
  119 + let firstMonth = Calendar.current.dateComponents([.weekday], from: firstDay)
  120 + return firstMonth.weekday!
  121 + }
  122 +
  123 + /// 获取当天
  124 + ///
  125 + /// - Returns: 今天几号
  126 + func getTodayDate() -> Int {
  127 + let comps = Calendar.current.dateComponents([.day], from: date)
  128 + return comps.day!
47 129 }
  130 +
  131 + /// 获取当月天数
  132 + ///
  133 + /// - Returns: 天数
  134 + func getCurrentMonthDay () ->Int{
  135 +
  136 + let comps = Calendar.current.range(of: .day, in: .month, for: date)
  137 + return (comps?.count)!
  138 + }
  139 +
48 140 }
  141 +
  142 +
... ...
ParentAssistant/Pods/Pods.xcodeproj/xcuserdata/caoyang.xcuserdatad/xcschemes/xcschememanagement.plist
... ... @@ -12,42 +12,42 @@
12 12 <key>DZNEmptyDataSet.xcscheme</key>
13 13 <dict>
14 14 <key>orderHint</key>
15   - <integer>1</integer>
  15 + <integer>2</integer>
16 16 </dict>
17 17 <key>Pods-ParentAssistant.xcscheme</key>
18 18 <dict>
19 19 <key>orderHint</key>
20   - <integer>2</integer>
  20 + <integer>3</integer>
21 21 </dict>
22 22 <key>Reachability.xcscheme</key>
23 23 <dict>
24 24 <key>orderHint</key>
25   - <integer>3</integer>
  25 + <integer>4</integer>
26 26 </dict>
27 27 <key>SDWebImage.xcscheme</key>
28 28 <dict>
29 29 <key>orderHint</key>
30   - <integer>4</integer>
  30 + <integer>5</integer>
31 31 </dict>
32 32 <key>SVProgressHUD.xcscheme</key>
33 33 <dict>
34 34 <key>orderHint</key>
35   - <integer>5</integer>
  35 + <integer>6</integer>
36 36 </dict>
37 37 <key>SwiftHash.xcscheme</key>
38 38 <dict>
39 39 <key>orderHint</key>
40   - <integer>6</integer>
  40 + <integer>7</integer>
41 41 </dict>
42 42 <key>Toast.xcscheme</key>
43 43 <dict>
44 44 <key>orderHint</key>
45   - <integer>7</integer>
  45 + <integer>8</integer>
46 46 </dict>
47 47 <key>XRCarouselView.xcscheme</key>
48 48 <dict>
49 49 <key>orderHint</key>
50   - <integer>8</integer>
  50 + <integer>9</integer>
51 51 </dict>
52 52 </dict>
53 53 </dict>
... ...