Mainly layouts and refacts

This commit is contained in:
Paul Schneider 2016-10-14 16:21:03 +02:00
commit 7b3340cbc3
23 changed files with 629 additions and 417 deletions

View file

@ -1,8 +1,4 @@
using BookAStar.Interfaces;
using BookAStar.Model;
using BookAStar.Pages;
using BookAStar.ViewModels;
using System;
using System;
using Xamarin.Forms;
using XLabs.Forms.Mvvm;
using XLabs.Forms.Pages;
@ -16,17 +12,20 @@ using XLabs.Enums;
namespace BookAStar
{
using Interfaces;
using Model;
using Pages;
using ViewModels;
public partial class App : Application // superclass new in 1.3
{
public static IPlatform PlatformSpecificInstance { get; set; }
public static string AppName { get; set; }
// Exists in order to dispose of a static instance strongly typed
// TODO : replace all references to this field
// by Views resolution, and then, drop it
// Exists in order to dispose of a static instance strongly typed,
// It Makes smaller code.
public static App CurrentApp { get { return Current as App; } }
public static bool MasterPresented
{
get
@ -65,7 +64,7 @@ namespace BookAStar
}
// FIXME Not called
// Called Once, at app init
private void OnInitialize(object sender, EventArgs e)
{
@ -81,21 +80,20 @@ namespace BookAStar
// Called on rotation
private void OnSuspended(object sender, EventArgs e)
{
// TODO the navigation stack persistence (save)
// TODO save the navigation stack
}
// called on app startup, after OnStartup, not on rotation
private void OnAppResumed(object sender, EventArgs e)
{
// TODO the navigation stack persistence (restore)
// TODO restore the navigation stack
base.OnResume();
}
// FIXME Not called ... see OnSuspended
// FIXME Not called?
private void OnRotation(object sender, EventArgs<Orientation> e)
{
// TODO the navigation stack persistence (restore?)
}
public static GenericConfigSettingsMgr ConfigManager { protected set; get; }
@ -215,9 +213,6 @@ namespace BookAStar
, BookQueryPage>((b, p) => p.BindingContext = new BookQueryViewModel(query));
App.Current.MainPage.Navigation.PushAsync(page as Page);
}
// TODO système de persistance de l'état de l'appli
}
}

View file

@ -56,14 +56,14 @@
<Compile Include="Extensions\EnumExtensions.cs" />
<Compile Include="Extensions\ImageResourceExtension.cs" />
<Compile Include="Factories\ViewFactory.cs" />
<Compile Include="Helpers\DataManager.cs" />
<Compile Include="Data\DataManager.cs" />
<Compile Include="Helpers\ObservableString.cs" />
<Compile Include="Interfaces\ILocalEntity.cs" />
<Compile Include="Helpers\LocaLEntity.cs" />
<Compile Include="Data\LocaLEntity.cs" />
<Compile Include="Helpers\NotIdentifiedException.cs" />
<Compile Include="Helpers\PageHelpers.cs" />
<Compile Include="Helpers\PropertySupport.cs" />
<Compile Include="Helpers\RemoteEntityRO.cs" />
<Compile Include="Data\RemoteEntityRO.cs" />
<Compile Include="Helpers\ServiceNotAvailable.cs" />
<Compile Include="Helpers\Settings.cs" />
<Compile Include="Helpers\UserHelpers.cs" />
@ -95,7 +95,7 @@
<DependentUpon>EventDetail.xaml</DependentUpon>
</Compile>
<Compile Include="Helpers\MainSettings.cs" />
<Compile Include="Helpers\RemoteEntity.cs" />
<Compile Include="Data\RemoteEntity.cs" />
<Compile Include="Interfaces\IPlatform.cs" />
<Compile Include="Model\Blog\Blog.cs" />
<Compile Include="Model\Blog\BlogTag.cs" />

View file

