Skip to content

Commit 19a8d03

Browse files
[add]first version
Signed-off-by: Willian Chan <[email protected]>
1 parent c1bf66b commit 19a8d03

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+4034
-0
lines changed

ART_Brage.rtprj

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project>
3+
<GlobalSetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" DownloadMode="1" ProjectName="ART_Brage" DefaultWinWidth="240" DefaultWinHeight="240" EditorFontSize="24" ProjectParentName="ART_Badge_240_UI_2" GUIVersion="V4">
4+
</GlobalSetting>
5+
<Solution>
6+
<ART_Brage SubType="Project">
7+
<UI文件 SubType="UIFile">
8+
<CustomPanels SubType="CustomPanel">
9+
<AppListCustomPanel.ui SubType="PageUi" />
10+
<pointerClock.ui SubType="PageUi" />
11+
</CustomPanels>
12+
<pages SubType="Directory">
13+
<list_settings SubType="PageDirectory">
14+
<list_settings.js SubType="PageJs" />
15+
<list_settings.ui SubType="PageUi" />
16+
</list_settings>
17+
<main SubType="PageDirectory">
18+
<main.js SubType="PageJs" />
19+
<main.ui SubType="PageUi" />
20+
</main>
21+
</pages>
22+
</UI文件>
23+
<modules SubType="Modules">
24+
<digit_clock.js SubType="ModulesJs" />
25+
<hardware.js SubType="ModulesJs" />
26+
<pointer_clock.js SubType="ModulesJs" />
27+
<rtc.js SubType="ModulesJs" />
28+
</modules>
29+
<app.js SubType="AppJs" />
30+
<app.json SubType="AppJson" />
31+
</ART_Brage>
32+
</Solution>
33+
</Project>
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
var notifi_lib = require("notification");
2+
var msg_items = [];
3+
4+
var page = {
5+
anim: 0,
6+
touchStartY : 0, // panel中触摸的Y坐标
7+
touchStartX : 0, // panel中触摸的Y坐标
8+
touchStartPosition : 0,// page中开始触摸的坐标
9+
touchEndPosition : 0, // page中结束触摸的坐标
10+
direction: false,
11+
title:"",
12+
13+
msg_items: [],
14+
call_back: null,
15+
/* 此方法在第一次显示窗体前发生 */
16+
onLoad:function(event){
17+
PageTouchInit(this);
18+
19+
},
20+
refreshMsg: function () {
21+
msgs = notifi_lib.getMsgs("NotRead");
22+
for (var i = 0; i < msgs.length; ++i) {
23+
var item = msgs[i];
24+
var index = msg_items.indexOf(item);
25+
if (index == -1)
26+
{
27+
msg_items.push(item);//
28+
}
29+
}
30+
this.loadMsg(msg_items);
31+
32+
},
33+
loadMsg: function (items) {
34+
this.setData({ listctrl: { empty: true } });
35+
var array = [];
36+
for (var i = 0, len = items.length; i < len; i++) {
37+
var data = {};
38+
var content = "";
39+
var const_length = 18;
40+
if (items[i].text_content.length > const_length)
41+
content = items[i].text_content.substring(0, const_length) + "...";
42+
else
43+
content = items[i].text_content;
44+
45+
data["id"] = items[i].id;
46+
data["content"] = { id: "content" + i, value: content};
47+
data["icon"] = { id: "icon" + i, value: items[i].icon_path };
48+
data["title"] = { id: "title" + i, value: items[i].title };
49+
data["button1"]={id: "btn_" + items[i].id, value:""}
50+
array.push(data);
51+
}
52+
53+
this.setData({ listctrl: { list: { page: this, items: [{ xml: 'Panels/Top_message_item', items: array }] } } })
54+
},
55+
56+
/* 当前页状态变化为隐藏时触发 */
57+
onHide: function (event) {
58+
notifi_lib.offNotification(this.call_back);
59+
},
60+
61+
/* 此方法展示窗体前发生 */
62+
onShow:function(event){
63+
var that = this;
64+
notifi_lib.onNotification(this.call_back = function(event) {
65+
var count = notifi_lib.getCount("NotRead");
66+
if (count > 0)
67+
that.refreshMsg();
68+
});
69+
that.refreshMsg();
70+
},
71+
72+
/* 此方法关闭窗体前发生 */
73+
onExit:function(event){
74+
PageTouchUninit(this);
75+
},
76+
onPageTouch: function (event) {
77+
PageTouchEvent(this, event,
78+
0,
79+
0,
80+
function () { pm.navigateBack() },
81+
0,
82+
0
83+
)
84+
},
85+
86+
// 添加之后不能更新
87+
onSwitch:function(event) {
88+
89+
},
90+
onClick: function (event) {
91+
console.dir(event);
92+
var id = event.target.id
93+
var str_id = id.substring(4, id.length);
94+
for (var index = 0; index < msg_items.length; index ++)
95+
{
96+
if (msg_items[index].id == str_id)
97+
{
98+
item = msg_items[index];
99+
notifi_lib.updateMsgReadStatus(str_id);
100+
msg_items.splice(index, 1);
101+
notifi_lib.offNotification(this.call_back);
102+
pm.navigateTo({url : 'MessagePage/MessagePage', value : item})
103+
break;
104+
}
105+
}
106+
107+
},
108+
};
109+
110+
Page(page);
111+
112+
page = 0;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<rtgui version="1.0">
3+
<class>Page</class>
4+
<widget class="Page" bindtouch="onPageTouch" name="Top_message">
5+
<public>
6+
<property name="background">255, 0, 0, 0</property>
7+
</public>
8+
<widgets>
9+
<widget name="Switch" class="Switch" bindchange="onSwitch">
10+
<public>
11+
<property name="rect">123, -1, 73, 79</property>
12+
<property name="background">0, 212, 208, 200</property>
13+
</public>
14+
<property name="offBgImg">images/message.png</property>
15+
<property name="onBgImg">images/message.png</property>
16+
</widget>
17+
<widget name="listctrl" class="listctrl">
18+
<public>
19+
<property name="rect">38, 84, 250, 225</property>
20+
<property name="background">0, 212, 208, 200</property>
21+
</public>
22+
<property name="gap">3</property>
23+
</widget>
24+
</widgets>
25+
</widget>
26+
</rtgui>

