Strap Kit - Cross-Platform Tools for Wearable Developers
A cross platform development framework for wearables.
Use strapkit
to generate a new project with Strap Metrics built right in. More to follow.
Version
0.0.1
LICENSE
See LICENSE
Checking Dependencies
Strap Kit requires git, python, node, and npm at a minimum, and platform specific SDK's like Pebble and Android Wear to build for those platforms. To check your dependencies, you can run the command below (requires curl and bash). For a full run down of how to install the dependencies, go to the full developer docs.
$> curl http://check-config.straphq.com | bash
Installation
$> sudo npm install strapkit -g
Using the CLI
- Create your Strapkit project.
$> strapkit create TestProject
OR
$> strapkit create ./TestProject com.testproject TestProject
strapkit create
generates a starter app.js in ./TestProject/js. This is where you write your app using the API documentation below.
- Choose deployment platforms.
$> strapkit platform add pebble android-wear
OR, to add just one platform only, you may specify that platform by itself.
$> strapkit platform add pebble
Removing platforms is just as easy as adding them.
$> strapkit platform remove pebble
- Compile for all platforms.
$> strapkit build
OR, to compile for one platform only, you may specify just that platform.
$> strapkit build pebble
If you wish to forego using Strap kit to install your app, the compiled binary of your app is available in a "build" folder after running the Strap kit build command.
- Install to device.
# When not using pebble $> strapkit install # IP Required for pebble $> strapkit install Phones.IP.Goes.Here
Publish 'n' Profit!
Write your first cross platform app
Page
A Page is the container for all your app's UI. When you create a new page, you are bringing the user to a different set of looks and actions.
Example
var splashPage = StrapKitUI; var card = StrapKitUI; // Adds content to a PagesplashPage; // Tells your wearable app to show this pagesplashPage;
Initialize
var page = StrapKitUI;
OR
var page = StrapKitUI;var page = StrapKitUI;
Add View
page;
Show Page
page;
Card View
Card is a standard wearable UI component across all platforms. This UI component typically has a title and a body associated with it, and can be clickable. This must be added to a Page in order for the component to be shown.
Example
var card = StrapKitUI;myPage;
Initialize
var card = StrapKitUI;
Set On Click Function
card;
TextView
TextView is a standard wearable UI component across all platforms. This UI component can show text and a position of your your choosing.
Example
var textView = StrapKitUI;myPage;
Position
StrapKitUI;
ListView
ListView is a standard wearable UI competent across all platforms. This UI component will show a list of items defined by you. And Item will contain a title and a subtitle as strings. To make the app more interactive, you can attach an object to and Item as data.
Example
var menuItems = title: 'My Title 1' subtitle: 'My Subtitle 1' data: info: "My Info 1" title: 'My Title 2' subtitle: 'My Subtitle 2' data: info: "My Info 2" ; var resultsMenu = StrapKitUI; resultsMenu;
Set On Item Click
myList;
HttpClient
HttpClient allows you to access API clients outside of the wearable app.
Example
StrapKit;
Opts
StrapKit;
Strap Metrics
With StrapKit JS, adding Strap Metrics to your app is a breeze.
Initialize
Initializing Strap Metrics allows you to immediately get access to diagnostics and sensor data. You can then log events that are specific to your app.
var app_id = "8djanek08sdjk";StrapKitMetrics; // Metrics will start logging sensor data // Log an eventStrapKitMetrics; // Log an event with datavar myInfo = info: "This was easy";StrapKitMetrics;
Location
StrapKit JS can leverage native geolocation in Javascript to get the location of the device. A callback can be used to extract the position
from the successful function. The generic form of this method is:
navigator.geolocation.getCurrentPosition(success, failure, options);
Example
if (navigator && navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
console.log("Got geolocation!");
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
}, function() {
console.log("Failed to get geolocation!");
}, {
maximumAge: 50000,
timeout: 5000,
enableHighAccuracy: true
});
}