{"id":29828073,"url":"https://github.com/sql-mistermagoo/mauiblazorkeyboard","last_synced_at":"2025-07-29T07:16:13.626Z","repository":{"id":300486461,"uuid":"1006295890","full_name":"SQL-MisterMagoo/MauiBlazorKeyboard","owner":"SQL-MisterMagoo","description":"Maui Blazor hybrid sample where the on-screen keyboard doesn't hide inputs","archived":false,"fork":false,"pushed_at":"2025-06-22T00:07:38.000Z","size":192,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-22T01:20:47.607Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SQL-MisterMagoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-21T23:54:04.000Z","updated_at":"2025-06-22T00:07:41.000Z","dependencies_parsed_at":"2025-06-22T01:32:25.177Z","dependency_job_id":null,"html_url":"https://github.com/SQL-MisterMagoo/MauiBlazorKeyboard","commit_stats":null,"previous_names":["sql-mistermagoo/mauiblazorkeyboard"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SQL-MisterMagoo/MauiBlazorKeyboard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SQL-MisterMagoo%2FMauiBlazorKeyboard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SQL-MisterMagoo%2FMauiBlazorKeyboard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SQL-MisterMagoo%2FMauiBlazorKeyboard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SQL-MisterMagoo%2FMauiBlazorKeyboard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SQL-MisterMagoo","download_url":"https://codeload.github.com/SQL-MisterMagoo/MauiBlazorKeyboard/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SQL-MisterMagoo%2FMauiBlazorKeyboard/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267645241,"owners_count":24120877,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-29T07:16:11.395Z","updated_at":"2025-07-29T07:16:13.618Z","avatar_url":"https://github.com/SQL-MisterMagoo.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MauiBlazorKeyboard\n\nA .NET MAUI Blazor application that demonstrates how to handle on-screen keyboard visibility on mobile devices to prevent input fields from being hidden by the keyboard.\n\n## Problem Statement\n\nIn mobile applications with forms, the on-screen keyboard can often hide input fields, creating a poor user experience. This project demonstrates a native .NET MAUI solution to adjust the application layout when the keyboard appears.\n\n## Implementation Details\n\nThis project implements platform-specific solutions to handle keyboard visibility:\n\n### Android Implementation\n\n- Modified `MainActivity.cs` to set `WindowSoftInputMode = SoftInput.AdjustResize` which instructs Android to resize the app window when the keyboard appears\n- Added additional code in `OnCreate` method to ensure proper keyboard behavior:\n\n```csharp\n[Activity(WindowSoftInputMode = SoftInput.AdjustResize)]\npublic class MainActivity : MauiAppCompatActivity\n{\n    protected override void OnCreate(Bundle? savedInstanceState)\n    {\n        base.OnCreate(savedInstanceState);\n        \n        // Ensure the window adjusts when keyboard is shown\n        Window?.SetSoftInputMode(SoftInput.AdjustResize);\n    }\n}\n```\n### iOS and MacCatalyst Implementation\n\n- Modified `AppDelegate.cs` to observe keyboard show/hide events and adjust the page padding accordingly:\n\n```csharp\npublic override bool FinishedLaunching(UIApplication app, NSDictionary options)\n{\n    // Enable keyboard adjustment\n    UIKeyboard.Notifications.ObserveWillShow((sender, args) =\u003e {\n        if (Microsoft.Maui.Controls.Application.Current?.Windows.Count \u003e 0 \u0026\u0026 \n            Microsoft.Maui.Controls.Application.Current.Windows[0]?.Page is not null)\n        {\n            Microsoft.Maui.Controls.Application.Current.Windows[0].Page.Padding = \n                new Microsoft.Maui.Thickness(0, 0, 0, args.FrameEnd.Height);\n        }\n    });\n    \n    UIKeyboard.Notifications.ObserveWillHide((sender, args) =\u003e {\n        if (Microsoft.Maui.Controls.Application.Current?.Windows.Count \u003e 0 \u0026\u0026 \n            Microsoft.Maui.Controls.Application.Current.Windows[0]?.Page is not null)\n        {\n            Microsoft.Maui.Controls.Application.Current.Windows[0].Page.Padding = \n                new Microsoft.Maui.Thickness(0);\n        }\n    });\n    \n    return base.FinishedLaunching(app, options);\n}\n```\n\n### Cross-Platform Service\n\n- Created a `KeyboardHandler` service to provide a unified API for keyboard handling across platforms:\n\n```csharp\npublic interface IKeyboardHandler\n{\n    void Initialize();\n}\n\npublic class KeyboardHandler : IKeyboardHandler\n{\n    public void Initialize()\n    {\n        // Platform-specific implementations handle most of the keyboard behavior\n    }\n}\n```\n\n- Registered the service in `MauiProgram.cs`:\n`builder.Services.AddSingleton\u003cIKeyboardHandler, KeyboardHandler\u003e();`\n- Initialized the service in `App.xaml.cs`:\n\n```csharp\npublic App(IKeyboardHandler keyboardHandler)\n{\n    InitializeComponent();\n    \n    _keyboardHandler = keyboardHandler;\n    _keyboardHandler.Initialize();\n}\n```\n\n## Testing\n\nThe solution can be tested by running the application on an Android or iOS device/emulator and focusing on input fields. The application should automatically adjust its layout to ensure the focused input field remains visible above the keyboard.\n\n## Requirements\n\n- .NET 9\n- Compatible with Android, iOS, and MacCatalyst platforms","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsql-mistermagoo%2Fmauiblazorkeyboard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsql-mistermagoo%2Fmauiblazorkeyboard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsql-mistermagoo%2Fmauiblazorkeyboard/lists"}