git.iko.soy/dashared/GDproject
on master help sign in
sticky header on profile is deleted. improved header file
commit77ad34ca176d4036974e10f95824ae3914951978 authorDarya Rednikina <rednikina.com@yandex.ru> dateSat 16 Feb 2019, 17:23 (8 years ago) parentcf2ae8b
5 files changed+40−80
GDproject/Base.lproj/Main.storyboard+16−2 GDproject/Controller/BasicInfoController.swift−29 GDproject/Controller/News/HeaderNewsChannels.swift+5−44 GDproject/Controller/News/NewsVC.swift−2 GDproject/Controller/ProfileViewController.swift+19−3
GDproject/Base.lproj/Main.storyboard+16−2
@@ -54,7 +54,7 @@
5454 <rect key="frame" x="0.0" y="116" width="375" height="502"/>
5555 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
5656 <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"/>
5858 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
5959 <subviews>
6060 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="93Q-rB-JKk">
@@ -110,17 +110,30 @@
110110 </button>
111111 </subviews>
112112 </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>
113123 </subviews>
114124 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
115125 <constraints>
126+ <constraint firstAttribute="trailing" secondItem="vC8-pT-qzP" secondAttribute="trailing" constant="16" id="1pN-90-cEV"/>
116127 <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"/>
118130 <constraint firstItem="hFb-Uj-GwE" firstAttribute="leading" secondItem="kFZ-3c-OFY" secondAttribute="leading" constant="16" id="HWn-2I-NvS"/>
119131 <constraint firstAttribute="trailing" secondItem="hFb-Uj-GwE" secondAttribute="trailing" constant="16" id="MHn-bJ-vkd"/>
120132 <constraint firstItem="HD1-1N-Rae" firstAttribute="leading" secondItem="93Q-rB-JKk" secondAttribute="trailing" constant="20" id="Zmg-ZS-Eyy"/>
121133 <constraint firstItem="93Q-rB-JKk" firstAttribute="leading" secondItem="kFZ-3c-OFY" secondAttribute="leading" constant="16" id="f3K-RA-5qe"/>
122134 <constraint firstAttribute="trailing" secondItem="HD1-1N-Rae" secondAttribute="trailing" constant="16" id="qT1-ct-8ed"/>
123135 <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"/>
124137 </constraints>
125138 </view>
126139 </tableView>
@@ -142,6 +155,7 @@
142155 <outlet property="placeLabel" destination="vCL-BI-I2h" id="r5C-RE-QOe"/>
143156 <outlet property="profileImageView" destination="93Q-rB-JKk" id="Q3z-aT-aGK"/>
144157 <outlet property="profileView" destination="kFZ-3c-OFY" id="aJd-83-7kt"/>
158+ <outlet property="segmentedControl" destination="vC8-pT-qzP" id="9en-ed-hiM"/>
145159 <outlet property="surnameLabel" destination="vff-nz-u6X" id="je2-H8-N6i"/>
146160 <outlet property="tableView" destination="cay-ea-rTl" id="RlG-PF-8DP"/>
147161 </connections>
GDproject/Controller/BasicInfoController.swift−29
@@ -25,10 +25,6 @@ class BasicInfoController: UIViewController, UITableViewDelegate, UITableViewDat
2525 CellData(opened: false, title: "Link", sectionData: ["https://wwww.hse.ru"])
2626 ]
2727
28− var type: HeaderType = .BASIC_INFO("Profile", "Basic info")
29−
30− var viewController: ProfileViewController?
31−
3228 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
3329 if (dataSourse[section].opened){
3430 return dataSourse[section].sectionData.count + 1
@@ -75,29 +71,4 @@ class BasicInfoController: UIViewController, UITableViewDelegate, UITableViewDat
7571 func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
7672 return 100.0
7773 }
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− }
10374}
GDproject/Controller/News/HeaderNewsChannels.swift+5−44
@@ -16,30 +16,11 @@ class HeaderNewsChannels: UITableViewCell {
1616 weak var vc: NewsController?
1717 weak var vcProfile: ProfileViewController?
1818
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− }
3819
3920 override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
4021 super.init(style: style, reuseIdentifier: reuseIdentifier)
4122 backgroundColor = .white
42− //setUpCell()
23+ setUpCell()
4324 }
4425
4526 required init?(coder aDecoder: NSCoder) {
@@ -48,43 +29,23 @@ class HeaderNewsChannels: UITableViewCell {
4829
4930 func setUpCell(){
5031
51− guard let postsChannelsSegment = postsChannelsSegment else {
52− return
53− }
54−
5532 addSubview(postsChannelsSegment)
56−
33+ postsChannelsSegment.selectedSegmentIndex = 0
5734 postsChannelsSegment.addTarget(self, action: #selector(changedValue), for: .valueChanged)
5835 postsChannelsSegment.edgesToSuperview(insets: .left(16) + .right(16) + .top(8) + .bottom(8))
5936 }
6037
6138 // Initialize
62− var postsChannelsSegment: UISegmentedControl?
39+ var postsChannelsSegment: UISegmentedControl = UISegmentedControl(items: ["Posts", "Channels"])
6340
6441 @objc func changedValue(_ sender: UISegmentedControl) {
6542 let index = sender.selectedSegmentIndex
6643
6744 switch index {
6845 case 0:
69− switch type {
70− case .BASIC_INFO:
71− vcProfile?.changeToPosts()
72− case .NEWS:
73− vc?.setUpNavigationItemsforPosts()
74− default:
75− break
76− }
46+ vc?.setUpNavigationItemsforPosts()
7747 case 1:
78− switch type {
79− case .PROFILE:
80− print("info")
81− vcProfile?.changeToBasicInfo()
82− case .NEWS:
83− print("channels")
84− vc?.setUpNavigationItemsForChannels()
85− default:
86− break
87− }
48+ vc?.setUpNavigationItemsForChannels()
8849 default:
8950 break
9051 }
GDproject/Controller/News/NewsVC.swift−2
@@ -63,8 +63,6 @@ class NewsVC: UIViewController, UITableViewDelegate, UITableViewDataSource{
6363 cell.vc = viewController as? NewsController
6464 cell.vcProfile = viewController as? ProfileViewController
6565
66− cell.type = type
67−
6866 let view = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 46.0))
6967 view.addSubview(cell)
7068 cell.edgesToSuperview()
GDproject/Controller/ProfileViewController.swift+19−3
@@ -9,7 +9,10 @@
99import UIKit
1010import TinyConstraints
1111
12−class ProfileViewController: UIViewController {
12+class ProfileViewController: UIViewController
13+{
14+
15+ @IBOutlet weak var segmentedControl: UISegmentedControl!
1316
1417 @IBOutlet weak var profileView: UIView!
1518
@@ -45,14 +48,13 @@ class ProfileViewController: UIViewController {
4548 {
4649 super.viewDidLoad()
4750
48− posts.type = .PROFILE("Posts", "Basic Info")
51+ posts.type = .NONE
4952
5053 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. .")])]
5154
5255 // basicInfo.dataSourse =
5356
5457 posts.viewController = self
55− basicInfo.viewController = self
5658
5759 tableView.register(HeaderNewsChannels.self, forCellReuseIdentifier: headerNewsChannelsVC)
5860
@@ -106,6 +108,20 @@ class ProfileViewController: UIViewController {
106108 self.present(optionMenu, animated: true, completion: nil)
107109 }
108110
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+
109125 func changeToPosts(){
110126 tableView.delegate = posts
111127 tableView.dataSource = posts