unoplatform / uno

Build Mobile, Desktop and WebAssembly apps with C# and XAML. Today. Open source and professionally supported.
https://platform.uno
Apache License 2.0
8.77k stars 706 forks source link

[IOS16] `CommandBar` title shortened to one letter + ... instead of full title. #10207

Open Marc-Antoine-Soucy opened 1 year ago

Marc-Antoine-Soucy commented 1 year ago

Current behavior

On IOS 16, on pages where there is a (single) in the commandbar, the title is shortened to one letter + ...

example: Orders being shortened to O... image

Expected behavior

I would expect the title to be fully shown, just like on previous IOS versions.

How to reproduce it (as minimally and precisely as possible)

IOSNavBarTitle16.zip

<CommandBar Background="{StaticResource BackgroundColor}" toolkit:UIElementExtensions.Elevation="0">

            <CommandBar.Content>
                <Grid VerticalAlignment="Center"
                      ios:HorizontalAlignment="Center">

                    <!-- CommandBar Title-->
                    <TextBlock Text="PageTitle"
                               Style="{StaticResource SomeStyle}"
                               Foreground="{StaticResource TextColor}"
                               ios:TextAlignment="Center" />
                </Grid>
            </CommandBar.Content>

            <CommandBar.PrimaryCommands>

                <!-- Search Button -->
                <AppBarButton Command="{Binding Dosomething}">
                    <AppBarButton.Icon>
                        <BitmapIcon UriSource="{StaticResource Icon}"
                                    Foreground="{StaticResource IconColor}" />
                    </AppBarButton.Icon>
                </AppBarButton>
            </CommandBar.PrimaryCommands>
        </CommandBar>

In a certain app, which uses NativeDefaultCommandBar, any page with a commandbar like this one has this issue with IOS 16. I am working right now on making a sample

Workaround

So far, I found 2:

1: If you put <AppBarButton/> (just like that, empty), above the real AppBarButton with an icon, it gives more space to the title. If you do it several times, it gives enough space for the whole title to show. I do not understand why it works.

2: You can also set the grid, which contains the title, to horizontalAlignment=Stretch, and then add some margin to manually center the title.

Works on UWP/WinUI

Yes

Environment

Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia

NuGet package version(s)

`

<PackageReference Include="System.Memory" Version="4.5.4" />
<PackageReference Include="Uno.Microsoft.Toolkit.Uwp.DeveloperTools" Version="7.1.10" />
<PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls" Version="7.1.10" />
<PackageReference Include="Uno.Microsoft.Xaml.Behaviors.Uwp.Managed" Version="2.3.0-uno.12" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.5.14" />
<PackageReference Include="Uno.UI.RemoteControl" Version="4.5.14" />
<PackageReference Include="Uno.XamlMerge.Task">`

`

<PackageReference Include="Uno.Injectable" Version="2.0.0-dev.10" />
<PackageReference Include="Uno.Material" Version="2.0.0-dev.179" />
<PackageReference Include="Uno.SourceGenerationTasks" Version="4.1.0" />
<PackageReference Include="Uno.Toolkit.UI" Version="1.3.0-dev.11" />
<PackageReference Include="Uno.Toolkit.UI.Material" Version="1.3.0-dev.11" />
<PackageReference Include="Uno.UI" Version="4.5.14" />
<PackageReference Include="Xamarin.Essentials.Interfaces" Version="1.7.3.1" />`

Affected platforms

iOS

IDE

Visual Studio 2022

IDE version

17.3.6

Relevant plugins

No response

Anything else we need to know?

I am working on making a sample.

Marc-Antoine-Soucy commented 1 year ago

I tried building the app on the latest pre-release, but I would get this error: 1> MSBUILD : error : Generation failed: System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: Generation failed for Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator. System.NullReferenceException: Object reference not set to an instance of an object. 1>MSBUILD : error : at Uno.Roslyn.GeneratorExecutionContextExtensions.GetMSBuildItemsWithAdditionalFiles(GeneratorExecutionContext context, String name) in /home/vsts/work/1/s/src/SourceGenerators/SourceGeneratorHelpers/Helpers/GeneratorExecutionContextExtensions.cs:line 37 1>MSBUILD : error : at Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGeneration.GetWinUIItems(String name) in /home/vsts/work/1/s/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs:line 222 1>MSBUILD : error : at Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGeneration..ctor(GeneratorExecutionContext context) in /home/vsts/work/1/s/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs:line 125 1>MSBUILD : error : at Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator.Execute(GeneratorExecutionContext context) in /home/vsts/work/1/s/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGenerator.cs:line 52 1>MSBUILD : error : at Uno.SourceGeneration.Host.SourceGeneratorEngine.<>cDisplayClass4_1.b13(ValueTuple`3 generatorDef) in D:\a\1\s\src\Uno.SourceGeneration.Engine.Shared\SourceGeneratorEngine.cs:line 224 1>MSBUILD : error : at Uno.SourceGeneration.Host.SourceGeneratorEngine.<>cDisplayClass4_1.b13(ValueTuple3 generatorDef) in D:\a\1\s\src\Uno.SourceGeneration.Engine.Shared\SourceGeneratorEngine.cs:line 243 1>MSBUILD : error : at System.Linq.Parallel.SelectQueryOperator2.SelectQueryOperatorEnumerator1.MoveNext(TOutput& currentElement, TKey& currentKey) 1>MSBUILD : error : at System.Linq.Parallel.StopAndGoSpoolingTask2.SpoolingWork() 1>MSBUILD : error : at System.Linq.Parallel.SpoolingTaskBase.Work() 1>MSBUILD : error : at System.Linq.Parallel.QueryTask.BaseWork(Object unused) 1>MSBUILD : error : at System.Threading.Tasks.Task.Execute() 1>MSBUILD : error : --- End of inner exception stack trace --- 1>MSBUILD : error : 1>MSBUILD : error : Server stack trace: 1>MSBUILD : error : at System.Linq.Parallel.QueryTaskGroupState.QueryEnd(Boolean userInitiatedDispose) 1>MSBUILD : error : at System.Linq.Parallel.DefaultMergeHelper2.System.Linq.Parallel.IMergeHelper<TInputOutput>.Execute() 1>MSBUILD : error : at System.Linq.Parallel.MergeExecutor1.Execute[TKey](PartitionedStream2 partitions, Boolean ignoreOutput, ParallelMergeOptions options, TaskScheduler taskScheduler, Boolean isOrdered, CancellationState cancellationState, Int32 queryId) 1>MSBUILD : error : at System.Linq.Parallel.PartitionedStreamMerger1.Receive[TKey](PartitionedStream2 partitionedStream) 1>MSBUILD : error : at System.Linq.Parallel.UnaryQueryOperator2.UnaryQueryOperatorResults.ChildResultsRecipient.Receive[TKey](PartitionedStream2 inputStream) 1>MSBUILD : error : at System.Linq.Parallel.ScanQueryOperator1.ScanEnumerableQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient1 recipient) 1>MSBUILD : error : at System.Linq.Parallel.UnaryQueryOperator2.UnaryQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient1 recipient) 1>MSBUILD : error : at System.Linq.Parallel.QueryOperator1.ExecuteAndGetResultsAsArray() 1>MSBUILD : error : at Uno.SourceGeneration.Host.SourceGeneratorEngine.Generate() in D:\a\1\s\src\Uno.SourceGeneration.Engine.Shared\SourceGeneratorEngine.cs:line 166 1>MSBUILD : error : at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs) 1>MSBUILD : error : at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg) 1>MSBUILD : error : 1>MSBUILD : error : Exception rethrown at [0]: 1>MSBUILD : error : at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 1>MSBUILD : error : at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 1>MSBUILD : error : at Uno.SourceGeneratorTasks.RemoteSourceGeneratorEngine.Generate(RemotableLogger2 logger, BuildEnvironment environment) 1>MSBUILD : error : at Uno.SourceGeneration.Host.Server.GenerationServerHost.GenerateForCollection(EnvironmentPool collection, BuildEnvironment environment) in D:\a\1\s\src\Uno.SourceGeneration.Host\Server\GenerationServerHost.netframework.cs:line 61 1>MSBUILD : error : at Uno.SourceGeneration.Host.Server.GenerationServerHost.RunGeneration(RunRequest request, CancellationToken cancellationToken) in D:\a\1\s\src\Uno.SourceGeneration.Host\Server\GenerationServerHost.cs:line 73 1>MSBUILD : error : ---> (Inner Exception #0) System.InvalidOperationException: Generation failed for Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator. System.NullReferenceException: Object reference not set to an instance of an object. 1>MSBUILD : error : at Uno.Roslyn.GeneratorExecutionContextExtensions.GetMSBuildItemsWithAdditionalFiles(GeneratorExecutionContext context, String name) in /home/vsts/work/1/s/src/SourceGenerators/SourceGeneratorHelpers/Helpers/GeneratorExecutionContextExtensions.cs:line 37 1>MSBUILD : error : at Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGeneration.GetWinUIItems(String name) in /home/vsts/work/1/s/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs:line 222 1>MSBUILD : error : at Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGeneration..ctor(GeneratorExecutionContext context) in /home/vsts/work/1/s/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs:line 125 1>MSBUILD : error : at Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator.Execute(GeneratorExecutionContext context) in /home/vsts/work/1/s/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGenerator.cs:line 52 1>MSBUILD : error : at Uno.SourceGeneration.Host.SourceGeneratorEngine.<>cDisplayClass4_1.b13(ValueTuple`3 generatorDef) in D:\a\1\s\src\Uno.SourceGeneration.Engine.Shared\SourceGeneratorEngine.cs:line 224 1>MSBUILD : error : at Uno.SourceGeneration.Host.SourceGeneratorEngine.<>cDisplayClass4_1.b13(ValueTuple3 generatorDef) in D:\a\1\s\src\Uno.SourceGeneration.Engine.Shared\SourceGeneratorEngine.cs:line 243 1>MSBUILD : error : at System.Linq.Parallel.SelectQueryOperator2.SelectQueryOperatorEnumerator1.MoveNext(TOutput& currentElement, TKey& currentKey) 1>MSBUILD : error : at System.Linq.Parallel.StopAndGoSpoolingTask2.SpoolingWork() 1>MSBUILD : error : at System.Linq.Parallel.SpoolingTaskBase.Work() 1>MSBUILD : error : at System.Linq.Parallel.QueryTask.BaseWork(Object unused) 1>MSBUILD : error : at System.Threading.Tasks.Task.Execute()<--- 1>MSBUILD : error : 1>MSBUILD : error : ---> (Inner Exception #1) System.InvalidOperationException: Generation failed for Uno.UI.SourceGenerators.RemoteControl.RemoteControlGenerator. System.NullReferenceException: Object reference not set to an instance of an object. 1>MSBUILD : error : at Uno.Roslyn.GeneratorExecutionContextExtensions.GetMSBuildItemsWithAdditionalFiles(GeneratorExecutionContext context, String name) in /home/vsts/work/1/s/src/SourceGenerators/SourceGeneratorHelpers/Helpers/GeneratorExecutionContextExtensions.cs:line 37 1>MSBUILD : error : at Uno.UI.SourceGenerators.RemoteControl.RemoteControlGenerator.<>cDisplayClass4_0.gBuildSearchPath|0(String s) in /home/vsts/work/1/s/src/SourceGenerators/Uno.UI.SourceGenerators/RemoteControl/RemoteControlGenerator.cs:line 81 1>MSBUILD : error : at System.Linq.Enumerable.d172.MoveNext() 1>MSBUILD : error : at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() 1>MSBUILD : error : at System.Linq.Enumerable.d641.MoveNext() 1>MSBUILD : error : at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() 1>MSBUILD : error : at System.String.Join(String separator, IEnumerable`1 values) 1>MSBUILD : error : at Uno.UI.SourceGenerators.RemoteControl.RemoteControlGenerator.BuildSearchPaths(GeneratorExecutionContext context, IndentedStringBuilder sb) in /home/vsts/work/1/s/src/SourceGenerators/Uno.UI.SourceGenerators/RemoteControl/RemoteControlGenerator.cs:line 88 1>MSBUILD : error : at Uno.UI.SourceGenerators.RemoteControl.RemoteControlGenerator.Execute(GeneratorExecutionContext context) in /home/vsts/work/1/s/src/SourceGenerators/Uno.UI.SourceGenerators/RemoteControl/RemoteControlGenerator.cs:line 51 1>MSBUILD : error : at Uno.SourceGeneration.Host.SourceGeneratorEngine.<>cDisplayClass4_1.b13(ValueTuple3 generatorDef) in D:\a\1\s\src\Uno.SourceGeneration.Engine.Shared\SourceGeneratorEngine.cs:line 224 1>MSBUILD : error : at Uno.SourceGeneration.Host.SourceGeneratorEngine.<>c__DisplayClass4_1.<Generate>b__13(ValueTuple3 generatorDef) in D:\a\1\s\src\Uno.SourceGeneration.Engine.Shared\SourceGeneratorEngine.cs:line 243 1>MSBUILD : error : at System.Linq.Parallel.SelectQueryOperator2.SelectQueryOperatorEnumerator1.MoveNext(TOutput& currentElement, TKey& currentKey) 1>MSBUILD : error : at System.Linq.Parallel.StopAndGoSpoolingTask`2.SpoolingWork() 1>MSBUILD : error : at System.Linq.Parallel.SpoolingTaskBase.Work() 1>MSBUILD : error : at System.Linq.Parallel.QueryTask.BaseWork(Object unused) 1>MSBUILD : error : at System.Threading.Tasks.Task.Execute()<--- 1>MSBUILD : error : 1> C:\Users\ma.soucy.nuget\packages\uno.sourcegenerationtasks\4.1.0\build\netstandard1.0\Uno.SourceGenerationTasks.targets(134,2): error : Generation failed, error code Rejected

jeromelaban commented 1 year ago

For the latest pre-release you'll need to the latest uno-sourcegeneration tasks as well. Is the package installed explicitly in your app ?

Marc-Antoine-Soucy commented 1 year ago

Apparently, yes. I will update it

jeromelaban commented 1 year ago

Also, can you try with iOS 16.1? I recall there was an issue with UINavigation and iOS 16, but I can't find the link anymore.

Marc-Antoine-Soucy commented 1 year ago

I don't have access to an IOS 16.1 device/simulator. Is it easy to install one?

Marc-Antoine-Soucy commented 1 year ago

now, even thought I get another error message when I try to build on the simulator 1> C:\Users\ma.soucy.nuget\packages\uno.ui\4.6.0-dev.772\buildTransitive\xamarinios10\uno.winui.common.targets(212,3): error : Building for the iOS Simulator requires the use of the static registrar. Make sure that MtouchExtraArgs contains --registrar:static. See https://github.com/unoplatform/uno/issues/9430 for more details.

even thought I put image I'm trying to put it elsewhere in the page, or with a = instead of : but nothing seems to work.

jeromelaban commented 1 year ago

Can you tell what does not work? Are there errors ? Also, it's likely that you already have an MtouchExtraArgs entry in the file below.

Marc-Antoine-Soucy commented 1 year ago

Yeah, you are correct, there was another MtouchExtraArgs entry below that. When I built it after that, it remained stuck in the splashscreen. So, I closed the app and reopened it and it closed itself almost instantly. I'm not sure if that's the navigation bug you were referring to?

Actually, it was an exception I somehow missed, and the problem was the mergedDictionnary was not created when building the app.

Now, I am building it again because I forgot to check the build/debugging logs. It might take a bit of time because it takes a while to build.

Marc-Antoine-Soucy commented 1 year ago

So, I can confirm this bug also happens on the latest pre-release 4.6.0-dev.772

Marc-Antoine-Soucy commented 1 year ago

IOSNavBarTitle16.zip added a sample app

There's no ... in the title, but the root problem, which is that there's not enough space for a reasonable title to display is still very obviously there.