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

Long title for alert buttons #121

Closed
sergeygarazha opened this issue Oct 5, 2018 · 2 comments
Closed

Long title for alert buttons #121

sergeygarazha opened this issue Oct 5, 2018 · 2 comments

Comments

@sergeygarazha
Copy link

When there is 2 buttons in alert, and button title too long, string doesn't wraps to new line. Even if numberOfLines set to 2 for EKProperty.LabelStyle.

var attributes = EKAttributes.centerFloat
attributes.displayDuration = .infinity
attributes.windowLevel = .alerts
attributes.entryBackground = .visualEffect(style: .dark)
attributes.screenInteraction = .dismiss
attributes.hapticFeedbackType = .warning
attributes.position = .center
attributes.roundCorners = .all(radius: 12)
attributes.border = .value(color: UIColor.spDarkGray, width: 2)
attributes.screenBackground = .color(color: UIColor.black.withAlphaComponent(0.45))
attributes.positionConstraints.maxSize = EKAttributes.PositionConstraints.Size(width: EKAttributes.PositionConstraints.Edge.offset(value: 65), height: EKAttributes.PositionConstraints.Edge.intrinsic)
attributes.shadow = .active(with: EKAttributes.Shadow.Value(color: .black, opacity: 0.7, radius: 15, offset: .zero))

let messageImage = EKProperty.ImageContent(imageName: "image")
let titleLabelStyle = EKProperty.LabelStyle(font: UIFont.bold(20), color: UIColor.white, alignment: NSTextAlignment.center, numberOfLines: 0)
let titleLabelContent = EKProperty.LabelContent(text: title, style: titleLabelStyle)
let descriptionLabelStyle = EKProperty.LabelStyle(font: UIFont.systemFont(ofSize: 15), color: UIColor.white, alignment: NSTextAlignment.center, numberOfLines: 0)
let descriptionLabelContent = EKProperty.LabelContent(text: message, style: descriptionLabelStyle)
let message = EKSimpleMessage(image: messageImage, title: titleLabelContent, description: descriptionLabelContent)


let buttonStyle = EKProperty.LabelStyle(font: UIFont.regular(fontSize), color: titleColor, alignment: NSTextAlignment.center, numberOfLines: 0)
let labelContent = EKProperty.LabelContent(text: "Long button title", style: buttonStyle)
let firstButton = EKProperty.ButtonContent(label: labelContent, backgroundColor: backgroundColor, highlightedBackgroundColor: highlightedColor) {
    SwiftEntryKit.dismiss()
    action()
}

let buttonStyle = EKProperty.LabelStyle(font: UIFont.regular(fontSize), color: titleColor, alignment: NSTextAlignment.center, numberOfLines: 0)
let labelContent = EKProperty.LabelContent(text: "Cancel", style: buttonStyle)
let secondButton = EKProperty.ButtonContent(label: labelContent, backgroundColor: backgroundColor, highlightedBackgroundColor: highlightedColor) {
    SwiftEntryKit.dismiss()
    action()
}

let buttons = EKProperty.ButtonBarContent(with: firstButton, secondButton, separatorColor: UIColor.lightGray, expandAnimatedly: true)

let alertMessage = EKAlertMessage(simpleMessage: message, imagePosition: .top, buttonBarContent: buttons)
let view = EKAlertMessageView(with: alertMessage)
SwiftEntryKit.display(entry: view, using: attributes)
  • Device: [iPhone X, iPhone 8]
  • iOS Version: [iOS 12]
  • Xcode Version [10.0]
  • Dependency Manager Version [CocoaPods 1.5.3]
  • SwiftEntryKit Release # [0.7.2]

fullsizeoutput_2050

@huri000
Copy link
Owner

huri000 commented Oct 10, 2018

@sergeygarazha, Sorry for the late response.
I'll do my best to get this issue and the bottom corners issue handled this week.

huri000 added a commit that referenced this issue Dec 8, 2018
Estimated each button height and set it considering the axis of the spread of button button bar content.
Allow to set minimum button height and edge inset for each button title label.
huri000 added a commit that referenced this issue Dec 8, 2018
Estimated each button height and set it considering the axis of the spread of button button bar content.
Allow to set minimum button height and edge inset for each button title label.
@huri000
Copy link
Owner

huri000 commented Dec 8, 2018

Sorry for the delay. Resolved in 0.8.6.
In any case, the button title must have a reasonable length of text for a button.
Cheers!
🎉

@huri000 huri000 closed this as completed Dec 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants