Compare commits
5 Commits
b568074ef7
...
bd9e0bc4e8
Author | SHA1 | Date |
---|---|---|
poka | bd9e0bc4e8 | |
david.peters | 735963a9bc | |
david.peters | 8358e625a5 | |
david.peters | 93e82a73f6 | |
David Peters | 2ce48a3f46 |
|
@ -1,3 +1,8 @@
|
||||||
|
## 1.0.1
|
||||||
|
|
||||||
|
* Added dark theme support [#13](https://github.com/peterscodee/miniplayer/issues/13)
|
||||||
|
* Removed overflow errors in the example app [#14](https://github.com/peterscodee/miniplayer/issues/14)
|
||||||
|
|
||||||
## 1.0.0+2
|
## 1.0.0+2
|
||||||
|
|
||||||
* Fixed a bug introduced with the null safety release
|
* Fixed a bug introduced with the null safety release
|
||||||
|
|
|
@ -7,49 +7,49 @@ packages:
|
||||||
name: async
|
name: async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.2"
|
version: "2.8.1"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: boolean_selector
|
name: boolean_selector
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.1.0"
|
||||||
characters:
|
characters:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: characters
|
name: characters
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.0"
|
version: "1.1.0"
|
||||||
charcode:
|
charcode:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: charcode
|
name: charcode
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.3"
|
version: "1.3.1"
|
||||||
clock:
|
clock:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: clock
|
name: clock
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.1"
|
version: "1.1.0"
|
||||||
collection:
|
collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: collection
|
name: collection
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.14.13"
|
version: "1.15.0"
|
||||||
fake_async:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: fake_async
|
name: fake_async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.2.0"
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -66,28 +66,28 @@ packages:
|
||||||
name: matcher
|
name: matcher
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.8"
|
version: "0.12.10"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.8"
|
version: "1.7.0"
|
||||||
miniplayer:
|
miniplayer:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: miniplayer
|
path: ".."
|
||||||
url: "https://pub.dartlang.org"
|
relative: true
|
||||||
source: hosted
|
source: path
|
||||||
version: "0.4.0"
|
version: "1.0.1"
|
||||||
path:
|
path:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path
|
name: path
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.7.0"
|
version: "1.8.0"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -99,56 +99,55 @@ packages:
|
||||||
name: source_span
|
name: source_span
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.7.0"
|
version: "1.8.1"
|
||||||
stack_trace:
|
stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stack_trace
|
name: stack_trace
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.5"
|
version: "1.10.0"
|
||||||
stream_channel:
|
stream_channel:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stream_channel
|
name: stream_channel
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.1.0"
|
||||||
string_scanner:
|
string_scanner:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: string_scanner
|
name: string_scanner
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.5"
|
version: "1.1.0"
|
||||||
term_glyph:
|
term_glyph:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: term_glyph
|
name: term_glyph
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.2.0"
|
||||||
test_api:
|
test_api:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.17"
|
version: "0.4.2"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: typed_data
|
name: typed_data
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.3.0"
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vector_math
|
name: vector_math
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.8"
|
version: "2.1.0"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.9.0-14.0.dev <3.0.0"
|
dart: ">=2.12.0 <3.0.0"
|
||||||
flutter: ">=1.0.0 <2.0.0"
|
|
||||||
|
|
|
@ -24,7 +24,9 @@ dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
miniplayer: ^1.0.0
|
miniplayer:
|
||||||
|
path:
|
||||||
|
../
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
|
@ -98,7 +98,9 @@ class _MiniplayerState extends State<Miniplayer> with TickerProviderStateMixin {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _resetAnimationController({Duration? duration}) {
|
void _resetAnimationController({Duration? duration}) {
|
||||||
if (_animationController != null) _animationController!.dispose();
|
if (_animationController != null) {
|
||||||
|
_animationController!.dispose();
|
||||||
|
}
|
||||||
_animationController = AnimationController(
|
_animationController = AnimationController(
|
||||||
vsync: this,
|
vsync: this,
|
||||||
duration: duration ?? widget.duration,
|
duration: duration ?? widget.duration,
|
||||||
|
@ -109,23 +111,26 @@ class _MiniplayerState extends State<Miniplayer> with TickerProviderStateMixin {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
if (widget.valueNotifier == null)
|
if (widget.valueNotifier == null) {
|
||||||
heightNotifier = ValueNotifier(widget.minHeight);
|
heightNotifier = ValueNotifier(widget.minHeight);
|
||||||
else
|
} else {
|
||||||
heightNotifier = widget.valueNotifier!;
|
heightNotifier = widget.valueNotifier!;
|
||||||
|
}
|
||||||
|
|
||||||
_resetAnimationController();
|
_resetAnimationController();
|
||||||
|
|
||||||
_dragHeight = heightNotifier.value;
|
_dragHeight = heightNotifier.value;
|
||||||
|
|
||||||
if (widget.controller != null)
|
if (widget.controller != null) {
|
||||||
widget.controller!.addListener(controllerListener);
|
widget.controller!.addListener(controllerListener);
|
||||||
|
}
|
||||||
|
|
||||||
if (widget.onDismissed != null)
|
if (widget.onDismissed != null) {
|
||||||
onDismissed = widget.onDismissed;
|
onDismissed = widget.onDismissed;
|
||||||
else
|
} else {
|
||||||
// ignore: deprecated_member_use_from_same_package
|
// ignore: deprecated_member_use_from_same_package
|
||||||
onDismissed = widget.onDismiss;
|
onDismissed = widget.onDismiss;
|
||||||
|
}
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
@ -133,17 +138,23 @@ class _MiniplayerState extends State<Miniplayer> with TickerProviderStateMixin {
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_heightController.close();
|
_heightController.close();
|
||||||
if (_animationController != null) _animationController!.dispose();
|
|
||||||
|
|
||||||
if (widget.controller != null)
|
if (_animationController != null) {
|
||||||
|
_animationController!.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (widget.controller != null) {
|
||||||
widget.controller!.removeListener(controllerListener);
|
widget.controller!.removeListener(controllerListener);
|
||||||
|
}
|
||||||
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (dismissed) return Container();
|
if (dismissed) {
|
||||||
|
return Container();
|
||||||
|
}
|
||||||
|
|
||||||
return MiniplayerWillPopScope(
|
return MiniplayerWillPopScope(
|
||||||
onWillPop: () async {
|
onWillPop: () async {
|
||||||
|
@ -180,8 +191,6 @@ class _MiniplayerState extends State<Miniplayer> with TickerProviderStateMixin {
|
||||||
valueListenable: dragDownPercentage,
|
valueListenable: dragDownPercentage,
|
||||||
builder:
|
builder:
|
||||||
(BuildContext context, double value, Widget? child) {
|
(BuildContext context, double value, Widget? child) {
|
||||||
if (value == 0) return child!;
|
|
||||||
|
|
||||||
return Opacity(
|
return Opacity(
|
||||||
opacity: borderDouble(
|
opacity: borderDouble(
|
||||||
minRange: 0.0,
|
minRange: 0.0,
|
||||||
|
@ -204,7 +213,7 @@ class _MiniplayerState extends State<Miniplayer> with TickerProviderStateMixin {
|
||||||
blurRadius: widget.elevation,
|
blurRadius: widget.elevation,
|
||||||
offset: Offset(0.0, 4))
|
offset: Offset(0.0, 4))
|
||||||
],
|
],
|
||||||
color: Theme.of(context).canvasColor,
|
color: widget.backgroundColor, //kopa
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -216,7 +225,9 @@ class _MiniplayerState extends State<Miniplayer> with TickerProviderStateMixin {
|
||||||
_startHeight = _dragHeight;
|
_startHeight = _dragHeight;
|
||||||
updateCount = 0;
|
updateCount = 0;
|
||||||
|
|
||||||
if (animating) _resetAnimationController();
|
if (animating) {
|
||||||
|
_resetAnimationController();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onPanEnd: (details) async {
|
onPanEnd: (details) async {
|
||||||
///Calculates drag speed
|
///Calculates drag speed
|
||||||
|
@ -229,11 +240,13 @@ class _MiniplayerState extends State<Miniplayer> with TickerProviderStateMixin {
|
||||||
|
|
||||||
///Define the percentage distance depending on the speed with which the widget should snap
|
///Define the percentage distance depending on the speed with which the widget should snap
|
||||||
double snapPercentage = 0.005;
|
double snapPercentage = 0.005;
|
||||||
if (speed <= 4)
|
if (speed <= 4) {
|
||||||
snapPercentage = 0.2;
|
snapPercentage = 0.2;
|
||||||
else if (speed <= 9)
|
} else if (speed <= 9) {
|
||||||
snapPercentage = 0.08;
|
snapPercentage = 0.08;
|
||||||
else if (speed <= 50) snapPercentage = 0.01;
|
} else if (speed <= 50) {
|
||||||
|
snapPercentage = 0.01;
|
||||||
|
}
|
||||||
|
|
||||||
///Determine to which SnapPosition the widget should snap
|
///Determine to which SnapPosition the widget should snap
|
||||||
PanelState snap = PanelState.MIN;
|
PanelState snap = PanelState.MIN;
|
||||||
|
@ -245,23 +258,27 @@ class _MiniplayerState extends State<Miniplayer> with TickerProviderStateMixin {
|
||||||
|
|
||||||
///Started from expanded state
|
///Started from expanded state
|
||||||
if (_startHeight > widget.minHeight) {
|
if (_startHeight > widget.minHeight) {
|
||||||
if (_percentageMax > 1 - snapPercentage)
|
if (_percentageMax > 1 - snapPercentage) {
|
||||||
snap = PanelState.MAX;
|
snap = PanelState.MAX;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///Started from minified state
|
///Started from minified state
|
||||||
else {
|
else {
|
||||||
if (_percentageMax > snapPercentage)
|
if (_percentageMax > snapPercentage) {
|
||||||
snap = PanelState.MAX;
|
snap = PanelState.MAX;
|
||||||
else
|
}
|
||||||
|
|
||||||
///DismissedPercentage > 0.2 -> dismiss
|
///DismissedPercentage > 0.2 -> dismiss
|
||||||
if (onDismissed != null &&
|
else if (onDismissed != null &&
|
||||||
percentageFromValueInRange(
|
percentageFromValueInRange(
|
||||||
min: widget.minHeight,
|
min: widget.minHeight,
|
||||||
max: 0,
|
max: 0,
|
||||||
value: _dragHeight) >
|
value: _dragHeight,
|
||||||
snapPercentage) snap = PanelState.DISMISS;
|
) >
|
||||||
|
snapPercentage) {
|
||||||
|
snap = PanelState.DISMISS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///Snap to position
|
///Snap to position
|
||||||
|
@ -289,7 +306,9 @@ class _MiniplayerState extends State<Miniplayer> with TickerProviderStateMixin {
|
||||||
void _handleHeightChange({bool animation = false}) {
|
void _handleHeightChange({bool animation = false}) {
|
||||||
///Drag above minHeight
|
///Drag above minHeight
|
||||||
if (_dragHeight >= widget.minHeight) {
|
if (_dragHeight >= widget.minHeight) {
|
||||||
if (dragDownPercentage.value != 0) dragDownPercentage.value = 0;
|
if (dragDownPercentage.value != 0) {
|
||||||
|
dragDownPercentage.value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (_dragHeight > widget.maxHeight) return;
|
if (_dragHeight > widget.maxHeight) return;
|
||||||
|
|
||||||
|
@ -298,20 +317,21 @@ class _MiniplayerState extends State<Miniplayer> with TickerProviderStateMixin {
|
||||||
|
|
||||||
///Drag below minHeight
|
///Drag below minHeight
|
||||||
else if (onDismissed != null) {
|
else if (onDismissed != null) {
|
||||||
var percentageDown = borderDouble(
|
final percentageDown = borderDouble(
|
||||||
minRange: 0.0,
|
minRange: 0.0,
|
||||||
maxRange: 1.0,
|
maxRange: 1.0,
|
||||||
value: percentageFromValueInRange(
|
value: percentageFromValueInRange(
|
||||||
min: widget.minHeight, max: 0, value: _dragHeight));
|
min: widget.minHeight, max: 0, value: _dragHeight));
|
||||||
|
|
||||||
if (dragDownPercentage.value != percentageDown)
|
if (dragDownPercentage.value != percentageDown) {
|
||||||
dragDownPercentage.value = percentageDown;
|
dragDownPercentage.value = percentageDown;
|
||||||
|
}
|
||||||
|
|
||||||
if (percentageDown >= 1 && animation && !dismissed) {
|
if (percentageDown >= 1 && animation && !dismissed) {
|
||||||
if (onDismissed != null) onDismissed!();
|
if (onDismissed != null) {
|
||||||
setState(() {
|
onDismissed!();
|
||||||
dismissed = true;
|
}
|
||||||
});
|
setState(() => dismissed = true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,7 +356,9 @@ class _MiniplayerState extends State<Miniplayer> with TickerProviderStateMixin {
|
||||||
if (_animationController == null) return;
|
if (_animationController == null) return;
|
||||||
final startHeight = _dragHeight;
|
final startHeight = _dragHeight;
|
||||||
|
|
||||||
if (duration != null) _resetAnimationController(duration: duration);
|
if (duration != null) {
|
||||||
|
_resetAnimationController(duration: duration);
|
||||||
|
}
|
||||||
|
|
||||||
Animation<double> _sizeAnimation = Tween(
|
Animation<double> _sizeAnimation = Tween(
|
||||||
begin: startHeight,
|
begin: startHeight,
|
||||||
|
@ -408,22 +430,26 @@ class MiniplayerController extends ValueNotifier<ControllerData?> {
|
||||||
//Animates to a given height or state(expanded, dismissed, ...)
|
//Animates to a given height or state(expanded, dismissed, ...)
|
||||||
void animateToHeight(
|
void animateToHeight(
|
||||||
{double? height, PanelState? state, Duration? duration}) {
|
{double? height, PanelState? state, Duration? duration}) {
|
||||||
if (height == null && state == null)
|
if (height == null && state == null) {
|
||||||
throw ("Miniplayer: One of the two parameters, height or status, is required.");
|
throw ("Miniplayer: One of the two parameters, height or status, is required.");
|
||||||
|
}
|
||||||
|
|
||||||
if (height != null && state != null)
|
if (height != null && state != null) {
|
||||||
throw ("Miniplayer: Only one of the two parameters, height or status, can be specified.");
|
throw ("Miniplayer: Only one of the two parameters, height or status, can be specified.");
|
||||||
|
}
|
||||||
|
|
||||||
ControllerData? valBefore = value;
|
ControllerData? valBefore = value;
|
||||||
|
|
||||||
if (state != null)
|
if (state != null) {
|
||||||
value = ControllerData(state.heightCode, duration);
|
value = ControllerData(state.heightCode, duration);
|
||||||
else {
|
} else {
|
||||||
if (height! < 0) return;
|
if (height! < 0) return;
|
||||||
|
|
||||||
value = ControllerData(height.round(), duration);
|
value = ControllerData(height.round(), duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valBefore == value) notifyListeners();
|
if (valBefore == value) {
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: miniplayer
|
name: miniplayer
|
||||||
description: A lightweight flutter package to simplify the creation of a miniplayer.
|
description: A lightweight flutter package to simplify the creation of a miniplayer.
|
||||||
version: 1.0.0+2
|
version: 1.0.1
|
||||||
homepage: https://www.peterscode.dev
|
homepage: https://www.peterscode.dev
|
||||||
repository: https://github.com/peterscodee/miniplayer
|
repository: https://github.com/peterscodee/miniplayer
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue