new files, fixes recent refactorings and more

main
Paul Schneider 9 years ago
parent 36054f8b73
commit 41b245fd2d
14 changed files with 200 additions and 130 deletions

@ -40,7 +40,16 @@
<Compile Include="App.xaml.cs"> <Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon> <DependentUpon>App.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Behaviors\EmailValidatorBehavior.cs" />
<Compile Include="Behaviors\MaxLengthValidator.cs" />
<Compile Include="Behaviors\DecimalValidatorBehavior.cs" />
<Compile Include="Behaviors\PickerBehavior.cs" />
<Compile Include="Behaviors\StarBehavior.cs" />
<Compile Include="Constants.cs" /> <Compile Include="Constants.cs" />
<Compile Include="Converters\BooleanToObjectConverter.cs" />
<Compile Include="Converters\GenderConverter.cs" />
<Compile Include="Converters\RatingText.cs" />
<Compile Include="Extensions\ImageResourceExtension.cs" />
<Compile Include="Factories\ViewFactory.cs" /> <Compile Include="Factories\ViewFactory.cs" />
<Compile Include="Helpers\DataManager.cs" /> <Compile Include="Helpers\DataManager.cs" />
<Compile Include="Helpers\ObservableString.cs" /> <Compile Include="Helpers\ObservableString.cs" />
@ -50,7 +59,7 @@
<Compile Include="Helpers\PageHelpers.cs" /> <Compile Include="Helpers\PageHelpers.cs" />
<Compile Include="Helpers\PropertySupport.cs" /> <Compile Include="Helpers\PropertySupport.cs" />
<Compile Include="Helpers\RemoteEntityRO.cs" /> <Compile Include="Helpers\RemoteEntityRO.cs" />
<Compile Include="Helpers\ServiceNotAvailable1.cs" /> <Compile Include="Helpers\ServiceNotAvailable.cs" />
<Compile Include="Helpers\Settings.cs" /> <Compile Include="Helpers\Settings.cs" />
<Compile Include="Helpers\UserHelpers.cs" /> <Compile Include="Helpers\UserHelpers.cs" />
<Compile Include="Interfaces\IComponentContext.cs" /> <Compile Include="Interfaces\IComponentContext.cs" />
@ -133,9 +142,6 @@
<Compile Include="ViewModels\EstimateViewModel.cs" /> <Compile Include="ViewModels\EstimateViewModel.cs" />
<Compile Include="ViewModels\UserLoginViewModel.cs" /> <Compile Include="ViewModels\UserLoginViewModel.cs" />
<Compile Include="ViewModels\ViewModelBase.cs" /> <Compile Include="ViewModels\ViewModelBase.cs" />
<Compile Include="Views\CommandLineEditor.xaml.cs">
<DependentUpon>CommandLineEditor.xaml</DependentUpon>
</Compile>
<Compile Include="Views\MarkdownView.cs" /> <Compile Include="Views\MarkdownView.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Pages\SearchPage.xaml.cs"> <Compile Include="Pages\SearchPage.xaml.cs">
@ -145,6 +151,9 @@
<DependentUpon>AccountChooserPage.xaml</DependentUpon> <DependentUpon>AccountChooserPage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Model\Tag.cs" /> <Compile Include="Model\Tag.cs" />
<Compile Include="Views\RatingView.xaml.cs">
<DependentUpon>RatingView.xaml</DependentUpon>
</Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="App.xaml"> <EmbeddedResource Include="App.xaml">
@ -279,33 +288,39 @@
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Views\CommandLineEditor.xaml"> <EmbeddedResource Include="Pages\EditBillingLinePage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator> <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
<SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Pages\EditBillingLinePage.xaml"> <EmbeddedResource Include="Pages\DashboardPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator> <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Pages\DashboardPage.xaml"> <EmbeddedResource Include="Images\Users\icon_add_user.png" />
<EmbeddedResource Include="Images\Users\icon_anon_user.png" />
<EmbeddedResource Include="Images\Users\icon_block_user.png" />
<EmbeddedResource Include="Images\Users\icon_remove_user.png" />
<EmbeddedResource Include="Images\Users\icon_user.png" />
<EmbeddedResource Include="Images\Users\icon_user_settings.png" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Pages\HomePage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator> <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Images\icon_add_user.png" /> <Content Include="Images\Validation\error.png" />
<EmbeddedResource Include="Images\icon_anon_user.png" /> <Content Include="Images\Validation\star_outline.png" />
<EmbeddedResource Include="Images\icon_block_user.png" /> <Content Include="Images\Validation\star_selected.png" />
<EmbeddedResource Include="Images\icon_remove_user.png" /> <Content Include="Images\Validation\success.png" />
<EmbeddedResource Include="Images\icon_user.png" />
<EmbeddedResource Include="Images\icon_user_settings.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Pages\HomePage.xaml"> <EmbeddedResource Include="Views\RatingView.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator> <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>

