Skip to content

Add ApplicationHandler#2653

Merged
PureWeen merged 42 commits intomainfrom
dev/apphandler
Oct 2, 2021
Merged

Add ApplicationHandler#2653
PureWeen merged 42 commits intomainfrom
dev/apphandler

Conversation

@mattleibow
Copy link
Member

@mattleibow mattleibow commented Sep 23, 2021

Description of Change

This PR adds an ApplicationHandler so that an app can invoke a "quit" action. Previously this was on IPlatformServices, but now we got handlers - and not only that, it is easily overridable by setting the method in the mappers.

#1965

Additions made

  • Adds ApplicationHandler
  • Removes IPlatformServices.QuitApplication()
  • Removes ScopedMauiContext and IScopedMauiContext
  • Removes a few properties on IMauiContext and puts it inside a "proxy" IServiceProvider
  • Added a MakeScoped with various overloads to wrap a context and add additional specific values (window, animation manager, fragment manager)
interface IApplication {
  void RequestTerminate();
}

class ApplicationHandler {
  CommandMapper = {
    ["Terminate"] = MapTerminate,
  }
}

It also removes the various Forms.Init() calls that do not take a maui context. This is no longer needed since we got the compat extensions using the lifecycle events.

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)
  • Targets a single property for a single control (or intertwined few properties)
  • Adds the property to the appropriate interface
  • Avoids any changes not essential to the handler property
  • Adds the mapping to the PropertyMapper in the handler
  • Adds the mapping method to the Android, iOS, and Standard aspects of the handler
  • Implements the actual property updates (usually in extension methods in the Platform section of Core)
  • Tags ported renderer methods with [PortHandler]
  • Adds an example of the property to the sample project (MainPage)
  • Adds the property to the stub class
  • Implements basic property tests in DeviceTests

Does this PR touch anything that might affect accessibility?

  • Does this PR introduce a new control? (If yes, add an example using SemanticProperties to the SemanticsPage)
  • APIs that modify focusability?
  • APIs that modify any text property on a control?
  • Does this PR modify view nesting or view arrangement in anyway?
  • Is there the smallest possibility that your PR will change accessibility?
  • I'm not sure, please help me

If any of the above checkboxes apply to your PR, then the PR will need to provide testing to demonstrate that accessibility still works.

{
public static void MapRequestTerminate(ApplicationHandler handler, IApplication application, object? args)
{
handler.NativeView.Exit();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattleibow mattleibow requested a review from PureWeen September 23, 2021 04:23
@rmarinho
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

Base automatically changed from dev/openuriaction to main September 24, 2021 21:49
@mattleibow mattleibow requested a review from Eilon as a code owner September 24, 2021 21:49
hartez
hartez previously requested changes Sep 29, 2021
Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I'd recommended making IMauiApplicationContext, IMauiWindowContext, and the related concrete classes internal. I could see these eventually becoming apart of our better scoping solution. For now we could expose Application/Window to users via extension methods?

  • And then we can create a tracking issue for the possible exit options on Android?

@mattleibow mattleibow marked this pull request as draft September 30, 2021 14:37
@mattleibow
Copy link
Member Author

mattleibow commented Oct 1, 2021

Need to re-verify iOS, but I think the code is ready again.

And of course some rando errors.

@mattleibow mattleibow marked this pull request as ready for review October 1, 2021 00:43
@mattleibow
Copy link
Member Author

Android (and others) quitting stuff: #2814

@mattleibow mattleibow requested review from PureWeen and hartez October 2, 2021 02:03
@mattleibow mattleibow dismissed stale reviews from hartez and PureWeen October 2, 2021 02:03

fixed things

@PureWeen PureWeen merged commit 6d90b87 into main Oct 2, 2021
@PureWeen PureWeen deleted the dev/apphandler branch October 2, 2021 21:15
@github-actions github-actions bot locked and limited conversation to collaborators Dec 21, 2023
@samhouts samhouts added the fixed-in-6.0.101-preview.10 Look for this fix in 6.0.101-preview.10! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

fixed-in-6.0.101-preview.10 Look for this fix in 6.0.101-preview.10! legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants