Skip to content

Commit

Permalink
Push all changes
Browse files Browse the repository at this point in the history
  • Loading branch information
devonuto committed May 9, 2022
1 parent 8e70d9e commit efdf59d
Show file tree
Hide file tree
Showing 36 changed files with 1,060 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
################################################################################

/.vs/MauiBugs/FileContentIndex
/FormattingBug/.vs
/FormattingBug/bin/Debug/net6.0-android
/FormattingBug/obj
9 changes: 9 additions & 0 deletions FormattingBug/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?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:FormattingBug"
x:Class="FormattingBug.App">
<Application.Resources>
<ResourceDictionary Source="Resources/Styles.xaml" />
</Application.Resources>
</Application>
11 changes: 11 additions & 0 deletions FormattingBug/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace FormattingBug;

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

MainPage = new AppShell();
}
}
14 changes: 14 additions & 0 deletions FormattingBug/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="FormattingBug.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:FormattingBug"
Shell.FlyoutBehavior="Disabled">

<ShellContent
Title="Hello, World!"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />

</Shell>
9 changes: 9 additions & 0 deletions FormattingBug/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace FormattingBug;

public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
27 changes: 27 additions & 0 deletions FormattingBug/Converter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Globalization;
using System.Text.RegularExpressions;

namespace FormattingBug;

public class DecimalCurrencyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return decimal.Parse(value.ToString()).ToString("c2", culture);
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
var isNegative = Regex.IsMatch(value.ToString(), "^-", RegexOptions.CultureInvariant);
var valueFromString = Regex.Replace(value.ToString(), @"\$|,", "");

if (string.IsNullOrEmpty(valueFromString))
{
return 0m;
}

return valueFromString.Length <= 0
? 0m
: !decimal.TryParse(valueFromString, out var decimalVal) ? 0m : (object)(isNegative ? decimalVal * -1 : decimalVal);
}
}
56 changes: 56 additions & 0 deletions FormattingBug/FormattingBug.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>FormattingBug</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>

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

<!-- App Identifier -->
<ApplicationId>com.companyname.formattingbug</ApplicationId>
<ApplicationIdGuid>C042A79B-F8AD-45F0-8512-4A689CA6F3B2</ApplicationIdGuid>

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

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>

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

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\appiconfg.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="CommunityToolkit.Maui.Markup" Version="1.0.0-rc2" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0-preview3" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions FormattingBug/FormattingBug.csproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugFramework>net6.0-android</ActiveDebugFramework>
<IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen>
<ActiveDebugProfile>Pixel 5 - API 32 (Android 12.1 - API 32)</ActiveDebugProfile>
</PropertyGroup>
</Project>
22 changes: 22 additions & 0 deletions FormattingBug/MainPage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using CommunityToolkit.Maui.Markup;

namespace FormattingBug;

public class MainPage : ContentPage
{
public MainPage()
{
BindingContext = new MainPageViewModel();

var testEntry = new Entry { Placeholder = "Money", HorizontalTextAlignment = TextAlignment.End, Keyboard = Keyboard.Numeric };
testEntry.Bind(Entry.TextProperty, nameof(MainPageViewModel.EntryValue), BindingMode.TwoWay, new DecimalCurrencyConverter());
Content = new StackLayout
{
Margin = new Thickness(50),
VerticalOptions = LayoutOptions.Center,
Children = {
testEntry
}
};
}
}
13 changes: 13 additions & 0 deletions FormattingBug/MainPageViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using CommunityToolkit.Mvvm.ComponentModel;

namespace FormattingBug;

public partial class MainPageViewModel : ObservableObject
{
[ObservableProperty]
private decimal entryValue;

public MainPageViewModel()
{
}
}
21 changes: 21 additions & 0 deletions FormattingBug/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace FormattingBug;

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

builder.Services.AddSingleton<MainPage>();
builder.Services.AddSingleton<MainPageViewModel>();

return builder.Build();
}
}
5 changes: 5 additions & 0 deletions FormattingBug/Platforms/Android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?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" />
</manifest>
10 changes: 10 additions & 0 deletions FormattingBug/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 FormattingBug;

[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 FormattingBug/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 FormattingBug;

[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 FormattingBug/Platforms/Android/Resources/values/colors.xml
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>
9 changes: 9 additions & 0 deletions FormattingBug/Platforms/MacCatalyst/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Foundation;

namespace FormattingBug;

[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
30 changes: 30 additions & 0 deletions FormattingBug/Platforms/MacCatalyst/Info.plist
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>
15 changes: 15 additions & 0 deletions FormattingBug/Platforms/MacCatalyst/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using ObjCRuntime;
using UIKit;

namespace FormattingBug;

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 FormattingBug/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 FormattingBug;

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 FormattingBug/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="com.companyname.FormattingBug" version="1.0.0" api-version="7" xmlns="http://tizen.org/ns/packages">
<profile name="common" />
<ui-application appid="com.companyname.FormattingBug" exec="FormattingBug.dll" multiple="false" nodisplay="false" taskmanage="true" type="dotnet" launch_mode="single">
<label>FormattingBug</label>
<icon>appicon.xhigh.png</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 FormattingBug/Platforms/Windows/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<maui:MauiWinUIApplication
x:Class="FormattingBug.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:FormattingBug.WinUI">

</maui:MauiWinUIApplication>
24 changes: 24 additions & 0 deletions FormattingBug/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 FormattingBug.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 efdf59d

Please sign in to comment.