Xamarin.Forms icon indicating copy to clipboard operation
Xamarin.Forms copied to clipboard

[Bug] Setting ShellSection.Icon in custom ShellItemRenderer breaks ShellSection.IsEnabled

Open ChristopherStephan opened this issue 4 years ago • 0 comments

Description

Setting the ShellSection.Icon in a custom ShellItemRenderer will lead to the bug that the IsEnabled state has no effect on the ShellSection. The second tab is configured with IsEnabled="False", the renderer sets an icon and although the IsEnabled property is false, one can navigate to the second tab. The expectation is that one cannot navigate to the second tab. When the icon is not set in the renderer, the IsEnabled state works as expected and it is not possible to navigate to the second tab. This bug affects only iOS.

    <TabBar>
        <Tab Title="About" Route="AboutPage" Icon="icon_about.png" >
            <ShellContent>
                <local:AboutPage />
            </ShellContent>
        </Tab>
        <Tab Title="Browse" Icon="icon_feed.png" IsEnabled="False">
            <ShellContent>
                <local:ItemsPage />
            </ShellContent>
        </Tab>
    </TabBar>
public class MyShellItemRenderer : ShellItemRenderer
    {
        public MyShellItemRenderer(IShellContext context) : base(context)
        {
        }

        public override void ViewWillAppear(bool animated)
        {
            var items = ShellItem.Items.Where(item => item.IsVisible);
            for (int i = 0; i < items.Count(); i++)
            {
                var item = items.ElementAtOrDefault(i);
                item.Icon = "icon_about.png"; // this line causes the bug
                Console.WriteLine($"####### Item is enabled? {item.IsEnabled}");
            }
        }
    }

Steps to Reproduce

  1. Open attached demo app
  2. Tap on second tab

Expected Behavior

  • The second tab is not tappable
  • The icon of the second tab is not highlighted
  • The content of the second tab is not presented

Actual Behavior

  • The tab of the second tab section is tappable
  • The icon of the second tab is highlighted
  • The content of the second tab is presented, although IsEnabled is false

Basic Information

  • Platform Target Frameworks:
    • iOS: 13.7
  • NuGet Packages:
    • Xamarin.Forms 4.8.0.1687
  • Maybe relates to issue https://github.com/xamarin/Xamarin.Forms/issues/6832

Environment

Show/Hide Visual Studio info
=== Visual Studio Community 2019 for Mac ===

Version 8.8.6 (build 15)
Installation UUID: 4fe7661e-4af9-4c68-ab41-0f65830136b5
	GTK+ 2.24.23 (Raleigh theme)
	Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

	Package version: 612000113

=== Mono Framework MDK ===

Runtime:
	Mono 6.12.0.113 (2020-02/4fdfb5b1fd5) (64-bit)
	Package version: 612000113

=== Roslyn (Language Service) ===

3.8.0-5.20519.18+4c195c3ac1974edcefa76774d7a59a2350ec55fa

=== NuGet ===

Version: 5.8.0.6860

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/5.0.102/Sdks
SDK Versions:
	5.0.102
	3.1.201
	2.1.802
MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	5.0.2
	3.1.8
	3.1.3
	2.1.23
	2.1.22
	2.1.13

=== .NET Core 3.1 SDK ===

SDK: 3.1.201

=== Xamarin.Profiler ===

Version: 1.6.12.29
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 12.3 (17715)
Build 12C33

=== Xamarin.Mac ===

Version: 7.2.0.3 (Visual Studio Community)
Hash: c51fabee8
Branch: xcode12.3
Build date: 2020-12-10 21:05:04-0500

=== Xamarin.iOS ===

Version: 14.8.0.3 (Visual Studio Community)
Hash: c51fabee8
Branch: xcode12.3
Build date: 2020-12-10 21:05:05-0500

=== Xamarin.Android ===

Version: 11.1.0.26 (Visual Studio Community)
Commit: xamarin-android/d16-8/a36ce73
Android SDK: /Users/Shared/Development/Android/sdk
	Supported Android versions:
		8.0 (API level 26)
		8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.4
SDK Build Tools Version: 29.0.2

Build Information: 
Mono: 5e9cb6d
Java.Interop: xamarin/java.interop/d16-8@79d9533
ProGuard: Guardsquare/proguard/proguard6.2.2@ebe9000
SQLite: xamarin/sqlite/3.32.1@1a3276b
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-8@2fb1cbc

=== Microsoft OpenJDK for Mobile ===

Java SDK: /Users/Shared/Development/jdk/microsoft_dist_openjdk_8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.8.0.32
Hash: 01a7774
Branch: remotes/origin/d16-8
Build date: 2021-01-14 00:34:58 UTC

=== Android Device Manager ===

Version: 16.8.0.46
Hash: 0a81419
Branch: remotes/origin/d16-8
Build date: 2021-01-14 00:35:22 UTC

=== Xamarin Designer ===

Version: 16.8.0.510
Hash: 44e3f3ce9
Branch: remotes/origin/d16-8
Build date: 2020-12-10 00:06:14 UTC

=== Build Information ===

Release ID: 808060015
Git revision: d34d29b4643a130479d762e4d2b5750e6462fde7
Build date: 2021-01-15 08:35:04-05
Build branch: release-8.8
Xamarin extensions: d34d29b4643a130479d762e4d2b5750e6462fde7

=== Operating System ===

Mac OS X 10.15.7
Darwin 19.6.0 Darwin Kernel Version 19.6.0
    Mon Aug 31 22:12:52 PDT 2020
    root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64

=== Enabled user installed extensions ===

DeepClean 1.2.5


Screenshots

simulator_screenshot_4AE005E4-7578-4755-850D-D3F43F694CFF

Reproduction Link

IsEnabledBug.zip

ChristopherStephan avatar May 12 '21 14:05 ChristopherStephan