End HomePage interface

Logic is coming... soon or not
This commit is contained in:
2019-03-25 21:48:48 +01:00
parent 35e468e0b0
commit e64979e42f
16 changed files with 198 additions and 17 deletions

View File

@@ -6,7 +6,8 @@
<ContentView.Content>
<Frame CornerRadius="5"
Padding="5"
BorderColor="Gray"
BorderColor="{OnPlatform UWP='Gray', Android='Gray'}"
HasShadow="True"
BackgroundColor="{OnPlatform UWP='#F0F0F0'}">
<StackLayout HorizontalOptions="Fill"
VerticalOptions="Fill"

View File

@@ -14,6 +14,11 @@ namespace PlantBox.Client.Forms
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class HomeItem : ContentView
{
// Colors
public static readonly Color BadColor = Color.FromHex("#dd2c00");
public static readonly Color GoodColor = Color.FromHex("#64dd17");
public static readonly Color WarningColor = Color.FromHex("#ff6d00");
// Name
public static readonly BindableProperty PlantNameProperty = BindableProperty.Create(nameof(PlantName), typeof(string), typeof(HomeItem));
public string PlantName
@@ -65,13 +70,13 @@ namespace PlantBox.Client.Forms
switch(PlantState)
{
case PlantState.Bad:
color = Color.Red;
color = BadColor;
break;
case PlantState.Warning:
color = Color.Yellow;
color = WarningColor;
break;
default:
color = Color.Lime;
color = GoodColor;
break;
}

View File

@@ -12,8 +12,9 @@
<ListView ItemsSource="{Binding Plants}"
SelectionMode="None"
IsPullToRefreshEnabled="True"
RowHeight="85"
SeparatorVisibility="None">
RowHeight="{OnPlatform Android=85}"
SeparatorVisibility="None"
ItemTapped="ListView_ItemTapped">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>

View File

@@ -1,4 +1,7 @@
using System;
using PlantBox.Client.Forms.Plant;
using PlantBox.Client.Models;
using PlantBox.Shared.Communication.Commands;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
@@ -17,5 +20,12 @@ namespace PlantBox.Client.Forms
{
InitializeComponent();
}
}
private async void ListView_ItemTapped(object sender, ItemTappedEventArgs e)
{
var plant = (PlantInfo)e.Item;
await Navigation.PushAsync(new PlantPage(plant));
}
}
}

View File

@@ -0,0 +1,12 @@
<?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="PlantBox.Client.Forms.Plant.CaptorsPage">
<ContentPage.Content>
<StackLayout>
<Label Text="Welcome to Xamarin.Forms!"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace PlantBox.Client.Forms.Plant
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class CaptorsPage : ContentPage
{
public CaptorsPage ()
{
InitializeComponent ();
}
}
}

View File

@@ -0,0 +1,12 @@
<?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="PlantBox.Client.Forms.Plant.HistoricPage">
<ContentPage.Content>
<StackLayout>
<Label Text="Welcome to Xamarin.Forms!"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace PlantBox.Client.Forms.Plant
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class HistoricPage : ContentPage
{
public HistoricPage ()
{
InitializeComponent ();
}
}
}

View File

@@ -0,0 +1,4 @@
<?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="PlantBox.Client.Forms.Plant.PlantPage" />

View File

@@ -0,0 +1,31 @@
using PlantBox.Client.Models;
using PlantBox.Client.Resources;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace PlantBox.Client.Forms.Plant
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PlantPage : TabbedPage
{
public PlantPage(PlantInfo plant)
{
InitializeComponent();
Children.Add(new CaptorsPage()
{
Title = Locale.Informations
});
Children.Add(new HistoricPage()
{
Title = Locale.Historic
});
}
}
}

View File

@@ -0,0 +1,23 @@
using PlantBox.Shared.Communication.Commands;
using System;
using System.Collections.Generic;
using System.Text;
namespace PlantBox.Client.Models
{
public class PlantInfo
{
public string Name { get; }
public ulong ID { get; }
public PlantType Type { get; }
public PlantState State { get; }
public PlantInfo(string name, ulong iD, PlantType type, PlantState state)
{
Name = name;
ID = iD;
Type = type;
State = state;
}
}
}

View File

@@ -53,6 +53,15 @@
<EmbeddedResource Update="Forms\HomeItem.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Forms\Plant\CaptorsPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Forms\Plant\HistoricPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Forms\Plant\PlantPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Forms\Settings\LanguageSelectorPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>

View File

@@ -78,6 +78,15 @@ namespace PlantBox.Client.Resources {
}
}
/// <summary>
/// Recherche une chaîne localisée semblable à Captors.
/// </summary>
internal static string Captors {
get {
return ResourceManager.GetString("Captors", resourceCulture);
}
}
/// <summary>
/// Recherche une chaîne localisée semblable à General.
/// </summary>
@@ -87,6 +96,15 @@ namespace PlantBox.Client.Resources {
}
}
/// <summary>
/// Recherche une chaîne localisée semblable à Historic.
/// </summary>
internal static string Historic {
get {
return ResourceManager.GetString("Historic", resourceCulture);
}
}
/// <summary>
/// Recherche une chaîne localisée semblable à Home.
/// </summary>

View File

@@ -123,9 +123,15 @@
<data name="Author" xml:space="preserve">
<value>Auteur</value>
</data>
<data name="Captors" xml:space="preserve">
<value>Capteurs</value>
</data>
<data name="General" xml:space="preserve">
<value>Général</value>
</data>
<data name="Historic" xml:space="preserve">
<value>Historique</value>
</data>
<data name="HomePageTitle" xml:space="preserve">
<value>Accueil</value>
</data>

View File

@@ -123,9 +123,15 @@
<data name="Author" xml:space="preserve">
<value>Author</value>
</data>
<data name="Captors" xml:space="preserve">
<value>Captors</value>
</data>
<data name="General" xml:space="preserve">
<value>General</value>
</data>
<data name="Historic" xml:space="preserve">
<value>Historic</value>
</data>
<data name="HomePageTitle" xml:space="preserve">
<value>Home</value>
</data>

View File

@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
@@ -14,23 +15,25 @@ namespace PlantBox.Client.ViewModels
{
public event PropertyChangedEventHandler PropertyChanged;
public ObservableCollection<InfoResponse> Plants { get; set; }
public ObservableCollection<PlantInfo> Plants { get; set; }
public HomeViewModel()
{
Plants = LoadPlants(App.Settings.IDs);
}
public ObservableCollection<InfoResponse> LoadPlants(IEnumerable<ulong> ids)
public ObservableCollection<PlantInfo> LoadPlants(IEnumerable<ulong> ids)
{
// Mock
return new ObservableCollection<InfoResponse>()
{
new InfoResponse("Salon", PlantType.Ficus, PlantState.Good, 75.2),
new InfoResponse("Chambre", PlantType.Bamboo, PlantState.Warning, 11.2),
new InfoResponse("Hello", PlantType.Cactus, PlantState.Bad, 45.2),
new InfoResponse("Hello", PlantType.Cactus, PlantState.Bad, 45.2)
};
return new ObservableCollection<PlantInfo>
(
new[] {
new PlantInfo("Salon", 0, PlantType.Ficus, PlantState.Good),
new PlantInfo("Chambre", 1, PlantType.Bamboo, PlantState.Warning),
new PlantInfo("Hellx", 2, PlantType.Cactus, PlantState.Bad),
new PlantInfo("Hello", 3, PlantType.Cactus, PlantState.Bad)
}.OrderBy(x => x.State).ThenBy(x => x.Name)
);
}
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)