diff --git a/StarWarsSample/StarWarsSample.Core/Models/Specie.cs b/StarWarsSample/StarWarsSample.Core/Models/Specie.cs new file mode 100644 index 00000000..52fb91cb --- /dev/null +++ b/StarWarsSample/StarWarsSample.Core/Models/Specie.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; + +namespace StarWarsSample.Core.Models +{ + public class Specie + { + public string Name { get; set; } + public string Average_Height { get; set; } + public string Average_Lifespan { get; set; } + public string Classification { get; set; } + public string Designation { get; set; } + public string Homeworld { get; set; } + public string Language { get; set; } + public string Eye_Colors { get; set; } + public string Hair_Colors { get; set; } + public List People { get; set; } + public List Films { get; set; } + public string Skin_Colors { get; set; } + public string Created { get; set; } + public string Edited { get; set; } + public string Url { get; set; } + } +} \ No newline at end of file diff --git a/StarWarsSample/StarWarsSample.Core/Resources/Strings.Designer.cs b/StarWarsSample/StarWarsSample.Core/Resources/Strings.Designer.cs index 6b011b4c..73c6f2d9 100644 --- a/StarWarsSample/StarWarsSample.Core/Resources/Strings.Designer.cs +++ b/StarWarsSample/StarWarsSample.Core/Resources/Strings.Designer.cs @@ -1,44 +1,58 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +// +// Este código fue generado por una herramienta. +// Versión de runtime:4.0.30319.42000 +// +// Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si +// se vuelve a generar el código. +// +//------------------------------------------------------------------------------ namespace StarWarsSample.Core.Resources { using System; using System.Reflection; - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [System.Diagnostics.DebuggerNonUserCodeAttribute()] - [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + /// + /// Clase de recurso fuertemente tipado, para buscar cadenas traducidas, etc. + /// + // StronglyTypedResourceBuilder generó automáticamente esta clase + // a través de una herramienta como ResGen o Visual Studio. + // Para agregar o quitar un miembro, edite el archivo .ResX y, a continuación, vuelva a ejecutar ResGen + // con la opción /str o recompile su proyecto de VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class Strings { - private static System.Resources.ResourceManager resourceMan; + private static global::System.Resources.ResourceManager resourceMan; - private static System.Globalization.CultureInfo resourceCulture; + private static global::System.Globalization.CultureInfo resourceCulture; - [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Strings() { } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - public static System.Resources.ResourceManager ResourceManager { + /// + /// Devuelve la instancia de ResourceManager almacenada en caché utilizada por esta clase. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { get { - if (object.Equals(null, resourceMan)) { - System.Resources.ResourceManager temp = new System.Resources.ResourceManager("StarWarsSample.Core.Resources.Strings", typeof(Strings).GetTypeInfo().Assembly); + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StarWarsSample.Core.Resources.Strings", typeof(Strings).GetTypeInfo().Assembly); resourceMan = temp; } return resourceMan; } } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - public static System.Globalization.CultureInfo Culture { + /// + /// Reemplaza la propiedad CurrentUICulture del subproceso actual para todas las + /// búsquedas de recursos mediante esta clase de recurso fuertemente tipado. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -47,141 +61,255 @@ public static System.Globalization.CultureInfo Culture { } } - public static string Population { + /// + /// Busca una cadena traducida similar a Another option. + /// + public static string AnotherOption { get { - return ResourceManager.GetString("Population", resourceCulture); + return ResourceManager.GetString("AnotherOption", resourceCulture); } } - public static string Terrain { + /// + /// Busca una cadena traducida similar a Average Height. + /// + public static string AverageHeight { get { - return ResourceManager.GetString("Terrain", resourceCulture); + return ResourceManager.GetString("AverageHeight", resourceCulture); } } - public static string Gravity { + /// + /// Busca una cadena traducida similar a Average Lifespan. + /// + public static string AverageLifespan { get { - return ResourceManager.GetString("Gravity", resourceCulture); + return ResourceManager.GetString("AverageLifespan", resourceCulture); } } - public static string Diameter { + /// + /// Busca una cadena traducida similar a Birth year. + /// + public static string BirthYear { get { - return ResourceManager.GetString("Diameter", resourceCulture); + return ResourceManager.GetString("BirthYear", resourceCulture); } } + /// + /// Busca una cadena traducida similar a Classification. + /// + public static string Classification { + get { + return ResourceManager.GetString("Classification", resourceCulture); + } + } + + /// + /// Busca una cadena traducida similar a Climate. + /// public static string Climate { get { return ResourceManager.GetString("Climate", resourceCulture); } } - public static string Name { + /// + /// Busca una cadena traducida similar a Death Star Status. + /// + public static string DeathStarStatus { get { - return ResourceManager.GetString("Name", resourceCulture); + return ResourceManager.GetString("DeathStarStatus", resourceCulture); } } + /// + /// Busca una cadena traducida similar a Destroy. + /// public static string Destroy { get { return ResourceManager.GetString("Destroy", resourceCulture); } } - public static string Statistics { + /// + /// Busca una cadena traducida similar a Diameter. + /// + public static string Diameter { get { - return ResourceManager.GetString("Statistics", resourceCulture); + return ResourceManager.GetString("Diameter", resourceCulture); } } - public static string DeathStarStatus { + /// + /// Busca una cadena traducida similar a Eye color. + /// + public static string EyeColor { get { - return ResourceManager.GetString("DeathStarStatus", resourceCulture); + return ResourceManager.GetString("EyeColor", resourceCulture); } } - public static string Time { + /// + /// Busca una cadena traducida similar a Gender. + /// + public static string Gender { get { - return ResourceManager.GetString("Time", resourceCulture); + return ResourceManager.GetString("Gender", resourceCulture); } } - public static string Targets { + /// + /// Busca una cadena traducida similar a Gravity. + /// + public static string Gravity { get { - return ResourceManager.GetString("Targets", resourceCulture); + return ResourceManager.GetString("Gravity", resourceCulture); } } - public static string AnotherOption { + /// + /// Busca una cadena traducida similar a Hair color. + /// + public static string HairColor { get { - return ResourceManager.GetString("AnotherOption", resourceCulture); + return ResourceManager.GetString("HairColor", resourceCulture); } } - public static string Menu { + /// + /// Busca una cadena traducida similar a Height. + /// + public static string Height { get { - return ResourceManager.GetString("Menu", resourceCulture); + return ResourceManager.GetString("Height", resourceCulture); } } - public static string TargetPlanets { + /// + /// Busca una cadena traducida similar a Home world. + /// + public static string HomeWorld { get { - return ResourceManager.GetString("TargetPlanets", resourceCulture); + return ResourceManager.GetString("HomeWorld", resourceCulture); } } - public static string TargetPeople { + /// + /// Busca una cadena traducida similar a Language. + /// + public static string Language { get { - return ResourceManager.GetString("TargetPeople", resourceCulture); + return ResourceManager.GetString("Language", resourceCulture); } } - public static string Height { + /// + /// Busca una cadena traducida similar a Mass. + /// + public static string Mass { get { - return ResourceManager.GetString("Height", resourceCulture); + return ResourceManager.GetString("Mass", resourceCulture); } } - public static string Mass { + /// + /// Busca una cadena traducida similar a Menu. + /// + public static string Menu { get { - return ResourceManager.GetString("Mass", resourceCulture); + return ResourceManager.GetString("Menu", resourceCulture); } } - public static string HairColor { + /// + /// Busca una cadena traducida similar a Name. + /// + public static string Name { get { - return ResourceManager.GetString("HairColor", resourceCulture); + return ResourceManager.GetString("Name", resourceCulture); } } + /// + /// Busca una cadena traducida similar a Population. + /// + public static string Population { + get { + return ResourceManager.GetString("Population", resourceCulture); + } + } + + /// + /// Busca una cadena traducida similar a Skin color. + /// public static string SkinColor { get { return ResourceManager.GetString("SkinColor", resourceCulture); } } - public static string EyeColor { + /// + /// Busca una cadena traducida similar a Statistics. + /// + public static string Statistics { get { - return ResourceManager.GetString("EyeColor", resourceCulture); + return ResourceManager.GetString("Statistics", resourceCulture); } } - public static string BirthYear { + /// + /// Busca una cadena traducida similar a Target: People. + /// + public static string TargetPeople { get { - return ResourceManager.GetString("BirthYear", resourceCulture); + return ResourceManager.GetString("TargetPeople", resourceCulture); } } - public static string Gender { + /// + /// Busca una cadena traducida similar a Target: Planets. + /// + public static string TargetPlanets { get { - return ResourceManager.GetString("Gender", resourceCulture); + return ResourceManager.GetString("TargetPlanets", resourceCulture); } } - public static string HomeWorld { + /// + /// Busca una cadena traducida similar a Targets. + /// + public static string Targets { get { - return ResourceManager.GetString("HomeWorld", resourceCulture); + return ResourceManager.GetString("Targets", resourceCulture); + } + } + + /// + /// Busca una cadena traducida similar a Target: Species. + /// + public static string TargetSpecies { + get { + return ResourceManager.GetString("TargetSpecies", resourceCulture); + } + } + + /// + /// Busca una cadena traducida similar a Terrain. + /// + public static string Terrain { + get { + return ResourceManager.GetString("Terrain", resourceCulture); + } + } + + /// + /// Busca una cadena traducida similar a Time. + /// + public static string Time { + get { + return ResourceManager.GetString("Time", resourceCulture); } } } diff --git a/StarWarsSample/StarWarsSample.Core/Resources/Strings.resx b/StarWarsSample/StarWarsSample.Core/Resources/Strings.resx index 321ac851..24afe8d8 100644 --- a/StarWarsSample/StarWarsSample.Core/Resources/Strings.resx +++ b/StarWarsSample/StarWarsSample.Core/Resources/Strings.resx @@ -1,6 +1,6 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Population - - - Terrain - - - Gravity - - - Diameter - - - Climate - - - Name - - - Destroy - - - Statistics - - - Death Star Status - - - Time - - - Targets - - - Another option - - - Menu - - - Target: Planets - - - Target: People - - - Height - - - Mass - - - Hair color - - - Skin color - - - Eye color - - - Birth year - - - Gender - - - Home world + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Population + + + Terrain + + + Gravity + + + Diameter + + + Climate + + + Name + + + Destroy + + + Statistics + + + Death Star Status + + + Time + + + Targets + + + Another option + + + Menu + + + Target: Planets + + + Target: People + + + Height + + + Mass + + + Hair color + + + Skin color + + + Eye color + + + Birth year + + + Gender + + + Home world + + + Average Height + + + Classification + + + Language + + + Target: Species + + + Average Lifespan \ No newline at end of file diff --git a/StarWarsSample/StarWarsSample.Core/Services/Implementations/SpeciesService.cs b/StarWarsSample/StarWarsSample.Core/Services/Implementations/SpeciesService.cs new file mode 100644 index 00000000..c91eae44 --- /dev/null +++ b/StarWarsSample/StarWarsSample.Core/Services/Implementations/SpeciesService.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Threading.Tasks; +using StarWarsSample.Core.Models; +using StarWarsSample.Core.Rest.Interfaces; +using StarWarsSample.Core.Services.Interfaces; + +namespace StarWarsSample.Core.Services.Implementations +{ + public class SpeciesService : ISpeciesService + { + private readonly IRestClient _restClient; + + public SpeciesService (IRestClient restClient) + { + _restClient = restClient; + } + + public Task> GetSpeciesAsync(string url = null) + { + return string.IsNullOrEmpty(url) + ? _restClient.MakeApiCall>($"{Constants.BaseUrl}/species/", HttpMethod.Get) + : _restClient.MakeApiCall>(url, HttpMethod.Get); + } + + public Task GetSpecieAsync() + { + return _restClient.MakeApiCall($"{Constants.BaseUrl}/species/3/", HttpMethod.Get); + } + + private PagedResult GetMockedSpecie() + { + return new PagedResult() + { + Count = 3, + Next = string.Empty, + Previous = string.Empty, + Results = new List + { + new Specie + { + Name = "Wookiee", + Average_Height = "210", + Language = "Shyriiwook" + }, + new Specie + { + Name = "Hutt", + Average_Height = "300", + Language = "Huttese" + }, + new Specie + { + Name = "Ewok", + Average_Height = "100", + Language = "Ewokese" + } + } + }; + } + } +} diff --git a/StarWarsSample/StarWarsSample.Core/Services/Interfaces/ISpeciesService.cs b/StarWarsSample/StarWarsSample.Core/Services/Interfaces/ISpeciesService.cs new file mode 100644 index 00000000..bcefd60d --- /dev/null +++ b/StarWarsSample/StarWarsSample.Core/Services/Interfaces/ISpeciesService.cs @@ -0,0 +1,13 @@ +using System; +using System.Threading.Tasks; +using StarWarsSample.Core.Models; + +namespace StarWarsSample.Core.Services.Interfaces +{ + public interface ISpeciesService + { + Task> GetSpeciesAsync(string url = null); + + Task GetSpecieAsync(); + } +} diff --git a/StarWarsSample/StarWarsSample.Core/StarWarsSample.Core.csproj b/StarWarsSample/StarWarsSample.Core/StarWarsSample.Core.csproj index 10131f78..78c843b2 100644 --- a/StarWarsSample/StarWarsSample.Core/StarWarsSample.Core.csproj +++ b/StarWarsSample/StarWarsSample.Core/StarWarsSample.Core.csproj @@ -1,135 +1,130 @@ - + - - Debug - AnyCPU - {DECE7897-83CC-431C-B87E-D61901D0A629} - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Library - StarWarsSample.Core - StarWarsSample.Core - v4.5 - Profile7 - - - true - full - false - bin\Debug - DEBUG; - prompt - 4 - - - true - bin\Release - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - Strings.resx - - - - - - - - - ..\packages\Microsoft.Net.Http.2.2.22\lib\portable-net45+win8\System.Net.Http.Extensions.dll - - - ..\packages\Microsoft.Net.Http.2.2.22\lib\portable-net45+win8\System.Net.Http.Primitives.dll - - - ..\packages\modernhttpclient.2.4.2\lib\Portable-Net45+WinRT45+WP8+WPA81\ModernHttpClient.dll - - - ..\packages\Nito.AsyncEx.3.0.1\lib\portable-net45+netcore45+wpa81\Nito.AsyncEx.Concurrent.dll - - - ..\packages\Nito.AsyncEx.3.0.1\lib\portable-net45+netcore45+wpa81\Nito.AsyncEx.dll - - - ..\packages\Splat.1.6.2\lib\Portable-net45+win+wpa81+wp80\Splat.dll - - - ..\packages\Acr.UserDialogs.6.4.1\lib\portable-net45+wp8+win8+wpa81\Acr.UserDialogs.dll - - - ..\packages\Acr.UserDialogs.6.4.1\lib\portable-net45+wp8+win8+wpa81\Acr.UserDialogs.Interface.dll - - - ..\packages\OxyPlot.Core.2.0.0-unstable0956\lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1+Xamarin.iOS10\OxyPlot.dll - - - ..\packages\Newtonsoft.Json.10.0.3\lib\portable-net45+win8+wp8+wpa81\Newtonsoft.Json.dll - - - ..\packages\MvvmCross.Platform.5.1.1\lib\portable-net45+win+wpa81+wp80\MvvmCross.Platform.dll - - - ..\packages\MvvmCross.Core.5.1.1\lib\portable-net45+win+wpa81+wp80\MvvmCross.Core.dll - - - ..\packages\MvvmCross.Binding.5.1.1\lib\portable-net45+win+wpa81+wp80\MvvmCross.Binding.dll - - - ..\packages\MvvmCross.Binding.5.1.1\lib\portable-net45+win+wpa81+wp80\MvvmCross.Localization.dll - - - ..\packages\MvvmCross.Plugin.Messenger.5.1.1\lib\portable-net45+win+wpa81+wp80\MvvmCross.Plugins.Messenger.dll - - - ..\packages\MvvmCross.Plugin.Visibility.5.1.1\lib\portable-net45+win+wpa81+wp80\MvvmCross.Plugins.Visibility.dll - - - ..\packages\MvvmCross.Plugin.Json.5.1.1\lib\portable-net45+win+wpa81+wp80\MvvmCross.Plugins.Json.dll - - - - - - - - - - - - - - - - - - - - - PublicResXFileCodeGenerator - Strings.Designer.cs - - - + + Debug + AnyCPU + {DECE7897-83CC-431C-B87E-D61901D0A629} + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + StarWarsSample.Core + StarWarsSample.Core + v4.5 + Profile7 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + + + true + bin\Release + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Strings.resx + True + True + + + + + + + + + ..\packages\Microsoft.Net.Http.2.2.22\lib\portable-net45+win8\System.Net.Http.Extensions.dll + + + ..\packages\Microsoft.Net.Http.2.2.22\lib\portable-net45+win8\System.Net.Http.Primitives.dll + + + ..\packages\modernhttpclient.2.4.2\lib\Portable-Net45+WinRT45+WP8+WPA81\ModernHttpClient.dll + + + ..\packages\Nito.AsyncEx.3.0.1\lib\portable-net45+netcore45+wpa81\Nito.AsyncEx.Concurrent.dll + + + ..\packages\Nito.AsyncEx.3.0.1\lib\portable-net45+netcore45+wpa81\Nito.AsyncEx.dll + + + ..\packages\Splat.1.6.2\lib\Portable-net45+win+wpa81+wp80\Splat.dll + + + ..\packages\Acr.UserDialogs.6.4.1\lib\portable-net45+wp8+win8+wpa81\Acr.UserDialogs.dll + + + ..\packages\Acr.UserDialogs.6.4.1\lib\portable-net45+wp8+win8+wpa81\Acr.UserDialogs.Interface.dll + + + ..\packages\OxyPlot.Core.2.0.0-unstable0956\lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1+Xamarin.iOS10\OxyPlot.dll + + + ..\packages\Newtonsoft.Json.10.0.3\lib\portable-net45+win8+wp8+wpa81\Newtonsoft.Json.dll + + + ..\packages\MvvmCross.Platform.5.1.1\lib\portable-net45+win+wpa81+wp80\MvvmCross.Platform.dll + + + ..\packages\MvvmCross.Core.5.1.1\lib\portable-net45+win+wpa81+wp80\MvvmCross.Core.dll + + + ..\packages\MvvmCross.Binding.5.1.1\lib\portable-net45+win+wpa81+wp80\MvvmCross.Binding.dll + + + ..\packages\MvvmCross.Binding.5.1.1\lib\portable-net45+win+wpa81+wp80\MvvmCross.Localization.dll + + + ..\packages\MvvmCross.Plugin.Messenger.5.1.1\lib\portable-net45+win+wpa81+wp80\MvvmCross.Plugins.Messenger.dll + + + ..\packages\MvvmCross.Plugin.Visibility.5.1.1\lib\portable-net45+win+wpa81+wp80\MvvmCross.Plugins.Visibility.dll + + + ..\packages\MvvmCross.Plugin.Json.5.1.1\lib\portable-net45+win+wpa81+wp80\MvvmCross.Plugins.Json.dll + + + + + + + + + PublicResXFileCodeGenerator + Strings.Designer.cs + + + \ No newline at end of file diff --git a/StarWarsSample/StarWarsSample.Core/ViewModels/MainViewModel.cs b/StarWarsSample/StarWarsSample.Core/ViewModels/MainViewModel.cs index 61e56378..6d91c780 100644 --- a/StarWarsSample/StarWarsSample.Core/ViewModels/MainViewModel.cs +++ b/StarWarsSample/StarWarsSample.Core/ViewModels/MainViewModel.cs @@ -13,6 +13,7 @@ public MainViewModel(IMvxNavigationService navigationService) ShowPeopleViewModelCommand = new MvxAsyncCommand(async () => await _navigationService.Navigate()); ShowPlanetsViewModelCommand = new MvxAsyncCommand(async () => await _navigationService.Navigate()); + ShowSpeciesViewModelCommand = new MvxAsyncCommand(async () => await _navigationService.Navigate()); ShowMenuViewModelCommand = new MvxAsyncCommand(async () => await _navigationService.Navigate()); } @@ -27,6 +28,7 @@ public override void Start() // MVVM Commands public IMvxAsyncCommand ShowPeopleViewModelCommand { get; private set; } public IMvxAsyncCommand ShowPlanetsViewModelCommand { get; private set; } + public IMvxAsyncCommand ShowSpeciesViewModelCommand { get; private set; } public IMvxAsyncCommand ShowMenuViewModelCommand { get; private set; } // Private methods diff --git a/StarWarsSample/StarWarsSample.Core/ViewModels/MenuViewModel.cs b/StarWarsSample/StarWarsSample.Core/ViewModels/MenuViewModel.cs index 3bebc1e5..629ad324 100644 --- a/StarWarsSample/StarWarsSample.Core/ViewModels/MenuViewModel.cs +++ b/StarWarsSample/StarWarsSample.Core/ViewModels/MenuViewModel.cs @@ -14,6 +14,7 @@ public MenuViewModel(IMvxNavigationService navigationService) ShowPlanetsCommand = new MvxAsyncCommand(async () => await _navigationService.Navigate()); ShowPeopleCommand = new MvxAsyncCommand(async () => await _navigationService.Navigate()); + ShowSpecieCommand = new MvxAsyncCommand(async () => await _navigationService.Navigate()); ShowStatusCommand = new MvxAsyncCommand(async () => await _navigationService.Navigate()); } @@ -25,6 +26,7 @@ public MenuViewModel(IMvxNavigationService navigationService) public IMvxCommand ShowStatusCommand { get; private set; } public IMvxCommand ShowPlanetsCommand { get; private set; } public IMvxCommand ShowPeopleCommand { get; private set; } + public IMvxCommand ShowSpecieCommand { get; private set; } // Private methods } diff --git a/StarWarsSample/StarWarsSample.Core/ViewModels/PlanetViewModel.cs b/StarWarsSample/StarWarsSample.Core/ViewModels/PlanetViewModel.cs index 97ef3753..5b200c74 100644 --- a/StarWarsSample/StarWarsSample.Core/ViewModels/PlanetViewModel.cs +++ b/StarWarsSample/StarWarsSample.Core/ViewModels/PlanetViewModel.cs @@ -61,7 +61,7 @@ private async Task DestroyPlanet() if (!destroy) return; - + var request = new DestructionAction { OnDestroyed = () => Close(new DestructionResult { Entity = Planet, Destroyed = true }) diff --git a/StarWarsSample/StarWarsSample.Core/ViewModels/SpecieViewModel.cs b/StarWarsSample/StarWarsSample.Core/ViewModels/SpecieViewModel.cs new file mode 100644 index 00000000..3caac413 --- /dev/null +++ b/StarWarsSample/StarWarsSample.Core/ViewModels/SpecieViewModel.cs @@ -0,0 +1,43 @@ +using System; +using System.Threading.Tasks; +using System.Linq; +using Acr.UserDialogs; +using StarWarsSample.Core.Models; +using StarWarsSample.Core.ViewModelResults; + +namespace StarWarsSample.Core.ViewModels +{ + public class SpecieViewModel : BaseViewModel> + { + private readonly IUserDialogs _userDialogs; + + public SpecieViewModel( + IUserDialogs userDialogs) + { + _userDialogs = userDialogs; + } + + // MvvmCross Lifecycle + public override Task Initialize(Specie parameter) + { + Specie = parameter; + + return Task.FromResult(0); + } + + // MVVM Properties + private Specie _specie; + public Specie Specie + { + get + { + return _specie; + } + set + { + _specie = value; + RaisePropertyChanged(() => Specie); + } + } + } +} diff --git a/StarWarsSample/StarWarsSample.Core/ViewModels/SpeciesViewModel.cs b/StarWarsSample/StarWarsSample.Core/ViewModels/SpeciesViewModel.cs new file mode 100644 index 00000000..e80aa864 --- /dev/null +++ b/StarWarsSample/StarWarsSample.Core/ViewModels/SpeciesViewModel.cs @@ -0,0 +1,105 @@ +using System.Threading.Tasks; +using MvvmCross.Core.Navigation; +using MvvmCross.Core.ViewModels; +using Nito.AsyncEx; +using StarWarsSample.Core.Models; +using StarWarsSample.Core.ViewModelResults; +using StarWarsSample.Core.Services.Interfaces; + +namespace StarWarsSample.Core.ViewModels +{ + public class SpeciesViewModel : BaseViewModel + { + private readonly ISpeciesService _speciesService; + private readonly IMvxNavigationService _navigationService; + + private string _nextPage; + + public SpeciesViewModel( + ISpeciesService speciesService, + IMvxNavigationService navigationService) + { + _speciesService = speciesService; + _navigationService = navigationService; + + Species = new MvxObservableCollection(); + + SpecieSelectedCommand = new MvxAsyncCommand(SpecieSelected); + FetchSpecieCommand = new MvxCommand( + () => + { + if (!string.IsNullOrEmpty(_nextPage)) + { + FetchSpeciesTask = NotifyTaskCompletion.Create(LoadSpecies); + RaisePropertyChanged(() => FetchSpeciesTask); + } + }); + RefreshSpeciesCommand = new MvxCommand(RefreshSpecies); + } + + // MvvmCross Lifecycle + public override Task Initialize() + { + LoadSpeciesTask = NotifyTaskCompletion.Create(LoadSpecies); + + return Task.FromResult(0); + } + + // MVVM Properties + public INotifyTaskCompletion LoadSpeciesTask { get; private set; } + + public INotifyTaskCompletion FetchSpeciesTask { get; private set; } + + private MvxObservableCollection _species; + public MvxObservableCollection Species + { + get + { + return _species; + } + set + { + _species = value; + RaisePropertyChanged(() => Species); + } + } + + // MVVM Commands + public IMvxCommand SpecieSelectedCommand { get; private set; } + + public IMvxCommand FetchSpecieCommand { get; private set; } + + public IMvxCommand RefreshSpeciesCommand { get; private set; } + + // Private methods + private async Task LoadSpecies() + { + var result = await _speciesService.GetSpeciesAsync(_nextPage); + + if (string.IsNullOrEmpty(_nextPage)) + { + Species.Clear(); + Species.AddRange(result.Results); + } + else + { + Species.AddRange(result.Results); + } + + _nextPage = result.Next; + } + + private async Task SpecieSelected(Specie selectedSpecie) + { + var result = await _navigationService.Navigate>(selectedSpecie); + } + + private void RefreshSpecies() + { + _nextPage = null; + + LoadSpeciesTask = NotifyTaskCompletion.Create(LoadSpecies); + RaisePropertyChanged(() => LoadSpeciesTask); + } + } +} diff --git a/StarWarsSample/StarWarsSample.Droid/Resources/Resource.designer.cs b/StarWarsSample/StarWarsSample.Droid/Resources/Resource.designer.cs index a0f1b8b3..1273e1d4 100644 --- a/StarWarsSample/StarWarsSample.Droid/Resources/Resource.designer.cs +++ b/StarWarsSample/StarWarsSample.Droid/Resources/Resource.designer.cs @@ -1,11 +1,11 @@ #pragma warning disable 1591 //------------------------------------------------------------------------------ // -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// Este código fue generado por una herramienta. +// Versión de runtime:4.0.30319.42000 // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si +// se vuelve a generar el código. // //------------------------------------------------------------------------------ @@ -5674,27 +5674,9 @@ public partial class Drawable // aapt resource value: 0x7f020054 public const int avd_hide_password = 2130837588; - // aapt resource value: 0x7f020076 - public const int avd_hide_password_1 = 2130837622; - - // aapt resource value: 0x7f020077 - public const int avd_hide_password_2 = 2130837623; - - // aapt resource value: 0x7f020078 - public const int avd_hide_password_3 = 2130837624; - // aapt resource value: 0x7f020055 public const int avd_show_password = 2130837589; - // aapt resource value: 0x7f020079 - public const int avd_show_password_1 = 2130837625; - - // aapt resource value: 0x7f02007a - public const int avd_show_password_2 = 2130837626; - - // aapt resource value: 0x7f02007b - public const int avd_show_password_3 = 2130837627; - // aapt resource value: 0x7f020056 public const int Background = 2130837590; @@ -5752,11 +5734,11 @@ public partial class Drawable // aapt resource value: 0x7f020068 public const int notification_icon_background = 2130837608; - // aapt resource value: 0x7f020074 - public const int notification_template_icon_bg = 2130837620; + // aapt resource value: 0x7f020076 + public const int notification_template_icon_bg = 2130837622; - // aapt resource value: 0x7f020075 - public const int notification_template_icon_low_bg = 2130837621; + // aapt resource value: 0x7f020077 + public const int notification_template_icon_low_bg = 2130837623; // aapt resource value: 0x7f020069 public const int notification_tile_bg = 2130837609; @@ -5789,7 +5771,13 @@ public partial class Drawable public const int screen = 2130837618; // aapt resource value: 0x7f020073 - public const int statistics = 2130837619; + public const int specie = 2130837619; + + // aapt resource value: 0x7f020074 + public const int Species_Header = 2130837620; + + // aapt resource value: 0x7f020075 + public const int statistics = 2130837621; static Drawable() { @@ -5885,8 +5873,8 @@ public partial class Id // aapt resource value: 0x7f0900b1 public const int animation_view = 2131296433; - // aapt resource value: 0x7f0900b7 - public const int appbar = 2131296439; + // aapt resource value: 0x7f0900ba + public const int appbar = 2131296442; // aapt resource value: 0x7f090032 public const int auto = 2131296306; @@ -6068,8 +6056,8 @@ public partial class Id // aapt resource value: 0x7f09008d public const int main_frame = 2131296397; - // aapt resource value: 0x7f0900b9 - public const int masked = 2131296441; + // aapt resource value: 0x7f0900bc + public const int masked = 2131296444; // aapt resource value: 0x7f090099 public const int media_actions = 2131296409; @@ -6083,17 +6071,20 @@ public partial class Id // aapt resource value: 0x7f09001d public const int multiply = 2131296285; - // aapt resource value: 0x7f0900ba - public const int nav_items = 2131296442; + // aapt resource value: 0x7f0900bd + public const int nav_items = 2131296445; - // aapt resource value: 0x7f0900bc - public const int nav_people = 2131296444; + // aapt resource value: 0x7f0900bf + public const int nav_people = 2131296447; - // aapt resource value: 0x7f0900bb - public const int nav_planets = 2131296443; + // aapt resource value: 0x7f0900be + public const int nav_planets = 2131296446; - // aapt resource value: 0x7f0900bd - public const int nav_statistics = 2131296445; + // aapt resource value: 0x7f0900c0 + public const int nav_specie = 2131296448; + + // aapt resource value: 0x7f0900c1 + public const int nav_statistics = 2131296449; // aapt resource value: 0x7f09008f public const int navigation_frame = 2131296399; @@ -6149,8 +6140,8 @@ public partial class Id // aapt resource value: 0x7f0900b3 public const int planets_recycler_view = 2131296435; - // aapt resource value: 0x7f0900b6 - public const int plot_view = 2131296438; + // aapt resource value: 0x7f0900b9 + public const int plot_view = 2131296441; // aapt resource value: 0x7f0900b2 public const int posts_placeholder = 2131296434; @@ -6263,6 +6254,15 @@ public partial class Id // aapt resource value: 0x7f090051 public const int spacer = 2131296337; + // aapt resource value: 0x7f0900b8 + public const int specie_back = 2131296440; + + // aapt resource value: 0x7f0900b7 + public const int specie_collapsing = 2131296439; + + // aapt resource value: 0x7f0900b6 + public const int species_recycler_view = 2131296438; + // aapt resource value: 0x7f090008 public const int split_action_bar = 2131296264; @@ -6362,8 +6362,8 @@ public partial class Id // aapt resource value: 0x7f09000e public const int view_offset_helper = 2131296270; - // aapt resource value: 0x7f0900b8 - public const int visible = 2131296440; + // aapt resource value: 0x7f0900bb + public const int visible = 2131296443; // aapt resource value: 0x7f090045 public const int weak = 2131296325; @@ -6641,16 +6641,22 @@ public partial class Layout public const int select_dialog_singlechoice_material = 2130968646; // aapt resource value: 0x7f040047 - public const int SplashScreen = 2130968647; + public const int SpeciesView = 2130968647; // aapt resource value: 0x7f040048 - public const int StatusView = 2130968648; + public const int SpecieView = 2130968648; // aapt resource value: 0x7f040049 - public const int support_simple_spinner_dropdown_item = 2130968649; + public const int SplashScreen = 2130968649; // aapt resource value: 0x7f04004a - public const int toolbar_actionbar = 2130968650; + public const int StatusView = 2130968650; + + // aapt resource value: 0x7f04004b + public const int support_simple_spinner_dropdown_item = 2130968651; + + // aapt resource value: 0x7f04004c + public const int toolbar_actionbar = 2130968652; static Layout() { diff --git a/StarWarsSample/StarWarsSample.Droid/Resources/drawable-nodpi/Species_Header.jpg b/StarWarsSample/StarWarsSample.Droid/Resources/drawable-nodpi/Species_Header.jpg new file mode 100644 index 00000000..dcadfa21 Binary files /dev/null and b/StarWarsSample/StarWarsSample.Droid/Resources/drawable-nodpi/Species_Header.jpg differ diff --git a/StarWarsSample/StarWarsSample.Droid/Resources/drawable/specie.xml b/StarWarsSample/StarWarsSample.Droid/Resources/drawable/specie.xml new file mode 100644 index 00000000..c7c4b766 --- /dev/null +++ b/StarWarsSample/StarWarsSample.Droid/Resources/drawable/specie.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/StarWarsSample/StarWarsSample.Droid/Resources/layout/PlanetView.axml b/StarWarsSample/StarWarsSample.Droid/Resources/layout/PlanetView.axml index 32a60d25..8e0b381f 100644 --- a/StarWarsSample/StarWarsSample.Droid/Resources/layout/PlanetView.axml +++ b/StarWarsSample/StarWarsSample.Droid/Resources/layout/PlanetView.axml @@ -1,94 +1,93 @@ - - - - - - - - - - - - - - - -