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
39 changed files
with
1,365 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "maui", "maui\maui.csproj", "{02F3277E-C9F4-4917-ADCE-D26EAD8860FC}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "About", "About", "{1A5C33A3-3B5A-418E-A6D8-E63CBAEC269E}" | ||
ProjectSection(SolutionItems) = preProject | ||
readme.md = readme.md | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{02F3277E-C9F4-4917-ADCE-D26EAD8860FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{02F3277E-C9F4-4917-ADCE-D26EAD8860FC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{02F3277E-C9F4-4917-ADCE-D26EAD8860FC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{02F3277E-C9F4-4917-ADCE-D26EAD8860FC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
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,13 @@ | ||
using DryIoc; | ||
using maui.Pages; | ||
using IContainer = DryIoc.IContainer; | ||
|
||
namespace maui; | ||
|
||
public partial class App : Application | ||
{ | ||
public App(IContainer container) | ||
{ | ||
MainPage = container.Resolve<MainPage>(); | ||
} | ||
} |
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,26 @@ | ||
namespace maui.BaseTypes; | ||
|
||
// imagine these were good page base classes | ||
public abstract class BasePage : ContentPage { } | ||
public abstract class BasePage<TViewModel> : BasePage | ||
where TViewModel : BaseViewModel | ||
{ | ||
public TViewModel ViewModel { get; set; } | ||
|
||
public BasePage(TViewModel viewModel) | ||
{ | ||
ViewModel = viewModel; | ||
} | ||
} | ||
|
||
// imagine this was a good view model base class with inotify etc. | ||
public abstract class BaseViewModel | ||
{ | ||
|
||
} | ||
|
||
// imagine this was a good view model base class | ||
public abstract class BaseService | ||
{ | ||
|
||
} |
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,35 @@ | ||
using DryIoc; | ||
using maui.BaseTypes; | ||
using IContainer = DryIoc.IContainer; | ||
|
||
namespace maui; | ||
|
||
public static class ContainerExtensions | ||
{ | ||
// called at startup and by reload manager to update container types | ||
public static IContainer RegisterApplicationTypes(this IContainer container, params Type[] types) | ||
{ | ||
foreach (var t in types.Where(t => !t.IsAbstract)) | ||
{ | ||
// register pages and viewmodels for direct resolution | ||
if (t.IsSubclassOf(typeof(Page)) || t.IsSubclassOf(typeof(BaseViewModel))) | ||
{ | ||
container.Register(t, reuse: Reuse.Transient); | ||
|
||
// if you were using shell or prism you could add/overwrite the route registration here | ||
} | ||
|
||
// register services against interfaces | ||
// use 'IfAlreadyRegistered.Replace' to replace existing registrations | ||
if (t.IsSubclassOf(typeof(BaseService))) | ||
{ | ||
container.RegisterMany( | ||
new [] { t }, | ||
serviceTypeCondition: _ => true, | ||
ifAlreadyRegistered: IfAlreadyRegistered.Replace); | ||
} | ||
} | ||
|
||
return container; | ||
} | ||
} |
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,59 @@ | ||
using CommunityToolkit.Maui.Markup; | ||
using DryIoc; | ||
using DryIoc.Microsoft.DependencyInjection; | ||
using maui.Reload; | ||
using Microsoft.Extensions.Logging; | ||
using Tbc.Target.Config; | ||
using Debug = System.Diagnostics.Debug; | ||
using IContainer = DryIoc.IContainer; | ||
|
||
namespace maui; | ||
|
||
public static class MauiProgram | ||
{ | ||
public static MauiApp CreateMauiApp() | ||
{ | ||
var builder = MauiApp.CreateBuilder(); | ||
var container = ConfigureMutableContainer(builder); | ||
|
||
builder | ||
.UseMauiApp<App>() | ||
.UseMauiCommunityToolkitMarkup() | ||
.ConfigureFonts(fonts => | ||
{ | ||
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); | ||
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); | ||
}); | ||
|
||
#if DEBUG | ||
builder.Logging.AddDebug(); | ||
#endif | ||
|
||
var app = builder.Build(); | ||
|
||
#if DEBUG | ||
Task.Run(() => RunTbc(app, container)); | ||
#endif | ||
return app; | ||
} | ||
|
||
private static async Task RunTbc(MauiApp app, IContainer container) | ||
{ | ||
var rm = new ReloadManager(container); | ||
var ts = new Tbc.Target.TargetServer(TargetConfiguration.Default(port: 50129)); | ||
await ts.Run(rm, x => Debug.WriteLine(x)); | ||
} | ||
|
||
private static IContainer ConfigureMutableContainer(MauiAppBuilder builder) | ||
{ | ||
// this is the dryioc container | ||
var container = | ||
new Container(Rules.MicrosoftDependencyInjectionRules) | ||
.RegisterApplicationTypes(typeof(MauiProgram).Assembly.GetTypes()); | ||
|
||
// this makes it maui friendly | ||
builder.ConfigureContainer(new DryIocServiceProviderFactory(container)); | ||
|
||
return container; | ||
} | ||
} |
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,47 @@ | ||
using CommunityToolkit.Maui.Markup; | ||
using maui.BaseTypes; | ||
|
||
namespace maui.Pages; | ||
|
||
public class MainPage : BasePage<MainViewModel> | ||
{ | ||
public MainPage(MainViewModel vm) : base(vm) | ||
{ | ||
BackgroundColor = Colors.Blue; | ||
|
||
Content = | ||
new StackLayout | ||
{ | ||
Children = | ||
{ | ||
new Label { Text = vm.MyString } | ||
.TextColor(Colors.Red) | ||
.TextCenter(), | ||
} | ||
}.Center(); | ||
} | ||
} | ||
|
||
public class MainViewModel : BaseViewModel | ||
{ | ||
private readonly IMyService _myService; | ||
|
||
public string MyString { get; set; } | ||
|
||
public MainViewModel(IMyService myService) | ||
{ | ||
_myService = myService; | ||
|
||
MyString = _myService.MyString; | ||
} | ||
} | ||
|
||
|
||
public interface IMyService | ||
{ | ||
string MyString { get; } | ||
} | ||
public class MyService : BaseService, IMyService | ||
{ | ||
public string MyString => "service string"; | ||
} |
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,10 @@ | ||
namespace maui.Pages; | ||
|
||
public class OtherPage : ContentPage | ||
{ | ||
public OtherPage() | ||
{ | ||
BackgroundColor = Colors.Red; | ||
} | ||
} | ||
|
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
</manifest> |
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,12 @@ | ||
using Android.App; | ||
using Android.Content.PM; | ||
using Android.OS; | ||
|
||
namespace maui; | ||
|
||
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, | ||
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | | ||
ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] | ||
public class MainActivity : MauiAppCompatActivity | ||
{ | ||
} |
15 changes: 15 additions & 0 deletions
15
src/samples/maui/maui/Platforms/Android/MainApplication.cs
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 Android.App; | ||
using Android.Runtime; | ||
|
||
namespace maui; | ||
|
||
[Application] | ||
public class MainApplication : MauiApplication | ||
{ | ||
public MainApplication(IntPtr handle, JniHandleOwnership ownership) | ||
: base(handle, ownership) | ||
{ | ||
} | ||
|
||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
} |
6 changes: 6 additions & 0 deletions
6
src/samples/maui/maui/Platforms/Android/Resources/values/colors.xml
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="colorPrimary">#512BD4</color> | ||
<color name="colorPrimaryDark">#2B0B98</color> | ||
<color name="colorAccent">#2B0B98</color> | ||
</resources> |
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,9 @@ | ||
using Foundation; | ||
|
||
namespace maui; | ||
|
||
[Register("AppDelegate")] | ||
public class AppDelegate : MauiUIApplicationDelegate | ||
{ | ||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
} |
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,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>UIDeviceFamily</key> | ||
<array> | ||
<integer>1</integer> | ||
<integer>2</integer> | ||
</array> | ||
<key>UIRequiredDeviceCapabilities</key> | ||
<array> | ||
<string>arm64</string> | ||
</array> | ||
<key>UISupportedInterfaceOrientations</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
<string>UIInterfaceOrientationLandscapeLeft</string> | ||
<string>UIInterfaceOrientationLandscapeRight</string> | ||
</array> | ||
<key>UISupportedInterfaceOrientations~ipad</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
<string>UIInterfaceOrientationPortraitUpsideDown</string> | ||
<string>UIInterfaceOrientationLandscapeLeft</string> | ||
<string>UIInterfaceOrientationLandscapeRight</string> | ||
</array> | ||
<key>XSAppIconAssets</key> | ||
<string>Assets.xcassets/appicon.appiconset</string> | ||
</dict> | ||
</plist> |
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 ObjCRuntime; | ||
using UIKit; | ||
|
||
namespace maui; | ||
|
||
public class Program | ||
{ | ||
// This is the main entry point of the application. | ||
static void Main(string[] args) | ||
{ | ||
// if you want to use a different Application Delegate class from "AppDelegate" | ||
// you can specify it here. | ||
UIApplication.Main(args, null, typeof(AppDelegate)); | ||
} | ||
} |
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; | ||
using Microsoft.Maui.Hosting; | ||
|
||
namespace maui; | ||
|
||
class Program : MauiApplication | ||
{ | ||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
|
||
static void Main(string[] args) | ||
{ | ||
var app = new Program(); | ||
app.Run(args); | ||
} | ||
} |
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="maui-application-id-placeholder" version="0.0.0" api-version="7" xmlns="http://tizen.org/ns/packages"> | ||
<profile name="common" /> | ||
<ui-application appid="maui-application-id-placeholder" exec="maui.dll" multiple="false" nodisplay="false" taskmanage="true" type="dotnet" launch_mode="single"> | ||
<label>maui-application-title-placeholder</label> | ||
<icon>maui-appicon-placeholder</icon> | ||
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" /> | ||
</ui-application> | ||
<shortcut-list /> | ||
<privileges> | ||
<privilege>http://tizen.org/privilege/internet</privilege> | ||
</privileges> | ||
<dependencies /> | ||
<provides-appdefined-privileges /> | ||
</manifest> |
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,8 @@ | ||
<maui:MauiWinUIApplication | ||
x:Class="maui.WinUI.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:maui="using:Microsoft.Maui" | ||
xmlns:local="using:maui.WinUI"> | ||
|
||
</maui:MauiWinUIApplication> |
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,23 @@ | ||
using Microsoft.UI.Xaml; | ||
|
||
// To learn more about WinUI, the WinUI project structure, | ||
// and more about our project templates, see: http://aka.ms/winui-project-info. | ||
|
||
namespace maui.WinUI; | ||
|
||
/// <summary> | ||
/// Provides application-specific behavior to supplement the default Application class. | ||
/// </summary> | ||
public partial class App : MauiWinUIApplication | ||
{ | ||
/// <summary> | ||
/// Initializes the singleton application object. This is the first line of authored code | ||
/// executed, and as such is the logical equivalent of main() or WinMain(). | ||
/// </summary> | ||
public App() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
} |
Oops, something went wrong.