Skip to content

Commit

Permalink
Alternating colors look nice in tables when embedded in IDE (flutter#…
Browse files Browse the repository at this point in the history
  • Loading branch information
elliette authored Nov 5, 2024
1 parent f7091d2 commit 2184bba
Show file tree
Hide file tree
Showing 30 changed files with 37 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'dart:ui';
import 'package:devtools_app_shared/ui.dart';
import 'package:flutter/material.dart';

import '../../../../shared/common_widgets.dart';
import '../../../../shared/diagnostics/diagnostics_node.dart';
import '../../../../shared/primitives/utils.dart';
import '../../inspector_data_models.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'dart:ui';
import 'package:devtools_app_shared/ui.dart';
import 'package:flutter/material.dart';

import '../../../../shared/common_widgets.dart';
import '../../../../shared/diagnostics/diagnostics_node.dart';
import '../../../../shared/primitives/utils.dart';
import '../../../inspector/layout_explorer/ui/dimension.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'package:devtools_app_shared/ui.dart';
import 'package:flutter/material.dart';
import 'package:logging/logging.dart';

import '../../shared/common_widgets.dart';
import '../../shared/primitives/utils.dart';
import '../../shared/ui/icons.dart';
import 'logging_controller.dart';
Expand Down
30 changes: 0 additions & 30 deletions packages/devtools_app/lib/src/shared/common_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -940,36 +940,6 @@ extension LinkedScrollControllerGroupExtension on LinkedScrollControllerGroup {
}
}

/// Utility extension methods to the [Color] class.
extension ColorExtension on Color {
/// Return a slightly darker color than the current color.
Color darken([double percent = 0.05]) {
assert(0.0 <= percent && percent <= 1.0);
percent = 1.0 - percent;

final c = this;
return Color.from(
alpha: c.a,
red: c.r * percent,
green: c.g * percent,
blue: c.b * percent,
);
}

/// Return a slightly brighter color than the current color.
Color brighten([double percent = 0.05]) {
assert(0.0 <= percent && percent <= 1.0);

final c = this;
return Color.from(
alpha: c.a,
red: c.r + ((1.0 - c.r) * percent),
green: c.g + ((1.0 - c.g) * percent),
blue: c.b + ((1.0 - c.b) * percent),
);
}
}

class BreadcrumbNavigator extends StatelessWidget {
const BreadcrumbNavigator.builder({
super.key,
Expand Down
1 change: 1 addition & 0 deletions packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ To learn more about DevTools, check out the
* Persist filter settings across sessions. - [#8447](https://github.com/flutter/devtools/pull/8447),
[#8456](https://github.com/flutter/devtools/pull/8456)
[#8470](https://github.com/flutter/devtools/pull/8470)
* Tables match IDE theme when embedded in an IDE. - [#8498](https://github.com/flutter/devtools/pull/8498)

## Inspector updates

Expand Down
3 changes: 1 addition & 2 deletions packages/devtools_app/test/shared/table_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1707,8 +1707,7 @@ void main() {
final crackleFinder = find.byKey(const Key('Crackle'));

// Expected ARGB color values.
const color1Value =
'(a: 1.0, r: 0.9490196078431372, g: 0.9411764705882353, b: 0.9568627450980393)';
const color1Value = '(a: 1.0, r: 0.94, g: 0.94, b: 0.94)';
const color2Value = '(a: 1.0, r: 1.0, g: 1.0, b: 1.0)';
const rowSelectedColorValue = '(a: 1.0, r: 1.0, g: 1.0, b: 1.0)';

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions packages/devtools_app_shared/lib/src/ui/theme/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ ThemeData _baseTheme({
),
primaryTextTheme: _devToolsTextTheme(theme, theme.primaryTextTheme),
textTheme: _devToolsTextTheme(theme, theme.textTheme),
colorScheme: theme.colorScheme.copyWith(
surface: backgroundColor,
),
);
}

Expand Down Expand Up @@ -359,11 +362,10 @@ extension DevToolsSharedColorScheme on ColorScheme {
Color get _devtoolsLink =>
isLight ? const Color(0xFF1976D2) : Colors.lightBlueAccent;

Color get alternatingBackgroundColor1 =>
isLight ? Colors.white : const Color(0xFF1B1B1F);
Color get alternatingBackgroundColor1 => surface;

Color get alternatingBackgroundColor2 =>
isLight ? const Color(0xFFF2F0F4) : const Color(0xFF303033);
isLight ? surface.darken(0.06) : surface.brighten(0.06);

Color get selectedRowBackgroundColor =>
isLight ? const Color(0xFFC7C6CA) : const Color(0xFF5E5E62);
Expand Down
30 changes: 30 additions & 0 deletions packages/devtools_app_shared/lib/src/ui/ui_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,33 @@ Color? tryParseColor(String? input, {Logger? logger}) {
return null;
}
}

/// Utility extension methods to the [Color] class.
extension ColorExtension on Color {
/// Return a slightly darker color than the current color.
Color darken([double percent = 0.05]) {
assert(0.0 <= percent && percent <= 1.0);
percent = 1.0 - percent;

final c = this;
return Color.from(
alpha: c.a,
red: c.r * percent,
green: c.g * percent,
blue: c.b * percent,
);
}

/// Return a slightly brighter color than the current color.
Color brighten([double percent = 0.05]) {
assert(0.0 <= percent && percent <= 1.0);

final c = this;
return Color.from(
alpha: c.a,
red: c.r + ((1.0 - c.r) * percent),
green: c.g + ((1.0 - c.g) * percent),
blue: c.b + ((1.0 - c.b) * percent),
);
}
}

0 comments on commit 2184bba

Please sign in to comment.