Archived
1
Fork 0

Fix context menus and fix window titles not being updated

This commit is contained in:
redstrate 2020-05-24 23:51:08 -04:00
parent 50ec9aeb1b
commit b610f02f2e
7 changed files with 24 additions and 12 deletions

View file

@ -65,10 +65,10 @@
</subviews> </subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints> <constraints>
<constraint firstItem="nHo-hC-uT9" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" constant="25" id="715-Gf-Neb"/> <constraint firstItem="nHo-hC-uT9" firstAttribute="bottom" secondItem="6Tk-OE-BBY" secondAttribute="bottom" id="4rZ-Za-ukx"/>
<constraint firstItem="nHo-hC-uT9" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" id="PKo-Re-WQy"/> <constraint firstItem="nHo-hC-uT9" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="9Yp-CZ-4Ox"/>
<constraint firstItem="nHo-hC-uT9" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="UdF-XX-6F1"/> <constraint firstItem="nHo-hC-uT9" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" id="Cl4-QI-W1y"/>
<constraint firstItem="nHo-hC-uT9" firstAttribute="trailing" secondItem="8bC-Xf-vdC" secondAttribute="trailingMargin" constant="20" id="ZpI-FT-bld"/> <constraint firstItem="nHo-hC-uT9" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" id="p1V-UB-9bB"/>
</constraints> </constraints>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/> <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view> </view>
@ -254,7 +254,7 @@
<!--Post Info View Controller--> <!--Post Info View Controller-->
<scene sceneID="w3u-pt-BtZ"> <scene sceneID="w3u-pt-BtZ">
<objects> <objects>
<viewController storyboardIdentifier="InfoViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="MaR-nc-wxI" customClass="PostInfoViewController" customModule="Gallery" customModuleProvider="target" sceneMemberID="viewController"> <viewController storyboardIdentifier="PostInfoViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="MaR-nc-wxI" customClass="PostInfoViewController" customModule="Gallery" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="VFL-0t-HSi"> <view key="view" contentMode="scaleToFill" id="VFL-0t-HSi">
<rect key="frame" x="0.0" y="0.0" width="320" height="493"/> <rect key="frame" x="0.0" y="0.0" width="320" height="493"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>

View file

@ -61,7 +61,13 @@ class HomeViewController: UIViewController, UIDocumentPickerDelegate {
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
collectionManager = PostsManager(collectionView: collectionView, tag: tags) collectionManager = PostsManager(viewController: self, collectionView: collectionView, tag: tags)
updateWindowTitle()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
updateWindowTitle() updateWindowTitle()
} }

View file

@ -67,6 +67,12 @@ class PostDetailViewController: UIViewController, UIPopoverPresentationControlle
updateWindowTitle() updateWindowTitle()
} }
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
updateWindowTitle()
}
@objc func closePopup() { @objc func closePopup() {
UIApplication.shared.requestSceneSessionDestruction((self.view.window?.windowScene!.session)!, options: nil, errorHandler: nil) UIApplication.shared.requestSceneSessionDestruction((self.view.window?.windowScene!.session)!, options: nil, errorHandler: nil)
} }

View file

@ -59,6 +59,6 @@ class PostInfoViewController: UIViewController {
extension PostInfoViewController { extension PostInfoViewController {
static func loadFromStoryboard() -> PostInfoViewController? { static func loadFromStoryboard() -> PostInfoViewController? {
let storyboard = UIStoryboard(name: "Main", bundle: .main) let storyboard = UIStoryboard(name: "Main", bundle: .main)
return storyboard.instantiateViewController(withIdentifier: "InfoViewController") as? PostInfoViewController return storyboard.instantiateViewController(withIdentifier: "PostInfoViewController") as? PostInfoViewController
} }
} }

View file

@ -47,13 +47,12 @@ func generateThumbnail(path: URL) -> UIImage? {
} }
class PostsManager: NSObject, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UICollectionViewDropDelegate, UICollectionViewDragDelegate { class PostsManager: NSObject, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UICollectionViewDropDelegate, UICollectionViewDragDelegate {
var viewController: UIViewController?
var collectionView : UICollectionView? var collectionView : UICollectionView?
var managedContext: NSManagedObjectContext? var managedContext: NSManagedObjectContext?
var posts: [NSManagedObject] = [] var posts: [NSManagedObject] = []
weak var viewController: UIViewController?
private let itemsPerRow: CGFloat = 4 private let itemsPerRow: CGFloat = 4
private let sectionInsets = UIEdgeInsets(top: 10.0, private let sectionInsets = UIEdgeInsets(top: 10.0,
@ -92,9 +91,10 @@ class PostsManager: NSObject, UICollectionViewDataSource, UICollectionViewDelega
return cell return cell
} }
init(collectionView: UICollectionView, tag: String?) { init(viewController: UIViewController, collectionView: UICollectionView, tag: String?) {
super.init() super.init()
self.viewController = viewController
self.collectionView = collectionView self.collectionView = collectionView
collectionView.dragInteractionEnabled = true collectionView.dragInteractionEnabled = true

View file

@ -11,7 +11,7 @@ class SearchViewController: UIViewController {
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
postManager = PostsManager(collectionView: collectionView, tag: nil) postManager = PostsManager(viewController: self, collectionView: collectionView, tag: nil)
} }
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

View file

@ -11,7 +11,7 @@ class TagPreviewViewController: UIViewController {
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
collectionManager = PostsManager(collectionView: collectionView, tag: nil) collectionManager = PostsManager(viewController: self, collectionView: collectionView, tag: nil)
} }
override func viewDidAppear(_ animated: Bool) { override func viewDidAppear(_ animated: Bool) {