Jiggy Help-Please Look

Discussion in 'Jiggy Runtime Development' started by Brill301, Jun 16, 2008.

  1. Brill301

    Brill301 Member

    Joined:
    Dec 19, 2007
    Messages:
    441
    Likes Received:
    14
    Device:
    iPhone 4 (Black)
    Hello, so I am making an app for the iphone, it is going to have a bunch of directories that lead to links on the web, there will be a bunch of links and when you click the links they will open up in safari. [THE APP ITSELF IS NOT GOING TO LINK UP TO SAFARI]

    So I would like to get this

    Code:
    // d.d.d
    // /Applications/d.app/main.js
    Plugins.load( "UIKit" );
     
    var window = new UIWindow( UIHardware.fullScreenApplicationContentRect );
    window.setHidden( false );
    window.orderFront();
    window.makeKey();
    window.backgroundColor = [ 1 , 1 , 1 , 1 ];
    
     
    var mainView = new UIView();
     Plugins.load( "UIKit" );
    
    window.setContentView( mainView );
    
    // You have to define all the possible buttons for the bar in an array like this
    
    var buttons = 
    [
        {
            UIButtonBarButtonTag: 1,
            UIButtonBarButtonTitle: "Home",
            UIButtonBarButtonInfo: "BarAlbums.png",
            UIButtonBarButtonSelectedInfo: "BarAlbums_Sel.png",
            UIButtonBarButtonType: 0
        },
    
        {
            UIButtonBarButtonTag: 2,
            UIButtonBarButtonTitle: "Movies",
            UIButtonBarButtonInfo: "BarArtists.png",
            UIButtonBarButtonSelectedInfo: "BarArtists_Sel.png",
            UIButtonBarButtonType: 0
        },
    
        {
            UIButtonBarButtonTag: 3,
            UIButtonBarButtonTitle: "TV Shows",
            UIButtonBarButtonInfo: "BarAudioBooks.png",
            UIButtonBarButtonSelectedInfo: "BarAudioBooks_Sel.png",
            UIButtonBarButtonType: 0
        }
        
        
    ];
    
    // The button bar is created a bit differently - you pass in its
    // superview, its frame and the button definition.
    // You do not need to do mainView.addSubview( bb )
    
    var bb = new UIButtonBar( mainView , [ 0 , 0 , 320 , 60 ] , buttons );
    
    // Style 1 is the cool black one used in the iPod app. 0 is blue - like a 
    // navigation bar and 2 is gray.
    
    bb.barStyle = 1;
    
    // Now, you register a group of buttons - you give it a group number 
    // and an array of button tags. This lets you show entire groups easily
    
    bb.registerButtonGroup( 1 , [ 1 , 2 , 3 ] );
    
    // Show that group. The second parameter is a duration for a fading the
    // group in.
    
    bb.showButtonGroup( 1 , 1.0 );
    
    
    
    bb.showSelectionForButton( 1 );
    
    // This adds a "badge" to the button ( a red circle with the string you pass in)
    
    bb.setBadgeValue( 3 , "New" );
    
    // This animates the badge - it blinks
    
    bb.setBadgeAnimated( 3 , true );
    
    // The event when a button is pressed
    
    bb.onButtonPressed = function( bar , button )
    {
      // We select the button that was pressed
      
      bb.showSelectionForButton( button );
      
      log( "PRESSED BUTTON:" + button );      
      
      log( "SELECTED BUTTON:" + bb.selectedButton );
      
      /*
      // This automatically brings up a customize sheet that 
      // the user can use to re-arrange and add buttons.
      
      if ( button == 3 )
        bb.customize( [ 1 , 2 , 3 ] );
      */
      
      // This gives you an array of the currently visible buttons
      
      log( "VISIBLE BUTTONS:" + bb.getVisibleButtonTags().toSource() );
      
      // This is how you can remove the badge
      
      if ( button == 3 )
        bb.setBadgeValue( 3 , null );
      else
        bb.setBadgeValue( 3 , "New" );
    }
    

    How would I get writing inside those three subcategories at the top, I am making it sound confusing, but I would just like me to be able to write inside the dub categoreis ( i.e. inside of the 'home' button have it say, "welcome" or something....

    let me know if you do not understand, or if you can help...
  2. Brill301

    Brill301 Member

    Joined:
    Dec 19, 2007
    Messages:
    441
    Likes Received:
    14
    Device:
    iPhone 4 (Black)
    another question....

    another quick question- Doesnt have to do with the first question...
    Code:
    Plugins.load( "UIKit" );
    
    var itemOne = new UINavigationItem( "MovieTheater4iPhone" );
    var itemTwo = new UINavigationItem( "" );
    var about = new UIAlertSheet( "TITLE" , [ ] , 1 );
    about.setBodyText( "Main Text" );
    about.setAlertSheetStyle( 0 );
    about.onTap = function()
    {
    about.dismiss( true ); // Close Alert Sheet
    }
    var window = new UIWindow( UIHardware.fullScreenApplicationContentRect );
    window.setHidden( false );
    window.orderFront();
    window.makeKey();
    window.backgroundColor = [ 1 , 1 , 1 , 1 ];
    
    var tview = new UITransitionView( window.bounds );
    
    window.setContentView( tview );
    
    var bar = new UINavigationBar( [ 0 , 0 , window.bounds[ 2 ] , 44 ] );
    bar.showButtonsWithStyle( null , 0 , null , 0 );
    
    var setbar = new UINavigationBar( [ 0 , 0 , window.bounds[ 2 ] , 44 ] );
    setbar.showButtonsWithStyle( "BACK" , 2 , "NEXT", 0 );
    
    var ptable = new UIPreferencesTable( [ 0 , 44 , 320 , 460-44 ] , tview.bounds );
    
    ptable.onGetNumberOfGroups = function( tbl )
    {
      return 1;
    }
    
    ptable.onGetNumberOfRowsInGroup = function( tbl , group )
    {
      switch( group )
      {
        case 0 : return 1;
      }
    }
    
    ptable.onIsLabelGroup = function( tbl , group )
    {
      switch( group )
      {
        case 0 : return false;
      }
    }
    
    var titleCells = [];
    
    var titleCell;
    
    titleCell = new UIPreferencesTableCell();
    titleCell.title = "TV Shows";
    titleCell.title = "Movies";
    
    titleCells.push( titleCell );
    
    ptable.onGetCellForGroup = function( tbl , group )
    {
      if ( group >= 0 && group < titleCells.length )
        return titleCells[ group ];
      else
        return null;
    };
    
    ptable.onGetHeightForRow = function( tbl , group , row , proposedHeight )
    {
      if ( row == -1 )
      {
        return 40;
      }
      return proposedHeight;
    };
    
    ptable.onShowDisclosureForRow = function( tbl , row )
    {
      if ( row == 1)
      {
      return true;
      }
      else
      {
      return false;
      }
    }
    
    var cells = [ [] , [] , [] ];
    
    var cell;
    var control;
    
    cell = new UIPreferencesControlTableCell();
    cell.title = "Movies";
    cell.setEnabled( true );
    cell.showSelection = false;
    cells[0].push( cell );
    cell.onTap = function()
    {
    setbar.pushNavigationItem( itemTwo );
    tview.transitionFrom( 1 , blueView , redView );
    }
    
    
    ptable.onGetCell = 
      function( tbl , group , row )
      {
        return cells[ group ][ row ];
      };
      
    ptable.reloadData();
    
    
    var conftable = new UIPreferencesTable( [ 0 , 44 , 320 , 460-44 ] , tview.bounds );
    
    conftable.onGetNumberOfGroups = function( tbl )
    {
      return 1;
    }
    
    conftable.onGetNumberOfRowsInGroup = function( tbl , group )
    {
      switch( group )
      {
        case 0 : return 1;
      }
    }
    
    conftable.onIsLabelGroup = function( tbl , group )
    {
      switch( group )
      {
        case 0 : return false;
      }
    }
    
    var titleCellst = [];
    
    var titleCellt;
    
    titleCellt = new UIPreferencesTableCell();
    titleCellt.title = "Movies";
    
    titleCellst.push( titleCellt );
    
    conftable.onGetCellForGroup = function( tbl , group )
    {
      if ( group >= 0 && group < titleCells.length )
        return titleCellst[ group ];
      else
        return null;
    };
    
    conftable.onGetHeightForRow = function( tbl , group , row , proposedHeight )
    {
      if ( row == -1 )
      {
        return 40;
      }
    
      return proposedHeight;
    };
    
    conftable.onShowDisclosureForRow = function( tbl , row )
    {
      if ( row == 1)
      {
      return false;
      }
      else
      {
      return false;
      }
    }
    
    var tcells = [ [] , [] , [] ];
    
    var tcell;
    
    tcell = new UIPreferencesControlTableCell();
    tcell.title = "Page Two";
    tcell.setEnabled( true );
    tcell.showSelection = false;
    tcells[0].push( tcell );
    
    conftable.onGetCell = 
      function( tbl , group , row )
      {
        return tcells[ group ][ row ];
      };
      
    conftable.reloadData();
    
    var blueView = new UIView( tview.bounds );
    blueView.backgroundColor = [ 0 , 0 , 1 , 1 ];
    
    var redView = new UIView( tview.bounds );
    redView.backgroundColor = [ 1 , 0 , 0 , 1 ];
    
    tview.transition( 0 , blueView );
    
    blueView.addSubview( ptable );
    redView.addSubview( conftable );
    
    bar.pushNavigationItem( itemOne );
    setbar.pushNavigationItem( itemTwo );
     
    blueView.addSubview( bar );
    redView.addSubview( setbar );
    
    setbar.onButtonClicked = function( bar , button )
    {
      if ( button == 1 )
      {
      tview.transitionFrom( 2 , redView , blueView );
      blueView.addSubview( ptable );
      }
      {
      if ( button == 2 )
      {
      tview.transitionFrom( 2 , redView , blueView );
      blueView.addSubview( ptable );
      }
      }
      };
    
    how would I get the "page two" clickable and able to link up to the web?
  3. blackjak231

    blackjak231 Member

    Joined:
    Oct 1, 2007
    Messages:
    759
    Likes Received:
    6
    Device:
    iPhone 4 (White)
    I dont really get the first question, but i can surely help you with the second one!
    If by clickable you mean be able to click on it and having it open safari...etc, just do this in your conftable:

    Code:
    tcell = new UIPreferencesControlTableCell();
    tcell.title = "Page Two";
    tcell.setEnabled( true );
    tcell.showSelection = false;
    tcells[0].push( tcell );
    tcell.onTap = function( )
    {
      openURL("http://youradresshere.com");
    }
    
    This is just one cell, but basically, you just have to use the command " openURL("http://.....") "

    I hope it helped you!

Share This Page