public AudioRecorderPage()
        {
            NavigationPage.SetHasNavigationBar(this, false);
            CustomLayout masterLayout = new CustomLayout();
            masterLayout.HorizontalOptions = LayoutOptions.Center;
            masterLayout.BackgroundColor = Color.FromRgb(230, 255, 254);
            PurposeColorSubTitleBar subTitleBar = new PurposeColorSubTitleBar(Color.FromRgb(12, 113, 210), "Audio recorder", false);
            masterLayout.AddChildToLayout(subTitleBar, 0, Device.OnPlatform(2, 4, 4));

			PurposeColor.CustomControls.PurposeColorTitleBar titleBar = new PurposeColor.CustomControls.PurposeColorTitleBar(Color.FromRgb(8, 137, 216), "Purpose Color", Color.Black, "back", true);
            masterLayout.AddChildToLayout(titleBar, 0, 0);

            Button recordBtn = new Button
            {
                Text = "Record",
                VerticalOptions = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center
            };
            recordBtn.Clicked += RecordBtn_Clicked;
            masterLayout.AddChildToLayout(recordBtn, 10, 20);

            Button stopRecordBtn = new Button
            {
                Text = "Stop Recording",
                VerticalOptions = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center
            };
            stopRecordBtn.Clicked += StopRecordBtn_Clicked;
            masterLayout.AddChildToLayout(stopRecordBtn, 10, 30);


            Button PlaybackBtn = new Button
            {
                Text = "Playback",
                VerticalOptions = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center
            };
            PlaybackBtn.Clicked += PlaybackBtn_Clicked;
            masterLayout.AddChildToLayout(PlaybackBtn, 10, 40);




            Content = masterLayout;
        }
		public ProfileSettingsPage(int userId = 0)
		{
			NavigationPage.SetHasNavigationBar(this, false);
			masterLayout = new CustomLayout();
			masterLayout.BackgroundColor = Constants.PAGE_BG_COLOR_LIGHT_GRAY;
			subTitleBar = new PurposeColorSubTitleBar(Constants.SUB_TITLE_BG_COLOR, "       Profile Info", false, true);
			subTitleBar.BackButtonTapRecognizer.Tapped += (s, e) =>
			{
				try
				{
					Navigation.PopAsync();
				}
				catch (Exception ex)
				{
				}
			};

			mainTitleBar = new PurposeColorTitleBar(Color.FromRgb(8, 135, 224), "Purpose Color", Color.Black, "back", false);
			progressBar = DependencyService.Get<PurposeColor.interfaces.IProgressBar>();
			progressBar.ShowProgressbar ("Retriving user details..");

			try {
				currentUser = App.Settings.GetUser ();
			} catch (Exception ex) {
				
			}

			if (userId != 0) {
				userIdForProfileInfo = userId;
				// get user info from service.
			} 
			else 
			{
				if (currentUser == null) {
					return;
				}
				else
				{
					userInfo = currentUser;
				}
			}

			this.Appearing += ProfileSettingsPage_Appearing;
			progressBar.HideProgressbar ();
		}
		public CommunityMediaViewer ( List<PurposeColor.Constants.MediaDetails> mediaList )
		{
			NavigationPage.SetHasNavigationBar (this, false);
			masterLayout = new CustomLayout ();
			masterLayout.BackgroundColor = Color.Black;// Color.FromRgb(244, 244, 244);
			masterScroll = new ScrollView ();
			masterScroll.BackgroundColor = Color.Black;//Color.FromRgb(244, 244, 244);
			progressBar = DependencyService.Get<IProgressBar> ();

			mainTitleBar = new PurposeColorTitleBar (Color.FromRgb (8, 135, 224), "Purpose Color", Color.Black, "back", true);
			subTitleBar = new PurposeColorSubTitleBar (Constants.SUB_TITLE_BG_COLOR, "Gem Media Viewer", false);
			subTitleBar.BackButtonTapRecognizer.Tapped += async (object sender, EventArgs e) => {
				try {
					await Navigation.PopAsync ();
				} catch (Exception) {
				}
			};

			mainTitleBar.imageAreaTapGestureRecognizer.Tapped += (object sender, EventArgs e) => 
			{
				App.masterPage.IsPresented = !App.masterPage.IsPresented;
			};
				

			masterStack = new CustomLayout ();
			masterStack.BackgroundColor = Color.Transparent;
			masterStack.HorizontalOptions = LayoutOptions.Center;

			StackLayout bottomAndLowerControllStack = new StackLayout {
				Orientation = StackOrientation.Vertical,
				BackgroundColor = Color.Transparent,
				Spacing = 1,
				Padding = new Thickness (0, 5, 0, 5),
				WidthRequest = App.screenWidth,
			};


			ScrollView imgScrollView = new ScrollView ();
			imgScrollView.Orientation = ScrollOrientation.Horizontal;

			StackLayout horizmgConatiner = new StackLayout ();
			horizmgConatiner.Orientation = StackOrientation.Horizontal;


			CustomImageButton nextImg = new CustomImageButton ();
			nextImg.ImageName = "next.png";
			nextImg.WidthRequest = 40;
			nextImg.HeightRequest = 65;
				
			nextImg.Clicked += async (object sender, EventArgs e) => 
			{

				double curX = imgScrollView.ScrollX;
				double imgWidth = App.screenWidth * 100 / 100;

				if( Device.OS == TargetPlatform.iOS )
				{
					if( curX + imgWidth + 15 < imgScrollView.ContentSize.Width )
						await imgScrollView.ScrollToAsync( curX + imgWidth , 0, true );
				}
				else
				{
					await imgScrollView.ScrollToAsync( curX + imgWidth , 0, true );
				}
					
			};


			CustomImageButton prevImg = new CustomImageButton ();
			prevImg.ImageName = "prev.png";
			prevImg.WidthRequest = 40;
			prevImg.HeightRequest = 65;
			prevImg.Clicked += async (object sender, EventArgs e) => 
			{
				double curX = imgScrollView.ScrollX;
				double imgWidth = App.screenWidth * 90 / 100;
				if( curX > 0 )
				await imgScrollView.ScrollToAsync( curX - App.screenWidth , 0, true );
			};


			#region MEDIA LIST

			if (mediaList != null) 
			{
				foreach (var item in mediaList) 
				{
					TapGestureRecognizer videoTap = new TapGestureRecognizer ();
					videoTap.Tapped += OnActionVideoTapped;

					Image img = new Image ();
					bool isValidUrl = ( item.Url != null && !string.IsNullOrEmpty ( item.Url )) ? true : false;
					string source = (isValidUrl) ? item.Url : Device.OnPlatform ("noimage.png", "noimage.png", "//Assets//noimage.png");
					string fileExtenstion = Path.GetExtension (source);
					bool isImage = (fileExtenstion == ".png" || fileExtenstion == ".jpg" || fileExtenstion == ".jpeg") ? true : false;
					img.WidthRequest = App.screenWidth;
					img.HeightRequest = App.screenWidth;
					img.Aspect = Aspect.AspectFill;
					img.ClassId = null;
					if (item != null && item.MediaType == "mp4") 
					{
						img.ClassId = source;
						source = Constants.SERVICE_BASE_URL + item.ImageName;
					}
					else if ( item != null &&  item.MediaType == "aac")
					{
						img.ClassId = source;
						source = Device.OnPlatform ("audio.png", "audio.png", "//Assets//audio.png");
					}
					else if ( item != null &&  item.MediaType == "3gpp")
					{
						img.ClassId = source;
						source = Constants.SERVICE_BASE_URL + item.ImageName;
					}
					else if ( item != null && item.MediaType == "wav")
					{
						img.ClassId = source;
						source = Device.OnPlatform ("audio.png", "audio.png", "//Assets//audio.png");
					}
					img.Source = source;
					img.GestureRecognizers.Add (videoTap);
					var indicator = new ActivityIndicator { Color = new Color (.5), };
					indicator.SetBinding (ActivityIndicator.IsRunningProperty, "IsLoading");
					indicator.BindingContext = img;
					masterStack.AddChildToLayout (indicator, 40, 30);

					if (item != null && ( item.MediaType == "mp4" || item.MediaType == "3gpp" ) )
					{
						Grid grid = new Grid
						{
							VerticalOptions = LayoutOptions.FillAndExpand,
							HorizontalOptions = LayoutOptions.FillAndExpand,
							RowDefinitions = 
							{
								new RowDefinition { Height = new GridLength( img.WidthRequest / 3 ) },
								new RowDefinition { Height = new GridLength( img.WidthRequest / 3 ) },
								new RowDefinition { Height = new GridLength( img.WidthRequest / 3 ) },

							},
							ColumnDefinitions = 
							{
								new ColumnDefinition { Width = new GridLength( img.WidthRequest / 3 ) },
								new ColumnDefinition { Width = new GridLength( img.WidthRequest / 3 ) },
								new ColumnDefinition { Width = new GridLength( img.WidthRequest / 3 ) },

							}
						};

						Image play = new Image();
						play.Source = "video_play.png";
						play.Aspect = Aspect.AspectFit;
						play.WidthRequest = 75;
						play.HeightRequest = 75;
						play.HorizontalOptions = LayoutOptions.Center;
						play.VerticalOptions = LayoutOptions.Center;
						play.ClassId =  img.ClassId;
						play.GestureRecognizers.Add(videoTap);

						grid.Children.Add( img, 0, 0 );
						Grid.SetColumnSpan(img, 3);
						Grid.SetRowSpan( img, 3 );
						grid.Children.Add(play, 1, 1);
						horizmgConatiner.Children.Add(grid);
					}
					else
					{
						horizmgConatiner.Children.Add(img);
					}
				}
				imgScrollView.Content = horizmgConatiner;
				bottomAndLowerControllStack.Children.Add (imgScrollView);

			}

			#endregion

			masterStack.AddChildToLayout (bottomAndLowerControllStack, 0, Device.OnPlatform (5, 9, 12));//12
			masterScroll.HeightRequest = App.screenHeight - 20;
			masterScroll.WidthRequest = App.screenWidth;// * 90 / 100;

			StackLayout masterStackLayout = new StackLayout ();
			masterStackLayout.HorizontalOptions = LayoutOptions.Center;
			masterStackLayout.BackgroundColor = Color.Black;
			masterStackLayout.Orientation = StackOrientation.Vertical;
			masterStackLayout.Children.Add (masterStack);
			masterScroll.Content = masterStackLayout;
			masterLayout.AddChildToLayout (mainTitleBar, 0, 0);
			masterLayout.AddChildToLayout (subTitleBar, 0, Device.OnPlatform (9, 10, 10));
			masterLayout.AddChildToLayout (masterScroll, 0, 18);
			masterLayout.AddChildToLayout (prevImg, Device.OnPlatform( -2, -2, 0 ), 50);
			masterLayout.AddChildToLayout (nextImg, 90, 50);
			Content = masterLayout;
		}
		public void Dispose()
		{
			this.statusEntry = null;
			userInfo = null;
			masterLayout = null;
			galleryInputStackTapRecognizer = null;
			galleryInputStack = null;
			galleryInput = null;
			profilePic = null;
			progressBar = null;
			userProfile = null;
			mainTitleBar = null;
			subTitleBar = null;
			CommunitySharingLabel= null;
			communityShareIcon = null;
			communityStatusBtn = null;
			User currentUser = null;

			GC.Collect();
		}
        public void Dispose()
        {
            this.mainTitleBar.imageAreaTapGestureRecognizer.Tapped -= imageAreaTapGestureRecognizer_Tapped;
            this.mainTitleBar = null;
            this.subTitleBar.BackButtonTapRecognizer.Tapped -= OnBackButtonTapRecognizerTapped;
            this.subTitleBar.NextButtonTapRecognizer.Tapped -= NextButtonTapRecognizer_Tapped;
            this.Appearing -= FeelingNowPage_Appearing;
            this.goalsAndDreamsPickerButton.Clicked -= OnGoalsPickerButtonClicked;
            this.goalsAndDreamsPickerButton = null;
            this.actionPickerButton.Clicked -= OnActionPickerButtonClicked;
            this.actionPickerButton = null;
            this.subTitleBar = null;
            this.masterLayout = null;
            // this.deviceSpec = null;
            actionPreviewListSource.Clear();
            actionPreviewListSource = null;
            this.actionPreviewListView = null;
            this.listContainer = null;
            this.slider = null;
            this.selectedGoal = null;
            this.selectedActions = null;

            GC.Collect();
        }
        public CommunityGemsPage()
        {
            NavigationPage.SetHasNavigationBar(this, false);
            CustomLayout masterLayout = new CustomLayout();
            masterLayout.BackgroundColor = Color.FromRgb(230, 255, 254);

            PurposeColorTitleBar titleBar = new PurposeColorTitleBar(Color.FromRgb(8, 137, 216), "Purpose Color", Color.Black, "back");
            PurposeColorSubTitleBar subTitleBar = new PurposeColorSubTitleBar(Color.FromRgb(12, 113, 210), "Emotional Awareness");

            gemsSource = new List<Gems>();

            Gems gemItems = new Gems();
            gemItems.ArrowImage = "";
            gemItems.DateInfo = "2015 Janury 30";
            gemItems.GemImage = Device.OnPlatform("manali.jpg", "manali.jpg", "//Assets//manali.jpg");
            gemItems.Name = "Lance Clusner";
            gemItems.ProfilePhoto = Device.OnPlatform("avatar.jpg", "avatar.jpg", "//Assets//avatar.jpg"); 
            gemItems.GemInfo = "This is just a dummy page to check how it displays in mobile devices. below picture is taken from manali. Manali is a high-altitude Himalayan resort town in India’s northern Himachal Pradesh state. It has a reputation as a backpacking center and honeymoon destination. Set on the Beas River, it’s a gateway for skiing in the Solang Valley and trekking in Parvati Valley. It's also a jumping-off point for paragliding, rafting and mountaineering in the Pir Panjal mountains, home to 4,000m-high Rohtang Pass..Manali is a high-altitude Himalayan resort town in India’s northern Himachal Pradesh state. It has a reputation as a backpacking center and honeymoon destination. Set on the Beas River, it’s a gateway for skiing in the Solang Valley and trekking in Parvati Valley. It's also a jumping-off point for paragliding, rafting and mountaineering in the Pir Panjal mountains, home to 4,000m-high Rohtang Pass.Manali is a high-altitude Himalayan resort town in India’s northern Himachal Pradesh state. It has a reputation as a backpacking center and honeymoon destination. Set on the Beas River, it’s a gateway for skiing in the Solang Valley and trekking in Parvati Valley. It's also a jumping-off point for paragliding, rafting and mountaineering in the Pir Panjal mountains, home to 4,000m-high Rohtang Pass..Manali is a high-altitude Himalayan resort town in India’s northern Himachal Pradesh state. It has a reputation as a backpacking center and honeymoon destination. Set on the Beas River, it’s a gateway for skiing in the Solang Valley and trekking in Parvati Valley. It's also a jumping-off point for paragliding, rafting and mountaineering in the Pir Panjal mountains, home to 4,000m-high Rohtang Pass.Manali is a high-altitude Himalayan resort town in India’s northern Himachal Pradesh state. It has a reputation as a backpacking center and honeymoon destination. Set on the Beas River, it’s a gateway for skiing in the Solang Valley and trekking in Parvati Valley. It's also a jumping-off point for paragliding, rafting and mountaineering in the Pir Panjal mountains, home to 4,000m-high Rohtang Pass..Manali is a high-altitude Himalayan resort town in India’s northern Himachal Pradesh state. It has a reputation as a backpacking center and honeymoon destination. Set on the Beas River, it’s a gateway for skiing in the Solang Valley and trekking in Parvati Valley. It's also a jumping-off point for paragliding, rafting and mountaineering in the Pir Panjal mountains, home to 4,000m-high Rohtang Pass..Manali is a high-altitude Himalayan resort town in India’s northern Himachal Pradesh state. It has a reputation as a backpacking center and honeymoon destination. Set on the Beas River, it’s a gateway for skiing in the Solang Valley and trekking in Parvati Valley. It's also a jumping-off point for paragliding, rafting and mountaineering in the Pir Panjal mountains, home to 4,000m-high Rohtang Pass.Manali is a high-altitude Himalayan resort town in India’s northern Himachal Pradesh state. It has a reputation as a backpacking center and honeymoon destination. Set on the Beas River, it’s a gateway for skiing in the Solang Valley and trekking in Parvati Valley. It's also a jumping-off point for paragliding, rafting and mountaineering in the Pir Panjal mountains, home to 4,000m-high Rohtang Pass.Manali is a high-altitude Himalayan resort town in India’s northern Himachal Pradesh state. It has a reputation as a backpacking center and honeymoon destination. Set on the Beas River, it’s a gateway for skiing in the Solang Valley and trekking in Parvati Valley. It's also a jumping-off point for paragliding, rafting and mountaineering in the Pir Panjal mountains, home to 4,000m-high Rohtang Pass.";


            Gems gemItem2 = new Gems();
            gemItem2.ArrowImage = "";
            gemItem2.DateInfo = "2015 Janury 30";
            gemItem2.GemImage = Device.OnPlatform("manali.jpg", "manali.jpg", "//Assets//manali.jpg");
            gemItem2.Name = "Virender Sehwag";
            gemItem2.ProfilePhoto = Device.OnPlatform("avatar.jpg", "avatar.jpg", "//Assets//avatar.jpg"); 
            gemItem2.GemInfo = "This is just a dummy page to check how ";



            Gems gemItem3 = new Gems();
            gemItem3.ArrowImage = "";
            gemItem3.DateInfo = "2015 Janury 30";
            gemItem3.GemImage = Device.OnPlatform("manali.jpg", "manali.jpg", "//Assets//manali.jpg");
            gemItem3.Name = "Brian lara";
            gemItem3.ProfilePhoto = Device.OnPlatform("avatar.jpg", "avatar.jpg", "//Assets//avatar.jpg"); 
            gemItem3.GemInfo = "This is just a dummy page to check how This is just a dummy page to check how This is just a dummy page to check how This is just a dummy page to check how This is just a dummy page to check how This is just a dummy page to check how This is just a dummy page to check how ";

            for (int index = 0; index < 50; index++ )
            {
                gemsSource.Add(gemItems);
                gemsSource.Add(gemItem2);
                gemsSource.Add(gemItem3);
                gemsSource.Add(gemItems);
            }


            ListView gemsList = new ListView();
            gemsList.ItemTemplate = new DataTemplate(typeof(GemsCell));
            gemsList.SeparatorVisibility = SeparatorVisibility.None;
            gemsList.BackgroundColor = Color.FromRgb(230, 255, 254);
            gemsList.ItemsSource = gemsSource;
            gemsList.HeightRequest = deviceSpec.ScreenHeight * 75 / 100;
            gemsList.HasUnevenRows = true;

            masterLayout.AddChildToLayout(titleBar, 0, 0);
            masterLayout.AddChildToLayout(subTitleBar, 0, 10);
            masterLayout.AddChildToLayout( gemsList, 0, 20 ); 
            Content = masterLayout;
        }
        public GemsDetailsPage( DetailsPageModel model )
        {
			try
			{
				NavigationPage.SetHasNavigationBar(this, false);
				detailsPageModel = model;
				masterLayout = new CustomLayout();
				masterLayout.BackgroundColor = Color.FromRgb(244, 244, 244);
				masterScroll = new ScrollView();
				masterScroll.BackgroundColor = Color.FromRgb(244, 244, 244);
				masterScroll.IsClippedToBounds = true;
				progressBar = DependencyService.Get<IProgressBar>();
				masterStack = new CustomLayout();
				//masterStack.Orientation = StackOrientation.Vertical;
				masterStack.BackgroundColor = Color.FromRgb(244, 244, 244);
				mediaList = model.eventMediaArray;
				actionMediaList = model.actionMediaArray;
				CurrentGemId = model.gemId;
				CurrentGemType = model.gemType;
				User user = null;
				App.GemDeleted = false;

				try
				{
					user = App.Settings.GetUser();
				}
				catch (Exception ex)
				{
					var test = ex.Message;
				}
				if (string.IsNullOrEmpty (model.pageTitleVal)) {
					model.pageTitleVal = "GEM Details";
				}
				mainTitleBar = new PurposeColorTitleBar(Color.FromRgb(8, 135, 224), "Purpose Color", Color.Black, "back", true);
				mainTitleBar.imageAreaTapGestureRecognizer.Tapped += OnImageAreaTapGestureRecognizerTapped;
				subTitleBar = new PurposeColorSubTitleBar(Constants.SUB_TITLE_BG_COLOR, model.pageTitleVal, false);
				subTitleBar.BackButtonTapRecognizer.Tapped += async (object sender, EventArgs e) =>
				{
					try
					{
						await Navigation.PopAsync();
					}
					catch (Exception){
					}
				};


				this.Appearing += GemsDetailsPage_Appearing;

				Label pageTitle = new Label();
				pageTitle.Text = model.titleVal;//model.pageTitleVal;
				pageTitle.TextColor = Color.Black;
				pageTitle.FontFamily = Constants.HELVERTICA_NEUE_LT_STD;
				pageTitle.FontAttributes = FontAttributes.Bold;
				pageTitle.WidthRequest = App.screenWidth * 80 / 100;
				pageTitle.HeightRequest = 50;
				pageTitle.XAlign = TextAlignment.Start;
				pageTitle.YAlign = TextAlignment.Start;
				pageTitle.FontSize = Device.OnPlatform(15, 20, 15);

				StackLayout emptyLayout = new StackLayout();
				emptyLayout.BackgroundColor = Color.Transparent;
				emptyLayout.WidthRequest = App.screenWidth * 90 / 100;
				emptyLayout.HeightRequest = 30;

				#region TOOLS LAYOUT

				StackLayout toolsLayout = new StackLayout();
				toolsLayout.Spacing = App.screenWidth * .10;
				toolsLayout.Orientation = StackOrientation.Horizontal;
				toolsLayout.HorizontalOptions = LayoutOptions.Center;
				toolsLayout.HeightRequest = App.screenHeight * .05;
				toolsLayout.Padding = new Thickness(10, 5, 10, 10);
				toolsLayout.ClassId = "ToolsLayout";

				favoriteButton = new Image();
				favoriteButton.Source = Device.OnPlatform("favoriteIcon.png", "favoriteIcon.png", "//Assets//favoriteIcon.png");
				favoriteButton.WidthRequest = Device.OnPlatform(15, 15, 15);
				favoriteButton.HeightRequest = Device.OnPlatform(15, 15, 15);
				favoriteButton.VerticalOptions = LayoutOptions.Center;
				favoriteButtonTap = new TapGestureRecognizer();
				favoriteButtonTap.Tapped += FavoriteButtonTapped;
				favoriteButton.GestureRecognizers.Add(favoriteButtonTap);

				favoriteLabel = new Label
				{
					Text = "Favorite",
					FontFamily = Constants.HELVERTICA_NEUE_LT_STD,
					TextColor = Color.Gray,
					VerticalOptions = LayoutOptions.Center,
					FontSize = Device.OnPlatform(12,12,15)
				};
				favoriteLabel.GestureRecognizers.Add(favoriteButtonTap);
				toolsLayout.Children.Add( new StackLayout{Children = {favoriteButton,favoriteLabel}, Orientation = StackOrientation.Horizontal, Spacing = 5});

				//toolsLayout.Children.Add(favoriteButton);
				//toolsLayout.Children.Add(favoriteLabel);

				if (user.AllowCommunitySharing)
				{
					shareButton = new Image();
					shareButton.Source = Device.OnPlatform("share.png", "share.png", "//Assets//share.png");
					shareButton.WidthRequest = Device.OnPlatform(15, 15, 15);
					shareButton.HeightRequest = Device.OnPlatform(15, 15, 15);
					shareButton.VerticalOptions = LayoutOptions.Center;
					shareLabel = new Label
					{
						Text = "Share",
						FontFamily = Constants.HELVERTICA_NEUE_LT_STD,
						TextColor = Color.Gray,
						VerticalOptions = LayoutOptions.Center,
						FontSize = Device.OnPlatform(12,12,15)
					};
					shareButtonTap = new TapGestureRecognizer();
					shareButtonTap.Tapped += ShareButtonTapped;
					shareButton.GestureRecognizers.Add(shareButtonTap);
					shareLabel.GestureRecognizers.Add(shareButtonTap);
					toolsLayout.Children.Add(new StackLayout{Children = {shareButton,shareLabel}, Orientation = StackOrientation.Horizontal, Spacing = 5});
					//toolsLayout.Children.Add(shareLabel);
				}



				Image commentButton = new Image();
				commentButton.Source = Device.OnPlatform("icon_cmnt.png", "icon_cmnt.png", "//Assets//icon_cmnt.png");
				commentButton.WidthRequest = Device.OnPlatform(15, 15, 15);
				commentButton.HeightRequest = Device.OnPlatform(15, 15, 15);
				commentButton.VerticalOptions = LayoutOptions.Center;
				commentsLabel = new Label
				{
					Text = "Comments",
					VerticalOptions = LayoutOptions.Center,
					FontFamily = Constants.HELVERTICA_NEUE_LT_STD,
					TextColor = Color.Gray,
					FontSize = Device.OnPlatform(12,12,15),
					ClassId = "CommentLabel"
				};

				commentButtonTap = new TapGestureRecognizer();
				commentButtonTap.Tapped += CommentButtonTapped;
				commentButton.GestureRecognizers.Add(commentButtonTap);
				commentsLabel.GestureRecognizers.Add(commentButtonTap);

				toolsLayout.Children.Add( new StackLayout{Children = {commentButton,commentsLabel}, Orientation = StackOrientation.Horizontal, Spacing = 5});
				//toolsLayout.Children.Add(commentButton);
				//toolsLayout.Children.Add(commentsLabel);

				#endregion

				#region  title, description
				title = new Label ();
				title.Text = model.titleVal;
				title.TextColor = Color.Black;
				title.WidthRequest = App.screenWidth * 90 / 100;
				title.FontSize = Device.OnPlatform (12, 12, 12);
				title.FontFamily = Constants.HELVERTICA_NEUE_LT_STD;

				description = new Label ();
				description.WidthRequest = App.screenWidth * .75;
				description.Text = model.description;
				description.TextColor = Color.Black;
				description.FontFamily = Constants.HELVERTICA_NEUE_LT_STD;

				Image menuButton = new Image
				{
					Source = Device.OnPlatform("downarrow.png", "downarrow.png", "//Assets//downarrow.png"),
					HorizontalOptions = LayoutOptions.End,
					BackgroundColor = Color.Transparent,
					WidthRequest = Device.OnPlatform(25, 25, 60),
					HeightRequest = Device.OnPlatform(25, 25, 40),
					Aspect = Aspect.AspectFit
				};

				TapGestureRecognizer editMenuGesture = new TapGestureRecognizer();
				editMenuGesture.Tapped += GemMenuButton_Clicked;
				menuButton.GestureRecognizers.Add(editMenuGesture);

				masterStack.AddChildToLayout(pageTitle, 2, Device.OnPlatform(0,1,1));
				masterStack.AddChildToLayout(menuButton, Device.OnPlatform(87, 90, 99), Device.OnPlatform(0,1,1));
				//masterStack.AddChildToLayout(title,1,Device.OnPlatform(3,7,7));
				#endregion

				StackLayout bottomAndLowerControllStack = new StackLayout
				{
					Orientation = StackOrientation.Vertical,
					BackgroundColor = Color.Transparent,
					Spacing = 1,
					Padding = 0,// new Thickness(0, 0, 0, 5),
					WidthRequest = App.screenWidth,// * .90,
					ClassId= "BottomNlowerStack"
				};
				bottomAndLowerControllStack.Children.Add(new StackLayout { Padding = new Thickness(6, 0, 0, 5), Children = { description } });

				#region MEDIA LIST

				if (mediaList != null)
				{
					for (int index = 0; index < mediaList.Count; index++)
					{
						TapGestureRecognizer videoTap = new TapGestureRecognizer();
						videoTap.Tapped += OnEventVideoTapped;
						bool isValidUrl = (mediaList[index].event_media != null && !string.IsNullOrEmpty(mediaList[index].event_media)) ? true : false;
						string source = (isValidUrl) ? model.Media + mediaList[index].event_media : Device.OnPlatform("noimage.png", "noimage.png", "//Assets//noimage.png");
						string fileExtenstion = Path.GetExtension(source);
						bool isImage = (fileExtenstion == ".png" || fileExtenstion == ".jpg" || fileExtenstion == ".jpeg") ? true : false;
						//img.WidthRequest = App.screenWidth;// * 50 / 100;
						Image img = new Image();

						if(isImage)
							img.HeightRequest = App.screenWidth * 1.1;
						else
						{
							img.HeightRequest = App.screenWidth;
						}
						
						//img.MinimumHeightRequest = App.screenWidth;
						//img.MinimumWidthRequest = App.screenWidth;

						img.Aspect = Aspect.AspectFill;
						img.ClassId = null;
						if (mediaList[index] != null && mediaList[index].media_type == "mp4")
						{
							img.ClassId = source;
							source = Constants.SERVICE_BASE_URL + mediaList[index].video_thumb;
						}
						else if (mediaList[index] != null && (mediaList[index].media_type == "3gpp" || mediaList[index].media_type == "aac") )
						{
							img.ClassId = source;
							source = Device.OnPlatform("audio.png", "audio.png", "//Assets//audio.png");
						}
						else if (mediaList[index] != null && mediaList[index].media_type == "wav")
						{
							img.ClassId = source;
							source = Device.OnPlatform("audio.png", "audio.png", "//Assets//audio.png");
						}
						img.Source = source;
						img.GestureRecognizers.Add(videoTap);

						var indicator = new ActivityIndicator { Color = new Color(.5), };
						indicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsLoading");
						indicator.BindingContext = img;
						masterStack.AddChildToLayout(indicator, 40, Device.OnPlatform(50,40,40));
						if (isValidUrl)
						{

							if (mediaList[index] != null && mediaList[index].media_type == "mp4")
							{
								Grid grid = new Grid
								{
									VerticalOptions = LayoutOptions.FillAndExpand,
									HorizontalOptions = LayoutOptions.FillAndExpand,
									RowDefinitions = 
									{
										new RowDefinition { Height = new GridLength( App.screenWidth / 3 ) },
										new RowDefinition { Height = new GridLength( App.screenWidth / 3 ) },
										new RowDefinition { Height = new GridLength( App.screenWidth / 3 ) },

									},
									ColumnDefinitions = 
									{
										new ColumnDefinition { Width = new GridLength( App.screenWidth / 3 ) },
										new ColumnDefinition { Width = new GridLength( App.screenWidth / 3 ) },
										new ColumnDefinition { Width = new GridLength( App.screenWidth / 3 ) },

									}
									};

								Image play = new Image();
								play.Source = "video_play.png";
								play.Aspect = Aspect.AspectFit;
								play.WidthRequest = 75;
								play.HeightRequest = 75;
								play.HorizontalOptions = LayoutOptions.Center;
								play.VerticalOptions = LayoutOptions.Center;
								play.ClassId =  mediaList[index].event_media ;
								play.GestureRecognizers.Add(videoTap);

								BoxView box = new BoxView();
								box.BackgroundColor = Color.Red;
								box.WidthRequest = 100;
								box.HeightRequest = 100;

								grid.Children.Add( img, 0, 0 );
								Grid.SetColumnSpan(img, 3);
								Grid.SetRowSpan( img, 3 );
								grid.Children.Add(play, 1, 1);
								bottomAndLowerControllStack.Children.Add(grid);
							}
							else
							{
								bottomAndLowerControllStack.Children.Add(img);
							}
						}


					}
				}

				if (actionMediaList != null)
				{
					for (int index = 0; index < actionMediaList.Count; index++)
					{
						TapGestureRecognizer videoTap = new TapGestureRecognizer();
						videoTap.Tapped += OnActionVideoTapped;

						Image img = new Image();
						bool isValidUrl = (actionMediaList[index].action_media != null && !string.IsNullOrEmpty(actionMediaList[index].action_media)) ? true : false;
						string source = (isValidUrl) ? model.Media + actionMediaList[index].action_media : Device.OnPlatform("noimage.png", "noimage.png", "//Assets//noimage.png");
						string fileExtenstion = Path.GetExtension(source);
						bool isImage = (fileExtenstion == ".png" || fileExtenstion == ".jpg" || fileExtenstion == ".jpeg") ? true : false;
						//img.WidthRequest = App.screenWidth;// * 50 / 100;
						if(isImage)
							img.HeightRequest = App.screenWidth * 1.1;
						else
						{
							img.HeightRequest = App.screenWidth;
						}
						
						img.Aspect = Aspect.AspectFill;
						img.ClassId = null;
						if (actionMediaList[index] != null && actionMediaList[index].media_type == "mp4")
						{
							img.ClassId = source;
							source = Constants.SERVICE_BASE_URL + actionMediaList[index].video_thumb;
						}
						else if (actionMediaList[index] != null && (actionMediaList[index].media_type == "3gpp" || actionMediaList[index].media_type == "aac"))
						{
							img.ClassId = source;
							source = Device.OnPlatform("audio.png", "audio.png", "//Assets//audio.png");
						}
						else if (actionMediaList[index] != null && actionMediaList[index].media_type == "wav")
						{
							img.ClassId = source;
							source = Device.OnPlatform("audio.png", "audio.png", "//Assets//audio.png");
						}
						img.Source = source;
						img.GestureRecognizers.Add(videoTap);
						var indicator = new ActivityIndicator { Color = new Color(.5), };
						indicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsLoading");
						indicator.BindingContext = img;
						masterStack.AddChildToLayout(indicator, 40, Device.OnPlatform(50,40,40));
						if (isValidUrl)
						{
							if (actionMediaList[index] != null && actionMediaList[index].media_type == "mp4")
							{
								Grid grid = new Grid
								{
									VerticalOptions = LayoutOptions.FillAndExpand,
									HorizontalOptions = LayoutOptions.FillAndExpand,
									RowDefinitions = 
									{
										new RowDefinition { Height = new GridLength( App.screenWidth / 3 ) },
										new RowDefinition { Height = new GridLength( App.screenWidth / 3 ) },
										new RowDefinition { Height = new GridLength( App.screenWidth / 3 ) },

									},
									ColumnDefinitions = 
									{
										new ColumnDefinition { Width = new GridLength( App.screenWidth / 3 ) },
										new ColumnDefinition { Width = new GridLength( App.screenWidth / 3 ) },
										new ColumnDefinition { Width = new GridLength( App.screenWidth / 3 ) },

									}
									};

								Image play = new Image();
								play.Source = "video_play.png";
								play.Aspect = Aspect.AspectFit;
								play.WidthRequest = 75;
								play.HeightRequest = 75;
								play.HorizontalOptions = LayoutOptions.Center;
								play.VerticalOptions = LayoutOptions.Center;
								play.ClassId =  actionMediaList[index].action_media ;
								play.GestureRecognizers.Add(videoTap);

								BoxView box = new BoxView();
								box.BackgroundColor = Color.Red;
								box.WidthRequest = 100;
								box.HeightRequest = 100;

								grid.Children.Add( img, 0, 0 );
								Grid.SetColumnSpan(img, 3);
								Grid.SetRowSpan( img, 3 );
								grid.Children.Add(play, 1, 1);
								bottomAndLowerControllStack.Children.Add(grid);
							}
							else
							{
								bottomAndLowerControllStack.Children.Add(img);
							}
						}
					}
				}


				if (model.goal_media != null)
				{
					ScrollView imgScrollView = new ScrollView();
					imgScrollView.Orientation = ScrollOrientation.Horizontal;

					//StackLayout horizmgConatiner = new StackLayout();
					// horizmgConatiner.Orientation = StackOrientation.Horizontal;

					for (int index = 0; index < model.goal_media.Count; index++)
					{
						TapGestureRecognizer videoTap = new TapGestureRecognizer();
						videoTap.Tapped += OnActionVideoTapped;

						Image img = new Image();
						bool isValidUrl = (model.goal_media[index].goal_media != null && !string.IsNullOrEmpty(model.goal_media[index].goal_media)) ? true : false;
						string source = (isValidUrl) ?  model.goal_media[index].goal_media : Device.OnPlatform("noimage.png", "noimage.png", "//Assets//noimage.png");
						string fileExtenstion = Path.GetExtension(source);
						bool isImage = (fileExtenstion == ".png" || fileExtenstion == ".jpg" || fileExtenstion == ".jpeg") ? true : false;
						//img.WidthRequest = App.screenWidth;// * 50 / 100;
						if(isImage)
							img.HeightRequest = App.screenWidth * 1.1;
						else
						{
							img.HeightRequest = App.screenWidth;
						}
						
						img.Aspect = Aspect.AspectFill;
						img.ClassId = null;
						if (model.goal_media[index] != null && model.goal_media[index].media_type == "mp4")
						{

							source = Constants.SERVICE_BASE_URL +  model.goal_media[index].video_thumb;
							img.ClassId = source;
						}
						else if (model.goal_media[index] != null && (model.goal_media[index].media_type == "3gpp" || model.goal_media[index].media_type == "aac"))
						{
							img.ClassId = source;
							source = Device.OnPlatform("audio.png", "audio.png", "//Assets//audio.png");
						}
						else if (model.goal_media[index] != null && model.goal_media[index].media_type == "wav")
						{
							img.ClassId = source;
							source = Device.OnPlatform("audio.png", "audio.png", "//Assets//audio.png");
						}
						img.Source = source;
						img.GestureRecognizers.Add(videoTap);
						var indicator = new ActivityIndicator { Color = new Color(.5), };
						indicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsLoading");
						indicator.BindingContext = img;
						masterStack.AddChildToLayout(indicator, 40, Device.OnPlatform(50,40,40));
						// horizmgConatiner.Children.Add(img);
						if( isValidUrl )
						{
							if ( model.goal_media[index]!= null &&  model.goal_media[index].media_type == "mp4")
							{
								Grid grid = new Grid
								{
									VerticalOptions = LayoutOptions.FillAndExpand,
									HorizontalOptions = LayoutOptions.FillAndExpand,
									RowDefinitions = 
									{
										new RowDefinition { Height = new GridLength( App.screenWidth / 3 ) },
										new RowDefinition { Height = new GridLength( App.screenWidth / 3 ) },
										new RowDefinition { Height = new GridLength( App.screenWidth / 3 ) },

									},
									ColumnDefinitions = 
									{
										new ColumnDefinition { Width = new GridLength( App.screenWidth / 3 ) },
										new ColumnDefinition { Width = new GridLength( App.screenWidth / 3 ) },
										new ColumnDefinition { Width = new GridLength( App.screenWidth / 3 ) },

									}
									};

								Image play = new Image();
								play.Source = "video_play.png";
								play.Aspect = Aspect.AspectFit;
								play.WidthRequest = 75;
								play.HeightRequest = 75;
								play.HorizontalOptions = LayoutOptions.Center;
								play.VerticalOptions = LayoutOptions.Center;
								play.ClassId =   Constants.SERVICE_BASE_URL +  model.goal_media[index].goal_media ;
								play.GestureRecognizers.Add(videoTap);

								BoxView box = new BoxView();
								box.BackgroundColor = Color.Red;
								box.WidthRequest = 100;
								box.HeightRequest = 100;

								grid.Children.Add( img, 0, 0 );
								Grid.SetColumnSpan(img, 3);
								Grid.SetRowSpan( img, 3 );
								grid.Children.Add(play, 1, 1);
								//horizmgConatiner.Children.Add(grid);
								bottomAndLowerControllStack.Children.Add(grid);
							}
							else
							{
								//horizmgConatiner.Children.Add(img);
								bottomAndLowerControllStack.Children.Add(img);
							}
						}

					}

					// imgScrollView.Content = horizmgConatiner;
					// bottomAndLowerControllStack.Children.Add(imgScrollView);
				}

				#endregion

				//masterStack.AddChildToLayout(toolsLayout,1,65);
				//masterStack.AddChildToLayout(emptyLayout,1,75);
				bottomAndLowerControllStack.Children.Add(toolsLayout);
				bottomAndLowerControllStack.Children.Add(emptyLayout);
				if (model.titleVal.Length < 25) {
					masterStack.AddChildToLayout (bottomAndLowerControllStack, 0, 8);
				} else {
					masterStack.AddChildToLayout (bottomAndLowerControllStack, 0, 11);
				}

				StackLayout spaceOffsetlayout = new StackLayout();
				spaceOffsetlayout.WidthRequest = App.screenWidth * 50 / 100;
				spaceOffsetlayout.HeightRequest = Device.OnPlatform(100, 100, 250);
				spaceOffsetlayout.BackgroundColor = Color.Transparent;
				//masterStack.AddChildToLayout(spaceOffsetlayout, 1, 85);
				bottomAndLowerControllStack.Children.Add(spaceOffsetlayout);

				masterScroll.HeightRequest = App.screenHeight - 20;
				masterScroll.WidthRequest = App.screenWidth; //App.screenWidth * 90 / 100;

				masterScroll.Content = masterStack;

				masterLayout.AddChildToLayout(mainTitleBar, 0, 0);
				masterLayout.AddChildToLayout(subTitleBar, 0, Device.OnPlatform(9, 10, 10));
				masterLayout.AddChildToLayout(masterScroll,0, Device.OnPlatform(16,18,18));

				#region CUSTOM LIST MENU

				//new CustomListViewItem { EmotionID = item.EmotionId.ToString(), Name = item.EmpotionName, SliderValue = item.EmotionValue  }

				#endregion

				Content = masterLayout;
			} 
			catch (Exception ex)
			{
				Debug.WriteLine ( ex.Message );
			}
        }
        public FeelingsSecondPage()
        {
            progressBar = DependencyService.Get<IProgressBar>();
            NavigationPage.SetHasNavigationBar(this, false);
            masterLayout = new CustomLayout();
            masterLayout.BackgroundColor = Color.FromRgb(244, 244, 244);
            //deviceSpec = DependencyService.Get<IDeviceSpec>();
			AddEventsSituationsOrThoughts.feelingSecondPage = this;
            this.Appearing += FeelingsSecondPage_Appearing;
            actionPreviewListSource = new ObservableCollection<PreviewItem>();

            mainTitleBar = new PurposeColorTitleBar(Color.FromRgb(8, 135, 224), "Purpose Color", Color.Black, "back", true);
            mainTitleBar.imageAreaTapGestureRecognizer.Tapped += imageAreaTapGestureRecognizer_Tapped;

            subTitleBar = new PurposeColorSubTitleBar(Constants.SUB_TITLE_BG_COLOR, "Emotional Awareness");
            subTitleBar.BackButtonTapRecognizer.Tapped += OnBackButtonTapRecognizerTapped;
            subTitleBar.NextButtonTapRecognizer.Tapped += NextButtonTapRecognizer_Tapped;
            screenHeight = App.screenHeight;
            screenWidth = App.screenWidth;
			aePicker = null;
			actionlist = null;

            Label firstLine = new Label();
            firstLine.Text = "Does being";
            firstLine.FontFamily = Constants.HELVERTICA_NEUE_LT_STD;
            firstLine.TextColor = Color.FromRgb(40, 47, 50);
            firstLine.HeightRequest = screenHeight * 15 / 100;
            firstLine.HorizontalOptions = LayoutOptions.Center;
            firstLine.WidthRequest = screenWidth;
            firstLine.XAlign = TextAlignment.Center;

            Label secondLine = new Label();
            secondLine.Text = App.SelectedEmotion;
            secondLine.FontFamily = Constants.HELVERTICA_NEUE_LT_STD;
            secondLine.FontAttributes = FontAttributes.Italic;
            secondLine.TextColor = Constants.BLUE_BG_COLOR;//Color.FromRgb(40, 47, 50);
            secondLine.HeightRequest = screenHeight * 15 / 100;
            secondLine.HorizontalOptions = LayoutOptions.Center;
            secondLine.WidthRequest = screenWidth;
            secondLine.XAlign = TextAlignment.Center;

            Label thirdLine = new Label();
            thirdLine.Text = "support your goals and dreams?";
            thirdLine.FontFamily = Constants.HELVERTICA_NEUE_LT_STD;
            thirdLine.TextColor = Color.FromRgb(40, 50, 50);
            thirdLine.HeightRequest = screenHeight * 11 / 100;
            thirdLine.HorizontalOptions = LayoutOptions.Center;
            thirdLine.WidthRequest = screenWidth;
            thirdLine.XAlign = TextAlignment.Center;


            goalsAndDreamsPickerButton = new PurposeColor.interfaces.CustomImageButton();
            goalsAndDreamsPickerButton.ImageName = Device.OnPlatform("select_box_whitebg.png", "select_box_whitebg.png", @"/Assets/select_box_whitebg.png");
            goalsAndDreamsPickerButton.Text = "Goals & Dreams";
            goalsAndDreamsPickerButton.FontFamily = Constants.HELVERTICA_NEUE_LT_STD;
            goalsAndDreamsPickerButton.TextOrientation = interfaces.TextOrientation.Left;
            goalsAndDreamsPickerButton.FontSize = 17;
            goalsAndDreamsPickerButton.TextColor = Color.Gray;
            goalsAndDreamsPickerButton.WidthRequest = screenWidth * 90 / 100;

            goalsAndDreamsPickerButton.Clicked += OnGoalsPickerButtonClicked;


            actionPickerButton = new CustomImageButton();
            actionPickerButton.IsVisible = false;
            actionPickerButton.BackgroundColor = Color.FromRgb(30, 126, 210);
            actionPickerButton.Text = "Add Supporting Actions";
            actionPickerButton.TextColor = Color.White;

            actionPickerButton.TextOrientation = TextOrientation.Middle;
            actionPickerButton.FontFamily = Constants.HELVERTICA_NEUE_LT_STD;
            // actionPickerButton.TextOrientation = interfaces.TextOrientation.Left;
            actionPickerButton.WidthRequest = screenWidth * 90 / 100;

            actionPickerButton.Clicked += OnActionPickerButtonClicked;


            if (App.screenDensity > 1.5)
            {
                firstLine.FontSize = Device.OnPlatform(20, 20, 30);
                secondLine.FontSize = Device.OnPlatform(20, 22, 30);
                thirdLine.FontSize = Device.OnPlatform(20, 20, 30);
                actionPickerButton.FontSize = 17;
                actionPickerButton.HeightRequest = screenHeight * 6 / 100;
                goalsAndDreamsPickerButton.HeightRequest = screenHeight * 6 / 100;
            }
            else
            {
                firstLine.FontSize = Device.OnPlatform(16, 18, 26);
                secondLine.FontSize = Device.OnPlatform(16, 20, 26);
                thirdLine.FontSize = Device.OnPlatform(16, 18, 26);
                actionPickerButton.FontSize = 15;
                actionPickerButton.HeightRequest = screenHeight * 9 / 100;
                goalsAndDreamsPickerButton.HeightRequest = screenHeight * 9 / 100;
            }

            slider = new CustomSlider
            {
                Minimum = -2,
                Maximum = 2,
                WidthRequest = screenWidth * 90 / 100
            };
            slider.StopGesture = GetstopGetsture;


            //Image sliderDivider1 = new Image();
            //sliderDivider1.Source = "drag_sepeate.png";


            //Image sliderDivider2 = new Image();
            //sliderDivider2.Source = "drag_sepeate.png";


            //Image sliderDivider3 = new Image();
            //sliderDivider3.Source = "drag_sepeate.png";

            //Image sliderBG = new Image();
            //sliderBG.Source = "drag_bg.png";

            this.Appearing += FeelingNowPage_Appearing;

            masterLayout.AddChildToLayout(mainTitleBar, 0, 0);
            masterLayout.AddChildToLayout(subTitleBar, 0, Device.OnPlatform(9, 10, 9));
            masterLayout.AddChildToLayout(firstLine, 0, 20);
            masterLayout.AddChildToLayout(secondLine, 0, 25);
            masterLayout.AddChildToLayout(thirdLine, 0, 30);
            //masterLayout.AddChildToLayout(sliderBG, 7, 45);
            masterLayout.AddChildToLayout(slider, 5, Device.OnPlatform(37, 35, 34));
            /*  masterLayout.AddChildToLayout(sliderDivider1, 30, 45.5f);
              masterLayout.AddChildToLayout(sliderDivider2, 50, 45.5f);
              masterLayout.AddChildToLayout(sliderDivider3, 70, 45.5f);*/
            masterLayout.AddChildToLayout(goalsAndDreamsPickerButton, 5, Device.OnPlatform(50, 50, 45));
            masterLayout.AddChildToLayout(actionPickerButton, 5, Device.OnPlatform(65, 65, 55));


            listContainer = new StackLayout();
            listContainer.BackgroundColor = Constants.PAGE_BG_COLOR_LIGHT_GRAY;
            listContainer.WidthRequest = screenWidth * 90 / 100;
            listContainer.HeightRequest = screenHeight * 20 / 100;
            listContainer.ClassId = "preview";

            actionPreviewListView = new ListView();
            actionPreviewListView.BackgroundColor = Constants.PAGE_BG_COLOR_LIGHT_GRAY;
            actionPreviewListView.ItemTemplate = new DataTemplate(typeof(ActionPreviewCellItem));
            ActionPreviewCellItem.mainPage = this;
            actionPreviewListView.SeparatorVisibility = SeparatorVisibility.None;
            actionPreviewListView.Opacity = 1;
            actionPreviewListView.ItemsSource = actionPreviewListSource;
            listContainer.Children.Add(actionPreviewListView);
            masterLayout.AddChildToLayout(listContainer, 5, Device.OnPlatform(73, 73, 64));

            Content = masterLayout;

        }
        public CreateEventPage()
        {
            NavigationPage.SetHasNavigationBar(this, false);
            masterLayout = new CustomLayout();
            masterLayout.BackgroundColor = Color.FromRgb(244, 244, 244);
            deviceSpec = DependencyService.Get<IDeviceSpec>();

			PurposeColorTitleBar mainTitleBar = new PurposeColorTitleBar(Color.FromRgb(8, 135, 224), "Purpose Color", Color.Black, "back", true);
            mainTitleBar.imageAreaTapGestureRecognizer.Tapped += imageAreaTapGestureRecognizer_Tapped;
            PurposeColorSubTitleBar subTitleBar = new PurposeColorSubTitleBar(Constants.SUB_TITLE_BG_COLOR, "Create Reminder", false, true);
            subTitleBar.BackButtonTapRecognizer.Tapped += BackButtonTapRecognizer_Tapped;

			CustomImageButton startDatePickerButton = new CustomImageButton();
			CustomImageButton startTimePickerButton = new CustomImageButton();
			CustomImageButton endDatePickerButton = new CustomImageButton();
			CustomImageButton endTimePickerButton = new CustomImageButton();


            CustomEntry title = new CustomEntry();
			title.WidthRequest = deviceSpec.ScreenWidth * 90 / 100;
			title.Placeholder = " Title";
			title.TextColor = Color.Black;
			title.BackgroundColor = Color.White;


            CustomEntry messege = new CustomEntry();
			messege.WidthRequest = deviceSpec.ScreenWidth * 90 / 100;
			messege.Placeholder = " Description";
			messege.TextColor = Color.Black;
			messege.BackgroundColor = Color.White;


			DatePicker startDatePicker = new DatePicker();
			startDatePicker.WidthRequest = 0;
			startDatePicker.HeightRequest = 0;
			startDatePicker.IsVisible = false;
			startDatePicker.DateSelected += (object sender, DateChangedEventArgs e) => 
			{
				
				startDatePickerButton.Text = startDatePicker.Date.ToString("dd/MM/yyyy");
			};

			DatePicker endDatePicker = new DatePicker();
			endDatePicker.WidthRequest = 0;
			endDatePicker.HeightRequest = 0;
			endDatePicker.IsVisible = false;
			endDatePicker.DateSelected += (object sender, DateChangedEventArgs e) => 
			{
				endDatePickerButton.Text = endDatePicker.Date.ToString("dd/MM/yyyy");
			};

			TimePicker startTimePicker = new TimePicker();
			startTimePicker.WidthRequest = 0;
			startTimePicker.HeightRequest = 0;
			startTimePicker.IsVisible = false;
			startTimePicker.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => 
			{
                try
                {

                    if ("Time" == e.PropertyName)
                    {
                        //	string tie = startTimePicker.Time.ToString("hh:mm tt");
                        string amPM = (startTimePicker.Time.Hours > 12) ? "PM" : "AM";
                        startTimePickerButton.Text = startTimePicker.Time.ToString(); //startTimePicker.Time.Hours.ToString () + " : " + startTimePicker.Time.Minutes.ToString() + "  " + amPM;

                    }

                }
                catch (Exception ex)
                {
                    var test = ex.Message;
                }
			};


			TimePicker endTimePicker = new TimePicker();
			endTimePicker.WidthRequest = 0;
			endTimePicker.HeightRequest = 0;
			endTimePicker.IsVisible = false;
			endTimePicker.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => 
			{
                try
                {
                    if ("Time" == e.PropertyName)
                    {
                        string amPM = (endTimePicker.Time.Hours > 12) ? "PM" : "AM";
                        endTimePickerButton.Text = endTimePicker.Time.ToString();// endTimePicker.Time.Hours.ToString () + " : " + endTimePicker.Time.Minutes.ToString() + "  " + amPM;
                    }
                }
                catch (Exception ex)
                {
                    var test = ex.Message;
                }
			};

            //startDatePickerButton = new CustomImageButton();
            startDatePickerButton.ImageName = Device.OnPlatform("select_box_whitebg.png", "select_box_whitebg.png", "//Assets//select_box_whitebg.png");
            startDatePickerButton.Text = "Start Date";
            startDatePickerButton.FontSize = 17;
            startDatePickerButton.FontFamily = Constants.HELVERTICA_NEUE_LT_STD;
            startDatePickerButton.TextOrientation = interfaces.TextOrientation.Left;
            startDatePickerButton.TextColor = Color.Gray;
            startDatePickerButton.WidthRequest = deviceSpec.ScreenWidth * 40 / 100;
			startDatePickerButton.Clicked += (object sender, EventArgs e) => 
			{
                try
                {
					startDatePicker.Date = DateTime.Now.AddDays(1);
                    startDatePicker.Focus();
                }
                catch (Exception ex)
                {
                    var test = ex.Message;
                }
			};



           // startTimePickerButton = new CustomImageButton();
            startTimePickerButton.ImageName = Device.OnPlatform("select_box_whitebg.png", "select_box_whitebg.png", "//Assets//select_box_whitebg.png");
            startTimePickerButton.Text = " Start Time";
            startTimePickerButton.TextOrientation = TextOrientation.Middle;         
            startTimePickerButton.FontSize = 17;
            startTimePickerButton.FontFamily = Constants.HELVERTICA_NEUE_LT_STD;
            startTimePickerButton.TextOrientation = interfaces.TextOrientation.Left;
            startTimePickerButton.TextColor = Color.Gray;
            startTimePickerButton.WidthRequest = deviceSpec.ScreenWidth * 40 / 100;
			startTimePickerButton.Clicked += (object sender, EventArgs e) => 
			{
                try
                {
                    startTimePicker.Time = new TimeSpan(12, 00, 00);
                    startTimePicker.Focus();
                }
                catch (Exception ex)
                {
                    var test = ex.Message;
                }
			};
		
		
		   // endDatePickerButton = new CustomImageButton();
            endDatePickerButton.ImageName = Device.OnPlatform("select_box_whitebg.png", "select_box_whitebg.png", "//Assets//select_box_whitebg.png");
			endDatePickerButton.Text = "End Date";
			endDatePickerButton.FontSize = 17;
			endDatePickerButton.FontFamily = Constants.HELVERTICA_NEUE_LT_STD;
			endDatePickerButton.TextOrientation = interfaces.TextOrientation.Left;
			endDatePickerButton.TextColor = Color.Gray;
			endDatePickerButton.WidthRequest = deviceSpec.ScreenWidth * 40 / 100;
			endDatePickerButton.Clicked += (object sender, EventArgs e) => 	
			{
                try
                {
					endDatePicker.Date = DateTime.Now.AddDays(1);
                    endDatePicker.Focus();
                }
                catch (Exception ex)
                {
                    var test = ex.Message;
                }
			};


		   // endTimePickerButton = new CustomImageButton();
            endTimePickerButton.ImageName = Device.OnPlatform("select_box_whitebg.png", "select_box_whitebg.png", "//Assets//select_box_whitebg.png");
			endTimePickerButton.Text = " End Time";
			endTimePickerButton.FontSize = 17;
			endTimePickerButton.FontFamily = Constants.HELVERTICA_NEUE_LT_STD;
			endTimePickerButton.TextOrientation = interfaces.TextOrientation.Left;
			endTimePickerButton.TextColor = Color.Gray;
			endTimePickerButton.WidthRequest = deviceSpec.ScreenWidth * 40 / 100;
			endTimePickerButton.Clicked += (object sender, EventArgs e) => 	
			{
                try
                {
                    endTimePicker.Time = new TimeSpan(12, 00, 00);
                    endTimePicker.Focus();
                }
                catch (Exception ex)
                {
                    var test = ex.Message;
                }
			};

			CustomImageButton reminderPickerButton = new CustomImageButton ();
			Picker reminderPicker = new Picker ();
			reminderPicker.Items.Add ("15");
			reminderPicker.Items.Add ("30");
			reminderPicker.Items.Add ("45");
			reminderPicker.Items.Add ("60");
			reminderPicker.WidthRequest = 0;
			reminderPicker.HeightRequest = 0;
			reminderPicker.SelectedIndexChanged += (object sender, EventArgs e) => 
			{
				reminderPickerButton.Text = reminderPicker.Items[reminderPicker.SelectedIndex];
			};


            reminderPickerButton.ImageName = Device.OnPlatform("select_box_whitebg.png", "select_box_whitebg.png", "//Assets//select_box_whitebg.png");
			reminderPickerButton.Text = " Reminder";
			reminderPickerButton.TextOrientation = TextOrientation.Middle;         
			reminderPickerButton.FontSize = 17;
			reminderPickerButton.FontFamily = Constants.HELVERTICA_NEUE_LT_STD;
			reminderPickerButton.TextOrientation = interfaces.TextOrientation.Left;
			reminderPickerButton.TextColor = Color.Gray;
			reminderPickerButton.WidthRequest = deviceSpec.ScreenWidth * 90 / 100;
			reminderPickerButton.Clicked += (object sender, EventArgs e) => 
			{
				reminderPicker.Focus();
			};

			Button createReminderButton = new Button ();
			createReminderButton.Text = "Create Reminder";
			createReminderButton.TextColor = Color.White;
			createReminderButton.BackgroundColor = Color.FromRgb( 30, 126, 210 );
			createReminderButton.WidthRequest = deviceSpec.ScreenWidth * 90 / 100;
			createReminderButton.Clicked += async (object sender, EventArgs e) =>
			{
                try
                {

                    App.CalPage = this;
                    if (startDatePickerButton.Text == "Start Date" || endDatePickerButton.Text == "End Date")
                    {
                        await DisplayAlert(Constants.ALERT_TITLE, "Please select start date and end date to proceed", Constants.ALERT_OK);
                        return;
                    }
                    IReminderService reminder = DependencyService.Get<IReminderService>();

                    if (Device.OS == TargetPlatform.iOS)
                    {
                        var access = await reminder.RequestAccessAsync();
                        if (!access)
                            return;
                    }

                    int reminderValue = 0;
                    if (reminderPickerButton.Text != null && reminderPickerButton.Text.Length > 0 && reminderPicker.SelectedIndex >= 0)
                    {
                        reminderValue = Convert.ToInt32(reminderPickerButton.Text);
                    }

                    DateTime startDateAndTime = new DateTime(startDatePicker.Date.Year, startDatePicker.Date.Month, startDatePicker.Date.Day, startTimePicker.Time.Hours, startTimePicker.Time.Minutes, 0);
                    DateTime endDateAndTime = new DateTime(endDatePicker.Date.Year, endDatePicker.Date.Month, endDatePicker.Date.Day, endTimePicker.Time.Hours, endTimePicker.Time.Minutes, 0);

                    // add this to app datetime fields to serve to api.
                    App.SelectedActionStartDate = startDateAndTime.ToString(); //to be converted into UTC
                    App.SelectedActionEndDate = endDateAndTime.ToString(); //to be converted into UTC
                    App.SelectedActionReminderValue = reminderValue;
                    if (!reminder.Remind(startDateAndTime, endDateAndTime, title.Text, messege.Text, reminderValue))
                    {
                        await DisplayAlert("Purpose Color", "Error in creating calendar event", Constants.ALERT_OK);
                    }
                    else
                    {
                        IProgressBar progress = DependencyService.Get<IProgressBar>();
                        progress.ShowToast("Calander event created");
                        if (Device.OS != TargetPlatform.iOS)
                        { //Navigation.PopAsync(); 
                            await Navigation.PopModalAsync();
                        }

                    }

                }
                catch (Exception ex)
                {
                    var test = ex.Message;
                }
			};

            masterLayout.AddChildToLayout(mainTitleBar, 0, 0);
            masterLayout.AddChildToLayout(subTitleBar, 0, Device.OnPlatform(9, 10, 10));

			masterLayout.AddChildToLayout(startDatePicker, 0, 0);
            masterLayout.AddChildToLayout(startTimePicker, 0, 0);
			masterLayout.AddChildToLayout(endDatePicker, 0, 0);
			masterLayout.AddChildToLayout(endTimePicker, 0, 0);
			masterLayout.AddChildToLayout(reminderPicker, 0, 0);

			masterLayout.AddChildToLayout (title, 5, 20);
			masterLayout.AddChildToLayout(messege, 5, 30);
			masterLayout.AddChildToLayout(startDatePickerButton, 5, 40);
			masterLayout.AddChildToLayout(startTimePickerButton, 55, 40);
			masterLayout.AddChildToLayout(endDatePickerButton, 5, 50);
			masterLayout.AddChildToLayout(endTimePickerButton, 55, 50);
			masterLayout.AddChildToLayout(reminderPickerButton, 5, 70);
			masterLayout.AddChildToLayout(createReminderButton, 5, 80);
            Content = masterLayout;
        }
		public void Dispose()
		{
			this.eventPickerButton = null;
			this.eventPickerButton.Clicked -= OnEventPickerButtonClicked;
			this.emotionalPickerButton = null;
			this.emotionalPickerButton.Clicked -= OnEmotionalPickerButtonClicked;
			this.slider = null;
			this.masterLayout = null;
			this.progressBar = null;
			this.selectedEmotionItem = null;
			this.selectedEventItem = null;
			this.about = null;
			this.subTitleBar.NextButtonTapRecognizer.Tapped -= OnNextButtonTapRecognizerTapped;
			this.subTitleBar.BackButtonTapRecognizer.Tapped -= OnBackButtonTapRecognizerTapped;
			this.subTitleBar = null;
			this.Appearing -= OnFeelingNowPageAppearing;
			this.mainTitleBar = null;
			sliderValLabel = null;
			emotionTextLabel = null;
			eventTextLabel = null;
			imagesContainer = null;
			feedbackLabelStack = null;
			sliderFeedbackStack = null;
			feelingFeedbackStack = null;
			eventFeedbackStack = null;
			hLine = null;
			emotionTextTap = null;

			GC.Collect();
		}
		public FeelingNowPage()
		{
			NavigationPage.SetHasNavigationBar(this, false);
			masterLayout = new CustomLayout();
			masterLayout.BackgroundColor = Color.FromRgb(244, 244, 244);
			screenHeight = App.screenHeight;
			screenWidth = App.screenWidth;
			progressBar = DependencyService.Get<IProgressBar>();
			currentUser = App.Settings.GetUser ();
			AddEventsSituationsOrThoughts.feelingsPage = this;

			mainTitleBar = new PurposeColorTitleBar(Color.FromRgb(8, 135, 224), "Purpose Color", Color.Black, "back", true);
			mainTitleBar.imageAreaTapGestureRecognizer.Tapped += imageAreaTapGestureRecognizer_Tapped;
			subTitleBar = new PurposeColorSubTitleBar(Constants.SUB_TITLE_BG_COLOR, "Emotional Awareness");
			subTitleBar.NextButtonTapRecognizer.Tapped += OnNextButtonTapRecognizerTapped;
			subTitleBar.BackButtonTapRecognizer.Tapped += OnBackButtonTapRecognizerTapped;

			slider = new CustomSlider
			{
				Minimum = -2,
				Maximum = 2,
				WidthRequest = screenWidth * 90 / 100
			};
			slider.StopGesture = GetstopGetsture;

			Label howYouAreFeeling = new Label();
			howYouAreFeeling.Text = Constants.HOW_YOU_ARE_FEELING;
			howYouAreFeeling.FontFamily = Constants.HELVERTICA_NEUE_LT_STD;
			howYouAreFeeling.TextColor = Color.FromRgb(40, 47, 50);
			howYouAreFeeling.HorizontalOptions = LayoutOptions.Center;

			Label howYouAreFeeling2 = new Label();
			howYouAreFeeling2.Text = "feeling now ?";
			howYouAreFeeling2.FontFamily = Constants.HELVERTICA_NEUE_LT_STD;
			howYouAreFeeling2.TextColor = Color.FromRgb(40, 47, 50);
			howYouAreFeeling2.HorizontalOptions = LayoutOptions.Center;

			#region  Emotion pic button
			emotionalPickerButton = new PurposeColor.interfaces.CustomImageButton ();
			emotionalPickerButton.ImageName = Device.OnPlatform ("select_box_whitebg.png", "select_box_whitebg.png", @"/Assets/select_box_whitebg.png");
			emotionalPickerButton.Text = "Select Emotion";

			emotionalPickerButton.FontFamily = Constants.HELVERTICA_NEUE_LT_STD;
			emotionalPickerButton.TextOrientation = interfaces.TextOrientation.Left;
			emotionalPickerButton.TextColor = Color.Gray;
			emotionalPickerButton.WidthRequest = screenWidth * 90 / 100;
			emotionalPickerButton.Clicked += OnEmotionalPickerButtonClicked;

			eventPickerButton = new PurposeColor.interfaces.CustomImageButton ();
			eventPickerButton.IsVisible = false;
			eventPickerButton.ImageName = Device.OnPlatform ("select_box_whitebg.png", "select_box_whitebg.png", "/Assets/select_box_whitebg.png");
			eventPickerButton.Text = "Events, Situation & Thoughts";
			eventPickerButton.FontFamily = Constants.HELVERTICA_NEUE_LT_STD;
			eventPickerButton.TextOrientation = interfaces.TextOrientation.Left;
			eventPickerButton.TextColor = Color.Gray;
			eventPickerButton.WidthRequest = screenWidth * 90 / 100;


			if (!eventsDisplaying)
			{
				eventPickerButton.Clicked += OnEventPickerButtonClicked;
			}
			#endregion

			#region About text
			about = new Label ();
			about.IsVisible = false;
			about.Text = "About";
			about.FontFamily = Constants.HELVERTICA_NEUE_LT_STD;
			about.WidthRequest = screenWidth;
			about.HorizontalOptions = LayoutOptions.Center;
			about.XAlign = TextAlignment.Center;

			about.FontFamily = Constants.HELVERTICA_NEUE_LT_STD;
			about.TextColor = Color.FromRgb (40, 47, 50);

			int fontSize = 15;
			if (App.screenDensity > 1.5) {
				howYouAreFeeling.FontSize = Device.OnPlatform (20, 22, 30);
				howYouAreFeeling2.FontSize = Device.OnPlatform (20, 22, 30);
				about.FontSize = Device.OnPlatform (15, 18, 30);

				emotionalPickerButton.HeightRequest = screenHeight * 6 / 100;
				fontSize = 17;
				eventPickerButton.HeightRequest = screenHeight * 6 / 100;
			} else {
				howYouAreFeeling.FontSize = Device.OnPlatform (16, 18, 26);
				howYouAreFeeling2.FontSize = Device.OnPlatform (16, 18, 26);
				about.FontSize = Device.OnPlatform (16, 18, 26);

				emotionalPickerButton.HeightRequest = screenHeight * 9 / 100;
				fontSize = 15;
				eventPickerButton.HeightRequest = screenHeight * 9 / 100;
			}

			emotionalPickerButton.FontSize = Device.OnPlatform (fontSize, fontSize, 22);
			eventPickerButton.FontSize = Device.OnPlatform (fontSize, fontSize, 22);
			#endregion

			this.Appearing += OnFeelingNowPageAppearing;

			sliderValue = slider.CurrentValue;
			masterLayout.AddChildToLayout(mainTitleBar, 0, 0);
			masterLayout.AddChildToLayout(subTitleBar, 0, Device.OnPlatform(9, 10, 10));

			sliderValLabel = new Label
			{
				TextColor = Constants.BLUE_BG_COLOR,
				BackgroundColor = Color.Transparent,
				XAlign = TextAlignment.Start
			};

			sliderValueImage = new Image {
				Source = "Sliderfeedback0.png",
				HeightRequest = 30,
				Aspect = Aspect.Fill, 
				InputTransparent = true,
				BackgroundColor = Color.Transparent,

			};

			#region SLIDER LABEL TAP

			TapGestureRecognizer sliderLabelTapRecognizer = new TapGestureRecognizer();
			sliderLabelTapRecognizer.Tapped += (s, e) =>
			{
				/// show a slider as a popup and get its value,
				RemoveSliderPopup();
				popupSlider = new CustomSlider
				{
					Minimum = -2,
					Maximum = 2,
					WidthRequest = screenWidth * 90 / 100,
					HorizontalOptions = LayoutOptions.Center,
					VerticalOptions = LayoutOptions.Center,
					CurrentValue = sliderValue
				};

				StackLayout sliderBg = new StackLayout
				{
					BackgroundColor = Color.Black,
					Opacity = .95,
					HeightRequest = App.screenHeight,
					WidthRequest = App.screenWidth,
					HorizontalOptions = LayoutOptions.Center,
					VerticalOptions = LayoutOptions.Center,
					Children = {
						new StackLayout{HeightRequest = 250},
						new StackLayout{
							Children = { popupSlider },
							Padding = 10,
							BackgroundColor = Color.FromRgb(244, 244, 244),
							HorizontalOptions = LayoutOptions.Center,
							VerticalOptions = LayoutOptions.Center,
							Opacity = 1
						}
					},
					ClassId = "sliderBg"
				};

				TapGestureRecognizer sliderBgTapRecognizer = new TapGestureRecognizer();
				sliderBg.GestureRecognizers.Add(sliderBgTapRecognizer);
				sliderBgTapRecognizer.Tapped += (snd, eve) =>
				{
					RemoveSliderPopup();
				};

				popupSlider.CurrentValue = slider.CurrentValue;
				popupSlider.StopGesture = GetstopGetsture;

				masterLayout.AddChildToLayout(sliderBg, 0, 0);
			};

			#endregion

			emotionTextLabel = new Label
			{
				TextColor = Constants.BLUE_BG_COLOR,
				BackgroundColor = Color.Transparent,
				XAlign = TextAlignment.Start,
				FontFamily = Constants.HELVERTICA_NEUE_LT_STD,
				FontSize = Device.OnPlatform(12, 14, 26)
			};
			emotionTextTap = new TapGestureRecognizer();
			emotionTextTap.Tapped += EmotionTextTap_Tapped;

			eventTextLabel = new Label
			{
				TextColor = Constants.BLUE_BG_COLOR,
				BackgroundColor = Color.Transparent,
				XAlign = TextAlignment.Start,
				FontFamily = Constants.HELVERTICA_NEUE_LT_STD,
				FontSize = Device.OnPlatform(12, 14, 26)
			};

			eventTextTap = new TapGestureRecognizer();
			eventTextTap.Tapped += async (s, e) =>
			{
				if (!eventsDisplaying)
				{
					await Task.Delay(100);
					OnEventPickerButtonClicked(eventPickerButton, EventArgs.Empty);
				}
			};
			//eventTextLabel.GestureRecognizers.Add(eventTextTap);

			sliderFeedbackStack = new StackLayout {
				IsVisible = false,
				BackgroundColor = Color.Transparent,
				VerticalOptions = LayoutOptions.Center,
				Orientation = StackOrientation.Horizontal, 
				Spacing = 0, Padding = new Thickness (App.screenWidth * .10, 0, 10, 0), 
				Children = {
					new Label {
						FontFamily = Constants.HELVERTICA_NEUE_LT_STD,
						FontSize = Device.OnPlatform(12, 14, 26),
						Text = "Happiness : ",
						TextColor = Color.Black,
						VerticalOptions = LayoutOptions.End,
					},
					sliderValueImage
				}
			};
			sliderFeedbackStack.GestureRecognizers.Add(sliderLabelTapRecognizer);


			feelingFeedbackStack = new StackLayout {
				IsVisible = false,
				Orientation = StackOrientation.Horizontal,
				Spacing = 0,
				Padding = new Thickness (App.screenWidth * .10, 0, 10, 0),
				Children = {
					new Label {
						Text = "Feeling : " ,
						TextColor = Color.Black,
						FontFamily = Constants.HELVERTICA_NEUE_LT_STD,
						FontSize = Device.OnPlatform(12, 14, 26),
					},
					emotionTextLabel
				}
			};
			feelingFeedbackStack.GestureRecognizers.Add(emotionTextTap);

			eventFeedbackStack = new StackLayout {
				IsVisible = false,
				//BackgroundColor = Color.Red,
				Orientation = StackOrientation.Horizontal,
				Spacing = 0,
				Padding = new Thickness (App.screenWidth * .10, 0, 10, 0),
				Children = {
					new Label {
						Text = "Event : " ,
						TextColor = Color.Black,
						FontFamily = Constants.HELVERTICA_NEUE_LT_STD,
						FontSize = Device.OnPlatform(12, 14, 26),
					},
					eventTextLabel
				}
			};
			eventFeedbackStack.GestureRecognizers.Add(eventTextTap);

			// add this to a customLayout n a stack with bg transparent.
			topLabelsContainer = new CustomLayout {
				WidthRequest = screenWidth,
			};

			topLabelBg = new StackLayout {
				WidthRequest = screenWidth,
				BackgroundColor = Color.Gray,
				Opacity = .2
			};

			topBgandCloseBtn = new StackLayout {
				//BackgroundColor  = Color.Yellow, // for testing only
				Orientation = StackOrientation.Vertical,
				Spacing = 0,
				Children = {topLabelBg}
			};

			topCloseBtn = new Image {
				Source = "downarrow.png",
				IsVisible = false,
				HeightRequest = 25,
				WidthRequest = 35,
				HorizontalOptions = LayoutOptions.End
			};
			topBgandCloseBtn.Children.Add (topCloseBtn);

			TapGestureRecognizer topCloseBtnTapRecognizer = new TapGestureRecognizer();
			topCloseBtnTapRecognizer.Tapped += (s, e) =>
			{
				AnimateToplabels(0);
			};

			topCloseBtn.GestureRecognizers.Add (topCloseBtnTapRecognizer);

			feedbackLabelStack = new StackLayout
			{
				Orientation = StackOrientation.Vertical,
				//BackgroundColor = Constants.PAGE_BG_COLOR_LIGHT_GRAY,
				HorizontalOptions = LayoutOptions.Center,
				VerticalOptions = LayoutOptions.Center,
				Spacing = 2,
				WidthRequest = App.screenWidth,
				Children = {sliderFeedbackStack, feelingFeedbackStack, eventFeedbackStack}
			};
			topLabelsContainer.AddChildToLayout (topBgandCloseBtn, 0, 0);
			topLabelsContainer.AddChildToLayout (feedbackLabelStack, 0, 0);


			//masterLayout.AddChildToLayout(feedbackLabelStack, 0, Device.OnPlatform(16, 18, 10));
			masterLayout.AddChildToLayout(topLabelsContainer, 0, Device.OnPlatform(16, 18, 10));

			masterLayout.AddChildToLayout(howYouAreFeeling, 16, Device.OnPlatform(33, 33, 30));
			masterLayout.AddChildToLayout(howYouAreFeeling2, 29, Device.OnPlatform(38, 38, 27));
			masterLayout.AddChildToLayout(slider, 5, 43);

			masterLayout.AddChildToLayout(emotionalPickerButton, 5, Device.OnPlatform(50, 57, 47));
			masterLayout.AddChildToLayout(about, 0, Device.OnPlatform(62, 66, 59));
			masterLayout.AddChildToLayout(eventPickerButton, 5, Device.OnPlatform(70, 73, 67));




			//SetFeedBackLablText();
			Content = masterLayout;

		}
		public void Dispose()
		{
			GC.Collect ();
			plotView = null;
			masterLayout = null;
			subTitleBar = null;
		    mainTitleBar = null;

			region1DownArrow = null;
			region2DownArrow = null;;
			region3DownArrow = null;;
			region4DownArrow = null;;
			region1ButtonStack = null;;
			region2ButtonStack = null;;
			region3ButtonStack = null;;
			region4ButtonStack = null;;

			region1WarmLabel = null;
			region2AssertiveLabel = null;
			region3PatientLabel = null;
			region4DetailedLabel = null;
			emotionList = null;
			graphAndEmotionListContainer = null;
			BottomStackContainer = null;
		}
		public PieGraphPage()
		{
			NavigationPage.SetHasNavigationBar(this, false);
			masterLayout = new CustomLayout();
			masterLayout.BackgroundColor = Color.FromRgb(244, 244, 244);
			progressBar = DependencyService.Get<IProgressBar>();

			this.Appearing += OnGraphPageAppearing;

			mainTitleBar = new PurposeColorTitleBar(Color.FromRgb(8, 135, 224), "Purpose Color", Color.Black, "back", true);
			mainTitleBar.imageAreaTapGestureRecognizer.Tapped += imageAreaTapGestureRecognizer_Tapped;
			subTitleBar = new PurposeColorSubTitleBar(Constants.SUB_TITLE_BG_COLOR, "Emotional Intellegence", false);
			subTitleBar.BackButtonTapRecognizer.Tapped += OnBackButtonTapRecognizerTapped;
			masterLayout.AddChildToLayout(mainTitleBar, 0, 0);
			masterLayout.AddChildToLayout(subTitleBar, 0, Device.OnPlatform(9, 10, 10));

			graphAndEmotionListContainer = new StackLayout
			{
				HorizontalOptions = LayoutOptions.Center,
				Spacing = 5,
				Orientation = StackOrientation.Vertical
			};

			Label headingLabel = new Label
			{
				Text = "My Emotional Zone",
				FontFamily = Constants.HELVERTICA_NEUE_LT_STD,
				TextColor = Constants.BLUE_BG_COLOR, //Color.FromRgb(40, 47, 50),
				FontSize = App.screenDensity >= 2 ? Device.OnPlatform(14, 16, 20) : Device.OnPlatform(10, 12, 16),
				VerticalOptions = LayoutOptions.Center
			};

			Image filter = new Image {
				Source = "filter.png",
				HeightRequest = 25,
				WidthRequest = 25,
				Aspect = Aspect.AspectFill,
				HorizontalOptions = LayoutOptions.End
			};
			TapGestureRecognizer filterTapRecognizer = new TapGestureRecognizer();
			filter.GestureRecognizers.Add(filterTapRecognizer);
			filterTapRecognizer.Tapped += async (sender, e) => {
				await DisplayAlert(Constants.ALERT_TITLE,"Filter option to be implemented",Constants.ALERT_OK);
			};

			graphAndEmotionListContainer.Children.Add(new StackLayout{ Spacing = 70, Padding  = new Thickness(80,2,10,0), Orientation = StackOrientation.Horizontal , Children = {headingLabel,filter}});


			#region REGION 1 BUTTON STACK


			region1WarmLabel = new Label
			{
				Text = "Warm",
				WidthRequest = 180, 
				FontSize = Device.OnPlatform(14, 16, 20 ),
				VerticalOptions = LayoutOptions.End,
				TextColor = Color.FromRgb(40, 47, 50),
			};

			region1DownArrow = new Image
			{
				Source = "downarrow",
				HeightRequest = 20,
				WidthRequest = 20
			};
			Image region1Icon = new Image
			{
				Source = "ic_red",
				HeightRequest = 25,
				WidthRequest = 25
			};

			StackLayout region1Button = new StackLayout
			{
				Orientation = StackOrientation.Horizontal,
				Spacing = Device.OnPlatform(20, 10, 40),
				Padding = new Thickness(10,10,10,1),
				Children = { region1Icon, region1WarmLabel, region1DownArrow }
			};
			TapGestureRecognizer emotion1TapRecognizer = new TapGestureRecognizer();
			region1Button.GestureRecognizers.Add(emotion1TapRecognizer);
			emotion1TapRecognizer.Tapped += Emotion1TapRecognizerTapped;

			region1ButtonStack = new StackLayout
			{
				// add all warm button elements to this container.
				// head icon, label and arrow icon. rotate the arrow icon 180 degree on each click.

				Orientation = StackOrientation.Vertical,
				Children = { region1Button }
			};

			#endregion

			#region REGION 2 BUTTON STACK


			region2AssertiveLabel = new Label
			{
				Text = "Assertive",
				WidthRequest = 180,
				FontSize = Device.OnPlatform(14, 16, 20 ),
				VerticalOptions = LayoutOptions.End,
				TextColor = Color.FromRgb(40, 47, 50),
			};
			region2DownArrow = new Image
			{
				Source = "downarrow",
				HeightRequest = 20,
				WidthRequest = 20
			};
			Image region2Icon = new Image
			{
				Source = "ic_orge",
				HeightRequest = 25,
				WidthRequest = 25
			};
			StackLayout region2Button = new StackLayout
			{
				Orientation = StackOrientation.Horizontal,
				Spacing = Device.OnPlatform(20, 10, 40),
				Padding = new Thickness(10,10,10,1),
				Children = { region2Icon, region2AssertiveLabel, region2DownArrow }
			};
			region2ButtonStack = new StackLayout
			{
				Orientation = StackOrientation.Vertical,
				Children = { region2Button }
			};
			TapGestureRecognizer emotion2TapRecognizer = new TapGestureRecognizer();
			region2Button.GestureRecognizers.Add(emotion2TapRecognizer);
			emotion2TapRecognizer.Tapped += Emotion2TapRecognizerTapped;
			#endregion

			#region REGION 3 BUTTON STACK
			region3DownArrow = new Image
			{
				Source = "downarrow",
				HeightRequest = 20,
				WidthRequest = 20
			};

			region3PatientLabel = new Label
			{
				Text = "Patient",
				WidthRequest = 180,
				FontSize = Device.OnPlatform(14, 16, 20 ),
				VerticalOptions = LayoutOptions.End,
				TextColor = Color.FromRgb(40, 47, 50),
			};
			Image region3Icon = new Image
			{
				Source = "ic_green",
				HeightRequest = 25,
				WidthRequest = 25
			};

			StackLayout region3Button = new StackLayout
			{
				Orientation = StackOrientation.Horizontal,
				Spacing = Device.OnPlatform(20, 10, 40),
				Padding = new Thickness(10,10,10,1),
				Children = { region3Icon, region3PatientLabel, region3DownArrow }
			};
			TapGestureRecognizer emotion3TapRecognizer = new TapGestureRecognizer();
			region3Button.GestureRecognizers.Add(emotion3TapRecognizer);
			emotion3TapRecognizer.Tapped += Emotion3TapRecognizerTapped;

			region3ButtonStack = new StackLayout
			{
				Orientation = StackOrientation.Vertical,
				Children = { region3Button }
			};


			#endregion

			#region REGION 4 BUTTON STACK

			region4DownArrow = new Image
			{
				Source = "downarrow",
				HeightRequest = 20,
				WidthRequest = 20
			};


			region4DetailedLabel = new Label
			{
				Text = "Detailed",
				WidthRequest = 180,
				FontSize = Device.OnPlatform(14, 16, 20 ),
				VerticalOptions = LayoutOptions.Center,
				TextColor = Color.FromRgb(40, 47, 50),
			};
			Image region4Icon = new Image
			{
				Source = "ic_blu",
				HeightRequest = 25,
				WidthRequest = 25
			};


			StackLayout region4Button = new StackLayout
			{
				Orientation = StackOrientation.Horizontal,
				Spacing = Device.OnPlatform(20, 10, 40),
				Padding = new Thickness(10,10,10,1),
				Children = { region4Icon, region4DetailedLabel, region4DownArrow }
			};
			TapGestureRecognizer emotion4TapRecognizer = new TapGestureRecognizer();
			region4Button.GestureRecognizers.Add(emotion4TapRecognizer);
			emotion4TapRecognizer.Tapped += Emotion4TapRecognizerTapped;
			region4ButtonStack = new StackLayout
			{
				Orientation = StackOrientation.Vertical,
				Children = { region4Button }
			};

			#endregion

			BottomStackContainer = new StackLayout
			{
				// add all buttons to this container.
				BackgroundColor = Color.Transparent,
				HorizontalOptions = LayoutOptions.Center,
				WidthRequest = App.screenWidth * .80,
				Orientation = StackOrientation.Vertical,
				Padding = new Thickness(0,0,0,10),
				Children = { new StackLayout {Orientation = StackOrientation.Vertical, Padding = new Thickness(Device.OnPlatform(5, 10, 10),0,0,10), Spacing = 5, Children = {region4ButtonStack, region3ButtonStack, region2ButtonStack, region1ButtonStack} }} // 1. red, 2. blue
			};

			ScrollView contentScrool = new ScrollView {
				HeightRequest = App.screenHeight - (App.screenHeight * .20),
				WidthRequest = App.screenWidth,
				Content = graphAndEmotionListContainer,
				IsClippedToBounds = true,
				Orientation = ScrollOrientation.Vertical,
				HorizontalOptions = LayoutOptions.Center
			};

			masterLayout.AddChildToLayout (contentScrool, 0, 18);

			Content = new StackLayout {
				HeightRequest = App.screenHeight,
				WidthRequest = App.screenWidth,
				Children = { masterLayout }
			};
		}