• Stars
    star
    110
  • Rank 316,770 (Top 7 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 12 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Create a Settings.bundle for your RubyMotion app

motion-settings-bundle

Create a Settings.bundle for your RubyMotion app. This allows your app to have a "global" settings entry in the Settings app.

Installation

Add this line to your application's Gemfile:

gem 'motion-settings-bundle'

And then execute:

bundle

Or install it yourself as:

gem install motion-settings-bundle

Usage

Add a chunk of code into your project's Rakefile like so:

require 'motion-settings-bundle'

Motion::SettingsBundle.setup do |app|
  # A text field. Allows configuration of a string.
  app.text "Name", key: "username", default: "Paul Atreides"
  app.text "E-mail", key: "email", keyboard: "EmailAddress", autocapitalization: "None"
  app.text "Password", key: "password", secure: true

  # A read-only text field. Use for showing a small chunk of text, maybe a version number
  app.title "Year of Birth", key: "yearOfBirth", default: "10,175 AG"

  # An on/off switch. Turn something on or off. Default is `false` (off).
  app.toggle "Kwisatz Haderach?", key: "superpowersEnabled", default: true

  # MultiValue, to choose from some item
  app.multivalue "Picture Resolution 1", key: "pictureResolution1", default: "1500", values: ["1500", "1200", "1000"]

  # MultiValue 2, with values and different titles (required when the values are numbers not string)
  app.multivalue "Picture Resolution 2", key: "pictureResolution2", default: 1500, values: [1500, 1200, 1000],
    titles: ["1500px", "1200px", "1000px"]

  # A slider, configure volume or something linear
  app.slider "Spice Level", key: "spiceLevel", default: 50, min: 1, max: 100

  # Child pane to display licenses in
  app.child "Acknowledgements" do |ack|
    ack.child "AwesomeOSSLibrary" do |lic|
      lic.group "Copyright 2013 AwesomeOSSContributor"
      lic.group "More license text that is terribly formatted but fulfills legal requirements"
    end
  end
end

Now just run rake as normal!

This should now add a Settings.bundle folder into your resources directory. Make sure to commit it! If you ever change the data in the Settings.setup block, it will be re-built on the next rake run. You'll end up with something like this:

screenshot1 of motion-settings-bundle screenshot2 of motion-settings-bundle screenshot3 of motion-settings-bundle

If you're wondering how to access this in code, it's pretty easy:

NSUserDefaults.standardUserDefaults["username"]
# returns "Paul Atreides"

And so on. Just remember, the defaults aren't populated until your user actually opens the Settings app, so make sure to handle all of your setting entries being nil.

TODO

This project really solely exists to avoid creating/editing the Settings.bundle in XCode. The specs for it so far have been based off mordaroso/rubymotion-settings-bundle. Please feel free to contribute more ways to generate settings!

  • Add a custom label, "Settings for Blah"
  • Don't re-create files every time
  • Slider default level doesn't seem to work yet

Contributing

I couldn't figure out how to test this automatically. Run bundle to get the gems you need, and then rake to generate a RubyMotion app in the iOS simulator, and then open the Settings app.

If you've added a setting it would be really nice if you could update screenshot.png as well!

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

MIT. See LICENSE.

More Repositories

1

sub

a delicious way to organize programs
Shell
1,744
star
2

unix

Mirror of the Restoration of 1st Edition UNIX kernel sources from pdf document.
C
791
star
3

m

A Test::Unit runner that can run tests by line number.
Ruby
377
star
4

motion-layout

A nice way to use iOS6+ autolayout in your RubyMotion app. Use ASCII-art inspired format strings to build your app's layout!
Ruby
215
star
5

hola

example gem repo
Ruby
124
star
6

gitready

learn git one commit at a time. updates weekly or when great tips are found
98
star
7

vim-fu

Combining the awesomeness of various vim plugins in one easy configurable unit.
Vim Script
38
star
8

shp

A new UI for git. This doesn't work yet.
Rust
28
star
9

pubsub

easy example of redis pubsub
Ruby
27
star
10

qrush.github.com

coding with spice
CSS
26
star
11

skyway

Official news, tour, stats and community site for Aqueous
Ruby
22
star
12

rebase

A weekly update about GitHub!
Ruby
15
star
13

react-native-wkwebview

WKWebView for React Native (+ a few nice things)
Objective-C
12
star
14

snake

A simple Snake game, written in Shoes.
Ruby
9
star
15

danger_danger

example rails 3.1.1 app using high_voltage for a static site
Ruby
9
star
16

gsay

SPEAK LIKE A GOOGLE ROBOT
Ruby
9
star
17

mon

A pokemon battle simulator
Ruby
7
star
18

kidsmash-mac

Kidsmash: 🍎
Swift
6
star
19

beardo

Co-ops are run by dirty hippies; dirty hippies have beards; therefore, this app is called beardo.
5
star
20

higo

go, on heroku!
Ruby
5
star
21

kidsmash

KID SMASH - JavaScript port of BabySmash for SE444
JavaScript
5
star
22

beesknees

a boggle clone && an experiment with redis
Ruby
4
star
23

dfat

DWARF FORTRESS ADVENTURE TIME
Ruby
4
star
24

gemwhisperer

THE GEM WHISPERER: HE SPEAKS TO GEMS
JavaScript
3
star
25

go

explorations into google's go
Go
3
star
26

archive

My twitter archive
JavaScript
3
star
27

nyruby

nyruby: the empire state's ruby group
Ruby
3
star
28

LookInside

An actual compiling sample code repo from WWDC 2014: A Look Inside Presentation Controllers
Objective-C
3
star
29

test-without-issues

2
star
30

wedding

JavaScript
2
star
31

mwnbot

Java
2
star
32

counter

a carcassonne counter
Ruby
2
star
33

df

dorf fortress.
2
star
34

ThreadMessages

Ruby
2
star
35

mwrc

sandbox/playground for my MWRC 2011 talk
Ruby
2
star
36

q-tracer

c# raytracer project for cg2
C#
1
star
37

arel-test

Ruby
1
star
38

gifs

CSS
1
star
39

ec2bootstrapper

git-svn clone of the C# EC2 bootstrapper from CodePlex
C#
1
star
40

q

Shell
1
star
41

nathanlanevsraptor

a tweetstream demo, made during BarCampBoston 6
JavaScript
1
star
42

historian-extension

1
star
43

aftest

Ruby
1
star
44

q-blizzard

another CG2 project, this time a c# particle system
C#
1
star
45

notvirus.news

CSS
1
star
46

cheeseburger

redis: data cheeseburgers!
Ruby
1
star
47

stupidrubytricks

WNYRuby December 2011 Talk
Ruby
1
star