mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-23 03:32:13 -04:00
Container App: bookmark widget max row setting
This commit is contained in:
parent
7dc988a6d6
commit
86ae17d762
@ -0,0 +1,71 @@
|
||||
//
|
||||
// SettingWidgetBookmarksTBVC.swift
|
||||
// Kiwix
|
||||
//
|
||||
// Created by Chris Li on 7/26/16.
|
||||
// Copyright © 2016 Chris. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class SettingWidgetBookmarksTBVC: UITableViewController {
|
||||
private var rowCount = 1 // widget row count
|
||||
|
||||
let options = [NSLocalizedString("One Row", comment: "Setting: Bookmark Widget"),
|
||||
NSLocalizedString("Two Rows", comment: "Setting: Bookmark Widget"),
|
||||
NSLocalizedString("Three Rows", comment: "Setting: Bookmark Widget")]
|
||||
|
||||
override func viewWillAppear(animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
title = LocalizedStrings.bookmarks
|
||||
if let defaults = NSUserDefaults(suiteName: "group.kiwix") {
|
||||
rowCount = max(1, min(defaults.integerForKey("BookmarkWidgetRowCount"), 3))
|
||||
}
|
||||
}
|
||||
|
||||
override func viewWillDisappear(animated: Bool) {
|
||||
super.viewWillDisappear(animated)
|
||||
let defaults = NSUserDefaults(suiteName: "group.kiwix")
|
||||
defaults?.setInteger(rowCount ?? 1, forKey: "BookmarkWidgetRowCount")
|
||||
}
|
||||
|
||||
// MARK: - Table view data source
|
||||
|
||||
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return options.count
|
||||
}
|
||||
|
||||
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
|
||||
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
|
||||
cell.textLabel?.text = options[indexPath.row]
|
||||
cell.accessoryType = indexPath.row == (rowCount - 1) ? .Checkmark : .None
|
||||
return cell
|
||||
}
|
||||
|
||||
override func tableView(tableView: UITableView, titleForFooterInSection section: Int) -> String? {
|
||||
return NSLocalizedString("Set the maximum number of rows displayed in Bookmarks Today Widget.", comment: "Setting: Bookmark Widget")
|
||||
}
|
||||
|
||||
// MARK: - Table view delegate
|
||||
|
||||
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
|
||||
let oldIndexPath = NSIndexPath(forItem: rowCount - 1, inSection: 0)
|
||||
guard let oldCell = tableView.cellForRowAtIndexPath(oldIndexPath),
|
||||
let newCell = tableView.cellForRowAtIndexPath(indexPath) else {return}
|
||||
oldCell.accessoryType = .None
|
||||
newCell.accessoryType = .Checkmark
|
||||
rowCount = indexPath.row + 1
|
||||
tableView.deselectRowAtIndexPath(indexPath, animated: true)
|
||||
}
|
||||
|
||||
override func tableView(tableView: UITableView, willDisplayFooterView view: UIView, forSection section: Int) {
|
||||
guard section == 0 else {return}
|
||||
guard let view = view as? UITableViewHeaderFooterView else {return}
|
||||
view.textLabel?.textAlignment = .Center
|
||||
}
|
||||
}
|
@ -9,10 +9,11 @@
|
||||
import UIKit
|
||||
|
||||
class SettingTBVC: UITableViewController {
|
||||
private(set) var sectionHeader = [LocalizedStrings.library, LocalizedStrings.reading, LocalizedStrings.search, LocalizedStrings.misc]
|
||||
private(set) var sectionHeader = [LocalizedStrings.library, LocalizedStrings.reading, LocalizedStrings.search, LocalizedStrings.widget, LocalizedStrings.misc]
|
||||
private(set) var cellTextlabels = [[LocalizedStrings.libraryAutoRefresh, LocalizedStrings.libraryUseCellularData, LocalizedStrings.libraryBackup],
|
||||
[LocalizedStrings.fontSize, LocalizedStrings.adjustLayout],
|
||||
[LocalizedStrings.history],
|
||||
[LocalizedStrings.bookmarks],
|
||||
[LocalizedStrings.rateKiwix, LocalizedStrings.about]]
|
||||
|
||||
let dateComponentsFormatter: NSDateComponentsFormatter = {
|
||||
@ -124,6 +125,8 @@ class SettingTBVC: UITableViewController {
|
||||
performSegueWithIdentifier("AdjustLayout", sender: self)
|
||||
case LocalizedStrings.history:
|
||||
performSegueWithIdentifier("SearchHistory", sender: self)
|
||||
case LocalizedStrings.bookmarks:
|
||||
performSegueWithIdentifier("SettingWidgetBookmarksTBVC", sender: self)
|
||||
case "Boost Factor 🚀":
|
||||
performSegueWithIdentifier("SearchTune", sender: self)
|
||||
case LocalizedStrings.rateKiwix:
|
||||
@ -194,6 +197,7 @@ extension LocalizedStrings {
|
||||
class var library: String {return NSLocalizedString("Library ", comment: "Setting: Section Header")}
|
||||
class var reading: String {return NSLocalizedString("Reading", comment: "Setting: Section Header")}
|
||||
class var search: String {return NSLocalizedString("Search", comment: "Setting: Section Header")}
|
||||
class var widget: String {return NSLocalizedString("Widget", comment: "Setting: Section Header")}
|
||||
class var misc: String {return NSLocalizedString("Misc", comment: "Setting: Section Header")}
|
||||
|
||||
//MARK: - Table Cell Text
|
||||
@ -202,7 +206,6 @@ extension LocalizedStrings {
|
||||
class var libraryBackup: String {return NSLocalizedString("Backup Local Files", comment: "Setting: Backup Local Files")}
|
||||
class var fontSize: String {return NSLocalizedString("Font Size", comment: "Setting: Font Size")}
|
||||
class var adjustLayout: String {return NSLocalizedString("Adjust Layout", comment: "Setting: Adjust Layout")}
|
||||
class var booksToInclude: String {return NSLocalizedString("Books To Include", comment: "Setting: Books To Include")}
|
||||
class var rateKiwix: String {return NSLocalizedString("Please Rate Kiwix", comment: "Setting: Others")}
|
||||
class var emailFeedback: String {return NSLocalizedString("Send Email Feedback", comment: "Setting: Others")}
|
||||
class var about: String {return NSLocalizedString("About", comment: "Setting: Others")}
|
||||
|
@ -49,7 +49,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.7.643</string>
|
||||
<string>1.7.663</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
|
@ -59,35 +59,34 @@
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1097" y="1698"/>
|
||||
</scene>
|
||||
<!--Table View Controller-->
|
||||
<!--Setting Widget BookmarksTBVC-->
|
||||
<scene sceneID="Bdc-3z-wHY">
|
||||
<objects>
|
||||
<tableViewController id="UN7-Sp-113" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" id="K9Y-GV-eEk">
|
||||
<tableViewController id="UN7-Sp-113" customClass="SettingWidgetBookmarksTBVC" customModule="Kiwix" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" id="K9Y-GV-eEk">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||
<sections>
|
||||
<tableViewSection id="Y6v-WD-nDY">
|
||||
<cells>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="8kv-1M-Lve">
|
||||
<rect key="frame" x="0.0" y="35" width="600" height="44"/>
|
||||
<prototypes>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" textLabel="map-7k-Ncg" style="IBUITableViewCellStyleDefault" id="8kv-1M-Lve">
|
||||
<rect key="frame" x="0.0" y="113.5" width="600" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="8kv-1M-Lve" id="Wgh-qo-MWk">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="right" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="r9e-gL-liU">
|
||||
<rect key="frame" x="487" y="5" width="105" height="38.5"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits" autocorrectionType="no" keyboardType="numberPad"/>
|
||||
</textField>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="map-7k-Ncg">
|
||||
<rect key="frame" x="15" y="0.0" width="570" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
</cells>
|
||||
</tableViewSection>
|
||||
</sections>
|
||||
</prototypes>
|
||||
<sections/>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="UN7-Sp-113" id="o6W-R0-C63"/>
|
||||
<outlet property="delegate" destination="UN7-Sp-113" id="Rga-Ke-onq"/>
|
||||
@ -96,7 +95,7 @@
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="ics-PY-I9c" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1097" y="2364"/>
|
||||
<point key="canvasLocation" x="670" y="2328"/>
|
||||
</scene>
|
||||
<!--SettingTBVC-->
|
||||
<scene sceneID="AlF-dM-FGj">
|
||||
@ -153,6 +152,7 @@
|
||||
<segue destination="cXQ-cR-uO9" kind="show" identifier="LibraryBackup" id="wMK-ai-X9p"/>
|
||||
<segue destination="EDV-vq-3pR" kind="show" identifier="SearchTune" id="fPh-da-uXe"/>
|
||||
<segue destination="lA5-ta-PUI" kind="show" identifier="SearchHistory" id="uJK-HK-z5P"/>
|
||||
<segue destination="UN7-Sp-113" kind="show" identifier="SettingWidgetBookmarksTBVC" id="K7x-tv-esq"/>
|
||||
</connections>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="h5i-dV-ulp" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
|
@ -121,6 +121,7 @@
|
||||
973DD4231D3443A3009D45DB /* ExtensionAndTypealias.swift in Sources */ = {isa = PBXBuildFile; fileRef = 973DD4221D3443A3009D45DB /* ExtensionAndTypealias.swift */; };
|
||||
973DD4251D344558009D45DB /* ScanLocalBookOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 973DD4241D344558009D45DB /* ScanLocalBookOperation.swift */; };
|
||||
973DD4281D36E3E4009D45DB /* SettingSingleSwitchTBVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 973DD4271D36E3E4009D45DB /* SettingSingleSwitchTBVC.swift */; };
|
||||
974F42821D47E19A00F8074C /* SettingWidgetBookmarksTBVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 974F42811D47E19A00F8074C /* SettingWidgetBookmarksTBVC.swift */; };
|
||||
975227821D020560001D1DDE /* Indexer.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 975227811D020560001D1DDE /* Indexer.storyboard */; };
|
||||
975227991D020C00001D1DDE /* indexer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 975227921D020C00001D1DDE /* indexer.cpp */; settings = {COMPILER_FLAGS = "-w"; }; };
|
||||
9752279B1D020C00001D1DDE /* otherTools.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 975227931D020C00001D1DDE /* otherTools.cpp */; };
|
||||
@ -379,6 +380,7 @@
|
||||
97497B5C1D074FB800ECD691 /* htmlparse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = htmlparse.h; path = "Kiwix/libkiwix/C&C++/xapian/htmlparse.h"; sourceTree = "<group>"; };
|
||||
97497B5D1D074FB800ECD691 /* myhtmlparse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = myhtmlparse.h; path = "Kiwix/libkiwix/C&C++/xapian/myhtmlparse.h"; sourceTree = "<group>"; };
|
||||
97497B5E1D07584100ECD691 /* xapianIndexer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = xapianIndexer.h; path = "Kiwix/libkiwix/C&C++/xapianIndexer.h"; sourceTree = "<group>"; };
|
||||
974F42811D47E19A00F8074C /* SettingWidgetBookmarksTBVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SettingWidgetBookmarksTBVC.swift; path = "Kiwix-iOS/Controller/Setting/SettingWidgetBookmarksTBVC.swift"; sourceTree = SOURCE_ROOT; };
|
||||
975227811D020560001D1DDE /* Indexer.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Indexer.storyboard; path = "Kiwix-OSX/StoryBoards/Indexer.storyboard"; sourceTree = SOURCE_ROOT; };
|
||||
975227921D020C00001D1DDE /* indexer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = indexer.cpp; path = "Kiwix/libkiwix/C&C++/indexer.cpp"; sourceTree = "<group>"; tabWidth = 2; };
|
||||
975227931D020C00001D1DDE /* otherTools.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = otherTools.cpp; path = "Kiwix/libkiwix/C&C++/otherTools.cpp"; sourceTree = "<group>"; };
|
||||
@ -824,6 +826,14 @@
|
||||
name = Bookmark;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
974F42801D47E15400F8074C /* Widget */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
974F42811D47E19A00F8074C /* SettingWidgetBookmarksTBVC.swift */,
|
||||
);
|
||||
name = Widget;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
975227A41D020C0F001D1DDE /* indexer */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -902,6 +912,7 @@
|
||||
97C01FCA1C39B7F100D010E5 /* Library */,
|
||||
97C01FD21C39BF4E00D010E5 /* Reading */,
|
||||
970E68B31D37E1E0001E8514 /* Search */,
|
||||
974F42801D47E15400F8074C /* Widget */,
|
||||
);
|
||||
name = Setting;
|
||||
sourceTree = "<group>";
|
||||
@ -1649,6 +1660,7 @@
|
||||
978C58981C1CD86E0077AE47 /* Book.swift in Sources */,
|
||||
978C58961C1CD86E0077AE47 /* Language.swift in Sources */,
|
||||
971A10701D022E62007FC62C /* Network.swift in Sources */,
|
||||
974F42821D47E19A00F8074C /* SettingWidgetBookmarksTBVC.swift in Sources */,
|
||||
970E68B21D37E1DD001E8514 /* SettingSearchTuneController.swift in Sources */,
|
||||
971A104A1D022CBE007FC62C /* SearchResultTBVC.swift in Sources */,
|
||||
971A105B1D022DAD007FC62C /* LibraryOnlineTBVC.swift in Sources */,
|
||||
|
Loading…
x
Reference in New Issue
Block a user