CosmicMind / Material

A UI/UX framework for creating beautiful applications.
http://cosmicmind.com
MIT License
11.98k stars 1.26k forks source link

Alert view #104

Closed kgDe35NjrC closed 8 years ago

kgDe35NjrC commented 8 years ago

What would be the best way to make a card-like alert view? Should I subclass CardView?

components_dialogs_content1

daniel-jonathan commented 8 years ago

In general subclassing MaterialKit components is not necessary. The easiest way would be to use a CardView and set the appropriate properties. Something like this:

let cardView: CardView = CardView() cardView.titleLabel = UILabel() cardView.titleLabel!.text = "Use Google's location service?" // ... add styling

cardView.detailLabel = UILabel() cardView.detailLabel!.text = "Let Google help ... running." // ... add styling

// make flat buttons (disagree, agree) cardView.rightButtons = [disagree, agree]

When you do the positioning, MaterialLayout would make this easy.

When you do the depth, probably looking for .Depth5 cardView.shadowDepth = .Depth5

daniel-jonathan commented 8 years ago

If you have any further questions, feel free to re-open or create a new ticket :)

kgDe35NjrC commented 8 years ago

How do I actually turn this cardview into an alert? Do I make a UILaertVieeController and set its view to the cardview?

kgDe35NjrC commented 8 years ago

Here's my current UIAlertController code:

        let alert = UIAlertController(title: title, message: message, preferredStyle: .Alert)
        let action = UIAlertAction(title: "Dismiss", style: .Default, handler: nil)
        alert.addAction(action)
        presentViewController(alert, animated: true, completion: nil)
daniel-jonathan commented 8 years ago

I haven’t played with what you are trying to do enough to have an accurate answer. Are you required to use an AlertView?


Daniel Dahan

M: +1 647.627.0770 Skype: djondahan

On Dec 20, 2015, at 12:01 AM, Paul Van Wieren notifications@github.com wrote:

Here's my current UIAlertController code:

    let alert = UIAlertController(title: title, message: message, preferredStyle: .Alert)
    let action = UIAlertAction(title: "Dismiss", style: .Default, handler: nil)
    alert.addAction(action)
    presentViewController(alert, animated: true, completion: nil)

— Reply to this email directly or view it on GitHub https://github.com/CosmicMind/MaterialKit/issues/104#issuecomment-166067423.

sohayb commented 8 years ago

Was going to open such a ticket. As you know, alerts are required in almost every app (logout prompts, single choice or multiple choice lists and so on) so it's great if you guys have that in mind

daniel-jonathan commented 8 years ago

I will put it in upcoming :)