Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,13 @@
// found in the LICENSE file.

import 'dart:async';
import 'package:meta/meta.dart';
import 'package:ui/src/engine.dart';
import 'package:ui/ui.dart' as ui;

/// Tracks the [FlutterView]s focus changes.
final class ViewFocusBinding {
ViewFocusBinding(this._viewManager, this._onViewFocusChange);


/// Wether [FlutterView] focus changes will be reported and performed.
///
/// DO NOT rely on this bit as it will go away soon. You're warned :)!
@visibleForTesting
static bool isEnabled = false;

final FlutterViewManager _viewManager;
final ui.ViewFocusChangeCallback _onViewFocusChange;

Expand All @@ -43,9 +35,6 @@ final class ViewFocusBinding {
}

void changeViewFocus(int viewId, ui.ViewFocusState state) {
if (!isEnabled) {
return;
}
final DomElement? viewElement = _viewManager[viewId]?.dom.rootElement;

if (state == ui.ViewFocusState.focused) {
Expand Down Expand Up @@ -82,10 +71,6 @@ final class ViewFocusBinding {
});

void _handleFocusChange(DomElement? focusedElement) {
if (!isEnabled) {
return;
}

final int? viewId = _viewId(focusedElement);
if (viewId == _lastViewId) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@ void testMain() {
late EnginePlatformDispatcher dispatcher;

setUp(() {
ViewFocusBinding.isEnabled = true;

dispatcher = EnginePlatformDispatcher.instance;
dispatchedViewFocusEvents = <ui.ViewFocusEvent>[];
dispatcher.onViewFocusChange = dispatchedViewFocusEvents.add;
});

tearDown(() {
ViewFocusBinding.isEnabled = false;
EngineSemantics.instance.semanticsEnabled = false;
});

Expand Down