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

EKAlertMessageView fail to layout all of the ButtonContents inside EKAlertMessage #41

Closed
Jimmy-Prime opened this issue Jun 6, 2018 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@Jimmy-Prime
Copy link

EKAlertMessageView works fine when there are only five ButtonContents, but it fails when there are more than five ButtonContents.

Here is a screenshot of the symptom
screen shot 2018-06-06 at 16 32 02

My environment:

  • Xcode 9.4
  • iPhone 8 Plus 11.4 simulator
  • SwiftEntryKit 0.3.1

Code generating the menu

    func showPopUpOfPost(_ post: Post) {
        var image = UIImage()
        let semaphore = DispatchSemaphore(value: 1)
        if let url = post.profileURL {
            KingfisherManager.shared.retrieveImage(with: url, options: nil, progressBlock: nil) { (retrieved, error, cacheType, url) in
                if retrieved != nil {
                    image = retrieved!
                }
                semaphore.signal()
            }
        }
        semaphore.wait()
        let imageContent = EKProperty.ImageContent(image: image, size: CGSize(width: 36, height: 36), contentMode: UIViewContentMode.scaleAspectFit, makeRound: true)

        let title = EKProperty.LabelContent(text: UserManager.getBy(id: post.creatorID)!.displayName, style: .init(font: UIFont.boldSystemFont(ofSize: 17), color: .white))

        let description = EKProperty.LabelContent(text: post.displayMessage, style: .init(font: UIFont.systemFont(ofSize: 17), color: .white))

        let simpleMessage = EKSimpleMessage(image: imageContent, title: title, description: description)

        let hashTagButton = buttonContent(text: "Add hashtag")
        let reactionButton = buttonContent(text: "Add reaction")
        let commentButton = buttonContent(text: "Add comment")
        let bookmarkButton = buttonContent(text: "Bookmark")
        let copyButton = buttonContent(text: "Copy message")
        let pinButton = buttonContent(text: "Pin message")

        let buttonsBarContent = EKProperty.ButtonBarContent(with: hashTagButton, reactionButton, commentButton, bookmarkButton, copyButton, pinButton, separatorColor: .black, expandAnimatedly: true)

        let alertMessage = EKAlertMessage(simpleMessage: simpleMessage, imagePosition: .left, buttonBarContent: buttonsBarContent)

        let contentView = EKAlertMessageView(with: alertMessage)

        SwiftEntryKit.display(entry: contentView, using: Utilities.longPressPostAttribute)
    }

    private func buttonContent(text: String) -> EKProperty.ButtonContent {
        let font = UIFont.systemFont(ofSize: 14)
        let labelStyle = EKProperty.LabelStyle(font: font, color: .white)
        let label = EKProperty.LabelContent(text: text, style: labelStyle)
        return EKProperty.ButtonContent(label: label, backgroundColor: .clear, highlightedBackgroundColor: .black) {
            SwiftEntryKit.dismiss()
        }
    }

The attributes

class Utilities: NSObject {
    class var longPressPostAttribute: EKAttributes {
        var attributes: EKAttributes
        attributes = .bottomToast
        attributes.hapticFeedbackType = .success
        attributes.screenInteraction = .dismiss
        attributes.entryInteraction = .absorbTouches
        attributes.scroll = .enabled(swipeable: true, pullbackAnimation: .jolt)
        attributes.screenBackground = .color(color: UIColor.black.withAlphaComponent(0.8))
        attributes.entryBackground = .color(color: .highlight)
        attributes.entranceAnimation = .init(
            translate: .init(duration: 0.2, spring: .init(damping: 1, initialVelocity: 0)),
            scale: .init(from: 0.6, to: 1, duration: 0.2),
            fade: .init(from: 0.8, to: 1, duration: 0.1))
        attributes.exitAnimation = .init(
            scale: .init(from: 1, to: 0.7, duration: 0.3),
            fade: .init(from: 1, to: 0, duration: 0.3))
        attributes.displayDuration = .infinity
        attributes.border = .value(color: .black, width: 1)
        let minEdge = min(UIScreen.main.bounds.size.width, UIScreen.main.bounds.size.height)
        attributes.positionConstraints.maxSize = .init(width: .constant(value: minEdge), height: .intrinsic)

        return attributes
    }
}

Thanks for this beautiful library!

@huri000
Copy link
Owner

huri000 commented Jun 6, 2018

Hi,
Thanks for reporting this issue. I'll check it in the next few days and update this thread.

@huri000 huri000 self-assigned this Jun 6, 2018
@huri000 huri000 added the bug Something isn't working label Jun 6, 2018
huri000 added a commit that referenced this issue Jun 6, 2018
@huri000
Copy link
Owner

huri000 commented Jun 6, 2018

The reported issue has been fixed in v0.3.2. Enjoy! 🎉

@huri000 huri000 closed this as completed Jun 6, 2018
@Jimmy-Prime
Copy link
Author

Thanks for this super fast response

huri000 added a commit that referenced this issue Jun 8, 2018
* master:
  Support multiple button (EKButtonBarView) as an entry.
  Bug Fix: EKAlertMessageView fail to layout all of the ButtonContents inside EKAlertMessage #41

# Conflicts:
#	README.md
#	SwiftEntryKit.podspec
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