mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-22 02:52:39 -04:00
Bookmark edit
This commit is contained in:
parent
d62e53cdd6
commit
0d6498fa3e
Binary file not shown.
Before Width: | Height: | Size: 1015 B |
@ -10,7 +10,7 @@
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "multimedia.png",
|
||||
"filename" : "star.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
BIN
Kiwix-iOS/Assets.xcassets/StarRemoved.imageset/star.png
vendored
Normal file
BIN
Kiwix-iOS/Assets.xcassets/StarRemoved.imageset/star.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
@ -18,6 +18,7 @@ class BookmarkTBVC: UITableViewController, NSFetchedResultsControllerDelegate, D
|
||||
title = LocalizedStrings.bookmarks
|
||||
tableView.estimatedRowHeight = 66.0
|
||||
tableView.rowHeight = UITableViewAutomaticDimension
|
||||
tableView.allowsMultipleSelectionDuringEditing = true
|
||||
|
||||
tableView.emptyDataSetSource = self
|
||||
tableView.emptyDataSetDelegate = self
|
||||
@ -29,6 +30,13 @@ class BookmarkTBVC: UITableViewController, NSFetchedResultsControllerDelegate, D
|
||||
|
||||
override func viewWillDisappear(animated: Bool) {
|
||||
super.viewWillDisappear(animated)
|
||||
setEditing(false, animated: false)
|
||||
}
|
||||
|
||||
override func setEditing(editing: Bool, animated: Bool) {
|
||||
super.setEditing(editing, animated: animated)
|
||||
tableView.setEditing(editing, animated: animated)
|
||||
navigationController?.setToolbarHidden(!editing, animated: animated)
|
||||
}
|
||||
|
||||
// MARK: - Empty table datasource & delegate
|
||||
@ -111,6 +119,7 @@ class BookmarkTBVC: UITableViewController, NSFetchedResultsControllerDelegate, D
|
||||
// MARK: - Table view delegate
|
||||
|
||||
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
|
||||
guard !tableView.editing else {return}
|
||||
defer {dismissViewControllerAnimated(true, completion: nil)}
|
||||
guard let navigationController = navigationController?.presentingViewController as? UINavigationController else {return}
|
||||
guard let mainVC = navigationController.topViewController as? MainController else {return}
|
||||
@ -118,6 +127,23 @@ class BookmarkTBVC: UITableViewController, NSFetchedResultsControllerDelegate, D
|
||||
mainVC.load(article.url)
|
||||
}
|
||||
|
||||
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {}
|
||||
|
||||
override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
|
||||
let remove = UITableViewRowAction(style: .Destructive, title: LocalizedStrings.remove) { (action, indexPath) -> Void in
|
||||
guard let article = self.fetchedResultController.objectAtIndexPath(indexPath) as? Article else {return}
|
||||
let context = NSManagedObjectContext.mainQueueContext
|
||||
context.performBlockAndWait({ () -> Void in
|
||||
context.deleteObject(article)
|
||||
})
|
||||
}
|
||||
return [remove]
|
||||
}
|
||||
|
||||
// MARK: - Fetched Result Controller Delegate
|
||||
|
||||
let managedObjectContext = UIApplication.appDelegate.managedObjectContext
|
||||
@ -175,6 +201,23 @@ class BookmarkTBVC: UITableViewController, NSFetchedResultsControllerDelegate, D
|
||||
|
||||
// MARK: - Action
|
||||
|
||||
@IBAction func editingButtonTapped(sender: UIBarButtonItem) {
|
||||
setEditing(!editing, animated: true)
|
||||
}
|
||||
|
||||
@IBAction func removeBookmarkButtonTapped(sender: UIBarButtonItem) {
|
||||
guard editing else {return}
|
||||
guard let selectedIndexPathes = tableView.indexPathsForSelectedRows else {return}
|
||||
let artiicles = selectedIndexPathes.flatMap() {fetchedResultController.objectAtIndexPath($0) as? Article}
|
||||
let context = NSManagedObjectContext.mainQueueContext
|
||||
context.performBlock {
|
||||
artiicles.forEach() {
|
||||
$0.isBookmarked = false
|
||||
$0.bookmarkDate = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func dismissButtonTapped(sender: UIBarButtonItem) {
|
||||
dismissViewControllerAnimated(true, completion: nil)
|
||||
}
|
||||
|
@ -36,7 +36,7 @@
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.7.284</string>
|
||||
<string>1.7.300</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
|
@ -30,13 +30,13 @@
|
||||
<constraint firstAttribute="height" constant="22" id="jS6-tO-mfx"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fG8-KY-O8H">
|
||||
<rect key="frame" x="66" y="36" width="526" height="19.5"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="a8w-h5-qXQ">
|
||||
@ -78,7 +78,7 @@
|
||||
<constraint firstAttribute="height" constant="22" id="J7B-2l-svg"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="l55-kI-Ig5">
|
||||
@ -87,7 +87,7 @@
|
||||
<constraint firstAttribute="height" constant="19.5" id="H4O-Fl-fMr"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="fjC-I2-EvF">
|
||||
@ -100,7 +100,7 @@
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="justified" lineBreakMode="tailTruncation" numberOfLines="4" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wb6-do-Jvs">
|
||||
<rect key="frame" x="8" y="66" width="584" height="74.5"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleCaption2"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
@ -138,12 +138,25 @@
|
||||
<outlet property="delegate" destination="FmQ-kS-9xq" id="Ge9-9m-6Uz"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
<toolbarItems>
|
||||
<barButtonItem style="plain" systemItem="flexibleSpace" id="Z1G-0A-26t"/>
|
||||
<barButtonItem image="StarRemoved" id="j6g-X2-Pte">
|
||||
<connections>
|
||||
<action selector="removeBookmarkButtonTapped:" destination="FmQ-kS-9xq" id="Ssy-s0-9my"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
</toolbarItems>
|
||||
<navigationItem key="navigationItem" id="Mu9-Fa-bI7">
|
||||
<barButtonItem key="leftBarButtonItem" image="DownArrow" id="gcp-jo-kFP">
|
||||
<connections>
|
||||
<action selector="dismissButtonTapped:" destination="FmQ-kS-9xq" id="E2b-fg-15n"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
<barButtonItem key="rightBarButtonItem" systemItem="edit" id="o5l-d8-2hL">
|
||||
<connections>
|
||||
<action selector="editingButtonTapped:" destination="FmQ-kS-9xq" id="3tT-Df-zmE"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
</navigationItem>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="cYS-sb-0qX" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
@ -487,13 +500,17 @@
|
||||
<!--Navigation Controller-->
|
||||
<scene sceneID="TmE-cH-Z0r">
|
||||
<objects>
|
||||
<navigationController storyboardIdentifier="BookmarkNav" automaticallyAdjustsScrollViewInsets="NO" id="7So-3x-feX" sceneMemberID="viewController">
|
||||
<navigationController storyboardIdentifier="BookmarkNav" automaticallyAdjustsScrollViewInsets="NO" toolbarHidden="NO" id="7So-3x-feX" sceneMemberID="viewController">
|
||||
<toolbarItems/>
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" id="liO-Vk-25p">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
<nil name="viewControllers"/>
|
||||
<toolbar key="toolbar" opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="lf3-4t-a4k">
|
||||
<rect key="frame" x="0.0" y="556" width="600" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</toolbar>
|
||||
<connections>
|
||||
<segue destination="FmQ-kS-9xq" kind="relationship" relationship="rootViewController" id="aTC-tp-9EX"/>
|
||||
</connections>
|
||||
@ -623,5 +640,6 @@
|
||||
<image name="BookmarkAdded" width="348" height="331"/>
|
||||
<image name="BookmarkRemoved" width="348" height="331"/>
|
||||
<image name="DownArrow" width="21" height="21"/>
|
||||
<image name="StarRemoved" width="21" height="21"/>
|
||||
</resources>
|
||||
</document>
|
||||
|
Loading…
x
Reference in New Issue
Block a user