Dimitris Togias

replace resegmentedcontrol with 2 uibuttons

......@@ -9,8 +9,9 @@ import UIKit
import RESegmentedControl
@objc public class LoyaltyAnalysisViewController: UIViewController {
@IBOutlet weak var tabView: RESegmentedControl!
@IBOutlet weak var leftButton: UIButton!
@IBOutlet weak var rightButton: UIButton!
@IBOutlet weak var contentView: UIView!
var pageController: UIPageViewController!
......@@ -24,13 +25,13 @@ import RESegmentedControl
setNavigationTitle("Ανάλυση")
// tab
let titles = ["Εξαργυρωμένα", "Μοιρασμένα δώρα"]
var segmentItems: [SegmentModel] {
return titles.map({ SegmentModel(title: $0) })
}
let preset = BootstapPreset(backgroundColor: .white, selectedBackgroundColor: .white)
tabView.configure(segmentItems: segmentItems, preset: preset)
leftButton.setTitle("Εξαργυρωμένα", for:.normal)
leftButton.backgroundColor = . clear
leftButton.setTitleColor(UIColor(rgb: 0x2EAFB9), for:.normal)
rightButton.setTitle("Μοιρασμένα δώρα", for:.normal)
rightButton.backgroundColor = . clear
rightButton.setTitleColor(UIColor(rgb: 0x2EAFB9), for:.normal)
// pages
pageController = UIPageViewController(transitionStyle:.scroll, navigationOrientation:.horizontal)
......@@ -63,6 +64,19 @@ import RESegmentedControl
return analysisVC;
}
// MARK: - Handlers
@IBAction func handleLeft() {
let analysisVC = self.viewControllerAt(0)
pageController.setViewControllers([analysisVC!], direction:.reverse, animated:true)
}
@IBAction func handleRight() {
let analysisVC = self.viewControllerAt(1)
pageController.setViewControllers([analysisVC!], direction:.forward, animated:true)
}
}
// MARK: - PageViewController
......@@ -108,7 +122,13 @@ extension LoyaltyAnalysisViewController: UIPageViewControllerDataSource, UIPageV
if let childVCs = pageViewController.viewControllers as? [AnalysisChildViewController] {
let currentIndex = childVCs[0].index
tabView.selectedSegmentIndex = currentIndex
if (currentIndex == 0) {
leftButton.isSelected = true
rightButton.isSelected = false
} else {
leftButton.isSelected = false
rightButton.isSelected = true
}
}
}
}
......
......@@ -404,11 +404,47 @@
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Z7V-En-7Tl" customClass="RESegmentedControl" customModule="RESegmentedControl">
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Z7V-En-7Tl">
<rect key="frame" x="0.0" y="44" width="414" height="50"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="liP-dN-sf3">
<rect key="frame" x="0.0" y="0.0" width="206.5" height="50"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="Button"/>
<connections>
<action selector="handleLeft" destination="duB-b9-cnh" eventType="touchUpInside" id="eCq-GW-QAg"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kAf-Oi-EnQ">
<rect key="frame" x="206.5" y="0.0" width="1" height="50"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="CxW-qN-ftc"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="BNZ-3e-HXp">
<rect key="frame" x="207.5" y="0.0" width="206.5" height="50"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="Button"/>
<connections>
<action selector="handleRight" destination="duB-b9-cnh" eventType="touchUpInside" id="bo6-x4-8Ld"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="kAf-Oi-EnQ" firstAttribute="leading" secondItem="liP-dN-sf3" secondAttribute="trailing" id="7Eg-e7-UZK"/>
<constraint firstItem="liP-dN-sf3" firstAttribute="leading" secondItem="Z7V-En-7Tl" secondAttribute="leading" id="CRR-X1-VXy"/>
<constraint firstAttribute="trailing" secondItem="BNZ-3e-HXp" secondAttribute="trailing" id="FUC-Xt-vrx"/>
<constraint firstAttribute="bottom" secondItem="liP-dN-sf3" secondAttribute="bottom" id="HX4-Xg-GBR"/>
<constraint firstItem="liP-dN-sf3" firstAttribute="top" secondItem="Z7V-En-7Tl" secondAttribute="top" id="O5V-e5-NPf"/>
<constraint firstAttribute="height" constant="50" id="W4o-5O-kfL"/>
<constraint firstItem="BNZ-3e-HXp" firstAttribute="top" secondItem="Z7V-En-7Tl" secondAttribute="top" id="WtA-PL-BZy"/>
<constraint firstItem="kAf-Oi-EnQ" firstAttribute="centerX" secondItem="Z7V-En-7Tl" secondAttribute="centerX" id="jG4-gb-zWB"/>
<constraint firstAttribute="bottom" secondItem="BNZ-3e-HXp" secondAttribute="bottom" id="kzL-YN-Vkn"/>
<constraint firstItem="BNZ-3e-HXp" firstAttribute="leading" secondItem="kAf-Oi-EnQ" secondAttribute="trailing" id="zPD-7c-CdH"/>
<constraint firstItem="kAf-Oi-EnQ" firstAttribute="top" secondItem="Z7V-En-7Tl" secondAttribute="top" id="zq1-qp-f9S"/>
<constraint firstAttribute="bottom" secondItem="kAf-Oi-EnQ" secondAttribute="bottom" id="zsL-bI-ChP"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="FyK-3t-liP">
......@@ -430,12 +466,13 @@
</view>
<connections>
<outlet property="contentView" destination="FyK-3t-liP" id="lBC-DU-jIb"/>
<outlet property="tabView" destination="Z7V-En-7Tl" id="V5w-xL-IBc"/>
<outlet property="leftButton" destination="liP-dN-sf3" id="PSM-x1-lPV"/>
<outlet property="rightButton" destination="BNZ-3e-HXp" id="NDe-B7-wIV"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="jF4-GM-aCp" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="3125" y="836"/>
<point key="canvasLocation" x="3124.6376811594205" y="835.71428571428567"/>
</scene>
<!--Sharing History View Controller-->
<scene sceneID="Yng-iu-80u">
......