Skip to content

Commit 8f74c31

Browse files
committed
app is now working with OmniMenu
1 parent 08e1846 commit 8f74c31

File tree

7 files changed

+31
-258
lines changed

7 files changed

+31
-258
lines changed

source/iHIIT.mc

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
using Toybox.Application as App;
22
using Toybox.System as Sys;
3+
using Toybox.WatchUi as Ui;
4+
import Toybox.Lang;
35

46
/**
57
* ENTRY POINT
68
*/
79
class iHIIT extends App.AppBase {
810
//@todo: Make sure to set this to false when creating a release
9-
private var debug_mode = false;
11+
private var debug_mode as Boolean = false;
1012

11-
protected var controller;
13+
// The controller
14+
protected var controller as $.iHIITController;
1215

1316
public function initialize() {
1417
AppBase.initialize();
@@ -17,31 +20,24 @@ class iHIIT extends App.AppBase {
1720

1821
// Return the initial view of your application here
1922
public function getInitialView() {
20-
//return [new SelectWorkoutView(), new SelectWorkoutDelegate()];
21-
22-
//TEMPORARY - SKIP workout selection
23-
controller.beginCurrentWorkout();
24-
return [new DoWorkoutView(), new DoWorkoutDelegate()];
25-
26-
//TEMPORARY - TEST OmniMenu
27-
//return controller.testOmniMenu();
23+
return controller.getInitialApplicationView();
2824
}
2925

3026
// Hook called on application start up
31-
public function onStart(state) {
27+
public function onStart(state) as Void {
3228
Sys.println("App:::START");
3329
}
3430

3531
// Hook called on application stop
36-
public function onStop(state) {
32+
public function onStop(state) as Void {
3733
Sys.println("App:::STOP");
3834
}
3935

4036
public function getController() as $.iHIITController {
4137
return controller;
4238
}
4339

44-
public function isDebugMode() {
40+
public function isDebugMode() as Boolean {
4541
return debug_mode;
4642
}
4743
}

source/iHIITController.mc

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ class iHIITController {
2222
finish_workout_option = 0;
2323
}
2424

25+
public function getInitialApplicationView() as [Ui.View, Ui.BehaviorDelegate] {
26+
return [new SelectWorkoutView(), new SelectWorkoutDelegate()];
27+
28+
//TEMPORARY - SKIP workout selection
29+
//initialize(1)
30+
//beginCurrentWorkout();
31+
//return [new DoWorkoutView(), new DoWorkoutDelegate()];
32+
33+
//TEMPORARY - TEST OmniMenu
34+
//return testOmniMenu();
35+
}
2536
/*
2637
* Start the selected workout
2738
*/
@@ -56,20 +67,20 @@ class iHIITController {
5667

5768
// Resume
5869
if (!currentWorkout.isTerminated()) {
59-
choices.put(0, {
70+
choices.put(choices.size(), {
6071
"label" => Ui.loadResource(Rez.Strings.finish_workout_prompt_resume),
6172
"callback" => method(:resumeWorkout),
6273
});
6374
}
6475

6576
// Save & Exit
66-
choices.put(1, {
77+
choices.put(choices.size(), {
6778
"label" => Ui.loadResource(Rez.Strings.finish_workout_prompt_save_and_exit),
6879
"callback" => method(:saveWorkout),
6980
});
7081

7182
// Discard and Exit
72-
choices.put(2, {
83+
choices.put(choices.size(), {
7384
"label" => Ui.loadResource(Rez.Strings.finish_workout_prompt_discard_and_exit),
7485
"callback" => method(:discardWorkout),
7586
});
@@ -82,7 +93,7 @@ class iHIITController {
8293
*/
8394
function resumeWorkout() {
8495
if (!currentWorkout.isPaused()) {
85-
Sys.println("Controller: RESUME REFUSED - Workout must be paused to be resumed");
96+
Sys.println("Controller: RESUME REFUSED - Workout is already ended.");
8697
return;
8798
}
8899

@@ -218,8 +229,8 @@ class iHIITController {
218229
// @TODO: REMOVE ME!
219230
// public function testOmniMenu() {
220231
// var choices = {
221-
// 0 => { "label" => "Choice #1", "callback" => method(:choiceOneAction) },
222-
// 1 => { "label" => "Choice #2", "callback" => method(:choiceTwoAction) },
232+
// 0 => { "label" => "Choice #1", "callback" => null },
233+
// 1 => { "label" => "Choice #2", "callback" => null },
223234
// 2 => { "label" => "Choice #3", "callback" => null },
224235
// 3 => { "label" => "Choice #4", "callback" => null },
225236
// 4 => { "label" => "Choice #5", "callback" => null },
@@ -228,14 +239,6 @@ class iHIITController {
228239
// return [new OmniMenuView(choices, 0), new OmniMenuDelegate(null)];
229240
// }
230241

231-
// public function choiceOneAction() {
232-
// Sys.println("Controller: Choice One Action!");
233-
// }
234-
235-
// public function choiceTwoAction() {
236-
// Sys.println("Controller: Choice Two Action!");
237-
// }
238-
239242
// Handle timing out after exit
240243
public function onExit() {
241244
Sys.exit();

source/view/discardConfirmation/discardConfirmationDelegate.mc

Lines changed: 0 additions & 58 deletions
This file was deleted.

source/view/discardConfirmation/discardConfirmationView.mc

Lines changed: 0 additions & 56 deletions
This file was deleted.

source/view/finishWorkout/finishWorkoutDelegate.mc

Lines changed: 0 additions & 67 deletions
This file was deleted.

source/view/finishWorkout/finishWorkoutView.mc

Lines changed: 0 additions & 48 deletions
This file was deleted.

source/view/omniMenu/omniMenuView.mc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class OmniMenuView extends Ui.View {
2626
}
2727

2828
public function onShow() {
29-
Sys.println("OmniMenu: Show");
29+
Sys.println("OmniMenu: Show (index: " + currentChoiceIndex + ")");
3030
ctrl.omniMenuChoices = defaultChoices;
3131
ctrl.omniMenuSelectedIndex = currentChoiceIndex;
3232
}
@@ -72,7 +72,10 @@ class OmniMenuView extends Ui.View {
7272
dc.setColor(Gfx.COLOR_DK_GRAY, Gfx.COLOR_TRANSPARENT);
7373
dc.drawText(width / 2, y, Gfx.FONT_SYSTEM_MEDIUM, txt, Gfx.TEXT_JUSTIFY_CENTER);
7474

75-
// View.onUpdate(dc);
75+
// Update current index stored in the controller in this instance
76+
// So next time the OnShow is called we can restore it (necessary for concatenated OmniMenu displays)
77+
currentChoiceIndex = ctrl.omniMenuSelectedIndex;
78+
7679
Sys.println("OmniMenu:::updated");
7780
}
7881

0 commit comments

Comments
 (0)