Skip to content

Commit

Permalink
refactor!: removed all deprecated members (#102)
Browse files Browse the repository at this point in the history
* refactor!: removed all deprecated members

* readme: removed "Getting started" section as the article is outdated now

* minor re-arragnment

* remove any default `AppBar`
  • Loading branch information
daadu authored Dec 18, 2021
1 parent 9e5c2b8 commit dade980
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 159 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ __NOTE: If using Flutter v1.x.x, use v0.5.x pub version.__
| __Issue Tracker__ | https://github.com/fluttercommunity/backdrop/issues |
| __Chat Room__ | https://gitter.im/flutter-backdrop |

## Getting started
Follow the medium article to [__Quickly Implement Backdrop in Flutter.__](https://medium.com/@daadu/backdrop-with-flutter-acfa9fee7d2f)

## Usage
### BackdropScaffold
Use `BackdropScaffold` instead of the standard `Scaffold` in your app.
Expand Down
2 changes: 1 addition & 1 deletion demo/lib/use_cases/navigation/navigation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class _NavigationState extends State<Navigation> {
)),
],
onTap: (int position) => {setState(() => _currentIndex = position)},
separator: const Divider(),
separatorBuilder: (context, position) => const Divider(),
);
}

Expand Down
19 changes: 0 additions & 19 deletions lib/app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,6 @@ import 'package:backdrop/button.dart';
import 'package:backdrop/scaffold.dart';
import 'package:flutter/material.dart';

/// Deprecated. Not needed anymore when [BackdropAppBar] is used.
///
/// This enum is used to specify where [BackdropToggleButton] should appear
/// within [AppBar].
@Deprecated("Replace by the use of BackdropAppBar."
"This feature was deprecated after v0.2.17.")
enum BackdropIconPosition {
/// Indicates that [BackdropToggleButton] should not appear at all.
none,

/// Indicates that [BackdropToggleButton] should appear at the start of
/// [AppBar].
leading,

/// Indicates that [BackdropToggleButton] should appear as an action within
/// [AppBar.actions].
action
}

/// A material app bar that offers functionality for triggering the
/// [BackdropScaffold]'s functionality. It is internally implemented using the
/// [AppBar] class.
Expand Down
9 changes: 1 addition & 8 deletions lib/navigation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ class BackdropNavigationBackLayer extends StatelessWidget {
/// Callback that is called whenever a list item is tapped by the user.
final ValueChanged<int>? onTap;

/// Customizable separator used with [ListView.separated].
@Deprecated("Replace by use of `separatorBuilder`."
"This feature was deprecated after v0.4.2.")
final Widget? separator;

/// Customizable separatorBuilder used with [ListView.separated].
final IndexedWidgetBuilder? separatorBuilder;

Expand All @@ -71,7 +66,6 @@ class BackdropNavigationBackLayer extends StatelessWidget {
Key? key,
required this.items,
this.onTap,
this.separator,
this.separatorBuilder,
this.itemPadding,
this.itemSplashBorder,
Expand All @@ -97,8 +91,7 @@ class BackdropNavigationBackLayer extends StatelessWidget {
customBorder: itemSplashBorder,
splashColor: itemSplashColor,
),
separatorBuilder:
separatorBuilder ?? (builder, position) => separator ?? Container(),
separatorBuilder: separatorBuilder ?? (builder, position) => Container(),
);
}
}
140 changes: 12 additions & 128 deletions lib/scaffold.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import 'package:backdrop/app_bar.dart';
import 'package:backdrop/button.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';

@Deprecated('Replace with frontLayerScrim.')
const _kInactiveOverlayOpacity = 0.7;
@Deprecated('Replace with frontLayerScrim.')
const _kInactiveOverlayColor = Color(0xFFEEEEEE);

