-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from mmolotov/develop
v 2.0.0
- Loading branch information
Showing
40 changed files
with
1,028 additions
and
896 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
} | ||
}) | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
137
page/common/creation_pages/create_timer.page.template.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.