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

feat: Add SafeArea #292

Merged
merged 1 commit into from
Sep 8, 2022
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,4 @@ ASALocalRun/

# MFractors (Xamarin productivity tool) working folder
.mfractor/
/src/nuget_override.props
2 changes: 1 addition & 1 deletion build/workflow/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:
- template: templates/dotnet6-install-mac.yml

- bash: |
mono '/Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/MSBuild.dll' /ds /m /r /p:Configuration=Release /p:Platform=iPhone /p:ApplicationVersion=$(MajorMinorPatch) /p:DisableNet6MobileTargets=true samples/Uno.Toolkit.Samples/Uno.Toolkit.Samples.iOS/Uno.Toolkit.Samples.iOS.csproj
mono '/Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/MSBuild.dll' /ds /m /r /p:Configuration=Release /p:Platform=iPhone /p:ApplicationVersion=$(MajorMinorPatch) /p:DisableNet6MobileTargets=true /p:UnoUIUseRoslynSourceGenerators=False samples/Uno.Toolkit.Samples/Uno.Toolkit.Samples.iOS/Uno.Toolkit.Samples.iOS.csproj

- task: PublishBuildArtifacts@1
inputs:
Expand Down
2 changes: 1 addition & 1 deletion build/workflow/scripts/android-uitest-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ cd $BUILD_SOURCESDIRECTORY

# build the sample, while the emulator is starting
mono '/Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/MSBuild.dll' /m /r /p:Configuration=Release $UNO_UITEST_PROJECT
mono '/Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/MSBuild.dll' /m /r /p:Configuration=Release /p:IsUiAutomationMappingEnabled=True /p:DisableNet6MobileTargets=True /p:AndroidBuildApplicationPackage=True $UNO_UITEST_ANDROID_PROJECT
mono '/Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/MSBuild.dll' /m /r /p:Configuration=Release /p:IsUiAutomationMappingEnabled=True /p:DisableNet6MobileTargets=True /p:UnoUIUseRoslynSourceGenerators=False /p:AndroidBuildApplicationPackage=True $UNO_UITEST_ANDROID_PROJECT

cd $BUILD_SOURCESDIRECTORY/build

Expand Down
4 changes: 2 additions & 2 deletions build/workflow/scripts/ios-uitest-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export UNO_ORIGINAL_TEST_RESULTS=$BUILD_SOURCESDIRECTORY/build/TestResult-origin
export UNO_TESTS_RESPONSE_FILE=$BUILD_SOURCESDIRECTORY/build/nunit.response
export UNO_UITEST_SIMULATOR_VERSION="com.apple.CoreSimulator.SimRuntime.iOS-15-2"
export UNO_UITEST_SIMULATOR_NAME="iPad Pro (12.9-inch) (4th generation)"
export UITEST_IOSDEVICE_ID="651C50DA-98B5-447C-998D-8F3CC7B6444B"
export UITEST_IOSDEVICE_ID="iPad Pro (12.9-inch) (4th generation)"

echo "Listing iOS simulators"
xcrun simctl list devices --json
Expand All @@ -25,7 +25,7 @@ xcrun simctl list devices --json
cd $BUILD_SOURCESDIRECTORY

mono '/Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/MSBuild.dll' /m /r /p:Configuration=Release $UNO_UITEST_PROJECT
mono '/Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/MSBuild.dll' /m /r /p:Configuration=Release /p:Platform=iPhoneSimulator /p:IsUiAutomationMappingEnabled=True /p:DisableNet6MobileTargets=True $UNO_UITEST_IOS_PROJECT
mono '/Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/MSBuild.dll' /m /r /p:Configuration=Release /p:Platform=iPhoneSimulator /p:IsUiAutomationMappingEnabled=True /p:UnoUIUseRoslynSourceGenerators=False /p:DisableNet6MobileTargets=True $UNO_UITEST_IOS_PROJECT

