changement de candidat à l'investissement

This commit is contained in:
Paul Schneider 2017-01-26 11:04:03 +01:00
commit be3087fff6
351 changed files with 359 additions and 497 deletions

View file

@ -0,0 +1,49 @@
using BookAStar.Model.Blog;
using Xamarin.Forms;
namespace BookAStar.Pages.BlogPages
{
public class BlogPage : ContentPage
{
HtmlWebViewSource _source;
HtmlWebViewSource _sourceTitle;
MarkdownDeep.Markdown _md;
WebView titleLabel;
WebView contentView;
public BlogPage()
{
_source = new HtmlWebViewSource();
_sourceTitle = new HtmlWebViewSource();
_md = new MarkdownDeep.Markdown();
_sourceTitle.BaseUrl = _source.BaseUrl = Constants.YavscHomeUrl;
_sourceTitle.Html = "Hello";
titleLabel = new WebView { Source = _sourceTitle };
contentView = new WebView { Source = _source };
Content = new StackLayout
{
Children = {
titleLabel,
contentView
}
};
}
protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();
var blog = BindingContext as Blog;
if (blog == null)
{
_sourceTitle.Html = _source.Html = "";
}
else
{
_sourceTitle.Html = _md.Transform(blog.Title);
_source.Html = _md.Transform(blog.Content);
}
}
}
}

View file

@ -0,0 +1,137 @@
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BookAStar.Pages.Chat.ChatPage"
xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar"
xmlns:controls="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"
xmlns:toolkit="clr-namespace:XLabs.Forms.Mvvm;assembly=XLabs.Forms"
xmlns:converters="clr-namespace:BookAStar.Converters;assembly=BookAStar"
xmlns:local="clr-namespace:BookAStar;Assembly:BookAStar"
xmlns:extensions="clr-namespace:BookAStar.Extensions;assembly=BookAStar"
Style="{StaticResource PageStyle}" >
<TabbedPage.Resources>
<ResourceDictionary>
<converters:SignalRConnectionStateToObject x:Key="cxToStyleImage" x:TypeArguments="Style">
<converters:SignalRConnectionStateToObject.DisconnectedObject>
<Style TargetType="Image">
<Setter Property="Source"
Value="{extensions:ImageResource BookAStar.Images.Chat.disconnected.png}" />
</Style>
</converters:SignalRConnectionStateToObject.DisconnectedObject>
<converters:SignalRConnectionStateToObject.ConnectedObject>
<Style TargetType="Image">
<Setter Property="Source"
Value="{extensions:ImageResource BookAStar.Images.Chat.connected.png}" />
</Style>
</converters:SignalRConnectionStateToObject.ConnectedObject>
<converters:SignalRConnectionStateToObject.ConnectingObject>
<Style TargetType="Image">
<Setter Property="Source"
Value="{extensions:ImageResource BookAStar.Images.Chat.connecting.png}" />
</Style>
</converters:SignalRConnectionStateToObject.ConnectingObject>
<converters:SignalRConnectionStateToObject.ReconnectingObject>
<Style TargetType="Image">
<Setter Property="Source"
Value="{extensions:ImageResource BookAStar.Images.Chat.reconnecting.png}" />
</Style>
</converters:SignalRConnectionStateToObject.ReconnectingObject>
</converters:SignalRConnectionStateToObject>
</ResourceDictionary>
</TabbedPage.Resources>
<TabbedPage.Children>
<ContentPage Title="Public" Icon="chat_icon_s.png" >
<StackLayout Padding="5, 5, 5, 5">
<StackLayout Spacing = "12"
Orientation = "Horizontal"
Padding="5, 0, 5, 0">
<Image Style="{Binding Path=State, Converter={StaticResource cxToStyleImage}}" />
<Entry x:Name="messageEntry" Placeholder = "enter your Message"
VerticalOptions = "Center"
HorizontalOptions = "FillAndExpand"></Entry>
<Button x:Name="sendButton" Text = "Send" HorizontalOptions = "End"
VerticalOptions = "Center"></Button>
</StackLayout>
<ListView x:Name="messageList" HasUnevenRows="true" ItemsSource="{Binding Messages}">
<ListView.ItemTemplate HeightRequest="80" VerticalOptions="StartAndExpand">
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Horizontal" VerticalOptions="StartAndExpand">
<Label Text="{Binding Date, StringFormat='{0:HH:mm}'}" FontAttributes="Italic" />
<Label Text="{Binding SenderId}" FontFamily="monospace" FontAttributes="Italic" />
<BoxView WidthRequest="1" HeightRequest="15" Color="#000090"/>
<Label Text="{Binding Message}" FontFamily="monospace" />
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage>
<ContentPage Title="Notifications" Icon="exclam.png" >
<StackLayout Padding="5, 5, 5, 5">
<ListView x:Name="notifList" HasUnevenRows="true" ItemsSource="{Binding Notifs}">
<ListView.ItemTemplate HeightRequest="80" VerticalOptions="StartAndExpand">
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Horizontal" VerticalOptions="StartAndExpand">
<Label Text="{Binding Date, StringFormat='{0:hh:mm}'}" FontAttributes="Italic" />
<Label Text="{Binding SenderId}" FontFamily="monospace" FontAttributes="Italic" />
<BoxView Color="#000090" WidthRequest="1" HeightRequest="15" />
<Label Text="{Binding Message}" FontFamily="monospace" />
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage>
<ContentPage Title="Contacts" Icon="peer_to_peer.png" >
<StackLayout Padding="5, 5, 5, 5">
<StackLayout Spacing = "12"
Orientation = "Horizontal">
</StackLayout>
<views:UserListView x:Name="chatUserList" />
<StackLayout BindingContext="{x:Reference Name=chatUserList}" IsVisible="{Binding HasASelection}">
<ListView x:Name="pvList" HasUnevenRows="true" ItemsSource="{Binding SelectedUser.PrivateMessages}" BindingContext="{x:Reference Name=chatUserList}">
<ListView.ItemTemplate HeightRequest="80"
VerticalOptions="StartAndExpand">
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Horizontal" VerticalOptions="StartAndExpand">
<Label Text="{Binding Date, StringFormat='{0:hh:mm}'}" FontAttributes="Italic" />
<Label Text="{Binding SenderId}" FontFamily="monospace" FontAttributes="Italic" />
<BoxView Color="#000090" WidthRequest="1" HeightRequest="15" />
<Label Text="{Binding Message}" FontFamily="monospace" />
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Entry x:Name="pvEntry" Placeholder = "enter your private message"
VerticalOptions = "Center" HorizontalOptions = "FillAndExpand"></Entry>
<Button x:Name="sendPVButton" Text = "Send" HorizontalOptions = "End"
VerticalOptions = "Center"></Button>
</StackLayout>
</StackLayout>
</ContentPage>
</TabbedPage.Children>
</TabbedPage>

View file

