Guest User

Untitled

a guest
Jan 22nd, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.65 KB | None | 0 0
  1. // Set the current window
  2.  
  3. var window = Titanium.UI.currentWindow;
  4.  
  5. // Include the API file
  6.  
  7. Ti.include("public_api.js");
  8.  
  9. // Create the delete button
  10.  
  11. var button_delete = Titanium.UI.createButton({
  12. title: 'Delete'
  13. });
  14.  
  15. // Add the add button to the navigation
  16.  
  17. window.setRightNavButton(button_delete);
  18.  
  19. // Create the main view
  20.  
  21. var main = Titanium.UI.createView({
  22. width: 320,
  23. height: 90
  24. });
  25.  
  26. // Create the profile view
  27.  
  28. var profile = Titanium.UI.createView({
  29. width: 320,
  30. height: 90,
  31. backgroundImage:'../images/1.png'
  32. });
  33.  
  34. // Create the avatar view
  35.  
  36. var profile_avatar = Titanium.UI.createImageView({
  37. image:'../images/avatar.jpg',
  38. left: 20,
  39. top: 20,
  40. width: 48,
  41. height: 48,
  42. borderRadius: 5
  43. });
  44.  
  45. profile.add(profile_avatar);
  46.  
  47. // Create the fullname label
  48.  
  49. var profile_fullname = Titanium.UI.createLabel({
  50. text:'Petter Palander',
  51. font:{fontSize: 16,fontWeight: 'bold'},
  52. width: 'auto',
  53. textAlign: 'left',
  54. top: 18,
  55. left: 78,
  56. height: 18
  57. });
  58.  
  59. profile.add(profile_fullname);
  60.  
  61. // Create the status message
  62.  
  63. var profile_message = Titanium.UI.createLabel({
  64. text: 'I had a very shiny day and it was all good and then we saw the light yes sir!',
  65. color: '#333',
  66. font: {fontSize: 12,fontWeight: 'normal'},
  67. width: 200,
  68. textAlign: 'left',
  69. top: 32,
  70. left: 78,
  71. height: 40
  72. });
  73.  
  74. profile.add(profile_message);
  75.  
  76. // Create the profile view
  77.  
  78. var message = Titanium.UI.createView({
  79. width: 320,
  80. height: 90,
  81. backgroundImage:'../images/1.png'
  82. });
  83.  
  84. // Create the avatar view
  85.  
  86. var message_avatar = Titanium.UI.createImageView({
  87. image:'../images/appicon.png',
  88. left: 20,
  89. top: 20,
  90. width: 48,
  91. height: 48,
  92. borderRadius: 5
  93. });
  94.  
  95. message.add(message_avatar);
  96.  
  97. // Create the title label
  98.  
  99. var message_title = Titanium.UI.createLabel({
  100. text:'Latest message',
  101. font:{fontSize: 16,fontWeight: 'bold'},
  102. width: 'auto',
  103. textAlign: 'left',
  104. top: 18,
  105. left: 78,
  106. height: 18
  107. });
  108.  
  109. message.add(message_title);
  110.  
  111. // Create the status message
  112.  
  113. var message_message = Titanium.UI.createLabel({
  114. text: 'Working hard to get the ambadoo iPhone app to the app store.',
  115. color: '#333',
  116. font: {fontSize: 12,fontWeight: 'normal'},
  117. width: 200,
  118. textAlign: 'left',
  119. top: 32,
  120. left: 78,
  121. height: 40
  122. });
  123.  
  124. message.add(message_message);
  125.  
  126. // Create the bio view
  127.  
  128. var bio = Titanium.UI.createView({
  129. width: 320,
  130. height: 90,
  131. backgroundImage:'../images/1.png'
  132. });
  133.  
  134. // Create the about label
  135.  
  136. var bio_about = Titanium.UI.createLabel({
  137. text:'About',
  138. font:{fontSize: 16,fontWeight: 'bold'},
  139. width: 'auto',
  140. textAlign: 'left',
  141. top: 18,
  142. left: 20,
  143. height: 18
  144. });
  145.  
  146. bio.add(bio_about);
  147.  
  148. // Create the bio message
  149.  
  150. var bio_message = Titanium.UI.createLabel({
  151. text: 'This is a cool text about me!',
  152. color: '#333',
  153. font: {fontSize: 12,fontWeight: 'normal'},
  154. width: 200,
  155. textAlign: 'left',
  156. top: 24,
  157. left: 20,
  158. height: 40
  159. });
  160.  
  161. bio.add(bio_message);
  162.  
  163. // Create the scrollview
  164.  
  165. var scrollView = Titanium.UI.createScrollableView({
  166. views:[profile,message,bio],
  167. showPagingControl:true,
  168. pagingControlColor: '#333',
  169. clipViews:true,
  170. top:0,
  171. left:0,
  172. right:0,
  173. height:90,
  174. opacity:1
  175. });
  176.  
  177. // Animate scrollview
  178.  
  179. scrollView.animate({
  180. opacity:1,
  181. duration:500
  182. });
  183.  
  184. // Create drop shadow for main view
  185.  
  186. var dropshadow = Titanium.UI.createImageView({
  187. image: '../images/dropshadow.png',
  188. top: 100,
  189. width: 320,
  190. height: 14,
  191. zIndex: 10
  192. });
  193.  
  194. // Create the container for the contact information
  195.  
  196. var container = Titanium.UI.createScrollView({
  197. contentWidth: 'auto',
  198. contentHeight: 'auto',
  199. top: 100,
  200. showVerticalScrollIndicator: true,
  201. showHorizontalScrollIndicator: false
  202.  
  203. });
  204.  
  205. // Create the current position map
  206.  
  207. var cp_map = Titanium.Map.createView({
  208. mapType: Titanium.Map.STANDARD_TYPE,
  209. region: {
  210. latitude: 5.345,
  211. longitude: 100.30442344,
  212. latitudeDelta: 0.5,
  213. longitudeDelta: 0.5,
  214. animate: false,
  215. regionFit: true,
  216. userLocation: true
  217. },
  218. width: 300,
  219. height: 70,
  220. top: 15,
  221. left: 10,
  222. borderRadius: 5,
  223. borderWidth: 1,
  224. borderColor: '#999'
  225. });
  226.  
  227. // Create the map label
  228.  
  229. var cp_label = Titanium.UI.createLabel({
  230. text: 'Hydro Hotel, Penang',
  231. font: {fontSize: 12,fontWeight: 'bold'},
  232. width: 'auto',
  233. height: '14',
  234. top: 90,
  235. left: 20,
  236. textAlign: 'left',
  237. color: '#222',
  238. shadowColor: '#fff',
  239. shadowOffset: {x:0, y:1}
  240. });
  241.  
  242. // Map Overlay Hack to be albe to click the map for big view. There's probably a better way to do this.
  243.  
  244. var cp_overlay = Titanium.UI.createView({
  245. width: 300,
  246. height: 70,
  247. top: 15,
  248. left: 10,
  249. zIndex: 2
  250. });
  251.  
  252. // Creat the window to display the full map
  253.  
  254. var mapview = Titanium.UI.createWindow({
  255. title: 'Location on map',
  256. backgroundColor: '#eee',
  257. barColor: '#f09',
  258. tabBarHidden: true,
  259. url: 'map.js'
  260. });
  261.  
  262. // Click Map to open Full Screen Map View
  263.  
  264. cp_overlay.addEventListener('click', function(e){
  265. Titanium.UI.currentTab.open(mapview,{animated:true});
  266. });
  267.  
  268. // Create the tag labels
  269.  
  270. var tags = Titanium.UI.createLabel({
  271. text: 'sswc, iphone, apple, sweden, stockholm, developer, css, javascript',
  272. font: {fontSize: 14,fontWeight: 'bold'},
  273. top: 0,
  274. left: 20,
  275. height: 'auto',
  276. width: 300,
  277. color: '#444',
  278. shadowColor: '#fff',
  279. shadowOffset: {x:0, y:1},
  280. textAlign: 'left'
  281. });
  282.  
  283. // Create the lastUpdated label
  284.  
  285. var lastUpdated = Titanium.UI.createLabel({
  286. text: 'Last Updated: 14/3/2011 11:34',
  287. font: {fontSize: 13,fontWeight: 'normal'},
  288. top: 30,
  289. height: 33,
  290. width: 320,
  291. color: '#444',
  292. shadowColor: '#fff',
  293. shadowOffset: {x:0, y:1},
  294. textAlign: 'center'
  295. });
  296.  
  297. // Create the table header view
  298.  
  299. var headerView = Ti.UI.createView({
  300. height:110
  301. });
  302.  
  303. // Create the table footer view
  304.  
  305. var footerView = Ti.UI.createView({
  306. height:60
  307. });
  308.  
  309. // Add labels to header view
  310.  
  311. headerView.add(cp_map);
  312. headerView.add(cp_label);
  313. headerView.add(cp_overlay);
  314.  
  315. // Add labels to footer view
  316.  
  317. footerView.add(tags);
  318. footerView.add(lastUpdated);
  319.  
  320. // Create the main table
  321.  
  322. var table = Titanium.UI.createTableView({
  323. opacity: 1,
  324. width:320,
  325. backgroundColor:'transparent',
  326. separatorStyle:Ti.UI.iPhone.TableViewSeparatorStyle.NONE,
  327. style: Titanium.UI.iPhone.TableViewStyle.GROUPED,
  328. headerView:headerView,
  329. footerView:footerView,
  330. scrollable: true,
  331. editable: true
  332. });
  333.  
  334. // Get the section from the other file
  335.  
  336. var section = loadPhones();
  337.  
  338. // Add sections to the table
  339.  
  340. table.setData([section]);
  341.  
  342. // Create the profile message event listener
  343.  
  344. profile_message.addEventListener('click', function()
  345. {
  346. // Create the new window
  347.  
  348. var win = Titanium.UI.createWindow({
  349. url:'../profile/lifestream.js',
  350. title:'Lifestream',
  351. barColor: '#f09'
  352. });
  353.  
  354. // Animate the page turn
  355.  
  356. Titanium.UI.currentTab.open(win);
  357.  
  358. });
  359.  
  360. // Create the button delete event listener
  361.  
  362. button_delete.addEventListener('click', function()
  363. {
  364. // Create the new window
  365.  
  366. alert("Removing the contact");
  367.  
  368. });
  369.  
  370. // Create the tags event listener
  371.  
  372. tags.addEventListener('click', function()
  373. {
  374. // Create the new window
  375.  
  376. var win = Titanium.UI.createWindow({
  377. url:'../profile/tags.js',
  378. title:'People with #tag',
  379. barColor: '#f09'
  380. });
  381.  
  382. // Animate the page turn
  383.  
  384. Titanium.UI.currentTab.open(win);
  385.  
  386. });
  387.  
  388. // Add table to the container view
  389.  
  390. container.add(table);
  391.  
  392. // Add dropshadow view to the window
  393.  
  394. window.add(dropshadow);
  395.  
  396. // Add main view to the window
  397.  
  398. window.add(main);
  399.  
  400. // Add scrollview to the window
  401.  
  402. window.add(scrollView);
  403.  
  404. // Add container view to the window
  405.  
  406. window.add(container);
Add Comment
Please, Sign In to add comment