/// <summary> /// Gets the labels data. /// </summary> /// <param name="key">The key.</param> /// <param name="uid">The id.</param> /// <returns>returns label</returns> public async Task <CreateNewLabel> GetLabelsData(string key, string uid) { //// Returns the label from notes choosen CreateNewLabel label = await this.firebase.Child("Persons").Child(uid).Child("Label").Child(key).OnceSingleAsync <CreateNewLabel>(); return(label); }
/// <summary> /// Deletes the label. /// </summary> /// <param name="label">The label.</param> /// <param name="key">The key.</param> /// <param name="uid">The id.</param> public void DeleteLabel(CreateNewLabel label, string key, string uid) { try { //// Deletes the choosen label this.firebase.Child("Persons").Child(uid).Child("Label").Child(key).DeleteAsync(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// Edits the label. /// </summary> public async void EditLabel() { FirebaseHelper firebaseHelper = new FirebaseHelper(); //// Gets current user id var userid = DependencyService.Get <IFirebaseAuthenticator>().UserId(); ////Gets the notes data CreateNewLabel createNewLabel = await firebaseHelper.GetLabelsData(this.value, userid); txtLabel.Text = createNewLabel.Label; }
//public async void UpdateCollabratedNotes(NotesData notes, string key) //{ // try // { // var users = await firebase.Child("Persons").OnceAsync<SignUpUserData>(); // foreach (var items in users) // { // var noteCollabrator = await firebase.Child("Persons").Child(items.Key).Child("Notes").OnceAsync<NotesData>(); // foreach (var item in noteCollabrator) // { // if (item.Key == notes.Key) // { // await this.firebase.Child("Persons").Child(items.Key).Child("Notes").Child(key).PutAsync(new NotesData() { Title = notes.Title, Notes = notes.Notes, ColorNote = notes.ColorNote, LabelData = notes.LabelData, Area = notes.Area, IsCollaborated = true }); // } // } // } // } // catch (Exception ex) // { // Console.WriteLine(ex.Message); // } //} /// <summary> /// Updates the labels. /// </summary> /// <param name="label">The label.</param> /// <param name="key">The key.</param> /// <param name="uid">The id.</param> public void UpdateLabels(CreateNewLabel label, string key, string uid) { try { //// Updates the label in firebase this.firebase.Child("Persons").Child(uid).Child("Label").Child(key).PutAsync(new CreateNewLabel() { Label = label.Label }); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// Handles the Clicked event of the Delete control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void Delete_Clicked(object sender, EventArgs e) { FirebaseHelper firebaseHelper = new FirebaseHelper(); //// Gets current user id var userid = DependencyService.Get <IFirebaseAuthenticator>().UserId(); //// Updates the notes when DeleteNotes method is called CreateNewLabel label = new CreateNewLabel() { Label = txtLabel.Text, }; firebaseHelper.DeleteLabel(label, this.value, userid); }
/// <summary> /// Application developers can override this method to provide behavior when the back button is pressed. /// </summary> /// <returns> /// To be added. /// </returns> protected override bool OnBackButtonPressed() { try { FirebaseHelper firebaseHelper = new FirebaseHelper(); //// Gets current user id var userid = DependencyService.Get <IFirebaseAuthenticator>().UserId(); //// Updates the notes whenUpdateNotes method is called CreateNewLabel label = new CreateNewLabel() { Label = txtLabel.Text, }; firebaseHelper.UpdateLabels(label, this.value, userid); } catch (Exception e) { Console.WriteLine(e.Message); } return(base.OnBackButtonPressed()); }
/// <summary> /// Grids the view. /// </summary> /// <param name="list">The list.</param> public void GridView(IList <CreateNewLabel> list) { try { GridLayout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(350) }); 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 labelss GridLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(50) }); rowCount++; } var index = -1; //// Adds label to row and columns for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) { for (int columnIndex = 0; columnIndex < 1; columnIndex++) { CreateNewLabel data = null; index++; if (index < list.Count) { data = list[index]; } //// Creates Labels var label = new Xamarin.Forms.Label { Text = data.Label, TextColor = Color.Black, FontAttributes = FontAttributes.None, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, }; //// Created label key var labelKey = new Xamarin.Forms.Label { Text = data.LabelKey, IsVisible = false }; //// Image added to layout var image = new Image { Source = "label.png", VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Start, WidthRequest = 20, HeightRequest = 20, }; //// Image added to layout var imageedit = new Image { Source = "editicon.png", VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.End, }; //// Creates stack layout for each label StackLayout layout = new StackLayout() { Spacing = 2, Margin = 2, BackgroundColor = Color.White }; var tapGestureRecognizer = new TapGestureRecognizer(); layout.Children.Add(labelKey); layout.Children.Add(label); layout.Children.Add(image); layout.Children.Add(imageedit); layout.GestureRecognizers.Add(tapGestureRecognizer); layout.Spacing = 2; layout.Margin = 2; layout.BackgroundColor = Color.White; var frame = new Frame(); frame.BorderColor = Color.White; frame.Content = layout; //// Tapped gesture when tapped navigates to Update Labels Page tapGestureRecognizer.Tapped += (object sender, EventArgs args) => { StackLayout stacklayout = (StackLayout)sender; IList <Xamarin.Forms.View> item = stacklayout.Children; Xamarin.Forms.Label KeyValue = (Xamarin.Forms.Label)item[0]; var Keyval = KeyValue.Text; Navigation.PushAsync(new UpdateLabels(Keyval)); }; GridLayout.Children.Add(frame, columnIndex, rowIndex); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }