Commit 6342acd4 authored by Alexis Lecanu's avatar Alexis Lecanu

add button restart and continu

parent 7e753be2
<strings>
<string id="AppName">Timer</string>
<string id="Continu">Continuer</string>
<string id="Restart">Recommencer</string>
<string id="Start">Lancer</string>
<string id="Remove">Supprimer</string>
<string id="Rename">Renommer</string>
......
<strings>
<string id="AppName">Timer</string>
<string id="Continu">Continu</string>
<string id="Start">Start</string>
<string id="Restart">Restart</string>
<string id="Remove">Remove</string>
<string id="Rename">Rename</string>
<string id="Bip">Sound</string>
......
......@@ -33,13 +33,11 @@ class Element {
}
function getProperty(property){
System.print("getProperty "+property+ " "+beep+ " "+beep5s+ " "+vibrate);
if(property.equals("name")){
return name;
}else if(property.equals("time")){
return time;
}else if(property.equals("beep")){
System.print("cool");
return beep;
}else if(property.equals("beep5s")){
return beep5s;
......
......@@ -2,19 +2,11 @@ using Toybox.WatchUi as Ui;
class TimerDelegate extends Ui.BehaviorDelegate {
hidden var alarms;
hidden var bip;
hidden var bip5S;
hidden var vibrate;
hidden var data;
function initialize(data) {
BehaviorDelegate.initialize();
self.data=data;
alarms = Ui.loadResource(Rez.Strings.Alarms);
bip = Ui.loadResource(Rez.Strings.Bip);
bip5S = Ui.loadResource(Rez.Strings.Bip5s);
vibrate = Ui.loadResource(Rez.Strings.Vibrate);
models.get(data.name).setVisible(true);
}
......@@ -26,23 +18,7 @@ class TimerDelegate extends Ui.BehaviorDelegate {
}
function onMenu(){
var menuItems;
if(Attention has :playTone && Attention has :vibrate){
menuItems = new [3];
menuItems[0]=new StateMenuItem (:Beep,bip,data,"beep");
menuItems[1]=new StateMenuItem (:Beep5s,bip5S,data,"beep5s");
menuItems[2]=new StateMenuItem (:Vibrate,vibrate,data,"vibrate");
}else if(Attention has :playTone){
menuItems = new [2];
menuItems[0]=new StateMenuItem (:Beep,bip,data,"beep");
menuItems[1]=new StateMenuItem (:Beep5s,bip5S,data,"beep5s");
}else{
menuItems = new [1];
menuItems[0]=new StateMenuItem (:Vibrate,vibrate,data,"vibrate");
}
var menu = new Menu (menuItems, alarms);
var menu = new AlarmMenu (data);
Ui.pushView(menu,new AlarmMenuDelegate(menu) , Ui.SLIDE_RIGHT );
}
......
......@@ -20,15 +20,13 @@ class TimerModel{
}
function startTimer(){
if(status!=:Work){
counter = data.time;
status=:Work;
refreshTimer.stop();
displayTimer.stop();
refreshTimer.start(method(:refresh), 1000, true);
startBuzz();
Ui.requestUpdate();
}
counter = data.time;
status=:Work;
refreshTimer.stop();
displayTimer.stop();
refreshTimer.start(method(:refresh), 1000, true);
startBuzz();
Ui.requestUpdate();
}
function stopTimer(beep){
......
using Toybox.Application as App;
using Toybox.WatchUi as Ui;
class AlarmMenu extends Menu {
hidden var alarms;
hidden var bip;
hidden var bip5S;
hidden var vibrate;
function initialize (data) {
alarms = Ui.loadResource(Rez.Strings.Alarms);
bip = Ui.loadResource(Rez.Strings.Bip);
bip5S = Ui.loadResource(Rez.Strings.Bip5s);
vibrate = Ui.loadResource(Rez.Strings.Vibrate);
var menuItems = new [0];
if(Attention has :playTone){
menuItems.add(new StateMenuItem (:Beep,bip,data,"beep"));
menuItems.add(new StateMenuItem (:Beep5s,bip5S,data,"beep5s"));
}
if(Attention has :vibrate){
menuItems.add(new StateMenuItem (:Vibrate,vibrate,data,"vibrate"));
}
Menu.initialize (menuItems, alarms);
}
}
\ No newline at end of file
......@@ -16,11 +16,4 @@ class AlarmMenuDelegate extends MenuDelegate {
}
}
function onBack(){
if(model!=null){
Ui.popView (Ui.SLIDE_LEFT);
return true;
}
return false;
}
}
\ No newline at end of file
......@@ -4,14 +4,44 @@ using Toybox.WatchUi as Ui;
class ElementMenu extends Menu {
hidden var data;
hidden var start;
hidden var restart;
hidden var continu;
hidden var alarms;
hidden var remove;
hidden var rename;
function initialize (menuItems,data) {
function initialize (data) {
self.data=data;
continu = Ui.loadResource(Rez.Strings.Continu);
start = Ui.loadResource(Rez.Strings.Start);
restart = Ui.loadResource(Rez.Strings.Restart);
alarms = Ui.loadResource(Rez.Strings.Alarms);
remove = Ui.loadResource(Rez.Strings.Remove);
rename = Ui.loadResource(Rez.Strings.Rename);
var menuItems = new [0];
menuItems.add(new DataMenuItem (:Start,start, data));
menuItems.add(new TimeMenuItem (:Timer,data));
menuItems.add(new DataMenuItem (:Alarms,alarms,data));
menuItems.add(new DataMenuItem (:Remove,remove,data));
menuItems.add(new DataMenuItem (:Rename,rename,data));
Menu.initialize (menuItems, data.name);
}
function onShow() {
Menu.setTitle( data.name);
function onShow() {
if(models.hasKey(data.name) && models.get(data.name).status==:Work){
var menuItems = new [0];
menuItems.add(new DataMenuItem (:Continu,continu, data));
menuItems.add(new DataMenuItem (:Start,restart, data));
menuItems.add(new TimeMenuItem (:Timer,data));
menuItems.add(new DataMenuItem (:Alarms,alarms,data));
menuItems.add(new DataMenuItem (:Remove,remove,data));
menuItems.add(new DataMenuItem (:Rename,rename,data));
Menu.setMenuArray(menuItems);
}
Menu.setTitle(data.name);
Menu.onShow();
}
}
\ No newline at end of file
using Toybox.WatchUi as Ui;
class ElementMenuDelegate extends MenuDelegate {
hidden var alarms;
hidden var bip;
hidden var bip5S;
hidden var vibrate;
hidden var timer;
function initialize(menu) {
MenuDelegate.initialize(menu);
alarms = Ui.loadResource(Rez.Strings.Alarms);
bip = Ui.loadResource(Rez.Strings.Bip);
bip5S = Ui.loadResource(Rez.Strings.Bip5s);
vibrate = Ui.loadResource(Rez.Strings.Vibrate);
timer = Ui.loadResource(Rez.Strings.Timer);
}
function onMenuItem(item) {
if(item.id==:Start){
if(item.id==:Continu){
Ui.pushView(new TimerView(item.data), new TimerDelegate(item.data), Ui.SLIDE_IMMEDIATE );
}else if(item.id==:Start){
var model;
if(models.hasKey(item.data.name)){
model = models.get(item.data.name);
......@@ -27,8 +22,7 @@ class ElementMenuDelegate extends MenuDelegate {
}
model.startTimer();
Ui.pushView(new TimerView(item.data), new TimerDelegate(item.data), Ui.SLIDE_IMMEDIATE );
}
if(item.id ==:Timer){
}else if(item.id ==:Timer){
Ui.pushView(new TimePicker(timer,item.data), new TimePickerDelegate(item.data), Ui.SLIDE_IMMEDIATE);
}else if(item.id ==:Remove){
elements.remove(item.data);
......@@ -38,23 +32,7 @@ class ElementMenuDelegate extends MenuDelegate {
Ui.pushView(new Ui.TextPicker(item.data.name), new EditElementPicker(item.data), Ui.SLIDE_LEFT);
}
}else if ( item.id == :Alarms){
var menuItems;
if(Attention has :playTone && Attention has :vibrate){
menuItems = new [3];
menuItems[0]=new StateMenuItem (:Beep,bip,item.data,"beep");
menuItems[1]=new StateMenuItem (:Beep5s,bip5S,item.data,"beep5s");
menuItems[2]=new StateMenuItem (:Vibrate,vibrate,item.data,"vibrate");
}else if(Attention has :playTone){
menuItems = new [2];
menuItems[0]=new StateMenuItem (:Beep,bip,item.data,"beep");
menuItems[1]=new StateMenuItem (:Beep5s,bip5S,item.data,"beep5s");
}else{
menuItems = new [1];
menuItems[0]=new StateMenuItem (:Vibrate,vibrate,item.data,"vibrate");
}
var menu = new Menu (menuItems, alarms);
var menu = new AlarmMenu (item.data);
Ui.pushView(menu,new AlarmMenuDelegate(menu) , Ui.SLIDE_LEFT );
}
}
......
......@@ -2,17 +2,8 @@ using Toybox.WatchUi as Ui;
class HomeMenuDelegate extends MenuDelegate {
hidden var start;
hidden var alarms;
hidden var remove;
hidden var rename;
function initialize(menu) {
MenuDelegate.initialize(menu);
start = Ui.loadResource(Rez.Strings.Start);
alarms = Ui.loadResource(Rez.Strings.Alarms);
remove = Ui.loadResource(Rez.Strings.Remove);
rename = Ui.loadResource(Rez.Strings.Rename);
}
function onMenuItem(item) {
......@@ -21,15 +12,8 @@ class HomeMenuDelegate extends MenuDelegate {
Ui.pushView(new Ui.TextPicker(""), new AddElementPicker(), Ui.SLIDE_LEFT);
}
}else{
var menuItems = new [5];
menuItems[0]=new DataMenuItem (:Start,start, item.data);
menuItems[1]=new TimeMenuItem (:Timer,item.data);
menuItems[2]=new DataMenuItem (:Alarms,alarms,item.data);
menuItems[3]=new DataMenuItem (:Remove,remove,item.data);
menuItems[4]=new DataMenuItem (:Rename,rename,item.data);
var menu = new ElementMenu (menuItems, item.data);
Ui.pushView(menu,new ElementMenuDelegate(menu) , Ui.SLIDE_LEFT );
var menu = new ElementMenu (item.data);
Ui.pushView(menu,new ElementMenuDelegate(menu) , Ui.SLIDE_LEFT );
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment