git.iko.soy/dashared/GDproject
on master help sign in
sticky header on profile is deleted. improved header file
77ad34cDarya Rednikina
GDproject/Base.lproj/Main.storyboard+16−2
@@ -54,7 +54,7 @@
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="162"/>
57+ <rect key="frame" x="0.0" y="0.0" width="375" height="199"/>
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">
@@ -110,17 +110,30 @@
110 </button>
110 </button>
111 </subviews>
111 </subviews>
112 </stackView>
112 </stackView>
113+ <segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="vC8-pT-qzP">
114+ <rect key="frame" x="16" y="161" width="343" height="29"/>
115+ <segments>
116+ <segment title="Posts"/>
117+ <segment title="Basic Info"/>
118+ </segments>
119+ <connections>
120+ <action selector="valueChanged:" destination="R4D-Ao-uvG" eventType="valueChanged" id="KpK-xZ-KhE"/>
121+ </connections>
122+ </segmentedControl>
113 </subviews>
123 </subviews>
114 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
124 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
115 <constraints>
125 <constraints>
126+ <constraint firstAttribute="trailing" secondItem="vC8-pT-qzP" secondAttribute="trailing" constant="16" id="1pN-90-cEV"/>
116 <constraint firstItem="93Q-rB-JKk" firstAttribute="top" secondItem="kFZ-3c-OFY" secondAttribute="top" constant="16" id="5r9-SM-GHQ"/>
127 <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"/>
128+ <constraint firstAttribute="bottom" secondItem="vC8-pT-qzP" secondAttribute="bottom" constant="10" id="7gm-xL-uhs"/>
129+ <constraint firstItem="vC8-pT-qzP" firstAttribute="top" secondItem="hFb-Uj-GwE" secondAttribute="bottom" constant="7" id="GC2-zv-hp0"/>
118 <constraint firstItem="hFb-Uj-GwE" firstAttribute="leading" secondItem="kFZ-3c-OFY" secondAttribute="leading" constant="16" id="HWn-2I-NvS"/>
130 <constraint firstItem="hFb-Uj-GwE" firstAttribute="leading" secondItem="kFZ-3c-OFY" secondAttribute="leading" constant="16" id="HWn-2I-NvS"/>
119 <constraint firstAttribute="trailing" secondItem="hFb-Uj-GwE" secondAttribute="trailing" constant="16" id="MHn-bJ-vkd"/>
131 <constraint firstAttribute="trailing" secondItem="hFb-Uj-GwE" secondAttribute="trailing" constant="16" id="MHn-bJ-vkd"/>
120 <constraint firstItem="HD1-1N-Rae" firstAttribute="leading" secondItem="93Q-rB-JKk" secondAttribute="trailing" constant="20" id="Zmg-ZS-Eyy"/>
132 <constraint firstItem="HD1-1N-Rae" firstAttribute="leading" secondItem="93Q-rB-JKk" secondAttribute="trailing" constant="20" id="Zmg-ZS-Eyy"/>
121 <constraint firstItem="93Q-rB-JKk" firstAttribute="leading" secondItem="kFZ-3c-OFY" secondAttribute="leading" constant="16" id="f3K-RA-5qe"/>
133 <constraint firstItem="93Q-rB-JKk" firstAttribute="leading" secondItem="kFZ-3c-OFY" secondAttribute="leading" constant="16" id="f3K-RA-5qe"/>
122 <constraint firstAttribute="trailing" secondItem="HD1-1N-Rae" secondAttribute="trailing" constant="16" id="qT1-ct-8ed"/>
134 <constraint firstAttribute="trailing" secondItem="HD1-1N-Rae" secondAttribute="trailing" constant="16" id="qT1-ct-8ed"/>
123 <constraint firstItem="HD1-1N-Rae" firstAttribute="top" secondItem="kFZ-3c-OFY" secondAttribute="top" constant="16" id="zZe-Oe-Okw"/>
135 <constraint firstItem="HD1-1N-Rae" firstAttribute="top" secondItem="kFZ-3c-OFY" secondAttribute="top" constant="16" id="zZe-Oe-Okw"/>
136+ <constraint firstItem="vC8-pT-qzP" firstAttribute="leading" secondItem="kFZ-3c-OFY" secondAttribute="leading" constant="16" id="zrN-AS-TUX"/>
124 </constraints>
137 </constraints>
125 </view>
138 </view>
126 </tableView>
139 </tableView>
@@ -142,6 +155,7 @@
142 <outlet property="placeLabel" destination="vCL-BI-I2h" id="r5C-RE-QOe"/>
155 <outlet property="placeLabel" destination="vCL-BI-I2h" id="r5C-RE-QOe"/>
143 <outlet property="profileImageView" destination="93Q-rB-JKk" id="Q3z-aT-aGK"/>
156 <outlet property="profileImageView" destination="93Q-rB-JKk" id="Q3z-aT-aGK"/>
144 <outlet property="profileView" destination="kFZ-3c-OFY" id="aJd-83-7kt"/>
157 <outlet property="profileView" destination="kFZ-3c-OFY" id="aJd-83-7kt"/>
158+ <outlet property="segmentedControl" destination="vC8-pT-qzP" id="9en-ed-hiM"/>
145 <outlet property="surnameLabel" destination="vff-nz-u6X" id="je2-H8-N6i"/>
159 <outlet property="surnameLabel" destination="vff-nz-u6X" id="je2-H8-N6i"/>
146 <outlet property="tableView" destination="cay-ea-rTl" id="RlG-PF-8DP"/>
160 <outlet property="tableView" destination="cay-ea-rTl" id="RlG-PF-8DP"/>
147 </connections>
161 </connections>
GDproject/Controller/BasicInfoController.swift−29
@@ -25,10 +25,6 @@ class BasicInfoController: UIViewController, UITableViewDelegate, UITableViewDat
25 CellData(opened: false, title: "Link", sectionData: ["https://wwww.hse.ru"])
25 CellData(opened: false, title: "Link", sectionData: ["https://wwww.hse.ru"])
26 ]
26 ]
27
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 {
28 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
33 if (dataSourse[section].opened){
29 if (dataSourse[section].opened){
34 return dataSourse[section].sectionData.count + 1
30 return dataSourse[section].sectionData.count + 1
@@ -75,29 +71,4 @@ class BasicInfoController: UIViewController, UITableViewDelegate, UITableViewDat
75 func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
71 func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
76 return 100.0
72 return 100.0
77 }
73 }
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}
74}
GDproject/Controller/News/HeaderNewsChannels.swift+5−44
@@ -16,30 +16,11 @@ class HeaderNewsChannels: UITableViewCell {
16 weak var vc: NewsController?
16 weak var vc: NewsController?
17 weak var vcProfile: ProfileViewController?
17 weak var vcProfile: ProfileViewController?
18
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− }
38
19
39 override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
20 override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
40 super.init(style: style, reuseIdentifier: reuseIdentifier)
21 super.init(style: style, reuseIdentifier: reuseIdentifier)
41 backgroundColor = .white
22 backgroundColor = .white
42− //setUpCell()
23+ setUpCell()
43 }
24 }
44
25
45 required init?(coder aDecoder: NSCoder) {
26 required init?(coder aDecoder: NSCoder) {
@@ -48,43 +29,23 @@ class HeaderNewsChannels: UITableViewCell {
48
29
49 func setUpCell(){
30 func setUpCell(){
50
31
51− guard let postsChannelsSegment = postsChannelsSegment else {
52− return
53− }
54−
55 addSubview(postsChannelsSegment)
32 addSubview(postsChannelsSegment)
56−
33+ postsChannelsSegment.selectedSegmentIndex = 0
57 postsChannelsSegment.addTarget(self, action: #selector(changedValue), for: .valueChanged)
34 postsChannelsSegment.addTarget(self, action: #selector(changedValue), for: .valueChanged)
58 postsChannelsSegment.edgesToSuperview(insets: .left(16) + .right(16) + .top(8) + .bottom(8))
35 postsChannelsSegment.edgesToSuperview(insets: .left(16) + .right(16) + .top(8) + .bottom(8))
59 }
36 }
60
37
61 // Initialize
38 // Initialize
62− var postsChannelsSegment: UISegmentedControl?
39+ var postsChannelsSegment: UISegmentedControl = UISegmentedControl(items: ["Posts", "Channels"])
63
40
64 @objc func changedValue(_ sender: UISegmentedControl) {
41 @objc func changedValue(_ sender: UISegmentedControl) {
65 let index = sender.selectedSegmentIndex
42 let index = sender.selectedSegmentIndex
66
43
67 switch index {
44 switch index {
68 case 0:
45 case 0:
69− switch type {
70− case .BASIC_INFO:
71− vcProfile?.changeToPosts()
72− case .NEWS:
73− vc?.setUpNavigationItemsforPosts()
46+ vc?.setUpNavigationItemsforPosts()
74− default:
75− break
76− }
77 case 1:
47 case 1:
78− switch type {
79− case .PROFILE:
80− print("info")
81− vcProfile?.changeToBasicInfo()
82− case .NEWS:
83− print("channels")
84− vc?.setUpNavigationItemsForChannels()
48+ vc?.setUpNavigationItemsForChannels()
85− default:
86− break
87− }
88 default:
49 default:
89 break
50 break
90 }
51 }
GDproject/Controller/News/NewsVC.swift−2
@@ -63,8 +63,6 @@ class NewsVC: UIViewController, UITableViewDelegate, UITableViewDataSource{
63 cell.vc = viewController as? NewsController
63 cell.vc = viewController as? NewsController
64 cell.vcProfile = viewController as? ProfileViewController
64 cell.vcProfile = viewController as? ProfileViewController
65
65
66− cell.type = type
67−
68 let view = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 46.0))
66 let view = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 46.0))
69 view.addSubview(cell)
67 view.addSubview(cell)
70 cell.edgesToSuperview()
68 cell.edgesToSuperview()
GDproject/Controller/ProfileViewController.swift+19−3
@@ -9,7 +9,10 @@
9import UIKit
9import UIKit
10import TinyConstraints
10import TinyConstraints
11
11
12−class ProfileViewController: UIViewController {
12+class ProfileViewController: UIViewController
13+{
14+
15+ @IBOutlet weak var segmentedControl: UISegmentedControl!
13
16
14 @IBOutlet weak var profileView: UIView!
17 @IBOutlet weak var profileView: UIView!
15
18
@@ -45,14 +48,13 @@ class ProfileViewController: UIViewController {
45 {
48 {
46 super.viewDidLoad()
49 super.viewDidLoad()
47
50
48− posts.type = .PROFILE("Posts", "Basic Info")
51+ posts.type = .NONE
49
52
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. .")])]
53 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
54
52 // basicInfo.dataSourse =
55 // basicInfo.dataSourse =
53
56
54 posts.viewController = self
57 posts.viewController = self
55− basicInfo.viewController = self
56
58
57 tableView.register(HeaderNewsChannels.self, forCellReuseIdentifier: headerNewsChannelsVC)
59 tableView.register(HeaderNewsChannels.self, forCellReuseIdentifier: headerNewsChannelsVC)
58
60
@@ -106,6 +108,20 @@ class ProfileViewController: UIViewController {
106 self.present(optionMenu, animated: true, completion: nil)
108 self.present(optionMenu, animated: true, completion: nil)
107 }
109 }
108
110
111+
112+ @IBAction func valueChanged(_ sender: UISegmentedControl) {
113+ let index = sender.selectedSegmentIndex
114+
115+ switch index {
116+ case 0:
117+ changeToPosts()
118+ case 1:
119+ changeToBasicInfo()
120+ default:
121+ break
122+ }
123+ }
124+
109 func changeToPosts(){
125 func changeToPosts(){
110 tableView.delegate = posts
126 tableView.delegate = posts
111 tableView.dataSource = posts
127 tableView.dataSource = posts