# echo "Current system date"
# date
Expand Down
2 changes: 1 addition & 1 deletion build/workflow/scripts/wasm-uitest-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mkdir -p $UNO_UITEST_SCREENSHOT_PATH

cd $BUILD_SOURCESDIRECTORY

msbuild /r /p:Configuration=Release $UNO_UITEST_PROJECT
dotnet build /r /p:Configuration=Release $UNO_UITEST_PROJECT
dotnet build /r /p:Configuration=Release $UNO_UITEST_WASM_PROJECT /p:IsUiAutomationMappingEnabled=True /p:DisableNet6MobileTargets=True

# Start the server
Expand Down
1 change: 1 addition & 0 deletions build/workflow/stage-uitests-ios.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
jobs:
- job: iOS_Tests
displayName: 'iOS UI Tests'
timeoutInMinutes: 90
variables:
CI_Build: true
SourceLinkEnabled: false
Expand Down
18 changes: 16 additions & 2 deletions build/workflow/stage-uitests-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,27 @@
steps:
- checkout: self
clean: true

- task: UseDotNet@2
displayName: 'Use .NET Core SDK 6.0.300'
retryCountOnTaskFailure: 3
inputs:
packageType: sdk
version: 6.0.300

- task: UseDotNet@2
displayName: 'Use .Net Core runtime 6.0.x'
displayName: 'Use .NET Core SDK 5.0.400'
retryCountOnTaskFailure: 3
inputs:
packageType: sdk
version: 5.0.400

- task: UseDotNet@2
displayName: 'Use .NET Core SDK 3.1.406'
retryCountOnTaskFailure: 3
inputs:
packageType: sdk
version: 6.0.200
version: 3.1.406

- bash: |
chmod +x build/workflow/scripts/wasm-uitest-run.sh
Expand Down
5 changes: 5 additions & 0 deletions samples/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project ToolsVersion="15.0">
<PropertyGroup>
<LangVersion>latest</LangVersion>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@ public class MainActivity : Windows.UI.Xaml.ApplicationActivity
[Export("NavigateToNestedSample")]
public void NavigateToNestedSample(string pageName) => App.NavigateToNestedSample(pageName);

[Export("GetDisplayScreenScaling")]
public string GetDisplayScreenScaling(string value) => App.GetDisplayScreenScaling(value);