@ -0,0 +1,91 @@
using System;
using System.Diagnostics;
using Microsoft.AspNet.SignalR.Client;
using Xamarin.Forms;
namespace BookAStar.Pages.Chat
{
using Data;
using System.Linq;
using ViewModels.Messaging;
public partial class ChatPage : TabbedPage
{
public string ChatUser { get; set; }
public ChatPage(ChatViewModel model)
{
Init();
BindingContext = model;
}
public ChatPage()
{
Init();
}
private void Init()
{
InitializeComponent();
Title = "Chat";
/*
ToolbarItems.Add(new ToolbarItem(
name: "...",
icon: null,
activated: () => { })); */
App.ChatHubConnection.StateChanged += ChatHubConnection_StateChanged;
sendButton.Clicked += async (sender, args) =>
{
IsBusy = true;
try
{
ConnectionState cs = App.ChatHubConnection.State;
await App.ChatHubProxy.Invoke<string>("Send", ChatUser, messageEntry.Text);
messageEntry.Text = null;
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
IsBusy = false;
};
chatUserList.BindingContext = DataManager.Instance.ChatUsers;
sendPVButton.Clicked += (sender, args) =>
{
var dest = chatUserList.SelectedUser;
if (dest!=null)
{
IsBusy = true;
try
{
foreach (var cx in dest.ObservableConnections)
{
if (cx.Connected)
App.ChatHubProxy.Invoke<string>("SendPV", cx.ConnectionId, pvEntry.Text);
}
pvEntry.Text = null;
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
IsBusy = false;
}
};
}
private void ChatHubConnection_StateChanged(StateChange obj)
{
Xamarin.Forms.Device.BeginInvokeOnMainThread(
() => {
sendButton.IsEnabled = obj.NewState == ConnectionState.Connected;
});
}
}
}

View file

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BookAStar.Pages.ClientPages.SearchPage"
xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar"
xmlns:controls="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"
xmlns:toolkit="clr-namespace:XLabs.Forms.Mvvm;assembly=XLabs.Forms"
xmlns:converters="clr-namespace:BookAStar.Converters;assembly=BookAStar"
xmlns:local="clr-namespace:BookAStar;Assembly:BookAStar"
xmlns:extensions="clr-namespace:BookAStar.Extensions;assembly=BookAStar"
Style="{StaticResource PageStyle}" >
<TabbedPage.Children>
<ContentPage Title="Une star" Icon="">
<StackLayout Orientation="Horizontal">
<Editor x:Name="search_phrase" HorizontalOptions="FillAndExpand"/>
<Button x:Name="btn_update" HorizontalOptions="End" />
</StackLayout>
<DatePicker x:Name="search_date" />
</ContentPage>
</TabbedPage.Children>
<TabbedPage.Children>
<ContentPage Title="Un DJ" Icon="">
<StackLayout Orientation="Horizontal">
<Editor x:Name="search_phrase" HorizontalOptions="FillAndExpand"/>
<Button x:Name="btn_update" HorizontalOptions="End" />
</StackLayout>
<DatePicker x:Name="search_date" />
</ContentPage>
</TabbedPage.Children>
<TabbedPage.Children>
<ContentPage Title="Un chanteur" Icon="">
<StackLayout Orientation="Horizontal">
<Editor x:Name="search_phrase" HorizontalOptions="FillAndExpand"/>
<Button x:Name="btn_update" HorizontalOptions="End" />
</StackLayout>
<DatePicker x:Name="search_date" />
</ContentPage>
</TabbedPage.Children>
<TabbedPage.Children>
<ContentPage Title="Une formation musicale" Icon="">
<StackLayout Orientation="Horizontal">
<Editor x:Name="search_phrase" HorizontalOptions="FillAndExpand"/>
<Button x:Name="btn_update" HorizontalOptions="End" />
</StackLayout>
<DatePicker x:Name="search_date" />
</ContentPage>
</TabbedPage.Children>
</TabbedPage>

View file

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

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:signature="clr-namespace:SignaturePad.Forms;assembly=SignaturePad.Forms"
xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar"
x:Class="BookAStar.ViewModels.Signing.Signing"
Style="{StaticResource PageStyle}">
<StackLayout>
<views:MarkdownView x:Name="mdView"
Editable="False"
HorizontalOptions="FillAndExpand"
Markdown="{Binding Document}"
VerticalOptions="Start" />
<signature:SignaturePadView x:Name="padView"
HeightRequest="150" WidthRequest="240"
BackgroundColor="White"
CaptionText="Caption This" CaptionTextColor="Black"
ClearText="Clear Me!" ClearTextColor="Red"
PromptText="Prompt Here" PromptTextColor="Red"
SignatureLineColor="Aqua" StrokeColor="Black" StrokeWidth="2" />
<Button Clicked="OnGetStats" Text="Get Signature Stats" />
</StackLayout>
</ContentPage>

View file

@ -0,0 +1,59 @@
using SignaturePad.Forms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace BookAStar.ViewModels.Signing
{
public partial class Signing : ContentPage
{
public Signing()
{
InitializeComponent();
}
private async void OnGetStats(object sender, EventArgs e)
{
var points = padView.Points.ToArray();
var image = await padView.GetImageStreamAsync(SignatureImageFormat.Png);
var pointCount = points.Count();
var imageSize = image.Length / 1000;
var linesCount = points.Count(p => p == Point.Zero) + (points.Length > 0 ? 1 : 0);
image.Dispose();
await DisplayAlert("Stats", $"The signature has {linesCount} lines or {pointCount} points, and is {imageSize:#,###.0}KB (in memory) when saved as a PNG.", "Cool");
}
private async void OnChangeTheme(object sender, EventArgs e)
{
var action = await DisplayActionSheet("Change Theme", "Cancel", null, "White", "Black", "Aqua");
switch (action)
{
case "White":
padView.BackgroundColor = Color.White;
padView.StrokeColor = Color.Black;
padView.ClearTextColor = Color.Black;
padView.ClearText = "Clear Markers";
break;
case "Black":
padView.BackgroundColor = Color.Black;
padView.StrokeColor = Color.White;
padView.ClearTextColor = Color.White;
padView.ClearText = "Clear Chalk";
break;
case "Aqua":
padView.BackgroundColor = Color.Aqua;
padView.StrokeColor = Color.Red;
padView.ClearTextColor = Color.Black;
padView.ClearText = "Clear The Aqua";
break;
}
}
}
}

View file

@ -0,0 +1,15 @@

using BookAStar.Interfaces;
using System;
namespace BookAStar.Model.Workflow
{
public class BillingLine : IBillingLine
{
public long Id { get; set; }
public string Description { get; set; }
public TimeSpan Duration { get; set; }
public int Count { get; set; } = 1;
public decimal UnitaryCost { get; set; }
}
}

View file

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage 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.Pages.BookQueriesPage"
Style="{StaticResource PageStyle}"
Page.Title="Les Demandes"
>
<ContentPage.Resources>
<ResourceDictionary>
<Style x:Key="labelStyle" TargetType="Label">
<Setter Property="TextColor" Value="{DynamicResource EmphasisTextColor}" />
<Setter Property="FontAttributes" Value="Bold" />
<Setter Property="FontSize" Value="{DynamicResource LargeFontSize}" />
<Setter Property="VerticalOptions" Value="Start" />
<Setter Property="LineBreakMode" Value="WordWrap" />
</Style>
<Style TargetType="Label">
<Setter Property="Style" Value="{StaticResource ContentLabelStyle}" />
</Style>
<Style TargetType="Button">
<Setter Property="Style" Value="{StaticResource ButtonStyle}" />
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<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"
SeparatorVisibility="Default" SeparatorColor="Black">
<ListView.ItemTemplate VerticalOptions="StartAndExpand">
<DataTemplate>
<ViewCell>
<ViewCell.View>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Grid.Row="0" Grid.Column="0" Grid.RowSpan="3" Source="{Binding Avatar}" />
<Label Grid.Row="3" Grid.Column="0" Grid.RowSpan="2" Text="{Binding Client.UserName}" Style="{StaticResource labelStyle}"></Label>
<Label Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" Grid.RowSpan="2" Text="{Binding Data.Reason}"></Label>
<Label Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" LineBreakMode="WordWrap" Text="{Binding EventDate, StringFormat='{0:dddd d MMMM à HH:mm}'}" FontFamily="Italic"/>
<Label Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" LineBreakMode="WordWrap" Text="{Binding Location.Address}"/>
<Label Grid.Row="4" Grid.Column="1" Text="{Binding Previsionnal}" />
<Label Grid.Row="4" Grid.Column="2" Text="{Binding Id}" />
</Grid>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ScrollView>
</ContentPage.Content>
</ContentPage>

View file

@ -0,0 +1,47 @@
using BookAStar.Model;
using BookAStar.ViewModels;
using Xamarin.Forms;
using XLabs.Ioc;
using XLabs.Platform.Services;
namespace BookAStar.Pages
{
using Data;
using ViewModels.EstimateAndBilling;
public partial class BookQueriesPage : ContentPage
{
public BookQueriesPage()
{
InitializeComponent();
BindingContext = new BookQueriesViewModel();
}
public BookQueriesPage(BookQueriesViewModel model)
{
InitializeComponent();
BindingContext = model;
}
protected override void OnBindingContextChanged()
{
BookQueriesViewModel model = (BookQueriesViewModel) BindingContext;
if (model!=null)
{
model.RefreshQueries =
new Command(() =>
{
DataManager.Instance.BookQueries.Execute(null);
this.list.EndRefresh();
});
}
base.OnBindingContextChanged();
}
private void OnViewDetail(object sender, ItemTappedEventArgs e)
{
var item = e.Item as BookQueryViewModel;
App.NavigationService.NavigateTo<BookQueryPage>(true,item);
}
}
}

View file

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:BookAStar;assembly=BookAStar"
xmlns:maps="clr-namespace:Xamarin.Forms.Maps;assembly=Xamarin.Forms.Maps.dll"
x:Class="BookAStar.Pages.BookQueryPage"
Style ="{StaticResource PageStyle}"
>
<ContentPage.Resources>
<ResourceDictionary>
<Style TargetType="Label">
<Setter Property="Style" Value="{StaticResource ContentLabelStyle}" />
</Style>
<Style TargetType="Button">
<Setter Property="Style" Value="{StaticResource ButtonStyle}" />
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<StackLayout x:Name="bookQueryLayout">
<StackLayout Orientation="Vertical">
<Image Source="{Binding Avatar}" 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 Data.Reason}" />
<Label Text="{Binding Location.Address}" />
<Label Text="{Binding Previsional}" />
</StackLayout>
<StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" >
<maps:Map x:Name="map" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"></maps:Map>
<StackLayout Orientation="Horizontal">
<StackLayout Orientation="Vertical">
<Button Text="{Binding EditEstimateButtonText}" Clicked="OnEditEstimate" />
<Button Text="{x:Static local:Strings.DeclineQuery}" Clicked="OnDropQuery" />
</StackLayout>
<StackLayout Orientation="Vertical">
<Button Text="{x:Static local:Strings.BlockThisUser}" Clicked="OnBlockThisUser" />
<Button Text="{x:Static local:Strings.ViewEstimate}"
BorderRadius="50" BorderWidth="2" BorderColor="Aqua" x:Name ="btn"
VisualElement.IsVisible="{Binding EstimationDone}"
Clicked="OnViewEstimate" Image="exclam.png" />
</StackLayout>
</StackLayout>
</StackLayout>
</StackLayout>
</ContentPage>

View file

@ -0,0 +1,135 @@
using System;
using System.Linq;
using Xamarin.Forms;
using Xamarin.Forms.Maps;
namespace BookAStar.Pages
{
using Data;
using EstimatePages;
using Model.Social;
using Model.Workflow;
using ViewModels.EstimateAndBilling;
public partial class BookQueryPage : ContentPage
{
public BookQuery BookQuery
{
get
{
return (BindingContext as BookQueryViewModel).Data;
}
}
protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();
map.Pins.Clear();
if (BookQuery != null)
{
var lat = BookQuery.Location.Latitude;
var lon = BookQuery.Location.Longitude;
var pin = new Pin
{
Type = PinType.SavedPin,
Position = new Xamarin.Forms.Maps.Position
(lat, lon),
Label = BookQuery.Client.UserName,
Address = BookQuery.Location.Address
};
map.Pins.Add(pin);
map.MoveToRegion(MapSpan.FromCenterAndRadius(
new Xamarin.Forms.Maps.Position(lat, lon), Distance.FromMeters(100)));
}
}
public BookQueryPage()
{
InitializeComponent();
}
public BookQueryPage(BookQueryViewModel bookQuery =null)
{
InitializeComponent();
// when TODO update?
// Task.Run( async () => { bookQuery = await App.CurrentApp.DataManager.BookQueries.Get(bookQueryId); });
BindingContext = bookQuery;
}
private void OnEditEstimate(object sender, EventArgs ev)
{
var bookQueryViewModel = (BookQueryViewModel) BindingContext;
var editEstimateViewModel = bookQueryViewModel.DraftEstimate;
if (editEstimateViewModel == null)
{
// First search for an existing estimate
editEstimateViewModel = DataManager.Instance.EstimationCache.FirstOrDefault(
estimate=> estimate.Query.Id == bookQueryViewModel.Id
);
if (editEstimateViewModel == null)
{
DataManager.Instance.Contacts.Merge(BookQuery.Client);
DataManager.Instance.Contacts.SaveEntity();
editEstimateViewModel = new EditEstimateViewModel( new Estimate
{
ClientId = BookQuery.Client.UserId,
CommandId = BookQuery.Id,
OwnerId = MainSettings.CurrentUser.Id,
Id = 0
});
DataManager.Instance.EstimationCache.Add(editEstimateViewModel);
}
}
App.NavigationService.NavigateTo<EditEstimatePage>(true,
editEstimateViewModel);
}
private async void OnViewEstimate(object sender, EventArgs ev)
{
var bookQueryViewModel = (BookQueryViewModel) BindingContext;
var buttons = bookQueryViewModel.Estimates.Select(e => $"{e.Id} / {e.Title} / {e.Total}").ToArray();
var action = await App.DisplayActionSheet("Estimations validées", "Annuler", null, buttons);
if (buttons.Contains(action))
{
var index = Array.IndexOf(buttons,action);
var estimate = bookQueryViewModel.Estimates[index];
App.NavigationService.NavigateTo<ViewEstimatePage>(true,
new EditEstimateViewModel(estimate));
}
}
protected override void OnSizeAllocated(double width, double height)
{
if (width > height)
{
bookQueryLayout.Orientation = StackOrientation.Horizontal;
}
else
{
bookQueryLayout.Orientation = StackOrientation.Vertical;
}
base.OnSizeAllocated(width, height);
}
private void OnBlockThisUser(object sender, EventArgs ev)
{
var bookQueryViewModel = (BookQueryViewModel)BindingContext;
DataManager.Instance.BlackList.Add(
new Model.Access.BlackListed
{
OwnerId = MainSettings.CurrentUser.Id,
UserId = bookQueryViewModel.Data.Client.UserId
});
DataManager.Instance.BlackList.SaveEntity();
}
private void OnDropQuery(object sender, EventArgs ev)
{
var bookQueryViewModel = (BookQueryViewModel)BindingContext;
bookQueryViewModel.Rejected = true;
DataManager.Instance.EstimationCache.SaveEntity();
}
}
}

