Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unwanted Results via PopMenuManager #19

Closed
CaliCastle opened this issue Nov 30, 2018 · 9 comments
Closed

Unwanted Results via PopMenuManager #19

CaliCastle opened this issue Nov 30, 2018 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@CaliCastle
Copy link
Owner

CaliCastle commented Nov 30, 2018

✍🏻 Issue Description

There will be some unwanted carryovers in a result of using the PopMenuManager to construct the menu

@CaliCastle CaliCastle self-assigned this Nov 30, 2018
@CaliCastle
Copy link
Owner Author

Quote from LouK in Slack discussion:

it seems that the selected state of an item persists across multiple presentations of a menu... is there a way to deselect a selected item, or to not have the selection latched when the menu is dismissed? Looked at the source but I don't see where the selection is maintained...it almost looks like the completion closure in actionSelected's UIView.animate is not executing.

using the manager... looks like this when presenting the menu after previously selecting the middle item:
image

@CaliCastle CaliCastle added the bug Something isn't working label Nov 30, 2018
@HackShitUp
Copy link

I'm seeing this issue and I thought it was an issue with how I programmed. But after reviewing the documentation countless times and viewing your examples, this bug is getting pretty annoying. Any updates?

@CaliCastle
Copy link
Owner Author

@HackShitUp sorry for the inconvenience it had caused you, yeah I am aware of this bug and there will be a patch for all of the issues by the end of month December, thank you for the support!

@CaliCastle
Copy link
Owner Author

CaliCastle commented Dec 12, 2018

@HackShitUp for now the easiest way as a workaround would be using the PopMenuViewController instance

@HackShitUp
Copy link

