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

Adding Template and Misc. Fixes #2

Merged
merged 5 commits into from
Feb 22, 2023
Merged
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
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ root = true
indent_style = space
end_of_line = lf

[*.json]
indent_size = 2

[*.xaml]
indent_size = 2

Expand Down
15 changes: 15 additions & 0 deletions MauiMicroMvvm.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiMicroSample", "sample\M
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MauiMicroMvvm.Rx", "src\MauiMicroMvvm.Rx\MauiMicroMvvm.Rx.csproj", "{45A4D349-2170-4500-B076-E877DA6E015C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MauiMicroMvvm.Templates", "src\MauiMicroMvvm.Templates\MauiMicroMvvm.Templates.csproj", "{0803D0BA-65AB-4111-8202-B1E466347A65}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -60,6 +62,18 @@ Global
{45A4D349-2170-4500-B076-E877DA6E015C}.Release|x64.Build.0 = Release|Any CPU
{45A4D349-2170-4500-B076-E877DA6E015C}.Release|x86.ActiveCfg = Release|Any CPU
{45A4D349-2170-4500-B076-E877DA6E015C}.Release|x86.Build.0 = Release|Any CPU
{0803D0BA-65AB-4111-8202-B1E466347A65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0803D0BA-65AB-4111-8202-B1E466347A65}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0803D0BA-65AB-4111-8202-B1E466347A65}.Debug|x64.ActiveCfg = Debug|Any CPU
{0803D0BA-65AB-4111-8202-B1E466347A65}.Debug|x64.Build.0 = Debug|Any CPU
{0803D0BA-65AB-4111-8202-B1E466347A65}.Debug|x86.ActiveCfg = Debug|Any CPU
{0803D0BA-65AB-4111-8202-B1E466347A65}.Debug|x86.Build.0 = Debug|Any CPU
{0803D0BA-65AB-4111-8202-B1E466347A65}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0803D0BA-65AB-4111-8202-B1E466347A65}.Release|Any CPU.Build.0 = Release|Any CPU
{0803D0BA-65AB-4111-8202-B1E466347A65}.Release|x64.ActiveCfg = Release|Any CPU
{0803D0BA-65AB-4111-8202-B1E466347A65}.Release|x64.Build.0 = Release|Any CPU
{0803D0BA-65AB-4111-8202-B1E466347A65}.Release|x86.ActiveCfg = Release|Any CPU
{0803D0BA-65AB-4111-8202-B1E466347A65}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -68,6 +82,7 @@ Global
{4094C24B-1A79-46FF-BC6C-33639A824BBE} = {CAF06AA9-3F4E-4E07-A7A8-726097784A21}
{66C0C28B-59E4-40B6-A6C1-BEECC107378E} = {B8FC7CB8-399C-41C6-8D6D-0358D7E4CC25}
{45A4D349-2170-4500-B076-E877DA6E015C} = {CAF06AA9-3F4E-4E07-A7A8-726097784A21}
{0803D0BA-65AB-4111-8202-B1E466347A65} = {CAF06AA9-3F4E-4E07-A7A8-726097784A21}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {88111A1A-CBF1-447E-B8AF-0EF9432C51AC}
Expand Down
1 change: 1 addition & 0 deletions build.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"solution": {
"path": "MauiMicroMvvm.sln",
"projects": [
"src\\MauiMicroMvvm.Templates\\MauiMicroMvvm.Templates.csproj",
"src\\MauiMicroMvvm\\MauiMicroMvvm.csproj",
"src\\MauiMicroMvvm.Rx\\MauiMicroMvvm.Rx.csproj"
]
Expand Down
9 changes: 9 additions & 0 deletions sample/MauiMicroSample/AppShell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:micro="http://schemas.mauimicromvvm.com/2022/dotnet/maui"
micro:MauiMicro.Autowire="True"
FlyoutBehavior="Flyout"
xmlns:pages="clr-namespace:MauiMicroSample.Pages">

<FlyoutItem Title="Main Page"
Expand All @@ -23,4 +24,12 @@
</Tab>
</FlyoutItem>

<FlyoutItem Title="Maui Influencers"
Icon="people.png"
Route="MauiInfluencersPage">
<Tab>
<ShellContent ContentTemplate="{DataTemplate pages:MauiInfluencersPage}" />
</Tab>
</FlyoutItem>

</Shell>
3 changes: 2 additions & 1 deletion sample/MauiMicroSample/MauiMicroSample.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
Expand Down Expand Up @@ -50,6 +50,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
<PackageReference Include="Refit" Version="6.3.2" />
</ItemGroup>

<ItemGroup>
Expand Down
14 changes: 13 additions & 1 deletion sample/MauiMicroSample/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using MauiMicroSample.Modules;
using MauiMicroSample.Pages;
using MauiMicroSample.Services;
using MauiMicroSample.ViewModels;
using Microsoft.Extensions.Logging;
using Refit;

namespace MauiMicroSample;

Expand All @@ -23,7 +25,17 @@ public static MauiApp CreateMauiApp()
builder.Services.MapView<MainPage, MainPageViewModel>()
.MapView<MessageDemoPage, MessageDemoPageViewModel>()
.MapView<MessageDisplay, MessageDisplayViewModel>()
.MapView<AppShell, AppShellViewModel>();
.MapView<MauiInfluencersPage, MauiInfluencersViewModel>()
.MapView<InfluencerDetail, InfluencerDetailViewModel>()
.MapView<AppShell, AppShellViewModel>()
.AddSingleton(Connectivity.Current)
.AddSingleton(_ => new HttpClient
{
BaseAddress = new Uri("https://dansiegel.blob.core.windows.net")
})
.AddSingleton(_ => RestService.For<IApiClient>(_.GetRequiredService<HttpClient>()));

Routing.RegisterRoute($"{nameof(MauiInfluencersPage)}/{nameof(InfluencerDetail)}", typeof(InfluencerDetail));

builder.Logging.AddConsole();

Expand Down
13 changes: 13 additions & 0 deletions sample/MauiMicroSample/Models/MauiInfluencer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace MauiMicroSample.Models;

#nullable enable
public record MauiInfluencer
{
public string? Name { get; init; }
public string? GitHub { get; init; }
public string? Twitter { get; init; }
public string? Bio { get; init; }
public string? Avatar { get; init; }
public bool Mvp { get; init; }
public bool Microsoft { get; init; }
}
77 changes: 77 additions & 0 deletions sample/MauiMicroSample/Pages/InfluencerDetail.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:micro="http://schemas.mauimicromvvm.com/2022/dotnet/maui"
xmlns:vm="clr-namespace:MauiMicroSample.ViewModels"
micro:MauiMicro.Autowire="True"
x:Class="MauiMicroSample.Pages.InfluencerDetail"
x:DataType="vm:InfluencerDetailViewModel"
Title="{Binding Influencer.Name}">
<ContentPage.Resources>
<ResourceDictionary>
<Style TargetType="StackLayout">
<Setter Property="Margin" Value="20" />
</Style>
<Style TargetType="Label" Class="detailPageTitle" x:Key="DetailPageTitle">
<Setter Property="FontAttributes" Value="Bold" />
<Setter Property="FontSize" Value="Medium" />
<Setter Property="HorizontalTextAlignment" Value="Center" />
</Style>
<Style TargetType="Label" Class="detailPageSubtitle" x:Key="DetailPageSubtitle">
<Setter Property="Margin" Value="0,15,0,0" />
</Style>
<Style TargetType="Image">
<Setter Property="HeightRequest" Value="150" />
<Setter Property="WidthRequest" Value="150" />
</Style>
<Shadow x:Key="DefaultShadow" Opacity="0.9" Offset="20,20" Radius="20" Brush="Black" />
</ResourceDictionary>
</ContentPage.Resources>
<Grid RowDefinitions="Auto,*,Auto"
ColumnDefinitions="Auto,*"
Padding="15,10"
ColumnSpacing="10">
<Image Source="{Binding Influencer.Avatar}"
Shadow="{StaticResource DefaultShadow}" />
<StackLayout Grid.Column="1"
Margin="10,0"
Spacing="5">
<Label Text="{Binding Influencer.Name}"
SemanticProperties.Description="The name of the Maui Influencer"
FontSize="Title"
FontAttributes="Bold" />
<Image Source="microsoft.png"
HeightRequest="50"
WidthRequest="50"
HorizontalOptions="Start"
IsVisible="{Binding Influencer.Microsoft}" />
<Image Source="mvp.png"
HeightRequest="50"
WidthRequest="124"
HorizontalOptions="Start"
IsVisible="{Binding Influencer.Mvp}" />
</StackLayout>

<Frame HasShadow="True"
Grid.Row="1"
Grid.ColumnSpan="2"
HorizontalOptions="Start"
Margin="5,20">
<Label Text="{Binding Influencer.Bio}" />
</Frame>

<StackLayout HorizontalOptions="Center"
Orientation="Horizontal"
Margin="0,20"
Grid.Row="2"
Grid.ColumnSpan="2">
<!--<Button Text="GitHub"
Command="{Binding OpenGitHubCommand}"
Style="{DynamicResource LinkButton}" />
<Label Text=" | " />
<Button Text="Twitter"
Command="{Binding OpenTwitterCommand}"
Style="{DynamicResource LinkButton}" />-->
</StackLayout>
</Grid>
</ContentPage>
9 changes: 9 additions & 0 deletions sample/MauiMicroSample/Pages/InfluencerDetail.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace MauiMicroSample.Pages;

public partial class InfluencerDetail : ContentPage
{
public InfluencerDetail()
{
InitializeComponent();
}
}
56 changes: 56 additions & 0 deletions sample/MauiMicroSample/Pages/MauiInfluencersPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:micro="http://schemas.mauimicromvvm.com/2022/dotnet/maui"
xmlns:vm="clr-namespace:MauiMicroSample.ViewModels"
xmlns:model="clr-namespace:MauiMicroSample.Models"
micro:MauiMicro.Autowire="True"
x:Class="MauiMicroSample.Pages.MauiInfluencersPage"
x:DataType="vm:MauiInfluencersViewModel"
x:Name="page"
Title="Maui Influencers">
<ContentPage.Resources>
<ResourceDictionary>
<Style TargetType="Image">
<Setter Property="HeightRequest" Value="60" />
<Setter Property="WidthRequest" Value="60" />
<Setter Property="Margin" Value="10,0" />
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<CollectionView ItemsSource="{Binding Influencers}">
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid x:DataType="model:MauiInfluencer"
Padding="10"
RowDefinitions="Auto,*"
ColumnDefinitions="Auto,*">
<Grid.GestureRecognizers>
<TapGestureRecognizer Command="{Binding BindingContext.RowSelected, Source={x:Reference page}}"
CommandParameter="{Binding .}" />
</Grid.GestureRecognizers>
<Image Grid.RowSpan="2"
Source="{Binding Avatar}"
Aspect="AspectFill" />
<Label Grid.Column="1"
Text="{Binding Name}" />

<Image Source="microsoft.png"
HeightRequest="25"
WidthRequest="25"
HorizontalOptions="Start"
IsVisible="{Binding Microsoft}"
Grid.Row="1"
Grid.Column="1" />
<Image Source="mvp.png"
HeightRequest="25"
WidthRequest="62"
HorizontalOptions="Start"
IsVisible="{Binding Mvp}"
Grid.Row="1"
Grid.Column="1" />
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</ContentPage>
9 changes: 9 additions & 0 deletions sample/MauiMicroSample/Pages/MauiInfluencersPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace MauiMicroSample.Pages;

public partial class MauiInfluencersPage : ContentPage
{
public MauiInfluencersPage()
{
InitializeComponent();
}
}
9 changes: 9 additions & 0 deletions sample/MauiMicroSample/Resources/Images/microsoft.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/MauiMicroSample/Resources/Images/mvp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions sample/MauiMicroSample/Resources/Images/people.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions sample/MauiMicroSample/Services/IApiClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using MauiMicroSample.Models;
using Refit;

namespace MauiMicroSample.Services;

public interface IApiClient
{
[Get("/media/maui-devs.json")]
Task<ApiResponse<IEnumerable<MauiInfluencer>>> GetInfluencers();
}
23 changes: 23 additions & 0 deletions sample/MauiMicroSample/ViewModels/InfluencerDetailViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using MauiMicroMvvm;
using MauiMicroSample.Models;

namespace MauiMicroSample.ViewModels;

public class InfluencerDetailViewModel : MauiMicroViewModel
{
public InfluencerDetailViewModel(ViewModelContext context)
: base(context)
{
}

public MauiInfluencer Influencer
{
get => Get<MauiInfluencer>();
set => Set(value);
}

protected override void OnParametersSet()
{
base.OnParametersSet();
}
}
Loading