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 ); } }
async void DetailsTapgesture_Tapped (object sender, EventArgs e) { try { if(progressBar == null) progressBar = DependencyService.Get<IProgressBar>(); progressBar.ShowProgressbar("Retriving details"); string btnId = "0"; try { var senderType = sender.GetType(); if (senderType == typeof(CustomLayout)) { btnId = (sender as CustomLayout).ClassId; } else if(senderType == typeof(Image)) { btnId = (sender as Image).ClassId; } else if(senderType == typeof(StackLayout)) { btnId = (sender as StackLayout).ClassId; } } catch (Exception ) { } if(btnId == "0") { progressBar.HideProgressbar(); return; } selectedGem = btnId; if (App.isEmotionsListing) { try { SelectedEventDetails eventDetails = await ServiceHelper.GetSelectedEventDetails(btnId); if (eventDetails != null) { List<string> listToDownload = new List<string>(); foreach (var eventi in eventDetails.event_media) { if(string.IsNullOrEmpty(eventi.event_media)) { continue; } if (eventi.media_type == "png" || eventi.media_type == "jpg" || eventi.media_type == "jpeg") { listToDownload.Add(Constants.SERVICE_BASE_URL+eventi.event_media); string fileName = System.IO.Path.GetFileName(eventi.event_media); eventi.event_media = App.DownloadsPath + fileName; } else { eventi.event_media = Constants.SERVICE_BASE_URL + eventi.event_media ; } } if (listToDownload != null && listToDownload.Count > 0) { IDownload downloader = DependencyService.Get<IDownload>(); //progressBar.ShowProgressbar("loading details.."); await downloader.DownloadFiles(listToDownload); } DetailsPageModel model = new DetailsPageModel(); model.actionMediaArray = null; model.eventMediaArray = eventDetails.event_media; model.goal_media = null; model.Media = null; model.NoMedia = null; model.pageTitleVal = "Event Details"; model.titleVal = eventDetails.event_title; model.description = eventDetails.event_details; model.gemType = GemType.Event; model.gemId = btnId; if (progressBar != null) { progressBar.HideProgressbar(); } isLoadingFromDetailsPage = true; await Navigation.PushAsync(new GemsDetailsPage(model)); eventDetails = null; } } catch (Exception ) { } } else { //-- call service for Action details try { SelectedActionDetails actionDetails = await ServiceHelper.GetSelectedActionDetails(btnId); List<string> listToDownload = new List<string>(); foreach (var action in actionDetails.action_media) { if( string.IsNullOrEmpty(action.action_media)) { continue; } if (action.media_type == "png" || action.media_type == "jpg" || action.media_type == "jpeg") { listToDownload.Add(Constants.SERVICE_BASE_URL+action.action_media); string fileName = System.IO.Path.GetFileName(action.action_media); action.action_media = App.DownloadsPath + fileName; } else { action.action_media = Constants.SERVICE_BASE_URL + action.action_media; } } if (listToDownload != null && listToDownload.Count > 0) { IDownload downloader = DependencyService.Get<IDownload>(); //progressBar.ShowProgressbar("loading details.."); await downloader.DownloadFiles(listToDownload); //progressBar.HideProgressbar(); } if (actionDetails != null) { DetailsPageModel model = new DetailsPageModel(); model.actionMediaArray = actionDetails.action_media; model.eventMediaArray = null; model.goal_media = null; model.Media = null; model.NoMedia = null; model.pageTitleVal = "Action Details"; model.titleVal = actionDetails.action_title; model.description = actionDetails.action_details; model.gemType = GemType.Action; model.gemId = btnId; if (progressBar != null) { progressBar.HideProgressbar(); } isLoadingFromDetailsPage = true; await Navigation.PushAsync(new GemsDetailsPage(model)); actionDetails = null; } } catch (Exception ) { } } progressBar.HideProgressbar(); } catch (Exception ex) { if (progressBar != null) { progressBar.HideProgressbar(); } var test = ex.Message; } }
public void Dispose() { masterLayout = null; progressBar = null; //masterStack = null; title = null; description = null; mediaList = null; shareLabel = null; if (shareButtonTap != null) { shareButtonTap.Tapped -= OnShareButtonTapped; shareButtonTap = null; } if (commentButtonTap != null) { commentButtonTap.Tapped -= OnCommentButtonTapped; commentButtonTap = null; likeButtonTap = null; } gemMenuContainer = null; modelObject = null; masterStackLayout = null; communityGems = null; GC.Collect(); }
//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 AddEventsSituationsOrThoughts(string title, DetailsPageModel detailsPageModel = null) { NavigationPage.SetHasNavigationBar(this, false); masterLayout = new CustomLayout(); audioRecorder = DependencyService.Get<PurposeColor.interfaces.IAudioRecorder>(); //deviceSpec = DependencyService.Get<IDeviceSpec>(); screenHeight = App.screenHeight; screenWidth = App.screenWidth; masterLayout.BackgroundColor = Constants.PAGE_BG_COLOR_LIGHT_GRAY; pageTitle = title; lattitude = string.Empty; longitude = string.Empty; currentAddress = string.Empty; int devWidth = (int)screenWidth; App.MediaArray = new List<MediaItem>(); App.ContactsArray = new List<string>(); App.PreviewListSource.Clear(); int textInputWidth = (int)(devWidth * .80); contactSelectAction = OnContactSelected; #region TITLE BARS TopTitleBar = new StackLayout { BackgroundColor = Constants.BLUE_BG_COLOR, HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.StartAndExpand, Padding = 0, Spacing = 0, Children = { new BoxView { WidthRequest = screenWidth } } }; masterLayout.AddChildToLayout(TopTitleBar, 0, 0); string trimmedPageTitle = string.Empty; int titleMaxLength = 24; if (App.screenDensity > 1.5) { titleMaxLength = 24; } else { titleMaxLength = 22; } if (title.Length > titleMaxLength) { trimmedPageTitle = title.Substring(0, titleMaxLength); trimmedPageTitle += ".."; } else { trimmedPageTitle = pageTitle; } subTitleBar = new PurposeColorBlueSubTitleBar(Constants.SUB_TITLE_BG_COLOR, trimmedPageTitle, true, true); masterLayout.AddChildToLayout(subTitleBar, 0, 1); subTitleBar.BackButtonTapRecognizer.Tapped += OnBackButtonTapRecognizerTapped; subTitleBar.NextButtonTapRecognizer.Tapped += NextButtonTapRecognizer_Tapped; #endregion #region EVENT TITLE - CUSTOM ENTRY eventTitle = new CustomEntry { VerticalOptions = LayoutOptions.StartAndExpand, HorizontalOptions = LayoutOptions.StartAndExpand, BackgroundColor = Color.White, Placeholder = "Title", TextColor = Color.FromHex("#424646"), HeightRequest = Device.OnPlatform(50,50,73), WidthRequest = (int)(devWidth * .90) // 90% of screen, }; eventTitle.TextChanged += EventTitle_TextChanged; //if (App.screenDensity > 1.5) //{ // eventTitle.HeightRequest = screenHeight * 6 / 100; //} //else //{ // eventTitle.HeightRequest = screenHeight * 9 / 100; //} masterLayout.AddChildToLayout(eventTitle, 5, 11); #endregion #region EVENT DESCRIPTION eventDescription = new CustomEditor { VerticalOptions = LayoutOptions.StartAndExpand, HorizontalOptions = LayoutOptions.StartAndExpand, HeightRequest = 100, Placeholder = pageTitle, BackgroundColor = Color.White }; eventDescription.TextChanged += EventDescription_TextChanged; eventDescription.WidthRequest = textInputWidth; if (detailsPageModel != null) { if (detailsPageModel.IsCopyingGem) { isUpdatePage = false; } else { isUpdatePage = true; } currentGemId = detailsPageModel.gemId; if (detailsPageModel.gemType != null) { currentGemType = detailsPageModel.gemType; switch (currentGemType) { case GemType.Goal: pageTitle = Constants.EDIT_GOALS; break; case GemType.Event: pageTitle = Constants.EDIT_EVENTS; break; case GemType.Action: pageTitle = Constants.EDIT_ACTIONS; break; default: break; } } if (detailsPageModel.titleVal != null) { eventTitle.Text = detailsPageModel.titleVal; } if ( detailsPageModel.description != null) { eventDescription.Text = detailsPageModel.description; } } #endregion #region MEDIA INPUTS Image pinButton = new Image { BackgroundColor = Color.Transparent, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, Source = Device.OnPlatform("icn_attach.png", "icn_attach.png", "//Assets//icn_attach.png"), }; StackLayout pinButtonHolder = new StackLayout { Padding = 10, VerticalOptions = LayoutOptions.Start, Children = { pinButton } }; TapGestureRecognizer pinButtonTapRecognizer = new TapGestureRecognizer(); pinButtonHolder.GestureRecognizers.Add(pinButtonTapRecognizer); pinButtonTapRecognizer.Tapped += (s, e) => { iconContainerGrid.IsVisible = !iconContainerGrid.IsVisible; }; Image audioRecodeOnButton = new Image { BackgroundColor = Color.Transparent, VerticalOptions = LayoutOptions.Center, Source = Device.OnPlatform("mic.png", "mic.png", "//Assets//mic.png"), }; audioRecodeOnHolder = new StackLayout { Padding = 10, VerticalOptions = LayoutOptions.End, Children = { audioRecodeOnButton } }; TapGestureRecognizer RecodeOnTapRecognizer = new TapGestureRecognizer(); audioRecodeOnHolder.GestureRecognizers.Add(RecodeOnTapRecognizer); audioRecodeOffButton = new Image { BackgroundColor = Color.Transparent, VerticalOptions = LayoutOptions.Center, Source = Device.OnPlatform("turn_off_mic.png", "turn_off_mic.png", "//Assets//turn_off_mic.png"), }; audioRecodeOffHolder = new StackLayout { BackgroundColor = Color.Transparent, Padding = 10, VerticalOptions = LayoutOptions.End, IsVisible = false, Children = { audioRecodeOffButton } }; TapGestureRecognizer RecodeOffTapRecognizer = new TapGestureRecognizer(); audioRecodeOffHolder.GestureRecognizers.Add(RecodeOffTapRecognizer); audioRecodeOffHolder.TranslateTo(0, Device.OnPlatform(audioRecodeOffButton.Y + 60, audioRecodeOffButton.Y + 60, audioRecodeOffButton.Y + 50), 5, null); audioRecodeOnHolder.TranslateTo(0, Device.OnPlatform(audioRecodeOffButton.Y + 60, audioRecodeOffButton.Y + 60, audioRecodeOffButton.Y + 50), 5, null); RecodeOnTapRecognizer.Tapped += RecodeOnTapRecognizer_Tapped; RecodeOffTapRecognizer.Tapped += RecodeOffTapRecognizer_Tapped; StackLayout menuPinContainer = new StackLayout { BackgroundColor = Color.White, Orientation = StackOrientation.Vertical, HeightRequest = 140, WidthRequest = (int)(devWidth * .10), Children = { pinButtonHolder, audioRecodeOnHolder, audioRecodeOffHolder } }; TapGestureRecognizer locationlabelTap = new TapGestureRecognizer(); locationInfo = new Label(); locationInfo.TextColor = Constants.BLUE_BG_COLOR; locationInfo.BackgroundColor = Color.Transparent; locationInfo.FontSize = 12; locationInfo.HeightRequest = Device.OnPlatform(15, 25, 25); locationInfo.GestureRecognizers.Add(locationlabelTap); locationlabelTap.Tapped += OnEditLocationInfo; editLocationAndContactsStack = new StackLayout(); editLocationAndContactsStack.Padding = new Thickness(1, 1, 1, 1); editLocationAndContactsStack.BackgroundColor = Color.FromRgb(30, 126, 210); editLocationAndContactsStack.WidthRequest = App.screenWidth * 90 / 100; editLocationAndContactsStack.IsVisible = false; editLocationAndContactsStack.Orientation = StackOrientation.Horizontal; locAndContactsEntry = new Entry(); locAndContactsEntry.TextColor = Color.Black; locAndContactsEntry.BackgroundColor = Color.White; locAndContactsEntry.VerticalOptions = LayoutOptions.Center; locAndContactsEntry.WidthRequest = App.screenWidth * 80 / 100; locAndContactsEntry.HeightRequest = 50; editLocationDoneButton = new CustomImageButton(); editLocationDoneButton.VerticalOptions = LayoutOptions.Center; editLocationDoneButton.ImageName = "icn_done.png"; editLocationDoneButton.HeightRequest = 25; editLocationDoneButton.WidthRequest = 25; editLocationDoneButton.Clicked += OnLocationEditCompleted; editLocationAndContactsStack.Children.Add(locAndContactsEntry); editLocationAndContactsStack.Children.Add(editLocationDoneButton); if (Device.OS == TargetPlatform.iOS) { editLocationAndContactsStack.TranslationY = -30; } locLayout = new StackLayout(); locLayout.Orientation = StackOrientation.Vertical; locLayout.BackgroundColor = Color.Transparent; locLayout.Children.Add(locationInfo); TapGestureRecognizer contactsLabelTap = new TapGestureRecognizer(); contactInfo = new Label(); contactInfo.TextColor = Constants.BLUE_BG_COLOR; contactInfo.BackgroundColor = Color.Transparent; contactInfo.FontSize = 12; contactInfo.HeightRequest = Device.OnPlatform(15, 25, 25); contactInfo.GestureRecognizers.Add(contactsLabelTap); contactsLabelTap.Tapped += async (object sender, EventArgs e) => { editLocationAndContactsStack.ClassId = "contactedit"; string spanContacts = ""; if (contactInfo.FormattedText != null && contactInfo.FormattedText.Spans.Count > 1) spanContacts = contactInfo.FormattedText.Spans[1].Text; locAndContactsEntry.Text = spanContacts; editLocationAndContactsStack.IsVisible = true; contactInfo.IsVisible = false; iconContainerGrid.IsVisible = false; locationInfo.IsVisible = true; await editLocationAndContactsStack.TranslateTo(100, 0, 300, Easing.SinInOut); await editLocationAndContactsStack.TranslateTo(0, 0, 300, Easing.SinIn); }; locLayout.IsVisible = false; contactInfo.IsVisible = false; #endregion if(detailsPageModel != null) { if (detailsPageModel.eventMediaArray!= null && detailsPageModel.eventMediaArray.Count > 0) { foreach (EventMedia eventObj in detailsPageModel.eventMediaArray) { if (eventObj.event_media != null && !eventObj.event_media.Contains("default")) { AddFilenameToMediaList(eventObj.event_media); } } } if (detailsPageModel.goal_media != null && detailsPageModel.goal_media.Count > 0) { foreach (SelectedGoalMedia goalObj in detailsPageModel.goal_media) { if (goalObj.goal_media != null && !goalObj.goal_media.Contains("default")) { AddFilenameToMediaList(goalObj.goal_media); } } } if (detailsPageModel.actionMediaArray != null && detailsPageModel.actionMediaArray.Count > 0) { foreach (ActionMedia actionObj in detailsPageModel.actionMediaArray) { if (actionObj.action_media != null && !actionObj.action_media.Contains("default")) { AddFilenameToMediaList(actionObj.action_media); } } } } StackLayout entryAndLocContainer = new StackLayout(); entryAndLocContainer.Orientation = StackOrientation.Vertical; entryAndLocContainer.BackgroundColor = Color.White; entryAndLocContainer.Children.Add( eventDescription ); entryAndLocContainer.Children.Add(contactInfo); entryAndLocContainer.Children.Add(locLayout); textInputContainer = new StackLayout { Orientation = StackOrientation.Horizontal, Spacing = 0, Padding = 0, Children = { entryAndLocContainer, menuPinContainer } }; #region ICONS audioInput = new Image() { Source = Device.OnPlatform("ic_music.png", "ic_music.png", "//Assets//ic_music.png"), Aspect = Aspect.AspectFit }; int ICON_SIZE = 8; if( Device.OS == TargetPlatform.WinPhone ) { audioInput.WidthRequest = screenWidth * ICON_SIZE / 100; audioInput.HeightRequest = screenWidth * ICON_SIZE / 100; } audioInputStack = new StackLayout { Padding = new Thickness(5, 10, 5, 10), //BackgroundColor = Constants.STACK_BG_COLOR_GRAY, //HorizontalOptions = LayoutOptions.Center, Spacing = 0, Children = { audioInput /*, new Label { Text = "Audio", TextColor = Constants.TEXT_COLOR_GRAY, FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)) }*/ } }; cameraInput = new Image() { Source = Device.OnPlatform("icn_camera.png", "icn_camera.png", "//Assets//icn_camera.png"), Aspect = Aspect.AspectFit }; if (Device.OS == TargetPlatform.WinPhone) { cameraInput.WidthRequest = screenWidth * ICON_SIZE / 100; cameraInput.HeightRequest = screenWidth * ICON_SIZE / 100; } cameraInputStack = new StackLayout { Padding = new Thickness(5, 10, 5, 10), //BackgroundColor = Constants.STACK_BG_COLOR_GRAY, //HorizontalOptions = LayoutOptions.Center, Spacing = 0, Children = { cameraInput /*, new Label { Text = "Camera", TextColor = Constants.TEXT_COLOR_GRAY, FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)) } */ } }; cameraInputStack.ClassId = "camera"; #region CAMERA TAP RECOGNIZER CameraTapRecognizer = new TapGestureRecognizer(); cameraInputStack.GestureRecognizers.Add(CameraTapRecognizer); CameraTapRecognizer.Tapped += async (s, e) => { try { await ApplyAnimation( cameraInputStack ); StackLayout send = s as StackLayout; MediaSourceChooser chooser = new MediaSourceChooser(this, masterLayout, send.ClassId); chooser.ClassId = "mediachooser"; masterLayout.AddChildToLayout(chooser, 0, 0); } catch (System.Exception ex) { DisplayAlert("Camera", ex.Message + " Please try again later", "ok"); } /* try { StackLayout send = s as StackLayout; MediaSourceChooser chooser = new MediaSourceChooser(this, masterLayout, send.ClassId); chooser.ClassId = "mediachooser"; masterLayout.AddChildToLayout(chooser, 0, 0); } catch (System.Exception ex) { DisplayAlert("Camera", ex.Message + " Please try again later", "ok"); } */ }; #endregion galleryInput = new Image() { Source = Device.OnPlatform("icn_gallery.png", "icn_gallery.png", "//Assets//icn_gallery.png"), Aspect = Aspect.AspectFit }; if (Device.OS == TargetPlatform.WinPhone) { galleryInput.WidthRequest = screenWidth * ICON_SIZE / 100; galleryInput.HeightRequest = screenWidth * ICON_SIZE / 100; } galleryInputStack = new StackLayout { Padding = new Thickness(5, 10, 5, 10), Spacing = 0, Children = { galleryInput //new Label { Text = "Gallery", TextColor = Constants.TEXT_COLOR_GRAY, FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)) } } }; galleryInputStack.ClassId = "gallery"; #region GALLERY TAP RECOGNIZER TapGestureRecognizer galleryInputStackTapRecognizer = new TapGestureRecognizer(); galleryInputStack.GestureRecognizers.Add(galleryInputStackTapRecognizer); galleryInputStackTapRecognizer.Tapped += async (s, e) => { await ApplyAnimation( galleryInputStack ); StackLayout send = s as StackLayout; MediaSourceChooser chooser = new MediaSourceChooser(this, masterLayout, send.ClassId); chooser.ClassId = "mediachooser"; masterLayout.AddChildToLayout(chooser, 0, 0); }; #endregion locationInput = new Image() { Source = Device.OnPlatform("icn_location.png", "icn_location.png", "//Assets//icn_location.png"), Aspect = Aspect.AspectFit }; if (Device.OS == TargetPlatform.WinPhone) { locationInput.WidthRequest = screenWidth * ICON_SIZE / 100; locationInput.HeightRequest = screenWidth * ICON_SIZE / 100; } locationInputStack = new StackLayout { Padding = new Thickness(5, 10, 5, 10), //BackgroundColor = Constants.STACK_BG_COLOR_GRAY, //HorizontalOptions = LayoutOptions.Center, Spacing = 0, Children = { locationInput //, new Label { Text = "Location", TextColor = Constants.TEXT_COLOR_GRAY, FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)) } } }; #region LOCATION TAP RECOGNIZER TapGestureRecognizer locationInputTapRecognizer = new TapGestureRecognizer(); locationInputStack.GestureRecognizers.Add(locationInputTapRecognizer); locationInputTapRecognizer.Tapped += LocationInputTapRecognizer_Tapped; #endregion contactInput = new Image() { Source = Device.OnPlatform("icn_contact.png", "icn_contact.png", "//Assets//icn_contact.png"), Aspect = Aspect.AspectFit }; if (Device.OS == TargetPlatform.WinPhone) { contactInput.WidthRequest = screenWidth * ICON_SIZE / 100; contactInput.HeightRequest = screenWidth * ICON_SIZE / 100; } contactInputStack = new StackLayout { Padding = new Thickness(5, 10, 0, 10), Spacing = 0, Children = { contactInput //new Label { Text = "Contact", TextColor = Constants.TEXT_COLOR_GRAY, FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)) } } }; #region CONTACTS TAP RECOGNIZER TapGestureRecognizer contactsInputTapRecognizer = new TapGestureRecognizer(); contactInputStack.GestureRecognizers.Add(contactsInputTapRecognizer); contactsInputTapRecognizer.Tapped += async (s, e) => { await ApplyAnimation( contactInputStack ); try { if( Device.OS == TargetPlatform.Android || Device.OS == TargetPlatform.iOS ) { IContactPicker testicker = DependencyService.Get< IContactPicker >(); testicker.ShowContactPicker(); } } catch (Exception ex) { DisplayAlert("contactsInputTapRecognizer: ", ex.Message, "ok"); } }; #endregion #endregion #region ICON CONTAINER GRID iconContainerGrid = new Grid { IsVisible = false, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition { Height = GridLength.Auto } }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(((screenWidth * .80) )/4, GridUnitType.Absolute) }, // icon container x = 3 //new ColumnDefinition { Width = GridLength.Auto }, // new ColumnDefinition { Width = new GridLength(((screenWidth * .80)) /5, GridUnitType.Absolute) }, new ColumnDefinition { Width = new GridLength(((screenWidth * .80))/4, GridUnitType.Absolute) }, new ColumnDefinition { Width = new GridLength(((screenWidth * .80))/4, GridUnitType.Absolute) }, new ColumnDefinition { Width = new GridLength(((screenWidth * .80))/4, GridUnitType.Absolute) }, } }; iconContainerGrid.Children.Add(galleryInputStack, 0, 0); iconContainerGrid.Children.Add(cameraInputStack, 1, 0); // iconContainerGrid.Children.Add(audioInputStack, 2, 0); iconContainerGrid.Children.Add(locationInputStack, 2, 0); iconContainerGrid.Children.Add(contactInputStack, 3, 0); textinputAndIconsHolder = new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.Center, Spacing = 0, Padding = 0, Children = { textInputContainer, iconContainerGrid, editLocationAndContactsStack } }; Button createEvent = new Button(); if (pageTitle == Constants.ADD_ACTIONS || pageTitle == Constants.ADD_GOALS || pageTitle == Constants.EDIT_ACTIONS || pageTitle == Constants.EDIT_GOALS) { createEvent.BackgroundColor = Color.Transparent; createEvent.TextColor = Constants.BLUE_BG_COLOR; createEvent.Text = "Create Reminder"; createEvent.FontSize = 12; createEvent.BorderWidth = 0; createEvent.BorderColor = Color.Transparent; createEvent.Clicked += createEvent_Clicked; if( Device.OS == TargetPlatform.iOS ) createEvent.TranslationY = -8; textinputAndIconsHolder.Children.Add(createEvent); } masterLayout.AddChildToLayout(textinputAndIconsHolder, 5, 21); #region PREVIEW LIST listContainer = new StackLayout(); listContainer.BackgroundColor = Constants.PAGE_BG_COLOR_LIGHT_GRAY; listContainer.WidthRequest = screenWidth * 90 / 100; listContainer.HeightRequest = screenHeight * 25 / 100; listContainer.ClassId = "preview"; previewListView = new ListView(); previewListView.BackgroundColor = Constants.PAGE_BG_COLOR_LIGHT_GRAY; PreviewListViewCellItem.addEvntObject = this; previewListView.ItemTemplate = new DataTemplate(typeof(PreviewListViewCellItem)); previewListView.SeparatorVisibility = SeparatorVisibility.None; previewListView.Opacity = 1; previewListView.ItemsSource = App.PreviewListSource; previewListView.ItemSelected += (object sender, SelectedItemChangedEventArgs e) => { /* PreviewItem items = previewListView.SelectedItem as PreviewItem; if( items != null ) App.Navigator.PushModalAsync( new VideoPlayerView( items.Path ) );*/ previewListView.SelectedItem = null; }; listContainer.Children.Add(previewListView); masterLayout.AddChildToLayout(listContainer, 5, Device.OnPlatform( 63, 63, 50 )); #endregion //masterLayout.AddChildToLayout(locationEditStack, 5, 30 ); #endregion Content = masterLayout; }
async void OnEmotionTapped (object sender, EventArgs e) { View tap = sender as View; if (tap != null && tap.ClassId != null) { List<EventMedia> media = new List<EventMedia>(); EventTitle eventTitle = new EventTitle (); EventDetail eventDetail = new EventDetail (); eventDetail = emotionsMasterList.event_details.FirstOrDefault (itm => itm.event_id == tap.ClassId); eventTitle = emotionsMasterList.event_title.FirstOrDefault ( itm => itm.event_id == tap.ClassId ); media = emotionsMasterList.event_media.FindAll (itm => itm.event_id == tap.ClassId).ToList(); // title = emotionList.eve if (media != null) { IProgressBar progess = DependencyService.Get<IProgressBar>(); progess.ShowProgressbar("Loading details..."); DetailsPageModel model = new DetailsPageModel() { eventMediaArray = media, actionMediaArray = null, pageTitleVal = emotionsMasterList.emotion_title, titleVal = eventTitle.event_title, description = eventDetail.event_details, Media = eventsMediaPath, NoMedia = eventsNoMediaPath, gemId = eventDetail.event_id, gemType = GemType.Event, fromGEMSPage = true }; //await Navigation.PushAsync(new GemsDetailsPage(media, null, emotionsMasterList.emotion_title, eventTitle.event_title, eventDetail.event_details, eventsMediaPath, eventsNoMediaPath, eventDetail.event_id, GemType.Event)); await Navigation.PushAsync(new GemsDetailsPage( model )); progess.HideProgressbar(); eventDetail = null; eventTitle = null; media = null; GC.Collect (); } } else { await DisplayAlert( Constants.ALERT_TITLE, "Not a valid Event", Constants.ALERT_OK ); } }
async void OnGoalsTapped(object sender, EventArgs e) { IProgressBar progress = DependencyService.Get<IProgressBar>(); progress.ShowProgressbar( "Detailed view is loading...." ); Label detailslabel = sender as Label; Image mediaImg = sender as Image; string goalID = ""; if( detailslabel != null ) { goalID = detailslabel.ClassId; } else if( mediaImg != null ) { goalID = mediaImg.ClassId; } if( !string.IsNullOrEmpty( goalID ) ) { SelectedGoal goalInfo = await ServiceHelper.GetSelectedGoalDetails(goalID); if( goalInfo != null ) { DetailsPageModel model = new DetailsPageModel(); model.actionMediaArray = null; model.eventMediaArray = null; model.goal_media = goalInfo.resultarray.goal_media; model.Media = null; model.NoMedia = null; model.pageTitleVal = "Goal Details"; model.titleVal = goalInfo.resultarray.goal_title; model.description = goalInfo.resultarray.goal_details; model.gemType = GemType.Goal; model.gemId = goalID; List<SelectedGoalMedia> downloadedMediaList = new List<SelectedGoalMedia> (); downloadedMediaList = await DownloadMedias ( goalInfo.resultarray.goal_media ); progress.HideProgressbar(); await Navigation.PushAsync(new GemsDetailsPage(model)); } else { progress.HideProgressbar(); DisplayAlert(Constants.ALERT_TITLE, "Error in getting goals details", Constants.ALERT_OK); } } else { progress.HideProgressbar(); DisplayAlert(Constants.ALERT_TITLE, "Not a valid goal", Constants.ALERT_OK); } }
async void OnActionTapped (object sender, EventArgs e) { CustomLayout clikedLayout = sender as CustomLayout; if (clikedLayout != null && clikedLayout.ClassId != null) { string[] delimiters = { "&&" }; string[] clasIDArray = clikedLayout.ClassId.Split(delimiters, StringSplitOptions.None); string selectedGoalID = clasIDArray [0]; string selectedActionID = clasIDArray [1]; GemsGoalsDetails selectedGoal = gemsGoalsObject.resultarray.FirstOrDefault (item => item.goal_id == selectedGoalID); if (selectedGoal != null ) { List<ActionMedia> actionMediaList = selectedGoal.action_media.FindAll (item => item.goalaction_id == selectedActionID).ToList (); ActionTitle actionTitle = selectedGoal.action_title.FirstOrDefault ( item => item.goalaction_id == selectedActionID ); string title = (actionTitle != null && actionTitle.action_title != null) ? actionTitle.action_title : ""; ActionDetail actionDetail = selectedGoal.action_details.FirstOrDefault ( item => item.goalaction_id == selectedActionID ); string details = (actionDetail != null && actionDetail.action_details != null) ? actionDetail.action_details : ""; DetailsPageModel model = new DetailsPageModel() { eventMediaArray = null, actionMediaArray = actionMediaList, pageTitleVal = "Action Details", titleVal = title, description = details, Media = gemsGoalsObject.mediapath, NoMedia = gemsGoalsObject.noimageurl, gemId = actionTitle.goalaction_id, gemType = GemType.Action }; //await Navigation.PushAsync (new GemsDetailsPage (null, actionMediaList, "Action Details", title, details, gemsGoalsObject.mediapath, gemsGoalsObject.noimageurl, actionTitle.goalaction_id ,GemType.Action)); await Navigation.PushAsync(new GemsDetailsPage(model)); } else { DisplayAlert ( Constants.ALERT_TITLE, "No informations about selected action", "cancel" ); } } }
async void OnListViewItemSelected(object sender, SelectedItemChangedEventArgs e) { try { if (listView.SelectedItem == null) return; MenuItems selItem = e.SelectedItem as MenuItems; if ("Emotional Awareness" == selItem.Name) { App.masterPage.IsPresented = false; App.masterPage.Detail = new NavigationPage(new FeelingNowPage()); } else if ("Goal Enabling Materials" == selItem.Name) { App.masterPage.IsPresented = false; App.masterPage.Detail = new NavigationPage(new GemsMainPage()); } else if ("Goals & Dreams" == selItem.Name) { App.masterPage.IsPresented = false; App.masterPage.Detail = new NavigationPage(new GoalsPage()); } else if (Constants.EMOTIONAL_INTELLIGENCE == selItem.Name) { App.masterPage.IsPresented = false; App.masterPage.Detail = new NavigationPage(new PieGraphPage()); } else if ("Community GEMs" == selItem.Name) { App.masterPage.IsPresented = false; DetailsPageModel model = new DetailsPageModel(); App.masterPage.Detail = new NavigationPage(new CommunityGems( model )); } else if (Constants.APPLICATION_SETTTINGS == selItem.Name) { App.masterPage.IsPresented = false; App.masterPage.Detail = new NavigationPage(new ApplicationSettingsPage()); } else if(Constants.SIGN_OUT_TEXT == selItem.Name) { try { #region SAVING SIGN OUT SETTINGS PurposeColor.Model.User user = null; user = App.Settings.GetUser(); App.Settings.DeleteAllUsers(); // the same user may log in again. App.Settings.DeleteAllCompletedGoals(); App.Settings.DeleteAllEmotions(); App.Settings.DeleteAllEvents(); App.Settings.DeleteAllGemsActions(); App.Settings.DeleteAllGemsEvents(); App.Settings.DeleteAllPendingGoals(); App.Settings.DeleteAllActionWithImage(); App.Settings.DeleteAllEventWithImage(); //App.Settings.DeleteCommunityGems(); // as its common for all users. PurposeColor.Model.GlobalSettings globalSettings = App.Settings.GetAppGlobalSettings(); if(globalSettings != null) { globalSettings.ShowRegistrationScreen = false; globalSettings.IsLoggedIn = false; globalSettings.IsFirstLogin = false; await App.Settings.SaveAppGlobalSettings(globalSettings); } if (user != null) { string statusCode = await PurposeColor.Service.ServiceHelper.LogOut(user.UserId.ToString()); if (statusCode != "200") { await DisplayAlert(Constants.ALERT_TITLE, "Network error, please try again later.", Constants.ALERT_OK); } } App.Current.Properties["IsLoggedIn"] = false; #endregion } catch (Exception) { DisplayAlert(Constants.ALERT_TITLE, "Network error, Could not process the request.", Constants.ALERT_OK); } App.IsLoggedIn = false; App.masterPage.IsPresented = false; App.masterPage.Detail = new NavigationPage(new LogInPage()); App.burgerMenuItems.Clear(); App.burgerMenuItems.Add (new MenuItems { Name = Constants.SIGN_OUT_IN, ImageName = Device.OnPlatform ("logout_icon.png", "logout_icon.png", "//Assets//logout_icon.png") }); } //SIGN_OUT else if(Constants.SIGN_OUT_IN == selItem.Name) { App.masterPage.IsPresented = false; App.masterPage.Detail = new NavigationPage(new LogInPage()); } listView.SelectedItem = null; // reset the list selection, other wise the same menu cannot be selected again consecutively. } catch (Exception) { } }