diff --git a/Kiwix-iOS/Assets.xcassets/Main/Bookmark.imageset/star-3 copy.png b/Kiwix-iOS/Assets.xcassets/Main/Bookmark.imageset/star-3 copy.png new file mode 100644 index 00000000..e22bbafe Binary files /dev/null and b/Kiwix-iOS/Assets.xcassets/Main/Bookmark.imageset/star-3 copy.png differ diff --git a/Kiwix-iOS/Assets.xcassets/Main/Bookmark.imageset/star-3.png b/Kiwix-iOS/Assets.xcassets/Main/Bookmark.imageset/star-3.png index e22bbafe..eee0168f 100644 Binary files a/Kiwix-iOS/Assets.xcassets/Main/Bookmark.imageset/star-3.png and b/Kiwix-iOS/Assets.xcassets/Main/Bookmark.imageset/star-3.png differ diff --git a/Kiwix-iOS/Assets.xcassets/Main/BookmarkHighlighted.imageset/Contents.json b/Kiwix-iOS/Assets.xcassets/Main/BookmarkHighlighted.imageset/Contents.json index 309cb347..d725f785 100644 --- a/Kiwix-iOS/Assets.xcassets/Main/BookmarkHighlighted.imageset/Contents.json +++ b/Kiwix-iOS/Assets.xcassets/Main/BookmarkHighlighted.imageset/Contents.json @@ -10,7 +10,7 @@ }, { "idiom" : "universal", - "filename" : "stars64 copy 3.png", + "filename" : "star-3.png", "scale" : "3x" } ], diff --git a/Kiwix-iOS/Assets.xcassets/Main/BookmarkHighlighted.imageset/star-3.png b/Kiwix-iOS/Assets.xcassets/Main/BookmarkHighlighted.imageset/star-3.png new file mode 100644 index 00000000..c3312093 Binary files /dev/null and b/Kiwix-iOS/Assets.xcassets/Main/BookmarkHighlighted.imageset/star-3.png differ diff --git a/Kiwix-iOS/Assets.xcassets/Main/BookmarkHighlighted.imageset/stars64 copy 3.png b/Kiwix-iOS/Assets.xcassets/Main/BookmarkHighlighted.imageset/stars64 copy 3.png deleted file mode 100644 index b156f388..00000000 Binary files a/Kiwix-iOS/Assets.xcassets/Main/BookmarkHighlighted.imageset/stars64 copy 3.png and /dev/null differ diff --git a/Kiwix-iOS/Controller/Main/Buttons.swift b/Kiwix-iOS/Controller/Main/Buttons.swift index 3e857c49..4dae6b86 100644 --- a/Kiwix-iOS/Controller/Main/Buttons.swift +++ b/Kiwix-iOS/Controller/Main/Buttons.swift @@ -10,12 +10,12 @@ import UIKit class Buttons: LPTBarButtonItemDelegate { - private(set) lazy var back: UIBarButtonItem = LPTBarButtonItem(imageName: "LeftArrow", scale: 0.8, delegate: self) - private(set) lazy var forward: UIBarButtonItem = LPTBarButtonItem(imageName: "RightArrow", scale: 0.8, delegate: self) - private(set) lazy var toc: UIBarButtonItem = LPTBarButtonItem(imageName: "TableOfContent", scale: 0.8, delegate: self) - private(set) lazy var bookmark: UIBarButtonItem = LPTBarButtonItem(imageName: "Bookmark", scale: 0.9, delegate: self) - private(set) lazy var library: UIBarButtonItem = LPTBarButtonItem(imageName: "Library", delegate: self) - private(set) lazy var setting: UIBarButtonItem = LPTBarButtonItem(imageName: "Setting", delegate: self) + private(set) lazy var back: LPTBarButtonItem = LPTBarButtonItem(imageName: "LeftArrow", scale: 0.8, delegate: self) + private(set) lazy var forward: LPTBarButtonItem = LPTBarButtonItem(imageName: "RightArrow", scale: 0.8, delegate: self) + private(set) lazy var toc: LPTBarButtonItem = LPTBarButtonItem(imageName: "TableOfContent", scale: 0.8, delegate: self) + private(set) lazy var bookmark: LPTBarButtonItem = LPTBarButtonItem(imageName: "Bookmark", highlightedImageName: "BookmarkHighlighted", scale: 0.9, grayed: false, delegate: self) + private(set) lazy var library: LPTBarButtonItem = LPTBarButtonItem(imageName: "Library", delegate: self) + private(set) lazy var setting: LPTBarButtonItem = LPTBarButtonItem(imageName: "Setting", delegate: self) private(set) lazy var cancel: UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(tapped(button:))) diff --git a/Kiwix-iOS/Controller/Main/MainDelegates.swift b/Kiwix-iOS/Controller/Main/MainDelegates.swift index 449b7808..afda0c43 100644 --- a/Kiwix-iOS/Controller/Main/MainDelegates.swift +++ b/Kiwix-iOS/Controller/Main/MainDelegates.swift @@ -32,10 +32,15 @@ extension MainController: UIWebViewDelegate, SFSafariViewControllerDelegate { JS.preventDefaultLongTap(webView: webView) URLResponseCache.shared.stop() + guard let url = webView.request?.url, + let article = Article.fetch(url: url, context: AppDelegate.persistentContainer.viewContext) else {return} + buttons.back.tintColor = webView.canGoBack ? nil : UIColor.gray buttons.forward.tintColor = webView.canGoForward ? nil : UIColor.gray + buttons.bookmark.isHighlighted = article.isBookmarked guard let title = JS.getTitle(from: webView) else {return} + article.title = title searchBar.title = title } @@ -156,12 +161,13 @@ extension MainController: ButtonDelegates { } func didLongPressBookmarkButton() { - showBookmarkHUD() - guard let url = webView.request?.url, let article = Article.fetch(url: url, context: AppDelegate.persistentContainer.viewContext) else {return} - article.title = JS.getTitle(from: webView) + article.isBookmarked = !article.isBookmarked + showBookmarkHUD() + controllers.bookmarkHUD.bookmarkAdded = article.isBookmarked + buttons.bookmark.isHighlighted = article.isBookmarked } } diff --git a/Kiwix-iOS/Info.plist b/Kiwix-iOS/Info.plist index 131ff26f..4a4aab4b 100644 --- a/Kiwix-iOS/Info.plist +++ b/Kiwix-iOS/Info.plist @@ -49,7 +49,7 @@ CFBundleVersion - 1.8.3401 + 1.8.3419 ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS diff --git a/Kiwix-iOS/View/BarButtonItems.swift b/Kiwix-iOS/View/BarButtonItems.swift index 70e562ee..10d4fb99 100644 --- a/Kiwix-iOS/View/BarButtonItems.swift +++ b/Kiwix-iOS/View/BarButtonItems.swift @@ -15,17 +15,22 @@ class LPTBarButtonItem: UIBarButtonItem { scale: CGFloat = 1.0, grayed: Bool = true, delegate: LPTBarButtonItemDelegate? = nil) { - let image = UIImage(named: imageName)?.withRenderingMode(.alwaysTemplate) - let highlightedImage: UIImage? = { + var image = UIImage(named: imageName) + var highlightedImage: UIImage? = { guard let name = highlightedImageName else {return nil} - return UIImage(named: name)?.withRenderingMode(.alwaysTemplate) + return UIImage(named: name) }() + if grayed { + image = image?.withRenderingMode(.alwaysTemplate) + highlightedImage = highlightedImage?.withRenderingMode(.alwaysTemplate) + } + let imageView = UIImageView(image: image, highlightedImage: highlightedImage) imageView.contentMode = UIViewContentMode.scaleAspectFit imageView.frame = CGRect(x: 0, y: 0, width: 26, height: 26) - imageView.tintColor = grayed ? UIColor.gray : nil imageView.transform = CGAffineTransform(scaleX: scale, y: scale) + if grayed {imageView.tintColor = UIColor.gray} let containerView = UIView(frame: CGRect(x: 0, y: 0, width: 44, height: 30)) // on ipad may be 52, 44 is value on iP6s+, to be investigated imageView.center = containerView.center @@ -48,6 +53,12 @@ class LPTBarButtonItem: UIBarButtonItem { } } + var isHighlighted: Bool = false { + didSet { + imageView?.isHighlighted = isHighlighted + } + } + // MARK: - properties weak var delegate: LPTBarButtonItemDelegate? diff --git a/Kiwix-iOSWidgets/Bookmarks/Info.plist b/Kiwix-iOSWidgets/Bookmarks/Info.plist index 2ea4ebe5..ad1fb459 100644 --- a/Kiwix-iOSWidgets/Bookmarks/Info.plist +++ b/Kiwix-iOSWidgets/Bookmarks/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 1.8.3401 + 1.8.3419 NSExtension NSExtensionMainStoryboard