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 NavigationSample #37

Merged
merged 5 commits into from
Mar 8, 2024
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -352,4 +352,5 @@ MigrationBackup/
.idea

Resource.designer.cs
nupkgs/
nupkgs/
.DS_Store
17 changes: 17 additions & 0 deletions Fabulous.MauiControls.sln
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Solution Files", "_Solutio
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Gallery", "samples\Gallery\Gallery.fsproj", "{A28D6852-F21C-4A43-93AF-CC71050028A9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Navigation", "Navigation", "{3A3581BD-4228-49B0-84D5-AF39D620BA34}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "BasicNavigation", "samples\Navigation\BasicNavigation\BasicNavigation.fsproj", "{CE61493B-86CC-49CE-9443-F25F1ECB15C9}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "NavigationPath", "samples\Navigation\NavigationPath\NavigationPath.fsproj", "{5B3F6C4E-82CF-442F-BFB4-216C1CD85700}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -81,6 +87,14 @@ Global
{A28D6852-F21C-4A43-93AF-CC71050028A9}.Release|Any CPU.Build.0 = Release|Any CPU
{A28D6852-F21C-4A43-93AF-CC71050028A9}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{A28D6852-F21C-4A43-93AF-CC71050028A9}.Release|Any CPU.Deploy.0 = Release|Any CPU
{CE61493B-86CC-49CE-9443-F25F1ECB15C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CE61493B-86CC-49CE-9443-F25F1ECB15C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CE61493B-86CC-49CE-9443-F25F1ECB15C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CE61493B-86CC-49CE-9443-F25F1ECB15C9}.Release|Any CPU.Build.0 = Release|Any CPU
{5B3F6C4E-82CF-442F-BFB4-216C1CD85700}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B3F6C4E-82CF-442F-BFB4-216C1CD85700}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B3F6C4E-82CF-442F-BFB4-216C1CD85700}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B3F6C4E-82CF-442F-BFB4-216C1CD85700}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{67FB01A1-1A3E-4A3B-83DC-7D63B56FB1A1} = {35A6823C-8312-4F92-818A-5117BB31A569}
Expand All @@ -90,5 +104,8 @@ Global
{BD278E92-A806-4913-AB2D-59D59FE8E2AD} = {87C8E9E8-497E-46DB-90FE-4402E0CB230A}
{97FE743C-512F-44BA-92CF-3EB3A7972E5D} = {87C8E9E8-497E-46DB-90FE-4402E0CB230A}
{A28D6852-F21C-4A43-93AF-CC71050028A9} = {87C8E9E8-497E-46DB-90FE-4402E0CB230A}
{3A3581BD-4228-49B0-84D5-AF39D620BA34} = {87C8E9E8-497E-46DB-90FE-4402E0CB230A}
{CE61493B-86CC-49CE-9443-F25F1ECB15C9} = {3A3581BD-4228-49B0-84D5-AF39D620BA34}
{5B3F6C4E-82CF-442F-BFB4-216C1CD85700} = {3A3581BD-4228-49B0-84D5-AF39D620BA34}
EndGlobalSection
EndGlobal
105 changes: 105 additions & 0 deletions samples/Navigation/BasicNavigation/BasicNavigation.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.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);net7.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>NavigationSample</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<EnableDefaultItems>false</EnableDefaultItems>

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

<!-- App Identifier -->
<ApplicationId>org.fabulous.maui.basicnavigation</ApplicationId>
<ApplicationIdGuid>c6c98ddf-a204-4a7e-be03-2829f110f396</ApplicationIdGuid>

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

<TargetPlatformIdentifier Condition=" $(TargetPlatformIdentifier) == '' ">$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))</TargetPlatformIdentifier>

<SupportedOSPlatformVersion Condition="$(TargetPlatformIdentifier) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$(TargetPlatformIdentifier) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$(TargetPlatformIdentifier) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$(TargetPlatformIdentifier) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$(TargetPlatformIdentifier) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$(TargetPlatformIdentifier) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
<Compile Include="PageA.fs" />
<Compile Include="PageB.fs" />
<Compile Include="PageC.fs" />
<Compile Include="Sample.fs" />
<Compile Include="MauiProgram.fs" />
</ItemGroup>

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

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />

<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\*" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
</ItemGroup>

<ItemGroup Condition="$(TargetPlatformIdentifier) == 'android'">
<AndroidResource Include="$(AndroidProjectFolder)Resources/*/*" />
<AndroidResource Remove="$(AndroidProjectFolder)Resources/raw/.*" />
<AndroidResource Update="$(AndroidProjectFolder)Resources/raw/*" />
<AndroidAsset Include="$(AndroidProjectFolder)Assets/**/*" Exclude="$(AndroidProjectFolder)Assets/**/.*/**" />
<AndroidManifest Include="$(AndroidProjectFolder)AndroidManifest.xml" />
<Compile Include="$(AndroidProjectFolder)MainActivity.fs" />
<Compile Include="$(AndroidProjectFolder)MainApplication.fs" />
</ItemGroup>

<ItemGroup Condition="$(TargetPlatformIdentifier) == 'ios'">
<None Include="$(iOSProjectFolder)Info.plist" LogicalName="Info.plist" />
<Compile Include="$(iOSProjectFolder)AppDelegate.fs" />
<Compile Include="$(iOSProjectFolder)Program.fs" />
</ItemGroup>

<ItemGroup Condition="$(TargetPlatformIdentifier) == 'maccatalyst'">
<None Include="$(MacCatalystProjectFolder)Info.plist" LogicalName="Info.plist" />
<Compile Include="$(MacCatalystProjectFolder)AppDelegate.fs" />
<Compile Include="$(MacCatalystProjectFolder)Program.fs" />
</ItemGroup>

<ItemGroup Condition="$(TargetPlatformIdentifier) == 'windows'">
<Manifest Include="$(WindowsProjectFolder)app.manifest" />
<AppxManifest Include="$(WindowsProjectFolder)Package.appxmanifest" />
<Compile Include="$(WindowsProjectFolder)App.fs" />
<Compile Include="$(WindowsProjectFolder)Main.fs" />

<PackageReference Include="FSharp.Maui.WinUICompat" />
</ItemGroup>

<ItemGroup Condition="$(TargetPlatformIdentifier) == 'tizen'">
<TizenManifestFile Include="$(TizenProjectFolder)tizen-manifest.xml" />
<Compile Include="$(TizenProjectFolder)Main.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="FSharp.Core" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Fabulous.MauiControls\Fabulous.MauiControls.fsproj" />
</ItemGroup>

</Project>
16 changes: 16 additions & 0 deletions samples/Navigation/BasicNavigation/MauiProgram.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace NavigationSample

open Microsoft.Maui.Hosting
open Fabulous.Maui

type MauiProgram =
static member CreateMauiApp() =
MauiApp
.CreateBuilder()
.UseFabulousApp(Sample.program)
.ConfigureFonts(fun fonts ->
fonts
.AddFont("OpenSans-Regular.ttf", "OpenSansRegular")
.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold")
|> ignore)
.Build()
29 changes: 29 additions & 0 deletions samples/Navigation/BasicNavigation/PageA.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace NavigationSample

open Fabulous.Maui

open type Fabulous.Maui.View

module PageA =
type Model = { Count: int }

type Msg =
| Increment
| Decrement

let init () = { Count = 0 }

let update msg model =
match msg with
| Increment -> { Count = model.Count + 1 }
| Decrement -> { Count = model.Count - 1 }

let view model =
VStack() {
Label("Page A").font(32.).centerTextHorizontal().margin(0., 0., 0., 30.)

Label($"Count: {model.Count}").centerTextHorizontal()

Button("Increment", Increment)
Button("Decrement", Decrement)
}
29 changes: 29 additions & 0 deletions samples/Navigation/BasicNavigation/PageB.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace NavigationSample

open Fabulous.Maui

open type Fabulous.Maui.View

module PageB =
type Model = { Count: int }

type Msg =
| Increment
| Decrement

let init () = { Count = 0 }

let update msg model =
match msg with
| Increment -> { Count = model.Count + 1 }
| Decrement -> { Count = model.Count - 1 }

let view model =
VStack() {
Label("Page B").font(32.).centerTextHorizontal().margin(0., 0., 0., 30.)

Label($"Count: {model.Count}").centerTextHorizontal()

Button("Increment", Increment)
Button("Decrement", Decrement)
}
29 changes: 29 additions & 0 deletions samples/Navigation/BasicNavigation/PageC.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace NavigationSample

open Fabulous.Maui

open type Fabulous.Maui.View

module PageC =
type Model = { Count: int }

type Msg =
| Increment
| Decrement

let init () = { Count = 0 }

let update msg model =
match msg with
| Increment -> { Count = model.Count + 1 }
| Decrement -> { Count = model.Count - 1 }

let view model =
VStack() {
Label("Page C").font(32.).centerTextHorizontal().margin(0., 0., 0., 30.)

Label($"Count: {model.Count}").centerTextHorizontal()

Button("Increment", Increment)
Button("Decrement", Decrement)
}
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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace NavigationSample

open Android.App
open Android.Content.PM
open Microsoft.Maui

[<Activity(Theme = "@style/Maui.SplashTheme",
MainLauncher = true,
ConfigurationChanges =
(ConfigChanges.ScreenSize
||| ConfigChanges.Orientation
||| ConfigChanges.UiMode
||| ConfigChanges.ScreenLayout
||| ConfigChanges.SmallestScreenSize
||| ConfigChanges.Density))>]
type MainActivity() =
inherit MauiAppCompatActivity()
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace NavigationSample

open Android.App
open Microsoft.Maui

[<Application>]
type MainApplication(handle, ownership) =
inherit MauiApplication(handle, ownership)

override _.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">#512BD4</color>
<color name="colorPrimaryDark">#2B0B98</color>
<color name="colorAccent">#2B0B98</color>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace NavigationSample

open Foundation
open Microsoft.Maui

[<Register("AppDelegate")>]
type AppDelegate() =
inherit MauiUIApplicationDelegate()

override this.CreateMauiApp() = MauiProgram.CreateMauiApp()
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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace NavigationSample

open UIKit

module Program =
[<EntryPoint>]
let main args =
UIApplication.Main(args, null, typeof<AppDelegate>)
0
16 changes: 16 additions & 0 deletions samples/Navigation/BasicNavigation/Platforms/Tizen/Main.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace NavigationSample

open System
open Microsoft.Maui
open Microsoft.Maui.Hosting

type Program() =
inherit MauiApplication()

override this.CreateMauiApp() = MauiProgram.CreateMauiApp()

module Program =
[<EntryPoint>]
let main args =
let app = Program()
app.Run(args)
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.NavigationSample" version="1.0.0" api-version="7" xmlns="http://tizen.org/ns/packages">
<profile name="common" />
<ui-application appid="com.companyname.NavigationSample" exec="CounterApp.dll" multiple="false" nodisplay="false" taskmanage="true" type="dotnet" launch_mode="single">
<label>NavigationSample</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>
10 changes: 10 additions & 0 deletions samples/Navigation/BasicNavigation/Platforms/Windows/App.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace NavigationSample.WinUI

/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
type App() =
inherit FSharp.Maui.WinUICompat.App()

override this.CreateMauiApp() =
NavigationSample.MauiProgram.CreateMauiApp()
Loading