Skip to content
This repository has been archived by the owner on Jun 12, 2020. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronhktan committed Feb 14, 2018
0 parents commit 59478a7
Show file tree
Hide file tree
Showing 12 changed files with 408 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Aaron Tan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Fitbit Pomodoro
A Pomodoro app for the Fitbit Ionic.
101 changes: 101 additions & 0 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

var document = _interopDefault(require('document'));
var haptics = require('haptics');

var backgroundRect = document.getElementById("backgroundRect");
var backgroundRectResting = document.getElementById("backgroundRectResting");
var backgroundRectLongResting = document.getElementById("backgroundRectLongResting");

var btnBR = document.getElementById("btn-br");
var stateText = document.getElementById("stateText");
var minuteText = document.getElementById("minuteText");
var unitText = document.getElementById("unitText");
var times = 0;

btnBR.onactivate = function (evt) {
btnBR.style.display = "none";
haptics.vibration.start("confirmation");
minuteText.text = "24:59";
unitText.style.display = "none";
backgroundRect.animate("disable");
setTimeout(function() {
startWorkTimer(times);
}, 300);
};

function startWorkTimer(times) {
stateText.text = "Get to work!";
backgroundRect.animate("enable");
var end = new Date(new Date().getTime() + 25 * 60000);
minuteText.text = "24:59";
var timer = setInterval(function () {
var now = new Date().getTime();
var distance = end - now;
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
minutes = (minutes < 10) ? ("0" + minutes) : minutes;
seconds = (seconds < 10) ? ("0" + seconds) : seconds;
minuteText.text = minutes + ":" + seconds;
if (distance < 1) {
clearInterval(timer);
haptics.vibration.start("ping");
backgroundRect.animate("disable");
times++;
if (times < 2) {
backgroundRectResting.animate("enable");
startShortBreakTimer(times);
} else {
times = 0;
backgroundRectLongResting.animate("enable");
startLongBreakTimer(times);
}
}
}, 1000);
};

function startShortBreakTimer(times) {
stateText.text = "Take a short break";
var end = new Date(new Date().getTime() + 5 * 60000);
minuteText.text = "04:59";
var timer = setInterval(function () {
var now = new Date().getTime();
var distance = end - now;
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
minutes = (minutes < 10) ? ("0" + minutes) : minutes;
seconds = (seconds < 10) ? ("0" + seconds) : seconds;
minuteText.text = minutes + ":" + seconds;
if (distance < 1) {
clearInterval(timer);
haptics.vibration.start("ping");
backgroundRectResting.animate("disable");
backgroundRect.animate("enable");
startWorkTimer(times);
}
}, 1000);
}

