/
ArticleTilePage.xaml
142 lines (125 loc) · 6.8 KB
/
ArticleTilePage.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
x:Class="EssentialUIKit.Views.Catalog.ArticleTilePage"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:border="clr-namespace:Syncfusion.XForms.Border;assembly=Syncfusion.Core.XForms"
xmlns:buttons="clr-namespace:Syncfusion.XForms.Buttons;assembly=Syncfusion.Buttons.XForms"
xmlns:controls="clr-namespace:EssentialUIKit.Controls"
xmlns:converter="clr-namespace:EssentialUIKit.Converters"
xmlns:listView="clr-namespace:Syncfusion.ListView.XForms;assembly=Syncfusion.SfListView.XForms"
xmlns:rotator="clr-namespace:Syncfusion.SfRotator.XForms;assembly=Syncfusion.SfRotator.XForms"
xmlns:template="clr-namespace:EssentialUIKit.Views.Templates"
x:Name="articleTilePage"
BackgroundColor="{DynamicResource Gray-Bg}"
NavigationPage.HasNavigationBar="False">
<ContentPage.Resources>
<ResourceDictionary>
<converter:BooleanToStringConverter x:Key="BoolToStringConverter" />
<DataTemplate x:Key="HorizontalArticleView">
<template:ArticleTileTemplate Margin="16" ParentBindingContext="{Binding Path=BindingContext, Source={x:Reference articleTilePage}}" />
</DataTemplate>
<DataTemplate x:Key="HeaderView">
<StackLayout Spacing="8">
<!-- Label for featured stories -->
<Label
Margin="16,8"
FontSize="12"
HorizontalOptions="Start"
Style="{StaticResource TitleLabelStyle}"
Text="FEATURED STORIES"
TextColor="{DynamicResource Gray-800}" />
<!-- Rotator view -->
<rotator:SfRotator
x:Name="Rotator"
BackgroundColor="#FFFFFF}"
DotPlacement="Default"
DotsBorderColor="Transparent"
EnableLooping="False"
HeightRequest="210"
HorizontalOptions="Center"
ItemsSource="{Binding FeaturedStories}"
NavigationStripMode="Dots"
SelectedDotColor="{DynamicResource PrimaryColor}"
UnselectedDotColor="{DynamicResource Gray-White}"
VerticalOptions="Start">
<rotator:SfRotator.ItemTemplate>
<DataTemplate>
<Grid x:Name="Grid">
<Image
Aspect="AspectFill"
BackgroundColor="{DynamicResource Gray-200}"
HeightRequest="210"
Source="{Binding ImagePath}" />
<border:SfBorder
BackgroundColor="{DynamicResource PrimaryColor}"
BorderWidth="0"
HorizontalOptions="Start"
Opacity="0.8"
VerticalOptions="Center">
<Label
Margin="16"
FontFamily="Montserrat-Bold"
FontSize="20"
LineBreakMode="TailTruncation"
LineHeight="{OnPlatform Default=-1,
Android=1.25}"
MaxLines="2"
Text="{Binding Name}"
TextColor="{DynamicResource Gray-White}"
WidthRequest="200" />
</border:SfBorder>
<Grid.GestureRecognizers>
<TapGestureRecognizer Command="{Binding BindingContext.FeatureStoriesCommand, Source={x:Reference Rotator}}" CommandParameter="{Binding BindingContext, Source={x:Reference Grid}}" />
</Grid.GestureRecognizers>
</Grid>
</DataTemplate>
</rotator:SfRotator.ItemTemplate>
</rotator:SfRotator>
<!-- Label for Latest stories -->
<Label
Margin="16,16,0,0"
FontSize="12"
HorizontalOptions="Start"
Style="{StaticResource TitleLabelStyle}"
Text="LATEST STORIES"
TextColor="{DynamicResource Gray-800}" />
</StackLayout>
</DataTemplate>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<Grid RowDefinitions="Auto, *">
<!-- Title View -->
<controls:TitleView Title="Blog" Grid.Row="0">
<controls:TitleView.LeadingView>
<!-- Back button command -->
<buttons:SfButton
x:Name="backButton"
Command="{Binding Path=BindingContext.BackButtonCommand, Source={x:Reference articleTilePage}}"
CommandParameter="{x:Reference backButton}"
Style="{StaticResource IconButtonStyle}"
Text="{StaticResource Back}" />
</controls:TitleView.LeadingView>
</controls:TitleView>
<!-- List out the items for latest stories -->
<listView:SfListView
x:Name="SfListView"
Grid.Row="1"
AutoFitMode="Height"
HeaderTemplate="{StaticResource HeaderView}"
HorizontalOptions="FillAndExpand"
ItemSpacing="0"
ItemTemplate="{StaticResource HorizontalArticleView}"
ItemsSource="{Binding LatestStories}"
SelectionBackgroundColor="Transparent"
TapCommand="{Binding ItemSelectedCommand}"
VerticalOptions="FillAndExpand">
<!-- Layout to customize no. of columns in SfListView -->
<listView:SfListView.LayoutManager>
<listView:GridLayout x:Name="GridLayout" SpanCount="{OnIdiom Phone=2, Tablet=3, Desktop=5}" />
</listView:SfListView.LayoutManager>
</listView:SfListView>
</Grid>
</ContentPage.Content>
</ContentPage>