From 3e74a0ce1b6cb8513e0a60d8b4830459f616faf7 Mon Sep 17 00:00:00 2001 From: Uldis Zeidurs Date: Mon, 3 Jul 2017 15:34:05 +0300 Subject: [PATCH 1/3] adding basic cameraview sample --- Samples/CameraView/CameraView.unoproj | 11 ++ Samples/CameraView/MainView.ux | 160 ++++++++++++++++++++++++++ Samples/CameraView/README.md | 1 + Samples/CameraView/description.yaml | 2 + 4 files changed, 174 insertions(+) create mode 100644 Samples/CameraView/CameraView.unoproj create mode 100644 Samples/CameraView/MainView.ux create mode 100644 Samples/CameraView/README.md create mode 100644 Samples/CameraView/description.yaml diff --git a/Samples/CameraView/CameraView.unoproj b/Samples/CameraView/CameraView.unoproj new file mode 100644 index 0000000..03d1112 --- /dev/null +++ b/Samples/CameraView/CameraView.unoproj @@ -0,0 +1,11 @@ +{ + "RootNamespace": "", + "Packages": [ + "Fuse", + "FuseJS", + "Fuse.Controls.CameraView" + ], + "Includes": [ + "*" + ] +} \ No newline at end of file diff --git a/Samples/CameraView/MainView.ux b/Samples/CameraView/MainView.ux new file mode 100644 index 0000000..094e40b --- /dev/null +++ b/Samples/CameraView/MainView.ux @@ -0,0 +1,160 @@ + + + + + + + var Observable = require("FuseJS/Observable"); + var FileSystem = require("FuseJS/FileSystem"); + + var path = FileSystem.dataDirectory + "/"; + var library = Observable(); + var image = Observable(""); + + var flashIsOn = Observable(false); + + var imageObject = {}; + + function takePicture() { + cameraPanel.takePicture({callback: function(err, img) { + if (img !== null) { + imageObject = img; + image.value = img.path; + } + }}); + } + + function reset() { + image.value = ""; + flashIsOn.value = false; + } + + function savePicture() { + var dest = path + imageObject.name; + FileSystem.copySync(imageObject.path, dest); + library.add(dest); + reset(); + } + + function swapCamera() { + cameraPanel.swapCamera(); + } + + function toggleFlash() { + flashIsOn.value = ! flashIsOn.value; + if (flashIsOn.value) { + cameraPanel.enableFlash(); + } else { + cameraPanel.disableFlash(); + } + } + + module.exports = { + library: library, + image: image, + takePicture: takePicture, + reset: reset, + savePicture: savePicture, + swapCamera: swapCamera, + cameraDirection: cameraPanel.CurrentCameraDirection.map(function(x) { + return x.substr(0,1); + }), + toggleFlash: toggleFlash, + flashState: flashIsOn.map(function(x) { + var res = "Flash: "; + if (x) { + res += "On"; + } else { + res += "Off"; + } + return res; + }) + }; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/CameraView/README.md b/Samples/CameraView/README.md new file mode 100644 index 0000000..454f460 --- /dev/null +++ b/Samples/CameraView/README.md @@ -0,0 +1 @@ +# Using the CameraView premium library diff --git a/Samples/CameraView/description.yaml b/Samples/CameraView/description.yaml new file mode 100644 index 0000000..45123b9 --- /dev/null +++ b/Samples/CameraView/description.yaml @@ -0,0 +1,2 @@ +name: Using the CameraView premium library +desc: This sample shows how to use the CameraView premium library to build a fully functional camera app. From 5eb3c46cfbc43d1b65e312f4704e3d04009a604c Mon Sep 17 00:00:00 2001 From: Uldis Zeidurs Date: Tue, 4 Jul 2017 15:28:01 +0300 Subject: [PATCH 2/3] added icons and video implementation, and saving to cameraroll --- Samples/CameraView/Assets/camera_front.png | Bin 0 -> 444 bytes Samples/CameraView/Assets/camera_rear.png | Bin 0 -> 377 bytes Samples/CameraView/Assets/cancel.png | Bin 0 -> 754 bytes Samples/CameraView/Assets/check_circle.png | Bin 0 -> 738 bytes Samples/CameraView/Assets/flash_off.png | Bin 0 -> 485 bytes Samples/CameraView/Assets/flash_on.png | Bin 0 -> 318 bytes Samples/CameraView/Assets/photo_camera.png | Bin 0 -> 666 bytes Samples/CameraView/Assets/videocam.png | Bin 0 -> 234 bytes Samples/CameraView/CameraView.unoproj | 4 +- Samples/CameraView/MainView.js | 103 +++++++++ Samples/CameraView/MainView.ux | 231 +++++++++------------ 11 files changed, 199 insertions(+), 139 deletions(-) create mode 100644 Samples/CameraView/Assets/camera_front.png create mode 100644 Samples/CameraView/Assets/camera_rear.png create mode 100644 Samples/CameraView/Assets/cancel.png create mode 100644 Samples/CameraView/Assets/check_circle.png create mode 100644 Samples/CameraView/Assets/flash_off.png create mode 100644 Samples/CameraView/Assets/flash_on.png create mode 100644 Samples/CameraView/Assets/photo_camera.png create mode 100644 Samples/CameraView/Assets/videocam.png create mode 100644 Samples/CameraView/MainView.js diff --git a/Samples/CameraView/Assets/camera_front.png b/Samples/CameraView/Assets/camera_front.png new file mode 100644 index 0000000000000000000000000000000000000000..3eb24d1f292b06f87a54566d565e0872b5011945 GIT binary patch literal 444 zcmV;t0YmDu6CULI|ZC&Y!dI-TyXb}~cS?MiA@d$c|FKMN=VR|d*)U0(*8 z7J+=&^dKG zYX{6 literal 0 HcmV?d00001 diff --git a/Samples/CameraView/Assets/camera_rear.png b/Samples/CameraView/Assets/camera_rear.png new file mode 100644 index 0000000000000000000000000000000000000000..8392b2a888469b0bc58aadbf2648e6bbd393a870 GIT binary patch literal 377 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY0wn)GsXoKN!06!V;uuoF`1a<0FJ?!9hL3B% zP4db)E6k$n)6x6G%l#8abaxa-)A}j)3rgI+8ic|bPGAYknd9`n%h)A)FWAq}PD?z(=@@!dBmMxj#|JF)!Ma*&2 z=Pqn91?SbD{uBLj=*RWHn(t>V==*r^NKd})1>dq~f&3;X&&9lK{IvSP4XGC%{3d75 z#k^|F+ic8VwSeD`Urnv%W#faXo9*YAUtn=OFKgV!vo);UhTZanBVW;kW|=1nNKESm z_in9j<=q;6(t$hc`Y8uq>#T1sQ}#c)6ZT||z>)AIZVZxe5g_(?=o?oYD&r3uSXz#wJtboFyt=akR{00Fh2pa1{> literal 0 HcmV?d00001 diff --git a/Samples/CameraView/Assets/cancel.png b/Samples/CameraView/Assets/cancel.png new file mode 100644 index 0000000000000000000000000000000000000000..12b0e55ba8fa0e1d6d3621ae9e96a69847784ba4 GIT binary patch literal 754 zcmVrAd^1N}CfTD-j8x1WyX5_YN?g&!wJw*;`U5S{L{o!O_Mj=wNz)m{EJ0g5leRYHY(N7X zkyRCPX+h(JWZ5;NX+Q;jlXXAIYeD1aIWlQf0~#R2S2yI6gO2c7B`IhN-<6Yqrg+A8 zZHn%obKat_uAl{^zOzY$OMh9XhSZ!Js3~#+3~NLVoMjAwNUFPlN^Rfb} z*qiAMx^mzMq*t8(qzi1-dVwbCVrv6~v6C#Em$iwl4tW{0hrNi^SD#)Xa^T2U+>Q*Y zgGgGDND2;w66gal=t&9=L=4$MO8^>@ngcLz2OWZnv`nPtz`h-H3XY`Z*CaIuj_sf( zXh~`gH0+=jC`oz_JlH``hzUE6o&%3|Pz*|vo&(YQ2fg2~tfl41$FBaOZt6LDl62dj zs5xt_s!77ec%bG)^23St=vY*9a!x?YU7mO>YNE_e%q2LZOl=0n0(wCkUeD)cW6qMr{U;Q9R4l<1K z3m@Gxq8%;dJ&^91NHcsH<0j)TYb5P>Dn}*5OF779fLErS!M?MR<%qM$x0JhbA^Rcl z9Cb8>%=jCVf22kS*E&?0_WwhIJUfIvpNDSQ7H)6>q+LVIv(GUN9(W`o;*kd$9J9|n kgZiIZ_+5QaAJhl^12jg`PjXh`s{jB107*qoM6N<$g5Kp<2LJ#7 literal 0 HcmV?d00001 diff --git a/Samples/CameraView/Assets/check_circle.png b/Samples/CameraView/Assets/check_circle.png new file mode 100644 index 0000000000000000000000000000000000000000..542a64b312c4c62582ecd0b1d95e353f9766b39b GIT binary patch literal 738 zcmV<80v-K{P)B#E0)^$$#VgJu@EQcD@eS>cNYx8!*W^@@+Ufx{<6x_865&Dbu-TiipmA*X zGz_SVbF}+ObtTer&?mHW>E;>LeUO3%t#Ay6=Tw)Gf%YwNu4bO=?Mgrc7CBe5!1elS zgEp;l3|X$XUJI1wGDZ$mNCktYW90x$27~f3b6_V3l*Egf0~fUTgGOTK01Wwq=Hll7 zv;LqQew|z6z_LH+kehqKLw;D|z=1!=<)-E_7#?tHg#!hDP?3Lo`R8d5rxrMH<`44t zyM?OfJ)Ed>pd1F2#Z=9GP82v|P!R;A?@AoOD|10Wy2r612MY3I??<}Ju>wbM>~kO{ zxk?;Z5_~!Yq;6al4$Sz2h9L||g#%CgL9KXUNGhDbpC5)jg3Bs%z`+E8ra(Z_@_AVD8UxC`a)B9kfDtuZ1k06{i}r|3!IK9%a=B` zm0wme>Ut`{B3iwoNoRpKMv15u8P!~Irui7@Be6nCe+isnmwIyOv$rPiW1R}pJl5#7 ze~}=?Bs-J|>H>!eI@B%_2&RQ0W?ANd0%w#db4Gy!mYCr&w{)&r=uZRG05w3r0iX6C U;Qs5}NdN!<07*qoM6N<$g0@~ukN^Mx literal 0 HcmV?d00001 diff --git a/Samples/CameraView/Assets/flash_off.png b/Samples/CameraView/Assets/flash_off.png new file mode 100644 index 0000000000000000000000000000000000000000..3cf30f3eaa180a72589ef45700b0a681b978d287 GIT binary patch literal 485 zcmVJ5C-5uA{{kcAlxAIE)iV_Zv=-xoPdhl0a1b?BpO8T3ULEOMS(;OC0W8xvqJmu z#?G#HW{Uk=kCIQ`@mMD6(xr=Yxipdoz2QfU2 zYZ9aa=LNmoDnF?J+AOUfFq3ke2WQ1TD=GK(>Q~fok}`jEIj3q5Nv86K1LS#oWk`2e z<^Y{~D|eB!&iMyDhrGS8gWHxlDd-m)q$L1=Yc(7q0AE;@pADswL00000NkvXXu0mjfyO+}u literal 0 HcmV?d00001 diff --git a/Samples/CameraView/Assets/flash_on.png b/Samples/CameraView/Assets/flash_on.png new file mode 100644 index 0000000000000000000000000000000000000000..4e116af49eb011a1832a6b72de365f15ab9f4631 GIT binary patch literal 318 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY0wn)GsXoKNz{u+9;uuoF`1b0;iH8zITpvmc zO3r7ybm-Oc%qFdjCbb~ef014bm~8kqr>jm&Y@ez8uUPuWowFGxpN>2?tt@}|w>EC4 zgKx}&qQ+S}9G)_n7B-$@&3eQ%mHWyORxR-ro!lXM0m9-dViu_B1)wSPVyIf&&HW{% zxbfT(mR*~7IJhS<#m@9u5MS59xkXs`#lc^!7wkLKlbG(#h+V*J*r<1erE1eohjgGo zWXu9(!^U+!Y8PJbRar21h68_?_zM@G1=5?jOBB>Dw9atwHxqy1y zDuP#FBS9M!QcYr?x(Xj5^OKhEOrZ0;%Xt?M^PS1$oUvkJVg?bG2*VOq|FP&lUkJx< zKARBwK%20%c&{z=j$iacgSVPOZ>ZBRKY6Vs^pYxn!v)X(MaU+{KDTId#}NxSK|*6x zFv$sHenK`COmmFwEtDe)3f@BdM8ToA&@EBW@D_@SSjd>rJ=jul4hPAn$ZYd zQ(^?GM-r@1H!ZY@i{+CPWphGpzG8()mbM9@HXpGBsG>9Ms~`YLf6Qp{EBmWamEC4dDr!XN=Tg=UR*LRnyXqu_l$^Po#V$T zj`&?_>IiL%W{Dt*qP?plloe0b6+u)P>h$wELg`L#hA>QZ`WYP|H+WzkLrdxi*`3}7 zVOSR<9(Dx^Vxd?l7V1BL0REY1s|}3R@&Et;07*qoM6N<$f_%9k Avj6}9 literal 0 HcmV?d00001 diff --git a/Samples/CameraView/Assets/videocam.png b/Samples/CameraView/Assets/videocam.png new file mode 100644 index 0000000000000000000000000000000000000000..44c28e2f2830f927973beaa3a143ddfe439f20ed GIT binary patch literal 234 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY0wn)GsXhawHhQ`^hEy=Vyh zQBv~(_A|Uaeg>M$g-&EJ3;(E>F0WfsuqEq@i4qW8@}AzdO6rx>m9XRe^SrNqJ^A{6 z_JW14-f=$P%=XJsxKGL9nM=c&PKKGnj7I8ADSj*`=EzL26jUe%O0+bb;bi0#P;hAY zVbJ!!)MT - - var Observable = require("FuseJS/Observable"); - var FileSystem = require("FuseJS/FileSystem"); - - var path = FileSystem.dataDirectory + "/"; - var library = Observable(); - var image = Observable(""); - - var flashIsOn = Observable(false); - - var imageObject = {}; - - function takePicture() { - cameraPanel.takePicture({callback: function(err, img) { - if (img !== null) { - imageObject = img; - image.value = img.path; - } - }}); - } - - function reset() { - image.value = ""; - flashIsOn.value = false; - } - - function savePicture() { - var dest = path + imageObject.name; - FileSystem.copySync(imageObject.path, dest); - library.add(dest); - reset(); - } - - function swapCamera() { - cameraPanel.swapCamera(); - } - - function toggleFlash() { - flashIsOn.value = ! flashIsOn.value; - if (flashIsOn.value) { - cameraPanel.enableFlash(); - } else { - cameraPanel.disableFlash(); - } - } - - module.exports = { - library: library, - image: image, - takePicture: takePicture, - reset: reset, - savePicture: savePicture, - swapCamera: swapCamera, - cameraDirection: cameraPanel.CurrentCameraDirection.map(function(x) { - return x.substr(0,1); - }), - toggleFlash: toggleFlash, - flashState: flashIsOn.map(function(x) { - var res = "Flash: "; - if (x) { - res += "On"; - } else { - res += "Off"; - } - return res; - }) - }; - + + + + + + + + + + - - - - - - - - - - - - - - - - - - + @@ -102,58 +27,88 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 4c8945309814769c40136c567b68d43024e551d4 Mon Sep 17 00:00:00 2001 From: Uldis Zeidurs Date: Tue, 4 Jul 2017 16:17:39 +0300 Subject: [PATCH 3/3] comments cleanup --- Samples/CameraView/MainView.ux | 1 - 1 file changed, 1 deletion(-) diff --git a/Samples/CameraView/MainView.ux b/Samples/CameraView/MainView.ux index 60ce19d..65bf67e 100644 --- a/Samples/CameraView/MainView.ux +++ b/Samples/CameraView/MainView.ux @@ -1,4 +1,3 @@ -