/// <summary>
/// Returns a base64 encoded PNG file
/// </summary>
[Export("GetScreenshot")]
public string GetScreenshot(string displayId)
{
var rootView = Windows.UI.Xaml.Window.Current.Content as View;
var rootView = this.ContentView;

var bitmap = Android.Graphics.Bitmap.CreateBitmap(rootView.Width, rootView.Height, Android.Graphics.Bitmap.Config.Argb8888);
var locationOfViewInWindow = new int[2];
Expand All @@ -64,7 +67,7 @@ public string GetScreenshot(string displayId)

// PixelCopy.Request returns the actual rendering of the screen location
// for the app, incliing OpenGL content.
PixelCopy.Request(Window, scope, bitmap, listener, new Android.OS.Handler(_pixelCopyHandlerThread.Looper));
PixelCopy.Request(Window, srcRect: null, bitmap, listener, new Android.OS.Handler(_pixelCopyHandlerThread.Looper));

listener.WaitOne();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="Uno.Toolkit.Samples" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="29" />
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="31" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="Uno.Toolkit.Samples"></application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<item name="android:windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowNoTitle">true</item>


<!-- This makes the status bar translucent and allows content to be drawn behind --><!--
<item name="android:windowTranslucentStatus">true</item>-->
</style>
</resources>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<AndroidUseAapt2>true</AndroidUseAapt2>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>
<TargetFrameworkVersion>v11.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v12.0</TargetFrameworkVersion>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<AndroidUseIntermediateDesignerFile>True</AndroidUseIntermediateDesignerFile>
<ResourcesDirectory>..\Uno.Toolkit.Samples.Shared\Strings</ResourcesDirectory>
<LangVersion>8.0</LangVersion>

</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -76,15 +76,24 @@
<PackageReference Include="Uno.UniversalImageLoader" Version="1.9.35" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Xamarin.Android.Support.CustomTabs">
<Version>28.0.0.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.AppCompat.AppCompatResources">
<Version>1.2.0.5</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Browser">
<Version>1.4.0.2</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData">
<Version>2.3.1.1</Version>
</PackageReference>
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.5.0-dev.453" />
<PackageReference Include="Uno.Core.Extensions.Compatibility" Version="4.0.1" />
<PackageReference Include="Uno.Core.Extensions.Logging.Singleton" Version="4.0.1" />
<PackageReference Include="Xamarin.Jetbrains.Annotations">
<Version>23.0.0.4</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Compile Include="MainActivity.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<MaterialToolkitResourcesV1 xmlns="using:Uno.Toolkit.UI.Material" />
<MaterialToolkitResourcesV2 xmlns="using:Uno.Toolkit.UI.Material" />
<CupertinoToolkitResources xmlns="using:Uno.Toolkit.UI.Cupertino" />

input
<!-- Load application resources -->
<ResourceDictionary Source="Converters.xaml" />
<ResourceDictionary Source="ms-appx:///Styles/Application/Colors.xaml" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using Uno.Toolkit.Samples.Helpers;
using System.Collections.Generic;
using Microsoft.Extensions.Logging;
using VisualTreeHelperEx = Uno.Toolkit.Samples.Helpers.VisualTreeHelperEx;
using Uno.Toolkit.Samples.Content.NestedSamples;

namespace Uno.Toolkit.Samples
Expand Down Expand Up @@ -84,7 +85,7 @@ private Shell BuildShell()
AddNavigationItems(nv);

// landing navigation
ShellNavigateTo<ChipSamplePage>(
ShellNavigateTo<SafeAreaSamplePage>(
#if WINDOWS_UWP
// note: on uwp, NavigationView.SelectedItem MUST be set on launch to avoid entering compact-mode
trySynchronizeCurrentItem: true
Expand Down
18 changes: 13 additions & 5 deletions samples/Uno.Toolkit.Samples/Uno.Toolkit.Samples.Shared/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
using Windows.Foundation.Collections;
using MUXC = Microsoft.UI.Xaml.Controls;
using Uno.Toolkit.Samples.Entities;
using static Uno.UI.FeatureConfiguration;
using System.Globalization;
using Windows.Graphics.Display;

#if __IOS__
using Foundation;
Expand Down Expand Up @@ -64,11 +65,14 @@ public App()
this.InitializeComponent();

#if HAS_UNO || NETFX_CORE
this.Suspending += OnSuspending;
this.Suspending += OnSuspending;
#endif

#if HAS_UNO
FeatureConfiguration.Style.SetUWPDefaultStylesOverride<Frame>(false);
#endif
#if __ANDROID__ && USE_UITESTS
FeatureConfiguration.NativeFramePresenter.AndroidUnloadInactivePages = true;
#endif
}

Expand Down Expand Up @@ -125,11 +129,11 @@ private static void InitializeLogging()
var factory = LoggerFactory.Create(builder =>
{
#if __WASM__
builder.AddProvider(new global::Uno.Extensions.Logging.WebAssembly.WebAssemblyConsoleLoggerProvider());
builder.AddProvider(new global::Uno.Extensions.Logging.WebAssembly.WebAssemblyConsoleLoggerProvider());
#elif __IOS__
builder.AddProvider(new global::Uno.Extensions.Logging.OSLogLoggerProvider());
builder.AddProvider(new global::Uno.Extensions.Logging.OSLogLoggerProvider());
#elif NETFX_CORE
builder.AddDebug();
builder.AddDebug();
#else
builder.AddConsole();
#endif
Expand Down Expand Up @@ -178,6 +182,7 @@ private static void InitializeLogging()
public static void ForceNavigation(string sampleName) => (Application.Current as App)?.ForceSampleNavigation(sampleName);
public static void ExitNestedSample() => Shell.GetForCurrentView()?.ExitNestedSample();
public static void NavigateToNestedSample(string pageName) => (Application.Current as App)?.NavigateToNestedSampleCore(pageName);
public static string GetDisplayScreenScaling(string value) => (DisplayInformation.GetForCurrentView().LogicalDpi * 100f / 96f).ToString(CultureInfo.InvariantCulture);

#if __IOS__
[Export("navBackFromNestedPage:")]
Expand All @@ -191,6 +196,9 @@ private static void InitializeLogging()

[Export("navigateToNestedSample:")]
public void NavigateToNestedSampleBackdoor(NSString value) => NavigateToNestedSample(value);

[Export("getDisplayScreenScaling:")]
public NSString GetDisplayScreenScalingBackdoor(NSString value) => new NSString(GetDisplayScreenScaling(value));
#endif
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Uno.Toolkit.Samples.Content.NestedSamples;
using Uno.Toolkit.UI;
using Uno.Toolkit.Samples.Helpers;
using VisualTreeHelperEx = Uno.Toolkit.Samples.Helpers.VisualTreeHelperEx;
#if IS_WINUI
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
Expand All @@ -30,15 +31,15 @@

namespace Uno.Toolkit.Samples.Content.Controls
{
[SamplePage(SampleCategory.Controls, nameof(NavigationBar))]
public sealed partial class NavigationBarSamplePage : Page
{
[SamplePage(SampleCategory.Controls, nameof(NavigationBar))]
public sealed partial class NavigationBarSamplePage : Page
{
private Frame _modalFrame;
private Frame _modalFrameM3;

public NavigationBarSamplePage()
{
this.InitializeComponent();
{
this.InitializeComponent();
}

private void ModalFlyout_Opened(object sender, object e)
Expand All @@ -56,9 +57,9 @@ private void M3ModalFlyout_Opened(object sender, object e)
}

private void LaunchFullScreenMaterialSample(object sender, RoutedEventArgs e)
{
Shell.GetForCurrentView().ShowNestedSample<MaterialNavigationBarSample_NestedPage1>(clearStack: true);
}
{
Shell.GetForCurrentView().ShowNestedSample<MaterialNavigationBarSample_NestedPage1>(clearStack: true);
}

private void LaunchFullScreenMaterialDataContextSample(object sender, RoutedEventArgs e)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<Page x:Class="Uno.Toolkit.Samples.Content.Controls.SafeAreaSamplePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Uno.Toolkit.Samples.Content.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sample="using:Uno.Toolkit.Samples"
xmlns:utu="using:Uno.Toolkit.UI"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d">

<sample:SamplePageLayout IsDesignAgnostic="True">
<sample:SamplePageLayout.DesignAgnosticTemplate>
<DataTemplate>
<StackPanel Margin="0,20"
Spacing="20">
<Button HorizontalAlignment="Center"
VerticalAlignment="Center"
AutomationProperties.AutomationId="SafeArea_Launch_AP_Sample_Button"
Click="LaunchAPSample"
Content="Show Sample using Attached Properties" />

<Button HorizontalAlignment="Center"
VerticalAlignment="Center"
AutomationProperties.AutomationId="SafeArea_Launch_Control_Sample_Button"
Click="LaunchControlSample"
Content="Show Sample using SafeArea Control" />

<Button HorizontalAlignment="Center"
VerticalAlignment="Center"
AutomationProperties.AutomationId="SafeArea_Launch_SoftInput_Sample_Button"
Click="LaunchSoftInputSample"
Content="Show SoftInput Sample" />

</StackPanel>
</DataTemplate>
</sample:SamplePageLayout.DesignAgnosticTemplate>
</sample:SamplePageLayout>
</Page>
Loading