View file

@ -0,0 +1,121 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:BookAStar;assembly=BookAStar"
xmlns:converters="clr-namespace:BookAStar.Converters;assembly=BookAStar"
xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar"
xmlns:behaviors="clr-namespace:BookAStar.Behaviors;assembly=BookAStar"
xmlns:extensions="clr-namespace:BookAStar.Extensions;assembly=BookAStar"
x:Class="BookAStar.Pages.EditBillingLinePage"
Style="{StaticResource PageStyle}">
<ContentPage.Resources>
<ResourceDictionary>
<Style TargetType="Label">
<Setter Property="Style" Value="{StaticResource ContentLabelStyle}" />
</Style>
<Style TargetType="Button">
<Setter Property="Style" Value="{StaticResource ButtonStyle}" />
</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"
Value="{extensions:ImageResource BookAStar.Images.Validation.error.png}" />
</Style>
</converters:BooleanToObjectConverter.FalseObject>
<converters:BooleanToObjectConverter.TrueObject>
<Style TargetType="Image">
<Setter Property="HeightRequest" Value="20" />
<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 HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Text="{Binding Description, Mode=TwoWay}">
<Editor.Behaviors>
<behaviors:EditorMaxLengthValidator x:Name="descriptionLenValidator" MaxLength="12" MinLength="3" />
</Editor.Behaviors>
</Editor>
<StackLayout Orientation="Horizontal">
<Image x:Name="descriptionSuccessErrorImage"
Style="{Binding Source={x:Reference descriptionLenValidator}, Path=IsValid, Converter={StaticResource boolToStyleImage}}" />
<Label Text="{Binding Source={x:Reference descriptionLenValidator}, Path=Error}"
Style="{StaticResource ErrorLabelStyle}"></Label>
</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>
<Label Text="Quantité facturée" Style="{StaticResource InputLabelStyle}"></Label>
<Entry Text="{Binding Count, Mode=TwoWay}" Placeholder="Quantité" Keyboard="Numeric"
Style="{StaticResource BigEntry}">
<Entry.Behaviors>
<behaviors:IntegerEntryBehavior x:Name="countValidator" Min="0" Max="10" />
</Entry.Behaviors>
</Entry>
<StackLayout Orientation="Horizontal">
<Image x:Name="countSuccessErrorImage"
Style="{Binding Source={x:Reference countValidator},
Path=IsValid,
Converter={StaticResource boolToStyleImage}}" />
<Label Text="{Binding Source={x:Reference countValidator}, Path=Error}"
Style="{StaticResource ErrorLabelStyle}"></Label>
</StackLayout>
<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 BigLabelStyle}" />
<Image x:Name="unitaryCostSuccessErrorImage"
Style="{Binding Source={x:Reference unitCostValidator},
Path=IsValid,
Converter={StaticResource boolToStyleImage}}" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Button Text="Términé"
Command="{Binding ValidateCommand}"
Clicked="OnValidateClicked"></Button>
<Button Text="Supprimer"
Command="{Binding RemoveCommand}"
Clicked="OnDeleteClicked"></Button>
</StackLayout>
</StackLayout>
</ScrollView>
</ContentPage>

View file

@ -0,0 +1,38 @@
using BookAStar.Data;
using BookAStar.ViewModels;
using BookAStar.ViewModels.EstimateAndBilling;
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace BookAStar.Pages
{
public partial class EditBillingLinePage : ContentPage
{
public EditBillingLinePage(BillingLineViewModel model)
{
InitializeComponent();
foreach
(string du in Enum.GetNames(typeof(BillingLineViewModel.DurationUnits)))
picker.Items.Add(du);
BindingContext = model;
}
public void OnDeleteClicked(object sender, EventArgs e)
{
this.Navigation.PopAsync();
}
public void OnValidateClicked (object sender, EventArgs e)
{
this.Navigation.PopAsync();
}
protected override bool OnBackButtonPressed()
{
var bvm = (BillingLineViewModel)BindingContext;
bvm.ValidateCommand?.Execute(null);
return base.OnBackButtonPressed();
}
}
}

View file

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BookAStar.Pages.EditEstimatePage"
xmlns:converters="clr-namespace:BookAStar.Converters;assembly=BookAStar"
xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar"
xmlns:local="clr-namespace:BookAStar;assembly=BookAStar"
xmlns:behaviors="clr-namespace:BookAStar.Behaviors;assembly=BookAStar"
xmlns:extensions="clr-namespace:BookAStar.Extensions;assembly=BookAStar"
Style="{StaticResource PageStyle}">
<ContentPage.Resources>
<ResourceDictionary>
<Style TargetType="Label">
<Setter Property="Style" Value="{StaticResource ContentLabelStyle}" />
</Style>
<Style TargetType="Button">
<Setter Property="Style" Value="{StaticResource ButtonStyle}" />
</Style>
<converters:BooleanToObjectConverter x:Key="boolToStyleImage" x:TypeArguments="Style">
<converters:BooleanToObjectConverter.FalseObject>
<Style TargetType="Image">
<Setter Property="HeightRequest" Value="20" />
<Setter Property="Source"
Value="{extensions:ImageResource BookAStar.Images.Validation.error.png}" />
</Style>
</converters:BooleanToObjectConverter.FalseObject>
<converters:BooleanToObjectConverter.TrueObject>
<Style TargetType="Image">
<Setter Property="HeightRequest" Value="20" />
<Setter Property="Source"
Value="{extensions:ImageResource BookAStar.Images.Validation.success.png}" />
</Style>
</converters:BooleanToObjectConverter.TrueObject>
</converters:BooleanToObjectConverter>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<StackLayout Padding="10,10,10,10" x:Name="mainLayout">
<Grid HeightRequest="120">
<Grid.RowDefinitions>
<RowDefinition Height="2*" />
</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>
<Entry Placeholder="Saisissez un titre pour ce devis" Text="{Binding Title, Mode=TwoWay}" />
<views:MarkdownView x:Name="mdview"
Editable="True"
Markdown="{Binding Description, Mode=TwoWay}">
<views:MarkdownView.Behaviors>
<behaviors:MarkdownViewLengthValidator x:Name="descriptionLenValidator" MaxLength="512" MinLength="3" />
</views:MarkdownView.Behaviors>
</views:MarkdownView>
<StackLayout x:Name="biAnVaLayout">
<ListView x:Name="BillListView" ItemsSource="{Binding Bill}"
HasUnevenRows="true" ItemTapped="OnEditLine">
<ListView.ItemTemplate>
<DataTemplate >
<ViewCell>
<ViewCell.View Padding="5,5,5,5" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="30" />
<ColumnDefinition Width="90" />
<ColumnDefinition Width="16" />
</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>
<Image Grid.Row="0" Grid.Column="4" Style="{Binding
Path=ViewModelState.IsValid,
Converter={StaticResource boolToStyleImage}}" ></Image>
</Grid>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<StackLayout Orientation="Vertical">
<Button Text="Ajouter une ligne de facture" Clicked="OnNewCommanLine"></Button>
<Label FormattedText="{Binding FormattedTotal}"/>
<Button x:Name="btnValidate" Text="Valider ce devis" Clicked="OnEstimateValidated" IsEnabled="{Binding ViewModelState.IsValid}" ></Button>
</StackLayout>
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View file

@ -0,0 +1,128 @@
using System;
using Xamarin.Forms;
namespace BookAStar.Pages
{
using Data;
using EstimatePages;
using Model.Workflow;
using ViewModels.EstimateAndBilling;
using ViewModels.Signing;
public partial class EditEstimatePage : ContentPage
{
public EditEstimateViewModel Model
{
get
{
return (EditEstimateViewModel)BindingContext;
}
}
public EditEstimatePage(EditEstimateViewModel model)
{
BindingContext = model;
Model.CheckCommand = new Action<Estimate, ViewModels.Validation.ModelState>(
(e, m) =>
{
foreach (var line in model.Bill)
{
line.Check();
if (!line.ViewModelState.IsValid)
model.ViewModelState.AddError("Bill", "invalid line");
}
});
InitializeComponent();
Model.Check();
}
protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();
((EditEstimateViewModel)BindingContext).PropertyChanged += EditEstimatePage_PropertyChanged;
}
private void EditEstimatePage_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
DataManager.Instance.EstimationCache.SaveEntity();
}
protected override void OnSizeAllocated(double width, double height)
{
if (width > height)
{
biAnVaLayout.Orientation = StackOrientation.Horizontal;
}
else
{
biAnVaLayout.Orientation = StackOrientation.Vertical;
}
base.OnSizeAllocated(width, height);
}
protected void OnNewCommanLine(object sender, EventArgs e)
{
var com = new BillingLine() { Count = 1, UnitaryCost = 0.01m };
var bill = ((EditEstimateViewModel)BindingContext).Bill;
var lineView = new BillingLineViewModel(com)
{ ValidateCommand = new Command(() => {
bill.Add(new BillingLineViewModel(com));
DataManager.Instance.EstimationCache.SaveEntity();
})};
App.NavigationService.NavigateTo<EditBillingLinePage>(
true, lineView );
}
protected void OnEditLine(object sender, ItemTappedEventArgs e)
{
var line = (BillingLineViewModel)e.Item;
var evm = ((EditEstimateViewModel)BindingContext);
// update the validation command, that
// was creating a new line in the bill at creation time,
// now one only wants to update the line
line.ValidateCommand = new Command(() =>
{
evm.Check();
DataManager.Instance.EstimationCache.SaveEntity();
});
// and setup a removal command, that was not expected at creation time
line.RemoveCommand = new Command(() =>
{
evm.Bill.Remove(line);
evm.Check();
DataManager.Instance.EstimationCache.SaveEntity();
});
App.NavigationService.NavigateTo<EditBillingLinePage>(
true, line );
BillListView.SelectedItem = null;
}
protected async void OnEstimateValidated(object sender, EventArgs e)
{
var thisPage = this;
var evm = (EditEstimateViewModel) BindingContext;
var cmd = new Command<bool>( async (validated) =>
{
if (validated) {
DataManager.Instance.EstimationCache.Remove(evm);
DataManager.Instance.EstimationCache.SaveEntity();
}
await thisPage.Navigation.PopAsync();
});
var response = await App.DisplayActionSheet(
Strings.SignOrNot, Strings.DonotsignEstimate,
Strings.CancelValidation, new string[] { Strings.Sign });
if (response == Strings.Sign)
{
App.NavigationService.NavigateTo<EstimateSigningPage>(true,
new EstimateSigningViewModel(evm.Data) { ValidationCommand = cmd,
IsProviderView = true });
}
else if (response == Strings.CancelValidation)
return;
else cmd.Execute(true);
}
}
}

View file

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:signature="clr-namespace:SignaturePad.Forms;assembly=SignaturePad.Forms"
xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar"
x:Class="BookAStar.Pages.EstimatePages.EstimateSigningPage">
<ContentPage.Resources>
<ResourceDictionary>
<Style TargetType="Label">
<Setter Property="Style" Value="{StaticResource ContentLabelStyle}" />
</Style>
<Style TargetType="Button">
<Setter Property="Style" Value="{StaticResource ButtonStyle}" />
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<StackLayout Padding="10,10,10,10" x:Name="mainLayout">
<ScrollView>
<StackLayout>
<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>
<Label Text="{Binding Title}" Style="{StaticResource BigLabelStyle}" />
<views:MarkdownView x:Name="mdview"
HorizontalOptions="FillAndExpand"
Markdown="{Binding Description}"
/>
<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>
<Label FormattedText="{Binding FormattedTotal}"/>
<StackLayout Orientation="Horizontal">
<Image Source="{Binding ProSignImage}" HorizontalOptions="Start"></Image>
<Image Source="{Binding CliSignImage}" HorizontalOptions="End"></Image>
</StackLayout>
</StackLayout>
</ScrollView>
<signature:SignaturePadView x:Name="padView"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"
BackgroundColor="White"
CaptionText="{Binding Data.Owner?.UserName}" CaptionTextColor="Black"
ClearText="Effacer!" ClearTextColor="Red"
PromptText="Prompt Here" PromptTextColor="Red"
SignatureLineColor="Aqua" StrokeColor="Black" StrokeWidth="2" />
<Button Clicked="OnValidate" Text="Valider cette signature" x:Name="btnValidate" />
</StackLayout>
</ContentPage.Content>
</ContentPage>

View file

@ -0,0 +1,91 @@
using SignaturePad.Forms;
using System;
using System.IO;
using System.Linq;
using Xamarin.Forms;
namespace BookAStar.Pages.EstimatePages
{
using Data;
using ViewModels.EstimateAndBilling;
using ViewModels.Signing;
public partial class EstimateSigningPage : ContentPage
{
public EstimateSigningPage(EstimateSigningViewModel model)
{
InitializeComponent();
BindingContext = model;
}
private async void OnValidate(object sender, EventArgs ev)
{
btnValidate.IsEnabled = false;
if (DataManager.Instance.Estimates.IsExecuting)
{
await App.DisplayAlert(Strings.OperationPending, Strings.oups);
return;
}
IsBusy = true;
var evm = (EditEstimateViewModel)BindingContext;
var estimate = evm.Data;
using (var stream = await padView.GetImageStreamAsync(SignatureImageFormat.Png))
{
/*
var signatureMemoryStream = pngStream as MemoryStream;
if (signatureMemoryStream == null)
{
signatureMemoryStream = new MemoryStream();
pngStream.CopyTo(signatureMemoryStream);
}
var byteArray = signatureMemoryStream.ToArray();
var base64String = Convert.ToBase64String(byteArray)
*/
stream.Seek(0, SeekOrigin.Begin);
DataManager.Instance.Estimates.SignAsProvider(estimate, stream);
DataManager.Instance.Estimates.SaveEntity();
}
IsBusy = false;
var ParentValidationCommand = ((EstimateSigningViewModel)BindingContext).ValidationCommand;
if (ParentValidationCommand != null)
ParentValidationCommand.Execute(true);
await Navigation.PopAsync();
}
private async void OnChangeTheme(object sender, EventArgs e)
{
var action = await DisplayActionSheet("Change Theme", "Cancel", null, "White", "Black", "Aqua");
switch (action)
{
case "White":
padView.BackgroundColor = Color.White;
padView.StrokeColor = Color.Black;
padView.ClearTextColor = Color.Black;
padView.ClearText = "Clear Markers";
break;
case "Black":
padView.BackgroundColor = Color.Black;
padView.StrokeColor = Color.White;
padView.ClearTextColor = Color.White;
padView.ClearText = "Clear Chalk";
break;
case "Aqua":
padView.BackgroundColor = Color.Aqua;
padView.StrokeColor = Color.Red;
padView.ClearTextColor = Color.Black;
padView.ClearText = "Clear The Aqua";
break;
}
}
}
}

View file

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BookAStar.Pages.EstimatesClientPage"
Style="{StaticResource PageStyle}">
<ScrollView>
<StackLayout Padding="10,10,10,10" x:Name="mainLayout">
<ListView RefreshCommand="{Binding RefreshCommand}" IsPullToRefreshEnabled="True"
ItemsSource="{Binding Estimates}" x:Name="estimates" ItemTapped="OnViewDetail" HasUnevenRows="true" RowHeight="80">
<ListView.ItemTemplate HeightRequest="80" VerticalOptions="StartAndExpand">
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Horizontal" Padding="10,10,10,10" VerticalOptions="StartAndExpand">
<StackLayout Orientation="Vertical"
HeightRequest="80" VerticalOptions="StartAndExpand">
<StackLayout Orientation="Vertical" >
<Image Source="{Binding Owner.Avatar}" />
<Label Text="{Binding Client.UserName}"
Style="{StaticResource labelStyle}"></Label>
</StackLayout>
<Label LineBreakMode="WordWrap" Text="{Binding EventDate, StringFormat='{0:dddd d MMMM à HH:mm}'}" FontSize="12" FontFamily="Italic"/>
</StackLayout>
<StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand">
<Label LineBreakMode="WordWrap" Text="{Binding Location.Address}"/>
<Label Text="{Binding Previsionnal}"/>
<Label Text="{Binding Id}" HorizontalTextAlignment="End"/>
</StackLayout>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ScrollView>
</ContentPage>

View file

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

View file

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BookAStar.Pages.EstimatesProviderPage"
Style="{StaticResource PageStyle}">
<ScrollView>
<StackLayout Padding="10,10,10,10" x:Name="mainLayout">
<ListView RefreshCommand="{Binding RefreshCommand}" IsPullToRefreshEnabled="True"
ItemsSource="{Binding Estimates}" x:Name="estimates" ItemTapped="OnViewDetail" HasUnevenRows="true" RowHeight="80">
<ListView.ItemTemplate HeightRequest="80" VerticalOptions="StartAndExpand">
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Horizontal" Padding="10,10,10,10" VerticalOptions="StartAndExpand">
<StackLayout Orientation="Vertical"
HeightRequest="80" VerticalOptions="StartAndExpand">
<StackLayout Orientation="Vertical" >
<Image Source="{Binding Client.Avatar}" />
<Label Text="{Binding Client.UserName}"
Style="{StaticResource labelStyle}"></Label>
</StackLayout>
<Label LineBreakMode="WordWrap" Text="{Binding EventDate, StringFormat='{0:dddd d MMMM à HH:mm}'}" FontSize="12" FontFamily="Italic"/>
</StackLayout>
<StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand">
<Label LineBreakMode="WordWrap" Text="{Binding Location.Address}"/>
<Label Text="{Binding Previsionnal}"/>
<Label Text="{Binding Id}" HorizontalTextAlignment="End"/>
</StackLayout>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ScrollView>
</ContentPage>

View file

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace BookAStar.Pages
{
using Model.Workflow;
using ViewModels.EstimateAndBilling;
public partial class EstimatesProviderPage : ContentPage
{
public EstimatesProviderPage()
{
InitializeComponent();
}
private void OnViewDetail(object sender, ItemTappedEventArgs e)
{
Estimate data = e.Item as Estimate;
App.NavigationService.NavigateTo<EditEstimatePage>(
true,
new EditEstimateViewModel(data));
}
}
}

View file

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BookAStar.Pages.EstimatePages.ViewEstimatePage"
xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar"
xmlns:local="clr-namespace:BookAStar;assembly=BookAStar"
Style="{StaticResource PageStyle}">
<ContentPage.Resources>
<ResourceDictionary>
<Style TargetType="Label">
<Setter Property="Style" Value="{StaticResource ContentLabelStyle}" />
</Style>
<Style TargetType="Button">
<Setter Property="Style" Value="{StaticResource ButtonStyle}" />
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<ScrollView>
<StackLayout Padding="10,10,10,10" x:Name="mainLayout">
<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>
<Label Text="{Binding Title}" />
<views:MarkdownView x:Name="mdview"
HorizontalOptions="FillAndExpand"
Markdown="{Binding Description}"
/>
<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>
<Label FormattedText="{Binding FormattedTotal}"/>
</StackLayout>
</ScrollView>
</ContentPage.Content>
</ContentPage>

View file

@ -0,0 +1,25 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace BookAStar.Pages.EstimatePages
{
using ViewModels.EstimateAndBilling;
public partial class ViewEstimatePage : ContentPage
{
public ViewEstimatePage(EditEstimateViewModel model)
{
InitializeComponent();
billListView.ItemSelected += (sender, e) => {
((ListView)sender).SelectedItem = null;
};
BindingContext = model;
}
}
}

View file

@ -0,0 +1,103 @@
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage 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.Pages.HomePage"
Style="{StaticResource PageStyle}"
Title="Accueil">
<ContentPage.Resources>
<ResourceDictionary>
<Style TargetType="Label">
<Setter Property="Style" Value="{StaticResource ContentLabelStyle}" />
</Style>
<Style TargetType="Button">
<Setter Property="Style" Value="{StaticResource ButtonStyle}" />
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<TabbedPage.Children>
<!-- La recherche d'un pro -->
<TabbedPage Title="{x:Static local:Strings.SearchForAPro}" >
</TabbedPage>
<!--
les derniers sons/videos/articles postés
-->
<ContentPage Title="Blogspot">
<StackLayout Orientation="Horizontal">
<Editor x:Name="search_blog_phrase" HorizontalOptions="FillAndExpand"/>
<Button x:Name="btn_blog_update" HorizontalOptions="End" />
</StackLayout>
</ContentPage>
<!--
Les demandes devis en attente de réponse (pro)
-->
<ContentPage Title="Demandes de devis"
IsVisible="{Binding UserProfile.IsAPerformer}">
<StackLayout BindingContext="{Binding BookQueries}">
<ListView x:Name="querylist"
RefreshCommand="{Binding RefreshQueries}"
IsPullToRefreshEnabled="True"
ItemsSource="{Binding Queries}"
ItemTapped="OnViewBookQueryDetail"
HasUnevenRows="true"
SeparatorVisibility="Default"
SeparatorColor="Black">
<ListView.ItemTemplate VerticalOptions="StartAndExpand" >
<DataTemplate>
<ViewCell>
<ViewCell.View>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Grid.Row="0" Grid.Column="0" Grid.RowSpan="4" Source="{Binding Avatar}" />
<Label Grid.Row="0" Grid.Column="1" Text="{Binding Client.UserName}" Style="{StaticResource LabelStyle}"></Label>
<Label Grid.Row="1" Grid.Column="1" Text="{Binding Data.Reason}"></Label>
<Label Grid.Row="2" Grid.Column="1" LineBreakMode="WordWrap" Text="{Binding EventDate, StringFormat='{0:dddd d MMMM à HH:mm}'}" FontFamily="Italic"/>
<Label Grid.Row="3" Grid.Column="1" LineBreakMode="WordWrap" Text="{Binding Location.Address}" />
</Grid>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage>
<!-- Les signatures de contrat en souffreances (pro) -->
<ContentPage Title="Contrats fournisseur" IsVisible="{Binding UserProfile.IsAPerformer}">
</ContentPage>
<!-- Les signatures de contrat en souffreances (client) -->
<ContentPage Title="Contrats client" IsVisible="{Binding UserProfile.IsAPerformer}">
</ContentPage>
<!-- Les annonces pro (pro) -->
<ContentPage Title="Annonces pro" IsVisible="{Binding UserProfile.IsAPerformer}">
<StackLayout Orientation="Horizontal" >
<Editor x:Name="search_pub_pro_phrase" HorizontalOptions="FillAndExpand" VerticalOptions="Start"/>
<Button x:Name="btn_pro_pub" HorizontalOptions="End" VerticalOptions="Start" Text="Chercher"/>
</StackLayout>
</ContentPage>
<!-- les petites annonces des clients (pro) -->
<ContentPage Title="Annonces client" Icon="" IsVisible="{Binding UserProfile.IsAPerformer}">
<StackLayout Orientation="Horizontal" >
<Editor x:Name="search_pub_cli_phrase" HorizontalOptions="FillAndExpand" VerticalOptions="Start"/>
<Button x:Name="btn_cli_pub" HorizontalOptions="End" VerticalOptions="Start" Text="Chercher"/>
</StackLayout>
</ContentPage>
</TabbedPage.Children>
</TabbedPage>

View file

@ -0,0 +1,55 @@
using Xamarin.Forms;
namespace BookAStar.Pages
{
using Data;
using ViewModels;
using ViewModels.EstimateAndBilling;
public partial class HomePage
{
public HomePage()
{
InitializeComponent();
}
public HomePage(HomeViewModel model)
{
BindingContext = model;
}
public HomeViewModel Model {
get {
return (HomeViewModel) BindingContext;
}
set
{
BindingContext = value;
}
}
protected override void OnBindingContextChanged()
{
// this technique make this view model
// non-sharable between view or pages
if (Model != null)
{
// set the refresh command before using it
Model.BookQueries.RefreshQueries =
new Command(() =>
{
DataManager.Instance.BookQueries.Execute(null);
this.querylist.EndRefresh();
});
}
// Use the new refresh command
base.OnBindingContextChanged();
}
private void OnViewBookQueryDetail(object sender, ItemTappedEventArgs e)
{
var item = e.Item as BookQueryViewModel;
App.NavigationService.NavigateTo<BookQueryPage>(true, item);
}
}
}

View file

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage 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.Pages.EventDetail" Style="{StaticResource PageStyle}">
<ContentPage.Resources>
<ResourceDictionary>
<Style TargetType="Label">
<Setter Property="Style" Value="{StaticResource ContentLabelStyle}" />
</Style>
<Style TargetType="Button">
<Setter Property="Style" Value="{StaticResource ButtonStyle}" />
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<ScrollView>
<StackLayout>
<Label HorizontalOptions="Center" Text="{Binding EventType}" FontAttributes="Italic" FontSize="10"/>
<Image Source="{Binding ImgLocator}"/>
<Label Text="{Binding Title}" FontSize="20"/>
<Label FontSize="16" Text="{Binding Description}"/>
<StackLayout Orientation="Horizontal">
<Label FontAttributes="Italic" FontSize="10" Text="Lieu:" />
<Label Text="{Binding Location.Name}" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label FontAttributes="Italic" FontSize="10" Text="Date:" />
<Label Text="{Binding StartDate, StringFormat='{0:dddd dd MMMM yyyy}'}" /> <Label Text="{Binding StartDate, StringFormat='{0:H:mm}'}" />
</StackLayout>
<StackLayout Orientation="Horizontal" IsVisible="{Binding Promotted}">
<Label FontAttributes="Italic" FontSize="10" Text="Code promotion:"/>
<Label FontSize="15" TextColor="Yellow" BackgroundColor="#102030" Text="{Binding PromotionCode}"/>
</StackLayout>
<Button Text="{Binding EventWebPage, StringFormat='Sur le web:{0}'}" x:Name="btn_webpage" />
</StackLayout>
</ScrollView>
</ContentPage.Content>
</ContentPage>

View file

@ -0,0 +1,25 @@
using System;
using Xamarin.Forms;
namespace BookAStar
{
using Model.Workflow.Messaging;
namespace Pages
{
public partial class EventDetail : ContentPage
{
public EventDetail(YaEvent ev)
{
InitializeComponent();
BindingContext = ev;
btn_webpage.Clicked += (object sender, EventArgs e) =>
{
App.PlatformSpecificInstance.OpenWeb(ev.EventWebPage);
};
}
}
}
}

View file