@ -18,7 +18,7 @@ namespace BookAStar.Pages
private void OnViewDetail(object sender, ItemTappedEventArgs e) private void OnViewDetail(object sender, ItemTappedEventArgs e)
{ {
BookQueryData data = e.Item as BookQueryData; BookQueryData data = e.Item as BookQueryData;
App.CurrentApp.NavigationService.NavigateTo<BookQueryPage>(true,data); App.NavigationService.NavigateTo<BookQueryPage>(true,data);
} }
} }
} }

@ -77,7 +77,7 @@ namespace BookAStar.Pages
Id = 0, Id = 0,
Description = "# **Hello Estimate!**" Description = "# **Hello Estimate!**"
}; };
App.CurrentApp.NavigationService.NavigateTo<EditEstimatePage>(true, App.NavigationService.NavigateTo<EditEstimatePage>(true,
new EstimateViewModel(e)); new EstimateViewModel(e));
} }

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:BookAStar;assembly=BookAStar"
xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar"
x:Class="BookAStar.Pages.DashboardPage" x:Class="BookAStar.Pages.DashboardPage"
xmlns:lc="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms" xmlns:lc="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"
xmlns:lb="clr-namespace:XLabs.Forms.Behaviors;assembly=XLabs.Forms" xmlns:lb="clr-namespace:XLabs.Forms.Behaviors;assembly=XLabs.Forms"
@ -23,16 +25,20 @@
</Label> </Label>
<lb:Gestures.Interests> <lb:Gestures.Interests>
<lb:GestureCollection> <lb:GestureCollection>
<lb:GestureInterest GestureType="LongPress" GestureCommand="{Binding UserNameGesture}" GestureParameter="LongPress" /> <lb:GestureInterest GestureType="LongPress"
GestureCommand="{Binding UserNameGesture}"
GestureParameter="LongPress" />
</lb:GestureCollection> </lb:GestureCollection>
</lb:Gestures.Interests>
<Image Source="{Binding Avatar}" Aspect="AspectFit" VisualElement.HeightRequest="{StaticResource BigUserAvatarSize}" /> <Image Source="{Binding Avatar}" Aspect="AspectFit" VisualElement.HeightRequest="{StaticResource BigUserAvatarSize}" />
</Frame>
</lc:GesturesContentView>
<Label Text="{Binding UserName}" Style="{StaticResource LabelPageHeadingStyle}" <Label Text="{Binding UserName}" Style="{StaticResource LabelPageHeadingStyle}"
HorizontalTextAlignment="Center" HorizontalTextAlignment="Center"
LineBreakMode="WordWrap" XAlign="Center" LineBreakMode="WordWrap" XAlign="Center"
></Label> ></Label>
<views:RatingView Rating="{Binding Rating}"/>
</lb:Gestures.Interests>
</Frame>
</lc:GesturesContentView>
<Button Text="{Binding PerformerStatus}" Clicked="OnViewPerformerStatus" /> <Button Text="{Binding PerformerStatus}" Clicked="OnViewPerformerStatus" />
<Button Text="{Binding UserQueries}" Clicked="OnViewUserQueries" /> <Button Text="{Binding UserQueries}" Clicked="OnViewUserQueries" />
<StackLayout Orientation="Horizontal" > <StackLayout Orientation="Horizontal" >

