Last active
May 9, 2016 20:05
-
-
Save danielsiwiec/311fb3ffb54415670c7a0e5e0df160cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Toybox.Application as App; | |
using Toybox.WatchUi as Ui; | |
using Toybox.Graphics as Gfx; | |
class WaypointsApp extends App.AppBase { | |
function initialize() { | |
AppBase.initialize(); | |
} | |
function getInitialView() { | |
return [ new ScreenClearingView() ]; | |
} | |
} | |
class ScreenClearingView extends Ui.View { | |
function initialize() { | |
View.initialize(); | |
} | |
function onLayout(dc) { | |
Ui.pushView(new HashPicker(), null, Ui.SLIDE_DOWN); | |
} | |
} | |
class HashPicker extends Ui.Picker { | |
function initialize(){ | |
var title = new Ui.Text({:text=>"SAMPLE", :locX=>Ui.LAYOUT_HALIGN_CENTER, :locY=>Ui.LAYOUT_VALIGN_TOP, :color=>Gfx.COLOR_WHITE}); | |
Ui.Picker.initialize({:title => title,:pattern => createNumberPattern(4)}); | |
WatchUi.requestUpdate(); | |
} | |
function createNumberPattern(count) { | |
var digits = new [count]; | |
for (var i=0 ; i<count ; i+=1) { | |
digits[i] = new DigitFactory(); | |
} | |
return digits; | |
} | |
} | |
class DigitFactory extends Ui.PickerFactory { | |
hidden var mFormatString; | |
hidden var mFont; | |
function getIndex(value) { | |
var index = (value / mIncrement) - mStart; | |
return index; | |
} | |
function initialize() { | |
mFont = Gfx.FONT_NUMBER_HOT; | |
mFormatString = "%d"; | |
PickerFactory.initialize(); | |
} | |
function getDrawable(index, selected) { | |
return new Ui.Text( { :text=>getValue(index).format(mFormatString), :color=>Gfx.COLOR_WHITE, :font=> mFont, :locX =>Ui.LAYOUT_HALIGN_CENTER, :locY=>Ui.LAYOUT_VALIGN_CENTER } ); | |
} | |
function getValue(index) { | |
return index; | |
} | |
function getSize() { | |
return 10; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment