Code Monkey home page Code Monkey logo

jasonkneen.tiprefs's Introduction

TiPrefs

A module to help build preferences/settings pages quickly allowing you to add Switches, TextInputs etc.

TiPrefs

Currently supported : textinput, switch/bool, choice list - tested on iOS only.

Example:-

Add the module to your project

var prefs = require("tiprefs");

Initialise new preferences window

prefs.init("Settings");

Add a Switch (id is used for the key to save the setting, otherwise failsover to caption)

prefs.addSwitch({
	id : "save",
	caption : "Save on quit"
});

Add a Text input (caption is used as the key as no ID specified)

prefs.addTextInput({
	caption : "username",
	value : "myuser"
});

Add a choice list

prefs.addChoice({
	id : "day_of_week",
	caption : "Day of Week",
	choices : [
			  {title : 'Every Monday',value : 1}, 
			  {title : 'Every Tuesday',value : 2}, 
			  {title : 'Every Wednesday',value : 3}, 
			  {title : 'Every Thursday',value : 4}, 
			  {title : 'Every Friday',value : 5}, 
			  {title : 'Every Saturday',value : 6}, 
			  {title : 'Every Sunday',value : 7}
			  ]
});

Render it (and it'll create a navigation group container)

prefs.open();

or specify a tabGroup and it'll use that

prefs.open(tabGroup);

You can also add sections

prefs.init("Settings");

	prefs.addSection({
    	title: "Section"
	});

prefs.addSwitch({
    	id: "SAVE_ON_QUIT",
    	caption: "Alarm"
	});

prefs.addSection({
        title: "T10 Accounts"
});

prefs.addTextInput({
        id: "USERNAME",
        caption: "username",
        value: "Anonymous"
});

prefs.closeSection();

prefs.open();

You can retrieve values using the standard Ti properties based on the format

name + "_" + id / caption
name + "_" + id / caption + "_" + value


Ti.App.Properties.getBool("Settings_save");

or for the choice list above

Ti.App.Properties.getBool("Settings_day_of_week_1");

This is WORK IN PROGRESS!

jasonkneen.tiprefs's People

Contributors

jasonkneen avatar stereoket avatar

Watchers

Brenton House avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.