@ -35,7 +35,7 @@ namespace BookAStar.Pages
private void ShowPage<T>(object [] args, bool animate=false) where T:Page private void ShowPage<T>(object [] args, bool animate=false) where T:Page
{ {
App.CurrentApp.NavigationService.NavigateTo<T>(animate, args); App.NavigationService.NavigateTo<T>(animate, args);
App.MasterPresented = false; App.MasterPresented = false;
} }

@ -22,21 +22,21 @@
Style="{StaticResource InputLabelStyle}"></Label> Style="{StaticResource InputLabelStyle}"></Label>
<StackLayout Orientation="Horizontal"> <StackLayout Orientation="Horizontal">
<Entry Placeholder="Durée" Keyboard="Numeric" Style="{StaticResource BigEntry}" /> <Entry Placeholder="Durée" Keyboard="Numeric" Style="{StaticResource BigEntry}" />
<Picker x:Name="picker" SelectedIndex="1" Style="{StaticResource PickerStyle}" Title="Unité de temps"> <Picker x:Name="picker" SelectedIndex="{Binding UnitaryCost, Mode=TwoWay}" Style="{StaticResource PickerStyle}" Title="Unité de temps">
<Picker.Items> <Picker.Items>
<x:String>Heures</x:String>
<x:String>Jours</x:String> <x:String>Jours</x:String>
<x:String>Heures</x:String>
<x:String>Minutes</x:String> <x:String>Minutes</x:String>
</Picker.Items> </Picker.Items>
</Picker> </Picker>
</StackLayout> </StackLayout>
<Label Text="Quantité facturée" Style="{StaticResource InputLabelStyle}"></Label> <Label Text="Quantité facturée" Style="{StaticResource InputLabelStyle}"></Label>
<Entry Placeholder="Quantité" Text="1" Keyboard="Numeric" Style="{StaticResource BigEntry}"/> <Entry Text="{Binding Count, Mode=TwoWay}" Placeholder="Quantité" Keyboard="Numeric" Style="{StaticResource BigEntry}"/>
<Label Text="Prix unitaire" Style="{StaticResource InputLabelStyle}"></Label> <Label Text="Prix unitaire" Style="{StaticResource InputLabelStyle}"></Label>
<StackLayout Orientation="Horizontal"> <StackLayout Orientation="Horizontal">
<Entry Placeholder="Prix" Keyboard="Numeric" Style="{StaticResource BigEntry}"></Entry> <Entry Text="{Binding UnitaryCostText, Mode=TwoWay}" Placeholder="Prix" Keyboard="Numeric" Style="{StaticResource BigEntry}"></Entry>
<Label Text="€" Style="{StaticResource BigLabel}" HorizontalTextAlignment="Start"/> <Label Text="€" Style="{StaticResource BigLabel}" HorizontalTextAlignment="Start"/>
</StackLayout> </StackLayout>
<Button Text="Valider cette ligne de facture" Command="{Binding ValidateCommand}"></Button> <Button Text="Valider cette ligne de facture" Command="{Binding ValidateCommand}" Clicked="OnValidateClicked"></Button>
</StackLayout> </StackLayout>
</ContentPage> </ContentPage>

@ -13,9 +13,12 @@ namespace BookAStar.Pages
{ {
public EditBillingLinePage(BillingLineViewModel model) public EditBillingLinePage(BillingLineViewModel model)
{ {
InitializeComponent();
BindingContext = model; BindingContext = model;
InvalidateMeasure(); InitializeComponent();
}
public void OnValidateClicked (object sender, EventArgs e)
{
OnBackButtonPressed();
} }
} }
} }

@ -43,10 +43,18 @@ namespace BookAStar.Pages
protected void OnNewCommanLine(object sender, EventArgs e) protected void OnNewCommanLine(object sender, EventArgs e)
{ {
var com = new BillingLine(); var com = new BillingLine() { Count = 1, UnitaryCost = 0.01m };
App.CurrentApp.NavigationService.NavigateTo<EditBillingLinePage>( var lineView = new BillingLineViewModel(com)
{
ValidateCommand = new Command(() => {
((EstimateViewModel)BindingContext).Bill.
Add(com);
})
};
App.NavigationService.NavigateTo<EditBillingLinePage>(
true, true,
new object[] { new BillingLineViewModel(((EstimateViewModel)this.BindingContext).Data,com) } ); new object[] { lineView } );
} }
} }