/// This class is an InheritedWidget that exposes state of [BackdropScaffold]
/// [BackdropScaffoldState] to be accessed from anywhere below the widget tree.
///
Expand Down Expand Up @@ -70,20 +64,9 @@ class Backdrop extends InheritedWidget {
/// See also:
/// * [Scaffold], which is the plain scaffold used in material apps.
class BackdropScaffold extends StatefulWidget {
/// Deprecated. Use [animationController].
///
/// Can be used to customize the behaviour of the backdrop animation.
@Deprecated("See animationController. This was deprecated after v0.5.1")
final AnimationController? controller;

/// Can be used to customize the behaviour of the backdrop animation.
final AnimationController? animationController;

/// Deprecated. Use [BackdropAppBar.title].
///
/// The widget assigned to the [Scaffold]'s [AppBar.title].
final Widget? title;

/// Content that should be displayed on the back layer.
final Widget backLayer;

Expand All @@ -102,11 +85,6 @@ class BackdropScaffold extends StatefulWidget {
/// Defaults to true.
final bool subHeaderAlwaysActive;

/// Deprecated. Use [BackdropAppBar.actions].
///
/// Actions passed to [AppBar.actions].
final List<Widget> actions;

/// Defines the front layer's height when minimized (back layer revealed)).
/// Defaults to measured height of [subHeader] if provided, else 32.
///
Expand All @@ -129,14 +107,6 @@ class BackdropScaffold extends StatefulWidget {
/// ```
final BorderRadius frontLayerBorderRadius;

/// Deprecated. Use [BackdropAppBar]'s properties [BackdropAppBar.leading] and
/// [BackdropAppBar.automaticallyImplyLeading] to achieve the same behaviour.
///
/// The position of the icon button that toggles the backdrop functionality.
///
/// Defaults to [BackdropIconPosition.leading].
final BackdropIconPosition iconPosition;

/// Indicates the front layer should minimize to the back layer's
/// bottom edge. Otherwise, see [headerHeight] to specify this value.
/// Defaults to `false`.
Expand Down Expand Up @@ -183,15 +153,6 @@ class BackdropScaffold extends StatefulWidget {
/// Defaults to 1.
final double frontLayerActiveFactor;

/// Deprecated. Use [frontLayerScrim] instead.
@Deprecated('Replace with frontLayerScrim.')
final Color? inactiveOverlayColor;

/// Deprecated. Use [frontLayerScrim] instead.
@Deprecated('Replace with frontLayerScrim. Use Color#withOpacity, or pass'
'the opacity value in the Color constructor.')
final double? inactiveOverlayOpacity;

/// Defines the scrim color for the front layer when minimized
/// (revealing the back layer) and animating. Defaults to [Colors.white70].
///
Expand Down Expand Up @@ -225,7 +186,7 @@ class BackdropScaffold extends StatefulWidget {
/// A key to use when building the [Scaffold].
final GlobalKey<ScaffoldState>? scaffoldKey;

/// See [Scaffold.appBar].
/// See [Scaffold.appBar] and [BackdropAppBar].
final PreferredSizeWidget? appBar;

/// See [Scaffold.extendBody].
Expand Down Expand Up @@ -299,39 +260,23 @@ class BackdropScaffold extends StatefulWidget {
/// Creates a backdrop scaffold to be used as a material widget.
BackdropScaffold({
Key? key,
@Deprecated("See animationController. This was deprecated after v0.5.1")
this.controller,
this.animationController,
@Deprecated("Replace by use of BackdropAppBar. See BackdropAppBar.title."
"This feature was deprecated after v0.2.17.")
this.title,
required this.backLayer,
required this.frontLayer,
this.subHeader,
this.subHeaderAlwaysActive = true,
@Deprecated("Replace by use of BackdropAppBar. See BackdropAppBar.actions."
"This feature was deprecated after v0.2.17.")
this.actions = const <Widget>[],
this.headerHeight,
this.frontLayerBorderRadius = const BorderRadius.only(
topLeft: Radius.circular(16),
topRight: Radius.circular(16),
),
@Deprecated("Replace by use of BackdropAppBar. See BackdropAppBar.leading"
"and BackdropAppBar.automaticallyImplyLeading."
"This feature was deprecated after v0.2.17.")
this.iconPosition = BackdropIconPosition.leading,
this.stickyFrontLayer = false,
this.revealBackLayerAtStart = false,
this.animationCurve = Curves.ease,
this.reverseAnimationCurve,
this.frontLayerBackgroundColor,
double frontLayerActiveFactor = 1,
this.backLayerBackgroundColor,
@Deprecated('See frontLayerScrim. This was deprecated after v0.4.7.')
this.inactiveOverlayColor,
@Deprecated('See frontLayerScrim. This was deprecated after v0.4.7.')
this.inactiveOverlayOpacity,
this.frontLayerScrim = Colors.white70,
this.backLayerScrim = Colors.black54,
this.onBackLayerConcealed,
Expand All @@ -357,16 +302,15 @@ class BackdropScaffold extends StatefulWidget {
this.drawerEdgeDragWidth,
this.drawerEnableOpenDragGesture = true,
this.endDrawerEnableOpenDragGesture = true,
}) : assert(inactiveOverlayOpacity == null ||
inactiveOverlayOpacity >= 0.0 && inactiveOverlayOpacity <= 1.0),
frontLayerActiveFactor = frontLayerActiveFactor.clamp(0, 1).toDouble(),
}) : frontLayerActiveFactor = frontLayerActiveFactor.clamp(0, 1).toDouble(),
super(key: key);

@override
BackdropScaffoldState createState() => BackdropScaffoldState();
}

/// This class is used to represent the internal state of [BackdropScaffold].
///
/// It provides access to the functionality for triggering backdrop. As well it
/// offers ways to retrieve the current state of the [BackdropScaffold]'s front-
/// or back layers (concealed/revealed).
Expand All @@ -386,13 +330,6 @@ class BackdropScaffoldState extends State<BackdropScaffold>
double _backPanelHeight = 0;
double _subHeaderHeight = 0;

/// Deprecated. Use [animationController] instead.
///
/// [AnimationController] used for the backdrop animation.
@Deprecated("Replace by the use of `animationController`."
"This feature was deprecated after v0.5.1.")
AnimationController get controller => _animationController;

/// [AnimationController] used for the backdrop animation.
///
/// Defaults to
Expand All @@ -409,16 +346,15 @@ class BackdropScaffoldState extends State<BackdropScaffold>
scaffoldKey = widget.scaffoldKey ?? GlobalKey<ScaffoldState>();
// initialize _controller
_animationController = widget.animationController ??
widget.controller ??
AnimationController(
vsync: this,
duration: const Duration(milliseconds: 200),
value: widget.revealBackLayerAtStart ? 0 : 1,
);

// should only dispose of `_animationController`, if it was initialised inside this widget.
_shouldDisposeAnimationController =
(widget.animationController ?? widget.controller) == null;
// should only dispose of `_animationController`,
// if it was initialised inside this widget.
_shouldDisposeAnimationController = widget.animationController == null;

_backLayerScrimColorTween = _buildBackLayerScrimColorTween();

Expand All @@ -445,25 +381,11 @@ class BackdropScaffoldState extends State<BackdropScaffold>
super.dispose();
}

/// Deprecated. Use [isBackLayerConcealed] instead.
///
/// Whether the back layer is concealed or not.
@Deprecated("Replace by the use of `isBackLayerConcealed`."
"This feature was deprecated after v0.3.2.")
bool get isTopPanelVisible => isBackLayerConcealed;

/// Whether the back layer is concealed or not.
bool get isBackLayerConcealed =>
animationController.status == AnimationStatus.completed ||
animationController.status == AnimationStatus.forward;

/// Deprecated. Use [isBackLayerRevealed] instead.
///
/// Whether the back layer is revealed or not.
@Deprecated("Replace by the use of `isBackLayerRevealed`."
"This feature was deprecated after v0.3.2.")
bool get isBackPanelVisible => isBackLayerRevealed;

/// Whether the back layer is revealed or not.
bool get isBackLayerRevealed =>
animationController.status == AnimationStatus.dismissed ||
Expand All @@ -483,13 +405,6 @@ class BackdropScaffoldState extends State<BackdropScaffold>
}
}

/// Deprecated. Use [revealBackLayer] instead.
///
/// Animates the back layer to the "revealed" state.
@Deprecated("Replace by the use of `revealBackLayer`."
"This feature was deprecated after v0.3.2.")
void showBackLayer() => revealBackLayer();

/// Animates the back layer to the "revealed" state.
void revealBackLayer() {
if (isBackLayerConcealed) {
Expand All @@ -498,13 +413,6 @@ class BackdropScaffoldState extends State<BackdropScaffold>
}
}

/// Deprecated. Use [concealBackLayer] instead.
///
/// Animates the back layer to the "concealed" state.
@Deprecated("Replace by the use of `concealBackLayer`."
"This feature was deprecated after v0.3.2.")
void showFrontLayer() => concealBackLayer();

/// Animates the back layer to the "concealed" state.
void concealBackLayer() {
if (isBackLayerRevealed) {
Expand Down Expand Up @@ -549,20 +457,6 @@ class BackdropScaffoldState extends State<BackdropScaffold>
}

Widget _buildInactiveLayer(BuildContext context) {
Color? frontLayerScrim;
if (widget.inactiveOverlayColor == null &&
widget.inactiveOverlayOpacity == null) {
frontLayerScrim = widget.frontLayerScrim;
} else if (widget.inactiveOverlayOpacity == null) {
frontLayerScrim = widget.inactiveOverlayColor!.withOpacity(
_kInactiveOverlayOpacity,
);
} else if (widget.inactiveOverlayColor == null) {
frontLayerScrim = _kInactiveOverlayColor.withOpacity(
widget.inactiveOverlayOpacity!,
);
}

return Offstage(
offstage: animationController.status == AnimationStatus.completed,
child: FadeTransition(
Expand All @@ -572,13 +466,13 @@ class BackdropScaffoldState extends State<BackdropScaffold>
behavior: HitTestBehavior.opaque,
child: Column(
children: <Widget>[
// if subHeaderAlwaysActive then do not apply frontLayerScrim for area with _subHeaderHeight
widget.subHeader != null && widget.subHeaderAlwaysActive
? Container(height: _subHeaderHeight)
: Container(),
// if subHeaderAlwaysActive then do not apply frontLayerScrim for
// area with _subHeaderHeight
if (widget.subHeader != null && widget.subHeaderAlwaysActive)
Container(height: _subHeaderHeight),
Expanded(
child: Container(
color: frontLayerScrim,
color: widget.frontLayerScrim,
),
),
],
Expand Down Expand Up @@ -668,17 +562,7 @@ class BackdropScaffoldState extends State<BackdropScaffold>
onWillPop: () => _willPopCallback(context),
child: Scaffold(
key: scaffoldKey,
appBar: widget.appBar ??
AppBar(
title: widget.title,
actions: widget.iconPosition == BackdropIconPosition.action
? <Widget>[const BackdropToggleButton()] + widget.actions
: widget.actions,
elevation: 0,
leading: widget.iconPosition == BackdropIconPosition.leading
? const BackdropToggleButton()
: null,
),
appBar: widget.appBar,
body: LayoutBuilder(
builder: (context, constraints) {
return Stack(
Expand Down

0 comments on commit dade980

Please sign in to comment.