@ -0,0 +1,127 @@
using BookAStar.Model.Social;
using System;
using Xamarin.Forms;
using Xamarin.Forms.Maps;
using Yavsc;
namespace BookAStar.Pages
{
public class PinPage : ContentPage
{
Map map;
/*
protected async Task<Geolocator.Plugin.Abstractions.Position> GetPos() {
var locator = CrossGeolocator.Current;
locator.DesiredAccuracy = 50;
return await locator.GetPositionAsync (timeout: 10000);
}
private Position _pos;
public Position MyPosition {
get {
return _pos;
}
}
public async Task UpdateMyPos()
{
var pos = await GetPos();
_pos = new Position(pos.Latitude,pos.Longitude);
}
*/
protected override void OnAppearing ()
{
base.OnAppearing ();
}
public PinPage ()
{
map = new Map {
IsShowingUser = true,
HeightRequest = 100,
WidthRequest = 960,
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand
};
double lat=0;
double lon=0;
int pc = 0;
foreach (LocalizedEvent ev in Manager.Events) {
var pin = new Pin {
Type = PinType.SearchResult,
Position = new Xamarin.Forms.Maps.Position(
ev.Location.Latitude, ev.Location.Longitude),
Label = ev.Title,
Address = ev.Location.Address
};
pin.BindingContext = ev;
map.Pins.Add (pin);
// TODO find a true solution
lat = (lat * pc + ev.Location.Latitude) / (pc + 1);
lon = (lon * pc + ev.Location.Longitude) / (pc + 1);
pc++;
}
// TODO build a MapSpan covering events
map.MoveToRegion(MapSpan.FromCenterAndRadius (
new Xamarin.Forms.Maps.Position(lat,lon), Distance.FromMeters(100)));
/*
// A "relocate" button : useless, since it yet exists
var reLocate = new Button { Text = "Re-centrer" };
reLocate.Clicked += async delegate {
await UpdateMyPos();
Debug.WriteLine("Position: {0} {1}",MyPosition.Longitude,MyPosition.Latitude);
map.MoveToRegion (MapSpan.FromCenterAndRadius (
MyPosition, Distance.FromMeters (100)));
};
var buttons = new StackLayout {
Orientation = StackOrientation.Horizontal,
Children = {
reLocate
}
};
*/
// create map style buttons
var street = new Button { Text = "Street" };
var hybrid = new Button { Text = "Hybrid" };
var satellite = new Button { Text = "Satellite" };
street.Clicked += HandleMapStyleClicked;
hybrid.Clicked += HandleMapStyleClicked;
satellite.Clicked += HandleMapStyleClicked;
var segments = new StackLayout { Spacing = 30,
HorizontalOptions = LayoutOptions.CenterAndExpand,
Orientation = StackOrientation.Horizontal,
Children = {street, hybrid, satellite}
};
// put the page together
Content = new StackLayout {
Spacing = 0,
Children = {
map,
segments
}};
}
void HandleMapStyleClicked (object sender, EventArgs e)
{
var b = sender as Button;
switch (b.Text) {
case "Street":
map.MapType = MapType.Street;
break;
case "Hybrid":
map.MapType = MapType.Hybrid;
break;
case "Satellite":
map.MapType = MapType.Satellite;
break;
}
}
}
}

View file

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:local="clr-namespace:BookAStar;assembly=BookAStar"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BookAStar.Pages.UserProfile.AccountChooserPage"
Title="{x:Static local:Strings.UserAccounts}"
Style="{StaticResource PageStyle}"
xmlns:lc="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"
xmlns:lb="clr-namespace:XLabs.Forms.Behaviors;assembly=XLabs.Forms">
<StackLayout>
<Label Text="Compte utilisateur" StyleClass="Header"/>
<ListView x:Name="AccountListView"
SeparatorVisibility="Default"
VerticalOptions="FillAndExpand"
ItemsSource="{x:Static local:MainSettings.AccountList}"
>
<ListView.Header>
<StackLayout Orientation="Horizontal">
<Button x:Name="AddAccountBtn" Text="Connection, ou création d'un compte" />
</StackLayout>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Padding="5"
ColumnSpacing="10"
RowSpacing="2" >
<Image Grid.Column="0" Source="{Binding AvatarSource}" HeightRequest="80" />
<Label Grid.Column="1" Text="{Binding UserName}" >
</Label>
<Label Grid.Column="2" Text="{Binding EMails.ToString()}" />
<Label Grid.Column="3" Text="{Binding Roles.ToString()}" />
<Label Grid.Column="4" Text="{Binding Address}" />
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.Footer>
<StackLayout></StackLayout>
</ListView.Footer>
</ListView>
</StackLayout>
</ContentPage>

View file

@ -0,0 +1,68 @@

using System;
using Xamarin.Forms;
using System.Windows.Input;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using BookAStar.Helpers;
using XLabs.Forms.Behaviors;
using XLabs.Forms.Controls;
using BookAStar.Model.Auth.Account;
namespace BookAStar.Pages.UserProfile
{
public partial class AccountChooserPage : ContentPage
{
public AccountChooserPage ()
{
InitializeComponent ();
AddAccountBtn.Clicked += AddAccountBtn_Clicked;
//RemoveAccountBouton.Clicked += RemoveAccountBouton_Clicked;
AccountListView.ItemSelected += Accounts_ItemSelected;
// MainSettings.UserChanged += MainSettings_UserChanged;
}
// Should be useless
private void MainSettings_UserChanged(object sender, EventArgs e)
{
AccountListView.SelectedItem = MainSettings.CurrentUser;
throw new NotImplementedException();
}
private void Accounts_ItemSelected(object sender, SelectedItemChangedEventArgs e)
{
var user = e.SelectedItem as User;
// should later invoke IdentificationChanged
// FIXME don't do it when it's not from the user action
MainSettings.CurrentUser = user;
}
private async void RemoveAccount()
{
User user = AccountListView.SelectedItem as User;
var doIt = await this.Confirm("Suppression de l'identification",
$"Vous êtes sur le point de supprimer votre identification pour ce compte : {user.UserName}\nContinuer ?");
if (doIt)
App.PlatformSpecificInstance.RevokeAccount(user.UserName);
}
protected override void OnAppearing()
{
base.OnAppearing();
}
private void AddAccountBtn_Clicked(object sender, EventArgs e)
{
App.PlatformSpecificInstance.AddAccount();
}
}
}

View file

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
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.UserProfile.DashboardPage"
xmlns:lc="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"
xmlns:lb="clr-namespace:XLabs.Forms.Behaviors;assembly=XLabs.Forms"
Style="{StaticResource DashboardPageStyle}">
<ContentPage.Resources>
<ResourceDictionary>
<Style TargetType="Label">
<Setter Property="Style" Value="{StaticResource ContentLabelStyle}" />
</Style>
<Style TargetType="Button">
<Setter Property="Style" Value="{StaticResource ButtonStyle}" />
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<ScrollView>
<StackLayout BoxView.Color="{StaticResource ContentBackgroundColor}">
<lc:GesturesContentView>
<Image Source="{Binding Avatar}" HeightRequest="{StaticResource BigUserAvatarSize}" >
<lb:Gestures.Interests>
<lb:GestureCollection>
<lb:GestureInterest GestureType="SingleTap" GestureCommand="{Binding AvatarCommand}" GestureParameter="{Binding Ready}"/>
<lb:GestureInterest GestureType="LongPress" GestureCommand="{Binding AvatarCommand}" GestureParameter="{Binding Ready}"/>
<lb:GestureInterest GestureType="Swipe" Direction="Left" GestureCommand="{Binding AvatarCommand}" GestureParameter="{Binding Ready}"/>
<lb:GestureInterest GestureType="Swipe" Direction="Right" GestureCommand="{Binding AvatarCommand}" GestureParameter="{Binding Ready}"/>
</lb:GestureCollection>
</lb:Gestures.Interests>
</Image>
</lc:GesturesContentView>
<Button Text="{Binding UserName}" Clicked="OnRefreshQuery" />
<Button Text="{Binding UserFilesText}" Clicked="OnManageFiles" />
<StackLayout VisualElement.IsVisible="{Binding HaveAnUser}">
<Button Text="{Binding PerformerStatus}" Clicked="OnViewPerformerStatus" />
<Button Text="{Binding UserQueries}" Clicked="OnViewUserQueries"
VisualElement.IsVisible="{Binding IsAPerformer}"/>
<StackLayout Orientation="Horizontal">
<Label Text="Recevoir les notifications push" StyleClass="Header" />
<Switch IsToggled="{Binding ReceivePushNotifications, Mode=TwoWay}"
HorizontalOptions="End" />
</StackLayout>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="Utiliser ma position" StyleClass="Header" />
<Switch HorizontalOptions="End" IsToggled="{Binding AllowUseMyPosition, Mode=TwoWay}"/>
</StackLayout>
<StackLayout VisualElement.IsVisible="{Binding IsAPerformer}" >
<Label Text="{x:Static local:Strings.Profprof}" Style="{StaticResource LabelStyle}"/>
<views:RatingView Rating="{Binding Rating, Mode=TwoWay}" x:Name="ratingView" />
<StackLayout Orientation="Horizontal" VerticalOptions="Start">
<Label Text="{x:Static local:Strings.ClientProRequest}" />
<Switch HorizontalOptions="End" IsToggled="{Binding AllowProBookingOnly, Mode=TwoWay}" />
</StackLayout>
</StackLayout>
</StackLayout>
</ScrollView>
</ContentPage.Content>
</ContentPage>

