/// <summary> /// Updates the pin data. /// </summary> public async void UpdatePinData() { try { FirebaseHelper firebaseHelper = new FirebaseHelper(); //// Gets current user id var userid = DependencyService.Get <IFirebaseAuthenticator>().UserId(); ////Gets the notes data NotesData notesData = await firebaseHelper.GetNotesData(this.value, userid); txtTitle.Text = notesData.Title; txtNotes.Text = notesData.Notes; this.noteColor = notesData.ColorNote; this.listLabel = notesData.LabelData; this.area = notesData.Area; this.BackgroundColor = Color.FromHex(SetColor.GetHexColor(notesData)); this.collaborate = notesData.IsCollaborated; } catch (Exception e) { Console.WriteLine(e.Message); } }
public async void LocationArea(string Area) { var userid = DependencyService.Get <IFirebaseAuthenticator>().UserId(); var notes = await this.firebaseHelper.GetNotesData(value, userid); if (notes.Area != null) { var image = new Image { Source = "location.png", HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Start, HeightRequest = 13, WidthRequest = 13 }; var location = new Label { Text = notes.Area, HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Start, FontSize = 14, }; StackLayout framelayout = new StackLayout() { Spacing = 2, Margin = 1 }; var tapGestureRecognizer = new TapGestureRecognizer(); framelayout.GestureRecognizers.Add(tapGestureRecognizer); framelayout.Children.Add(image); framelayout.Children.Add(location); var locationFrame = new Frame(); locationFrame.CornerRadius = 28; locationFrame.HeightRequest = 14; location.WidthRequest = 50; locationFrame.BorderColor = Color.Gray; locationFrame.Content = framelayout; // locationFrame.Content = image; locationFrame.BackgroundColor = Color.FromHex(SetColor.GetHexColor(notes)); tapGestureRecognizer.Tapped += (object sender, EventArgs args) => { StackLayout stacklayout = (StackLayout)sender; IList <View> item = stacklayout.Children; Navigation.PushAsync(new GeoLocation()); }; //layout.Children.Add(image); locationLayout.Children.Add(locationFrame); } }
/// <summary> /// archive data. /// </summary> public async void UnArchiveData() { FirebaseHelper firebaseHelper = new FirebaseHelper(); //// Gets the current user id var userid = DependencyService.Get <IFirebaseAuthenticator>().UserId(); //// Gets all notes data from firebase NotesData notesData = await firebaseHelper.GetNotesData(this.val, userid); txtTitle.Text = notesData.Title; txtNotes.Text = notesData.Notes; this.noteColor = notesData.ColorNote; this.labelList = notesData.LabelData; this.area = notesData.Area; this.BackgroundColor = Color.FromHex(SetColor.GetHexColor(notesData)); this.collabarate = notesData.IsCollaborated; }
/// <summary> /// Grids the view. /// </summary> /// <param name="list">The list.</param> public void GridView(IList <NotesData> list, IList <CreateNewLabel> listLabel) { try { ///// Creates column defination of width 170 GridLayout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(170) }); GridLayout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(170) }); GridLayout.Margin = 5; int rowCount = 0; //// Creates number of columns as lables are added for (int row = 0; row < list.Count; row++) { //// Adds new row after 2 labels if (row % 2 == 0) { GridLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(2, GridUnitType.Auto) }); rowCount++; } } var index = -1; //// Adds label to row and columns for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) { for (int columnIndex = 0; columnIndex < 2; columnIndex++) { NotesData data = null; index++; if (index < list.Count) { data = list[index]; } //// Creates Labels var label = new Xamarin.Forms.Label { Text = data.Title, TextColor = Color.Black, FontAttributes = FontAttributes.Bold, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Start, }; //// Created label key var labelKey = new Xamarin.Forms.Label { Text = data.Key, IsVisible = false }; var colorlabel = new Xamarin.Forms.Label { Text = data.ColorNote, IsVisible = false }; //// Content view var content = new Xamarin.Forms.Label { Text = data.Notes, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Start, }; //// Creates stack layout for each label StackLayout layout = new StackLayout() { Spacing = 2, Margin = 2, //// BackgroundColor = Color.White }; //// Tapgesture is created var tapGestureRecognizer = new TapGestureRecognizer(); layout.Children.Add(labelKey); layout.Children.Add(label); layout.Children.Add(content); layout.Children.Add(colorlabel); layout.GestureRecognizers.Add(tapGestureRecognizer); layout.Spacing = 2; layout.Margin = 2; //// layout.BackgroundColor = Color.White; var frame = new Frame(); frame.BorderColor = Color.Black; frame.Content = layout; //// Setting the color class SetColor setColor = new SetColor(); setColor.GetColor(data, frame); //// Loops over the labels class foreach (CreateNewLabel createNewLabel in listLabel) { IList <string> labellist = data.LabelData; //// Loops over the list of labels added to the notes foreach (var labelid in labellist) { //// Checks if the labels are equal from the label list if (createNewLabel.LabelKey.Equals(labelid)) { var labelName = new Label { Text = createNewLabel.Label, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, FontSize = 12, }; var labelFrame = new Frame(); labelFrame.CornerRadius = 28; labelFrame.HeightRequest = 14; labelFrame.BorderColor = Color.Gray; labelFrame.Content = labelName; labelFrame.BackgroundColor = Color.FromHex(SetColor.GetHexColor(data)); layout.Children.Add(labelFrame); } } } if (data.Area != null) { var image = new Image { Source = "location.png", VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Start, HeightRequest = 13, WidthRequest = 13 }; var location = new Label { Text = data.Area, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.StartAndExpand, FontSize = 12, }; StackLayout framelayout = new StackLayout() { Spacing = 1, Margin = 1, }; framelayout.Children.Add(image); framelayout.Children.Add(location); var locationFrame = new Frame(); locationFrame.CornerRadius = 28; locationFrame.HeightRequest = 10; locationFrame.WidthRequest = 30; locationFrame.BorderColor = Color.Gray; locationFrame.Content = framelayout; // locationFrame.Content = image; locationFrame.BackgroundColor = Color.FromHex(SetColor.GetHexColor(data)); //layout.Children.Add(image); layout.Children.Add(locationFrame); } //// when tapped opens or navigates to particular page tapGestureRecognizer.Tapped += (object sender, EventArgs args) => { StackLayout layout123 = (StackLayout)sender; IList <View> item = layout123.Children; Xamarin.Forms.Label KeyValue = (Xamarin.Forms.Label)item[0]; var Keyvalue = KeyValue.Text; Navigation.PushAsync(new UnArchive(Keyvalue)); }; GridLayout.Children.Add(frame, columnIndex, rowIndex); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }