Skip to content

Commit

Permalink
Merge pull request #15 from ZeroGachis/fix/expander-cart-list
Browse files Browse the repository at this point in the history
Fix/expander cart list
  • Loading branch information
valentinmagrez authored Nov 9, 2020
2 parents 66803fd + 558c39b commit 074b461
Show file tree
Hide file tree
Showing 26 changed files with 557 additions and 100 deletions.
75 changes: 39 additions & 36 deletions Smartway.UiComponent.Sample/Buttons/Button.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,44 @@
xmlns:Buttons="clr-namespace:Smartway.UiComponent.Buttons;assembly=Smartway.UiComponent"
x:Class="Smartway.UiComponent.Sample.Buttons.Button">
<ContentPage.Content>
<StackLayout>
<Label Text="Primary Button"/>
<Buttons:Button Text="Primary"
Status="Primary"
Size="Small"
Activated="false"/>
<Buttons:Button Text="Primary"
Status="Primary"
Size="Small"
Activated="true"/>
<Buttons:Button Text="Primary"
Status="Primary"
Size="Large"
Activated="false"/>
<Buttons:Button Text="Primary"
Status="Primary"
Size="Large"
Activated="true"/>
<Label Text="Warning Button"/>
<Buttons:Button Text="Warning"
Status="Warning"
Size="Small"
Activated="false"/>
<Buttons:Button Text="Warning"
Status="Warning"
Size="Small"
Activated="True"/>
<Buttons:Button Text="Warning"
Status="Warning"
Size="Large"
Activated="true"/>
<Buttons:Button Text="Warning"
Status="Warning"
Size="Large"
Activated="true"/>
</StackLayout>
<ScrollView>
<StackLayout>
<Label Text="Primary Button"/>
<Buttons:Button Text="Primary"
Status="Primary"
Size="Small"
Activated="false"/>
<Buttons:Button Text="Primary"
Status="Primary"
Size="Small"
Activated="true"/>
<Buttons:Button Text="Primary"
Status="Primary"
Size="Large"
Activated="false"/>
<Buttons:Button Text="Primary"
Status="Primary"
Size="Large"
Activated="true"/>
<Label Text="Warning Button"/>
<Buttons:Button Text="Warning"
Status="Warning"
Size="Small"
Activated="false"/>
<Buttons:Button Text="Warning"
Status="Warning"
Size="Small"
Activated="True"/>
<Buttons:Button Text="Warning"
Status="Warning"
Size="Large"
Activated="true"/>
<Buttons:Button Text="Warning"
Status="Warning"
Size="Large"
Activated="true"/>
<Buttons:ScanButton Command="{Binding ScanCommand}"/>
</StackLayout>
</ScrollView>
</ContentPage.Content>
</ContentPage>
17 changes: 17 additions & 0 deletions Smartway.UiComponent.Sample/Buttons/ButtonViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Input;
using Xamarin.Forms;

namespace Smartway.UiComponent.Sample.Buttons
{
public class ButtonViewModel : ViewModel
{
public ICommand ScanCommand => new Command((param) =>
{
var message = "Scan is tapped";
DependencyService.Get<INotifyMessage>().ShortAlert(message);
});
}
}
21 changes: 16 additions & 5 deletions Smartway.UiComponent.Sample/DummyArticle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,23 @@ class DummyArticle
public bool IsOnShortage { get; set; }
public string Price { get; set; }
public string Gencode { get; set; }
public ICommand NavigationCommand => new Command((param) => {
var message = "Tapped on " + param.ToString();
DependencyService.Get<INotifyMessage>().ShortAlert(message);
});
public ICommand NavigationCommand
{
get =>
new Command((param) =>
{
var message = "Tapped on " + param.ToString();
DependencyService.Get<INotifyMessage>().ShortAlert(message);
});
set => throw new NotImplementedException();
}

public object NavigationParameter { get; set; }
public string Status { get; set; }
public DateTime ShortageAt => DateTime.Today;
public DateTime? OnShortageSince
{
get => DateTime.Today;
set => throw new NotImplementedException();
}
}
}
25 changes: 11 additions & 14 deletions Smartway.UiComponent.Sample/ExpanderCard/ExpanderCardSample.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,26 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:cards="clr-namespace:Smartway.UiComponent.Cards;assembly=Smartway.UiComponent"
xmlns:layouts="clr-namespace:Smartway.UiComponent.Layouts;assembly=Smartway.UiComponent"
x:Class="Smartway.UiComponent.Sample.ExpanderCard.ExpanderCardSample">
xmlns:viewModels="clr-namespace:Smartway.UiComponent.Sample.ExpanderCard.ViewModels;assembly=Smartway.UiComponent.Sample"
xmlns:cardLists="clr-namespace:Smartway.UiComponent.CardLists;assembly=Smartway.UiComponent"
x:Class="Smartway.UiComponent.Sample.ExpanderCard.ExpanderCardSample"
x:DataType="viewModels:ExpanderCardSampleViewModel">
<ContentPage.Content>
<ScrollView>
<StackLayout>
<cards:ExpanderCard Title="basic title" Counter="1">
</cards:ExpanderCard>
<cards:ExpanderCard Title="basic title With Content" Counter="123">
<cards:ExpanderCard.ExpanderContent>
<Label>Test Content</Label>
</cards:ExpanderCard.ExpanderContent>
<cards:ExpanderCard.ExpanderTemplate>
<DataTemplate>
<Label>Test Content</Label>
</DataTemplate>
</cards:ExpanderCard.ExpanderTemplate>
</cards:ExpanderCard>
<layouts:SectionSheet>
<Label Text="In Section Sheet"></Label>
<cards:ExpanderCard Title="warning title" Counter="233" Status="warning">
<cards:ExpanderCard.ExpanderContent>
<StackLayout>
<cards:ArticleCard Label="Escargot" Gencode="123456" Price="666" IsMultilocation="true"/>
<cards:ArticleCard Label="Escargot 1" Gencode="123456" Price="666" IsMultilocation="true"/>
<cards:ArticleCard Label="Escargot 2" Gencode="123456" Price="666" IsMultilocation="true"/>
<cards:ArticleCard Label="Escargot 3" Gencode="123456" Price="666" IsMultilocation="true"/>
</StackLayout>
</cards:ExpanderCard.ExpanderContent>
</cards:ExpanderCard>
<cardLists:ExpanderCardList Title="Expander 50 items " Status="warning" SourceList="{Binding Articles}"/>
<cardLists:ExpanderCardList Title="Expander lazy loading 50 items" SourceList="{Binding Articles}" LoadAsync="True"/>
</layouts:SectionSheet>
</StackLayout>
</ScrollView>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Collections.ObjectModel;
using Smartway.UiComponent.Cards;

namespace Smartway.UiComponent.Sample.ExpanderCard.ViewModels
{
class ExpanderCardSampleViewModel : ViewModel
{
public ExpanderCardSampleViewModel()
{
Articles = new ObservableCollection<object>();
for (var i = 0; i < 50; i++)
{
Articles.Add(new DummyArticle
{
Label = "Article "+i,
IsMultilocation = true,
IsOnShortage = true,
Price = "0,3€",
Gencode = "1234567891234",
NavigationParameter = "Article 5"
});
}
}

public ObservableCollection<object> Articles { get; set; }
}
}
18 changes: 18 additions & 0 deletions Smartway.UiComponent.Sample/Layouts/LayoutsSample.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?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:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:layouts="clr-namespace:Smartway.UiComponent.Layouts;assembly=Smartway.UiComponent"
mc:Ignorable="d"
x:Class="Smartway.UiComponent.Sample.Layouts.LayoutsSample">
<ContentPage.Content>
<layouts:ScannableLayout>
<layouts:ScannableLayout.LayoutContent>
<Label Text="Example layout avec bouton scan sur la page"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
</layouts:ScannableLayout.LayoutContent>
</layouts:ScannableLayout>
</ContentPage.Content>
</ContentPage>
20 changes: 20 additions & 0 deletions Smartway.UiComponent.Sample/Layouts/LayoutsSample.xaml.cs
Original file line number Diff line number Diff line change
@@ -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 Smartway.UiComponent.Sample.Layouts
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class LayoutsSample : ContentPage
{
public LayoutsSample()
{
InitializeComponent();
}
}
}
27 changes: 15 additions & 12 deletions Smartway.UiComponent.Sample/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@
x:Class="Smartway.UiComponent.Sample.MainPage"
x:DataType="sample:MainPageViewModel"
x:Name="Self">
<StackLayout>
<Button x:Name="SwitchThemeBtn" Text="Switch ALL APP Theme" Command="{Binding Source={x:Reference Self}, Path=SwitchTheme}"/>
<Button Text="BasicComponents" Command="{Binding BasicComponents}"/>
<Button Text="SectionForm" Command="{Binding SectionForm}"/>
<Button Text="Indicators" Command="{Binding Indicators}"/>
<Button Text="SectionSheet" Command="{Binding SectionSheet}"/>
<Button Text="ExpanderCard" Command="{Binding ExpanderCard}"/>
<Button Text="TopAppBar" Command="{Binding TopAppBar}"/>
<Button Text="Separator" Command="{Binding Separators}" />
<Button Text="Button" Command="{Binding Button}"/>
<Button Text="Inputs" Command="{Binding Inputs}"/>
</StackLayout>
<ScrollView>
<StackLayout>
<Button x:Name="SwitchThemeBtn" Text="Switch ALL APP Theme" Command="{Binding Source={x:Reference Self}, Path=SwitchTheme}"/>
<Button Text="BasicComponents" Command="{Binding BasicComponents}"/>
<Button Text="SectionForm" Command="{Binding SectionForm}"/>
<Button Text="Indicators" Command="{Binding Indicators}"/>
<Button Text="SectionSheet" Command="{Binding SectionSheet}"/>
<Button Text="ExpanderCard" Command="{Binding ExpanderCard}"/>
<Button Text="TopAppBar" Command="{Binding TopAppBar}"/>
<Button Text="Separator" Command="{Binding Separators}" />
<Button Text="Button" Command="{Binding Button}"/>
<Button Text="Inputs" Command="{Binding Inputs}"/>
<Button Text="Layouts" Command="{Binding Layouts}"/>
</StackLayout>
</ScrollView>
</ContentPage>
10 changes: 8 additions & 2 deletions Smartway.UiComponent.Sample/MainPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Smartway.UiComponent.Sample.Basics;
using Smartway.UiComponent.Sample.ExpanderCard;
using Smartway.UiComponent.Sample.Buttons;
using Smartway.UiComponent.Sample.ExpanderCard.ViewModels;
using Smartway.UiComponent.Sample.Indicators.ViewModels;
using Smartway.UiComponent.Sample.Inputs.ViewModels;
using Smartway.UiComponent.Sample.SectionSheet.ViewModels;
Expand Down Expand Up @@ -36,7 +37,7 @@ public class MainPageViewModel : ViewModel

