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 to NET MAUI #308

Open
wants to merge 11 commits into
base: develop
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 14 additions & 0 deletions DotNetRu.App/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:DotNetRu.App"
x:Class="DotNetRu.App.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
14 changes: 14 additions & 0 deletions DotNetRu.App/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace DotNetRu.App
{
public partial class App : Application
{
public App()
{
InitializeComponent();

// DependencyService.Register<ILogger, DotNetRuLogger>();

MainPage = new AppShell();
}
}
}
14 changes: 14 additions & 0 deletions DotNetRu.App/AppShell.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="DotNetRu.App.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:DotNetRu.App"
Shell.FlyoutBehavior="Disabled">

<ShellContent
Title="Home"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />

</Shell>
10 changes: 10 additions & 0 deletions DotNetRu.App/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace DotNetRu.App
{
public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
}
52 changes: 52 additions & 0 deletions DotNetRu.App/BasePages/AppPage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
namespace DotNetRu.Clients.Portable.Model
{
public class DeepLinkPage
{
public AppPage Page { get; set; }

public string Id { get; set; }
}

public enum AppPage
{
News,

Meetup,

Speakers,

Meetups,

Friends,

Settings,

Talk,

Speaker,

Friend,

Event,

Notification,

SocialPostImage,

Filter,

Information,

SocialPost,

Feedback,

ConferenceFeedback,

SpeakerFace,

Subscriptions
}
}


29 changes: 29 additions & 0 deletions DotNetRu.App/BasePages/BasePage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace DotNetRu.Clients.UI.Pages
{
using System.Diagnostics;
using DotNetRu.Clients.Portable.Interfaces;
using DotNetRu.Clients.Portable.Model;

public abstract class BasePage : ContentPage, IProvidePageInfo
{
private Stopwatch appeared;

public abstract AppPage PageType { get; }

protected string ItemId { get; set; }

protected override void OnAppearing()
{
this.appeared = Stopwatch.StartNew();
// App.Logger.TrackPage(this.PageType.ToString(), this.ItemId);

base.OnAppearing();
}

protected override void OnDisappearing()
{
// App.Logger.TrackTimeSpent(this.PageType.ToString(), this.ItemId, TimeSpan.FromTicks(DateTime.UtcNow.Ticks).Subtract(this.appeared.Elapsed));
base.OnDisappearing();
}
}
}
11 changes: 11 additions & 0 deletions DotNetRu.App/BasePages/ILocalize.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace DotNetRu.Clients.Portable.Interfaces
{
using System.Globalization;

public interface ILocalize
{
CultureInfo GetCurrentCultureInfo();

void SetLocale(CultureInfo cultureInfo);
}
}
10 changes: 10 additions & 0 deletions DotNetRu.App/BasePages/IProvidePageInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using DotNetRu.Clients.Portable.Model;

namespace DotNetRu.Clients.Portable.Interfaces
{
public interface IProvidePageInfo
{
AppPage PageType { get; }
}
}

28 changes: 28 additions & 0 deletions DotNetRu.App/BasePages/MenuItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Windows.Input;

using MvvmHelpers;

namespace DotNetRu.Clients.Portable.Model
{
public class MenuItem : ObservableObject
{
private string name;

public string Name
{
get => this.name;
set => this.SetProperty(ref this.name, value);
}

public string Icon {get; set; }

public ImageSource ImageSource { get; set; }

public string Parameter {get; set; }

public AppPage Page { get; set; }

public ICommand Command {get; set; }
}
}

45 changes: 45 additions & 0 deletions DotNetRu.App/BasePages/NavigationService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
namespace DotNetRu.Clients.UI.Helpers
{
/// <summary>
/// Helper navigation service to use so we don't push multiple pages at the same time.
/// </summary>
public static class NavigationService
{
static bool navigating;

/// <summary>
/// PUsh a page async
/// </summary>
/// <returns>awaitable task.</returns>
/// <param name="navigation">Navigation.</param>
/// <param name="page">Page.</param>
/// <param name="animate">If set to <c>true</c> animate.</param>
public static async Task PushAsync(INavigation navigation, Page page, bool animate = true)
{
if (navigating)
return;

navigating = true;
await navigation.PushAsync(page, animate);
navigating = false;
}

/// <summary>
/// Push a page modal async
/// </summary>
/// <returns>awaitable task.</returns>
/// <param name="navigation">Navigation.</param>
/// <param name="page">Page.</param>
/// <param name="animate">If set to <c>true</c> animate.</param>
public static async Task PushModalAsync(INavigation navigation, Page page, bool animate = true)
{
if (navigating)
return;

navigating = true;
await navigation.PushModalAsync(page, animate);
navigating = false;
}
}
}

72 changes: 72 additions & 0 deletions DotNetRu.App/DotNetRu.App.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-ios;</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>DotNetRu.App</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>

<!-- Display name -->
<ApplicationTitle>DotNetRu</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.pfedotovsky.dotnetru</ApplicationId>
<ApplicationIdGuid>c5ee66b3-443f-4a42-b8cb-934376c46de4</ApplicationIdGuid>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="Refractored.MvvmHelpers" Version="1.6.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\DotNetRu.AppUtils\DotNetRu.AppUtils.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Update="Localization\AppResources.Designer.cs">
<DependentUpon>AppResources.resx</DependentUpon>
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
</Compile>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Localization\AppResources.resx">
<LogicalName>AppResources.resx</LogicalName>
<LastGenOutput>AppResources.Designer.cs</LastGenOutput>
<Generator>PublicResXFileCodeGenerator</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Localization\AppResources.ru.resx">
<LogicalName>AppResources.ru.resx</LogicalName>
</EmbeddedResource>
</ItemGroup>

</Project>
Loading