This commit is contained in:
Chris Li 2016-11-24 14:27:12 -05:00
parent 13b33e2e3a
commit bc8e8afee5
6 changed files with 130 additions and 40 deletions

View File

@ -26,11 +26,13 @@ class Buttons {
private(set) lazy var cancel: UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(tapped(button:)))
let space = UIBarButtonItem(barButtonSystemItem: .flexibleSpace)
let testB = BarButton()
var delegate: ButtonDelegates?
var toolbar: [UIBarButtonItem] {
get {
return [back, space, forward, space, toc, space, bookmark, space, library, space, setting]
return [testB, space, toc, space, bookmark, space, library, space, setting]
}
}
@ -116,9 +118,10 @@ class GrayBarButtonItem: UIBarButtonItem {
class BarButton: UIBarButtonItem {
private(set) var type = BarButtonType.blank
convenience init(type: BarButtonType) {
let button = UIButton()
button.setImage(<#T##image: UIImage?##UIImage?#>, for: <#T##UIControlState#>)
self.init(customView: button)
let imageView = UIImageView(image: UIImage(named: "Bookmark"))
imageView.frame = CGRect(x: 0, y: 0, width: 26, height: 26)
self.init(customView: imageView)
// self.init(image: nil, style: .plain, target: nil, action: nil)
self.type = type
}
}

View File

@ -33,28 +33,28 @@ class MainController: UIViewController {
buttons.addLongTapGestureRecognizer()
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
guard traitCollection.horizontalSizeClass != previousTraitCollection?.horizontalSizeClass ||
traitCollection.verticalSizeClass != previousTraitCollection?.verticalSizeClass else {return}
switch traitCollection.horizontalSizeClass {
case .compact:
navigationController?.setToolbarHidden(false, animated: false)
navigationItem.leftBarButtonItems = nil
navigationItem.rightBarButtonItems = nil
if searchBar.isFirstResponder {
navigationItem.rightBarButtonItem = buttons.cancel
}
toolbarItems = buttons.toolbar
case .regular:
navigationController?.setToolbarHidden(true, animated: false)
toolbarItems = nil
navigationItem.leftBarButtonItems = buttons.navLeft
navigationItem.rightBarButtonItems = buttons.navRight
default:
return
}
}
// override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
// super.traitCollectionDidChange(previousTraitCollection)
// guard traitCollection.horizontalSizeClass != previousTraitCollection?.horizontalSizeClass ||
// traitCollection.verticalSizeClass != previousTraitCollection?.verticalSizeClass else {return}
// switch traitCollection.horizontalSizeClass {
// case .compact:
// navigationController?.setToolbarHidden(false, animated: false)
// navigationItem.leftBarButtonItems = nil
// navigationItem.rightBarButtonItems = nil
// if searchBar.isFirstResponder {
// navigationItem.rightBarButtonItem = buttons.cancel
// }
// toolbarItems = buttons.toolbar
// case .regular:
// navigationController?.setToolbarHidden(true, animated: false)
// toolbarItems = nil
// navigationItem.leftBarButtonItems = buttons.navLeft
// navigationItem.rightBarButtonItems = buttons.navRight
// default:
// return
// }
// }
}
class WebView: UIWebView {
@ -102,3 +102,23 @@ class WebView: UIWebView {
forwardList.removeAll()
}
}
class TestStackView: UIStackView {
var topBorder = CALayer()
override func awakeFromNib() {
super.awakeFromNib()
topBorder.backgroundColor = UIColor.lightGray.withAlphaComponent(0.9).cgColor
layer.addSublayer(topBorder)
}
override func draw(_ rect: CGRect) {
super.draw(rect)
topBorder.frame = CGRect(x: 0, y: 0, width: rect.width, height: 0.5)
}
override func layoutSubviews() {
super.layoutSubviews()
setNeedsDisplay()
}
}

View File

@ -181,7 +181,7 @@ extension MainController {
let controller = controllers.welcome
controller.view.translatesAutoresizingMaskIntoConstraints = false
addChildViewController(controller)
view.addSubview(controller.view)
view.insertSubview(controller.view, aboveSubview: webView)
let views = ["view": controller.view]
view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[view]|", options: .alignAllTop, metrics: nil, views: views))
view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[view]|", options: .alignAllLeft, metrics: nil, views: views))

View File

@ -49,7 +49,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.8.3101</string>
<string>1.8.3132</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>

View File

@ -36,7 +36,7 @@
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="AUI-Vv-fbI" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="3084" y="-674"/>
<point key="canvasLocation" x="4262" y="-350"/>
</scene>
<!--Root View Controller-->
<scene sceneID="BNz-yk-AfC">
@ -103,11 +103,11 @@
<rect key="frame" x="0.0" y="28" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="DSn-3Y-Gs4" id="vq5-6x-vLY">
<rect key="frame" x="0.0" y="0.0" width="414" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="xPq-dt-NK6">
<rect key="frame" x="15" y="0.0" width="384" height="43.666666666666664"/>
<rect key="frame" x="15" y="0.0" width="384" height="43"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@ -125,11 +125,11 @@
<rect key="frame" x="0.0" y="72" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="au4-iz-tLz" id="3UD-lZ-hs0">
<rect key="frame" x="0.0" y="0.0" width="414" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="DJX-Kf-59M">
<rect key="frame" x="15" y="0.0" width="384" height="43.666666666666664"/>
<rect key="frame" x="15" y="0.0" width="384" height="43"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@ -147,11 +147,11 @@
<rect key="frame" x="0.0" y="116" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="cam-ik-ZIw" id="ooG-35-3Wp">
<rect key="frame" x="0.0" y="0.0" width="414" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="ry7-2s-QyS">
<rect key="frame" x="15" y="0.0" width="384" height="43.666666666666664"/>
<rect key="frame" x="15" y="0.0" width="384" height="43"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@ -286,14 +286,24 @@
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</webView>
<containerView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="PIe-A7-HCU">
<rect key="frame" x="0.0" y="648" width="414" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="mI6-mY-aSf"/>
</constraints>
<connections>
<segue destination="iuJ-RV-a4u" kind="embed" id="3Xn-9i-i5i"/>
</connections>
</containerView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="MjM-In-ehJ" firstAttribute="top" secondItem="KVH-WC-JGt" secondAttribute="bottom" constant="-64" id="1Om-9P-m57"/>
<constraint firstAttribute="trailing" secondItem="PIe-A7-HCU" secondAttribute="trailing" id="FJC-nY-BU1"/>
<constraint firstItem="MjM-In-ehJ" firstAttribute="leading" secondItem="hRW-ET-fRA" secondAttribute="leading" id="Kf8-Rn-ROp"/>
<constraint firstItem="UIX-e1-SUg" firstAttribute="top" secondItem="MjM-In-ehJ" secondAttribute="bottom" constant="-44" id="MRq-VY-WQT">
<variation key="widthClass=regular" constant="0.0"/>
</constraint>
<constraint firstItem="UIX-e1-SUg" firstAttribute="top" secondItem="MjM-In-ehJ" secondAttribute="bottom" constant="-44" id="MRq-VY-WQT"/>
<constraint firstItem="PIe-A7-HCU" firstAttribute="leading" secondItem="hRW-ET-fRA" secondAttribute="leading" id="Zb9-9Y-QTe"/>
<constraint firstItem="UIX-e1-SUg" firstAttribute="top" secondItem="PIe-A7-HCU" secondAttribute="bottom" id="mQr-KY-UkV"/>
<constraint firstAttribute="trailing" secondItem="MjM-In-ehJ" secondAttribute="trailing" id="tIZ-J4-u59"/>
</constraints>
</view>
@ -305,7 +315,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Yrv-8u-IwG" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1656.8" y="-349.47526236881561"/>
<point key="canvasLocation" x="1658" y="-355"/>
</scene>
<!--Main Controller-->
<scene sceneID="nEL-IB-dp3">
@ -514,5 +524,62 @@
</objects>
<point key="canvasLocation" x="1099" y="433"/>
</scene>
<!--View Controller-->
<scene sceneID="eH2-wj-Pab">
<objects>
<viewController id="iuJ-RV-a4u" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="VgB-Ge-Zag">
<rect key="frame" x="0.0" y="0.0" width="414" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<visualEffectView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Cnf-Mv-aWx">
<rect key="frame" x="0.0" y="0.0" width="414" height="44"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="LMY-m4-Hg3">
<rect key="frame" x="0.0" y="0.0" width="414" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="tb0-Kd-aaC" customClass="TestStackView" customModule="Kiwix" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="414" height="44"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="7Ot-i5-YMq">
<rect key="frame" x="0.0" y="0.0" width="207" height="44"/>
<state key="normal" image="Library"/>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gYg-Ny-U6g">
<rect key="frame" x="207" y="0.0" width="207" height="44"/>
<state key="normal" image="Setting"/>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</stackView>
</subviews>
<constraints>
<constraint firstItem="tb0-Kd-aaC" firstAttribute="top" secondItem="LMY-m4-Hg3" secondAttribute="top" id="6mY-zA-avG"/>
<constraint firstItem="tb0-Kd-aaC" firstAttribute="leading" secondItem="LMY-m4-Hg3" secondAttribute="leading" id="RO9-L5-u12"/>
<constraint firstAttribute="trailing" secondItem="tb0-Kd-aaC" secondAttribute="trailing" id="lBi-Fe-Nhm"/>
<constraint firstAttribute="bottom" secondItem="tb0-Kd-aaC" secondAttribute="bottom" id="zrg-El-dRc"/>
</constraints>
</view>
<color key="backgroundColor" white="0.66666666666666663" alpha="0.10000000000000001" colorSpace="calibratedWhite"/>
<blurEffect style="extraLight"/>
</visualEffectView>
</subviews>
<color key="backgroundColor" white="0.66666666666666663" alpha="0.301056338028169" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="Cnf-Mv-aWx" secondAttribute="trailing" id="C6h-vo-T1p"/>
<constraint firstAttribute="bottom" secondItem="Cnf-Mv-aWx" secondAttribute="bottom" id="EPB-eb-6RG"/>
<constraint firstItem="Cnf-Mv-aWx" firstAttribute="leading" secondItem="VgB-Ge-Zag" secondAttribute="leading" id="S2o-Me-Oqo"/>
<constraint firstItem="Cnf-Mv-aWx" firstAttribute="top" secondItem="VgB-Ge-Zag" secondAttribute="top" id="yaW-Vr-d5T"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="xKC-rr-RXd" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2550.7246376811595" y="106.79347826086958"/>
</scene>
</scenes>
<resources>
<image name="Library" width="29" height="29"/>
<image name="Setting" width="27" height="27"/>
</resources>
</document>

View File

@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.8.3101</string>
<string>1.8.3132</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionMainStoryboard</key>