welcome controller button

This commit is contained in:
Chris Li 2017-02-08 13:56:19 -05:00
parent f4bd73e477
commit 216eb91a22
6 changed files with 78 additions and 48 deletions

View File

@ -9,8 +9,50 @@
import UIKit
class WelcomeController: UIViewController {
@IBOutlet weak var stackView: UIStackView!
// place holder for adding stuff like resume last read, suggestions in welcome screen
// maybe this class one day will become tabs controller
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let button = OpenLibraryButton()
stackView.addArrangedSubview(button)
}
}
class OpenLibraryButton: UIButton {
init() {
super.init(frame: CGRect.zero)
let style = NSMutableParagraphStyle()
style.alignment = .center
let attributedTitle = NSMutableAttributedString(string: "Open Library\n", attributes: [
NSForegroundColorAttributeName: UIColor.white,
NSFontAttributeName: UIFont.systemFont(ofSize: 17, weight: UIFontWeightMedium),
NSParagraphStyleAttributeName: style
]
)
let attributedSubtitle = NSMutableAttributedString(string: "Download or import a book", attributes: [
NSForegroundColorAttributeName: UIColor.white,
NSFontAttributeName: UIFont.systemFont(ofSize: 13, weight: UIFontWeightRegular),
NSParagraphStyleAttributeName: style
])
attributedTitle.append(attributedSubtitle)
titleLabel?.numberOfLines = 0
setAttributedTitle(attributedTitle, for: UIControlState.normal)
setTitleColor(UIColor.white, for: UIControlState.normal)
layer.cornerRadius = 10.0
backgroundColor = UIColor.blue
}
override var isHighlighted: Bool {
didSet {
backgroundColor = isHighlighted ? UIColor.lightGray : UIColor.orange
}
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

View File

@ -57,7 +57,7 @@
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<false/>
<key>NSExceptionDomains</key>
<dict>
<key>kiwix.org</key>

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="aWb-Y7-c2Y">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12100" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="aWb-Y7-c2Y">
<device id="retina5_5" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12072"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@ -31,7 +31,7 @@
<rect key="frame" x="0.0" y="28" width="414" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="BZj-UA-kZf" id="QkJ-pZ-dqx">
<rect key="frame" x="0.0" y="0.0" width="414" height="43"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" lineBreakMode="tailTruncation" minimumFontSize="8" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="GW1-dh-vyc">
@ -171,7 +171,7 @@
<rect key="frame" x="0.0" y="28" width="414" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="z8v-Ld-3tX" id="PYl-F0-kUl">
<rect key="frame" x="0.0" y="0.0" width="414" height="43"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="UgG-QR-OX4">
@ -228,7 +228,7 @@
<rect key="frame" x="0.0" y="72" width="414" height="87"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="wBv-ub-ny7" id="fk4-EM-rH7">
<rect key="frame" x="0.0" y="0.0" width="414" height="86"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="86.666666666666671"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="ien-Dp-MNO">
@ -347,7 +347,7 @@
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
<cells>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="Cell" id="bG3-jc-npj" customClass="LocalLangCell" customModule="Kiwix" customModuleProvider="target">
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="Cell" id="bG3-jc-npj" customClass="RecentSearchCell" customModule="Kiwix" customModuleProvider="target">
<rect key="frame" x="0.0" y="1" width="102" height="42"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">

View File

@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="2Bo-lO-qA9">
<device id="retina4_7" orientation="portrait">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12100" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="2Bo-lO-qA9">
<device id="retina5_5" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12072"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
@ -18,11 +20,11 @@
<viewControllerLayoutGuide type="bottom" id="erc-nt-iny"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" layoutMarginsFollowReadableWidth="YES" id="NVS-td-RHS">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="nWg-4h-oN7" customClass="Logo" customModule="Kiwix" customModuleProvider="target">
<rect key="frame" x="157.5" y="266.5" width="60" height="60"/>
<rect key="frame" x="177" y="301" width="60" height="60"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="60" id="J1t-fs-gnK"/>
@ -30,7 +32,7 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="HdA-x4-WiZ">
<rect key="frame" x="177.5" y="328.5" width="20" height="10"/>
<rect key="frame" x="197" y="363" width="20" height="10"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="10" id="fI2-Co-2QO"/>
@ -38,10 +40,9 @@
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Wikipedia Anywhere" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="786-cr-yay">
<rect key="frame" x="87.5" y="383" width="200" height="21"/>
<rect key="frame" x="107" y="440.33333333333326" width="200" height="15.666666666666686"/>
<constraints>
<constraint firstAttribute="width" constant="200" id="NIm-me-EN7"/>
<constraint firstAttribute="height" constant="21" id="c7K-v2-oGV"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" red="0.43529411759999997" green="0.4431372549" blue="0.47450980390000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@ -54,10 +55,9 @@
</variation>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="KIWIX" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="heM-Vx-A7u">
<rect key="frame" x="87.5" y="339" width="200" height="36"/>
<rect key="frame" x="107" y="373.66666666666669" width="200" height="58.666666666666629"/>
<constraints>
<constraint firstAttribute="width" constant="200" id="Zbh-Kq-ZDe"/>
<constraint firstAttribute="height" constant="36" id="md1-oa-sOt"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="light" pointSize="49"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@ -69,11 +69,18 @@
<fontDescription key="fontDescription" type="system" weight="light" pointSize="58"/>
</variation>
</label>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="E2J-2L-EfY">
<rect key="frame" x="20" y="539" width="374" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="VJS-aA-KWr"/>
</constraints>
</stackView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="heM-Vx-A7u" firstAttribute="centerY" secondItem="NVS-td-RHS" secondAttribute="centerY" id="4Na-Pg-67L"/>
<constraint firstItem="heM-Vx-A7u" firstAttribute="top" secondItem="nWg-4h-oN7" secondAttribute="bottom" constant="16" id="8gT-H8-CXp"/>
<constraint firstItem="E2J-2L-EfY" firstAttribute="top" secondItem="heM-Vx-A7u" secondAttribute="bottom" multiplier="1.2" constant="20" id="43n-kM-7JX">
<variation key="heightClass=compact" constant="0.0"/>
</constraint>
<constraint firstItem="786-cr-yay" firstAttribute="top" secondItem="heM-Vx-A7u" secondAttribute="bottom" constant="8" id="CU4-Lo-Cxs"/>
<constraint firstItem="heM-Vx-A7u" firstAttribute="top" secondItem="HdA-x4-WiZ" secondAttribute="bottom" constant="0.5" id="JoH-xK-bUs"/>
<constraint firstItem="heM-Vx-A7u" firstAttribute="centerX" secondItem="NVS-td-RHS" secondAttribute="centerX" id="Kjs-NP-6cQ"/>
@ -82,21 +89,20 @@
<constraint firstItem="HdA-x4-WiZ" firstAttribute="centerX" secondItem="NVS-td-RHS" secondAttribute="centerX" id="oAY-D3-1Si"/>
<constraint firstItem="786-cr-yay" firstAttribute="centerX" secondItem="NVS-td-RHS" secondAttribute="centerX" id="okf-kX-tsv"/>
<constraint firstItem="nWg-4h-oN7" firstAttribute="centerX" secondItem="NVS-td-RHS" secondAttribute="centerX" id="paN-oe-UEg"/>
<constraint firstItem="E2J-2L-EfY" firstAttribute="trailing" secondItem="NVS-td-RHS" secondAttribute="trailingMargin" id="v7Z-oQ-Ckf"/>
<constraint firstItem="E2J-2L-EfY" firstAttribute="leading" secondItem="NVS-td-RHS" secondAttribute="leadingMargin" id="yWh-6k-EfM"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="4Na-Pg-67L"/>
<exclude reference="8gT-H8-CXp"/>
</mask>
</variation>
</view>
<navigationItem key="navigationItem" id="CRN-GU-Pfx"/>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<simulatedTabBarMetrics key="simulatedBottomBarMetrics"/>
<connections>
<outlet property="stackView" destination="E2J-2L-EfY" id="MZl-Ma-Pnz"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="rsN-FU-j3g" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2780" y="-209"/>
<point key="canvasLocation" x="2780" y="-209.14542728635683"/>
</scene>
</scenes>
</document>

View File

@ -2,22 +2,4 @@
<Bucket
type = "0"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Kiwix/libkiwix/ZimReader.mm"
timestampString = "508185579.868817"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "43"
endingLineNumber = "43"
landmarkName = "-initWithZIMFileURL:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>

View File

@ -33,14 +33,14 @@
try {
zim::File zimFileHandle = *_reader->getZimFileHandler();
zim::Article xapianArticle = zimFileHandle.getArticle('Z', "/Z/fulltextIndex/xapian");
zim::Article xapianArticle = zimFileHandle.getArticle('Z', "/fulltextIndex/xapian");
if (xapianArticle.good()) {
zim::offset_type dbOffset = xapianArticle.getOffset();
int databasefd = open([url fileSystemRepresentation], O_RDONLY);
lseek(databasefd, dbOffset, SEEK_SET);
_db = new Xapian::Database(databasefd);
} else {
throw "xapian db not in zim";
throw "zim file dowes not have a embedded xapian db";
}
} catch (...) {
try {