function startLongBreakTimer(times) {
stateText.text = "Take a long break";
var end = new Date(new Date().getTime() + 15 * 60000);
minuteText.text = "14:59";
var timer = setInterval(function () {
var now = new Date().getTime();
var distance = end - now;
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
minutes = (minutes < 10) ? ("0" + minutes) : minutes;
seconds = (seconds < 10) ? ("0" + seconds) : seconds;
minuteText.text = minutes + ":" + seconds;
if (distance < 1) {
clearInterval(timer);
haptics.vibration.start("ping");
backgroundRectLongResting.animate("disable");
backgroundRect.animate("enable");
startWorkTimer(times);
}
}, 1000);
}
1 change: 1 addition & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"appManifestVersion":1,"main":"app/index.js","svgMain":"resources/index.gui","svgWidgets":"resources/widgets.gui","appType":"app","i18n":{"en":{"name":"Tomatina"}},"buildId":"0x0730781e263c063b","uuid":"4c0f5346-6d11-4494-a04f-731b152e6c1e","name":"Tomatina","bundleDate":"2018-01-09T22:46:27.359Z","requestedPermissions":[],"wipeColor":"#f44336"}
33 changes: 33 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"fitbit": {
"appUUID": "55d5be9a-1571-4987-b5e7-cda00dc7d56b",
"appType": "app",
"appDisplayName": "Tomatina",
"iconFile": "resources/icon.png",
"wipeColor": "#f44336",
"requestedPermissions": [],
"i18n": {
"en": {
"name": "Tomatina"
},
"zh-cn": {
"name": "番茄工作计时器"
},
"zh-tw": {
"name": "番茄工作計時器"
},
"fr": {
"name": "Tomatina"
},
"es": {
"name": "Tomatina"
},
"ja": {
"name": "トマティーナ"
},
"ko": {
"name": "토마티나"
}
}
}
}
Binary file added resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
144 changes: 144 additions & 0 deletions resources/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 72 additions & 0 deletions resources/index.gui
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<svg>
<defs>
<symbol id="backgroundRect">
<gradientRect id="backgroundRect" class="draggable"
x="0" y="0"
width="348" height="250"
gradient-type="linear"
gradient-x1="0" gradient-y1="0"
gradient-x2="0" gradient-y2="125"
gradient-color1="tomato" gradient-color2="red"
opacity="1"
pointer-events="none">
<animate attributeName="width" begin="enable" from="0" to="348" dur="1500" final="keep"/>
<animate attributeName="width" begin="disable" from="348" to="-30" dur="0.3" final="keep"/>
</gradientRect>
</symbol>

<symbol id="backgroundRectResting">
<gradientRect id="backgroundRectResting"
x="0" y="0"
width="0" height="250"
gradient-type="linear"
gradient-x1="0" gradient-y1="0"
gradient-x2="0" gradient-y2="125"
gradient-color1="mediumseagreen" gradient-color2="seagreen"
opacity="1"
pointer-events="none">
<animate attributeName="width" begin="enable" from="0" to="348" dur="300" final="keep"/>
<animate attributeName="width" begin="disable" from="348" to="-30" dur="0.3" final="keep"/>
</gradientRect>
</symbol>

<symbol id="backgroundRectLongResting">
<gradientRect id="backgroundRectLongResting"
x="0" y="0"
width="0" height="250"
gradient-type="linear"
gradient-x1="0" gradient-y1="0"
gradient-x2="0" gradient-y2="125"
gradient-color1="royalblue" gradient-color2="steelblue"
opacity="1"
pointer-events="none">
<animate attributeName="width" begin="enable" from="0" to="348" dur="900" final="keep"/>
<animate attributeName="width" begin="disable" from="348" to="-30" dur="0.3" final="keep"/>
</gradientRect>
</symbol>
</defs>

<svg width="100%" height="100%">
<use id="backgroundRect" href="#backgroundRect" width="100%" height="100%" />
</svg>

<svg width="100%" height="100%">
<use id="backgroundRectResting" href="#backgroundRectResting" width="100%" height="100%"/>
</svg>

<svg width="100%" height="100%">
<use id="backgroundRectLongResting" href="#backgroundRectLongResting" width="100%" height="100%"/>
</svg>

<text id="stateText" class="stateText" x="6" y="100" pointer-events="none">Start a Pomodoro</text>
<text id="minuteText" class="minutesBigText draggable" x="6" y="230" width="100%" pointer-events="none">25 </text>
<text id="unitText" class="unitText" x="120" y="230" pointer-events="none">min</text>

<line x1="0" y1="50%" x2="100%" y2="50%" fill="white" stroke-width="2" />

<use id="btn-br" href="#combo-button-lower-right" fill="white">
<set href="combo-button-icon" attributeName="href" to="play.png"/>
<set href="combo-button-icon-press" attributeName="href" to="play_press.png"/>
<set href="combo-button-stroke" attributeName="display" to="inline"/>
</use>
</svg>
Binary file added resources/play.png.txi
Binary file not shown.
Binary file added resources/play_press.png.txi
Binary file not shown.
Loading

0 comments on commit 59478a7

Please sign in to comment.