Guest User

Untitled

a guest
Apr 24th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function ModalPicker() {
  2.  
  3.     var self = this;
  4.  
  5.     this.cover = Titanium.UI.createWindow({
  6.         backgroundColor: "#fff",
  7.         opacity: 0.3,
  8.         fullscreen: true,
  9.         height: Titanium.Platform.displayCaps.platformHeight,
  10.         bottom: 0,
  11.         zIndex: 1000
  12.     });
  13.  
  14.     this.picker_view = Titanium.UI.createView({
  15.         height: 251,
  16.         bottom: -251,
  17.         zIndex: 1010
  18.     });
  19.  
  20.     this.cancel = Titanium.UI.createButton({
  21.         title: 'Cancel',
  22.         /* TODO: Fix this */
  23.         style: Titanium.UI.iPhone.SystemButtonStyle.BORDERED,
  24.         zIndex: 1020
  25.     });
  26.  
  27.     this.done = Titanium.UI.createButton({
  28.         title: 'Done',
  29.         /* TODO: Fix this */
  30.         style: Titanium.UI.iPhone.SystemButtonStyle.DONE,
  31.         zIndex: 1020
  32.     });
  33.  
  34.     this.spacer = Titanium.UI.createButton({
  35.         /* TODO: Fix this */
  36.         systemButton: Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE,
  37.         zIndex: 1020
  38.     });
  39.  
  40.     this.picker = Ti.UI.createPicker({
  41.         top: 43
  42.     });
  43.  
  44.     this.slide_in = Titanium.UI.createAnimation({
  45.         bottom: 0
  46.     });
  47.  
  48.     this.slide_out = Titanium.UI.createAnimation({
  49.         bottom: -251
  50.     });
  51.  
  52.     this.init = function () {
  53.  
  54.         tt.ui.View.add(self.cover);
  55.         self.cover.hide();
  56.         self.picker.selectionIndicator = true;
  57.         self.picker_view.add(self.picker);
  58.  
  59.         self.toolbar = Titanium.UI.createToolbar({
  60.             top: 0,
  61.             items: [self.cancel, self.spacer, self.done]
  62.         });
  63.  
  64.         self.picker_view.add(self.toolbar);
  65.  
  66.         self.cancel.addEventListener('click', function (e) {
  67.             self.cover.hide();
  68.             self.picker_view.animate(self.slide_out);
  69.         });
  70.  
  71.         tt.ui.View.add(self.picker_view);
  72.  
  73.     }
  74.  
  75.     this.show = function (params) {
  76.  
  77.         self.picker.columns = [];
  78.         self.picker.add(params.data);
  79.  
  80.         if (self.done.lastEventListener) {
  81.             self.done.removeEventListener('click', self.done.lastEventListener);
  82.         }
  83.  
  84.         self.done.lastEventListener = params.on_select;
  85.         self.done.addEventListener('click', params.on_select);
  86.  
  87.         self.cover.show();
  88.         self.picker_view.animate(self.slide_in);
  89.  
  90.     }
  91.  
  92.     this.hide = function () {
  93.         self.cover.hide();
  94.         self.picker_view.animate(self.slide_out);
  95.     }
  96.  
  97. }
Add Comment
Please, Sign In to add comment