Skip to content

Commit

Permalink
Merge pull request #3 from mmolotov/develop
Browse files Browse the repository at this point in the history
v 1.0.1
  • Loading branch information
mmolotov authored Sep 19, 2023
2 parents f1a6362 + 1e1840e commit 46c7c57
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 29 deletions.
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"appType": "app",
"version": {
"code": 1,
"name": "1.0.0"
"name": "1.0.1"
},
"icon": "icon.png",
"vender": "zepp",
Expand Down
4 changes: 2 additions & 2 deletions page/create_timer/create_timer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {push} from '@zos/router'
import {replace} from '@zos/router'

import {CONSTANTS, getText} from '../common'
import CreateNewTimerPage from './create_timer_template'
Expand All @@ -8,6 +8,6 @@ CreateNewTimerPage({
pageKey: 'create.timer',
confirmHandler: function (timer) {
getApp()._options.globalData.timerModel.timer = timer
push({url: CONSTANTS.pages.SELECT_INTERVAL})
replace({url: CONSTANTS.pages.SELECT_INTERVAL})
}
})
4 changes: 0 additions & 4 deletions page/create_timer/create_timer_template.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {back} from '@zos/router'
import {Vibrator, VIBRATOR_SCENE_SHORT_LIGHT} from '@zos/sensor'
import {localStorage} from '@zos/storage'
import {createWidget, deleteWidget, event, prop, widget} from '@zos/ui'
Expand All @@ -23,9 +22,6 @@ function CreateNewTimerPage(args) {

Page({
onInit() {
if (getApp()._options.globalData.openMain) {
back()
}
},
build() {
this.hh = localStorage.getItem(`${pageKey}.hh`) ? localStorage.getItem(`${pageKey}.hh`) : 0
Expand Down
10 changes: 6 additions & 4 deletions page/select_predefined/select_interval.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ const standardTimers = [
]

SelectPredefinedTimerPage({
header: getText(CONSTANTS.i18n.SELECT_INTERVAL_HEADER),
timersList: standardTimers,
addButtonLink: CONSTANTS.pages.CREATE_INTERVAL,
timerHandler: function (button) {
header: getText(CONSTANTS.i18n.SELECT_INTERVAL_HEADER),
timersList: standardTimers,
timerHandler: function (button) {
getApp()._options.globalData.timerModel.interval = button.getProperty(prop.DATASET).timer
replace({url: CONSTANTS.pages.TIMER_PROGRESS})
},
addButtonHandler: function () {
replace({url: CONSTANTS.pages.CREATE_INTERVAL})
}
})
6 changes: 2 additions & 4 deletions page/select_predefined/select_predefined_template.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {Vibrator, VIBRATOR_SCENE_SHORT_LIGHT} from '@zos/sensor'
import {createWidget, event, prop, widget} from '@zos/ui'
import {push} from '@zos/router'

import {CONSTANTS, getText} from '../common'
import {COMMON, SELECT_PREDEFINED} from '../style/style'
Expand All @@ -13,12 +12,11 @@ function SelectPredefinedTimerPage(args) {
addButtonStyle = COMMON.STANDARD_BOTTOM_BUTTON_STYLE(CONSTANTS.img.PLUS, CONSTANTS.img.PLUS_PRESSED),
timerHandler,
timersList,
addButtonLink
addButtonHandler
} = args

Page({
onInit() {
getApp()._options.globalData.openMain = false
},

build() {
Expand Down Expand Up @@ -60,7 +58,7 @@ function SelectPredefinedTimerPage(args) {
const addButton = createWidget(widget.BUTTON, addButtonStyle)
addButton.addEventListener(event.CLICK_DOWN, (e) => {
this.doVibro()
push({url: addButtonLink})
addButtonHandler()
})
}
})
Expand Down
10 changes: 6 additions & 4 deletions page/select_predefined/select_timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ const standardTimers = [
]

SelectPredefinedTimerPage({
header: getText(CONSTANTS.i18n.SELECT_TIMER_HEADER),
timersList: standardTimers,
addButtonLink: CONSTANTS.pages.CREATE_TIMER,
timerHandler: function (button) {
header: getText(CONSTANTS.i18n.SELECT_TIMER_HEADER),
timersList: standardTimers,
timerHandler: function (button) {
getApp()._options.globalData.timerModel.timer = button.getProperty(prop.DATASET).timer
push({url: CONSTANTS.pages.SELECT_INTERVAL})
},
addButtonHandler: function () {
push({url: CONSTANTS.pages.CREATE_TIMER})
}
})

18 changes: 8 additions & 10 deletions page/timer_progress/timer_progress.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {back} from '@zos/router'
import {createWidget, deleteWidget, prop, widget} from '@zos/ui'
import {Time, Vibrator, VIBRATOR_SCENE_TIMER} from '@zos/sensor'
import {Time, Vibrator, VIBRATOR_SCENE_DURATION_LONG, VIBRATOR_SCENE_SHORT_LIGHT, VIBRATOR_SCENE_TIMER} from '@zos/sensor'
import {pausePalmScreenOff, resetPalmScreenOff} from '@zos/display'

import {CONSTANTS, getText, zeroPad} from '../common'
Expand Down Expand Up @@ -59,7 +59,7 @@ Page({
this.startBlinkInterval()
this.createStopButton()
this.deleteAdditionalButtons()
this.doVibro()
this.doVibro(VIBRATOR_SCENE_TIMER)
} else {
this.notifyOnInterval(remainingSeconds)
}
Expand All @@ -82,7 +82,7 @@ Page({
if (this.lastReminder) {
const now = this.time.getTime()
if (now - this.lastReminder >= this.interval.valueSeconds * CONSTANTS.seconds.mili) {
this.doVibro()
this.doVibro(VIBRATOR_SCENE_DURATION_LONG)
this.switchTimerDisplayColor(true)
this.lastReminder = now
} else {
Expand Down Expand Up @@ -124,32 +124,30 @@ Page({
}
},

doVibro() {
doVibro(scene = VIBRATOR_SCENE_SHORT_LIGHT) {
this.vibro.stop()
this.vibro.setMode(VIBRATOR_SCENE_TIMER)
this.vibro.setMode(scene)
this.vibro.start()
},

createStopButton() {
return createWidget(widget.BUTTON,
COMMON.STANDARD_BOTTOM_BUTTON_STYLE_ACTION(CONSTANTS.img.STOP, CONSTANTS.img.STOP_PRESSED, (arg) => {
getApp()._options.globalData.openMain = true
back()
}))
},

createCancelButton() {
return createWidget(widget.BUTTON, TIMER_PROGRESS.CANCEL_BUTTON((arg) => {
this.doVibro()
getApp()._options.globalData.openMain = true
this.doVibro(VIBRATOR_SCENE_SHORT_LIGHT)
back()
}))
},

createPauseButton() {
return createWidget(widget.BUTTON,
TIMER_PROGRESS.PAUSE_RESUME_BUTTON(CONSTANTS.img.PAUSE, CONSTANTS.img.PAUSE_PRESSED, (button) => {
this.doVibro()
this.doVibro(VIBRATOR_SCENE_SHORT_LIGHT)
this.stopProcesses()
this.pause = this.time.getTime()
this.resumeButton = this.createResumeButton()
Expand All @@ -160,7 +158,7 @@ Page({
createResumeButton() {
return createWidget(widget.BUTTON,
TIMER_PROGRESS.PAUSE_RESUME_BUTTON(CONSTANTS.img.RESUME, CONSTANTS.img.RESUME_PRESSED, (button) => {
this.doVibro()
this.doVibro(VIBRATOR_SCENE_SHORT_LIGHT)
const pauseTime = this.time.getTime() - this.pause
this.end += pauseTime
this.lastReminder += pauseTime
Expand Down

0 comments on commit 46c7c57

Please sign in to comment.