Guest User

Untitled

a guest
Jan 22nd, 2018
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.58 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. // Create a new section
  335.  
  336. var phones_section = Titanium.UI.createTableViewSection({});
  337.  
  338. // Create a custom phones title
  339.  
  340. var phones_title = Ti.UI.createView({height:'auto'});
  341.  
  342. // Create a custom phones label
  343.  
  344. var phones_title_label = Ti.UI.createLabel({
  345. top:5, bottom:6, left:20,
  346. height:'auto',
  347. text:'Phones',
  348. color: '#333',
  349. shadowColor: '#fff',
  350. shadowOffset: {x:0, y:1},
  351. font:{fontSize:16, fontWeight:'bold'}
  352. });
  353.  
  354. // Create the add phone label
  355.  
  356. var phones_add_label = Titanium.UI.createLabel({
  357. width:'auto',
  358. height:'auto',
  359. top: 5,
  360. right: 10,
  361. bottom: 5,
  362. text: 'Add',
  363. color: '#333',
  364. shadowColor: '#fff',
  365. shadowOffset: {x:0, y:1},
  366. font:{fontSize:14, fontWeight: 'bold'}
  367. });
  368.  
  369. // Add the label to the phones title
  370.  
  371. phones_title.add(phones_title_label);
  372.  
  373. // Add the custom header to the section
  374.  
  375. phones_section.headerView = phones_title;
  376.  
  377. for (var i = 0; i < 5; i++)
  378. {
  379. // Create a row for the section
  380.  
  381. var row = Titanium.UI.createTableViewRow({
  382. header: 'Phones',
  383. height: 50,
  384. backgroundColor: 'transparent',
  385. color: '#000',
  386. opacity: 0.5,
  387. selectedBackgroundColor: '#ddd', hasChild: true});
  388.  
  389. // Create the title label
  390.  
  391. var desc = Titanium.UI.createLabel({
  392. text: 'Mobile',
  393. font: {fontSize: 16,fontWeight: 'bold'},
  394. height: 16,
  395. left: 9,
  396. top: 8,
  397. width: 'auto',
  398. textAlign: 'left',
  399. color: '#333',
  400. shadowColor: '#fff',
  401. shadowOffset: {x:0, y:1}
  402. });
  403.  
  404. // Create the value label
  405.  
  406. var value = Titanium.UI.createLabel({
  407. text: '+46 303044402',
  408. font: {fontSize: 12,fontWeight: 'normal'},
  409. height: 12,
  410. left: 9,
  411. top: 30,
  412. width: 'auto',
  413. textAlign: 'left',
  414. color: '#888',
  415. shadowColor: '#fff',
  416. shadowOffset: {x:0, y:1}
  417. });
  418.  
  419. // Add the desc to the row
  420.  
  421. row.add(desc);
  422.  
  423. // Add the value to the row
  424.  
  425. row.add(value);
  426.  
  427. // Add the row to the section
  428.  
  429. phones_section.add(row);
  430. }
  431.  
  432. // Get the section from the other file
  433.  
  434. var section = loadPhones();
  435.  
  436. // Add sections to the table
  437.  
  438. table.setData([section]);
  439.  
  440. // Create the profile message event listener
  441.  
  442. profile_message.addEventListener('click', function()
  443. {
  444. // Create the new window
  445.  
  446. var win = Titanium.UI.createWindow({
  447. url:'../profile/lifestream.js',
  448. title:'Lifestream',
  449. barColor: '#f09'
  450. });
  451.  
  452. // Animate the page turn
  453.  
  454. Titanium.UI.currentTab.open(win);
  455.  
  456. });
  457.  
  458. // Create the button delete event listener
  459.  
  460. button_delete.addEventListener('click', function()
  461. {
  462. // Create the new window
  463.  
  464. alert("Removing the contact");
  465.  
  466. });
  467.  
  468. // Create the tags event listener
  469.  
  470. tags.addEventListener('click', function()
  471. {
  472. // Create the new window
  473.  
  474. var win = Titanium.UI.createWindow({
  475. url:'../profile/tags.js',
  476. title:'People with #tag',
  477. barColor: '#f09'
  478. });
  479.  
  480. // Animate the page turn
  481.  
  482. Titanium.UI.currentTab.open(win);
  483.  
  484. });
  485.  
  486. // Add table to the container view
  487.  
  488. container.add(table);
  489.  
  490. // Add dropshadow view to the window
  491.  
  492. window.add(dropshadow);
  493.  
  494. // Add main view to the window
  495.  
  496. window.add(main);
  497.  
  498. // Add scrollview to the window
  499.  
  500. window.add(scrollView);
  501.  
  502. // Add container view to the window
  503.  
  504. window.add(container);
Add Comment
Please, Sign In to add comment