Skip to content

Commit 7cfb705

Browse files
Merge pull request #1 from JayashreeRavishankar/master
Customize the appearance of EmptyView using EmptyView Template
2 parents f9b5330 + b25b108 commit 7cfb705

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1536
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31611.283
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EmptyViewTemplate", "EmptyViewTemplate\EmptyViewTemplate.csproj", "{26B1E1B6-778D-48C3-B37C-52CC0F057C42}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{26B1E1B6-778D-48C3-B37C-52CC0F057C42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{26B1E1B6-778D-48C3-B37C-52CC0F057C42}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{26B1E1B6-778D-48C3-B37C-52CC0F057C42}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17+
{26B1E1B6-778D-48C3-B37C-52CC0F057C42}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{26B1E1B6-778D-48C3-B37C-52CC0F057C42}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{26B1E1B6-778D-48C3-B37C-52CC0F057C42}.Release|Any CPU.Deploy.0 = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
GlobalSection(ExtensibilityGlobals) = postSolution
25+
SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572}
26+
EndGlobalSection
27+
EndGlobal
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version = "1.0" encoding = "UTF-8" ?>
2+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:EmptyViewTemplate"
5+
x:Class="EmptyViewTemplate.App">
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
<ResourceDictionary.MergedDictionaries>
9+
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
10+
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
11+
</ResourceDictionary.MergedDictionaries>
12+
</ResourceDictionary>
13+
</Application.Resources>
14+
</Application>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace EmptyViewTemplate;
2+
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
9+
MainPage = new AppShell();
10+
}
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Shell
3+
x:Class="EmptyViewTemplate.AppShell"
4+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6+
xmlns:local="clr-namespace:EmptyViewTemplate"
7+
Shell.FlyoutBehavior="Disabled">
8+
9+
<ShellContent
10+
Title="Home"
11+
ContentTemplate="{DataTemplate local:MainPage}"
12+
Route="MainPage" />
13+
14+
</Shell>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace EmptyViewTemplate;
2+
3+
public partial class AppShell : Shell
4+
{
5+
public AppShell()
6+
{
7+
InitializeComponent();
8+
}
9+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
6+
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
7+
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>EmptyViewTemplate</RootNamespace>
10+
<UseMaui>true</UseMaui>
11+
<SingleProject>true</SingleProject>
12+
<ImplicitUsings>enable</ImplicitUsings>
13+
14+
<!-- Display name -->
15+
<ApplicationTitle>EmptyViewTemplate</ApplicationTitle>
16+
17+
<!-- App Identifier -->
18+
<ApplicationId>com.companyname.emptyviewtemplate</ApplicationId>
19+
<ApplicationIdGuid>5B0727E8-4F32-4E4C-918E-C22B07025459</ApplicationIdGuid>
20+
21+
<!-- Versions -->
22+
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
23+
<ApplicationVersion>1</ApplicationVersion>
24+
25+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
26+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
27+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
28+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
29+
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
30+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
31+
</PropertyGroup>
32+
33+
<ItemGroup>
34+
<!-- App Icon -->
35+
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
36+
37+
<!-- Splash Screen -->
38+
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
39+
40+
<!-- Images -->
41+
<MauiImage Include="Resources\Images\*" />
42+
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
43+
44+
<!-- Custom Fonts -->
45+
<MauiFont Include="Resources\Fonts\*" />
46+
47+
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
48+
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
49+
</ItemGroup>
50+
51+
<ItemGroup>
52+
<None Remove="Resources\Fonts\ListViewFontIcons.ttf" />
53+
<None Remove="Resources\Fonts\Roboto-Medium.ttf" />
54+
<None Remove="Resources\Fonts\Roboto-Regular.ttf" />
55+
<None Remove="Resources\Images\bags.png" />
56+
<None Remove="Resources\Images\camera.png" />
57+
<None Remove="Resources\Images\cameraaccessories.png" />
58+
<None Remove="Resources\Images\computeraccessories.png" />
59+
<None Remove="Resources\Images\coolingglasses.png" />
60+
<None Remove="Resources\Images\cosmetics.png" />
61+
<None Remove="Resources\Images\crocs.png" />
62+
<None Remove="Resources\Images\desktops.png" />
63+
<None Remove="Resources\Images\headsets.png" />
64+
<None Remove="Resources\Images\jewelries.png" />
65+
<None Remove="Resources\Images\laptops.png" />
66+
<None Remove="Resources\Images\memorycards.png" />
67+
<None Remove="Resources\Images\mobiles.png" />
68+
<None Remove="Resources\Images\monitors.png" />
69+
<None Remove="Resources\Images\musical.png" />
70+
<None Remove="Resources\Images\pendrives.png" />
71+
<None Remove="Resources\Images\poweraccessories.png" />
72+
<None Remove="Resources\Images\printers.png" />
73+
<None Remove="Resources\Images\router.png" />
74+
<None Remove="Resources\Images\shoes.png" />
75+
<None Remove="Resources\Images\smartwatches.png" />
76+
<None Remove="Resources\Images\soundbars.png" />
77+
<None Remove="Resources\Images\storagedevices.png" />
78+
<None Remove="Resources\Images\telephone.png" />
79+
<None Remove="Resources\Images\watchimage.png" />
80+
</ItemGroup>
81+
82+
<ItemGroup>
83+
<PackageReference Include="Syncfusion.Maui.Core" Version="*" />
84+
<PackageReference Include="Syncfusion.Maui.DataSource" Version="*" />
85+
<PackageReference Include="Syncfusion.Maui.GridCommon" Version="*" />
86+
<PackageReference Include="Syncfusion.Maui.ListView" Version="*" />
87+
</ItemGroup>
88+
89+
</Project>
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
using Microsoft.Maui.Controls;
2+
using Syncfusion.Maui.DataSource;
3+
4+
5+
namespace EmptyViewTemplate
6+
{
7+
#region SortingFilteringBehavior
8+
9+
public class SfListViewSortingFilteringBehavior : Behavior<ContentPage>
10+
{
11+
#region Fields
12+
13+
private Syncfusion.Maui.ListView.SfListView ListView;
14+
private SortingFilteringViewModel sortingFilteringViewModel;
15+
private Grid sortImageParent;
16+
private SearchBar searchBar = null;
17+
private Grid headerGrid;
18+
19+
#endregion
20+
21+
private void InitialSorting()
22+
{
23+
sortingFilteringViewModel.SortingOptions = ListViewSortOptions.Ascending;
24+
ListView.DataSource.SortDescriptors.Clear();
25+
if (sortingFilteringViewModel.SortingOptions != ListViewSortOptions.None)
26+
{
27+
ListView.DataSource.SortDescriptors.Add(new SortDescriptor()
28+
{
29+
PropertyName = "Quantity",
30+
Direction = sortingFilteringViewModel.SortingOptions == ListViewSortOptions.Ascending ? ListSortDirection.Ascending : ListSortDirection.Descending
31+
});
32+
}
33+
ListView.RefreshView();
34+
}
35+
#region Overrides
36+
protected override void OnAttachedTo(ContentPage bindable)
37+
{
38+
ListView = bindable.FindByName<Syncfusion.Maui.ListView.SfListView>("listView");
39+
sortingFilteringViewModel = bindable.FindByName<SortingFilteringViewModel>("viewModel");
40+
ListView.ItemsSource = sortingFilteringViewModel.Items;
41+
42+
headerGrid = bindable.FindByName<Grid>("headerGrid");
43+
headerGrid.BindingContext = sortingFilteringViewModel;
44+
45+
sortImageParent = bindable.FindByName<Grid>("sortImageParent");
46+
var SortImageTapped = new TapGestureRecognizer() { Command = new Command(SortImageTapped_Tapped) };
47+
sortImageParent.GestureRecognizers.Add(SortImageTapped);
48+
49+
searchBar = bindable.FindByName<SearchBar>("filterText");
50+
searchBar.TextChanged += SearchBar_TextChanged;
51+
InitialSorting();
52+
base.OnAttachedTo(bindable);
53+
}
54+
55+
protected override void OnDetachingFrom(ContentPage bindable)
56+
{
57+
ListView = null;
58+
sortImageParent = null;
59+
searchBar = null;
60+
searchBar.TextChanged -= SearchBar_TextChanged;
61+
base.OnDetachingFrom(bindable);
62+
}
63+
64+
#endregion
65+
66+
#region Events
67+
private void SearchBar_TextChanged(object sender, TextChangedEventArgs e)
68+
{
69+
searchBar = (sender as SearchBar);
70+
if (ListView.DataSource != null)
71+
{
72+
ListView.DataSource.Filter = FilterItems;
73+
ListView.DataSource.RefreshFilter();
74+
}
75+
ListView.RefreshView();
76+
}
77+
78+
private void SortImageTapped_Tapped()
79+
{
80+
if (sortingFilteringViewModel.SortingOptions == ListViewSortOptions.Descending)
81+
sortingFilteringViewModel.SortingOptions = ListViewSortOptions.Ascending;
82+
else if (sortingFilteringViewModel.SortingOptions == ListViewSortOptions.None)
83+
sortingFilteringViewModel.SortingOptions = ListViewSortOptions.Ascending;
84+
else if (sortingFilteringViewModel.SortingOptions == ListViewSortOptions.Ascending)
85+
sortingFilteringViewModel.SortingOptions = ListViewSortOptions.Descending;
86+
87+
ListView.DataSource.SortDescriptors.Clear();
88+
if (sortingFilteringViewModel.SortingOptions != ListViewSortOptions.None)
89+
{
90+
ListView.DataSource.SortDescriptors.Add(new SortDescriptor()
91+
{
92+
PropertyName = "Quantity",
93+
Direction = sortingFilteringViewModel.SortingOptions == ListViewSortOptions.Ascending ? ListSortDirection.Ascending : ListSortDirection.Descending
94+
});
95+
}
96+
ListView.RefreshView();
97+
}
98+
99+
#endregion
100+
101+
#region Methods
102+
private bool FilterItems(object obj)
103+
{
104+
if (searchBar == null || searchBar.Text == null)
105+
return true;
106+
107+
var productInfo = obj as ProductInfo;
108+
return (productInfo.ProductName.ToLower().Contains(searchBar.Text.ToLower()) || (productInfo.Quantity.ToString()).ToLower().Contains(searchBar.Text.ToLower()));
109+
}
110+
111+
#endregion
112+
}
113+
114+
#endregion
115+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Microsoft.Maui.Controls;
2+
using System;
3+
using System.Globalization;
4+
5+
6+
namespace EmptyViewTemplate
7+
{
8+
public class ListViewBoolToSortImageConverter : IValueConverter
9+
{
10+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11+
{
12+
var sortOptions = (ListViewSortOptions)value;
13+
if (sortOptions == ListViewSortOptions.Ascending)
14+
return "\ue709";
15+
else if (sortOptions == ListViewSortOptions.Descending)
16+
return "\ue719";
17+
else
18+
return "\ue709";
19+
}
20+
21+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
22+
{
23+
throw new NotImplementedException();
24+
}
25+
}
26+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace EmptyViewTemplate
8+
{
9+
public class FilterItem : BindableObject
10+
{
11+
public static readonly BindableProperty FilterProperty = BindableProperty.Create(nameof(Filter), typeof(string), typeof(FilterItem), null);
12+
13+
public string Filter
14+
{
15+
get { return (string)GetValue(FilterProperty); }
16+
set { SetValue(FilterProperty, value); }
17+
}
18+
}
19+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Syncfusion.Maui.Core.Hosting;
2+
namespace EmptyViewTemplate;
3+
4+
public static class MauiProgram
5+
{
6+
public static MauiApp CreateMauiApp()
7+
{
8+
var builder = MauiApp.CreateBuilder();
9+
builder
10+
.UseMauiApp<App>()
11+
.ConfigureFonts(fonts =>
12+
{
13+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
14+
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
15+
fonts.AddFont("Roboto-Medium.ttf", "Roboto-Medium");
16+
fonts.AddFont("Roboto-Regular.ttf", "Roboto-Regular");
17+
});
18+
builder.ConfigureSyncfusionCore();
19+
return builder.Build();
20+
}
21+
}

0 commit comments

Comments
 (0)