Merge branch 'vnext' of github.com:pazof/yavsc into vnext
This commit is contained in:
@ -25,6 +25,7 @@ namespace BookAStar
|
||||
using ViewModels.UserProfile;
|
||||
using Pages.UserProfile;
|
||||
using ViewModels.EstimateAndBilling;
|
||||
using System.Net;
|
||||
|
||||
public partial class App : Application // superclass new in 1.3
|
||||
{
|
||||
@ -109,7 +110,7 @@ namespace BookAStar
|
||||
BindingContext = page.BindingContext
|
||||
});
|
||||
}
|
||||
DataManager.Current.AppState.SaveCollection();
|
||||
DataManager.Current.AppState.SaveEntity();
|
||||
}
|
||||
|
||||
// called on app startup, after OnStartup, not on rotation
|
||||
@ -124,7 +125,7 @@ namespace BookAStar
|
||||
pageType, true, pageState.BindingContext);
|
||||
}
|
||||
DataManager.Current.AppState.Clear();
|
||||
DataManager.Current.AppState.SaveCollection();
|
||||
DataManager.Current.AppState.SaveEntity();
|
||||
}
|
||||
|
||||
// FIXME Not called?
|
||||
@ -206,6 +207,7 @@ namespace BookAStar
|
||||
masterDetail.Detail = new NavigationPage(home);
|
||||
ToolbarItem tiSetts = new ToolbarItem()
|
||||
{
|
||||
// FIXME what for? Priority = 0,
|
||||
Text = "Paramètres",
|
||||
Icon = "ic_corp_icon.png",
|
||||
Command = new Command(
|
||||
@ -290,7 +292,19 @@ namespace BookAStar
|
||||
// Start the Hub connection
|
||||
public async void StartHubConnection ()
|
||||
{
|
||||
await chatHubConnection.Start();
|
||||
try
|
||||
{
|
||||
await chatHubConnection.Start();
|
||||
}
|
||||
catch (WebException webex )
|
||||
{
|
||||
// TODO use webex, set this cx down status somewhere,
|
||||
// & display it & maybe try again later.
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// TODO use ex
|
||||
}
|
||||
}
|
||||
|
||||
public void SetupHubConnection()
|
||||
|
@ -61,6 +61,9 @@
|
||||
<Compile Include="Pages\UserProfile\UserFiles.xaml.cs">
|
||||
<DependentUpon>UserFiles.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Pages\UserProfile\UserProfilePage.xaml.cs">
|
||||
<DependentUpon>UserProfilePage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Settings\ChatSettings.cs" />
|
||||
<Compile Include="ViewModels\EditingViewModel.cs" />
|
||||
<Compile Include="Pages\DocSigning.xaml.cs">
|
||||
@ -78,7 +81,6 @@
|
||||
<Compile Include="Extensions\ImageResourceExtension.cs" />
|
||||
<Compile Include="Factories\ViewFactory.cs" />
|
||||
<Compile Include="Data\DataManager.cs" />
|
||||
<Compile Include="Helpers\ObservableString.cs" />
|
||||
<Compile Include="Interfaces\ILocalEntity.cs" />
|
||||
<Compile Include="Data\LocaLEntity.cs" />
|
||||
<Compile Include="Helpers\NotIdentifiedException.cs" />
|
||||
@ -422,6 +424,12 @@
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Pages\UserProfile\UserProfilePage.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||
<Import Project="..\..\packages\Xamarin.Forms.2.3.2.127\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.3.2.127\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
|
@ -7,6 +7,7 @@
|
||||
using Model.Social.Messaging;
|
||||
using Model.FileSystem;
|
||||
using ViewModels.EstimateAndBilling;
|
||||
using NonCrUD;
|
||||
|
||||
public class DataManager
|
||||
{
|
||||
@ -14,7 +15,7 @@
|
||||
public RemoteEntityRO<BookQueryData, long> BookQueries { get; set; }
|
||||
public RemoteEntity<Estimate, long> Estimates { get; set; }
|
||||
public RemoteEntity<Blog, long> Blogspot { get; set; }
|
||||
internal RemoteEntity<UserDirectoryInfo, string> RemoteFiles { get; set; }
|
||||
internal RemoteFilesEntity RemoteFiles { get; set; }
|
||||
|
||||
public LocalEntity<ClientProviderInfo,string> Contacts { get; set; }
|
||||
internal LocalEntity<PageState, int> AppState { get; set; }
|
||||
@ -48,7 +49,7 @@
|
||||
EstimationCache = new LocalEntity<EditEstimateViewModel, long>(e => e.Query.Id);
|
||||
EstimateLinesTemplates = new LocalEntity<BillingLine, string>(l => l.Description);
|
||||
PrivateMessages = new LocalEntity<ChatMessage, int>(m=> m.GetHashCode());
|
||||
RemoteFiles = new RemoteEntity<UserDirectoryInfo, string> ("fs", d => d.SubPath);
|
||||
RemoteFiles = new RemoteFilesEntity ();
|
||||
|
||||
PrivateMessages.Load();
|
||||
BookQueries.Load();
|
||||
|
@ -40,14 +40,24 @@ namespace BookAStar.Data
|
||||
return CurrentItem;
|
||||
}
|
||||
|
||||
public void Load()
|
||||
public virtual bool Load()
|
||||
{
|
||||
this.Populate<V>();
|
||||
return this.Populate<V,K>();
|
||||
}
|
||||
|
||||
public void Load(string subKey)
|
||||
public virtual bool Load(string subKey)
|
||||
{
|
||||
this.Populate<V>(subKey);
|
||||
return (this.Populate<V,K>(subKey));
|
||||
}
|
||||
public virtual bool Seek(int index)
|
||||
{
|
||||
|
||||
if (this.Count>index && index >=0)
|
||||
{
|
||||
CurrentItem = this[index];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,10 +6,17 @@ namespace BookAStar.Data.NonCrUD
|
||||
{
|
||||
using Helpers;
|
||||
using Model.FileSystem;
|
||||
|
||||
public class RemoteFiles : RemoteEntity<UserDirectoryInfo, FileAddress>
|
||||
using System.Linq;
|
||||
/*
|
||||
public class DirectoryEntryChangingEvent : EventArgs
|
||||
{
|
||||
public RemoteFiles() : base("fs", d => d)
|
||||
public UserDirectoryInfo OldItem { get; set; }
|
||||
public UserDirectoryInfo NewItem { get; set; }
|
||||
}*/
|
||||
|
||||
public class RemoteFilesEntity : RemoteEntity<UserDirectoryInfo, FileAddress>
|
||||
{
|
||||
public RemoteFilesEntity() : base("fs", d => d)
|
||||
{
|
||||
|
||||
}
|
||||
@ -23,14 +30,15 @@ namespace BookAStar.Data.NonCrUD
|
||||
try
|
||||
{
|
||||
var subpath = parameter as string;
|
||||
string path = ControllerUri.AbsolutePath + ((subpath != null) ? "/" + subpath : null);
|
||||
using (var response = await client.GetAsync(ControllerUri))
|
||||
string path = ControllerUri.AbsoluteUri + ((subpath != null) ? "/" + subpath : null);
|
||||
using (var response = await client.GetAsync(path))
|
||||
{
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
var di = JsonConvert.DeserializeObject<UserDirectoryInfo>(content);
|
||||
this.Merge(di);
|
||||
this.SaveEntity();
|
||||
}
|
||||
else if (response.StatusCode == System.Net.HttpStatusCode.BadRequest)
|
||||
throw new Exception("Bad request");
|
||||
@ -43,8 +51,32 @@ namespace BookAStar.Data.NonCrUD
|
||||
throw new Exception("Remote call failed", ex);
|
||||
}
|
||||
}
|
||||
AfterExecuting();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public override void Merge(UserDirectoryInfo item)
|
||||
{
|
||||
var key = GetKey(item);
|
||||
DirectoryEntryChangingEvent itemChanged = null;
|
||||
if (this.Any(x => GetKey(x).Equals(key)))
|
||||
{
|
||||
var old = LocalGet(key);
|
||||
itemChanged = new DirectoryEntryChangingEvent
|
||||
{
|
||||
OldItem = old,
|
||||
NewItem = item
|
||||
};
|
||||
Remove(old);
|
||||
}
|
||||
Add(item);
|
||||
CurrentItem = item;
|
||||
if (DirectoryEntryChanged != null && itemChanged != null)
|
||||
DirectoryEntryChanged.Invoke(this, itemChanged);
|
||||
}
|
||||
|
||||
public event EventHandler<DirectoryEntryChangingEvent> DirectoryEntryChanged;
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ namespace BookAStar.Data
|
||||
{
|
||||
Merge(item);
|
||||
}
|
||||
this.SaveCollection();
|
||||
this.SaveEntity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,59 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BookAStar
|
||||
{
|
||||
public class ObservableString : IObservable<string>, IDisposable
|
||||
{
|
||||
public ObservableString(string data)
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
private string data = null;
|
||||
private List<IObserver<string>> observers = new List<IObserver<string>>();
|
||||
|
||||
public string Data
|
||||
{
|
||||
get
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (data != value)
|
||||
{
|
||||
data = value;
|
||||
foreach (var obs in observers)
|
||||
obs.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
public static explicit operator ObservableString (string data)
|
||||
{
|
||||
return new ObservableString(data);
|
||||
}
|
||||
|
||||
public static explicit operator string (ObservableString observable)
|
||||
{
|
||||
return observable.ToString();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
observers = null;
|
||||
}
|
||||
|
||||
public IDisposable Subscribe(IObserver<string> observer)
|
||||
{
|
||||
observers.Add(observer);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace BookAStar
|
||||
{
|
||||
public interface ILoadable
|
||||
{
|
||||
void Load();
|
||||
bool Load();
|
||||
}
|
||||
|
||||
public interface IPersistentOnDemand : ILoadable
|
||||
@ -12,7 +13,7 @@ namespace BookAStar
|
||||
void Save();
|
||||
}
|
||||
|
||||
public interface ILocalEntity<V, K> : ILoadable where K : IEquatable<K>
|
||||
public interface ILocalEntity<V, K> : IList, ILoadable where K : IEquatable<K>
|
||||
{
|
||||
V CurrentItem { get; }
|
||||
|
||||
@ -22,5 +23,6 @@ namespace BookAStar
|
||||
|
||||
void Merge(V item);
|
||||
|
||||
bool Seek(int index);
|
||||
}
|
||||
}
|
@ -58,7 +58,7 @@ namespace BookAStar.Pages
|
||||
|
||||
private void OnEditEstimate(object sender, EventArgs ev)
|
||||
{
|
||||
var bookQueryViewModel = (BookQueryViewModel)BindingContext;
|
||||
var bookQueryViewModel = (BookQueryViewModel) BindingContext;
|
||||
|
||||
var editEstimateViewModel = bookQueryViewModel.DraftEstimate;
|
||||
if (editEstimateViewModel == null)
|
||||
@ -70,7 +70,7 @@ namespace BookAStar.Pages
|
||||
if (estimateToEdit == null)
|
||||
{
|
||||
DataManager.Current.Contacts.Merge(BookQuery.Client);
|
||||
DataManager.Current.Contacts.SaveCollection();
|
||||
DataManager.Current.Contacts.SaveEntity();
|
||||
estimateToEdit = new Estimate()
|
||||
{
|
||||
ClientId = BookQuery.Client.UserId,
|
||||
|
@ -24,7 +24,7 @@ namespace BookAStar.Pages
|
||||
|
||||
private void EditEstimatePage_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
DataManager.Current.EstimationCache.SaveCollection();
|
||||
DataManager.Current.EstimationCache.SaveEntity();
|
||||
}
|
||||
|
||||
protected override void OnSizeAllocated(double width, double height)
|
||||
@ -47,7 +47,7 @@ namespace BookAStar.Pages
|
||||
var lineView = new BillingLineViewModel(com)
|
||||
{ ValidateCommand = new Command(() => {
|
||||
bill.Add(com);
|
||||
bill.SaveCollection();
|
||||
DataManager.Current.EstimationCache.SaveEntity();
|
||||
})};
|
||||
App.NavigationService.NavigateTo<EditBillingLinePage>(
|
||||
true,
|
||||
@ -60,7 +60,7 @@ namespace BookAStar.Pages
|
||||
var lineView = new BillingLineViewModel(line)
|
||||
{
|
||||
ValidateCommand = new Command(() => {
|
||||
bill.SaveCollection();
|
||||
DataManager.Current.EstimationCache.SaveEntity();
|
||||
})
|
||||
};
|
||||
lineView.PropertyChanged += LineView_PropertyChanged;
|
||||
@ -71,7 +71,7 @@ namespace BookAStar.Pages
|
||||
|
||||
private void LineView_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
DataManager.Current.EstimationCache.SaveCollection();
|
||||
DataManager.Current.EstimationCache.SaveEntity();
|
||||
}
|
||||
|
||||
protected void OnEstimateValidated(object sender, EventArgs e)
|
||||
@ -88,9 +88,9 @@ namespace BookAStar.Pages
|
||||
{
|
||||
DataManager.Current.Estimates.Update(evm.Data);
|
||||
}
|
||||
DataManager.Current.Estimates.SaveCollection();
|
||||
DataManager.Current.Estimates.SaveEntity();
|
||||
DataManager.Current.EstimationCache.Remove(evm);
|
||||
DataManager.Current.EstimationCache.SaveCollection();
|
||||
DataManager.Current.EstimationCache.SaveEntity();
|
||||
Navigation.PopAsync();
|
||||
}
|
||||
}
|
||||
|
@ -18,36 +18,18 @@
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</ContentPage.Resources>
|
||||
<ScrollView>
|
||||
<StackLayout Orientation="Vertical" >
|
||||
<StackLayout>
|
||||
<lc:GesturesContentView ExcludeChildren="false" VisualElement.HeightRequest="{StaticResource BigUserAvatarSize}">
|
||||
<StackLayout>
|
||||
<Label Text="{Binding UserName}" Style="{StaticResource LabelPageHeadingStyle}"
|
||||
HorizontalTextAlignment="Center"
|
||||
LineBreakMode="WordWrap" XAlign="Center"
|
||||
<ContentPage.Content>
|
||||
<ScrollView>
|
||||
<StackLayout BoxView.Color="{StaticResource ContentBackgroundColor}">
|
||||
<Label Text="{Binding UserName}" Style="{StaticResource LabelPageHeadingStyle}"
|
||||
HorizontalTextAlignment="Center"
|
||||
LineBreakMode="WordWrap" XAlign="Center"
|
||||
></Label>
|
||||
|
||||
<Frame VisualElement.HeightRequest="{StaticResource BigUserAvatarSize}">
|
||||
|
||||
<lb:Gestures.Interests>
|
||||
<lb:GestureCollection>
|
||||
<lb:GestureInterest GestureType="LongPress"
|
||||
GestureCommand="{Binding UserNameGesture}"
|
||||
/>
|
||||
</lb:GestureCollection>
|
||||
</lb:Gestures.Interests>
|
||||
<Image Source="{Binding Avatar}" Aspect="AspectFit"
|
||||
|
||||
|
||||
<Image Source="{Binding Avatar}"
|
||||
VisualElement.HeightRequest="{StaticResource BigUserAvatarSize}" />
|
||||
|
||||
|
||||
</Frame>
|
||||
</StackLayout>
|
||||
</lc:GesturesContentView>
|
||||
<views:RatingView Rating="{Binding Rating, Mode=TwoWay}" x:Name="ratingView"/>
|
||||
|
||||
|
||||
</StackLayout>
|
||||
<views:RatingView Rating="{Binding Rating, Mode=TwoWay}" x:Name="ratingView" />
|
||||
|
||||
<Button Text="{Binding PerformerStatus}" Clicked="OnViewPerformerStatus" />
|
||||
<Button Text="{Binding UserQueries}" Clicked="OnViewUserQueries"
|
||||
@ -63,11 +45,11 @@
|
||||
<Switch HorizontalOptions="End" IsToggled="{Binding AllowUseMyPosition, Mode=TwoWay}"/>
|
||||
</StackLayout>
|
||||
<StackLayout Orientation="Horizontal" VerticalOptions="Start"
|
||||
VisualElement.IsVisible="{Binding UserIsPro}">
|
||||
<Label Text="Ne recevoir de demande de devis que de la part de professionnels uniquement"
|
||||
StyleClass="Header"/>
|
||||
VisualElement.IsVisible="{Binding UserIsPro}" >
|
||||
<Label Text="Ne recevoir de demande de devis que de la part de professionnels uniquement" />
|
||||
<Switch HorizontalOptions="End" IsToggled="{Binding AllowProBookingOnly, Mode=TwoWay}"/>
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
</ContentPage.Content>
|
||||
</ContentPage>
|
@ -6,6 +6,7 @@ namespace BookAStar.Pages.UserProfile
|
||||
{
|
||||
using Data;
|
||||
using ViewModels.UserProfile;
|
||||
|
||||
public partial class DashboardPage : ContentPage
|
||||
{
|
||||
|
||||
@ -23,10 +24,12 @@ namespace BookAStar.Pages.UserProfile
|
||||
ShowPage<AccountChooserPage>(null, true);
|
||||
});
|
||||
}
|
||||
|
||||
public void OnManageFiles(object sender, EventArgs e)
|
||||
{
|
||||
ShowPage<UserFiles>(new object[] { new DirectoryInfoViewModel() }, true);
|
||||
ShowPage<UserFiles>(null, true);
|
||||
}
|
||||
|
||||
public void OnViewPerformerStatus(object sender, EventArgs e)
|
||||
{
|
||||
ShowPage<AccountChooserPage>(null, true);
|
||||
|
@ -1,35 +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"
|
||||
x:Class="BookAStar.Pages.UserProfile.UserFiles">
|
||||
<Label Text="{Binding SubPath}" VerticalOptions="Center" HorizontalOptions="Center" />
|
||||
<ListView x:Name="dirlist" ItemsSource="{Binding SubDirectories}"
|
||||
RefreshCommand="{Binding RefreshCommand}" >
|
||||
<ListView.ItemTemplate >
|
||||
<DataTemplate>
|
||||
<ViewCell>
|
||||
<ViewCell.View>
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<Label Text="{Binding Name}" />
|
||||
<Label Text="{Binding Size}" />
|
||||
<Label Text="{Binding CreationTime, StringFormat='créé {0:dddd d MMMM à HH:mm}'}" />
|
||||
<Label Text="{Binding LastModified, StringFormat='modifié {0:dddd d MMMM à HH:mm}'}" />
|
||||
</StackLayout>
|
||||
</ViewCell.View>
|
||||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
<ListView x:Name="filelist" ItemsSource="{Binding FileInfo}"
|
||||
RefreshCommand="{Binding RefreshCommand}">
|
||||
<ListView.ItemTemplate >
|
||||
<DataTemplate>
|
||||
<ViewCell>
|
||||
<ViewCell.View>
|
||||
<Label Text="{Binding .}" />
|
||||
</ViewCell.View>
|
||||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
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'}" />
|
||||
<Label Text="{Binding CreationTime, StringFormat='créé {0:dddd d MMMM à HH:mm}'}" />
|
||||
<Label Text="{Binding LastModified, StringFormat='modifié {0:dddd d MMMM à HH:mm}'}" />
|
||||
</StackLayout>
|
||||
</ViewCell.View>
|
||||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
</ContentPage>
|
@ -4,31 +4,49 @@ 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 currentDir = DataManager.Current.RemoteFiles.CurrentItem;
|
||||
|
||||
BindingContext = new DirectoryInfoViewModel(currentDir)
|
||||
var current = DataManager.Current.RemoteFiles.CurrentItem;
|
||||
if (current != null)
|
||||
BindingContext = new DirectoryInfoViewModel(current);
|
||||
else BindingContext = new DirectoryInfoViewModel
|
||||
{
|
||||
RefreshCommand = new Command(() =>
|
||||
{
|
||||
DataManager.Current.RemoteFiles.Execute(null);
|
||||
|
||||
this.dirlist.EndRefresh();
|
||||
this.filelist.EndRefresh();
|
||||
})
|
||||
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.Current.RemoteFiles.Execute(null);
|
||||
var item = DataManager.Current.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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
<?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">
|
||||
<Label Text="{Binding UserName}" VerticalOptions="Center" HorizontalOptions="Center" />
|
||||
|
||||
</ContentPage>
|
@ -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.UserProfile
|
||||
{
|
||||
public partial class UserProfilePage : ContentPage
|
||||
{
|
||||
public UserProfilePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -265,9 +265,9 @@ namespace BookAStar
|
||||
/// <typeparam name="V"></typeparam>
|
||||
/// <param name="collection"></param>
|
||||
/// <param name="subKey"></param>
|
||||
public static void Populate<V>(this IList<V> collection, string subKey = null)
|
||||
public static bool Populate<V,K>(this ILocalEntity<V, K> collection, string subKey = null) where K : IEquatable<K>
|
||||
{
|
||||
var key = $"{EntityDataSettingsPrefix}/{subKey}/{typeof(V).FullName}";
|
||||
var key = GetCollectionKey<V>(subKey);
|
||||
var data = AppSettings.GetValueOrDefault<string>(key, null);
|
||||
if (!string.IsNullOrWhiteSpace(data))
|
||||
{
|
||||
@ -275,7 +275,15 @@ namespace BookAStar
|
||||
if (items != null)
|
||||
foreach (var item in items)
|
||||
collection.Add(item);
|
||||
var cursorKey = GetCursorKey<V>(subKey);
|
||||
var index = AppSettings.GetValueOrDefault<int>(cursorKey, -1);
|
||||
if (index>=0)
|
||||
{
|
||||
collection.Seek(index);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -284,11 +292,25 @@ namespace BookAStar
|
||||
/// <typeparam name="V"></typeparam>
|
||||
/// <param name="collection"></param>
|
||||
/// <param name="subKey"></param>
|
||||
public static void SaveCollection<V>(this IList<V> collection, string subKey=null)
|
||||
public static void SaveEntity<V,K>(this ILocalEntity<V, K> collection, string subKey=null) where K : IEquatable<K>
|
||||
{
|
||||
if (collection == null) return;
|
||||
var key = $"{EntityDataSettingsPrefix}/{subKey}/{typeof(V).FullName}";
|
||||
var key = GetCollectionKey<V>(subKey);
|
||||
var cursorKey = GetCursorKey<V>(subKey);
|
||||
AppSettings.AddOrUpdateValue(key, JsonConvert.SerializeObject(collection));
|
||||
if (collection.CurrentItem!=null)
|
||||
{
|
||||
int index = collection.IndexOf(collection.CurrentItem) ;
|
||||
AppSettings.AddOrUpdateValue<int>(cursorKey, index);
|
||||
}
|
||||
}
|
||||
private static string GetCursorKey<V>(string subKey)
|
||||
{
|
||||
return $"{EntityDataSettingsPrefix}/{subKey}/{typeof(V).FullName}/c";
|
||||
}
|
||||
private static string GetCollectionKey<V>(string subKey)
|
||||
{
|
||||
return $"{EntityDataSettingsPrefix}/{subKey}/{typeof(V).FullName}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,28 +5,71 @@ using XLabs.Forms.Mvvm;
|
||||
|
||||
namespace BookAStar.ViewModels.UserProfile
|
||||
{
|
||||
using System.ComponentModel;
|
||||
using Model.FileSystem;
|
||||
|
||||
public class DirectoryInfoViewModel : ViewModel
|
||||
{
|
||||
public ObservableString SubPath { get; set; }
|
||||
public ObservableCollection<string> SubDirectories { get; set; }
|
||||
public ObservableCollection<UserFileInfo> FileInfo { get; set; }
|
||||
public ICommand RefreshCommand { get; set; }
|
||||
public DirectoryInfoViewModel (UserDirectoryInfo model=null)
|
||||
private string subPath;
|
||||
public string SubPath
|
||||
{
|
||||
Data.DataManager.Current.RemoteFiles.CollectionChanged += RemoteFiles_CollectionChanged;
|
||||
|
||||
if (model == null)
|
||||
model = Data.DataManager.Current.RemoteFiles.CurrentItem;
|
||||
SubDirectories = new ObservableCollection<string> (model.SubDirectories);
|
||||
SubPath = new ObservableString (model.SubPath);
|
||||
FileInfo = new ObservableCollection<Model.FileSystem.UserFileInfo> (model.Files);
|
||||
get { return subPath; }
|
||||
set { SetProperty<string>(ref subPath, value); }
|
||||
}
|
||||
|
||||
private void RemoteFiles_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||
private string userName;
|
||||
public string UserName
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
get { return userName; }
|
||||
set { SetProperty<string>(ref userName, value); }
|
||||
}
|
||||
|
||||
private ObservableCollection<string> subDirectories;
|
||||
public ObservableCollection<string> SubDirectories
|
||||
{
|
||||
get { return subDirectories; }
|
||||
set { SetProperty< ObservableCollection < string >>( ref subDirectories, value) ; }
|
||||
}
|
||||
|
||||
private ObservableCollection<UserFileInfo> fileInfo;
|
||||
public ObservableCollection<UserFileInfo> FileInfo
|
||||
{
|
||||
get { return fileInfo; }
|
||||
set { SetProperty<ObservableCollection<UserFileInfo>> ( ref fileInfo, value ); }
|
||||
}
|
||||
|
||||
UserDirectoryInfo model;
|
||||
public UserDirectoryInfo InnerModel {
|
||||
get { return model; }
|
||||
set {
|
||||
if (SetProperty<UserDirectoryInfo>(ref model, value))
|
||||
if (model == null)
|
||||
{
|
||||
SubDirectories = new ObservableCollection<string>();
|
||||
FileInfo = new ObservableCollection<UserFileInfo>();
|
||||
SubPath = "<no path>";
|
||||
UserName = "<no user>";
|
||||
}
|
||||
else
|
||||
{
|
||||
SubDirectories = new ObservableCollection<string>(model.SubDirectories);
|
||||
FileInfo = new ObservableCollection<UserFileInfo>(model.Files);
|
||||
SubPath = model.SubPath;
|
||||
UserName = model.UserName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DirectoryInfoViewModel(UserDirectoryInfo model = null)
|
||||
{
|
||||
this.InnerModel = model;
|
||||
}
|
||||
|
||||
private ICommand refreshCommand;
|
||||
public ICommand RefreshCommand
|
||||
{
|
||||
get { return refreshCommand; }
|
||||
set { SetProperty<ICommand>(ref refreshCommand, value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,8 @@
|
||||
</ResourceDictionary>
|
||||
</ContentView.Resources>
|
||||
<ContentView.Content>
|
||||
<StackLayout>
|
||||
<StackLayout Orientation="Horizontal" HeightRequest="70">
|
||||
<StackLayout>
|
||||
<StackLayout Orientation="Horizontal" >
|
||||
<Grid>
|
||||
<Grid.Behaviors>
|
||||
<behaviors:StarBehavior x:Name="starOne" GroupName="myStar"/>
|
||||
@ -61,8 +61,7 @@
|
||||
|
||||
<Image x:Name="starSelectedFour"
|
||||
Source="{extensions:ImageResource BookAStar.Images.Validation.star_selected.png}"
|
||||
IsVisible="{Binding Source={x:Reference starFour},
|
||||
Path=IsStarred}"/>
|
||||
IsVisible="{Binding Source={x:Reference starFour}, Path=IsStarred}" />
|
||||
</Grid>
|
||||
<Grid >
|
||||
<Grid.Behaviors>
|
||||
@ -73,9 +72,9 @@
|
||||
|
||||
<Image x:Name="starSelectedFive"
|
||||
Source="{extensions:ImageResource BookAStar.Images.Validation.star_selected.png}"
|
||||
IsVisible="{Binding Source={x:Reference starFive},
|
||||
Path=IsStarred}"/>
|
||||
IsVisible="{Binding Source={x:Reference starFive}, Path=IsStarred}" />
|
||||
</Grid>
|
||||
|
||||
</StackLayout>
|
||||
<StackLayout>
|
||||
<StackLayout.Resources>
|
||||
@ -85,7 +84,7 @@
|
||||
</StackLayout.Resources>
|
||||
<Label Text="{Binding Source={x:Reference starFive}, Path=Rating, Converter={StaticResource ratingText}}" ></Label>
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
|
||||
</ContentView.Content>
|
||||
</ContentView>
|
||||
|
Reference in New Issue
Block a user