Skip to content

Commit 8f8222d

Browse files
committed
1. In catalog model the MainCategory property name is renamed as Name
2. In category tile/List page, catalog tile/list page item is tapped the selected item sending is by using behavior. So SfListViewTapBehavior is newly added. 3. In DetailPage the rotator template is set.
1 parent 6bddcca commit 8f8222d

File tree

14 files changed

+219
-49
lines changed

14 files changed

+219
-49
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using System.Threading.Tasks;
5+
using Xamarin.Forms;
6+
7+
namespace EssentialUIKit.Behaviors.ECommerce
8+
{
9+
/// <summary>
10+
/// This class extends the behavior of the frame to invoke a command when an event occurs.
11+
/// </summary>
12+
public class FrameTapBehavior : Behavior<Frame>
13+
{
14+
#region Fields
15+
16+
TapGestureRecognizer tapGestureRecognizer;
17+
18+
#endregion
19+
20+
#region Properties
21+
22+
/// <summary>
23+
/// Gets or sets the CommandParameterProperty, and it is a bindable property.
24+
/// </summary>
25+
public static readonly BindableProperty CommandParameterProperty =
26+
BindableProperty.Create("CommandParameter", typeof(object), typeof(FrameTapBehavior));
27+
28+
/// <summary>
29+
/// Gets or sets the CommandParameter.
30+
/// </summary>
31+
public object CommandParameter
32+
{
33+
get { return GetValue(CommandParameterProperty); }
34+
set { this.SetValue(CommandParameterProperty, value); }
35+
}
36+
37+
#endregion
38+
39+
#region Methods
40+
41+
/// <summary>
42+
/// Invoked when added frame to the page.
43+
/// </summary>
44+
/// <param name="bindableFrame">The Frame</param>
45+
protected override void OnAttachedTo(Frame bindableFrame)
46+
{
47+
base.OnAttachedTo(bindableFrame);
48+
tapGestureRecognizer = new TapGestureRecognizer();
49+
tapGestureRecognizer.Tapped += TapGestureRecognizer_Tapped;
50+
bindableFrame.GestureRecognizers.Add(tapGestureRecognizer);
51+
}
52+
53+
/// <summary>
54+
/// Invoked when frame is tapped.
55+
/// </summary>
56+
/// <param name="sender">The sender</param>
57+
/// <param name="e">EventArgs</param>
58+
private async void TapGestureRecognizer_Tapped(object sender, EventArgs e)
59+
{
60+
Application.Current.Resources.TryGetValue("Gray-200", out var retVal);
61+
((Frame)sender).BackgroundColor = (Color)retVal;
62+
63+
await Task.Delay(100);
64+
65+
((Frame)sender).BackgroundColor = Color.Transparent;
66+
}
67+
68+
/// <summary>
69+
/// Invoked when exit from the view
70+
/// </summary>
71+
/// <param name="bindableFrame">The Frame</param>
72+
protected override void OnDetachingFrom(Frame bindableFrame)
73+
{
74+
base.OnDetachingFrom(bindableFrame);
75+
tapGestureRecognizer.Tapped -= TapGestureRecognizer_Tapped;
76+
}
77+
78+
#endregion
79+
}
80+
81+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using Syncfusion.ListView.XForms;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
using System.Windows.Input;
6+
using Xamarin.Forms;
7+
8+
namespace EssentialUIKit.Behaviors
9+
{
10+
/// <summary>
11+
/// This class extends the behavior of the SfListView to invoke a command when an event occurs.
12+
/// </summary>
13+
public class SfListViewTapBehavior : Behavior<SfListView>
14+
{
15+
#region Properties
16+
17+
/// <summary>
18+
/// Gets or sets the CommandProperty, and it is a bindable property.
19+
/// </summary>
20+
public static readonly BindableProperty CommandProperty =
21+
BindableProperty.Create("Command", typeof(ICommand), typeof(SfListViewTapBehavior));
22+
23+
/// <summary>
24+
/// Gets or sets the Command.
25+
/// </summary>
26+
public ICommand Command
27+
{
28+
get { return (ICommand)GetValue(CommandProperty); }
29+
set { this.SetValue(CommandProperty, value); }
30+
}
31+
32+
#endregion
33+
34+
#region Method
35+
36+
/// <summary>
37+
/// Invoked when added sflistview to the page.
38+
/// </summary>
39+
/// <param name="bindableListView">The SfListView</param>
40+
protected override void OnAttachedTo(SfListView bindableListView)
41+
{
42+
base.OnAttachedTo(bindableListView);
43+
bindableListView.ItemTapped += BindableListView_ItemTapped;
44+
}
45+
46+
/// <summary>
47+
/// Invoked when tapping the listview item.
48+
/// </summary>
49+
/// <param name="sender">The Sender</param>
50+
/// <param name="e">ItemTappedEventArgs</param>
51+
private void BindableListView_ItemTapped(object sender, Syncfusion.ListView.XForms.ItemTappedEventArgs e)
52+
{
53+
if (this.Command == null)
54+
return;
55+
if (this.Command.CanExecute(e.ItemData))
56+
this.Command.Execute((e.ItemData));
57+
}
58+
59+
/// <summary>
60+
/// Invoked when exit from the page.
61+
/// </summary>
62+
/// <param name="bindableListView">The SfListView</param>
63+
protected override void OnDetachingFrom(SfListView bindableListView)
64+
{
65+
base.OnDetachingFrom(bindableListView);
66+
bindableListView.ItemTapped -= BindableListView_ItemTapped;
67+
}
68+
69+
#endregion
70+
}
71+
72+
}

EssentialUIKit/Data/ecommerce.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"categories": [
9898
{
9999
"icon": "Electronics.png",
100-
"maincategory": "Electronics",
100+
"name": "Electronics",
101101
"subcategories": [
102102

103103
"Laptops",
@@ -110,7 +110,7 @@
110110
},
111111
{
112112
"icon": "Fashion.png",
113-
"maincategory": "Fashion",
113+
"name": "Fashion",
114114
"subcategories": [
115115

116116
"Shirts",
@@ -123,7 +123,7 @@
123123
},
124124
{
125125
"icon": "HomeFurniture.png",
126-
"maincategory": "Home and Furniture",
126+
"name": "Home and Furniture",
127127
"subcategories": [
128128

129129
"Diwans",
@@ -134,7 +134,7 @@
134134
},
135135
{
136136
"icon": "PersonalCare.png",
137-
"maincategory": "Personal Care",
137+
"name": "Personal Care",
138138
"subcategories": [
139139

140140
"Laptops",
@@ -147,7 +147,7 @@
147147
},
148148
{
149149
"icon": "Books.png",
150-
"maincategory": "Books",
150+
"name": "Books",
151151
"subcategories": [
152152

153153
"Laptops",
@@ -160,7 +160,7 @@
160160
},
161161
{
162162
"icon": "Clothes.png",
163-
"maincategory": "Clothes",
163+
"name": "Clothes",
164164
"subcategories": [
165165

166166
"Laptops",
@@ -173,7 +173,7 @@
173173
},
174174
{
175175
"icon": "MobilePhones.png",
176-
"maincategory": "Mobile Phones",
176+
"name": "Mobile Phones",
177177
"subcategories": [
178178

179179
"Laptops",
@@ -186,7 +186,7 @@
186186
},
187187
{
188188
"icon": "Accessories.png",
189-
"maincategory": "Accessories",
189+
"name": "Accessories",
190190
"subcategories": [
191191

192192
"Laptops",
@@ -199,7 +199,7 @@
199199
},
200200
{
201201
"icon": "Toys.png",
202-
"maincategory": "Toys and Baby",
202+
"name": "Toys and Baby",
203203
"subcategories": [
204204

205205
"Laptops",

EssentialUIKit/Models/Ecommerce/Category.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ public string Icon
2525
}
2626

2727
/// <summary>
28-
/// Gets or sets the property that has been bound with a label in SfExpander header, which displays the main category.
28+
/// Gets or sets the property that has been bound with a label in SfExpander header, which displays the category name.
2929
/// </summary>
30-
[DataMember(Name = "maincategory")]
31-
public string MainCategory { get; set; }
30+
[DataMember(Name = "name")]
31+
public string Name { get; set; }
3232

3333
/// <summary>
3434
/// Gets or sets the property that has been bound with a label in SfExpander content, which displays the sub category.

EssentialUIKit/ViewModels/Ecommerce/CatalogPageViewModel.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public CatalogPageViewModel()
5252
{
5353
new Category
5454
{
55-
MainCategory = "Gender",
55+
Name = "Gender",
5656
SubCategories = new List<string>
5757
{
5858
"Men",
@@ -61,7 +61,7 @@ public CatalogPageViewModel()
6161
},
6262
new Category
6363
{
64-
MainCategory = "Brand",
64+
Name = "Brand",
6565
SubCategories = new List<string>
6666
{
6767
"Brand A",
@@ -70,7 +70,7 @@ public CatalogPageViewModel()
7070
},
7171
new Category
7272
{
73-
MainCategory = "Categories",
73+
Name = "Categories",
7474
SubCategories = new List<string>
7575
{
7676
"Category A",
@@ -79,7 +79,7 @@ public CatalogPageViewModel()
7979
},
8080
new Category
8181
{
82-
MainCategory = "Color",
82+
Name = "Color",
8383
SubCategories = new List<string>
8484
{
8585
"Maroon",
@@ -88,7 +88,7 @@ public CatalogPageViewModel()
8888
},
8989
new Category
9090
{
91-
MainCategory = "Price",
91+
Name = "Price",
9292
SubCategories = new List<string>
9393
{
9494
"Above 3000",
@@ -98,31 +98,31 @@ public CatalogPageViewModel()
9898
},
9999
new Category
100100
{
101-
MainCategory = "Size",
101+
Name = "Size",
102102
SubCategories = new List<string>
103103
{
104104
"S", "M", "L", "XL", "XXL"
105105
}
106106
},
107107
new Category
108108
{
109-
MainCategory = "Patterns",
109+
Name = "Patterns",
110110
SubCategories = new List<string>
111111
{
112112
"Pattern 1", "Pattern 2"
113113
}
114114
},
115115
new Category
116116
{
117-
MainCategory = "Offers",
117+
Name = "Offers",
118118
SubCategories = new List<string>
119119
{
120120
"Buy 1 Get 1", "Buy 1 Get 2"
121121
}
122122
},
123123
new Category
124124
{
125-
MainCategory = "Coupons",
125+
Name = "Coupons",
126126
SubCategories = new List<string>
127127
{
128128
"Coupon 1", "Coupon 2"

EssentialUIKit/ViewModels/Ecommerce/CategoryPageViewModel.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,7 @@ private static void ScrollToEndClicked(object attachedObject)
205205
/// <param name="obj">The Object</param>
206206
private static async void CategorySelected(object obj)
207207
{
208-
Application.Current.Resources.TryGetValue("Gray-F0", out var retVal);
209-
((Frame) obj).BackgroundColor = (Color) retVal;
210-
211-
await Task.Delay(100);
212-
213-
((Frame) obj).BackgroundColor = Color.Transparent;
208+
//Do Something
214209
}
215210

216211
/// <summary>

0 commit comments

Comments
 (0)