8000 Merge branch 'feature/chengxi/customview' into 'develop' · newcoderzhang/LuaViewSDK@ea935ab · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit ea935ab

Browse files
author
城西
committed
Merge branch 'feature/chengxi/customview' into 'develop'
Feature/chengxi/customview See merge request !34
2 parents 8a6b111 + ced94fa commit ea935ab

28 files changed

+1720
-104
lines changed

IOS/Demo/Demo.xcodeproj/project.pbxproj

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@
7777
84F9A0391C92BB2B00481334 /* demoA_ViewChildren.lua in Resources */ = {isa = PBXBuildFile; fileRef = 84F9A0381C92BB2B00481334 /* demoA_ViewChildren.lua */; };
7878
84F9A0471C92CA7300481334 /* button0.png in Resources */ = {isa = PBXBuildFile; fileRef = 84F9A0451C92CA7300481334 /* button0.png */; };
7979
84F9A0481C92CA7300481334 /* button1.png in Resources */ = {isa = PBXBuildFile; fileRef = 84F9A0461C92CA7300481334 /* button1.png */; };
80+
911270911DFA954D001F8047 /* demoL3_onTouch.lua in Resources */ = {isa = PBXBuildFile; fileRef = 911270901DFA954D001F8047 /* demoL3_onTouch.lua */; };
81+
911270971DFAA464001F8047 /* demoZ_Gesture.lua in Resources */ = {isa = PBXBuildFile; fileRef = 911270961DFAA464001F8047 /* demoZ_Gesture.lua */; };
8082
91232AB01DAB7BFB00536E0C /* demoK_WebView.lua in Resources */ = {isa = PBXBuildFile; fileRef = 91232AAF1DAB7BFB00536E0C /* demoK_WebView.lua */; };
83+
91912B0C1DF9658200ACDF0C /* animate1.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 91912B0B1DF9658200ACDF0C /* animate1.jpg */; };
84+
91F6788D1DF582770042D6FC /* demoL2_CustomView.lua in Resources */ = {isa = PBXBuildFile; fileRef = 91F6788C1DF582770042D6FC /* demoL2_CustomView.lua */; };
8185
BE9CD5061CACCF5700D6AC94 /* libLuaViewLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3CFF78181C74743C00847C05 /* libLuaViewLib.a */; };
8286
BEEB28DA1CA90F0A00EC2D86 /* demoA_FlexBox.lua in Resources */ = {isa = PBXBuildFile; fileRef = BEEB28D91CA90F0A00EC2D86 /* demoA_FlexBox.lua */; };
8387
DC3E58DF90755933412DC0A4 /* libPods-Demo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E3A299A541C820B23BCC7BCA /* libPods-Demo.a */; };
@@ -206,7 +210,11 @@
206210
84F9A0381C92BB2B00481334 /* demoA_ViewChildren.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = demoA_ViewChildren.lua; sourceTree = "<group>"; };
207211
84F9A0451C92CA7300481334 /* button0.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = button0.png; sourceTree = "<group>"; };
208212
84F9A0461C92CA7300481334 /* button1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = button1.png; sourceTree = "<group>"; };
213+
911270901DFA954D001F8047 /* demoL3_onTouch.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = demoL3_onTouch.lua; sourceTree = "<group>"; };
214+
911270961DFAA464001F8047 /* demoZ_Gesture.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = demoZ_Gesture.lua; sourceTree = "<group>"; };
209215
91232AAF1DAB7BFB00536E0C /* demoK_WebView.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = demoK_WebView.lua; sourceTree = "<group>"; };
216+
91912B0B1DF9658200ACDF0C /* animate1.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = animate1.jpg; sourceTree = "<group>"; };
217+
91F6788C1DF582770042D6FC /* demoL2_CustomView.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = demoL2_CustomView.lua; sourceTree = "<group>"; };
210218
BEEB28D91CA90F0A00EC2D86 /* demoA_FlexBox.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = demoA_FlexBox.lua; sourceTree = "<group>"; };
211219
E3A299A541C820B23BCC7BCA /* libPods-Demo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Demo.a"; sourceTree = BUILT_PRODUCTS_DIR; };
212220
/* End PBXFileReference section */
@@ -318,6 +326,8 @@
318326
91232AAF1DAB7BFB00536E0C /* demoK_WebView.lua */,
319327
3CC2F86B1C706BFA00D1E0B7 /* demoL_Alert.lua */,
320328
3CC2F86C1C706BFA00D1E0B7 /* demoL_LoadingIndicator.lua */,
329+
91F6788C1DF582770042D6FC /* demoL2_CustomView.lua */,
330+
911270901DFA954D001F8047 /* demoL3_onTouch.lua */,
321331
3CC2F86D1C706BFA00D1E0B7 /* demoM_Navigation.lua */,
322332
3CC2F86E1C706BFA00D1E0B7 /* demoO_coroutineDemo.lua */,
323333
3CC2F86F1C706BFA00D1E0B7 /* demoO_table.lua */,
@@ -338,7 +348,9 @@
338348
3CC2F8791C706BFA00D1E0B7 /* demoZ1_luabox.lua */,
339349
3CC2F87A1C706BFA00D1E0B7 /* demoZ2_callOC.lua */,
340350
3CC2F8821C706BFA00D1E0B7 /* demoZB1_Animator.lua */,
351+
911270961DFAA464001F8047 /* demoZ_Gesture.lua */,
341352
3CC2F88B1C706BFA00D1E0B7 /* lv_kit.lua */,
353+
91912B0B1DF9658200ACDF0C /* animate1.jpg */,
342354
3CC2F85B1C706BFA00D1E0B7 /* bt_catebrand_more.9.png */,
343355
84F9A0451C92CA7300481334 /* button0.png */,
344356
84F9A0461C92CA7300481334 /* button1.png */,
@@ -464,6 +476,7 @@
464476
TargetAttributes = {
465477
3CC2F8191C706B1D00D1E0B7 = {
466478
CreatedOnToolsVersion = 7.2;
479+
DevelopmentTeam = 6L4X75AQK7;
467480
};
468481
3CC2F8321C706B1D00D1E0B7 = {
469482
CreatedOnToolsVersion = 7.2;
@@ -535,6 +548,7 @@
535548
3CC2F8BE1C706BFA00D1E0B7 /* demoZB1_Animator.lua in Resources */,
536549
3CC2F8B01C706BFA00D1E0B7 /* demoV1_Customloading.lua in Resources */,
537550
3CC2F8A51C706BFA00D1E0B7 /* demoK_PagerView.lua in Resources */,
551+
911270911DFA954D001F8047 /* demoL3_onTouch.lua in Resources */,
538552
3CC2F8AA1C706BFA00D1E0B7 /* demoO_coroutineDemo.lua in Resources */,
539553
3CC2F8B91C706BFA00D1E0B7 /* demoZ_testunit.lua in Resources */,
540554
3CC2F8A71C706BFA00D1E0B7 /* demoL_Alert.lua in Resources */,
@@ -553,6 +567,7 @@
553567
3CC2F8CB1C706BFA00D1E0B7 /* enter.png in Resources */,
554568
3CC2F9191C70BB8E00D1E0B7 /* candle in Resources */,
555569
3CC2F8981C706BFA00D1E0B7 /* bt_catebrand_more.9.png in Resources */,
570+
91F6788D1DF582770042D6FC /* demoL2_CustomView.lua in Resources */,
556571
3CC2F8AF1C706BFA00D1E0B7 /* demoV1_CustomError.lua in Resources */,
557572
3CC2F8CA1C706BFA00D1E0B7 /* demoZ_1212.lua in Resources */,
558573
3CC2F8C41C706BFA00D1E0B7 /* img4.tiff in Resources */,
@@ -573,6 +588,8 @@
573588
3CC2F8CE1C706BFA00D1E0B7 /* hongbao.png in Resources */,
574589
3CC2F89E1C706BFA00D1E0B7 /* demoA_ImageAnimate.lua in Resources */,
575590
840BCEEE1CB7A0B700D816AD /* tags2.9.png in Resources */,
591+
911270971DFAA464001F8047 /* demoZ_Gesture.lua in Resources */,
592+
91912B0C1DF9658200ACDF0C /* animate1.jpg in Resources */,
576593
3CC2F8A01C706BFA00D1E0B7 /* demoC_Label.lua in Resources */,
577594
3CC2F89D1C706BFA00D1E0B7 /* demoA_Image.lua in Resources */,
578595
84F9A0391C92BB2B00481334 /* demoA_ViewChildren.lua in Resources */,
@@ -794,7 +811,7 @@
794811
baseConfigurationReference = 1D91B87B0C382EBA586DA7E1 /* Pods-Demo.debug.xcconfig */;
795812
buildSettings = {
796813
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
797-
DEVELOPMENT_TEAM = "";
814+
DEVELOPMENT_TEAM = 6L4X75AQK7;
798815
HEADER_SEARCH_PATHS = "$(SRCROOT)/../LuaViewSDK/Classes/**";
799816
INFOPLIST_FILE = Demo/Info.plist;
800817
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
@@ -810,7 +827,7 @@
810827
baseConfigurationReference = 39A1B496E543E8E483B39034 /* Pods-Demo.release.xcconfig */;
811828
buildSettings = {
812829
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
813-
DEVELOPMENT_TEAM = "";
830+
DEVELOPMENT_TEAM = 6L4X75AQK7;
814831
HEADER_SEARCH_PATHS = "$(SRCROOT)/../LuaViewSDK/Classes/**";
815832
INFOPLIST_FILE = Demo/Info.plist;
816833
IPHONEOS_DEPLOYMENT_TARGET = 7.0;

IOS/Demo/Demo/lua/animate1.jpg

44 KB
Loading
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
img = Image()
2+
3+
view = CustomView()
4+
view.frame(100, 100, 200, 200)
5+
view.backgroundColor(0x000000, 0.3)
6+
7+
img.hidden(true)
8+
9+
view.onDraw(function(canvas)
10+
testCanvasAndroidAndIos(canvas)
11+
end)
12+
13+
function testCanvasAndroidAndIos(canvas)
14+
print(canvas)
15+
-- drawLine
16+
canvas.color(0xff0000)
17+
canvas.strokeWidth(2)
18+
canvas.drawLine(0, 50, 100, 50)
19+
canvas.drawLine(50, 0, 50, 100)
20+
21+
canvas.resetPaint()
22+
canvas.color(0x00ff00, 0.5)
23+
canvas.drawLine(0, 0, 100, 0)
24+
canvas.drawLine(100, 0, 100, 100)
25+
canvas.drawLine(100, 100, 0, 100)
26+
canvas.drawLine(0, 100, 0, 0)
27+
canvas.drawLine(0, 0, 100, 100)
28+
canvas.drawLine(100, 0, 0, 100)
29+
30+
-- drawPoint
31+
canvas.color(0xff0000)
32+
canvas.strokeWidth(2)
33+
canvas.drawPoint(1, 5)
34+
canvas.drawPoint(99, 93)
35+
36+
-- drawRect
37+
canvas.resetPaint()
38+
canvas.style(PaintStyle.STROKE)
39+
canvas.drawRect(5, 5, 5, 5)
40+
canvas.style(PaintStyle.FILL)
41+
canvas.drawRect(10, 10, 5, 5)
42+
43+
-- drawRoundRects
44+
canvas.drawRoundRect(45, 1, 5, 5, 2, 2)
45+
canvas.drawRoundRect(45, 5, 10, 5, 2, 2)
46+
47+
-- drawCircle
48+
canvas.drawCircle(80, 0, 5)
49+
canvas.drawCircle(80, 15, 5)
50+
51+
-- drawText
52+
canvas.textSize(20)
53+
canvas.drawText("x", 20, 55)
54+
canvas.textSize(14)
55+
canvas.drawText("y", 20, 65)
56+
canvas.resetPaint()
57+
58+
-- drawOval
59+
canvas.drawOval(45, 50, 25, 10)
60+
canvas.drawOval(45, 60, 25, 10)
61+
62+
-- draw Arc
63+
canvas.drawArc(30, 30, 20, 20, 0, 90, true)
64+
65+
-- drawBitmap
66+
canvas.save()
67+
canvas.rotate(-10, 100, 100)
68+
-- canvas.skew(1 )
69+
canvas.scale(1.2)
70+
canvas.translate(-10, -10)
71+
canvas.strokeWidth(10)
72+
canvas.textSize(15)
73+
canvas.bold(true)
74+
canvas.drawText("测试一下", 20, 150)
75+
canvas.alpha(0.5)
76+
canvas.drawImage("animate1.jpg", 0, 100, 100, 100)
77+
canvas.restore()
78+
canvas.resetPaint()
79+
80+
print(img)
81+
if(img) then
82+
canvas.drawImage(img, 100, 0, 100, 100)
83+
end
84+
85+
-- clipRect
86+
canvas.clipRect(100, 100, 35, 35)
87+
canvas.drawCircle(100, 100, 40)
88+
89+
canvas.clipRect(150, 150, 30, 30)
90+
canvas.drawText("TestABCDEFGHEFGHIJKLMOPQRST", 150, 150)
91+
92+
print(canvas.nativeObj())
93+
end
94+
95+
96+
img.image("https://gju1.alicdn.com/bao/uploaded/i4/100000120700895002/TB2Qu0_fXXXXXb9XpXXXXXXXXXX_!!0-0-juitemmedia.jpg_560x560Q90.jpg", function()
97+
view.invalidate()
98+
print("image load finish")
99+
end)
100+
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
sw, sh = System.screenSize()
2+
3+
bg = Label()
4+
bg.text("我是背景,重复进入页面,尝试不同状态。")
5+
bg.frame(0, 0, sw, sh)
6+
bg.callback(function()
7+
Toast("bg clicked")
8+
end)
9+
bg.effects(ViewEffect.CLICK)
10+
11+
12+
view = CustomView()
13+
view.frame(0, 0, sw,sh)
14+
view.backgroundColor(0xff0000, 0.5)
15+
16+
lastX = nil
17+
lastY = nil
18+
19+
x = 0
20+
y = 0
21+
w = 4
22+
dx = 0
23+
dy = 0
24+
25+
isTouchable = math:random() > 0.5
26+
27+
bg.text(bg.text() .. (isTouchable and " 不可点击" or " 可以点击"))
28+
29+
view.onTouch(function(event)
30+
print(event.id, event.pointer, "action:", event.action, event.x, event.y)
31+
dx = lastX and event.x - lastX or 0
32+
dy = lastY and event.y - lastY or 0
33+
34+
35+
x = x + dx
36+
y = y + dy
37+
38+
if(x < 0) then
39+
x = 0
40+
end
41+
42+
if(y < 0) then
43+
y = 0
44+
end
45+
46+
if(x > sw) then
47+
x = sw
48+
end
49+
50+
if (y > sh) then
51+
y = sh
52+
end
53+
54+
lastX = event.action == TouchEvent.MOVE and event.x or nil
55+
lastY = event.action == TouchEvent.MOVE and event.y or nil
56+
57+
view.invalidate()
58+
59+
return isTouchable;
60+
end)
61+
62+
rect = {}
63+
64+
count = 20
65+
66+
for i = 0, count, 1 do
67+
rect[i + 1] = {}
68+
rect[i + 1][1] = x
69+
rect[i + 1][2] = y
70+
rect[i + 1][3] = w
71+
rect[i + 1][4] = w
72+
73+
x = x + 20
74+
75+
w = 3 + math:random(10)
76+
end
77+
78+
view.onDraw(function(canvas)
79+
print(x, y, w, h)
80+
81+
for i = 0, count, 1 do
82+
canvas.drawRect(rect[i+1][1], rect[i+1][2], rect[i+1][3], rect[i+1][4])
83+
end
84+
85+
for i = 0, count, 1 do
86+
rect[i+1][2] = (rect[i+1][2] + math:random()) * 1.005 - dy
87+
88+
if(rect[i+1][2] + rect[i+1][4] > 500) then
89+
rect[i+1][2] = 500 - rect[i + 1][4]
90+
end
91+
end
92+
93+
canvas.drawLine(0, 500 - dy, sw, 500-dy)
94+
95+
end)
96+
97+
timer = Timer();
98+
timer.callback(function()
99+
view.invalidate()
100+
end).start(0.01, true)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
w,h = System.screenSize();--获取屏幕尺寸
3+
4+
gesture = Gesture(
5+
function( event )
6+
print(event.id, event.pointer, event.action, event.x, event.y)
7+
end
8+
);
9+
10+
window.addGesture(gesture);
11+

0 commit comments

Comments
 (0)
0