mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-26 05:18:31 -04:00
bookmark Collection view
This commit is contained in:
parent
bb58f40e9b
commit
c0443cd506
21
Kiwix-iOS/Assets.xcassets/Dots.imageset/Contents.json
vendored
Normal file
21
Kiwix-iOS/Assets.xcassets/Dots.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "more-2.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
BIN
Kiwix-iOS/Assets.xcassets/Dots.imageset/more-2.png
vendored
Normal file
BIN
Kiwix-iOS/Assets.xcassets/Dots.imageset/more-2.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 479 B |
@ -32,6 +32,13 @@ class BookmarkCollectionController: UIViewController, UICollectionViewDataSource
|
||||
}
|
||||
}
|
||||
|
||||
let dateFormatter: DateFormatter = {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .medium
|
||||
formatter.timeStyle = .short
|
||||
return formatter
|
||||
}()
|
||||
|
||||
@IBAction func dismiss(_ sender: UIBarButtonItem) {
|
||||
dismiss(animated: true, completion: nil)
|
||||
}
|
||||
@ -80,6 +87,8 @@ class BookmarkCollectionController: UIViewController, UICollectionViewDataSource
|
||||
if let data = article.thumbImageData {
|
||||
cell.thumbImageView.image = UIImage(data: data)
|
||||
}
|
||||
cell.bookTitleLabel.text = article.book?.title
|
||||
if let date = article.bookmarkDate {cell.bookmarkDetailLabel.text = dateFormatter.string(from: date)}
|
||||
|
||||
return cell
|
||||
}
|
||||
@ -104,8 +113,7 @@ class BookmarkCollectionController: UIViewController, UICollectionViewDataSource
|
||||
let managedObjectContext = AppDelegate.persistentContainer.viewContext
|
||||
lazy var fetchedResultController: NSFetchedResultsController<Article> = {
|
||||
let fetchRequest = Article.fetchRequest()
|
||||
let titleDescriptor = NSSortDescriptor(key: "title", ascending: true)
|
||||
fetchRequest.sortDescriptors = [titleDescriptor]
|
||||
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "bookmarkDate", ascending: false)]
|
||||
var predicates = [NSPredicate]()
|
||||
predicates.append(NSPredicate(format: "isBookmarked = true"))
|
||||
if let book = self.book { predicates.append(NSPredicate(format: "book == %@", book)) }
|
||||
|
@ -203,6 +203,7 @@ extension MainController: ButtonDelegates {
|
||||
guard let url = webView.request?.url,
|
||||
let article = Article.fetch(url: url, context: context) else {return}
|
||||
article.isBookmarked = !article.isBookmarked
|
||||
if article.isBookmarked {article.bookmarkDate = Date()}
|
||||
|
||||
if context.hasChanges {try? context.save()}
|
||||
|
||||
|
@ -48,60 +48,75 @@
|
||||
<constraint firstAttribute="width" constant="32" id="aFo-L8-O71"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="justified" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LK0-aY-C9L">
|
||||
<rect key="frame" x="8" y="29" width="191" height="17"/>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="justified" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsLetterSpacingToFitWidth="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LK0-aY-C9L">
|
||||
<rect key="frame" x="8" y="31" width="191" height="17"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsLetterSpacingToFitWidth="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YA4-yb-hoI">
|
||||
<rect key="frame" x="8" y="8" width="191" height="21"/>
|
||||
<rect key="frame" x="8" y="9" width="191" height="21"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="21" id="ryf-C9-VVi"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="16"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="9EM-Do-qfE">
|
||||
<rect key="frame" x="8" y="123" width="191" height="2"/>
|
||||
<rect key="frame" x="8" y="121" width="191" height="2"/>
|
||||
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="2" id="y4a-qe-lIJ"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Alw-Di-WEl">
|
||||
<rect key="frame" x="48" y="126.99999999999999" width="31" height="14.666666666666643"/>
|
||||
<rect key="frame" x="47.999999999999993" y="129" width="35.333333333333321" height="17"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="HLG-V7-emv">
|
||||
<rect key="frame" x="173" y="132" width="26" height="26"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="26" id="gg4-Gh-ifO"/>
|
||||
<constraint firstAttribute="width" constant="26" id="iHJ-xq-kia"/>
|
||||
</constraints>
|
||||
<state key="normal" image="Dots"/>
|
||||
</button>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IJ9-eG-Llq">
|
||||
<rect key="frame" x="48" y="146.66666666666663" width="31" height="14.333333333333343"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="HLG-V7-emv">
|
||||
<rect key="frame" x="153" y="131" width="46" height="30"/>
|
||||
<state key="normal" title="Button"/>
|
||||
</button>
|
||||
</subviews>
|
||||
</view>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailingMargin" secondItem="9EM-Do-qfE" secondAttribute="trailing" id="0H3-5k-m0f"/>
|
||||
<constraint firstItem="LK0-aY-C9L" firstAttribute="top" secondItem="YA4-yb-hoI" secondAttribute="bottom" id="95I-Gx-tc1"/>
|
||||
<constraint firstItem="CQi-0M-O0e" firstAttribute="top" secondItem="9EM-Do-qfE" secondAttribute="bottom" constant="4" id="9jg-Ou-dzI"/>
|
||||
<constraint firstItem="LK0-aY-C9L" firstAttribute="top" secondItem="YA4-yb-hoI" secondAttribute="bottom" constant="1" id="95I-Gx-tc1"/>
|
||||
<constraint firstItem="CQi-0M-O0e" firstAttribute="top" secondItem="9EM-Do-qfE" secondAttribute="bottom" constant="6" id="9jg-Ou-dzI"/>
|
||||
<constraint firstItem="Alw-Di-WEl" firstAttribute="leading" secondItem="CQi-0M-O0e" secondAttribute="trailing" constant="8" id="Eoq-GI-7la"/>
|
||||
<constraint firstItem="Alw-Di-WEl" firstAttribute="top" secondItem="9EM-Do-qfE" secondAttribute="bottom" constant="2" id="GkX-zd-iqc"/>
|
||||
<constraint firstItem="Alw-Di-WEl" firstAttribute="top" secondItem="9EM-Do-qfE" secondAttribute="bottom" constant="6" id="GkX-zd-iqc"/>
|
||||
<constraint firstItem="9EM-Do-qfE" firstAttribute="top" relation="greaterThanOrEqual" secondItem="LK0-aY-C9L" secondAttribute="bottom" constant="4" id="Hju-Lg-iT1"/>
|
||||
<constraint firstItem="YA4-yb-hoI" firstAttribute="top" secondItem="lfi-9s-ZjZ" secondAttribute="topMargin" id="MCl-Il-92w"/>
|
||||
<constraint firstAttribute="bottomMargin" secondItem="HLG-V7-emv" secondAttribute="bottom" id="MLR-CH-oRZ"/>
|
||||
<constraint firstItem="YA4-yb-hoI" firstAttribute="top" secondItem="lfi-9s-ZjZ" secondAttribute="topMargin" constant="1" id="MCl-Il-92w"/>
|
||||
<constraint firstItem="LK0-aY-C9L" firstAttribute="trailing" secondItem="lfi-9s-ZjZ" secondAttribute="trailingMargin" id="Uyi-Wf-Cnt"/>
|
||||
<constraint firstAttribute="leadingMargin" secondItem="CQi-0M-O0e" secondAttribute="leading" id="ZX6-PL-WbD"/>
|
||||
<constraint firstAttribute="bottomMargin" secondItem="IJ9-eG-Llq" secondAttribute="bottom" id="cF2-DE-1ML"/>
|
||||
<constraint firstItem="YA4-yb-hoI" firstAttribute="trailing" secondItem="lfi-9s-ZjZ" secondAttribute="trailingMargin" id="hLA-Zn-QPh"/>
|
||||
<constraint firstItem="HLG-V7-emv" firstAttribute="centerY" secondItem="CQi-0M-O0e" secondAttribute="centerY" id="jfS-zk-Zag"/>
|
||||
<constraint firstAttribute="trailingMargin" secondItem="HLG-V7-emv" secondAttribute="trailing" id="lIe-ot-ssw"/>
|
||||
<constraint firstItem="YA4-yb-hoI" firstAttribute="leading" secondItem="lfi-9s-ZjZ" secondAttribute="leadingMargin" id="rW4-0u-SSB"/>
|
||||
<constraint firstItem="IJ9-eG-Llq" firstAttribute="leading" secondItem="CQi-0M-O0e" secondAttribute="trailing" constant="8" id="tyS-4B-ZFF"/>
|
||||
<constraint firstAttribute="bottomMargin" secondItem="CQi-0M-O0e" secondAttribute="bottom" id="v5E-tX-8bf"/>
|
||||
<constraint firstAttribute="leadingMargin" secondItem="9EM-Do-qfE" secondAttribute="leading" id="wFD-yH-9vp"/>
|
||||
<constraint firstItem="LK0-aY-C9L" firstAttribute="leading" secondItem="lfi-9s-ZjZ" secondAttribute="leadingMargin" id="zBD-zk-mO8"/>
|
||||
</constraints>
|
||||
<connections>
|
||||
<outlet property="bookTitleLabel" destination="Alw-Di-WEl" id="IeT-eI-4at"/>
|
||||
<outlet property="bookmarkDetailLabel" destination="IJ9-eG-Llq" id="yXc-Vr-xqQ"/>
|
||||
<outlet property="dividerView" destination="9EM-Do-qfE" id="2Wy-se-oIO"/>
|
||||
<outlet property="snippetLabel" destination="LK0-aY-C9L" id="kSC-vs-kOX"/>
|
||||
<outlet property="thumbImageView" destination="CQi-0M-O0e" id="CRV-Dt-GUf"/>
|
||||
<outlet property="titleLabel" destination="YA4-yb-hoI" id="aHl-Zv-pdt"/>
|
||||
@ -140,7 +155,7 @@
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="OOK-WC-dk5" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="5006" y="3267"/>
|
||||
<point key="canvasLocation" x="5005.7971014492759" y="3266.576086956522"/>
|
||||
</scene>
|
||||
<!--Bookmark Article Controller-->
|
||||
<scene sceneID="VN9-Ad-dWZ">
|
||||
@ -502,6 +517,7 @@
|
||||
<image name="BookmarkAdded" width="348" height="331"/>
|
||||
<image name="BookmarkRemoved" width="348" height="331"/>
|
||||
<image name="Cross" width="16" height="16"/>
|
||||
<image name="Dots" width="21" height="21"/>
|
||||
</resources>
|
||||
<inferredMetricsTieBreakers>
|
||||
<segue reference="ipW-qc-ph3"/>
|
||||
|
@ -120,6 +120,9 @@ class BookmarkCollectionCell: UICollectionViewCell {
|
||||
|
||||
thumbImageView.layer.cornerRadius = 4.0
|
||||
thumbImageView.clipsToBounds = true
|
||||
|
||||
dividerView.layer.cornerRadius = 1
|
||||
dividerView.layer.masksToBounds = true
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
@ -130,6 +133,9 @@ class BookmarkCollectionCell: UICollectionViewCell {
|
||||
@IBOutlet weak var thumbImageView: UIImageView!
|
||||
@IBOutlet weak var titleLabel: UILabel!
|
||||
@IBOutlet weak var snippetLabel: UILabel!
|
||||
@IBOutlet weak var dividerView: UIView!
|
||||
@IBOutlet weak var bookTitleLabel: UILabel!
|
||||
@IBOutlet weak var bookmarkDetailLabel: UILabel!
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user