Update player widget design.

This commit is contained in:
stonegate 2020-07-28 12:35:57 +08:00
parent 691c25fd6b
commit 4009f84c38
5 changed files with 1011 additions and 790 deletions

File diff suppressed because it is too large Load Diff

View File

@ -943,85 +943,31 @@ class _RecentUpdateState extends State<_RecentUpdate>
child: IconButton(
tooltip: s
.addNewEpisodeTooltip,
icon:
// Icon(Icons.playlist_add),
SizedBox(
height:
16,
width: 21,
child: CustomPaint(
painter: AddToPlaylistPainter(
context
.textColor,
context
.textColor,
))),
icon: SizedBox(
height: 16,
width: 21,
child:
CustomPaint(
painter:
AddToPlaylistPainter(
context
.textColor,
context
.textColor,
))),
onPressed: () {}),
);
}),
Material(
color: Colors.transparent,
child: IconButton(
tooltip: s.changeLayout,
padding: EdgeInsets.zero,
onPressed: () {
if (_layout ==
Layout.three) {
setState(() {
_layout = Layout.one;
});
} else if (_layout ==
Layout.two) {
setState(() {
_layout = Layout.three;
});
} else {
setState(() {
_layout = Layout.two;
});
}
},
icon: _layout == Layout.three
? SizedBox(
height: 10,
width: 30,
child: CustomPaint(
painter: LayoutPainter(
0,
context
.textTheme
.bodyText1
.color),
),
)
: _layout == Layout.two
? SizedBox(
height: 10,
width: 30,
child:
CustomPaint(
painter: LayoutPainter(
1,
context
.textTheme
.bodyText1
.color),
),
)
: SizedBox(
height: 10,
width: 30,
child:
CustomPaint(
painter: LayoutPainter(
4,
context
.textTheme
.bodyText1
.color),
),
),
)),
color: Colors.transparent,
child: LayoutButton(
layout: _layout,
onPressed: (layout) =>
setState(() {
_layout = layout;
}),
),
),
],
),
)),
@ -1204,62 +1150,12 @@ class _MyFavoriteState extends State<_MyFavorite>
Spacer(),
Material(
color: Colors.transparent,
child: IconButton(
padding: EdgeInsets.zero,
onPressed: () {
if (_layout == Layout.three) {
setState(() {
_layout = Layout.one;
});
} else if (_layout ==
Layout.two) {
setState(() {
_layout = Layout.three;
});
} else {
setState(() {
_layout = Layout.two;
});
}
},
icon: _layout == Layout.three
? SizedBox(
height: 10,
width: 30,
child: CustomPaint(
painter: LayoutPainter(
0,
context
.textTheme
.bodyText1
.color),
),
)
: _layout == Layout.two
? SizedBox(
height: 10,
width: 30,
child: CustomPaint(
painter: LayoutPainter(
1,
context
.textTheme
.bodyText1
.color),
),
)
: SizedBox(
height: 10,
width: 30,
child: CustomPaint(
painter: LayoutPainter(
4,
context
.textTheme
.bodyText1
.color),
),
)),
child: LayoutButton(
layout: _layout,
onPressed: (layout) => setState(() {
_layout = layout;
}),
),
),
],
)),

View File

