Skip to content

Commit

Permalink
Move OutlineDecoration to devtools_app_shared (#6245)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenzieschmoll authored Aug 24, 2023
1 parent 7ff0097 commit cf45a7d
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 75 deletions.
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
1 change: 0 additions & 1 deletion packages/devtools_app/lib/src/screens/debugger/common.dart
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

0 comments on commit cf45a7d

Please sign in to comment.