feat: ported totp.js library to zepp quick-js

This commit is contained in:
Савелий Савенок
2024-11-09 16:37:03 +03:00
commit b67cddf4eb
31 changed files with 645 additions and 0 deletions

2
page/i18n/en-US.po Normal file
View File

@@ -0,0 +1,2 @@
msgid "example"
msgstr "This is an example in device"

35
page/index.js Normal file
View File

@@ -0,0 +1,35 @@
import { getDeviceInfo } from '@zos/device'
import { push } from '@zos/router'
import { createWidget, widget } from '@zos/ui'
import {TOTP} from '../lib/totp.js/lib/totp.js'
Page({
build() {
const totp = new TOTP('asdasd')
const {width, height} = getDeviceInfo()
createWidget(widget.TEXT, {
x: width / 2 - 30,
y: height / 2 - 60,
text: totp.genOTP()
})
createWidget(widget.BUTTON,{
x: width / 2 - 40,
y: height / 2 - 20,
w: 80,
h: 80,
text: '+',
radius: 50,
text_size: 40,
normal_color: 0x303030,
press_color: 0x181c18,
click_func: () => {
push({
url: 'page/tip'
})
}
})
}
})

6
page/index.s.layout.js Normal file
View File

@@ -0,0 +1,6 @@
import { px } from "@zos/utils";
export const TEXT_STYLE = {
x: px(0),
y: px(0),
}

29
page/tip.js Normal file
View File

@@ -0,0 +1,29 @@
import { createWidget, widget, align } from "@zos/ui";
import { getDeviceInfo } from "@zos/device";
import { onGesture, GESTURE_LEFT } from '@zos/interaction'
import { back } from "@zos/router";
Page({
onInit(){
onGesture({
callback(event) {
if(event === GESTURE_LEFT){
back()
}
}
})
},
build() {
console.log("Page tip opened")
const {width, height} = getDeviceInfo()
createWidget(widget.TEXT, {
x: 0,
w: width,
h: height,
color: 0xffffff,
text_size: 30,
align_h: align.CENTER_H,
align_v: align.CENTER_V,
text: 'To add TOTP record open\n settings on Zepp app'
})
}
})