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

No Issue but Code Further optimization #10

Closed
imran87 opened this issue May 4, 2017 · 5 comments
Closed

No Issue but Code Further optimization #10

imran87 opened this issue May 4, 2017 · 5 comments

Comments

@imran87
Copy link

imran87 commented May 4, 2017

First of all well done a very good and complete written wrapper for UIAlert Controller. So my point is that when a user call action sheet on iPhone or iPad so your code should automattically set popover if device is a iPad so there is no need of user decision.

@sgr-ksmt
Copy link
Owner

sgr-ksmt commented May 6, 2017

@imran87 Thx for reporting issue.
But, popover's sourceView is automatically ignored in case of iPhone. So I think there is no need for the user to judge iPhone or iPad.
Just in case, I will add some implementations so that the application won't crash if popover's sourceView is not set.

This was referenced May 6, 2017
@imran87
Copy link
Author

imran87 commented May 6, 2017 via email

@sgr-ksmt
Copy link
Owner

sgr-ksmt commented May 7, 2017

@imran87

You can write code like below without checking device iPhone or iPad in universal app.
The reason why alertController.popoverPresentationController is nil in case of iPhone. So you may not separate code for popover(anchorView: button).

// it works both iPhone and iPad without checking.
Alertift.actionSheet(message: "Which food do you like?")
   .popover(anchorView: button) // iPhone: ignored internally, iPad: set anchorView to _alertController.popoverPresentationController
   .action(.default("🍣"))
   .action(.default("🍎"))
   .action(.default("🍖"))
   .action(.default("🍅"))
   .action(.cancel("None of them"))
   .finally { action, index in
       if action.style == .cancel {
           return
       }
       Alertift.alert(message: "\(index). \(action.title!)")
           .action(.default("OK"))
           .show()
   }
   .show()

No need if statement

// not good!
if iPhone {
    Alertift.actionSheet(message: "Which food do you like?")
        .action(...)
        .show()
} else {
    Alertift.actionSheet(message: "Which food do you like?")
        .popover(anchorView: button)
        .action(...)
        .show()   
}

👍 👍

@s2imon
Copy link

s2imon commented May 7, 2017

Hi there, I figured this might be the right place. Is there a way to also customise the color of the 2px line on the alert between the body text and the action text?
Giving the background black as a color makes the line disappear completely visually. :)

Thanks, I enjoy using this alert library. Very easy to use.

@imran87
Copy link
Author

imran87 commented May 7, 2017 via email

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

3 participants