Skip to content
Merged
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
61 changes: 17 additions & 44 deletions packages/devtools_app/lib/src/flutter/scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ class DevToolsScaffoldState extends State<DevToolsScaffold>
with TickerProviderStateMixin {
/// A tag used for [Hero] widgets to keep the [AppBar] in the same place
/// across route transitions.
static const String _appBarTag = 'DevTools AppBar';

AnimationController appBarAnimation;
CurvedAnimation appBarCurve;
static const Object _appBarTag = 'DevTools AppBar';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did this change from String to Object

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used as an Object later on, so I just updated the type to reflect the intend.


/// The controller for animating between tabs.
///
Expand Down Expand Up @@ -140,25 +137,12 @@ class DevToolsScaffoldState extends State<DevToolsScaffold>
Notifications.of(context),
_pushSnapshotScreenForImport,
);

// If the animations are null, initialize them.
appBarAnimation ??= defaultAnimationController(
this,
value: isNarrow ? 1.0 : 0.0,
);
appBarCurve ??= defaultCurvedAnimation(appBarAnimation);
if (isNarrow) {
appBarAnimation.forward();
} else {
appBarAnimation.reverse();
}
}

@override
void dispose() {
_tabController?.dispose();
_currentScreen?.dispose();
appBarAnimation?.dispose();
_connectVmSubscription?.cancel();
_showPageSubscription?.cancel();

Expand Down Expand Up @@ -286,20 +270,14 @@ class DevToolsScaffoldState extends State<DevToolsScaffold>
// TODO(kenz): we are handling drops from multiple scaffolds. We need
// to make sure we are only handling drops from the active scaffold.
handleDrop: _importController.importData,
child: AnimatedBuilder(
animation: appBarCurve,
builder: (context, child) {
return Scaffold(
appBar: _buildAppBar(),
body: child,
bottomNavigationBar: _buildStatusLine(context),
);
},
child: TabBarView(
child: Scaffold(
appBar: _buildAppBar(),
body: TabBarView(
physics: defaultTabBarViewPhysics,
controller: _tabController,
children: tabBodies,
),
bottomNavigationBar: _buildStatusLine(context),
),
),
),
Expand Down Expand Up @@ -328,31 +306,26 @@ class DevToolsScaffoldState extends State<DevToolsScaffold>
onTap: _pushScreenToLocalPageRoute,
tabs: [for (var screen in widget.tabs) screen.buildTab(context)],
);
preferredSize = Tween<Size>(
begin: const Size.fromHeight(kToolbarHeight),
end: const Size.fromHeight(kToolbarHeight + 40.0),
).evaluate(appBarCurve);
final animatedAlignment = Tween<Alignment>(
begin: Alignment.centerRight,
end: Alignment.bottomLeft,
).evaluate(appBarCurve);
preferredSize = isNarrow
? const Size.fromHeight(kToolbarHeight + 40.0)
: const Size.fromHeight(kToolbarHeight);
final alignment = isNarrow ? Alignment.bottomLeft : Alignment.centerRight;

final rightAdjust =
isNarrow ? 0.0 : DevToolsScaffold.actionWidgetSize / 2;
final animatedRightPadding = Tween<double>(
begin: math.max(
0.0,
DevToolsScaffold.actionWidgetSize * (actions?.length ?? 0.0) -
rightAdjust),
end: 0.0,
).evaluate(appBarCurve);
final rightPadding = isNarrow
? 0.0
: math.max(
0.0,
DevToolsScaffold.actionWidgetSize * (actions?.length ?? 0.0) -
rightAdjust);

flexibleSpace = Align(
alignment: animatedAlignment,
alignment: alignment,
child: Padding(
padding: EdgeInsets.only(
top: 4.0,
right: animatedRightPadding,
right: rightPadding,
),
child: tabBar,
),
Expand Down