Advertisement
thewarpedcoder

USer Case Titanium Camera Overlay

Jun 21st, 2011
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. // All source code open Source Copyright 2011
  2. // Code submitted by thewarpedcoder .... trevor@thewarpedcoder.net
  3.  
  4. /* The purpose of the user cases is to define instances of issues / bugs
  5. * with the applications I code.
  6. *
  7. * This user case uses nameSpaces as this is how the main application works,
  8. * and also opens and closes windows as required. It does not have a window
  9. * stack.
  10. */
  11.  
  12. Ti.UI.setBackgroundColor('#ffffff');
  13.  
  14. // Define the NameSpaces
  15. var mainNS = {};
  16. mainNS.event = {};
  17. mainNS.view = {};
  18. mainNS.tool = {};
  19.  
  20. (function()
  21. {
  22. // Events ....
  23. mainNS.event.loadCameraScreen = function(evt)
  24. {
  25. mainNS.view.loadCameraScreenWindow().open();
  26.  
  27. mainNS.view.showTheCamera();
  28. };
  29. mainNS.view.loadCameraScreenWindow = function()
  30. {
  31. var cameraScreenWin = Ti.UI.createWindow
  32. ({
  33. navBarHidden: true,
  34. backgroundColor: "#FFFFFF"
  35. });
  36. cameraScreenWin.addEventListener('close', function() { Ti.Media.hideCamera(); });
  37.  
  38. return cameraScreenWin;
  39. };
  40. mainNS.tool.appNavigationBar = function(evt)
  41. {
  42. var navigationBar = Ti.UI.createView
  43. ({
  44. bottom: 0,
  45. height: 50,
  46. right: 0,
  47. backgroundColor: "#000000",
  48. opacity: 0.75
  49. });
  50. var navBarTestBtn = Ti.UI.createView
  51. ({
  52. left: 5,
  53. width: 90,
  54. height: 50,
  55. top: 0,
  56. backgroundColor: "#000000",
  57. borderColor: "#FFFFFF",
  58. borderWidth: 2
  59. });
  60. var navBarTestBtnText = Ti.UI.createLabel
  61. ({
  62. width: 90,
  63. text: "TEST",
  64. color: "#FFFFFF",
  65. textAlign: 'center',
  66. font: {fontSize: 10}
  67. });
  68. navBarTestBtn.add(navBarTestBtnText);
  69. navigationBar.add(navBarTestBtn);
  70.  
  71. navBarTestBtn.addEventListener('click', function() {alert("IM A VIEW WITH A LISTENER");} );
  72.  
  73. return navigationBar;
  74. }
  75. mainNS.view.showTheCamera = function()
  76. {
  77. var displayVoucherOverlayView = Ti.UI.createView
  78. ({
  79. top: 0,
  80. bottom: 0,
  81. left: 0,
  82. right: 0,
  83. opacity: 0.75
  84. });
  85. var setAButton = Ti.UI.createButton
  86. ({
  87. top: 100,
  88. left: 30,
  89. right: 30,
  90. height: 75,
  91. title: "HELLO"
  92. });
  93. displayVoucherOverlayView.add(setAButton);
  94.  
  95. setAButton.addEventListener('click', function() { alert("I HAVE BEEN PRESSED");} );
  96.  
  97. var navBar = mainNS.tool.appNavigationBar({});
  98.  
  99. displayVoucherOverlayView.add(navBar);
  100.  
  101. var cameraTransform = Ti.UI.create2DMatrix();
  102. cameraTransform = cameraTransform.scale(2);
  103.  
  104. Ti.Media.showCamera
  105. ({
  106. success: function(event) {},
  107. cancel: function() {},
  108. error: function(error)
  109. {
  110. if (error.code == Ti.Media.NO_CAMERA)
  111. {
  112. alert("NO CAMERA");
  113. }
  114. else
  115. {
  116. alert("CAMERA ERROR");
  117. }
  118. },
  119. mediaTypes: [Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO],
  120. showControls: false,
  121. autohide: false,
  122. transform: cameraTransform,
  123. overlay: displayVoucherOverlayView
  124. });
  125. };
  126. // Initial Launch
  127. mainNS.event.loadCameraScreen({});
  128. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement