mirror of
https://github.com/zhigang1992/redpotion.git
synced 2026-05-29 00:00:56 +08:00
Added RedAlert and docs.
This commit is contained in:
7
Gemfile
7
Gemfile
@@ -1,5 +1,6 @@
|
||||
source 'https://rubygems.org'
|
||||
source "https://rubygems.org"
|
||||
|
||||
gemspec
|
||||
gem 'motion-cocoapods'
|
||||
gem 'cdq'
|
||||
gem "motion-cocoapods"
|
||||
gem "cdq"
|
||||
gem "RedAlert"
|
||||
|
||||
@@ -3,6 +3,7 @@ PATH
|
||||
specs:
|
||||
redpotion (1.1.1)
|
||||
ProMotion (~> 2.3)
|
||||
RedAlert
|
||||
motion-cocoapods
|
||||
motion_print
|
||||
rake
|
||||
@@ -13,6 +14,8 @@ GEM
|
||||
specs:
|
||||
ProMotion (2.3.0)
|
||||
methadone (~> 1.7)
|
||||
RedAlert (0.3)
|
||||
ruby_motion_query (>= 1.2.0)
|
||||
activesupport (3.2.21)
|
||||
i18n (~> 0.6, >= 0.6.4)
|
||||
multi_json (~> 1.0)
|
||||
@@ -77,6 +80,7 @@ PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
RedAlert
|
||||
cdq
|
||||
motion-cocoapods
|
||||
redpotion!
|
||||
|
||||
85
docs/cookbook/alerts_and_action_sheets.md
Normal file
85
docs/cookbook/alerts_and_action_sheets.md
Normal file
@@ -0,0 +1,85 @@
|
||||
<img src="./_art/screen.png" alt="Screen Shot" width="500" />
|
||||
|
||||
**Did you know that UIAlertView and UIActionSheet (as well as their respective delegate protocols) are deprecated in iOS 8?**
|
||||
|
||||
Apple requests you start using the new `UIAlertController`. RedPotion supports for antiquated `UIAlertView`s for the gnostalgic.
|
||||
|
||||
## Usage
|
||||
|
||||
```ruby
|
||||
|
||||
# Simply do an alert
|
||||
app.alert("Minimal Alert")
|
||||
|
||||
# Alert with callback
|
||||
app.alert("Alert with Block") {
|
||||
puts "Alert with Block worked!"
|
||||
}
|
||||
|
||||
# Modify some snazzy options
|
||||
app.alert(title: "New Title", message: "Great message", animated: false)
|
||||
|
||||
# Switch it to look like an ActionSheet by setting the style
|
||||
app.alert(title: "Hey there!", message: "My style is :sheet", style: :sheet) do |action_type|
|
||||
puts "You clicked #{action_type}"
|
||||
end
|
||||
|
||||
# Utilize common templates
|
||||
app.alert(message: "Would you like a sandwich?", actions: :yes_no_cancel, style: :sheet) do |action_type|
|
||||
case action_type
|
||||
when :yes
|
||||
puts "Here's your Sandwich!"
|
||||
when :no
|
||||
puts "FINE!"
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
You can even use the `make_button` helper to create custom UIAction buttons to add:
|
||||
```ruby
|
||||
# Use custom UIAction buttons and add them
|
||||
taco = app.make_button("Taco") {
|
||||
puts "Taco pressed"
|
||||
}
|
||||
nacho = app.make_button(title: "Nacho", style: :destructive) {
|
||||
puts "Nacho pressed"
|
||||
}
|
||||
button_list = [taco, nacho]
|
||||
app.alert(title: "Actions!", message: "Actions created with `make_button` helper.", actions: button_list)
|
||||
```
|
||||
|
||||
## Available Templates
|
||||
|
||||
Templates are provided [HERE](https://github.com/GantMan/RedAlert/blob/master/lib/project/button_templates.rb)
|
||||
* `:yes_no` = Simple yes and no buttons.
|
||||
* `:yes_no_cancel` = Yes/no buttons with a separated cancel button.
|
||||
* `:ok_cancel` = OK button with a separated cancel button.
|
||||
* `:delete_cancel` = Delete button (red) with a separated cancel button.
|
||||
|
||||
_More to come:_ be sure to submit a pull-request with your button template needs.
|
||||
|
||||
## More info
|
||||
|
||||
Feel free to read up on UIAlertController to see what all is wrapped up in this gem.
|
||||
* [Hayageek](http://hayageek.com/uialertcontroller-example-ios/)
|
||||
* [NSHipster](http://nshipster.com/uialertcontroller/)
|
||||
|
||||
## Classic UIAlertView Helpers
|
||||
|
||||
If you'd like to still support pre-iOS8, you can easily use `app.alert_view` with a similar syntax, and instead of actions you'll used the predefined delegates.
|
||||
|
||||
**`UIAlertView` Classic:**
|
||||
```ruby
|
||||
# support the elderly
|
||||
app.alert_view("Hey look at this old trick")
|
||||
|
||||
# Still feels like magic!
|
||||
app.alert_view({
|
||||
title: "Hey There",
|
||||
message: "Check out this complex alert!",
|
||||
cancel_button: 'Nevermind',
|
||||
other_buttons: ['Log In'],
|
||||
delegate: nil,
|
||||
view_style: UIAlertViewStyleLoginAndPasswordInput
|
||||
})
|
||||
```
|
||||
@@ -26,7 +26,8 @@ pages:
|
||||
- [cookbook/attributes.md, Cookbook, "Updating data or attributes"]
|
||||
- [cookbook/tagging.md, Cookbook, "Tagging views"]
|
||||
- [cookbook/format.md, Cookbook, "Formatting numbers and dates"]
|
||||
- [cookbook/core_data.md, Cookbook, "Using a local database"]
|
||||
- [cookbook/alerts_and_action_sheets.md, Cookbook, "Alerts and ActionSheets"]
|
||||
- [cookbook/core_data.md, Cookbook, "Using a local database. Core Data"]
|
||||
- [cookbook/timers.md, Cookbook, "Timers and delays. Do something every second"]
|
||||
- [cookbook/networking.md, Cookbook, "Networking, JSON, remote images"]
|
||||
- [cookbook/validations.md, Cookbook, "Validating data, text, text boxes, etc"]
|
||||
|
||||
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
|
||||
spec.add_runtime_dependency "ProMotion", "~> 2.3"
|
||||
spec.add_runtime_dependency "motion_print"
|
||||
spec.add_runtime_dependency "motion-cocoapods"
|
||||
spec.add_runtime_dependency "RedAlert"
|
||||
spec.add_runtime_dependency "rake"
|
||||
spec.add_development_dependency "webstub"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user