Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
a2e6c30b
Unverified
Commit
a2e6c30b
authored
Apr 04, 2020
by
Greg Spencer
Committed by
GitHub
Apr 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Highlight mode initial value calculation. (#52990)
parent
14f3a36a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
9 deletions
+43
-9
focus_manager.dart
packages/flutter/lib/src/widgets/focus_manager.dart
+28
-9
focus_manager_test.dart
packages/flutter/test/widgets/focus_manager_test.dart
+15
-0
No files found.
packages/flutter/lib/src/widgets/focus_manager.dart
View file @
a2e6c30b
...
...
@@ -3,7 +3,6 @@
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:io'
;
import
'dart:ui'
;
import
'package:flutter/foundation.dart'
;
...
...
@@ -1368,7 +1367,34 @@ class FocusManager with DiagnosticableTreeMixin, ChangeNotifier {
/// the [WidgetsBinding] instance.
static
FocusManager
get
instance
=>
WidgetsBinding
.
instance
.
focusManager
;
bool
_lastInteractionWasTouch
=
true
;
bool
get
_lastInteractionWasTouch
{
// Assume that if we're on one of these mobile platforms, or if there's no
// mouse connected, that the initial interaction will be touch-based, and
// that it's traditional mouse and keyboard on all others.
//
// This only affects the initial value: the ongoing value is updated to a
// known correct value as soon as any pointer events are received.
if
(
_lastInteractionWasTouchValue
==
null
)
{
switch
(
defaultTargetPlatform
)
{
case
TargetPlatform
.
android
:
case
TargetPlatform
.
fuchsia
:
case
TargetPlatform
.
iOS
:
_lastInteractionWasTouchValue
=
!
WidgetsBinding
.
instance
.
mouseTracker
.
mouseIsConnected
;
break
;
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
macOS
:
case
TargetPlatform
.
windows
:
_lastInteractionWasTouchValue
=
false
;
break
;
}
}
return
_lastInteractionWasTouchValue
;
}
bool
_lastInteractionWasTouchValue
;
set
_lastInteractionWasTouch
(
bool
value
)
{
_lastInteractionWasTouchValue
=
value
;
}
/// Sets the strategy by which [highlightMode] is determined.
///
...
...
@@ -1418,13 +1444,6 @@ class FocusManager with DiagnosticableTreeMixin, ChangeNotifier {
// Update function to be called whenever the state relating to highlightMode
// changes.
void
_updateHighlightMode
()
{
// Assume that if we're on one of these mobile platforms, or if there's no
// mouse connected, that the initial interaction will be touch-based, and
// that it's traditional mouse and keyboard on all others.
//
// This only affects the initial value: the ongoing value is updated as soon
// as any input events are received.
_lastInteractionWasTouch
??=
Platform
.
isAndroid
||
Platform
.
isIOS
||
!
WidgetsBinding
.
instance
.
mouseTracker
.
mouseIsConnected
;
FocusHighlightMode
newMode
;
switch
(
highlightStrategy
)
{
case
FocusHighlightStrategy
.
automatic
:
...
...
packages/flutter/test/widgets/focus_manager_test.dart
View file @
a2e6c30b
...
...
@@ -828,6 +828,21 @@ void main() {
// receive it.
expect
(
receivedAnEvent
,
isEmpty
);
});
testWidgets
(
'Initial highlight mode guesses correctly.'
,
(
WidgetTester
tester
)
async
{
FocusManager
.
instance
.
highlightStrategy
=
FocusHighlightStrategy
.
automatic
;
switch
(
defaultTargetPlatform
)
{
case
TargetPlatform
.
fuchsia
:
case
TargetPlatform
.
android
:
case
TargetPlatform
.
iOS
:
expect
(
FocusManager
.
instance
.
highlightMode
,
equals
(
FocusHighlightMode
.
touch
));
break
;
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
macOS
:
case
TargetPlatform
.
windows
:
expect
(
FocusManager
.
instance
.
highlightMode
,
equals
(
FocusHighlightMode
.
traditional
));
break
;
}
},
variant:
TargetPlatformVariant
.
all
());
testWidgets
(
'Events change focus highlight mode.'
,
(
WidgetTester
tester
)
async
{
await
setupWidget
(
tester
);
int
callCount
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment