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

Add the Fabimals sample #450

Merged
merged 9 commits into from
Jun 18, 2019
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
151 changes: 127 additions & 24 deletions Fabulous.sln

Large diffs are not rendered by default.

13 changes: 4 additions & 9 deletions samples/AllControls/UWP/AllControls.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,9 @@
</Page>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms">
<Version>3.4.0.1009999</Version>
</PackageReference>
<PackageReference Include="FSharp.Core">
<Version>4.5.2</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.1.9</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" />
<PackageReference Include="FSharp.Core" />
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\Fabulous.Core\Fabulous.Core.fsproj">
Expand Down Expand Up @@ -188,4 +182,5 @@
<Target Name="AfterBuild">
</Target>
-->
<Import Project="..\..\..\Packages.targets" />
</Project>
12 changes: 3 additions & 9 deletions samples/Calculator/UWP/Calculator.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,9 @@
</Page>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms">
<Version>3.4.0.1009999</Version>
</PackageReference>
<PackageReference Include="FSharp.Core">
<Version>4.5.2</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.1.9</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" />
<PackageReference Include="FSharp.Core" />
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\Fabulous.Core\Fabulous.Core.fsproj">
Expand Down
12 changes: 3 additions & 9 deletions samples/CounterApp/UWP/CounterApp.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,9 @@
</Page>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms">
<Version>3.4.0.1009999</Version>
</PackageReference>
<PackageReference Include="FSharp.Core">
<Version>4.5.2</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.1.9</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" />
<PackageReference Include="FSharp.Core" />
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\Fabulous.Core\Fabulous.Core.fsproj">
Expand Down
21 changes: 21 additions & 0 deletions samples/Shell/Fabimals/Droid/AssemblyInfo.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace Droid

open System.Reflection
open System.Runtime.CompilerServices

// the name of the type here needs to match the name inside the ResourceDesigner attribute
type Resources = Droid.Resource

[<assembly:Android.Runtime.ResourceDesigner("Droid.Resources", IsApplication = true)>]
[<assembly:AssemblyTitle("Fabimals.Droid")>]
[<assembly:AssemblyDescription("")>]
[<assembly:AssemblyConfiguration("")>]
[<assembly:AssemblyCompany("")>]
[<assembly:AssemblyProduct("")>]
[<assembly:AssemblyCopyright("")>]
[<assembly:AssemblyTrademark("")>]
[<assembly:AssemblyVersion("1.0.0.0")>]
()
// The assembly version has the format {Major}.{Minor}.{Build}.{Revision}
//[<assembly: AssemblyDelaySign(false)>]
//[<assembly: AssemblyKeyFile("")>]
19 changes: 19 additions & 0 deletions samples/Shell/Fabimals/Droid/Assets/AboutAssets.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Any raw assets you want to be deployed with your application can be placed in
this directory (and child directories) and given a Build Action of "AndroidAsset".

These files will be deployed with your package and will be accessible using Android's
AssetManager, like this:

public class ReadAsset : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);

InputStream input = Assets.Open ("my_asset.txt");
}
}

Additionally, some Android functions will automatically load asset files:

Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
289 changes: 289 additions & 0 deletions samples/Shell/Fabimals/Droid/Fabimals.Droid.fsproj

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions samples/Shell/Fabimals/Droid/MainActivity.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace Droid

open System
open Android.App
open Android.Content
open Android.Content.PM
open Android.Runtime
open Android.Views
open Android.Widget
open Android.OS
open Xamarin.Forms.Platform.Android

[<Activity(Label = "Fabimals", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = (ConfigChanges.ScreenSize ||| ConfigChanges.Orientation))>]
type MainActivity() =
inherit FormsAppCompatActivity()
override this.OnCreate(bundle : Bundle) =
FormsAppCompatActivity.TabLayoutResource <- Resources.Layout.Tabbar
SergejDK marked this conversation as resolved.
Show resolved Hide resolved
FormsAppCompatActivity.ToolbarResource <- Resources.Layout.Toolbar
base.OnCreate(bundle)
Xamarin.Forms.Forms.SetFlags("CollectionView_Experimental")
this.Window.SetStatusBarColor(Android.Graphics.Color.Argb(255, 0, 0, 0))
Xamarin.Forms.Forms.Init (this, bundle)

this.LoadApplication (new Fabimals.FabimalsApp ())
5 changes: 5 additions & 0 deletions samples/Shell/Fabimals/Droid/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:versionCode="1" android:versionName="1.0" package="org.fabulous.Fabimals">
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="28" />
<application android:label="Fabimals" android:icon="@mipmap/icon"></application>
</manifest>
44 changes: 44 additions & 0 deletions samples/Shell/Fabimals/Droid/Resources/AboutResources.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Images, layout descriptions, binary blobs and string dictionaries can be included
in your application as resource files. Various Android APIs are designed to
operate on the resource IDs instead of dealing with images, strings or binary blobs
directly.

For example, a sample Android app that contains a user interface layout (main.axml),
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
would keep its resources in the "Resources" directory of the application:

Resources/
drawable/
icon.png

layout/
main.axml

values/
strings.xml

In order to get the build system to recognize Android resources, set the build action to
"AndroidResource". The native Android APIs do not operate directly with filenames, but
instead operate on resource IDs. When you compile an Android application that uses resources,
the build system will package the resources for distribution and generate a class called "R"
(this is an Android convention) that contains the tokens for each one of the resources
included. For example, for the above Resources layout, this is what the R class would expose:

public class R {
public class drawable {
public const int icon = 0x123;
}

public class layout {
public const int main = 0x456;
}

public class strings {
public const int first_string = 0xabc;
public const int second_string = 0xbcd;
}
}

You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
to reference the layout/main.axml file, or R.strings.first_string to reference the first
string in the dictionary file values/strings.xml.
Loading