From 4ee886b8bce7d601ec39319226270b353b71ab2e Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Fri, 7 Oct 2016 18:14:28 +0200 Subject: [PATCH] Fixes the rating control --- BookAStar/BookAStar/Behaviors/StarBehavior.cs | 27 +++++--- BookAStar/BookAStar/BookAStar.csproj | 8 +-- .../BookAStar/Model/Workflow/Estimate.cs | 6 +- BookAStar/BookAStar/Pages/DashboardPage.xaml | 34 +++++---- .../BookAStar/Pages/EditBillingLinePage.xaml | 22 +++--- .../ViewModels/BillingLineViewModel.cs | 14 ++++ .../ViewModels/DashboardViewModel.cs | 2 + .../BookAStar/ViewModels/EstimateViewModel.cs | 4 +- BookAStar/BookAStar/Views/RatingView.xaml | 29 ++++---- BookAStar/BookAStar/Views/RatingView.xaml.cs | 69 ++++++++++++++++++- 10 files changed, 157 insertions(+), 58 deletions(-) diff --git a/BookAStar/BookAStar/Behaviors/StarBehavior.cs b/BookAStar/BookAStar/Behaviors/StarBehavior.cs index c73350f5..8ad6a9b0 100644 --- a/BookAStar/BookAStar/Behaviors/StarBehavior.cs +++ b/BookAStar/BookAStar/Behaviors/StarBehavior.cs @@ -87,8 +87,7 @@ namespace BookAStar.Behaviors BindableProperty.Create("IsStarred", typeof(bool), typeof(StarBehavior), - false, - propertyChanged: OnIsStarredChanged); + false); public bool IsStarred { @@ -100,8 +99,7 @@ namespace BookAStar.Behaviors { StarBehavior behavior = (StarBehavior)bindable; - if ((bool)newValue) - { + string groupName = behavior.GroupName; List behaviors = null; @@ -126,8 +124,14 @@ namespace BookAStar.Behaviors if (item == behavior) { itemReached = true; - item.IsStarred = true; - position = count; + // whould try to call this method again + // Assert item.IsStarred == newValue; + + // There are **6** positions, from 0 to five stars. + if ((bool)newValue) + position = count; + else position = count - 1; + } if (item != behavior && itemReached) item.IsStarred = false; @@ -135,8 +139,7 @@ namespace BookAStar.Behaviors item.Rating = position; count++; } - - } + } @@ -158,12 +161,14 @@ namespace BookAStar.Behaviors view.GestureRecognizers.Remove(tapRecognizer); tapRecognizer.Tapped -= OnTapRecognizerTapped; } - + void OnTapRecognizerTapped(object sender, EventArgs args) { // TODO HACK: PropertyChange does not fire, if the value is not changed :-( - IsStarred = false; - IsStarred = true; + bool currentIsStarred = (bool) GetValue(IsStarredProperty); + SetValue(IsStarredProperty, !currentIsStarred); + // does not lead to the call of: + OnIsStarredChanged(this,currentIsStarred,!currentIsStarred); } } } diff --git a/BookAStar/BookAStar/BookAStar.csproj b/BookAStar/BookAStar/BookAStar.csproj index fe37a575..7f218c4f 100644 --- a/BookAStar/BookAStar/BookAStar.csproj +++ b/BookAStar/BookAStar/BookAStar.csproj @@ -314,10 +314,10 @@ - - - - + + + + diff --git a/BookAStar/BookAStar/Model/Workflow/Estimate.cs b/BookAStar/BookAStar/Model/Workflow/Estimate.cs index 3b1e4174..cce5645a 100644 --- a/BookAStar/BookAStar/Model/Workflow/Estimate.cs +++ b/BookAStar/BookAStar/Model/Workflow/Estimate.cs @@ -22,12 +22,12 @@ namespace BookAStar.Model.Workflow /// In db, they are separated by : /// /// - public List AttachedGraphicList { get; set; } + public List AttachedGraphics { get; set; } public string AttachedGraphicsString { - get { return AttachedGraphicList==null?null:string.Join(":", AttachedGraphicList); } - set { AttachedGraphicList = value.Split(':').ToList(); } + get { return AttachedGraphics==null?null:string.Join(":", AttachedGraphics); } + set { AttachedGraphics = value.Split(':').ToList(); } } /// /// List of attached files diff --git a/BookAStar/BookAStar/Pages/DashboardPage.xaml b/BookAStar/BookAStar/Pages/DashboardPage.xaml index b744b970..b475686f 100644 --- a/BookAStar/BookAStar/Pages/DashboardPage.xaml +++ b/BookAStar/BookAStar/Pages/DashboardPage.xaml @@ -3,6 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:BookAStar;assembly=BookAStar" xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar" + xmlns:extensions="clr-namespace:BookAStar.Extensions;assembly=BookAStar" x:Class="BookAStar.Pages.DashboardPage" xmlns:lc="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms" xmlns:lb="clr-namespace:XLabs.Forms.Behaviors;assembly=XLabs.Forms" @@ -19,26 +20,35 @@ + + - - - - - - + + + + + + + + + + - - - + + + + + +