@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading.Tasks;
namespace BookAStar.Helpers
namespace BookAStar.Data
{
using Model;
using Model.Blog;

View file

@ -1,11 +1,10 @@

using BookAStar.Interfaces;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
namespace BookAStar
namespace BookAStar.Data
{
public class LocalEntity<V, K> : ObservableCollection<V>, ILocalEntity<V, K> where K : IEquatable<K>
{

View file

@ -6,7 +6,7 @@ using Newtonsoft.Json;
using System.Threading.Tasks;
using System.Net;
namespace BookAStar.Helpers
namespace BookAStar.Data
{
public class RemoteEntity<V,K> : LocalEntity<V, K>, ICommand where K : IEquatable<K>

View file

@ -1,11 +1,7 @@
using BookAStar;
using System;
using System.Collections.Generic;
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BookAStar.Helpers
namespace BookAStar.Data
{
public class RemoteEntityRO<V,K>: RemoteEntity<V,K> where K: IEquatable<K>
{

View file

@ -26,8 +26,8 @@
</ResourceDictionary>
</ContentPage.Resources>
<StackLayout Padding="10,10,10,10">
<ScrollView>
<StackLayout Padding="10,10,10,10" x:Name="mainLayout">
<ListView RefreshCommand="{Binding RefreshQueries}" IsPullToRefreshEnabled="True"
ItemsSource="{Binding Queries}" x:Name="list" ItemTapped="OnViewDetail" HasUnevenRows="true" RowHeight="80">
<ListView.ItemTemplate HeightRequest="80" VerticalOptions="StartAndExpand">
@ -46,7 +46,7 @@
<Label LineBreakMode="WordWrap" Text="{Binding EventDate, StringFormat='{0:dddd d MMMM à HH:mm}'}" FontSize="12" FontFamily="Italic"/>
</StackLayout>
<StackLayout Orientation="Vertical" VerticalOptions="StartAndExpand">
<StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand">
<Label LineBreakMode="WordWrap" Text="{Binding Location.Address}"/>
<Label Text="{Binding Previsionnal}"/>
<Label Text="{Binding Id}" HorizontalTextAlignment="End"/>
@ -58,5 +58,6 @@
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ScrollView>
</ContentPage>

View file

@ -20,5 +20,18 @@ namespace BookAStar.Pages
BookQueryData data = e.Item as BookQueryData;
App.NavigationService.NavigateTo<BookQueryPage>(true,data);
}
protected override void OnSizeAllocated(double width, double height)
{
/* TODO find a responsive layout
if (width > height)
{
mainLayout.Orientation = StackOrientation.Horizontal;
}
else
{
mainLayout.Orientation = StackOrientation.Vertical;
} */
base.OnSizeAllocated(width, height);
}
}
}

View file

@ -18,13 +18,16 @@
</ContentPage.Resources>
<StackLayout x:Name="bookQueryLayout">
<StackLayout Orientation="Vertical">
<Image Source="{Binding Client.AvatarOrNot}" Aspect="AspectFit" VisualElement.HeightRequest="{StaticResource BigUserAvatarSize}"/>
<Label Text="{Binding Client.UserName}"/>
<Label Text="{Binding EventDate, StringFormat='le {0:dddd d MMMM yyyy à hh:mm}'}" />
<Label Text="{Binding Location.Address}" />
<Label Text="{Binding Previsional}" />
</StackLayout>
<StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand">
<maps:Map x:Name="map" VerticalOptions="FillAndExpand"></maps:Map>
<Button Text="Faire un devis" Clicked="MakeAnEstimate" />
</StackLayout>
</StackLayout>
</ContentPage>

View file

@ -80,6 +80,18 @@ namespace BookAStar.Pages
App.NavigationService.NavigateTo<EditEstimatePage>(true,
new EditEstimateViewModel(e));
}
protected override void OnSizeAllocated(double width, double height)
{
if (width > height)
{
bookQueryLayout.Orientation = StackOrientation.Horizontal;
}
else
{
bookQueryLayout.Orientation = StackOrientation.Vertical;
}
base.OnSizeAllocated(width, height);
}
}
}

View file

@ -18,11 +18,11 @@
</Style>
<converters:EnumConverter x:Key="enumToInt" />
<converters:BooleanToObjectConverter x:Key="boolToStyleImage" x:TypeArguments="Style">
<converters:BooleanToObjectConverter.FalseObject>
<Style TargetType="Image">
<Setter Property="HeightRequest" Value="20" />
<Setter Property="Source"
<Setter Property="Source"
Value="{extensions:ImageResource BookAStar.Images.Validation.error.png}" />
</Style>
</converters:BooleanToObjectConverter.FalseObject>
@ -30,58 +30,73 @@
<converters:BooleanToObjectConverter.TrueObject>
<Style TargetType="Image">
<Setter Property="HeightRequest" Value="20" />
<Setter Property="Source"
<Setter Property="Source"
Value="{extensions:ImageResource BookAStar.Images.Validation.success.png}" />
</Style>
</converters:BooleanToObjectConverter.TrueObject>
</converters:BooleanToObjectConverter>
</ResourceDictionary>
</ContentPage.Resources>
<ScrollView>
<StackLayout x:Name="mainStackLayout">
<Label Text="Description de la ligne de facture"
Style="{StaticResource InputLabelStyle}"></Label>
<Editor VerticalOptions="FillAndExpand" Text="{Binding Description, Mode=TwoWay}">
<Editor.Behaviors>
<behaviors:EditorMaxLengthValidator x:Name="descriptionValidator" MaxLength="512" />
</Editor.Behaviors>
</Editor>
<Image Style="{Binding Source={x:Reference descriptionValidator},
<Label Text="Description de la ligne de facture"
Style="{StaticResource InputLabelStyle}"></Label>
<StackLayout Orientation="Horizontal" VerticalOptions="FillAndExpand">
<Editor HorizontalOptions="FillAndExpand" Text="{Binding Description, Mode=TwoWay}">
<Editor.Behaviors>
<behaviors:EditorMaxLengthValidator x:Name="descriptionValidator" MaxLength="512" />
</Editor.Behaviors>
</Editor>
<Image HorizontalOptions="End" Style="{Binding Source={x:Reference descriptionValidator},
Path=IsValid,
Converter={StaticResource boolToStyleImage}}" />
<Label Text="Durée de la prestation"
Style="{StaticResource InputLabelStyle}"></Label>
<StackLayout Orientation="Horizontal">
<Entry Placeholder="Durée" Keyboard="Numeric" Style="{StaticResource BigEntry}"
Text="{Binding DurationValue, Mode=TwoWay}" />
<views:EnumPicker x:Name="picker" Style="{StaticResource PickerStyle}"
EnumSource="{Binding DurationUnit}"
Title="Unité de temps"
SelectedItem="{Binding DurationUnit, Mode=TwoWay}">
</views:EnumPicker>
</StackLayout>
<Label Text="Quantité facturée" Style="{StaticResource InputLabelStyle}"></Label>
<Entry Text="{Binding Count, Mode=TwoWay}" Placeholder="Quantité" Keyboard="Numeric"
Style="{StaticResource BigEntry}"/>
<Label Text="Prix unitaire" Style="{StaticResource InputLabelStyle}"></Label>
<StackLayout Orientation="Horizontal">
<Entry Text="{Binding UnitaryCostText, Mode=TwoWay}" Placeholder="Prix"
Keyboard="Numeric" Style="{StaticResource BigEntry}">
<Entry.Behaviors>
<behaviors:DecimalValidatorBehavior x:Name="unitCostValidator" />
</Entry.Behaviors>
</Entry>
<Label Text="€" Style="{StaticResource BigLabel}" />
<Image x:Name="unitaryCostSuccessErrorImage"
Style="{Binding Source={x:Reference unitCostValidator},
</StackLayout>
<Label Text="Durée de la prestation"
Style="{StaticResource InputLabelStyle}">
</Label>
<StackLayout Orientation="Horizontal">
<Entry Placeholder="Durée" Keyboard="Numeric" Style="{StaticResource BigEntry}"
Text="{Binding DurationValue, Mode=TwoWay, StringFormat='{0}'}" >
<Entry.Behaviors>
<behaviors:DecimalValidatorBehavior x:Name="durationValidator" />
</Entry.Behaviors>
</Entry>
<views:EnumPicker x:Name="picker" Style="{StaticResource PickerStyle}"
EnumSource="{Binding DurationUnit}"
Title="Unité de temps"
SelectedItem="{Binding DurationUnit, Mode=TwoWay}">
</views:EnumPicker>
<Image x:Name="durationSuccessErrorImage"
Style="{Binding Source={x:Reference durationValidator},
Path=IsValid,
Converter={StaticResource boolToStyleImage}}" />
</StackLayout>
<Button Text="Valider cette ligne de devis"
Command="{Binding ValidateCommand}"
Clicked="OnValidateClicked"></Button>
</StackLayout>
<Label Text="Quantité facturée" Style="{StaticResource InputLabelStyle}"></Label>
<Entry Text="{Binding Count, Mode=TwoWay}" Placeholder="Quantité" Keyboard="Numeric"
Style="{StaticResource BigEntry}"/>
<Label Text="Prix unitaire" Style="{StaticResource InputLabelStyle}"></Label>
<StackLayout Orientation="Horizontal">
<Entry Text="{Binding UnitaryCostText, Mode=TwoWay}" Placeholder="Prix"
Keyboard="Numeric" Style="{StaticResource BigEntry}">
<Entry.Behaviors>
<behaviors:DecimalValidatorBehavior x:Name="unitCostValidator" />
</Entry.Behaviors>
</Entry>
<Label Text="€" Style="{StaticResource BigLabel}" />
<Image x:Name="unitaryCostSuccessErrorImage"
Style="{Binding Source={x:Reference unitCostValidator},
Path=IsValid,
Converter={StaticResource boolToStyleImage}}" />
</StackLayout>
<Button Text="Valider cette ligne de devis"
Command="{Binding ValidateCommand}"
Clicked="OnValidateClicked"></Button>
</StackLayout>
</ScrollView>
</ContentPage>

View file

@ -16,62 +16,67 @@
</ResourceDictionary>
</ContentPage.Resources>
<ScrollView>
<StackLayout Padding="10,10,10,10">
<StackLayout Orientation="Horizontal" Padding="10,10,10,10" View.VerticalOptions="CenterAndExpand">
<Label Text="{Binding Client.UserName}" LineBreakMode="WordWrap" View.VerticalOptions="CenterAndExpand"></Label>
<Label Text="{Binding Query.Location.Address}" LineBreakMode="WordWrap" View.VerticalOptions="CenterAndExpand"></Label>
<Label Text="{Binding Query.EventDate, StringFormat='{0:dddd d MMMM yyyy à hh:mm}'}" LineBreakMode="WordWrap" View.VerticalOptions="CenterAndExpand"></Label>
</StackLayout>
<StackLayout Padding="10,10,10,10" x:Name="mainLayout">
<views:MarkdownView x:Name="mdview"
HorizontalOptions="FillAndExpand"
View.VerticalOptions="CenterAndExpand"
Markdown="{Binding Description, Mode=TwoWay}"
MinimumHeightRequest="160"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=.6}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=1}"
></views:MarkdownView>
<ListView x:Name="BillListView" ItemsSource="{Binding Bill}"
VerticalOptions="End" MinimumHeightRequest="30" >
<ListView.ItemTemplate>
<DataTemplate >
<ViewCell>
<ViewCell.View>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="30" />
<ColumnDefinition Width="90" />
</Grid.ColumnDefinitions>
<Label Text="{Binding Description}"
Grid.Row="0" Grid.Column="0" ></Label>
<Label Text="{Binding Duration, StringFormat=\{0\}}"
Grid.Row="0" Grid.Column="1" ></Label>
<Label Text="{Binding Count}"
Grid.Row="0" Grid.Column="2" ></Label>
<Label Text="{Binding UnitaryCost}"
Grid.Row="0" Grid.Column="3"
FontFamily="Monospace"></Label>
</Grid>
<Grid MinimumHeightRequest="12">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Text="{Binding Client.UserName}" ></Label>
<Label Grid.Row="0" Grid.Column="1" Text="{Binding Query.Location.Address}" ></Label>
<Label Grid.Row="0" Grid.Column="2" Text="{Binding Query.EventDate, StringFormat='{0:dddd d MMMM yyyy à hh:mm}'}" ></Label>
</Grid>
<views:MarkdownView x:Name="mdview"
Editable="True"
HorizontalOptions="FillAndExpand"
Markdown="{Binding Description, Mode=TwoWay}"
VerticalOptions="Start"
/>
<StackLayout x:Name="biAnVaLayout">
<ListView x:Name="BillListView" ItemsSource="{Binding Bill}"
MinimumHeightRequest="40" HasUnevenRows="true" VerticalOptions="FillAndExpand"
HeightRequest="40">
<ListView.ItemTemplate>
<DataTemplate >
<ViewCell>
<ViewCell.View>
<Grid MinimumHeightRequest="12">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="30" />
<ColumnDefinition Width="90" />
</Grid.ColumnDefinitions>
<Label Text="{Binding Description}"
Grid.Row="0" Grid.Column="0" ></Label>
<Label Text="{Binding Duration, StringFormat=\{0\}}"
Grid.Row="0" Grid.Column="1" ></Label>
<Label Text="{Binding Count}"
Grid.Row="0" Grid.Column="2" ></Label>
<Label Text="{Binding UnitaryCost}"
Grid.Row="0" Grid.Column="3"
FontFamily="Monospace"></Label>
</Grid>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Button Text="Ajouter une ligne de facture" Clicked="OnNewCommanLine"></Button>
<Label FormattedText="{Binding FormattedTotal}"/>
<Button Text="Valider ce devis"></Button>
</StackLayout>
</ScrollView>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<StackLayout Orientation="Vertical">
<Button Text="Ajouter une ligne de facture" Clicked="OnNewCommanLine"></Button>
<Label FormattedText="{Binding FormattedTotal}"/>
<Button Text="Valider ce devis" Clicked="OnEstimateValidated" ></Button>
</StackLayout>
</StackLayout>
</StackLayout>
</ScrollView>
</ContentPage>

View file

@ -1,21 +1,10 @@
using BookAStar.Model;
using BookAStar.Model.Workflow;
using BookAStar.ViewModels;
using BookAStar.Views;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System;
using Xamarin.Forms;
using Xamarin.Forms.Internals;
using XLabs.Forms.Services;
using XLabs.Ioc;
using XLabs.Platform.Services;
namespace BookAStar.Pages
{
using Model.Workflow;
using ViewModels;
public partial class EditEstimatePage : ContentPage
{
@ -25,16 +14,17 @@ namespace BookAStar.Pages
BindingContext = model;
}
protected override void OnBindingContextChanged()
protected override void OnSizeAllocated(double width, double height)
{
base.OnBindingContextChanged();
((EditEstimateViewModel)BindingContext).PropertyChanged += EditEstimatePage_PropertyChanged;
}
private void EditEstimatePage_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (width > height)
{
biAnVaLayout.Orientation = StackOrientation.Horizontal;
}
else
{
biAnVaLayout.Orientation = StackOrientation.Vertical;
}
base.OnSizeAllocated(width, height);
}
protected void OnNewCommanLine(object sender, EventArgs e)
@ -52,6 +42,10 @@ namespace BookAStar.Pages
true,
new object[] { lineView } );
}
protected void OnEstimateValidated(object sender, EventArgs e)
{
throw new NotImplementedException();
}
}
}

View file

@ -15,7 +15,9 @@ namespace BookAStar.Views
public static readonly BindableProperty MarkdownProperty = BindableProperty.Create(
"Markdown", typeof(string), typeof(MarkdownView), null, BindingMode.TwoWay
);
public static readonly BindableProperty EditableProperty = BindableProperty.Create(
"Editable", typeof(bool), typeof(MarkdownView), false, BindingMode.OneWay
);
public string Markdown
{
get
@ -36,6 +38,14 @@ namespace BookAStar.Views
}
}
}
private bool editable;
public bool Editable
{
get {
return (bool) GetValue(EditableProperty);
}
set { SetValue (EditableProperty, value); }
}
public event EventHandler<EventArgs> Modified;