Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move OutlineDecoration to devtools_app_shared #6245

Merged
merged 2 commits into from
Aug 24, 2023
Merged
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
1 change: 0 additions & 1 deletion packages/devtools_app/lib/src/framework/scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import '../extensions/extension_settings.dart';
import '../screens/debugger/debugger_screen.dart';
import '../shared/analytics/prompt.dart';
import '../shared/banner_messages.dart';
import '../shared/common_widgets.dart';
import '../shared/config_specific/drag_and_drop/drag_and_drop.dart';
import '../shared/config_specific/import_export/import_export.dart';
import '../shared/console/widgets/console_pane.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import 'package:devtools_app_shared/ui.dart';
import 'package:flutter/material.dart';

import '../../shared/common_widgets.dart';
import '../../shared/utils.dart';

/// Create a header area for a debugger component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import 'package:devtools_app_shared/ui.dart';
import 'package:flutter/widgets.dart';

import '../../../../../../shared/common_widgets.dart';
import '../../../../shared/heap/heap.dart';
import '../../controller/class_data.dart';
import 'path.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:devtools_app_shared/ui.dart';
import 'package:flutter/material.dart';

import '../../shared/analytics/constants.dart' as gac;
import '../../shared/common_widgets.dart';
import '../../shared/http/http_request_data.dart';
import '../../shared/ui/tab.dart';
import 'network_controller.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:devtools_app_shared/ui.dart';
import 'package:devtools_app_shared/utils.dart';
import 'package:flutter/material.dart';

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

import '../../../shared/common_widgets.dart';
import '../../../shared/primitives/utils.dart';
import '../../../shared/table/table.dart';
import '../../../shared/table/table_data.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:devtools_app_shared/ui.dart';
import 'package:flutter/material.dart';

import '../../../shared/common_widgets.dart';
import '../vm_developer_common_widgets.dart';
import 'object_inspector_view_controller.dart';
import 'vm_object_model.dart';
Expand Down
67 changes: 0 additions & 67 deletions packages/devtools_app/lib/src/shared/common_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -943,73 +943,6 @@ class OutlinedRowGroup extends StatelessWidget {
}
}

class OutlineDecoration extends StatelessWidget {
const OutlineDecoration({
Key? key,
this.child,
this.showTop = true,
this.showBottom = true,
this.showLeft = true,
this.showRight = true,
}) : super(key: key);

factory OutlineDecoration.onlyBottom({required Widget? child}) =>
OutlineDecoration(
showTop: false,
showLeft: false,
showRight: false,
child: child,
);

factory OutlineDecoration.onlyTop({required Widget? child}) =>
OutlineDecoration(
showBottom: false,
showLeft: false,
showRight: false,
child: child,
);

factory OutlineDecoration.onlyLeft({required Widget? child}) =>
OutlineDecoration(
showBottom: false,
showTop: false,
showRight: false,
child: child,
);

factory OutlineDecoration.onlyRight({required Widget? child}) =>
OutlineDecoration(
showBottom: false,
showTop: false,
showLeft: false,
child: child,
);

final bool showTop;
final bool showBottom;
final bool showLeft;
final bool showRight;

final Widget? child;

@override
Widget build(BuildContext context) {
final color = Theme.of(context).focusColor;
final border = BorderSide(color: color);
return Container(
decoration: BoxDecoration(
border: Border(
left: showLeft ? border : BorderSide.none,
right: showRight ? border : BorderSide.none,
top: showTop ? border : BorderSide.none,
bottom: showBottom ? border : BorderSide.none,
),
),
child: child,
);
}
}

class ThickDivider extends StatelessWidget {
const ThickDivider({super.key});

Expand Down
1 change: 0 additions & 1 deletion packages/devtools_app/lib/src/shared/ui/tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:devtools_app_shared/ui.dart';
import 'package:flutter/material.dart';

import '../analytics/analytics.dart' as ga;
import '../common_widgets.dart';
import '../utils.dart';

double get _tabHeight => scaleByFontFactor(46.0);
Expand Down
79 changes: 79 additions & 0 deletions packages/devtools_app_shared/lib/src/ui/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ class AreaPaneHeader extends StatelessWidget implements PreferredSizeWidget {
}
}

/// Wraps [child] in a rounded border with default styling.
///
/// This border can optionally be made non-uniform by setting any of
/// [showTop], [showBottom], [showLeft] or [showRight] to false.
///
/// If [clip] is true, the child will be wrapped in a [ClipRRect] to ensure the
/// rounded corner of the border is drawn as expected. This should not be
/// necessary in most cases.
final class RoundedOutlinedBorder extends StatelessWidget {
const RoundedOutlinedBorder({
super.key,
Expand Down Expand Up @@ -182,6 +190,77 @@ final class RoundedOutlinedBorder extends StatelessWidget {
}
}

/// Wraps [child] in a border with default styling.
///
/// This border can optionally be made non-uniform by setting any of
/// [showTop], [showBottom], [showLeft] or [showRight] to false.
final class OutlineDecoration extends StatelessWidget {
const OutlineDecoration({
Key? key,
this.child,
this.showTop = true,
this.showBottom = true,
this.showLeft = true,
this.showRight = true,
}) : super(key: key);

factory OutlineDecoration.onlyBottom({required Widget? child}) =>
OutlineDecoration(
showTop: false,
showLeft: false,
showRight: false,
child: child,
);

factory OutlineDecoration.onlyTop({required Widget? child}) =>
OutlineDecoration(
showBottom: false,
showLeft: false,
showRight: false,
child: child,
);

factory OutlineDecoration.onlyLeft({required Widget? child}) =>
OutlineDecoration(
showBottom: false,
showTop: false,
showRight: false,
child: child,
);

factory OutlineDecoration.onlyRight({required Widget? child}) =>
OutlineDecoration(
showBottom: false,
showTop: false,
showLeft: false,
child: child,
);

final bool showTop;
final bool showBottom;
final bool showLeft;
final bool showRight;

final Widget? child;

@override
Widget build(BuildContext context) {
final color = Theme.of(context).focusColor;
final border = BorderSide(color: color);
return Container(
decoration: BoxDecoration(
border: Border(
left: showLeft ? border : BorderSide.none,
right: showRight ? border : BorderSide.none,
top: showTop ? border : BorderSide.none,
bottom: showBottom ? border : BorderSide.none,
),
),
child: child,
);
}
}

/// [BorderSide] styled with the DevTools default color palette.
BorderSide defaultBorderSide(ThemeData theme) {
return BorderSide(color: theme.focusColor);
Expand Down