Skip to content

Commit

Permalink
Merge pull request #5 from mmolotov/develop
Browse files Browse the repository at this point in the history
v 2.0.0
  • Loading branch information
mmolotov authored Dec 20, 2024
2 parents 46c7c57 + fded74f commit f8933c0
Show file tree
Hide file tree
Showing 40 changed files with 1,028 additions and 896 deletions.
12 changes: 3 additions & 9 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { TimerModel } from "./page/common"

App({
globalData: {
},
globalData: {},
onCreate(options) {
console.log('app on create invoke')
this.globalData.timerModel = new TimerModel()
},

onDestroy(options) {
console.log('app on destroy invoke')
}
})
},
});
23 changes: 12 additions & 11 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"configVersion": "v2",
"configVersion": "v3",
"app": {
"appId": 1032854,
"appName": "Timerr",
"appType": "app",
"version": {
"code": 1,
"name": "1.0.1"
"code": 2,
"name": "2.0.0"
},
"icon": "icon.png",
"vender": "zepp",
Expand All @@ -18,21 +18,22 @@
],
"runtime": {
"apiVersion": {
"compatible": "2.0.0",
"target": "2.0.0",
"minVersion": "2.0.0"
"compatible": "3.0.0",
"target": "3.0.0",
"minVersion": "3.0"
}
},
"debug": false,
"targets": {
"trex": {
"module": {
"page": {
"pages": [
"page/select_predefined/select_timer",
"page/select_predefined/select_interval",
"page/timer_progress/timer_progress",
"page/create_timer/create_timer",
"page/create_timer/create_interval"
"page/devices/trex/selection_pages/select_timer.page",
"page/devices/trex/selection_pages/select_interval.page",
"page/devices/trex/creation_pages/create_timer.page",
"page/devices/trex/creation_pages/create_interval.page",
"page/devices/trex/timer_progress/timer_progress.page"
]
}
},
Expand Down
Empty file added assets/gt/.gitkeep
Empty file.
Binary file removed assets/trex/gradient_w_1.png
Binary file not shown.
Binary file removed assets/trex/gradient_w_1_debug.png
Binary file not shown.
Binary file removed assets/trex/gradient_w_2.png
Binary file not shown.
Binary file removed assets/trex/gradient_w_2_debug.png
Binary file not shown.
2 changes: 1 addition & 1 deletion global.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/// <reference path="node_modules/@zeppos/device-types/index.d.ts" />
/// <reference path="node_modules/@zeppos/device-types/dist/index.d.ts" />
4 changes: 2 additions & 2 deletions jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"**/node_modules/*"
],
"files": [
"node_modules/@zeppos/device-types/index.d.ts"
"node_modules/@zeppos/device-types/dist/index.d.ts"
]
}
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "empty",
"name": "timerr",
"version": "1.0.0",
"description": "",
"main": "app.js",
Expand All @@ -9,6 +9,9 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@zeppos/device-types": "^2.0.0"
"@zeppos/device-types": "^3.0.0"
},
"dependencies": {
"@zeppos/zml": "^0.0.9"
}
}
91 changes: 0 additions & 91 deletions page/common.js

This file was deleted.

65 changes: 65 additions & 0 deletions page/common/common.layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import {getDeviceInfo} from '@zos/device'
import {align, text_style} from '@zos/ui'
import {getText} from '@zos/i18n';

export const {width: DEVICE_WIDTH, height: DEVICE_HEIGHT} = getDeviceInfo()

export const COLORS = {
// see https://www.figma.com/design/bY5cr0QN41npTOTO642Did/Zepp-OS-3.0-Library-Circular-(Community)?node-id=31-3&node-type=canvas
SYS: {
BUTTON: 0x515151,
BUTTON_PRESSED: 0x313131,
BUTTON_HIGHLIGHT: 0x0986D4,
BUTTON_HIGHLIGHT_PRESSED: 0x234F7C,
HIGHLIGHT: 0x0986D4,
HIGHLIGHT_DISABLED: 0x10283F,
PAGE_BACKGROUND: 0x000000
},
TEXT: {
BUTTON: 0xFFFFFF,
LINK: 0x059AF7,
TITLE: 0xFFFFFF,
WARNING: 0xD14221,
SUBTITLE: 0xB2B2B2
},
SECONDARY: {
_01: 0x03B5AA,
_02: 0x7B9E89,
_03: 0x399E5A,
_18: 0xAA2F2F,
_20: 0x9B3642
}
}

// STYLES
export const PAGE_HEADERS = {
HEADER_STYLE(pageName) {
return {
color: COLORS.TEXT.TITLE,
align_h: align.CENTER_H,
align_v: align.CENTER_V,
text_style: text_style.NONE,
text: getText(pageName)
}
}
}

