Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
vitash committed Dec 6, 2024
0 parents commit c8d1293
Show file tree
Hide file tree
Showing 21 changed files with 710 additions and 0 deletions.
454 changes: 454 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions AvaCs3.Android/AvaCs3.Android.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0-android</TargetFramework>
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
<Nullable>enable</Nullable>
<ApplicationId>com.CompanyName.AvaloniaTest</ApplicationId>
<ApplicationVersion>1</ApplicationVersion>
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<AndroidPackageFormat>apk</AndroidPackageFormat>
<AndroidEnableProfiledAot>true</AndroidEnableProfiledAot>
</PropertyGroup>

<ItemGroup>
<AndroidResource Include="Icon.png">
<Link>Resources\drawable\Icon.png</Link>
</AndroidResource>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia.Android" Version="$(AvaloniaVersion)" />
<PackageReference Include="Microsoft.NET.Runtime.MonoAOTCompiler.Task" Version="9.0.0" />
<PackageReference Include="Xamarin.AndroidX.Core.SplashScreen" Version="1.0.1.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AvaCs3\AvaCs3.csproj" />
</ItemGroup>
</Project>
Binary file added AvaCs3.Android/Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions AvaCs3.Android/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Android.App;
using Android.Content.PM;

using Avalonia;
using Avalonia.Android;
using Avalonia.ReactiveUI;

namespace AvaCs3.Android;

[Activity(
Label = "AvaCs3.Android",
Theme = "@style/MyTheme.NoActionBar",
Icon = "@drawable/icon",
MainLauncher = true,
ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.UiMode)]
public class MainActivity : AvaloniaMainActivity<App>
{
protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
{
return base.CustomizeAppBuilder(builder)
.WithInterFont()
.UseReactiveUI();
}
}
5 changes: 5 additions & 0 deletions AvaCs3.Android/Properties/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" android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="AvaloniaTest" android:icon="@drawable/Icon" />
</manifest>
13 changes: 13 additions & 0 deletions AvaCs3.Android/Resources/drawable/splash_screen.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item>
<color android:color="@color/splash_background"/>
</item>

<item android:drawable="@drawable/icon"
android:width="120dp"
android:height="120dp"
android:gravity="center" />

</layer-list>
4 changes: 4 additions & 0 deletions AvaCs3.Android/Resources/values-night/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="splash_background">#212121</color>
</resources>
4 changes: 4 additions & 0 deletions AvaCs3.Android/Resources/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="splash_background">#FFFFFF</color>
</resources>
12 changes: 12 additions & 0 deletions AvaCs3.Android/Resources/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<resources>

<style name="MyTheme">
</style>

<style name="MyTheme.NoActionBar" parent="@style/Theme.AppCompat.DayNight.NoActionBar">
<item name="android:windowActionBar">false</item>
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>
30 changes: 30 additions & 0 deletions AvaCs3.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35527.113 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvaCs3", "AvaCs3\AvaCs3.csproj", "{B8E23406-51C5-4181-B8B3-85A216EA893A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvaCs3.Android", "AvaCs3.Android\AvaCs3.Android.csproj", "{B206A310-BC2E-408E-9445-1BD6ED9F078D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B8E23406-51C5-4181-B8B3-85A216EA893A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8E23406-51C5-4181-B8B3-85A216EA893A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B8E23406-51C5-4181-B8B3-85A216EA893A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B8E23406-51C5-4181-B8B3-85A216EA893A}.Release|Any CPU.Build.0 = Release|Any CPU
{B206A310-BC2E-408E-9445-1BD6ED9F078D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B206A310-BC2E-408E-9445-1BD6ED9F078D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B206A310-BC2E-408E-9445-1BD6ED9F078D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{B206A310-BC2E-408E-9445-1BD6ED9F078D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B206A310-BC2E-408E-9445-1BD6ED9F078D}.Release|Any CPU.Build.0 = Release|Any CPU
{B206A310-BC2E-408E-9445-1BD6ED9F078D}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
10 changes: 10 additions & 0 deletions AvaCs3/App.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="AvaCs3.App"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->

<Application.Styles>
<FluentTheme />
</Application.Styles>
</Application>
36 changes: 36 additions & 0 deletions AvaCs3/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using AvaCs3.ViewModels;
using AvaCs3.Views;

using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;

namespace AvaCs3;

public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}

public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow
{
DataContext = new MainViewModel()
};
}
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
{
singleViewPlatform.MainView = new MainView
{
DataContext = new MainViewModel()
};
}

base.OnFrameworkInitializationCompleted();
}
}
Binary file added AvaCs3/Assets/avalonia-logo.ico
Binary file not shown.
20 changes: 20 additions & 0 deletions AvaCs3/AvaCs3.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<AvaloniaResource Include="Assets\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.ReactiveUI" Version="$(AvaloniaVersion)" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
</ItemGroup>
</Project>
6 changes: 6 additions & 0 deletions AvaCs3/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace AvaCs3.ViewModels;

public class MainViewModel : ViewModelBase
{
public string Greeting => "Welcome to Avalonia!";
}
7 changes: 7 additions & 0 deletions AvaCs3/ViewModels/ViewModelBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using ReactiveUI;

namespace AvaCs3.ViewModels;

public class ViewModelBase : ReactiveObject
{
}
16 changes: 16 additions & 0 deletions AvaCs3/Views/MainView.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:AvaCs3.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="AvaCs3.Views.MainView"
x:DataType="vm:MainViewModel">
<Design.DataContext>
<!-- This only sets the DataContext for the previewer in an IDE,
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
<vm:MainViewModel />
</Design.DataContext>

<TextBlock Text="{Binding Greeting}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</UserControl>
11 changes: 11 additions & 0 deletions AvaCs3/Views/MainView.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Avalonia.Controls;

namespace AvaCs3.Views;

public partial class MainView : UserControl
{
public MainView()
{
InitializeComponent();
}
}
12 changes: 12 additions & 0 deletions AvaCs3/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:AvaCs3.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:AvaCs3.Views"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="AvaCs3.Views.MainWindow"
Icon="/Assets/avalonia-logo.ico"
Title="AvaCs3">
<views:MainView />
</Window>
11 changes: 11 additions & 0 deletions AvaCs3/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Avalonia.Controls;

namespace AvaCs3.Views;

public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
6 changes: 6 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project>
<PropertyGroup>
<Nullable>enable</Nullable>
<AvaloniaVersion>11.1.0</AvaloniaVersion>
</PropertyGroup>
</Project>

0 comments on commit c8d1293

Please sign in to comment.