public ChatPage ()
		{
			NavigationPage.SetHasNavigationBar(this, false);
			progressBar = DependencyService.Get< IProgressBar > ();
			mainTitleBar = new PurposeColorTitleBar(Color.FromRgb(8, 135, 224), "Purpose Color", Color.Black, "back", true);
			mainTitleBar.imageAreaTapGestureRecognizer.Tapped += (object sender, EventArgs e) => 
			{
				App.masterPage.IsPresented = true;
			};
			subTitleBar = new CommunityGemSubTitleBar(Constants.SUB_TITLE_BG_COLOR, Constants.COMMUNITY_GEMS, true);
			subTitleBar.BackButtonTapRecognizer.Tapped += async (object sender, EventArgs e) => 
			{
				await Navigation.PopAsync();
			};

			this.Appearing += OnChatPageAppearing;
			masterLayout = new CustomLayout ();
			masterLayout.WidthRequest = App.screenWidth;
			masterLayout.HeightRequest = App.screenHeight;


			chatContactsListView = new ListView();
			chatContactsListView.ItemTemplate = new DataTemplate(typeof(ChatContactListCell));
			chatContactsListView.SeparatorVisibility = SeparatorVisibility.Default;
			chatContactsListView.BackgroundColor = Color.White;
			chatContactsListView.HeightRequest = App.screenHeight * 90 / 100;
			chatContactsListView.HasUnevenRows = true;
			//chatContactsListView.RowHeight = (int) App.screenHeight * 10 / 100;
			chatContactsListView.SeparatorColor = Color.FromRgb (8, 135, 224);
			chatContactsListView.ItemSelected +=  async (object sender, SelectedItemChangedEventArgs e) => 
			{
				string curentUserId = App.Settings.GetUser().UserId.ToString();
				ObservableCollection<ChatDetails> chats = new ObservableCollection<ChatDetails>();
				ChatUsersInfo selItem = chatContactsListView.SelectedItem as ChatUsersInfo;
				if( selItem != null )
				{
					ChatHistoryObject history = await ServiceHelper.GetChatHistory ( selItem.user_id, curentUserId );

					if (history != null)
					{
						foreach (var item in history.resultarray) 
						{
							ChatDetails detail = new ChatDetails ();
							detail.CurrentUserid = curentUserId;
							detail.FromUserID = item.from_id;
							detail.Message = item.msg;
							chats.Add ( detail );
						}
					}

					await Navigation.PushAsync( new ChatDetailsPage( chats, selItem.user_id, selItem.profileImgUrl,  selItem.firstname ) );
				}
				chatContactsListView.SelectedItem= null;
			};


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

			Content = masterLayout;
		}
		//public GemsDetailsPage(List<EventMedia> mediaArray, List<ActionMedia> actionMediaArray, string pageTitleVal, string titleVal, string desc, string Media, string NoMedia, string gemId, GemType gemType)
		public CommunityGems(DetailsPageModel model)
		{
			NavigationPage.SetHasNavigationBar(this, false);
			masterLayout = new CustomLayout();
			masterLayout.BackgroundColor = Color.FromRgb(244, 244, 244);
			masterScroll = new ScrollView();
			masterScroll.IsClippedToBounds = true;
			masterScroll.BackgroundColor = Color.FromRgb(244, 244, 244);
			progressBar = DependencyService.Get<IProgressBar>();
			currentUser = App.Settings.GetUser ();

			modelObject = model;
			CurrentGemId = model.gemId;
			CurrentGemType = model.gemType;

			cancelToken = new CancellationTokenSource ();
			mainTitleBar = new PurposeColorTitleBar(Color.FromRgb(8, 135, 224), "Purpose Color", Color.Black, "back", false);
			mainTitleBar.imageAreaTapGestureRecognizer.Tapped += OnImageAreaTapGestureRecognizerTapped;
			subTitleBar = new CommunityGemSubTitleBar(Constants.SUB_TITLE_BG_COLOR, Constants.COMMUNITY_GEMS, true);
			subTitleBar.myGemsTapRecognizer.Tapped += async (object sender, EventArgs e) => 
			{
				IProgressBar progress = DependencyService.Get<IProgressBar>();
				progress.ShowProgressbar( "Loading Mygems.." );

				CommunityGemsObject myGems = await ServiceHelper.GetMyGemsDetails();
				if( myGems != null )
				{
					//communityGems = null;
					Navigation.PushAsync( new MyGemsPage( myGems ) );
					myGemsCount = myGems.resultarray.Count;
				}

				progress.HideProgressbar();

				/*	masterStack.Children.Clear();
				masterStackLayout.Children.Clear();
				masterScroll.Content = null;

				RenderGems( communityGems );*/


			};
			subTitleBar.BackButtonTapRecognizer.Tapped += async (object sender, EventArgs e) =>
			{
				try
				{
					App.masterPage.IsPresented = !App.masterPage.IsPresented;
				}
				catch (Exception)
				{
				}
			};


			this.Appearing += OnAppearing;




			Label pageTitle = new Label();
			pageTitle.Text = 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);

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

			masterStackLayout = new StackLayout();
			masterStackLayout.Orientation = StackOrientation.Vertical;

			TapGestureRecognizer chatTap = new TapGestureRecognizer ();
			Image chat = new Image ();
			chat.Source = "chat.png";
			chat.Aspect = Aspect.Fill;
			chat.WidthRequest = App.screenWidth * 16 / 100;
			chat.HeightRequest = App.screenWidth * 12 / 100;
			chat.GestureRecognizers.Add ( chatTap );
			chatTap.Tapped += async (object sender, EventArgs e) => 
			{
				await Navigation.PushAsync( new ChatPage() );
			};

			masterLayout.AddChildToLayout(mainTitleBar, 0, 0);
			masterLayout.AddChildToLayout(chat, 80, 1);
			masterLayout.AddChildToLayout(subTitleBar, 0, Device.OnPlatform(9, 10, 10));
			masterLayout.AddChildToLayout(masterScroll, -1, 18);

			masterScroll.Scrolled += OnMasterScrollScrolled;

			Content = masterLayout;
		}
		public void Dispose ()
		{
			mainTitleBar = null;
			subTitleBar = null;
			masterLayout = null;
			chatContactsListView = null;
			userObject = null;
			this.Content = null;
		}