@ -270,7 +270,7 @@ class DBHelper {
var playHistory = <PlayHistory>[];
for (var record in list) {
playHistory.add(PlayHistory(record['title'], record['enclosure_url'],
record['seconds'], record['seek_value'],
(record['seconds']).toInt(), record['seek_value'],
playdate: DateTime.fromMillisecondsSinceEpoch(record['add_date'])));
}
return playHistory;
@ -337,7 +337,7 @@ class DBHelper {
[episodeBrief.enclosureUrl]);
return list.isNotEmpty
? PlayHistory(list.first['title'], list.first['enclosure_url'],
list.first['seconds'], list.first['seek_value'],
(list.first['seconds']).toInt(), list.first['seek_value'],
playdate:
DateTime.fromMillisecondsSinceEpoch(list.first['add_date']))
: PlayHistory(episodeBrief.title, episodeBrief.enclosureUrl, 0, 0);

View File

@ -606,34 +606,11 @@ class _PodcastDetailState extends State<PodcastDetail> {
color: Colors.transparent,
clipBehavior: Clip.hardEdge,
borderRadius: BorderRadius.circular(100),
child: IconButton(
padding: EdgeInsets.zero,
onPressed: () {
if (_layout == Layout.three) {
setState(() {
_layout = Layout.one;
});
} else if (_layout == Layout.two) {
setState(() {
_layout = Layout.three;
});
} else {
setState(() {
_layout = Layout.two;
});
}
},
icon: _layout == Layout.three
? IconPainter(
LayoutPainter(0, context.textColor),
)
: _layout == Layout.two
? IconPainter(
LayoutPainter(1, context.textColor),
)
: IconPainter(
LayoutPainter(4, context.textColor),
),
child: LayoutButton(
layout: _layout,
onPressed: (layout) => setState(() {
_layout = layout;
}),
),
),
SizedBox(width: 10)

View File

@ -1,15 +1,23 @@
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'extension_helper.dart';
enum SlideDirection { up, down }
class AudioPanel extends StatefulWidget {
final Widget miniPanel;
final Widget expandedPanel;
final Widget optionPanel;
final Widget cover;
final double minHeight;
final double maxHeight;
AudioPanel(
{@required this.miniPanel,
@required this.expandedPanel,
this.optionPanel,
this.cover,
this.minHeight = 60,
this.maxHeight = 300,
Key key})
@ -26,11 +34,11 @@ class _AudioPanelState extends State<AudioPanel> with TickerProviderStateMixin {
AnimationController _slowController;
Animation _animation;
SlideDirection _slideDirection;
double _expandHeight;
@override
void initState() {
initSize = widget.minHeight;
_slideDirection = SlideDirection.up;
_controller =
AnimationController(vsync: this, duration: Duration(milliseconds: 50))
..addListener(() {
@ -44,7 +52,9 @@ class _AudioPanelState extends State<AudioPanel> with TickerProviderStateMixin {
_animation =
Tween<double>(begin: 0, end: initSize).animate(_slowController);
_controller.forward();
_slideDirection = SlideDirection.up;
super.initState();
_expandHeight = 600;
}
@override
@ -54,6 +64,16 @@ class _AudioPanelState extends State<AudioPanel> with TickerProviderStateMixin {
super.dispose();
}
double _getHeight() {
if (_animation.value >= _expandHeight) {
return _expandHeight;
} else if (_animation.value <= widget.minHeight) {
return widget.minHeight;
} else {
return _animation.value;
}
}
@override
Widget build(BuildContext context) {
return Stack(children: <Widget>[
@ -65,7 +85,8 @@ class _AudioPanelState extends State<AudioPanel> with TickerProviderStateMixin {
child: Container(
color: Theme.of(context)
.scaffoldBackgroundColor
.withOpacity(0.8),
.withOpacity(0.9 *
math.min(_animation.value / widget.maxHeight, 1)),
),
),
)
@ -78,11 +99,7 @@ class _AudioPanelState extends State<AudioPanel> with TickerProviderStateMixin {
onVerticalDragUpdate: _update,
onVerticalDragEnd: (event) => _end(),
child: Container(
height: (_animation.value >= widget.maxHeight)
? widget.maxHeight
: (_animation.value <= widget.minHeight)
? widget.minHeight
: _animation.value,
height: _getHeight(),
child: _animation.value < widget.minHeight + 30
? Container(
color: Theme.of(context).primaryColor,
@ -97,7 +114,7 @@ class _AudioPanelState extends State<AudioPanel> with TickerProviderStateMixin {
)
: Container(
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
color: context.primaryColor,
boxShadow: [
BoxShadow(
offset: Offset(0, -0.5),
@ -117,7 +134,8 @@ class _AudioPanelState extends State<AudioPanel> with TickerProviderStateMixin {
(widget.maxHeight - widget.minHeight - 50)
: 1,
child: Container(
height: widget.maxHeight,
height: math.max(widget.maxHeight,
math.min(_animation.value, _expandHeight)),
child: widget.expandedPanel,
),
),
@ -160,12 +178,21 @@ class _AudioPanelState extends State<AudioPanel> with TickerProviderStateMixin {
_end() {
if (_slideDirection == SlideDirection.up) {
if (_move > 20) {
setState(() {
_animation =
Tween<double>(begin: _animation.value, end: widget.maxHeight)
.animate(_slowController);
initSize = widget.maxHeight;
});
if (_animation.value > widget.maxHeight + 20) {
setState(() {
_animation =
Tween<double>(begin: _animation.value, end: _expandHeight)
.animate(_slowController);
initSize = _expandHeight;
});
} else {
setState(() {
_animation =
Tween<double>(begin: _animation.value, end: widget.maxHeight)
.animate(_slowController);
initSize = widget.maxHeight;
});
}
_slowController.forward();
} else {
setState(() {
@ -178,26 +205,44 @@ class _AudioPanelState extends State<AudioPanel> with TickerProviderStateMixin {
}
} else if (_slideDirection == SlideDirection.down) {
if (_move > -50) {
setState(() {
_animation =
Tween<double>(begin: _animation.value, end: widget.maxHeight)
.animate(_slowController);
initSize = widget.maxHeight;
});
if (_animation.value > widget.maxHeight) {
setState(() {
_animation =
Tween<double>(begin: _animation.value, end: _expandHeight)
.animate(_slowController);
initSize = _expandHeight;
});
} else {
setState(() {
_animation =
Tween<double>(begin: _animation.value, end: widget.maxHeight)
.animate(_slowController);
initSize = widget.maxHeight;
});
}
_slowController.forward();
} else {
setState(() {
_animation =
Tween<double>(begin: _animation.value, end: widget.minHeight)
.animate(_controller);
initSize = widget.minHeight;
});
if (_animation.value > widget.maxHeight) {
setState(() {
_animation =
Tween<double>(begin: _animation.value, end: widget.maxHeight)
.animate(_slowController);
initSize = widget.maxHeight;
});
} else {
setState(() {
_animation =
Tween<double>(begin: _animation.value, end: widget.minHeight)
.animate(_controller);
initSize = widget.minHeight;
});
}
_controller.forward();
}
}
if (_animation.value >= widget.maxHeight) {
if (_animation.value >= _expandHeight) {
setState(() {
initSize = widget.maxHeight;
initSize = _expandHeight;
});
} else if (_animation.value < widget.minHeight) {
setState(() {