This repository has been archived by the owner on Nov 4, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
282 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using mavvm.Interfaces; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Maui; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific; | ||
|
||
namespace mavvmApp | ||
{ | ||
public partial class AppShell : Shell | ||
public partial class AppShell : IShellWithTabBar | ||
{ | ||
public AppShell() | ||
{ | ||
InitializeComponent(); | ||
} | ||
InitializeComponent(); | ||
|
||
TabBar = MainTabbar; | ||
} | ||
|
||
public TabBar TabBar { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using CommunityToolkit.Mvvm.Input; | ||
using mavvm; | ||
|
||
namespace mavvmApp.ViewModels | ||
{ | ||
public partial class LastPageViewModel : BindableBase, INavigateToAware | ||
{ | ||
|
||
[ICommand] | ||
async void GoBack() | ||
{ | ||
await BaseMethods.GoBack(parameters: new NavigationParameters {{"testKey3","testValue3" }}); | ||
} | ||
|
||
[ICommand] | ||
async void GoToSecondTabPage() | ||
{ | ||
await BaseMethods.GoToViewModel<SecondTabPageViewModel>(parameters: new NavigationParameters { { "testKey4", "testValue4" } }); | ||
} | ||
|
||
public void NavigatedTo(NavigationParameters parameters) | ||
{ | ||
Console.WriteLine(parameters); | ||
} | ||
|
||
public LastPageViewModel() | ||
{ | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:viewmodels="clr-namespace:mavvmApp.ViewModels" | ||
x:Class="mavvmApp.Views.LastPage" | ||
Title="{Binding Title}" | ||
BackgroundColor="{DynamicResource SecondaryColor}" | ||
Shell.PresentationMode="Animated"> | ||
|
||
|
||
<ScrollView> | ||
<Grid RowSpacing="25" RowDefinitions="Auto,Auto,Auto,Auto,*" | ||
Padding="{OnPlatform iOS='30,60,30,30', Default='30'}"> | ||
|
||
<Label | ||
Text="Hello, World!" | ||
Grid.Row="0" | ||
SemanticProperties.HeadingLevel="Level1" | ||
FontSize="32" | ||
HorizontalOptions="Center" /> | ||
|
||
<Label | ||
Text="Welcome to .NET Multi-platform App UI" | ||
Grid.Row="1" | ||
SemanticProperties.HeadingLevel="Level1" | ||
SemanticProperties.Description="Welcome to dot net Multi platform App U I" | ||
FontSize="18" | ||
HorizontalOptions="Center" /> | ||
|
||
<Label | ||
Text="{Binding Count, StringFormat='Current count: {0}'}" | ||
Grid.Row="2" | ||
FontSize="18" | ||
FontAttributes="Bold" | ||
HorizontalOptions="Center" /> | ||
|
||
<Button Text="GoBack" | ||
Grid.Row="3" Command="{Binding GoBackCommand}"/> | ||
<Button Text="Go to SecondTab" | ||
Grid.Row="4" Command="{Binding GoToSecondTabPageCommand}"/> | ||
|
||
</Grid> | ||
</ScrollView> | ||
</ContentPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using mavvmApp.ViewModels; | ||
using Microsoft.Maui.Controls; | ||
|
||
namespace mavvmApp.Views | ||
{ | ||
public partial class LastPage : ContentPage | ||
{ | ||
public LastPage() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
namespace mavvm.Attibutes | ||
{ | ||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] | ||
public class TabRouteAttribute : Attribute | ||
{ | ||
public string TabRoute { get; } | ||
|
||
public TabRouteAttribute(string tabRoute) | ||
{ | ||
TabRoute = tabRoute; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Reflection; | ||
using mavvm.Attibutes; | ||
using Microsoft.Maui.Controls; | ||
|
||
namespace mavvm.Customs | ||
{ | ||
public class MavvmShellTab : Tab | ||
{ | ||
protected override void OnChildAdded(Element child) | ||
{ | ||
base.OnChildAdded(child); | ||
|
||
var vmContent = (child as MavvmShellContent); | ||
var vm = vmContent?.ViewModel; | ||
if (vm is null) return; | ||
|
||
var attrib = vm.GetCustomAttribute<TabRouteAttribute>(); | ||
if (attrib is null) return; | ||
|
||
(child as MavvmShellContent).Route = attrib.TabRoute; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Xaml; | ||
|
||
namespace mavvm | ||
{ | ||
[ContentProperty(nameof(ViewModel))] | ||
public class GetOrCreateContent : IMarkupExtension | ||
{ | ||
public Type ViewModel { get; set; } | ||
|
||
public object ProvideValue(IServiceProvider serviceProvider) => | ||
new DataTemplate(() => Routing.GetOrCreateContent(ViewModel.Name)); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
using Microsoft.Maui.Controls; | ||
|
||
namespace mavvm.Interfaces | ||
{ | ||
public interface IShellWithTabBar | ||
{ | ||
TabBar TabBar { get; } | ||
} | ||
} | ||
|
Oops, something went wrong.