public ICommand ExpanderCard => new Command(async () =>
{
await NavigateTo(new ExpanderCardSample());
await NavigateTo(new ExpanderCardSample{ BindingContext = new ExpanderCardSampleViewModel()});
});

public ICommand BasicComponents => new Command(async () =>
Expand All @@ -51,12 +52,17 @@ public class MainPageViewModel : ViewModel

public ICommand Button => new Command(async () =>
{
await NavigateTo(new Buttons.Button());
await NavigateTo(new Buttons.Button{BindingContext = new ButtonViewModel()});
});

public ICommand Inputs => new Command(async () =>
{
await NavigateTo(new Inputs.Views.Inputs{ BindingContext = new InputsViewModel()});
});

public ICommand Layouts => new Command(async () =>
{
await NavigateTo(new Layouts.LayoutsSample());
});
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace Smartway.UiComponent.Sample.SectionSheet.ViewModels
{
class SectionSheetSampleViewModel: ViewModel
{
public List<object> Articles => new List<object>
public ObservableCollection<object> Articles => new ObservableCollection<object>
{
new DummyArticle
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
<EmbeddedResource Update="Basics\BasicComponents.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Layouts\LayoutsSample.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="SectionSheet\Views\SectionSheetSample.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
Expand Down
17 changes: 17 additions & 0 deletions Smartway.UiComponent/Buttons/ScanButton.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:utils="clr-namespace:Smartway.UiComponent.Utils;assembly=Smartway.UiComponent"
mc:Ignorable="d"
x:Class="Smartway.UiComponent.Buttons.ScanButton"
x:Name="Self"
>
<Frame CornerRadius="32" BackgroundColor="#27304A">
<Frame.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Source={Reference Self}, Path=Command}"></TapGestureRecognizer>
</Frame.GestureRecognizers>
<Image Source="{utils:ImageResource Source=Smartway.UiComponent.Resources.Images.icon_scan.png}" />
</Frame>
</ContentView>
23 changes: 23 additions & 0 deletions Smartway.UiComponent/Buttons/ScanButton.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Windows.Input;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace Smartway.UiComponent.Buttons
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ScanButton
{
public static readonly BindableProperty CommandProperty = BindableProperty.Create(nameof(Command), typeof(ICommand), typeof(ScanButton));

public ScanButton()
{
InitializeComponent();
}

public ICommand Command
{
get => (ICommand)GetValue(CommandProperty);
set => SetValue(CommandProperty, value);
}
}
}
2 changes: 1 addition & 1 deletion Smartway.UiComponent/CardLists/ArticleCardList.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Gencode="{Binding Gencode}"
NavigationCommand="{Binding NavigationCommand}"
NavigationParameter="{Binding NavigationParameter}"
ShortageAt="{Binding ShortageAt}"
OnShortageSince="{Binding OnShortageSince}"
/>
</StackLayout>
</DataTemplate>
Expand Down
Loading

0 comments on commit 074b461

Please sign in to comment.