View file

@ -0,0 +1,87 @@
using System;
using Xamarin.Forms;
using XLabs.Forms.Behaviors;
namespace BookAStar.Pages.UserProfile
{
using Data;
using Helpers;
using Newtonsoft.Json.Linq;
using System.Linq;
using System.Net.Http;
using ViewModels.UserProfile;
using XLabs.Forms.Controls;
public partial class DashboardPage : ContentPage
{
public DashboardPage()
{
InitializeComponent();
}
protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();
}
public async void OnRefreshQuery(object sender, EventArgs e)
{
// TODO disable the button when current user is not registered
if (MainSettings.CurrentUser==null)
ShowPage<AccountChooserPage>(null, true);
else
{
IsBusy = true;
using (var client = UserHelpers.CreateJsonClient())
{
using (var request = new HttpRequestMessage(HttpMethod.Get, Constants.UserInfoUrl))
{
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
string userJson = await response.Content.ReadAsStringAsync();
JObject jactiveUser = JObject.Parse(userJson);
var username = jactiveUser["UserName"].Value<string>();
var roles = jactiveUser["Roles"].Values<string>().ToList();
var emails = jactiveUser["EMails"].Values<string>().ToList();
var avatar = jactiveUser["Avatar"].Value<string>();
var address = jactiveUser["Avatar"].Value<string>();
var me = MainSettings.CurrentUser;
me.Address = address;
me.Avatar = avatar;
me.EMails = emails;
me.UserName = username;
me.Roles = roles;
MainSettings.SaveUser(me);
}
}
}
IsBusy = false;
}
}
public void OnManageFiles(object sender, EventArgs e)
{
ShowPage<UserFiles>(null, true);
}
public void OnViewPerformerStatus(object sender, EventArgs e)
{
ShowPage<AccountChooserPage>(null, true);
}
public void OnViewUserQueries(object sender, EventArgs e)
{
ShowPage<BookQueriesPage>(null, true);
}
private void ShowPage<T>(object [] args, bool animate=false) where T:Page
{
App.NavigationService.NavigateTo<T>(animate, args);
App.MasterPresented = false;
}
}
}

View file

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BookAStar.Pages.UserProfile.UserFiles"
Style="{StaticResource PageStyle}">
<ScrollView>
<StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="Dossiers:" />
<Label Text="{Binding UserName}" HorizontalOptions="Start" />
<Label Text="{Binding SubPath}" HorizontalOptions="Start" />
</StackLayout>
<ListView x:Name="filelist" ItemsSource="{Binding SubDirectories}"
RefreshCommand="{Binding RefreshCommand}"
SeparatorVisibility="Default"
VerticalOptions="Start">
<ListView.ItemTemplate >
<DataTemplate>
<ViewCell>
<ViewCell.View>
<Label Text="{Binding .}" />
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<ListView x:Name="dirlist" ItemsSource="{Binding FileInfo}"
RefreshCommand="{Binding RefreshCommand}"
SeparatorVisibility="Default"
VerticalOptions="Start" >
<ListView.ItemTemplate >
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Horizontal">
<Label Text="{Binding Name}" />
<Label Text="{Binding Size, StringFormat='{0}b'}" />
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ScrollView>
</ContentPage>

View file

@ -0,0 +1,52 @@
using Xamarin.Forms;
namespace BookAStar.Pages.UserProfile
{
using ViewModels.UserProfile;
using Data;
using System.Windows.Input;
public partial class UserFiles : ContentPage
{
protected DirectoryInfoViewModel model;
public UserFiles()
{
InitializeComponent();
var current = DataManager.Instance.RemoteFiles.CurrentItem;
if (current != null)
BindingContext = new DirectoryInfoViewModel(current);
else BindingContext = new DirectoryInfoViewModel
{
UserName = MainSettings.UserName
};
}
public UserFiles(DirectoryInfoViewModel model)
{
InitializeComponent();
BindingContext = model;
}
protected override void OnBindingContextChanged()
{
model = BindingContext as DirectoryInfoViewModel;
if (model != null)
model.RefreshCommand = new Command(() =>
{
DataManager.Instance.RemoteFiles.Execute(null);
var item = DataManager.Instance.RemoteFiles.CurrentItem;
if (item != null)
model.InnerModel = item;
// this.dirlist.EndRefresh();
// this.filelist.EndRefresh();
});
base.OnBindingContextChanged();
}
protected override void OnAppearing()
{
base.OnAppearing();
model.RefreshCommand.Execute(model.SubPath);
}
}
}

View file

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BookAStar.Pages.UserProfile.UserProfilePage"
xmlns:local="clr-namespace:BookAStar;assembly=BookAStar"
xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar"
xmlns:extensions="clr-namespace:BookAStar.Extensions;assembly=BookAStar"
xmlns:controls="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"
Style="{StaticResource PageStyle}">
<ScrollView>
<ScrollView.Padding>
<OnPlatform x:TypeArguments="Thickness"
Android="20,20,20,20"
WinPhone="20,20,20,20"
iOS="20,40,20,20" />
</ScrollView.Padding>
<StackLayout BoxView.Color="{StaticResource ContentBackgroundColor}" Spacing="10,10,10,10" >
<StackLayout VisualElement.IsVisible="{Binding HaveAnUser}">
<views:ImageButton
x:Name="AvatarButton"
Source="{Binding Avatar}"
IsEnabled="true"
BackgroundColor="#01abdf"
Orientation="ImageToLeft"
Text="{Binding UserName}"
TextColor="#ffffff"
></views:ImageButton>
<StackLayout Orientation="Horizontal">
<Label Text="Recevoir les notifications push" StyleClass="Header" />
<Switch IsToggled="{Binding ReceivePushNotifications, Mode=TwoWay}"
HorizontalOptions="End" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="Utiliser ma position" StyleClass="Header" />
<Switch HorizontalOptions="End" IsToggled="{Binding AllowUseMyPosition, Mode=TwoWay}"/>
</StackLayout>
<StackLayout VisualElement.IsVisible="{Binding IsAPerformer}">
<StackLayout Orientation="Horizontal" VerticalOptions="Start"
VisualElement.IsVisible="{Binding IsAPerformer}" >
<Label Text="Ne recevoir de demande de devis que de la part de professionnels uniquement" />
<Switch HorizontalOptions="End" IsToggled="{Binding AllowProBookingOnly, Mode=TwoWay}"/>
</StackLayout>
<Button Text="{Binding PerformerStatus}" Clicked="OnViewPerformerStatus" />
</StackLayout>
</StackLayout>
</StackLayout>
</ScrollView>
</ContentPage>

View file

@ -0,0 +1,65 @@

using BookAStar.ViewModels.UserProfile;
using Plugin.Media;
using Plugin.Media.Abstractions;
using System;
using Xamarin.Forms;
namespace BookAStar.Pages.UserProfile
{
public partial class UserProfilePage : ContentPage
{
public UserProfilePage()
{
InitializeComponent();
AvatarButton.Clicked += AvatarButton_Clicked;
}
public UserProfilePage(UserProfileViewModel model)
{
InitializeComponent();
AvatarButton.Clicked += AvatarButton_Clicked;
BindingContext = model;
}
private async void AvatarButton_Clicked (object sender, EventArgs e)
{
if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
{
await DisplayAlert("No Camera", ":( No camera avaialble.", "OK");
return;
}
var file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
{
Directory = "Avatars",
Name = "me.jpg"
});
if (file == null)
return;
// ImageSource.FromFile(file.Path);
/* ImageSource.FromStream(() =>
{
var stream = file.GetStream();
file.Dispose();
return stream;
}); */
}
public void OnManageFiles(object sender, EventArgs e)
{
ShowPage<UserFiles>(null, true);
}
public void OnViewPerformerStatus(object sender, EventArgs e)
{
ShowPage<AccountChooserPage>(null, true);
}
private void ShowPage<T>(object[] args, bool animate = false) where T : Page
{
App.NavigationService.NavigateTo<T>(animate, args);
App.MasterPresented = false;
}
}
}