@ -1,6 +1,7 @@
using BookAStar.Interfaces; using BookAStar.Interfaces;
using BookAStar.Model.Workflow; using BookAStar.Model.Workflow;
using System; using System;
using System.Globalization;
using System.Windows.Input; using System.Windows.Input;
using Xamarin.Forms; using Xamarin.Forms;
using XLabs.Forms.Mvvm; using XLabs.Forms.Mvvm;
@ -10,18 +11,12 @@ namespace BookAStar.ViewModels
public class BillingLineViewModel : ViewModel, IBillingLine public class BillingLineViewModel : ViewModel, IBillingLine
{ {
BillingLine data; BillingLine data;
public Estimate Billing { protected set; get; }
public BillingLineViewModel(Estimate billing, BillingLine data) public BillingLineViewModel( BillingLine data)
{ {
this.data = (data == null) ? new BillingLine() : data; this.data = (data == null) ? new BillingLine() : data;
Billing = billing; // sets durationValue & unit
ValidateCommand = Duration = data.Duration;
new Command(
() => {
Billing.Bill.Add(data);
Validated.Invoke(this, new EventArgs());
});
} }
protected int count; protected int count;
@ -29,12 +24,13 @@ namespace BookAStar.ViewModels
{ {
get get
{ {
return count; return data.Count;
} }
set set
{ {
SetProperty<int>(ref count, value, "Count"); SetProperty<int>(ref count, value, "Count");
data.Count = count;
} }
} }
protected string description; protected string description;
@ -42,45 +38,129 @@ namespace BookAStar.ViewModels
{ {
get get
{ {
return description; return data.Description;
} }
set set
{ {
SetProperty<string>(ref description, value, "Description"); SetProperty<string>(ref description, value, "Description");
data.Description = value;
} }
} }
protected TimeSpan duration; protected int durationValue;
public TimeSpan Duration public int DurationValue
{ {
get get
{ {
return duration; return durationValue;
}
set
{
SetProperty<int>(ref durationValue, value, "DurationValue");
data.Duration = this.Duration;
}
} }
public enum DurationUnits:int
{
Jours=0,
Heures=1,
Minutes=2
}
private DurationUnits durationUnit;
public DurationUnits DurationUnit
{
get {
return durationUnit;
}
set set
{ {
SetProperty<TimeSpan>(ref duration, value, "Duration"); SetProperty<DurationUnits>(ref durationUnit, value, "DurationUnit");
data.Duration = this.Duration;
} }
} }
protected decimal unitaryCost; protected decimal unitaryCost;
public decimal UnitaryCost public static readonly string unitCostFormat = "0,.00";
public string UnitaryCostText
{ {
get get
{ {
return unitaryCost; return unitaryCost.ToString(unitCostFormat, CultureInfo.InvariantCulture);
} }
set set
{ {
SetProperty<decimal>(ref unitaryCost, value, "UnitaryCost"); decimal newValue;
if (decimal.TryParse(value, NumberStyles.Currency,
CultureInfo.InvariantCulture,
out newValue))
{
SetProperty<decimal>(ref unitaryCost, newValue, "UnitaryCostText");
SetProperty<bool>(ref invalidCost, false, "InvalidCost");
}
else
SetProperty<bool>(ref invalidCost, true, "InvalidCost");
}
}
bool invalidCost;
public bool InvalidCost
{
get { return invalidCost; }
}
public ICommand ValidateCommand { set; get; }
public TimeSpan Duration
{
get
{
switch (DurationUnit)
{
case DurationUnits.Heures:
return new TimeSpan(DurationValue, 0, 0);
case DurationUnits.Jours:
return new TimeSpan(DurationValue*24, 0, 0);
case DurationUnits.Minutes:
return new TimeSpan(0, DurationValue, 0);
// Assert(false); since all units are treated bellow
default:
return new TimeSpan(0, 0, DurationValue);
} }
} }
public ICommand ValidateCommand { protected set; get; } set
{
double days = value.TotalDays;
if (days >= 1.0)
{
DurationValue = (int) days;
DurationUnit = DurationUnits.Jours;
return;
}
double hours = value.TotalHours;
if (hours >= 1.0)
{
DurationValue = (int) hours;
DurationUnit = DurationUnits.Jours;
return;
}
DurationValue = (int) value.TotalMinutes;
DurationUnit = DurationUnits.Minutes;
}
}
public event EventHandler<EventArgs> Validated; public decimal UnitaryCost
{
get
{
return decimal.Parse(this.UnitaryCostText,CultureInfo.InvariantCulture);
}
set
{
UnitaryCostText = value.ToString(unitCostFormat, CultureInfo.InvariantCulture);
}
}
} }
} }

