Skip to content

Commit 36ac0a2

Browse files
fix isolate selector color issue (#9094)
1 parent af04ddf commit 36ac0a2

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed

packages/devtools_app/lib/src/framework/scaffold/status_line.dart

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@ class StatusLine extends StatelessWidget {
2525
super.key,
2626
required this.currentScreen,
2727
required this.isEmbedded,
28-
required bool isConnected,
28+
required this.isConnected,
2929
}) : highlightForConnection = isConnected && !isEmbedded;
3030

3131
final Screen currentScreen;
32+
3233
final bool isEmbedded;
3334

35+
final bool isConnected;
36+
3437
/// Whether to highlight the footer when DevTools is connected to an app.
3538
final bool highlightForConnection;
3639

@@ -45,16 +48,20 @@ class StatusLine extends StatelessWidget {
4548
@override
4649
Widget build(BuildContext context) {
4750
final theme = Theme.of(context);
48-
final color = highlightForConnection ? theme.colorScheme.onPrimary : null;
51+
final backgroundColor =
52+
highlightForConnection ? theme.colorScheme.primary : null;
53+
final foregroundColor =
54+
highlightForConnection ? theme.colorScheme.onPrimary : null;
4955
final height = statusLineHeight + padding.top + padding.bottom;
5056
return ValueListenableBuilder<bool>(
5157
valueListenable: currentScreen.showIsolateSelector,
5258
builder: (context, showIsolateSelector, _) {
59+
showIsolateSelector = showIsolateSelector && isConnected;
5360
return DefaultTextStyle.merge(
54-
style: TextStyle(color: color),
61+
style: TextStyle(color: foregroundColor),
5562
child: Container(
5663
decoration: BoxDecoration(
57-
color: highlightForConnection ? theme.colorScheme.primary : null,
64+
color: backgroundColor,
5865
border: Border(
5966
top: Divider.createBorderSide(context, width: 1.0),
6067
),
@@ -74,7 +81,8 @@ class StatusLine extends StatelessWidget {
7481

7582
List<Widget> _getStatusItems(BuildContext context, bool showIsolateSelector) {
7683
final theme = Theme.of(context);
77-
final color = highlightForConnection ? theme.colorScheme.onPrimary : null;
84+
final foregroundColor =
85+
highlightForConnection ? theme.colorScheme.onPrimary : null;
7886
final screenWidth = ScreenSize(context).width;
7987
// TODO(https://github.com/flutter/devtools/issues/8913): this builds the
8088
// wrong status items for offline mode.
@@ -92,7 +100,7 @@ class StatusLine extends StatelessWidget {
92100
highlightForConnection: highlightForConnection,
93101
),
94102
if (showVideoTutorial) ...[
95-
BulletSpacer(color: color),
103+
BulletSpacer(color: foregroundColor),
96104
VideoTutorialLink(
97105
screenMetaData: screenMetaData!,
98106
screenWidth: screenWidth,
@@ -101,21 +109,21 @@ class StatusLine extends StatelessWidget {
101109
],
102110
],
103111
),
104-
BulletSpacer(color: color),
112+
BulletSpacer(color: foregroundColor),
105113
if (widerThanXxs && showIsolateSelector) ...[
106-
const IsolateSelector(),
107-
BulletSpacer(color: color),
114+
IsolateSelector(foregroundColor: foregroundColor),
115+
BulletSpacer(color: foregroundColor),
108116
],
109117
if (screenWidth > MediaSize.xs && pageStatus != null) ...[
110118
pageStatus,
111-
BulletSpacer(color: color),
119+
BulletSpacer(color: foregroundColor),
112120
],
113121
buildConnectionStatus(context, screenWidth),
114122
if (widerThanXxs && isEmbedded) ...[
115-
BulletSpacer(color: color),
123+
BulletSpacer(color: foregroundColor),
116124
Row(
117125
crossAxisAlignment: CrossAxisAlignment.end,
118-
children: DevToolsScaffold.defaultActions(color: color),
126+
children: DevToolsScaffold.defaultActions(color: foregroundColor),
119127
),
120128
],
121129
];
@@ -266,15 +274,16 @@ class VideoTutorialLink extends StatelessWidget {
266274
}
267275

268276
class IsolateSelector extends StatelessWidget {
269-
const IsolateSelector({super.key});
277+
const IsolateSelector({super.key, required this.foregroundColor});
278+
279+
final Color? foregroundColor;
270280

271281
@override
272282
Widget build(BuildContext context) {
273283
final isolateManager = serviceConnection.serviceManager.isolateManager;
274284
return MultiValueListenableBuilder(
275285
listenables: [isolateManager.isolates, isolateManager.selectedIsolate],
276286
builder: (context, values, _) {
277-
final theme = Theme.of(context);
278287
final isolates = values.first as List<IsolateRef>;
279288
final selectedIsolateRef = values.second as IsolateRef?;
280289
return PopupMenuButton<IsolateRef?>(
@@ -286,28 +295,29 @@ class IsolateSelector extends StatelessWidget {
286295
isolates.map((ref) {
287296
return PopupMenuItem<IsolateRef>(
288297
value: ref,
289-
child: IsolateOption(
298+
child: _IsolateOption(
290299
ref,
291-
color: theme.colorScheme.onSurface,
300+
// This is always rendered against the background color
301+
// for the pop up menu, which is the `surface` color.
302+
color: Theme.of(context).colorScheme.onSurface,
292303
),
293304
);
294305
}).toList(),
295-
child: IsolateOption(
306+
child: _IsolateOption(
296307
isolateManager.selectedIsolate.value,
297-
color: theme.colorScheme.onPrimary,
308+
color: foregroundColor,
298309
),
299310
);
300311
},
301312
);
302313
}
303314
}
304315

305-
class IsolateOption extends StatelessWidget {
306-
const IsolateOption(this.ref, {required this.color, super.key});
316+
class _IsolateOption extends StatelessWidget {
317+
const _IsolateOption(this.ref, {required this.color});
307318

308319
final IsolateRef? ref;
309-
310-
final Color color;
320+
final Color? color;
311321

312322
@override
313323
Widget build(BuildContext context) {

0 commit comments

Comments
 (0)