Skip to content

Commit

Permalink
Add project task-list-app-maui in MauiSamples (#375)
Browse files Browse the repository at this point in the history
Co-authored-by: Vladislav Antonyuk <[email protected]>
  • Loading branch information
jfs-dev and VladislavAntonyuk authored Oct 30, 2023
1 parent a4b3121 commit 7ff5637
Show file tree
Hide file tree
Showing 51 changed files with 1,810 additions and 0 deletions.
14 changes: 14 additions & 0 deletions task-list-app-maui/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:task_list_app_maui"
x:Class="task_list_app_maui.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
11 changes: 11 additions & 0 deletions task-list-app-maui/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace task_list_app_maui;

public partial class App : Application
{
public App()
{
InitializeComponent();

MainPage = new AppShell();
}
}
34 changes: 34 additions & 0 deletions task-list-app-maui/AppShell.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="task_list_app_maui.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:task_list_app_maui.Views"
Shell.FlyoutBehavior="Disabled"
Shell.BackgroundColor="DarkGreen"
Title="Task List">

<Shell.ToolbarItems>
<ToolbarItem Text="Search"
IconImageSource="search.png"
Clicked="OnSearchClicked" />

<ToolbarItem Text="About"
Order="Secondary"
Clicked="OnAboutClicked" />
</Shell.ToolbarItems>

<TabBar>
<Tab Title="Pending Tasks"
Icon="task_list.png">

<ShellContent ContentTemplate="{DataTemplate views:TarefasPendentesView}" />
</Tab>

<Tab Title="Completed Tasks"
Icon="task_check.png">

<ShellContent ContentTemplate="{DataTemplate views:TarefasConcluidasView}" />
</Tab>
</TabBar>
</Shell>
19 changes: 19 additions & 0 deletions task-list-app-maui/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace task_list_app_maui;

public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}

private void OnSearchClicked(object sender, EventArgs e)
{
DisplayAlert(Title, "Search Tasks", "OK");
}

private void OnAboutClicked(object sender, EventArgs e)
{
DisplayAlert(Title, "Information about the Task List app", "OK");
}
}
9 changes: 9 additions & 0 deletions task-list-app-maui/Data/AppDbContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Microsoft.EntityFrameworkCore;
using task_list_app_maui.Models;

namespace task_list_app_maui.Data;

public class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)
{
public DbSet<Tarefa> Tarefas { get; set; }
}
32 changes: 32 additions & 0 deletions task-list-app-maui/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using CommunityToolkit.Maui;
using Microsoft.EntityFrameworkCore;
using task_list_app_maui.Data;
using task_list_app_maui.ViewModels;
using task_list_app_maui.Views;

namespace task_list_app_maui;

public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiCommunityToolkit()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});

builder.Services.AddDbContext<AppDbContext>(options => { options.UseInMemoryDatabase("task-list-app-maui"); });

builder.Services.AddSingleton<TarefasViewModel>();

builder.Services.AddSingleton<TarefasPendentesView>();
builder.Services.AddSingleton<TarefasConcluidasView>();

return builder.Build();
}
}
30 changes: 30 additions & 0 deletions task-list-app-maui/Models/Tarefa.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.ComponentModel.DataAnnotations;
using CommunityToolkit.Mvvm.ComponentModel;

namespace task_list_app_maui.Models;

public class Tarefa : ObservableValidator
{
private int id;
private string descricao = string.Empty;
private DateTime data;
private TimeSpan hora;
private bool concluida;

[Key]
[Required]
public int Id { get => id; set => SetProperty(ref id, value, true); }

[Required]
[MaxLength(60)]
public string Descricao { get => descricao; set => SetProperty(ref descricao, value, true); }

[Required]
public DateTime Data { get => data; set => SetProperty(ref data, value, true); }

[Required]
public TimeSpan Hora { get => hora; set => SetProperty(ref hora, value, true); }

[Required]
public bool Concluida { get => concluida; set => SetProperty(ref concluida, value, true); }
}
6 changes: 6 additions & 0 deletions task-list-app-maui/Platforms/Android/AndroidManifest.xml
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>
10 changes: 10 additions & 0 deletions task-list-app-maui/Platforms/Android/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Android.App;
using Android.Content.PM;
using Android.OS;

namespace task_list_app_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 task-list-app-maui/Platforms/Android/MainApplication.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Android.App;
using Android.Runtime;

namespace task_list_app_maui;

[Application]
public class MainApplication : MauiApplication
{
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}

protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
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">#006400</color>
<color name="colorPrimaryDark">#006400</color>
<color name="colorAccent">#006400</color>
</resources>
9 changes: 9 additions & 0 deletions task-list-app-maui/Platforms/MacCatalyst/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Foundation;

namespace task_list_app_maui;

[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
11 changes: 11 additions & 0 deletions task-list-app-maui/Platforms/MacCatalyst/Entitlements.Debug.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?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>
<!-- Enable this value to use browser developer tools while debugging.-->
<!-- See https://aka.ms/blazor-hybrid-developer-tools -->
<key>com.apple.security.get-task-allow</key>
<true/>
</dict>
</plist>

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?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">
<!-- See https://aka.ms/maui-publish-app-store#add-entitlements for more information about adding entitlements.-->
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>

38 changes: 38 additions & 0 deletions task-list-app-maui/Platforms/MacCatalyst/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?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>
<!-- The Mac App Store requires you specify if the app uses encryption. -->
<!-- Please consult https://developer.apple.com/documentation/bundleresources/information_property_list/itsappusesnonexemptencryption -->
<!-- <key>ITSAppUsesNonExemptEncryption</key> -->
<!-- Please indicate <true/> or <false/> here. -->

<!-- Specify the category for your app here. -->
<!-- Please consult https://developer.apple.com/documentation/bundleresources/information_property_list/lsapplicationcategorytype -->
<!-- <key>LSApplicationCategoryType</key> -->
<!-- <string>public.app-category.YOUR-CATEGORY-HERE</string> -->
<key>UIDeviceFamily</key>
<array>
<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>
15 changes: 15 additions & 0 deletions task-list-app-maui/Platforms/MacCatalyst/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using ObjCRuntime;
using UIKit;

namespace task_list_app_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));
}
}
16 changes: 16 additions & 0 deletions task-list-app-maui/Platforms/Tizen/Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using Microsoft.Maui;
using Microsoft.Maui.Hosting;

namespace task_list_app_maui;

class Program : MauiApplication
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();

static void Main(string[] args)
{
var app = new Program();
app.Run(args);
}
}
15 changes: 15 additions & 0 deletions task-list-app-maui/Platforms/Tizen/tizen-manifest.xml
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="task-list-app-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>
8 changes: 8 additions & 0 deletions task-list-app-maui/Platforms/Windows/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<maui:MauiWinUIApplication
x:Class="task_list_app_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:task_list_app_maui.WinUI">

</maui:MauiWinUIApplication>
24 changes: 24 additions & 0 deletions task-list-app-maui/Platforms/Windows/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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 task_list_app_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();
}

Loading

0 comments on commit 7ff5637

Please sign in to comment.