@ -12,6 +12,7 @@ using XLabs.Platform.Services;
namespace BookAStar.ViewModels namespace BookAStar.ViewModels
{ {
internal class DashboardViewModel : ViewModel internal class DashboardViewModel : ViewModel
{ {
public string UserId public string UserId

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:BookAStar;assembly=BookAStar"
x:Class="BookAStar.Views.CommandLineEditor"
BackgroundColor="{x:Static local:Constants.BackgroundColor}"
>
<StackLayout>
<Label Text="Description de la ligne de facture"></Label>
<Editor ></Editor>
<StackLayout Orientation="Horizontal">
<Entry Placeholder="Durée de la prestation" Keyboard="Numeric"></Entry>
<Picker>
<Picker.Items>
<x:String>Heures</x:String>
<x:String>Jours</x:String>
<x:String>Minutes</x:String>
</Picker.Items>
</Picker>
</StackLayout>
<Entry Placeholder="Quantité" Text="1"/>
<Entry Placeholder="Prix unitaire" ></Entry>
<Button Text="Valider cette ligne de facture"></Button>
</StackLayout>
</ContentView>

@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace BookAStar.Views
{
public partial class CommandLineEditor : ContentView
{
public CommandLineEditor()
{
InitializeComponent();
}
}
}

@ -1,6 +1,7 @@
using BookAStar.Interfaces; using BookAStar.Interfaces;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Reflection.Emit; using System.Reflection.Emit;
using System.Text; using System.Text;
@ -15,19 +16,18 @@ namespace BookAStar.Views
"Markdown", typeof(string), typeof(MarkdownView), null, BindingMode.TwoWay "Markdown", typeof(string), typeof(MarkdownView), null, BindingMode.TwoWay
); );
private string markdown;
public string Markdown public string Markdown
{ {
get get
{ {
return markdown; return GetValue(MarkdownProperty) as string;
} }
set set
{ {
if (markdown != value) if (Markdown != value)
{ {
markdown = value; SetValue(MarkdownProperty, value);
if (Modified != null) if (Modified != null)
{ {
Modified.Invoke(this, new EventArgs()); Modified.Invoke(this, new EventArgs());
@ -45,10 +45,10 @@ namespace BookAStar.Views
double height = heightConstraint; double height = heightConstraint;
if (MinimumWidthRequest>0) if (MinimumWidthRequest>0)
width = widthConstraint > 80 ? widthConstraint < double.MaxValue ? widthConstraint : MinimumWidthRequest : MinimumWidthRequest; width = widthConstraint > MinimumWidthRequest ? widthConstraint < double.MaxValue ? widthConstraint : MinimumWidthRequest : MinimumWidthRequest;
if (MinimumHeightRequest > 0) if (MinimumHeightRequest > 0)
height = heightConstraint > 160 ? heightConstraint < double.MaxValue ? heightConstraint : MinimumHeightRequest : MinimumHeightRequest; height = heightConstraint > MinimumHeightRequest ? heightConstraint < double.MaxValue ? heightConstraint : MinimumHeightRequest : MinimumHeightRequest;
return base.OnMeasure(width, height); return base.OnMeasure(width, height);
} }

Loading…