Skip to content

Commit

Permalink
Some minor doc typo and diagnostic fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
gspencergoog committed Apr 6, 2023
1 parent 1592b60 commit e7e66c5
Show file tree
Hide file tree
Showing 12 changed files with 398 additions and 15 deletions.
3 changes: 2 additions & 1 deletion lib/ui/channel_buffers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ class ChannelBuffers {
'framework has had an opportunity to register a listener. See the ChannelBuffers '
'API documentation for details on how to configure the channel to expect more '
'messages, or to expect messages to get discarded:\n'
' https://api.flutter.dev/flutter/dart-ui/ChannelBuffers-class.html'
' https://api.flutter.dev/flutter/dart-ui/ChannelBuffers-class.html\n'
'The capacity of the $name channel is ${channel._capacity} message${channel._capacity != 1 ? 's' : ''}.',
);
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/ui/window/platform_configuration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -379,17 +379,17 @@ void PlatformConfigurationNativeApi::SetIsolateDebugName(
UIDartState::Current()->SetDebugName(name);
}

Dart_PerformanceMode PlatformConfigurationNativeApi::current_performace_mode_ =
Dart_PerformanceMode PlatformConfigurationNativeApi::current_performance_mode_ =
Dart_PerformanceMode_Default;

Dart_PerformanceMode PlatformConfigurationNativeApi::GetDartPerformanceMode() {
return current_performace_mode_;
return current_performance_mode_;
}

int PlatformConfigurationNativeApi::RequestDartPerformanceMode(int mode) {
UIDartState::ThrowIfUIOperationsProhibited();
current_performace_mode_ = static_cast<Dart_PerformanceMode>(mode);
return Dart_SetPerformanceMode(current_performace_mode_);
current_performance_mode_ = static_cast<Dart_PerformanceMode>(mode);
return Dart_SetPerformanceMode(current_performance_mode_);
}

Dart_Handle PlatformConfigurationNativeApi::GetPersistentIsolateData() {
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/window/platform_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Scene;
/// @brief An enum for defining the different kinds of accessibility features
/// that can be enabled by the platform.
///
/// Must match the `AccessibilityFeatureFlag` enum in framework.
/// Must match the `AccessibilityFeatures` class in framework.
enum class AccessibilityFeatureFlag : int32_t {
kAccessibleNavigation = 1 << 0,
kInvertColors = 1 << 1,
Expand Down Expand Up @@ -538,7 +538,7 @@ class PlatformConfigurationNativeApi {
static void RegisterBackgroundIsolate(int64_t root_isolate_token);

private:
static Dart_PerformanceMode current_performace_mode_;
static Dart_PerformanceMode current_performance_mode_;
};

} // namespace flutter
Expand Down
29 changes: 29 additions & 0 deletions shell/platform/common/application_lifecycle.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/shell/platform/common/application_lifecycle.h"

#include <cassert>

namespace flutter {

const char* AppLifecycleStateToString(AppLifecycleState state) {
switch (state) {
case kAppLifecycleStateDetached:
return "AppLifecycleState.detached";
case kAppLifecycleStateResumed:
return "AppLifecycleState.resumed";
case kAppLifecycleStateInactive:
return "AppLifecycleState.inactive";
case kAppLifecycleStateHidden:
return "AppLifecycleState.hidden";
case kAppLifecycleStatePaused:
return "AppLifecycleState.paused";
default:
assert(false && "Lifecycle state not recognized");
break;
}
}

} // namespace flutter
64 changes: 64 additions & 0 deletions shell/platform/common/application_lifecycle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_SHELL_PLATFORM_COMMON_APPLICATION_LIFECYCLE_H_
#define FLUTTER_SHELL_PLATFORM_COMMON_APPLICATION_LIFECYCLE_H_

namespace flutter {

/// This enum describes the possible lifecycle states of the application. It
/// must be kept up to date with changes in the framework's AppLifecycleState
/// enum. It is passed to the embedder's |SetLifecycleState| function.
///
/// |SetLifecycleState| will validate that the state transition is a valid state
/// transition, and will assert if it is not. States not supported on a platform
/// will be emitted when transitioning between states which are supported, so
/// that all implementations share the same allowed state machine. Here is the
/// allowed state machine:
///
/// +-----------+ +-----------+
/// | detached |------------------------------>| resumed |
/// +-----------+ +-----------+
/// ^ ^
/// | |
/// | v
/// +-----------+ +--------------+ +-----------+
/// | paused |<------>| hidden |<----->| inactive |
/// +-----------+ +--------------+ +-----------+
///
/// The states and their meanings are as follows:
///
/// detached: The initial state of the state machine. On Android and iOS,
/// also the final state of the state machine when all views are
/// detached. Other platforms do not enter this state again after
/// initially leaving it.
///
/// resumed: The nominal "running" state of the application. The
/// application is visible, has input focus, and is running.
///
/// inactive: At least one view of the application is visible, but none
/// have input focus. The application is otherwise running
/// normally.
///
/// hidden: All views of an application are hidden, either because the
/// application is being stopped (on iOS and Android), or because
/// it is being minimized or on a desktop that is no longer visible
/// (on desktop), or on a tab that is no longer visible (on web).
///
/// paused: The application is not running, and can be detached or started
/// again at any time. This state is typically only entered into on
/// iOS and Android.
typedef enum {
kAppLifecycleStateDetached = 0x0,
kAppLifecycleStateResumed = 0x1,
kAppLifecycleStateInactive = 0x2,
kAppLifecycleStateHidden = 0x3,
kAppLifecycleStatePaused = 0x4,
} AppLifecycleState;

const char* AppLifecycleStateToString(AppLifecycleState state);

} // namespace flutter

#endif // FLUTTER_SHELL_PLATFORM_COMMON_APPLICATION_LIFECYCLE_H_
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class PluginRegistrar {
// Takes ownership of |plugin|.
//
// Plugins are not required to call this method if they have other lifetime
// management, but this is a convient place for plugins to be owned to ensure
// that they stay valid for any registered callbacks.
// management, but this is a convenient place for plugins to be owned to
// ensure that they stay valid for any registered callbacks.
void AddPlugin(std::unique_ptr<Plugin> plugin);

protected:
Expand Down
4 changes: 2 additions & 2 deletions shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Called if this has been registered for `UIApplicationDelegate` callbacks.
*
* @return `NO` if this vetoes application launch.
* @return `NO` if this vetos application launch.
*/
- (BOOL)application:(UIApplication*)application
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions;

/**
* Called if this has been registered for `UIApplicationDelegate` callbacks.
*
* @return `NO` if this vetoes application launch.
* @return `NO` if this vetos application launch.
*/
- (BOOL)application:(UIApplication*)application
willFinishLaunchingWithOptions:(NSDictionary*)launchOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ FLUTTER_DARWIN_EXPORT
@interface FlutterPluginAppLifeCycleDelegate : NSObject <UNUserNotificationCenterDelegate>

/**
* Registers `delegate` to receive life cycle callbacks via this FlutterPluginAppLifecycleDelegate
* Registers `delegate` to receive life cycle callbacks via this FlutterPluginAppLifeCycleDelegate
* as long as it is alive.
*
* `delegate` will only referenced weakly.
* `delegate` will only be referenced weakly.
*/
- (void)addDelegate:(NSObject<FlutterApplicationLifeCycleDelegate>*)delegate;

/**
* Calls all plugins registered for `UIApplicationDelegate` callbacks.
*
* @return `NO` if any plugin vetoes application launch.
* @return `NO` if any plugin vetos application launch.
*/
- (BOOL)application:(UIApplication*)application
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions;

/**
* Calls all plugins registered for `UIApplicationDelegate` callbacks.
*
* @return `NO` if any plugin vetoes application launch.
* @return `NO` if any plugin vetos application launch.
*/
- (BOOL)application:(UIApplication*)application
willFinishLaunchingWithOptions:(NSDictionary*)launchOptions;
Expand Down
2 changes: 2 additions & 0 deletions shell/platform/darwin/macos/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ _framework_binary_subpath = "Versions/A/$_flutter_framework_name"
# the Flutter engine source root.
_flutter_framework_headers = [
"framework/Headers/FlutterAppDelegate.h",
"framework/Headers/FlutterAppLifecycleDelegate.h",
"framework/Headers/FlutterDartProject.h",
"framework/Headers/FlutterEngine.h",
"framework/Headers/FlutterMacOS.h",
Expand All @@ -57,6 +58,7 @@ source_set("flutter_framework_source") {
"framework/Source/AccessibilityBridgeMac.h",
"framework/Source/AccessibilityBridgeMac.mm",
"framework/Source/FlutterAppDelegate.mm",
"framework/Source/FlutterAppLifecycleDelegate.mm",
"framework/Source/FlutterBackingStore.h",
"framework/Source/FlutterBackingStore.mm",
"framework/Source/FlutterChannelKeyResponder.h",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_FLUTTERAPPLIFECYCLEDELEGATE_H_
#define FLUTTER_FLUTTERAPPLIFECYCLEDELEGATE_H_

#import <Cocoa/Cocoa.h>
#include <Foundation/Foundation.h>

#import "FlutterMacros.h"
#import "FlutterPluginMacOS.h"

NS_ASSUME_NONNULL_BEGIN

#pragma mark -
/**
* Protocol for listener of events from the NSApplication, typically a
* FlutterPlugin.
*/
@protocol FlutterAppLifecycleDelegate <NSObject>

@optional
/**
* Called when the |FlutterAppDelegate| gets the applicationWillFinishLaunching
* notification.
*/
- (void)handleWillFinishLaunching:(NSNotification*)notification;

/**
* Called when the |FlutterAppDelegate| gets the applicationDidFinishLaunching
* notification.
*/
- (void)handleDidFinishLaunching:(NSNotification*)notification;

/**
* Called when the |FlutterAppDelegate| gets the applicationWillBecomeActive
* notification.
*/
- (void)handleWillBecomeActive:(NSNotification*)notification;

/**
* Called when the |FlutterAppDelegate| gets the applicationDidBecomeActive
* notification.
*/
- (void)handleDidBecomeActive:(NSNotification*)notification;

/**
* Called when the |FlutterAppDelegate| gets the applicationWillResignActive
* notification.
*/
- (void)handleWillResignActive:(NSNotification*)notification;

/**
* Called when the |FlutterAppDelegate| gets the applicationWillResignActive
* notification.
*/
- (void)handleDidResignActive:(NSNotification*)notification;

/**
* Called when the |FlutterAppDelegate| gets the applicationWillHide
* notification.
*/
- (void)handleWillHide:(NSNotification*)notification;

/**
* Called when the |FlutterAppDelegate| gets the applicationDidHide
* notification.
*/
- (void)handleDidHide:(NSNotification*)notification;

/**
* Called when the |FlutterAppDelegate| gets the applicationWillUnhide
* notification.
*/
- (void)handleWillUnhide:(NSNotification*)notification;

/**
* Called when the |FlutterAppDelegate| gets the applicationDidUnhide
* notification.
*/
- (void)handleDidUnhide:(NSNotification*)notification;

/**
* Called when the |FlutterAppDelegate| gets the applicationDidUnhide
* notification.
*/
- (void)handleDidChangeScreenParameters:(NSNotification*)notification;

/**
* Called when the |FlutterAppDelegate| gets the applicationDidUnhide
* notification.
*/
- (void)handleDidChangeOcclusionState:(NSNotification*)notification API_AVAILABLE(macos(10.9));

/**
* Called when the |FlutterAppDelegate| gets the applicationWillTerminate
* notification.
*/
- (void)handleWillTerminate:(NSNotification*)notification;
@end

#pragma mark -

/**
* Propagates `NSAppDelegate` callbacks to registered plugins.
*/
FLUTTER_DARWIN_EXPORT
@interface FlutterAppLifecycleRegistrar : NSObject <FlutterAppLifecycleDelegate>

/**
* Registers `delegate` to receive life cycle callbacks via this FlutterAppLifecycleDelegate
* as long as it is alive.
*
* `delegate` will only be referenced weakly.
*/
- (void)addDelegate:(NSObject<FlutterAppLifecycleDelegate>*)delegate;

/**
* Unregisters `delegate` so that it will no longer receive life cycle callbacks
* via this FlutterAppLifecycleDelegate.
*/
- (void)removeDelegate:(NSObject<FlutterAppLifecycleDelegate>*)delegate;
@end

NS_ASSUME_NONNULL_END

#endif // FLUTTER_FLUTTERAPPLIFECYCLEDELEGATE_H_

0 comments on commit e7e66c5

Please sign in to comment.