ART_Brage/app.js

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
var date = new Date();
2+
3+
var data_pool; /* dcmlib data pool */
4+
5+
var TouchMode = {
6+
cancel: 0,
7+
press: 1, /* 长按 */
8+
move: 2, /* 移动 */
9+
}
10+
11+
var app = {
12+
data: {
13+
/* 全局设定 */
14+
mainPage: 0,
15+
clockIndex: 2,
16+
date: new Date(),
17+
stepCount: 489,
18+
bpmCount: 100,
19+
isSaveMode: false,
20+
language: "中文",
21+
version: "1.0.2",
22+
flag: 1,
23+
},
24+
25+
page: "pages/main/main",
26+
/* app 加载完成触发该函数 */
27+
onLaunch: function () {
28+
29+
},
30+
31+
/* app 退出触发该函数 */
32+
onExit: function () {
33+
},
34+
35+
};
36+
37+
PageTouchInit = function (page) {
38+
page.touchStartY = 0; /* panel中触摸的Y坐标 */
39+
page.touchStartPosition = 0; /* page中开始触摸的坐标 */
40+
page.touchEndPosition = 0; /* page中结束触摸的坐标 */
41+
page.touchStatus = TouchMode.cancel;
42+
page.touchTimer = 0;
43+
page.navigateEnable = true;
44+
}
45+
46+
PageTouchUninit = function (page) {
47+
var that = page;
48+
if (that.touchTimer != 0) {
49+
clearInterval(that.touchTimer);
50+
that.touchTimer = 0;
51+
}
52+
}
53+
54+
PageTouchEvent = function (page, event, longPress, R2L, L2R, T2D, D2T) {
55+
var that = page;
56+
var touchItem = event.touchs[0];
57+
58+
if (touchItem.type == "touchstart") {
59+
// console.log(" >>> touchStart")
60+
/* 长按操作 */
61+
that.touchStatus = TouchMode.press;
62+
that.touchStartPosition = { x: touchItem.x, y: touchItem.y };
63+
// console.log("that.touchTimer: ", that.touchTimer);
64+
if (that.touchTimer != 0) {
65+
clearInterval(that.touchTimer);
66+
that.touchTimer = 0;
67+
}
68+
69+
that.touchTimer = setTimeout(function () {
70+
// console.log(">> long press");
71+
clearInterval(that.touchTimer);
72+
that.touchTimer = 0;
73+
if (that.touchStatus == TouchMode.press) {
74+
if (typeof (longPress) == "function") {
75+
longPress();
76+
}
77+
}
78+
}, 1000);
79+
80+
} else if (touchItem.type == "touchmove") {
81+
// console.log(" >>> touch move")
82+
that.touchStatus = TouchMode.move;
83+
that.touchEndPosition = { x: touchItem.x, y: touchItem.y };
84+
} else if (touchItem.type == "touchend") {
85+
console.log(" >>> touch end")
86+
if (that.touchStatus == TouchMode.move) {
87+
var d_ValueX = that.touchEndPosition.x - that.touchStartPosition.x
88+
var d_ValueY = that.touchEndPosition.y - that.touchStartPosition.y
89+
// console.log(" x : " + d_ValueX);
90+
// console.log(" y : " + d_ValueY);
91+
// console.log(" that.navigateEnable : " + that.navigateEnable);
92+
if (d_ValueY > 50 && that.navigateEnable == true) {
93+
console.log("slide down")
94+
if (typeof (T2D) == "function") {
95+
T2D();
96+
return;
97+
}
98+
} else if (d_ValueY < -50 && that.navigateEnable == true) {
99+
console.log("slide up")
100+
if (typeof (D2T) == "function") {
101+
D2T();
102+
return;
103+
}
104+
}
105+
106+
if (d_ValueX > 50 && that.navigateEnable == true) {
107+
console.log("slide right")
108+
if (typeof (L2R) == "function") {
109+
L2R();
110+
return;
111+
}
112+
} else if (d_ValueX < -50 && that.navigateEnable == true) {
113+
console.log("slide left")
114+
if (typeof (R2L) == "function") {
115+
R2L();
116+
return;
117+
}
118+
}
119+
}
120+
that.touchStatus = TouchMode.cancel;
121+
if (that.touchTimer != 0) {
122+
clearInterval(that.touchTimer);
123+
that.touchTimer = 0;
124+
}
125+
} else if (touchItem.type == "touchcancel") {
126+
if (that.touchTimer != 0) {
127+
clearInterval(that.touchTimer);
128+
that.touchTimer = 0;
129+
}
130+
}
131+
}
132+
133+
App(app);
134+
135+
app = 0;

ART_Brage/app.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "320x320",
3+
"version": "v4.0.0",
4+
"tag":[ "demo"],
5+
"icon": "icon.png"
6+
}

ART_Brage/modules/digit_clock.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var digit_clock = function (that,date) {
2+
var hourStr;
3+
var minStr;
4+
var secStr;
5+
if(date.getHours() < 10)
6+
{
7+
hourStr = "0" + date.getHours()
8+
}else{
9+
hourStr = date.getHours()
10+
}
11+
if(date.getMinutes() < 10)
12+
{
13+
minStr = "0" + date.getMinutes()
14+
}else{
15+
minStr = date.getMinutes()
16+
}
17+
if(date.getSeconds() < 10)
18+
{
19+
secStr = "0" + date.getSeconds()
20+
}else{
21+
secStr = date.getSeconds()
22+
}
23+
that.setData({ time_label : { value : hourStr + ":" + minStr, refresh : true}});
24+
that.setData({ date_label : { value : date.getFullYear() + "/" + (date.getMonth() + 1) + "/" + date.getDate(), refresh : true}})
25+
}
26+
27+
module.exports = digit_clock;

0 commit comments

Comments
 (0)