git.iko.soy/dashared/GDproject
on master help sign in
started working on sticky headers and basic info in profile
cf2ae8bDarya Rednikina
GDproject.xcodeproj/project.pbxproj+8
@@ -10,6 +10,8 @@
10 125BD57D22171D2A008A3575 /* ProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 125BD57C22171D2A008A3575 /* ProfileViewController.swift */; };
10 125BD57D22171D2A008A3575 /* ProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 125BD57C22171D2A008A3575 /* ProfileViewController.swift */; };
11 125BD57F22171D73008A3575 /* Extentions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 125BD57E22171D73008A3575 /* Extentions.swift */; };
11 125BD57F22171D73008A3575 /* Extentions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 125BD57E22171D73008A3575 /* Extentions.swift */; };
12 125BD5812217314A008A3575 /* NewsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 125BD5802217314A008A3575 /* NewsVC.swift */; };
12 125BD5812217314A008A3575 /* NewsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 125BD5802217314A008A3575 /* NewsVC.swift */; };
13+ 12DB7FD722181CD20096878E /* BasicInfoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12DB7FD622181CD20096878E /* BasicInfoController.swift */; };
14+ 12DB7FD922181E660096878E /* BasicInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12DB7FD822181E660096878E /* BasicInfoCell.swift */; };
13 12E36D9C221424EA006FCDD7 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12E36D9B221424EA006FCDD7 /* AppDelegate.swift */; };
15 12E36D9C221424EA006FCDD7 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12E36D9B221424EA006FCDD7 /* AppDelegate.swift */; };
14 12E36D9E221424EA006FCDD7 /* NewsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12E36D9D221424EA006FCDD7 /* NewsController.swift */; };
16 12E36D9E221424EA006FCDD7 /* NewsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12E36D9D221424EA006FCDD7 /* NewsController.swift */; };
15 12E36DA1221424EA006FCDD7 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 12E36D9F221424EA006FCDD7 /* Main.storyboard */; };
17 12E36DA1221424EA006FCDD7 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 12E36D9F221424EA006FCDD7 /* Main.storyboard */; };
@@ -58,6 +60,8 @@
58 125BD57C22171D2A008A3575 /* ProfileViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileViewController.swift; sourceTree = "<group>"; };
60 125BD57C22171D2A008A3575 /* ProfileViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileViewController.swift; sourceTree = "<group>"; };
59 125BD57E22171D73008A3575 /* Extentions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extentions.swift; sourceTree = "<group>"; };
61 125BD57E22171D73008A3575 /* Extentions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extentions.swift; sourceTree = "<group>"; };
60 125BD5802217314A008A3575 /* NewsVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewsVC.swift; sourceTree = "<group>"; };
62 125BD5802217314A008A3575 /* NewsVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewsVC.swift; sourceTree = "<group>"; };
63+ 12DB7FD622181CD20096878E /* BasicInfoController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BasicInfoController.swift; sourceTree = "<group>"; };
64+ 12DB7FD822181E660096878E /* BasicInfoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BasicInfoCell.swift; sourceTree = "<group>"; };
61 12E36D98221424EA006FCDD7 /* GDproject.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GDproject.app; sourceTree = BUILT_PRODUCTS_DIR; };
65 12E36D98221424EA006FCDD7 /* GDproject.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GDproject.app; sourceTree = BUILT_PRODUCTS_DIR; };
62 12E36D9B221424EA006FCDD7 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
66 12E36D9B221424EA006FCDD7 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
63 12E36D9D221424EA006FCDD7 /* NewsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewsController.swift; sourceTree = "<group>"; };
67 12E36D9D221424EA006FCDD7 /* NewsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewsController.swift; sourceTree = "<group>"; };
@@ -157,6 +161,8 @@
157 isa = PBXGroup;
161 isa = PBXGroup;
158 children = (
162 children = (
159 125BD57C22171D2A008A3575 /* ProfileViewController.swift */,
163 125BD57C22171D2A008A3575 /* ProfileViewController.swift */,
164+ 12DB7FD622181CD20096878E /* BasicInfoController.swift */,
165+ 12DB7FD822181E660096878E /* BasicInfoCell.swift */,
160 12E36DD322156519006FCDD7 /* News */,
166 12E36DD322156519006FCDD7 /* News */,
161 );
167 );
162 path = Controller;
168 path = Controller;
@@ -267,7 +273,9 @@
267 125BD57F22171D73008A3575 /* Extentions.swift in Sources */,
273 125BD57F22171D73008A3575 /* Extentions.swift in Sources */,
268 12E36DD122148122006FCDD7 /* FullPostController.swift in Sources */,
274 12E36DD122148122006FCDD7 /* FullPostController.swift in Sources */,
269 125BD57D22171D2A008A3575 /* ProfileViewController.swift in Sources */,
275 125BD57D22171D2A008A3575 /* ProfileViewController.swift in Sources */,
276+ 12DB7FD922181E660096878E /* BasicInfoCell.swift in Sources */,
270 12E36D9C221424EA006FCDD7 /* AppDelegate.swift in Sources */,
277 12E36D9C221424EA006FCDD7 /* AppDelegate.swift in Sources */,
278+ 12DB7FD722181CD20096878E /* BasicInfoController.swift in Sources */,
271 12E36DCE22144756006FCDD7 /* Constants.swift in Sources */,
279 12E36DCE22144756006FCDD7 /* Constants.swift in Sources */,
272 );
280 );
273 runOnlyForDeploymentPostprocessing = 0;
281 runOnlyForDeploymentPostprocessing = 0;
GDproject/Base.lproj/Main.storyboard+13−12
@@ -54,30 +54,30 @@
54 <rect key="frame" x="0.0" y="116" width="375" height="502"/>
54 <rect key="frame" x="0.0" y="116" width="375" height="502"/>
55 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
55 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
56 <view key="tableHeaderView" contentMode="scaleToFill" id="kFZ-3c-OFY">
56 <view key="tableHeaderView" contentMode="scaleToFill" id="kFZ-3c-OFY">
57− <rect key="frame" x="0.0" y="0.0" width="375" height="200"/>
57+ <rect key="frame" x="0.0" y="0.0" width="375" height="162"/>
58 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
58 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
59 <subviews>
59 <subviews>
60 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="93Q-rB-JKk">
60 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="93Q-rB-JKk">
61− <rect key="frame" x="16" y="16" width="120" height="120"/>
61+ <rect key="frame" x="16" y="16" width="100" height="100"/>
62 <constraints>
62 <constraints>
63− <constraint firstAttribute="width" constant="120" id="3Xq-K8-0jL"/>
63+ <constraint firstAttribute="width" constant="100" id="3Xq-K8-0jL"/>
64− <constraint firstAttribute="height" constant="120" id="d83-z4-p3p"/>
64+ <constraint firstAttribute="height" constant="100" id="d83-z4-p3p"/>
65 </constraints>
65 </constraints>
66 </imageView>
66 </imageView>
67 <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="HD1-1N-Rae">
67 <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="HD1-1N-Rae">
68− <rect key="frame" x="156" y="16" width="203" height="120"/>
68+ <rect key="frame" x="136" y="16" width="223" height="100"/>
69 <subviews>
69 <subviews>
70 <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="OJ4-19-keW">
70 <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="OJ4-19-keW">
71− <rect key="frame" x="0.0" y="0.0" width="203" height="49"/>
71+ <rect key="frame" x="0.0" y="0.0" width="223" height="49"/>
72 <subviews>
72 <subviews>
73 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vff-nz-u6X">
73 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vff-nz-u6X">
74− <rect key="frame" x="0.0" y="0.0" width="203" height="21.5"/>
74+ <rect key="frame" x="0.0" y="0.0" width="223" height="21.5"/>
75 <fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
75 <fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
76 <nil key="textColor"/>
76 <nil key="textColor"/>
77 <nil key="highlightedColor"/>
77 <nil key="highlightedColor"/>
78 </label>
78 </label>
79 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="umX-IO-ePK">
79 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="umX-IO-ePK">
80− <rect key="frame" x="0.0" y="29.5" width="203" height="19.5"/>
80+ <rect key="frame" x="0.0" y="29.5" width="223" height="19.5"/>
81 <fontDescription key="fontDescription" type="system" pointSize="16"/>
81 <fontDescription key="fontDescription" type="system" pointSize="16"/>
82 <nil key="textColor"/>
82 <nil key="textColor"/>
83 <nil key="highlightedColor"/>
83 <nil key="highlightedColor"/>
@@ -85,18 +85,18 @@
85 </subviews>
85 </subviews>
86 </stackView>
86 </stackView>
87 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ypY-U6-bJm">
87 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ypY-U6-bJm">
88− <rect key="frame" x="0.0" y="103" width="203" height="17"/>
88+ <rect key="frame" x="0.0" y="83" width="223" height="17"/>
89 <fontDescription key="fontDescription" type="system" pointSize="14"/>
89 <fontDescription key="fontDescription" type="system" pointSize="14"/>
90 <nil key="textColor"/>
90 <nil key="textColor"/>
91 <nil key="highlightedColor"/>
91 <nil key="highlightedColor"/>
92 </label>
92 </label>
93 </subviews>
93 </subviews>
94 <constraints>
94 <constraints>
95− <constraint firstAttribute="height" constant="120" id="8vI-3o-mkr"/>
95+ <constraint firstAttribute="height" constant="100" id="8vI-3o-mkr"/>
96 </constraints>
96 </constraints>
97 </stackView>
97 </stackView>
98 <stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="hFb-Uj-GwE">
98 <stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="hFb-Uj-GwE">
99− <rect key="frame" x="16" y="154" width="343" height="30"/>
99+ <rect key="frame" x="16" y="124" width="343" height="30"/>
100 <subviews>
100 <subviews>
101 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vCL-BI-I2h">
101 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vCL-BI-I2h">
102 <rect key="frame" x="0.0" y="0.0" width="35.5" height="30"/>
102 <rect key="frame" x="0.0" y="0.0" width="35.5" height="30"/>
@@ -114,12 +114,12 @@
114 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
114 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
115 <constraints>
115 <constraints>
116 <constraint firstItem="93Q-rB-JKk" firstAttribute="top" secondItem="kFZ-3c-OFY" secondAttribute="top" constant="16" id="5r9-SM-GHQ"/>
116 <constraint firstItem="93Q-rB-JKk" firstAttribute="top" secondItem="kFZ-3c-OFY" secondAttribute="top" constant="16" id="5r9-SM-GHQ"/>
117+ <constraint firstAttribute="bottom" secondItem="hFb-Uj-GwE" secondAttribute="bottom" constant="8" id="Ccj-2e-nWu"/>
117 <constraint firstItem="hFb-Uj-GwE" firstAttribute="leading" secondItem="kFZ-3c-OFY" secondAttribute="leading" constant="16" id="HWn-2I-NvS"/>
118 <constraint firstItem="hFb-Uj-GwE" firstAttribute="leading" secondItem="kFZ-3c-OFY" secondAttribute="leading" constant="16" id="HWn-2I-NvS"/>
118 <constraint firstAttribute="trailing" secondItem="hFb-Uj-GwE" secondAttribute="trailing" constant="16" id="MHn-bJ-vkd"/>
119 <constraint firstAttribute="trailing" secondItem="hFb-Uj-GwE" secondAttribute="trailing" constant="16" id="MHn-bJ-vkd"/>
119 <constraint firstItem="HD1-1N-Rae" firstAttribute="leading" secondItem="93Q-rB-JKk" secondAttribute="trailing" constant="20" id="Zmg-ZS-Eyy"/>
120 <constraint firstItem="HD1-1N-Rae" firstAttribute="leading" secondItem="93Q-rB-JKk" secondAttribute="trailing" constant="20" id="Zmg-ZS-Eyy"/>
120 <constraint firstItem="93Q-rB-JKk" firstAttribute="leading" secondItem="kFZ-3c-OFY" secondAttribute="leading" constant="16" id="f3K-RA-5qe"/>
121 <constraint firstItem="93Q-rB-JKk" firstAttribute="leading" secondItem="kFZ-3c-OFY" secondAttribute="leading" constant="16" id="f3K-RA-5qe"/>
121 <constraint firstAttribute="trailing" secondItem="HD1-1N-Rae" secondAttribute="trailing" constant="16" id="qT1-ct-8ed"/>
122 <constraint firstAttribute="trailing" secondItem="HD1-1N-Rae" secondAttribute="trailing" constant="16" id="qT1-ct-8ed"/>
122− <constraint firstAttribute="bottom" secondItem="hFb-Uj-GwE" secondAttribute="bottom" constant="16" id="ucS-yd-kWf"/>
123 <constraint firstItem="HD1-1N-Rae" firstAttribute="top" secondItem="kFZ-3c-OFY" secondAttribute="top" constant="16" id="zZe-Oe-Okw"/>
123 <constraint firstItem="HD1-1N-Rae" firstAttribute="top" secondItem="kFZ-3c-OFY" secondAttribute="top" constant="16" id="zZe-Oe-Okw"/>
124 </constraints>
124 </constraints>
125 </view>
125 </view>
@@ -243,6 +243,7 @@
243 <tabBarController automaticallyAdjustsScrollViewInsets="NO" id="IeP-4W-8LT" sceneMemberID="viewController">
243 <tabBarController automaticallyAdjustsScrollViewInsets="NO" id="IeP-4W-8LT" sceneMemberID="viewController">
244 <toolbarItems/>
244 <toolbarItems/>
245 <tabBar key="tabBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="3pl-mU-U30">
245 <tabBar key="tabBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="3pl-mU-U30">
246+ <rect key="frame" x="0.0" y="0.0" width="1000" height="1000"/>
246 <autoresizingMask key="autoresizingMask"/>
247 <autoresizingMask key="autoresizingMask"/>
247 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
248 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
248 </tabBar>
249 </tabBar>
GDproject/Constants.swift+2
@@ -12,3 +12,5 @@ let postCellId = "PostCell"
12let headerNewsChannelsVC = "HeaderSegmentedControll"
12let headerNewsChannelsVC = "HeaderSegmentedControll"
13// for transitioning to full post view
13// for transitioning to full post view
14let fullPostControllerId = "FullPostController"
14let fullPostControllerId = "FullPostController"
15+
16+let basicInfoCellId = "BasicInfoCell"
GDproject/Controller/BasicInfoCell.swiftnew file+38
@@ -0,0 +1,38 @@
1+//
2+// BasicInfoCell.swift
3+// NewsFeed
4+//
5+// Created by cstore on 23/01/2019.
6+// Copyright © 2019 drHSE. All rights reserved.
7+//
8+
9+import UIKit
10+import TinyConstraints
11+
12+class BasicInfoCell: UITableViewCell{
13+
14+ var titleLabel: UILabel = {
15+ let label = UILabel()
16+ label.font = UIFont.boldSystemFont(ofSize: 16)
17+ label.textColor = .black
18+ return label
19+ }()
20+
21+ override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
22+ super.init(style: style, reuseIdentifier: reuseIdentifier)
23+ }
24+
25+ func setUpView(){
26+ addSubview(titleLabel)
27+ titleLabel.edgesToSuperview(excluding: .bottom, insets: .top(8) + .left(16) + .right(16))
28+ }
29+
30+ required init?(coder aDecoder: NSCoder) {
31+ fatalError("init(coder:) has not been implemented")
32+ }
33+
34+ func fill(title: String){
35+ setUpView()
36+ titleLabel.text = title
37+ }
38+}
GDproject/Controller/BasicInfoController.swiftnew file+103
@@ -0,0 +1,103 @@
1+//
2+// BasicInfoController.swift
3+// GDproject
4+//
5+// Created by cstore on 16/02/2019.
6+// Copyright © 2019 drHSE. All rights reserved.
7+//
8+
9+import UIKit
10+
11+struct CellData{
12+ var opened = Bool()
13+ var title = String()
14+ var sectionData = [String]()
15+}
16+
17+class BasicInfoController: UIViewController, UITableViewDelegate, UITableViewDataSource {
18+
19+ var dataSourse: [CellData] = [
20+ CellData(opened: false, title: "Phone", sectionData: ["+7 901 733 01 79"]),
21+ CellData(opened: false, title: "Mail", sectionData: ["vbogomazova@edu.hse.ru"]),
22+ CellData(opened: false, title: "Research ID", sectionData: ["4567834336789456737"]),
23+ CellData(opened: false, title: "Published", sectionData: ["Книга 1", "Книга 2", "Книга 3"]),
24+ CellData(opened: false, title: "Courses", sectionData: ["Курс 1", "Курс 2"]),
25+ CellData(opened: false, title: "Link", sectionData: ["https://wwww.hse.ru"])
26+ ]
27+
28+ var type: HeaderType = .BASIC_INFO("Profile", "Basic info")
29+
30+ var viewController: ProfileViewController?
31+
32+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
33+ if (dataSourse[section].opened){
34+ return dataSourse[section].sectionData.count + 1
35+ } else {
36+ return 1
37+ }
38+ }
39+
40+ func numberOfSections(in tableView: UITableView) -> Int {
41+ return dataSourse.count
42+ }
43+
44+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
45+ if indexPath.row == 0 {
46+ let cell = tableView.dequeueReusableCell(withIdentifier: basicInfoCellId, for: indexPath) as! BasicInfoCell
47+ cell.fill(title: dataSourse[indexPath.section].title)
48+ cell.selectionStyle = .none
49+ return cell
50+ } else {
51+ let cell = tableView.dequeueReusableCell(withIdentifier: basicInfoCellId, for: indexPath) as! BasicInfoCell
52+ cell.fill(title: dataSourse[indexPath.section].sectionData[indexPath.row - 1])
53+ cell.selectionStyle = .none
54+ return cell
55+ }
56+ }
57+
58+ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
59+ if indexPath.row == 0 {
60+ if dataSourse[indexPath.section].opened {
61+ dataSourse[indexPath.section].opened = false
62+ let section = IndexSet.init(integer: indexPath.section)
63+ tableView.reloadSections(section, with: .none)
64+ } else {
65+ dataSourse[indexPath.section].opened = true
66+ let section = IndexSet.init(integer: indexPath.section)
67+ tableView.reloadSections(section, with: .none)
68+ }
69+ }
70+ }
71+ func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
72+ return UITableView.automaticDimension
73+ }
74+
75+ func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
76+ return 100.0
77+ }
78+
79+ func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
80+ if section == 0 {
81+ return 46
82+ }
83+ return 0
84+ }
85+
86+ func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
87+ {
88+ if section == 0 {
89+ let cell = tableView.dequeueReusableCell(withIdentifier: headerNewsChannelsVC) as! HeaderNewsChannels
90+
91+ cell.vcProfile = viewController
92+
93+ cell.type = type
94+
95+ let view = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 46.0))
96+ view.addSubview(cell)
97+ cell.edgesToSuperview()
98+
99+ return view
100+ }
101+ return nil
102+ }
103+}
GDproject/Controller/News/HeaderNewsChannels.swift+50−7
@@ -11,12 +11,35 @@ import TinyConstraints
11
11
12class HeaderNewsChannels: UITableViewCell {
12class HeaderNewsChannels: UITableViewCell {
13
13
14+ weak var tableView: UITableView?
15+
14 weak var vc: NewsController?
16 weak var vc: NewsController?
17+ weak var vcProfile: ProfileViewController?
18+
19+ var type: HeaderType = .PROFILE("Posts", "Channel")
20+ {
21+ didSet{
22+ switch type {
23+ case .PROFILE(let f, let s):
24+ postsChannelsSegment = UISegmentedControl(items: [f,s])
25+ postsChannelsSegment?.selectedSegmentIndex = 0
26+ case .BASIC_INFO(let b, let i):
27+ postsChannelsSegment = UISegmentedControl(items: [b,i])
28+ postsChannelsSegment?.selectedSegmentIndex = 1
29+ case .NEWS(let n, let bi):
30+ postsChannelsSegment = UISegmentedControl(items: [n, bi])
31+ postsChannelsSegment?.selectedSegmentIndex = 0
32+ default:
33+ break
34+ }
35+ setUpCell()
36+ }
37+ }
15
38
16 override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
39 override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
17 super.init(style: style, reuseIdentifier: reuseIdentifier)
40 super.init(style: style, reuseIdentifier: reuseIdentifier)
18 backgroundColor = .white
41 backgroundColor = .white
19− setUpCell()
42+ //setUpCell()
20 }
43 }
21
44
22 required init?(coder aDecoder: NSCoder) {
45 required init?(coder aDecoder: NSCoder) {
@@ -24,24 +47,44 @@ class HeaderNewsChannels: UITableViewCell {
24 }
47 }
25
48
26 func setUpCell(){
49 func setUpCell(){
50+
51+ guard let postsChannelsSegment = postsChannelsSegment else {
52+ return
53+ }
54+
27 addSubview(postsChannelsSegment)
55 addSubview(postsChannelsSegment)
28− postsChannelsSegment.selectedSegmentIndex = 0
56+
29 postsChannelsSegment.addTarget(self, action: #selector(changedValue), for: .valueChanged)
57 postsChannelsSegment.addTarget(self, action: #selector(changedValue), for: .valueChanged)
30 postsChannelsSegment.edgesToSuperview(insets: .left(16) + .right(16) + .top(8) + .bottom(8))
58 postsChannelsSegment.edgesToSuperview(insets: .left(16) + .right(16) + .top(8) + .bottom(8))
31 }
59 }
32
60
33 // Initialize
61 // Initialize
34− let postsChannelsSegment = UISegmentedControl(items: ["Posts", "Channels"])
62+ var postsChannelsSegment: UISegmentedControl?
35
63
36 @objc func changedValue(_ sender: UISegmentedControl) {
64 @objc func changedValue(_ sender: UISegmentedControl) {
37 let index = sender.selectedSegmentIndex
65 let index = sender.selectedSegmentIndex
66+
38 switch index {
67 switch index {
39 case 0:
68 case 0:
40− print("posts")
69+ switch type {
70+ case .BASIC_INFO:
71+ vcProfile?.changeToPosts()
72+ case .NEWS:
41− vc?.setUpNavigationItemsforPosts()
73+ vc?.setUpNavigationItemsforPosts()
74+ default:
75+ break
76+ }
42 case 1:
77 case 1:
78+ switch type {
79+ case .PROFILE:
80+ print("info")
81+ vcProfile?.changeToBasicInfo()
82+ case .NEWS:
43− print("channels")
83+ print("channels")
44− vc?.setUpNavigationItemsForChannels()
84+ vc?.setUpNavigationItemsForChannels()
85+ default:
86+ break
87+ }
45 default:
88 default:
46 break
89 break
47 }
90 }
GDproject/Controller/News/NewsController.swift+2
@@ -32,6 +32,8 @@ class NewsController: UIViewController
32 news.dataSourse = dataSourse
32 news.dataSourse = dataSourse
33 news.viewController = self
33 news.viewController = self
34
34
35+ news.type = .NEWS("Posts", "Channels")
36+
35 tableView.delegate = news
37 tableView.delegate = news
36 tableView.dataSource = news
38 tableView.dataSource = news
37 tableView.reloadData()
39 tableView.reloadData()
GDproject/Controller/News/NewsVC.swift+27−3
@@ -12,6 +12,8 @@ class NewsVC: UIViewController, UITableViewDelegate, UITableViewDataSource{
12
12
13 var dataSourse: [Post] = []
13 var dataSourse: [Post] = []
14
14
15+ var type: HeaderType = .NONE
16+
15 var viewController: UIViewController?
17 var viewController: UIViewController?
16
18
17 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
19 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
@@ -46,19 +48,41 @@ class NewsVC: UIViewController, UITableViewDelegate, UITableViewDataSource{
46 }
48 }
47
49
48 func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
50 func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
49− return 46.0
51+ switch type {
52+ case .NONE:
53+ return 0
54+ default:
55+ return 46
56+ }
50 }
57 }
51
58
52 func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
59 func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
53 {
60 {
54 let cell = tableView.dequeueReusableCell(withIdentifier: headerNewsChannelsVC) as! HeaderNewsChannels
61 let cell = tableView.dequeueReusableCell(withIdentifier: headerNewsChannelsVC) as! HeaderNewsChannels
62+
55− //cell.vc = viewController as? NewsController
63+ cell.vc = viewController as? NewsController
64+ cell.vcProfile = viewController as? ProfileViewController
65+
66+ cell.type = type
56
67
57 let view = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 46.0))
68 let view = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 46.0))
58 view.addSubview(cell)
69 view.addSubview(cell)
59 cell.edgesToSuperview()
70 cell.edgesToSuperview()
60
71
72+ switch type {
73+ case .NONE:
74+ return nil
75+ default:
61− return view
76+ return view
77+ }
62 }
78 }
63
79
64}
80}
81+
82+
83+enum HeaderType {
84+ case NONE
85+ case NEWS(String, String)
86+ case PROFILE(String, String)
87+ case BASIC_INFO(String, String)
88+}
GDproject/Controller/ProfileViewController.swift+27−3
@@ -7,6 +7,7 @@
7//
7//
8
8
9import UIKit
9import UIKit
10+import TinyConstraints
10
11
11class ProfileViewController: UIViewController {
12class ProfileViewController: UIViewController {
12
13
@@ -37,17 +38,28 @@ class ProfileViewController: UIViewController {
37
38
38 var user: User = User(surname: "Богомазова", name: "Вероника", optional: "Львовна", emailName: "vbogomazova", id: 2, place: "📍Москва, Кочновский пр. 3", faculty: "Методист: Факультет Компьютерных наук")
39 var user: User = User(surname: "Богомазова", name: "Вероника", optional: "Львовна", emailName: "vbogomazova", id: 2, place: "📍Москва, Кочновский пр. 3", faculty: "Методист: Факультет Компьютерных наук")
39
40
40− //let basicInfo = BasicInfoTableViewController()
41+ let basicInfo = BasicInfoController()
41 let posts = NewsVC()
42 let posts = NewsVC()
42
43
43− override func viewDidLoad() {
44+ override func viewDidLoad()
45+ {
44 super.viewDidLoad()
46 super.viewDidLoad()
47+
48+ posts.type = .PROFILE("Posts", "Basic Info")
49+
45− posts.dataSourse = [Post(dataArray: [.text("Le Lorem Ipsum est simplement du faux texte employé dans la composition et la mise en page avant impression. Le Lorem Ipsum est le faux texte standard de l'imprimerie depuis les années 1500, quand un imprimeur anonyme assembla ensemble des morceaux de texte pour réaliser un livre spécimen de polices de texte. Il n'a pas fait que survivre cinq siècles, mais s'est aussi adapté à la bureautique informatique, sans que son contenu n'en soit modifié. Il a été popularisé dans les années 1960 grâce à la vente de feuilles Letraset contenant des passages du Lorem Ipsum, et, plus récemment, par son inclusion dans des applications de mise en page de texte, comme Aldus PageMaker. est qu'il possède une distribution de lettres plus ou moins normale, et en tout cas comparable avec celle du français standard. De nombreuses suites logicielles de mise en page ou éditeurs de sites Web ont fait du Lorem Ipsum leur faux texte par défaut, et une recherche pour 'Lorem Ipsum' vous conduira vers de nombreux sites qui n'en sont encore qu'à leur phase de construction. Plusieurs versions sont apparues avec le temps, parfois par accident, souvent intentionnellement (histoire d'y rajouter de petits clins d'oeil, voire des phrases embarassantes).")]), Post(dataArray: [.text("Il n'a pas fait que survivre cinq siècles, mais s'est aussi adapté à la bureautique informatique, sans que son contenu n'en soit modifié. Il a été popularisé dans les années 1960 grâce à la vente de feuilles Letraset contenant des passages du Lorem Ipsum, et, plus récemment, par son inclusion dans des applications de mise en page de texte, comme Aldus PageMaker. .")])]
50+ posts.dataSourse = [Post(dataArray: [.text("Le Lorem Ipsum est simplement du faux texte employé dans la composition et la mise en page avant impression. Le Lorem Ipsum est le faux texte standard de l'imprimerie depuis les années 1500, quand un imprimeur anonyme assembla ensemble des morceaux de texte pour réaliser un livre spécimen de polices de texte. comme Aldus PageMaker. est qu'il possède une distribution de lettres plus ou moins normale, et en tout cas comparable avec celle du français standard. De nombreuses suites logicielles de mise en page ou éditeurs de sites Web ont fait du Lorem Ipsum leur faux texte par défaut, et une recherche pour 'Lorem Ipsum' vous conduira vers de nombreux sites qui n'en sont encore qu'à leur phase de construction. Plusieurs versions sont apparues avec le temps, parfois par accident, souvent intentionnellement (histoire d'y rajouter de petits clins d'oeil, voire des phrases embarassantes).")]), Post(dataArray: [.text("Il n'a pas fait que survivre cinq siècles, mais s'est aussi adapté à la bureautique informatique, sans que son contenu n'en soit modifié. Il a été popularisé dans les années 1960 grâce à la vente de feuilles Letraset contenant des passages du Lorem Ipsum, et, plus récemment, par son inclusion dans des applications de mise en page de texte, comme Aldus PageMaker. .")])]
51+
52+ // basicInfo.dataSourse =
53+
54+ posts.viewController = self
55+ basicInfo.viewController = self
46
56
47 tableView.register(HeaderNewsChannels.self, forCellReuseIdentifier: headerNewsChannelsVC)
57 tableView.register(HeaderNewsChannels.self, forCellReuseIdentifier: headerNewsChannelsVC)
48
58
49 tableView.register(PostViewCell.self, forCellReuseIdentifier: postCellId)
59 tableView.register(PostViewCell.self, forCellReuseIdentifier: postCellId)
50
60
61+ tableView.register(BasicInfoCell.self, forCellReuseIdentifier: basicInfoCellId)
62+
51 posts.viewController = self
63 posts.viewController = self
52
64
53 fill(with: user)
65 fill(with: user)
@@ -93,4 +105,16 @@ class ProfileViewController: UIViewController {
93
105
94 self.present(optionMenu, animated: true, completion: nil)
106 self.present(optionMenu, animated: true, completion: nil)
95 }
107 }
108+
109+ func changeToPosts(){
110+ tableView.delegate = posts
111+ tableView.dataSource = posts
112+ tableView.reloadData()
113+ }
114+
115+ func changeToBasicInfo(){
116+ tableView.delegate = basicInfo
117+ tableView.dataSource = basicInfo
118+ tableView.reloadData()
119+ }
96}
120}