/**
 * A place to save code that was created and useful, but is no longer part of the app
 * 
 * The app should never call code that is given here.
 */
package com.sharefaith.churchapp.stash;

import java.io.IOException;
import java.util.HashMap;
import java.util.Hashtable;

import com.codename1.ui.BrowserComponent;
import com.codename1.ui.Component;
import com.codename1.ui.Container;
import com.codename1.ui.Font;
import com.codename1.ui.Image;
import com.codename1.ui.Label;
import com.codename1.ui.TextArea;
import com.codename1.ui.layouts.BoxLayout;
import com.codename1.ui.list.DefaultListCellRenderer;
import com.codename1.ui.plaf.Border;
import com.codename1.ui.plaf.Style;
import com.codename1.ui.util.Resources;
import com.sharefaith.churchapp.ChurchApp;
import com.sharefaith.churchapp.views.WelcomeView;

public class SFStash
{
	/**
	 * Create a non-editable, scrollable textarea
	 * @return
	 */
	public Container textAreaPlacement()
	{
		Container returnContainer = new Container( new BoxLayout( BoxLayout.Y_AXIS ) );

		TextArea ta = new TextArea( "Content getter goes here" );
		ta.setEditable( false );
		
		Style taStyle = new Style();
		taStyle.setBorder( Border.createEmpty() );
		taStyle.setMargin( 5, 5, 5, 5 );

		// Uncomment these to use the default font in iOS 
		//Font taFont = Font.createSystemFont( Font.FACE_SYSTEM, Font.SIZE_MEDIUM, Font.STYLE_PLAIN );
		//if( ChurchApp.deviceInfo().get( "os" ).equals( "and" ) )
		//{
			Font taFont = Font.createTrueTypeFont( "Droid Sans", "DroidSans.ttf" );
			taFont = taFont.derive( 28, Font.STYLE_PLAIN );
		//}
		taStyle.setFont( taFont );
		
		ta.setSelectedStyle( taStyle );
		ta.setUnselectedStyle( taStyle );
		
		returnContainer.addComponent( ta );
		
		return returnContainer;
	}
	
	/**
	 * Uses the browser component
	 * @return
	 */
	public Container htmlComntainer()
	{
		Container returnContainer = new Container( new BoxLayout( BoxLayout.Y_AXIS ) );

		BrowserComponent bc = new BrowserComponent();
		
		String html = new String( "Some html here" );
		bc.setPage( html, "/" );
		
		Style bcStyle = new Style();
		bcStyle.setBorder( Border.createEmpty() );
		bcStyle.setMargin( 2, 2, 2, 2 );
		
		bc.setSelectedStyle( bcStyle );
		bc.setUnselectedStyle( bcStyle );
		returnContainer.addComponent( bc );
		
		return returnContainer;
	}
	
	/**
	 * Implementation of a DefaultListCellRenderer
	 * @return
	 */
	public class SermonsSeriesRenderer extends DefaultListCellRenderer<Object>
	{
		public Component getCellRendererComponent( Component list, Object model, Object value, int index, boolean isSelected )
		{	
	        Hashtable<String,String> element = (Hashtable<String,String>) value;
	        
	        Font elementFont = Font.createTrueTypeFont( "Droid Sans", "DroidSans.ttf" );
			elementFont = elementFont.derive( 24, Font.STYLE_PLAIN );
	        this.getStyle().setFont( elementFont );
	        
	        this.setPreferredH( 80 );
	        
	        return this;
	    }
	}
}
