Skip to content

Commit b6ca97e

Browse files
committed
Updated the DeepNavigation sample with real data coming from TrackSeries
1 parent 655cae4 commit b6ca97e

32 files changed

+729
-34
lines changed

DeepNavigation/DeepNavigation.sln

+18
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeepNavigation.Droid", "Dee
99
EndProject
1010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeepNavigation.UWP", "DeepNavigation\DeepNavigation.UWP\DeepNavigation.UWP.csproj", "{49EB3DA8-5B66-4E89-A5DB-5110100A738F}"
1111
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InfoSeries.Core", "InfoSeries.Core\InfoSeries.Core.csproj", "{68906DF0-CED1-471A-A585-DBA675AB4E2B}"
13+
EndProject
1214
Global
1315
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1416
Debug|Any CPU = Debug|Any CPU
@@ -81,6 +83,22 @@ Global
8183
{49EB3DA8-5B66-4E89-A5DB-5110100A738F}.Release|x86.ActiveCfg = Release|x86
8284
{49EB3DA8-5B66-4E89-A5DB-5110100A738F}.Release|x86.Build.0 = Release|x86
8385
{49EB3DA8-5B66-4E89-A5DB-5110100A738F}.Release|x86.Deploy.0 = Release|x86
86+
{68906DF0-CED1-471A-A585-DBA675AB4E2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
87+
{68906DF0-CED1-471A-A585-DBA675AB4E2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
88+
{68906DF0-CED1-471A-A585-DBA675AB4E2B}.Debug|ARM.ActiveCfg = Debug|Any CPU
89+
{68906DF0-CED1-471A-A585-DBA675AB4E2B}.Debug|ARM.Build.0 = Debug|Any CPU
90+
{68906DF0-CED1-471A-A585-DBA675AB4E2B}.Debug|x64.ActiveCfg = Debug|Any CPU
91+
{68906DF0-CED1-471A-A585-DBA675AB4E2B}.Debug|x64.Build.0 = Debug|Any CPU
92+
{68906DF0-CED1-471A-A585-DBA675AB4E2B}.Debug|x86.ActiveCfg = Debug|Any CPU
93+
{68906DF0-CED1-471A-A585-DBA675AB4E2B}.Debug|x86.Build.0 = Debug|Any CPU
94+
{68906DF0-CED1-471A-A585-DBA675AB4E2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
95+
{68906DF0-CED1-471A-A585-DBA675AB4E2B}.Release|Any CPU.Build.0 = Release|Any CPU
96+
{68906DF0-CED1-471A-A585-DBA675AB4E2B}.Release|ARM.ActiveCfg = Release|Any CPU
97+
{68906DF0-CED1-471A-A585-DBA675AB4E2B}.Release|ARM.Build.0 = Release|Any CPU
98+
{68906DF0-CED1-471A-A585-DBA675AB4E2B}.Release|x64.ActiveCfg = Release|Any CPU
99+
{68906DF0-CED1-471A-A585-DBA675AB4E2B}.Release|x64.Build.0 = Release|Any CPU
100+
{68906DF0-CED1-471A-A585-DBA675AB4E2B}.Release|x86.ActiveCfg = Release|Any CPU
101+
{68906DF0-CED1-471A-A585-DBA675AB4E2B}.Release|x86.Build.0 = Release|Any CPU
84102
EndGlobalSection
85103
GlobalSection(SolutionProperties) = preSolution
86104
HideSolutionNode = FALSE

DeepNavigation/DeepNavigation/DeepNavigation.Droid/DeepNavigation.Droid.csproj

+19
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
4949
</PropertyGroup>
5050
<ItemGroup>
51+
<Reference Include="Corcav.Behaviors, Version=2.2.0.0, Culture=neutral, processorArchitecture=MSIL">
52+
<HintPath>..\..\packages\Corcav.Behaviors.2.2.0\lib\Corcav.Behaviors.dll</HintPath>
53+
<Private>True</Private>
54+
</Reference>
5155
<Reference Include="FormsViewGroup, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
5256
<HintPath>..\..\packages\Xamarin.Forms.2.3.1.114\lib\MonoAndroid10\FormsViewGroup.dll</HintPath>
5357
<Private>True</Private>
@@ -62,6 +66,10 @@
6266
</Reference>
6367
<Reference Include="Mono.Android" />
6468
<Reference Include="mscorlib" />
69+
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
70+
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
71+
<Private>True</Private>
72+
</Reference>
6573
<Reference Include="Prism, Version=6.2.0.0, Culture=neutral, PublicKeyToken=91a96d2a154366d8, processorArchitecture=MSIL">
6674
<HintPath>..\..\packages\Prism.Core.6.2.0\lib\MonoAndroid10\Prism.dll</HintPath>
6775
<Private>True</Private>
@@ -76,6 +84,15 @@
7684
</Reference>
7785
<Reference Include="System" />
7886
<Reference Include="System.Core" />
87+
<Reference Include="System.Net.Http" />
88+
<Reference Include="System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
89+
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.29\lib\monoandroid\System.Net.Http.Extensions.dll</HintPath>
90+
<Private>True</Private>
91+
</Reference>
92+
<Reference Include="System.Net.Http.Primitives, Version=4.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
93+
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.29\lib\monoandroid\System.Net.Http.Primitives.dll</HintPath>
94+
<Private>True</Private>
95+
</Reference>
7996
<Reference Include="System.Xml.Linq" />
8097
<Reference Include="System.Xml" />
8198
<Reference Include="Xamarin.Android.Support.Animated.Vector.Drawable, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
@@ -167,8 +184,10 @@
167184
</PropertyGroup>
168185
<Error Condition="!Exists('..\..\packages\Xamarin.Forms.2.3.1.114\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Xamarin.Forms.2.3.1.114\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets'))" />
169186
<Error Condition="!Exists('..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets'))" />
187+
<Error Condition="!Exists('..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />
170188
</Target>
171189
<Import Project="..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets" Condition="Exists('..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets')" />
190+
<Import Project="..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" />
172191
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
173192
Other similar extension points exist, see Microsoft.Common.targets.
174193
<Target Name="BeforeBuild">

DeepNavigation/DeepNavigation/DeepNavigation.Droid/packages.config

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="CommonServiceLocator" version="1.3" targetFramework="monoandroid60" />
4+
<package id="Corcav.Behaviors" version="2.2.0" targetFramework="monoandroid60" />
5+
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="monoandroid60" />
6+
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="monoandroid60" />
7+
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="monoandroid60" />
8+
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="monoandroid60" />
49
<package id="Prism.Core" version="6.2.0" targetFramework="monoandroid60" />
510
<package id="Prism.Forms" version="6.2.0" targetFramework="monoandroid60" />
611
<package id="Prism.Unity.Forms" version="6.2.0" targetFramework="monoandroid60" />

DeepNavigation/DeepNavigation/DeepNavigation/App.xaml.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using DeepNavigation.Views;
2+
using InfoSeries.Core.Services;
3+
using Microsoft.Practices.Unity;
24
using Prism.Unity;
35
using Xamarin.Forms;
46

@@ -8,11 +10,11 @@ public partial class App : PrismApplication
810
{
911
public App(IPlatformInitializer initializer = null) : base(initializer) { }
1012

11-
protected override void OnInitialized()
13+
protected override async void OnInitialized()
1214
{
1315
InitializeComponent();
1416

15-
NavigationService.NavigateAsync("MainTabbedPage/NavigationPage/ShowsListPage/DetailPage?id=1");
17+
await NavigationService.NavigateAsync("MainTabbedPage/NavigationPage/ShowsListPage/DetailPage?id=279121");
1618
}
1719

1820
protected override void RegisterTypes()
@@ -22,6 +24,7 @@ protected override void RegisterTypes()
2224
Container.RegisterTypeForNavigation<DetailPage>();
2325
Container.RegisterTypeForNavigation<MainTabbedPage>();
2426
Container.RegisterTypeForNavigation<NavigationPage>();
27+
Container.RegisterType<ITsApiService, TsApiService>();
2528
}
2629
}
2730
}

DeepNavigation/DeepNavigation/DeepNavigation/DeepNavigation.csproj

+10
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@
6868
</Compile>
6969
</ItemGroup>
7070
<ItemGroup>
71+
<Reference Include="Corcav.Behaviors, Version=2.2.0.0, Culture=neutral, processorArchitecture=MSIL">
72+
<HintPath>..\..\packages\Corcav.Behaviors.2.2.0\lib\Corcav.Behaviors.dll</HintPath>
73+
<Private>True</Private>
74+
</Reference>
7175
<Reference Include="Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7276
<HintPath>..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
7377
<Private>True</Private>
@@ -122,6 +126,12 @@
122126
<SubType>Designer</SubType>
123127
</EmbeddedResource>
124128
</ItemGroup>
129+
<ItemGroup>
130+
<ProjectReference Include="..\..\InfoSeries.Core\InfoSeries.Core.csproj">
131+
<Project>{68906df0-ced1-471a-a585-dba675ab4e2b}</Project>
132+
<Name>InfoSeries.Core</Name>
133+
</ProjectReference>
134+
</ItemGroup>
125135
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
126136
<Import Project="..\..\packages\Xamarin.Forms.2.3.1.114\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.3.1.114\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
127137
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
1-
using Prism.Mvvm;
1+
using System;
2+
using InfoSeries.Core.Models;
3+
using InfoSeries.Core.Services;
4+
using Prism.Mvvm;
25
using Prism.Navigation;
36

47
namespace DeepNavigation.ViewModels
58
{
69
public class DetailPageViewModel : BindableBase, INavigationAware
710
{
8-
private string _title;
9-
public string Title
11+
private readonly ITsApiService _tsApiService;
12+
private SerieInfoVM _selectedShow;
13+
14+
public SerieInfoVM SelectedShow
1015
{
11-
get { return _title; }
12-
set { SetProperty(ref _title, value); }
16+
get { return _selectedShow; }
17+
set { SetProperty(ref _selectedShow, value); }
1318
}
1419

15-
public DetailPageViewModel()
20+
public DetailPageViewModel(ITsApiService tsApiService)
1621
{
17-
22+
_tsApiService = tsApiService;
1823
}
1924

2025
public void OnNavigatedFrom(NavigationParameters parameters)
2126
{
22-
27+
2328
}
2429

25-
public void OnNavigatedTo(NavigationParameters parameters)
30+
public async void OnNavigatedTo(NavigationParameters parameters)
2631
{
27-
Title = "The Flash";
32+
int id = Convert.ToInt32(parameters["id"]);
33+
SelectedShow = await _tsApiService.GetSerieById(id);
2834
}
2935
}
3036
}
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,62 @@
1-
using Prism.Mvvm;
1+
using System.Collections.ObjectModel;
2+
using InfoSeries.Core.Models;
3+
using InfoSeries.Core.Services;
4+
using Prism.Mvvm;
25
using Prism.Navigation;
6+
using Xamarin.Forms;
37

48
namespace DeepNavigation.ViewModels
59
{
610
public class ShowsListPageViewModel : BindableBase, INavigationAware
711
{
8-
private string _title;
9-
public string Title
12+
private readonly ITsApiService _tsApiService;
13+
private readonly INavigationService _navigationService;
14+
private ObservableCollection<SerieFollowersVM> _highlightSeries;
15+
16+
public ObservableCollection<SerieFollowersVM> HighlightSeries
1017
{
11-
get { return _title; }
12-
set { SetProperty(ref _title, value); }
18+
get { return _highlightSeries; }
19+
set { SetProperty(ref _highlightSeries, value); }
1320
}
1421

15-
public ShowsListPageViewModel()
22+
23+
public ShowsListPageViewModel(ITsApiService tsApiService, INavigationService navigationService)
1624
{
17-
25+
_tsApiService = tsApiService;
26+
_navigationService = navigationService;
1827
}
1928

2029
public void OnNavigatedFrom(NavigationParameters parameters)
2130
{
2231

2332
}
2433

25-
public void OnNavigatedTo(NavigationParameters parameters)
34+
public async void OnNavigatedTo(NavigationParameters parameters)
35+
{
36+
var series = await _tsApiService.GetStatsTopSeries();
37+
HighlightSeries = new ObservableCollection<SerieFollowersVM>(series);
38+
}
39+
40+
41+
private Command<ItemTappedEventArgs> _goToDetailPage;
42+
43+
public Command<ItemTappedEventArgs> GoToDetailPage
2644
{
27-
Title = "List of shows";
45+
get
46+
{
47+
if (_goToDetailPage == null)
48+
{
49+
_goToDetailPage = new Command<ItemTappedEventArgs>(async selected =>
50+
{
51+
NavigationParameters param = new NavigationParameters();
52+
var serie = selected.Item as SerieFollowersVM;
53+
param.Add("show", serie.Id);
54+
await _navigationService.NavigateAsync("DetailPage", param);
55+
});
56+
}
57+
58+
return _goToDetailPage;
59+
}
2860
}
2961
}
3062
}
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,37 @@
1-
using Prism.Mvvm;
1+
using System.Collections.ObjectModel;
2+
using InfoSeries.Core.Models;
3+
using InfoSeries.Core.Services;
4+
using Prism.Mvvm;
25
using Prism.Navigation;
36

47
namespace DeepNavigation.ViewModels
58
{
69
public class UpcomingShowsPageViewModel : BindableBase, INavigationAware
710
{
8-
public UpcomingShowsPageViewModel()
11+
private readonly ITsApiService _tsApiService;
12+
13+
private ObservableCollection<SerieFollowersVM> _topSeries;
14+
15+
public ObservableCollection<SerieFollowersVM> TopSeries
16+
{
17+
get { return _topSeries; }
18+
set { SetProperty(ref _topSeries, value); }
19+
}
20+
21+
public UpcomingShowsPageViewModel(ITsApiService tsApiService)
922
{
23+
_tsApiService = tsApiService;
1024
}
1125

1226
public void OnNavigatedFrom(NavigationParameters parameters)
1327
{
1428

1529
}
1630

17-
public void OnNavigatedTo(NavigationParameters parameters)
31+
public async void OnNavigatedTo(NavigationParameters parameters)
1832
{
19-
//load the list of upcoming shows
33+
var series = await _tsApiService.GetStatsTopSeries();
34+
TopSeries = new ObservableCollection<SerieFollowersVM>(series);
2035
}
2136
}
2237
}

DeepNavigation/DeepNavigation/DeepNavigation/Views/DetailPage.xaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
44
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
55
prism:ViewModelLocator.AutowireViewModel="True"
6-
Title="{Binding Title}"
6+
Title="{Binding Path=SelectedShow.Name}"
77
x:Class="DeepNavigation.Views.DetailPage">
88

9-
<StackLayout HorizontalOptions="Center" VerticalOptions="Center">
10-
<Label Text="{Binding Title}" />
9+
<StackLayout>
10+
<Image x:Name="InfoPoster"
11+
Source="{Binding Path=SelectedShow.Images.Fanart}" Aspect="AspectFill" />
12+
<Label Text="{Binding Path=SelectedShow.Overview}" LineBreakMode="WordWrap" FontSize="13" TextColor="Black" Margin="15" />
1113
</StackLayout>
1214

1315
</ContentPage>

DeepNavigation/DeepNavigation/DeepNavigation/Views/ShowsListPage.xaml

+23-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,32 @@
22
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
33
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
44
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
5+
xmlns:behaviors="clr-namespace:Corcav.Behaviors;assembly=Corcav.Behaviors"
56
prism:ViewModelLocator.AutowireViewModel="True"
67
x:Class="DeepNavigation.Views.ShowsListPage"
78
Title="Shows list">
89

9-
<StackLayout HorizontalOptions="Center" VerticalOptions="Center">
10-
<Label Text="{Binding Title}" />
11-
</StackLayout>
10+
<ContentPage.Resources>
11+
<ResourceDictionary>
12+
<DataTemplate x:Key="HighlightSeriesTemplate">
13+
<ViewCell>
14+
<ViewCell.View>
15+
<Image Source="{Binding Images.Poster}" Grid.Column="0" x:Name="TopImage" />
16+
</ViewCell.View>
17+
</ViewCell>
18+
19+
20+
</DataTemplate>
21+
</ResourceDictionary>
22+
</ContentPage.Resources>
23+
24+
<ListView ItemTemplate="{StaticResource HighlightSeriesTemplate}"
25+
ItemsSource="{Binding Path=HighlightSeries}" RowHeight="200">
26+
<behaviors:Interaction.Behaviors>
27+
<behaviors:BehaviorCollection>
28+
<behaviors:EventToCommand EventName="ItemTapped" Command="{Binding GoToDetailPage}" />
29+
</behaviors:BehaviorCollection>
30+
</behaviors:Interaction.Behaviors>
31+
</ListView>
1232

1333
</ContentPage>

0 commit comments

Comments
 (0)