better_toolbar 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +31 -6
- data/lib/better_toolbar/better_toolbar.rb +14 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2086594670a6ce1c7eda06198a5256b2ee7e0df4
|
4
|
+
data.tar.gz: 7861f94bbd8479fcbd33b4c639d512ada9adedec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 683365b451401de4057705b3d0c556e23f6d009596891e670305161b7219d6516bc9f989b4103e3525b33f9c6685f122663389b20b512c0fba04ab126d4d5e04
|
7
|
+
data.tar.gz: c009f94a248737b6d170113b29de8a565f07f7c840b155aa89e9038507f33db36569b44c72d79af1608b4a9458737590134b697f3282ab158a8217409557ed27
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# BetterToolbar
|
2
2
|
|
3
|
-
|
3
|
+
No Ruby developer likes all those crazy constants thay Apple makes us try and remember, and creating a toolbar is full of that, plus extra crazy stuff that is basically just left over from the history of iOS. BetterToolbar helps you create toolbars and toolbar items in a more Ruby-esque way.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,12 +18,37 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
In version 0.0.1, you can create a `UIBarButtonItem` using a nicer factory style (yes, factories make you think of Java, but the fact is factories are useful).
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
toolbar = UIToolbar.new
|
25
|
+
item = BetterToolbar::Item.create(title: "Item 1", target: the_target, action: 'method_on_the_target:')
|
26
|
+
toolbar.setItems([item], animated: false)
|
27
|
+
```
|
28
|
+
|
29
|
+
In later versions, the plan is to have a nicer factory for a whole toolbar, but this works well for now. A preview is it might look something like this though.
|
30
|
+
|
31
|
+
**NOT REAL CODE**
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
toolbar = BetterToolbar.create({
|
35
|
+
target: self,
|
36
|
+
items: [
|
37
|
+
{ title: "Item 1", action: "item_one_pressed:" },
|
38
|
+
{ image: "sun", action: "sun_pressed:" },
|
39
|
+
:flexible_space,
|
40
|
+
{ title: "Item 3", target: different_target, action: "some_action:" }
|
41
|
+
]
|
42
|
+
})
|
43
|
+
```
|
44
|
+
|
45
|
+
That looks much nicer than what it would usually take to make a toolbar, and that's where it would be nice to get to.
|
22
46
|
|
23
47
|
## Contributing
|
24
48
|
|
25
49
|
1. Fork it
|
26
50
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3.
|
28
|
-
4.
|
29
|
-
5.
|
51
|
+
3. Make sure your tests pass
|
52
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
53
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
54
|
+
6. Create new Pull Request
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module BetterToolbar
|
2
|
+
def self.create(options = {})
|
3
|
+
toolbar = UIToolbar.new
|
4
|
+
items = options.fetch(:items, []).map { |i| item_options_to_item(options.merge(i)) }
|
5
|
+
toolbar.setItems(items, animated: false)
|
6
|
+
toolbar
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def self.item_options_to_item(item_options)
|
12
|
+
Item.create(item_options)
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: better_toolbar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Dean Watson-Hamblin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -33,6 +33,7 @@ extra_rdoc_files: []
|
|
33
33
|
files:
|
34
34
|
- README.md
|
35
35
|
- lib/better_toolbar.rb
|
36
|
+
- lib/better_toolbar/better_toolbar.rb
|
36
37
|
- lib/better_toolbar/item.rb
|
37
38
|
homepage: https://github.com/FluffyJack/better_toolbar
|
38
39
|
licenses:
|