@CaliCastle Happy New Year (if you'are around the U.S. haha)! So I do use that in our application, but the issue still persists. Do you know why the carryovers occur? I can try and fix it myself if I can understand the problem

@CaliCastle
Copy link
Owner Author

@HackShitUp hi, happy New Years to you too!! Actually this fix is already completed in my local environment I just need to make some adjustments before releasing an update, it'll be sometime later this week, thanks for the support and using PopMenu, I appreciate it!

@CaliCastle CaliCastle pinned this issue Jan 3, 2019
@HackShitUp
Copy link

HackShitUp commented Jan 3, 2019 via email

CaliCastle added a commit that referenced this issue Jan 5, 2019
Fix #19 and prevent menu offscreen
@CaliCastle
Copy link
Owner Author

@HackShitUp fixed in v2.1.2

@CaliCastle CaliCastle unpinned this issue Jan 5, 2019
@HackShitUp
Copy link

HackShitUp commented Jan 13, 2019

@CaliCastle I still get this issue whenever I'm presenting it from a UICollectionViewCell.

// Unwrap the 'Capsule' PFObject
        guard capsule != nil else { return }
        
        // MARK: - UINotificationFeedbackGenerator
        let feedbackGenerator = UINotificationFeedbackGenerator()
        feedbackGenerator.notificationOccurred(.success)
        
        // MARK: - PopMenu
        let manager = PopMenuManager.default
        manager.popMenuAppearance.popMenuColor.backgroundColor = .solid(fill: .white)
        manager.popMenuAppearance.popMenuFont = UIFont.demibold(size: 14)
        manager.popMenuAppearance.popMenuCornerRadius = 16
        manager.popMenuAppearance.popMenuItemSeparator = .fill(.groupTableViewBackground, height: 1)
        manager.popMenuShouldDismissOnSelection = true
        
        // Unlock Capsule
        let unlockAction = PopMenuDefaultAction(title: "Unlock", image: UIImage(named: "Unlocked")!, color: UIColor.black) {
            (action: PopMenuAction) in
            // MARK: - PFObject(className: "Capsule")
            self.capsule["isPrivate"] = false
            self.capsule.saveInBackground(block: { (success: Bool, error: Error?) in
                if success {
                    // MARK: - CSAlertManager
                    CSAlertManager.shared.showAlertBanner(title: "βœ… Unlocked Album", color: UIColor.black.withAlphaComponent(0.80))
                    
                    DispatchQueue.main.async {
                        // Reset the lockButton
                        self.lockButton.setImage(nil, for: .normal)
                    }
                    
                    // MARK: - NotificationCenter
                    NotificationCenter.default.post(name: GalleryViewController.reloadCapsules, object: nil)
                    
                } else {
                    print(error?.localizedDescription as Any)
                    // MARK: - CSAlertManager
                    CSAlertManager.shared.showAlertBanner(title: "πŸ’© Couldn't Unlock Album", color: UIColor.black.withAlphaComponent(0.80))
                }
            })
        }
        
        // Lock Capsule
        let lockAction = PopMenuDefaultAction(title: "Lock", image: UIImage(named: "Locked")!, color: UIColor.black) {
            (action: PopMenuAction) in
            // MARK: - PFObject(className: "Capsule")
            self.capsule["isPrivate"] = true
            self.capsule.saveInBackground(block: { (success: Bool, error: Error?) in
                if success {
                    // MARK: - CSAlertManager
                    CSAlertManager.shared.showAlertBanner(title: "βœ… Locked Album", color: UIColor.black.withAlphaComponent(0.80))
                    
                    DispatchQueue.main.async {
                        // Reset the lockButton
                        self.lockButton.setImage(UIImage(named: "Locked"), for: .normal)
                        self.lockButton.addTarget(self, action: #selector(self.unlockCapsule(_:)), for: .touchUpInside)
                    }
                    
                    // MARK: - NotificationCenter
                    NotificationCenter.default.post(name: GalleryViewController.reloadCapsules, object: nil)
                    
                } else {
                    print(error?.localizedDescription as Any)
                    // MARK: - CSAlertManager
                    CSAlertManager.shared.showAlertBanner(title: "πŸ’© Couldn't Lock Album", color: UIColor.black.withAlphaComponent(0.80))
                }
            })
        }
        
        // Edit Capsule
        let editAction = PopMenuDefaultAction(title: "Edit Name", image: UIImage(named: "Pen")!, color: UIColor.black) {
            (action: PopMenuAction) in
            manager.popMenuDidDismiss = { didSelect in
                // MARK: - CSAlertManager
                CSAlertManager.shared.renameCapsule(self.capsule, completionHandler: { (object: PFObject, success: Bool) in
                    if success {
                        // MARK: - NotificationCenter
                        NotificationCenter.default.post(name: GalleryViewController.reloadCapsules, object: nil)
                    }
                })
            }
        }
        
        // Send Capsule
        let sendAction = PopMenuDefaultAction(title: "Send", image: UIImage(named: "TabChat")!, color: UIColor.black) {
            (action: PopMenuAction) in
            manager.popMenuDidDismiss = { didSelect in
                if didSelect == true {
                    
                    // MARK: - TagUsersViewController
                    let tagUsersVC = TagUsersViewController.init(delegate: self, type: .send, existingUsers: nil, object: self.capsule)
                    // MARK: - CSNavigationController
                    let csNavigationController = CSNavigationController.init(rootViewController: tagUsersVC, type: .pushPop)
                    csNavigationController.presentNavigationFrom(viewController: self.parentViewController!)
                }
            }
        }
        
        // Delete Capsule
        let leaveAction = PopMenuDefaultAction(title: "Leave Album", image: UIImage(named: "LeaveButton")!, color: UIColor.black) {
            (action: PopMenuAction) in
            manager.popMenuDidDismiss = { didSelect in
                if didSelect == true {
                    
                    // MARK: - UIAlertController
                    let alertController = UIAlertController.init(title: "Leave Album?", message: "Are you sure you would like to leave this album? Your friends would have to add you again to add moments to them.", preferredStyle: .actionSheet)
                    
                    // Leave Action
                    let leaveAction = UIAlertAction.init(title: "Leave Album", style: .destructive, handler: { (action: UIAlertAction) in
                        self.capsule.remove(PFUser.current()!.objectId!, forKey: "collaborators")
                        self.capsule.saveInBackground(block: { (success: Bool, error: Error?) in
                            if success {
                                
                                // Remove the 'Capsule' object id
                                PFUser.current()!.remove(self.capsule.objectId!, forKey: "autoSaveKeys")
                                PFUser.current()!.saveInBackground()
                                
                                // MARK: - CSAlertManager
                                CSAlertManager.shared.showAlertBanner(title: "😒 Sad to see you go...", color: UIColor.black.withAlphaComponent(0.80))
                                
                                // MARK: - NotificationCenter
                                NotificationCenter.default.post(name: GalleryViewController.reloadCapsules, object: nil)
                                
                            } else {
                                print(error?.localizedDescription as Any)
                                // MARK: - CSAlertManager
                                CSAlertManager.shared.showAlertBanner(title: "πŸ’© Couldn't Unlock Album", color: UIColor.black.withAlphaComponent(0.80))
                            }
                        })
                    })
                    
                    // Cancel Action
                    let cancelAction = UIAlertAction.init(title: "Cancel", style: .cancel, handler: { (action: UIAlertAction) in
                        alertController.dismiss(animated: true, completion: nil)
                    })
                    
                    alertController.addAction(leaveAction)
                    alertController.addAction(cancelAction)
                    self.parentViewController?.present(alertController, animated: true, completion: nil)
                }
            }
        }

        if capsule!.value(forKey: "isPrivate") as! Bool == false {
            //
            // Lock
            //
            manager.addAction(lockAction)
        } else {
            //
            // Unlock
            //
            manager.addAction(unlockAction)
        }
        manager.addAction(editAction)
        manager.addAction(sendAction)
        manager.addAction(leaveAction)
        manager.present(sourceView: self)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants