Skip to content

Commit

Permalink
use backdrop to replace scaffold drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
X-Wei committed Jul 27, 2019
1 parent 2b69ab2 commit da486f8
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions lib/my_route.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:backdrop/backdrop.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart' as url_launcher;
Expand Down Expand Up @@ -37,30 +38,35 @@ abstract class MyRoute extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Text(this.title),
),
actions: _getAppbarActions(context),
elevation: 0,
final double headerHeight = 128.0;
final double appbarHeight = kToolbarHeight;
final double backLayerHeight =
MediaQuery.of(context).size.height - headerHeight - appbarHeight;
return BackdropScaffold(
title: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Text(this.title),
),
// Use a Builder so that Scaffold.of(context) uses correct context, c.f.
// https://stackoverflow.com/a/45948913
body: Builder(
actions: _getAppbarActions(context),
iconPosition: BackdropIconPosition.action,
headerHeight: headerHeight,
frontLayer: Builder(
builder: (BuildContext context) => WidgetWithCodeView(
child: this.buildMyRouteContent(context),
sourceFilePath: this._sourceFile,
codeLinkPrefix: '$GITHUB_URL/blob/master',
),
),
// Only home route has drawer:
drawer: this.routeName == Navigator.defaultRouteName
? Drawer(
child: my_app_meta.getNavDrawerItems(context),
)
: null,
// To make the listview in backlayer scrollable, had to calculate the
// height of backlayer, and wrap inside a Column. This is due to the
// implementation of BackdropScaffold ('backdrop' package, v0.1.8).
backLayer: Column(
children: <Widget>[
SizedBox(
height: backLayerHeight,
child: my_app_meta.getNavDrawerItems(context))
],
),
);
}

Expand Down

0 comments on commit da486f8

Please sign in to comment.