public GemsMoreDetailsPage(GemsEmotionsDetails emotionsList, GemsGoalsDetails goalsList, string eventMedia, string eventMediaThumb, string eventNoMedia, string goalsMedia, string goalsMediaThumb, string goalsNoMedia)
        {

            NavigationPage.SetHasNavigationBar(this, false);
            masterLayout = new CustomLayout();
            masterLayout.BackgroundColor = Color.FromRgb(244, 244, 244);
			IProgressBar progressBar = DependencyService.Get<IProgressBar>();
            eventsMediaPath = eventMedia;
            eventsMediaThumbPath = eventMediaThumb;
			goalsMediaPath = goalsMedia;
			goalsMediaThumbPath = goalsMediaThumb;
			goalsNoMediaPath = goalsNoMedia;
			eventsNoMediaPath = eventNoMedia;
            emotionsMasterList = emotionsList;
			goalsMasterList = goalsList;
			isFirstTime = true;


            // PurposeColorTitleBar mainTitleBar = new PurposeColorTitleBar(Color.FromRgb(8, 135, 224), "Purpose Color", Color.Black, "back", false);
            mainTitleBar = new GemsPageTitleBarWithBack(Color.FromRgb(8, 135, 224), "Add Supporting Emotions", Color.White, "", false);
			mainTitleBar.imageAreaTapGestureRecognizer.Tapped += (object sender, EventArgs e) => 
			{
                try
                {
					App.masterPage.IsPresented = !App.masterPage.IsPresented;
                }
                catch (Exception)
                {
                    
                }
			};

            if (emotionsMasterList != null)
            {
                mainTitleBar.title.Text = emotionsMasterList.emotion_title;
            }
            else
            {
                mainTitleBar.title.Text = goalsMasterList.goal_title;
            }


            masterScroll = new ScrollView();
            masterScroll.WidthRequest = App.screenWidth;
            masterScroll.HeightRequest = App.screenHeight * 85 / 100;
			masterScroll.IsClippedToBounds = true;
            masterStack = new StackLayout();
            masterStack.Orientation = StackOrientation.Vertical;
            masterStack.BackgroundColor = Color.Transparent;


			this.Appearing += OnAppearing;


            masterScroll.Content = masterStack;
            masterLayout.AddChildToLayout(mainTitleBar, 0, 0);
            masterLayout.AddChildToLayout(masterScroll, 0, 10);
            Content = masterLayout;
        }
        public void Dispose()
        {
			masterLayout = null;
			mainTitleBar = null;
			masterScroll = null;
			masterStack = null;
			emotionsMasterList = null;
			goalsMasterList = null;
			eventsMediaPath = null;
			eventsMediaThumbPath = null;
			goalsMediaPath = null;
			goalsMediaThumbPath = null;
			goalsNoMediaPath = null;
			eventsNoMediaPath = null;
			GC.Collect ();
        }
		public GemsEmotionsObject GetGemsEmotionsObject()
		{
            try
            {
                GemsEmotionsObject masterObject = new GemsEmotionsObject();

                List<EventTitle> listEventTitle = new List<EventTitle>();
                List<EventDetail> listEventDetails = new List<EventDetail>();
                List<EventMedia> listEventMedia = new List<EventMedia>();
                List<EventDatetime> listEventDatetime = new List<EventDatetime>();
                List<GemsEmotionsDetailsDB> listEmotions = new List<GemsEmotionsDetailsDB>();
                List<GemsEmotionsDetails> gemsEmotions = new List<GemsEmotionsDetails>();

                listEventTitle = (from t in Connection.Table<EventTitle>() select t).ToList();
                listEventDetails = (from t in Connection.Table<EventDetail>() select t).ToList();
                listEventMedia = (from t in Connection.Table<EventMedia>() select t).ToList();
                listEventDatetime = (from t in Connection.Table<EventDatetime>() select t).ToList();
                listEmotions = (from t in Connection.Table<GemsEmotionsDetailsDB>() select t).ToList();

                masterObject.resultarray = new List<GemsEmotionsDetails>();
                foreach (var item in listEmotions)
                {
                    GemsEmotionsDetails resultArray = new GemsEmotionsDetails();

                    resultArray.user_id = item.user_id;
                    resultArray.emotion_id = item.emotion_id;
                    resultArray.emotion_title = item.emotion_title;

                    resultArray.event_title = new List<EventTitle>();
                    resultArray.event_details = new List<EventDetail>();
                    resultArray.event_datetime = new List<EventDatetime>();
                    resultArray.event_media = new List<EventMedia>();

                    // Title
                    foreach (var titeObject in listEventTitle)
                    {
                        if (titeObject.emotion_id == item.emotion_id)
                            resultArray.event_title.Add(titeObject);
                    }

                    // Details
                    foreach (var detailsObject in listEventDetails)
                    {
                        if (detailsObject.emotion_id == item.emotion_id)
                            resultArray.event_details.Add(detailsObject);
                    }

                    // date and time
                    foreach (var dateObject in listEventDatetime)
                    {
                        if (dateObject.emotion_id == item.emotion_id)
                            resultArray.event_datetime.Add(dateObject);
                    }

                    // media
                    foreach (var mediaObject in listEventMedia)
                    {
                        if (mediaObject.emotion_id == item.emotion_id)
                            resultArray.event_media.Add(mediaObject);
                    }

                    masterObject.resultarray.Add(resultArray);
                }


                masterObject.code = (listEmotions != null && listEmotions.Count > 0) ? listEmotions[0].code : "";
                masterObject.noimageurl = (listEmotions != null && listEmotions.Count > 0) ? listEmotions[0].noimageurl : "";
                masterObject.mediapath = (listEmotions != null && listEmotions.Count > 0) ? listEmotions[0].mediapath : "";
                masterObject.mediathumbpath = (listEmotions != null && listEmotions.Count > 0) ? listEmotions[0].mediathumbpath : "";
                return masterObject;
            }
            catch (Exception)
            {
                
                return null;
            }

		}