Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Babel sample (WPF & Android) #136

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Babel/Babel.Core/App.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Babel.Core.Services;
using MvvmCross.Core.ViewModels;
using MvvmCross;
using MvvmCross.IoC;
using MvvmCross.Localization;
using MvvmCross.Platform;
using MvvmCross.Platform.IoC;
using MvvmCross.Plugins.JsonLocalization;
using MvvmCross.Plugin.JsonLocalization;
using MvvmCross.ViewModels;

namespace Babel.Core
{
Expand All @@ -23,8 +23,8 @@ public override void Initialize()
private void InitializeText()
{
var builder = new TextProviderBuilder();
Mvx.RegisterSingleton<IMvxTextProviderBuilder>(builder);
Mvx.RegisterSingleton<IMvxTextProvider>(builder.TextProvider);
Mvx.IoCProvider.RegisterSingleton<IMvxTextProviderBuilder>(builder);
Mvx.IoCProvider.RegisterSingleton<IMvxTextProvider>(builder.TextProvider);
}
}
}
}
94 changes: 7 additions & 87 deletions Babel/Babel.Core/Babel.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,91 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F7103111-05CE-4859-A81F-F7D88CAEE12E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Babel.Core</RootNamespace>
<AssemblyName>Babel.Core</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile259</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included -->
<None Include="packages-old.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="App.cs" />
<Compile Include="Constants.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\TextProviderBuilder.cs" />
<Compile Include="ViewModels\BaseViewModel.cs" />
<Compile Include="ViewModels\FirstViewModel.cs" />
<Compile Include="ViewModels\SecondViewModel.cs" />
</ItemGroup>

<ItemGroup>
<Reference Include="MvvmCross.Binding, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmCross.Binding.4.0.0-beta8\lib\portable-net45+win+wpa81+wp80\MvvmCross.Binding.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MvvmCross.Core, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmCross.Core.4.0.0-beta8\lib\portable-net45+win+wpa81+wp80\MvvmCross.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MvvmCross.Localization, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmCross.Platform.4.0.0-beta8\lib\portable-net45+win+wpa81+wp80\MvvmCross.Localization.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MvvmCross.Platform, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmCross.Platform.4.0.0-beta8\lib\portable-net45+win+wpa81+wp80\MvvmCross.Platform.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MvvmCross.Plugins.Json, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmCross.Plugin.Json.4.0.0-beta8\lib\portable-net45+win+wpa81+wp80\MvvmCross.Plugins.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MvvmCross.Plugins.JsonLocalization, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmCross.Plugin.JsonLocalization.4.0.0-beta8\lib\portable-net45+win+wpa81+wp80\MvvmCross.Plugins.JsonLocalization.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MvvmCross.Plugins.ResourceLoader, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmCross.Plugin.ResourceLoader.4.0.0-beta8\lib\portable-win+net45+wp8+win8+wpa81\MvvmCross.Plugins.ResourceLoader.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.2\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<PackageReference Include="MvvmCross" Version="6.2.3" />
<PackageReference Include="MvvmCross.Plugin.JsonLocalization" Version="6.2.3" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
28 changes: 0 additions & 28 deletions Babel/Babel.Core/Properties/AssemblyInfo.cs

This file was deleted.

7 changes: 3 additions & 4 deletions Babel/Babel.Core/Services/TextProviderBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using MvvmCross.Platform.IoC;
using MvvmCross.Plugins.JsonLocalization;
using MvvmCross.IoC;
using MvvmCross.Plugin.JsonLocalization;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace Babel.Core.Services
{
public class TextProviderBuilder
: MvxTextProviderBuilder
public class TextProviderBuilder : MvxTextProviderBuilder
{
public TextProviderBuilder()
: base(Constants.GeneralNamespace, Constants.RootFolderForResources)
Expand Down
7 changes: 3 additions & 4 deletions Babel/Babel.Core/ViewModels/BaseViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
using MvvmCross.Core.ViewModels;
using MvvmCross.Localization;
using MvvmCross.ViewModels;

namespace Babel.Core.ViewModels
{
public abstract class BaseViewModel
: MvxViewModel
public abstract class BaseViewModel : MvxViewModel
{
public IMvxLanguageBinder TextSource
{
get { return new MvxLanguageBinder(Constants.GeneralNamespace, GetType().Name); }
}
}
}
}
43 changes: 18 additions & 25 deletions Babel/Babel.Core/ViewModels/FirstViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,47 +1,40 @@
using MvvmCross.Core.ViewModels;
using MvvmCross.Plugins.JsonLocalization;
using System.Windows.Input;
using MvvmCross.Commands;
using MvvmCross.Navigation;
using MvvmCross.Plugin.JsonLocalization;

namespace Babel.Core.ViewModels
{
public class FirstViewModel
: BaseViewModel
public class FirstViewModel : BaseViewModel
{
private readonly IMvxTextProviderBuilder _builder;
private readonly IMvxNavigationService _navigationService;
private string _hello;

public FirstViewModel(IMvxTextProviderBuilder builder)
public FirstViewModel(IMvxTextProviderBuilder builder, IMvxNavigationService navigationService)
{
_builder = builder;
_navigationService = navigationService;
}

public ICommand LolCatCommand
{
get { return new MvxCommand(() => PickLanguage("LolCat")); }
}
public IMvxCommand LolCatCommand => new MvxCommand(() => PickLanguage("LolCat"));

public ICommand ProperEnglishCommand
{
get { return new MvxCommand(() => PickLanguage("ProperEnglish")); }
}
public IMvxCommand ProperEnglishCommand => new MvxCommand(() => PickLanguage("ProperEnglish"));

public ICommand DefaultCommand
{
get { return new MvxCommand(() => PickLanguage(string.Empty)); }
}
public IMvxCommand DefaultCommand => new MvxCommand(() => PickLanguage(string.Empty));

private void PickLanguage(string which)
{
_builder.LoadResources(which);
}

public ICommand GoCommand
{
get { return new MvxCommand(() => ShowViewModel<SecondViewModel>()); }
}
public IMvxCommand GoCommand => new MvxCommand(() => _navigationService.Navigate<SecondViewModel>());

public IMvxCommand ForceTextRefreshCommand => new MvxCommand(() => RaisePropertyChanged(() => TextSource));

public ICommand ForceTextRefreshCommand
public string Hello
{
get { return new MvxCommand(() => RaisePropertyChanged(() => TextSource)); }
get => _hello;
set => SetProperty(ref _hello, value);
}
}
}
}
14 changes: 11 additions & 3 deletions Babel/Babel.Core/ViewModels/SecondViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
using MvvmCross.Commands;
using MvvmCross.Navigation;

namespace Babel.Core.ViewModels
{
public class SecondViewModel
: BaseViewModel
public class SecondViewModel : BaseViewModel
{
public SecondViewModel(IMvxNavigationService navigationService)
{
GoBackCommand = new MvxCommand(() => navigationService.Navigate<FirstViewModel>());
}

public IMvxCommand GoBackCommand { get; }
}
}
}
13 changes: 0 additions & 13 deletions Babel/Babel.Core/packages-old.config

This file was deleted.

11 changes: 0 additions & 11 deletions Babel/Babel.Core/packages.config

This file was deleted.

Loading