export const BUTTONS = {
STANDARD_BOTTOM_BUTTON_STYLE(src, pressedSrc) {
return {
x: 0,
normal_src: src,
press_src: pressedSrc
}
},
STANDARD_BOTTOM_BUTTON_STYLE_WITH_HANDLER(src, pressedSrc, handler) {
return {
x: 0,
normal_src: src,
press_src: pressedSrc,
click_func: (button) => {
handler(button)
}
}
}
}
137 changes: 137 additions & 0 deletions page/common/creation_pages/create_timer.page.template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import {createWidget, widget} from '@zos/ui'
import {formatNumberForPicker} from '../../../utils';
import {getText} from '@zos/i18n';
import {CONSTANTS} from '../../constants/constants';
import {log as Logger} from '@zos/utils';
import {TimeSpan} from '../../data/models'
import {LocalStorage} from '@zos/storage'

let hh = 0
let mm = 0
let ss = 0
const logger = Logger.getLogger('timerr');
const storage = new LocalStorage()

function CreationPage(args) {
const {
//data
storageKey,
pageName,
nextPageUrl,

//style
headerStyle,
containerStyle,

//handlers
nextPageRoutingFunction
} = args

Page({
onInit() {
},
build() {
this.initValues()
let viewContainer = createWidget(widget.VIEW_CONTAINER, containerStyle)
this.renderTimerDisplay(viewContainer)
this.renderHeader(viewContainer);
},
onDestroy() {
},
initValues() {
hh = storage.getItem(`${pageName}.hh`, 0) ?? 0
mm = storage.getItem(`${pageName}.mm`, 0) ?? 0
ss = storage.getItem(`${pageName}.ss`, 0) ?? 0
logger.debug('initial picker values:',
` ${pageName}.hh: `, hh,
` ${pageName}.mm: `, mm,
` ${pageName}.ss: `, ss)
},
renderTimerDisplay(viewContainer) {
this.selectTime(viewContainer)
},
renderHeader(viewContainer) {
viewContainer.createWidget(widget.TEXT, headerStyle)
createWidget(widget.TEXT, headerStyle)
},
selectTime(viewContainer) {
viewContainer.createWidget(widget.WIDGET_PICKER, {
title: '',
nb_of_columns: 3,
init_col_index: 2,
data_config: [
{
data_array: new Array(24).fill(0).map((d, index) => formatNumberForPicker(index)),
support_loop: true,
init_val_index: hh,
connector: ':',
unit: getText(CONSTANTS.i18n.UNIT_HOUR)
},
{
data_array: new Array(60).fill(0).map((d, index) => formatNumberForPicker(index)),
support_loop: false,
init_val_index: mm,
connector: ':',
unit: getText(CONSTANTS.i18n.UNIT_MINUTE)
},
{
data_array: new Array(60).fill(0).map((d, index) => formatNumberForPicker(index)),
support_loop: false,
init_val_index: ss,
unit: getText(CONSTANTS.i18n.UNIT_SECOND)
}
],
picker_cb: this.pickerCallback
});
},
pickerCallback(picker, event_type, column, valueIndex) {
function collectTimeSpans() {
let hourSec = new TimeSpan(getNumber(hh), CONSTANTS.timeUnits.HOUR).valueSeconds
let minSec = new TimeSpan(getNumber(mm), CONSTANTS.timeUnits.MIN).valueSeconds
let sec = new TimeSpan(getNumber(ss), CONSTANTS.timeUnits.SEC).valueSeconds
return new TimeSpan(sec + minSec + hourSec, CONSTANTS.timeUnits.SEC)
}

function getNumber(value) {
return (typeof value === 'number') ? value : 0;
}

function putInLocalStorage(storage, pageName, hh, mm, ss) {
logger.debug('save picker values:',
` ${pageName}.hh: `, hh,
` ${pageName}.mm: `, mm,
` ${pageName}.ss: `, ss)
storage.setItem(`${pageName}.hh`, hh)
storage.setItem(`${pageName}.mm`, mm)
storage.setItem(`${pageName}.ss`, ss)
}

function savePikerValues(timeSpan) {
// remember selected picker values for future
putInLocalStorage(storage, pageName, hh, mm, ss)
logger.debug('select ' + storageKey + ' : ' + timeSpan.valueSeconds)
getApp()._options.globalData[storageKey] = timeSpan
}

if (event_type === 1) {
switch (column) {
case 0:
hh = valueIndex
break;
case 1:
mm = valueIndex
break;
case 2:
ss = valueIndex
break;
}
} else if (event_type === 2) {
let timeSpan = collectTimeSpans();
savePikerValues(timeSpan)
nextPageRoutingFunction({url: nextPageUrl})
}
}
})
}

export default CreationPage
Loading

0 comments on commit f8933c0

Please sign in to comment.