1
0
mirror of https://github.com/stonega/tsacdop synced 2025-03-01 17:58:00 +01:00

Redesign player widget.

This commit is contained in:
stonegate 2020-07-29 20:06:49 +08:00
parent 1642c4b839
commit 814628ce3d
7 changed files with 1420 additions and 1688 deletions

View File

@ -2,20 +2,21 @@ import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:flutter_html/flutter_html.dart'; import 'package:flutter_html/flutter_html.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:intl/intl.dart';
import 'package:tuple/tuple.dart';
import 'package:flutter_linkify/flutter_linkify.dart'; import 'package:flutter_linkify/flutter_linkify.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:tuple/tuple.dart';
import 'package:url_launcher/url_launcher.dart';
import '../home/audioplayer.dart'; import '../home/audioplayer.dart';
import '../local_storage/sqflite_localpodcast.dart'; import '../local_storage/sqflite_localpodcast.dart';
import '../state/audio_state.dart'; import '../state/audio_state.dart';
import '../type/episodebrief.dart'; import '../type/episodebrief.dart';
import '../type/play_histroy.dart'; import '../type/play_histroy.dart';
import '../util/audiopanel.dart';
import '../util/custom_widget.dart'; import '../util/custom_widget.dart';
import '../util/extension_helper.dart'; import '../util/extension_helper.dart';
import 'episode_download.dart'; import 'episode_download.dart';
@ -34,6 +35,7 @@ class EpisodeDetail extends StatefulWidget {
class _EpisodeDetailState extends State<EpisodeDetail> { class _EpisodeDetailState extends State<EpisodeDetail> {
final textstyle = TextStyle(fontSize: 15.0, color: Colors.black); final textstyle = TextStyle(fontSize: 15.0, color: Colors.black);
final GlobalKey<AudioPanelState> _playerKey = GlobalKey<AudioPanelState>();
double downloadProgress; double downloadProgress;
/// Show page title. /// Show page title.
@ -122,245 +124,258 @@ class _EpisodeDetailState extends State<EpisodeDetail> {
systemNavigationBarIconBrightness: systemNavigationBarIconBrightness:
Theme.of(context).accentColorBrightness, Theme.of(context).accentColorBrightness,
), ),
child: Scaffold( child: WillPopScope(
backgroundColor: Theme.of(context).primaryColor, onWillPop: () async {
appBar: AppBar( if (_playerKey.currentState != null &&
title: _showTitle _playerKey.currentState.initSize > 100) {
? Text( _playerKey.currentState.backToMini();
widget.episodeItem.title, return false;
maxLines: 1, } else {
overflow: TextOverflow.ellipsis, return true;
) }
: Center(), },
elevation: _showTitle ? 1 : 0, child: Scaffold(
actions: [ backgroundColor: Theme.of(context).primaryColor,
PopupMenuButton( appBar: AppBar(
shape: RoundedRectangleBorder( title: _showTitle
borderRadius: BorderRadius.all(Radius.circular(10))), ? Text(
elevation: 1, widget.episodeItem.title,
tooltip: s.menu, maxLines: 1,
itemBuilder: (context) => [ overflow: TextOverflow.ellipsis,
PopupMenuItem( )
value: 0, : Center(),
child: Container( elevation: _showTitle ? 1 : 0,
padding: EdgeInsets.only(left: 10), actions: [
child: Row( PopupMenuButton(
crossAxisAlignment: CrossAxisAlignment.center, shape: RoundedRectangleBorder(
children: <Widget>[ borderRadius: BorderRadius.all(Radius.circular(10))),
SizedBox( elevation: 1,
width: 25, tooltip: s.menu,
height: 25, itemBuilder: (context) => [
child: CustomPaint( PopupMenuItem(
painter: ListenedAllPainter( value: 0,
context.textTheme.bodyText1.color, child: Container(
stroke: 2)), padding: EdgeInsets.only(left: 10),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 5.0),
),
Text(
s.markListened,
),
],
),
),
),
],
onSelected: (value) async {
switch (value) {
case 0:
await _markListened(widget.episodeItem);
if (mounted) setState(() {});
Fluttertoast.showToast(
msg: s.markListened,
gravity: ToastGravity.BOTTOM,
);
break;
default:
break;
}
},
),
],
),
body: Stack(
children: <Widget>[
Container(
color: Theme.of(context).primaryColor,
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
controller: _controller,
child: Column(
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 20.0),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
widget.episodeItem.title,
textAlign: TextAlign.left,
style: Theme.of(context).textTheme.headline5,
),
),
),
Container(
alignment: Alignment.centerLeft,
padding: EdgeInsets.only(
left: 20.0, right: 20, top: 10, bottom: 10),
child: Text(
s.published(DateFormat.yMMMd().format(
DateTime.fromMillisecondsSinceEpoch(
widget.episodeItem.pubDate))),
style:
TextStyle(color: Theme.of(context).accentColor)),
),
Padding(
padding: EdgeInsets.only(
left: 20.0, right: 20, top: 10, bottom: 10),
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[ children: <Widget>[
if (widget.episodeItem.explicit == 1) SizedBox(
Container( width: 25,
decoration: BoxDecoration( height: 25,
color: Colors.red[800], child: CustomPaint(
shape: BoxShape.circle), painter: ListenedAllPainter(
height: 25.0, context.textTheme.bodyText1.color,
width: 25.0, stroke: 2)),
margin: EdgeInsets.only(right: 10.0), ),
alignment: Alignment.center, Padding(
child: Text('E', padding: EdgeInsets.symmetric(horizontal: 5.0),
style: TextStyle(color: Colors.white))), ),
if (widget.episodeItem.duration != 0) Text(
Container( s.markListened,
decoration: BoxDecoration( ),
color: Colors.cyan[300],
borderRadius:
BorderRadius.all(Radius.circular(15.0))),
height: 25.0,
margin: EdgeInsets.only(right: 10.0),
padding: EdgeInsets.symmetric(horizontal: 10.0),
alignment: Alignment.center,
child: Text(
s.minsCount(
widget.episodeItem.duration ~/ 60),
style: textstyle),
),
if (widget.episodeItem.enclosureLength != null &&
widget.episodeItem.enclosureLength != 0)
Container(
decoration: BoxDecoration(
color: Colors.lightBlue[300],
borderRadius:
BorderRadius.all(Radius.circular(15.0))),
height: 25.0,
margin: EdgeInsets.only(right: 10.0),
padding: EdgeInsets.symmetric(horizontal: 10.0),
alignment: Alignment.center,
child: Text(
'${(widget.episodeItem.enclosureLength) ~/ 1000000}MB',
style: textstyle),
),
], ],
), ),
), ),
_loaddes ),
? (_description.contains('<')) ],
? Html( onSelected: (value) async {
padding: EdgeInsets.only( switch (value) {
left: 20.0, right: 20, bottom: 50), case 0:
defaultTextStyle: await _markListened(widget.episodeItem);
// GoogleFonts.libreBaskerville( if (mounted) setState(() {});
GoogleFonts.martel( Fluttertoast.showToast(
textStyle: TextStyle( msg: s.markListened,
height: 1.8, gravity: ToastGravity.BOTTOM,
);
break;
default:
break;
}
},
),
],
),
body: Stack(
children: <Widget>[
Container(
color: Theme.of(context).primaryColor,
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
controller: _controller,
child: Column(
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 20.0),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
widget.episodeItem.title,
textAlign: TextAlign.left,
style: Theme.of(context).textTheme.headline5,
),
),
),
Container(
alignment: Alignment.centerLeft,
padding: EdgeInsets.only(
left: 20.0, right: 20, top: 10, bottom: 10),
child: Text(
s.published(DateFormat.yMMMd().format(
DateTime.fromMillisecondsSinceEpoch(
widget.episodeItem.pubDate))),
style: TextStyle(
color: Theme.of(context).accentColor)),
),
Padding(
padding: EdgeInsets.only(
left: 20.0, right: 20, top: 10, bottom: 10),
child: Row(
children: <Widget>[
if (widget.episodeItem.explicit == 1)
Container(
decoration: BoxDecoration(
color: Colors.red[800],
shape: BoxShape.circle),
height: 25.0,
width: 25.0,
margin: EdgeInsets.only(right: 10.0),
alignment: Alignment.center,
child: Text('E',
style: TextStyle(color: Colors.white))),
if (widget.episodeItem.duration != 0)
Container(
decoration: BoxDecoration(
color: Colors.cyan[300],
borderRadius: BorderRadius.all(
Radius.circular(15.0))),
height: 25.0,
margin: EdgeInsets.only(right: 10.0),
padding: EdgeInsets.symmetric(horizontal: 10.0),
alignment: Alignment.center,
child: Text(
s.minsCount(
widget.episodeItem.duration ~/ 60),
style: textstyle),
),
if (widget.episodeItem.enclosureLength != null &&
widget.episodeItem.enclosureLength != 0)
Container(
decoration: BoxDecoration(
color: Colors.lightBlue[300],
borderRadius: BorderRadius.all(
Radius.circular(15.0))),
height: 25.0,
margin: EdgeInsets.only(right: 10.0),
padding: EdgeInsets.symmetric(horizontal: 10.0),
alignment: Alignment.center,
child: Text(
'${(widget.episodeItem.enclosureLength) ~/ 1000000}MB',
style: textstyle),
),
],
),
),
_loaddes
? (_description.contains('<'))
? Html(
padding: EdgeInsets.only(
left: 20.0, right: 20, bottom: 50),
defaultTextStyle:
// GoogleFonts.libreBaskerville(
GoogleFonts.martel(
textStyle: TextStyle(
height: 1.8,
),
), ),
), data: _description,
data: _description, linkStyle: TextStyle(
linkStyle: TextStyle( color: context.accentColor,
color: context.accentColor, // decoration: TextDecoration.underline,
// decoration: TextDecoration.underline, textBaseline: TextBaseline.ideographic),
textBaseline: TextBaseline.ideographic), onLinkTap: (url) {
onLinkTap: (url) { _launchUrl(url);
_launchUrl(url); },
}, useRichText: true,
useRichText: true, )
) : _description.length > 0
: _description.length > 0 ? Container(
? Container( padding: EdgeInsets.only(
padding: EdgeInsets.only( left: 20.0,
left: 20.0, right: 20.0, bottom: 50.0), right: 20.0,
alignment: Alignment.topLeft, bottom: 50.0),
child: SelectableLinkify( alignment: Alignment.topLeft,
onOpen: (link) { child: SelectableLinkify(
_launchUrl(link.url); onOpen: (link) {
}, _launchUrl(link.url);
text: _description, },
style: GoogleFonts.martel( text: _description,
textStyle: TextStyle( style: GoogleFonts.martel(
height: 1.8, textStyle: TextStyle(
height: 1.8,
),
),
linkStyle: TextStyle(
color: Theme.of(context).accentColor,
// decoration:
// TextDecoration.underline,
), ),
), ),
linkStyle: TextStyle( )
color: Theme.of(context).accentColor, : Container(
// decoration: height: context.width,
// TextDecoration.underline, alignment: Alignment.center,
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Image(
image: AssetImage(
'assets/shownote.png'),
height: 100.0,
),
Padding(padding: EdgeInsets.all(5.0)),
Text(s.noShownote,
textAlign: TextAlign.center,
style: TextStyle(
color: context.textColor
.withOpacity(0.5))),
],
), ),
), )
) : Center(),
: Container( Selector<AudioPlayerNotifier, bool>(
height: context.width, selector: (_, audio) => audio.playerRunning,
alignment: Alignment.center, builder: (_, data, __) {
child: Column( return SizedBox(
mainAxisAlignment: height: data ? 70.0 : 0,
MainAxisAlignment.center, );
children: <Widget>[ }),
Image( ],
image: ),
AssetImage('assets/shownote.png'),
height: 100.0,
),
Padding(padding: EdgeInsets.all(5.0)),
Text(s.noShownote,
textAlign: TextAlign.center,
style: TextStyle(
color: context.textColor
.withOpacity(0.5))),
],
),
)
: Center(),
Selector<AudioPlayerNotifier, bool>(
selector: (_, audio) => audio.playerRunning,
builder: (_, data, __) {
return Padding(
padding: EdgeInsets.only(bottom: data ? 60.0 : 0),
);
}),
],
), ),
), ),
), Selector<AudioPlayerNotifier, bool>(
Selector<AudioPlayerNotifier, bool>( selector: (_, audio) => audio.playerRunning,
selector: (_, audio) => audio.playerRunning, builder: (_, data, __) {
builder: (_, data, __) { return Container(
return Container( alignment: Alignment.bottomCenter,
alignment: Alignment.bottomCenter, padding: EdgeInsets.only(bottom: data ? 70.0 : 0),
padding: EdgeInsets.only(bottom: data ? 60.0 : 0), child: AnimatedContainer(
child: AnimatedContainer( duration: Duration(milliseconds: 400),
duration: Duration(milliseconds: 400), height: !_showMenu ? 50 : 0,
height: !_showMenu ? 50 : 0, child: SingleChildScrollView(
child: SingleChildScrollView( scrollDirection: Axis.vertical,
scrollDirection: Axis.vertical, child: MenuBar(
child: MenuBar( episodeItem: widget.episodeItem,
episodeItem: widget.episodeItem, heroTag: widget.heroTag,
heroTag: widget.heroTag, hide: widget.hide),
hide: widget.hide), ),
), ),
), );
); }),
}), Container(child: PlayerWidget(playerKey: _playerKey)),
Container(child: PlayerWidget()), ],
], ),
), ),
), ),
); );

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,7 @@ import '../state/podcast_group.dart';
import '../state/setting_state.dart'; import '../state/setting_state.dart';
import '../type/episodebrief.dart'; import '../type/episodebrief.dart';
import '../type/playlist.dart'; import '../type/playlist.dart';
import '../util/audiopanel.dart';
import '../util/custom_widget.dart'; import '../util/custom_widget.dart';
import '../util/episodegrid.dart'; import '../util/episodegrid.dart';
import '../util/extension_helper.dart'; import '../util/extension_helper.dart';
@ -44,6 +45,7 @@ class Home extends StatefulWidget {
class _HomeState extends State<Home> with SingleTickerProviderStateMixin { class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
final GlobalKey<AudioPanelState> _playerKey = GlobalKey<AudioPanelState>();
TabController _controller; TabController _controller;
Decoration _getIndicator(BuildContext context) { Decoration _getIndicator(BuildContext context) {
return UnderlineTabIndicator( return UnderlineTabIndicator(
@ -102,10 +104,14 @@ class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
systemNavigationBarColor: Theme.of(context).primaryColor, systemNavigationBarColor: Theme.of(context).primaryColor,
), ),
child: Scaffold( child: Scaffold(
key: _scaffoldKey, // key: _scaffoldKey,
body: WillPopScope( body: WillPopScope(
onWillPop: () async { onWillPop: () async {
if (Platform.isAndroid) { if (_playerKey.currentState != null &&
_playerKey.currentState.initSize > 100) {
_playerKey.currentState.backToMini();
return false;
} else if (Platform.isAndroid) {
_androidAppRetain.invokeMethod('sendToBackground'); _androidAppRetain.invokeMethod('sendToBackground');
return false; return false;
} else { } else {
@ -445,7 +451,7 @@ class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
}), }),
], ],
), ),
Container(child: PlayerWidget()), Container(child: PlayerWidget(playerKey: _playerKey)),
], ],
), ),
), ),

View File

@ -21,6 +21,7 @@ import '../type/episodebrief.dart';
import '../type/fireside_data.dart'; import '../type/fireside_data.dart';
import '../type/play_histroy.dart'; import '../type/play_histroy.dart';
import '../type/podcastlocal.dart'; import '../type/podcastlocal.dart';
import '../util/audiopanel.dart';
import '../util/custom_widget.dart'; import '../util/custom_widget.dart';
import '../util/episodegrid.dart'; import '../util/episodegrid.dart';
import '../util/extension_helper.dart'; import '../util/extension_helper.dart';
@ -39,6 +40,8 @@ class _PodcastDetailState extends State<PodcastDetail> {
final GlobalKey<RefreshIndicatorState> _refreshIndicatorKey = final GlobalKey<RefreshIndicatorState> _refreshIndicatorKey =
GlobalKey<RefreshIndicatorState>(); GlobalKey<RefreshIndicatorState>();
final GlobalKey<AudioPanelState> _playerKey = GlobalKey<AudioPanelState>();
/// Fireside background if hosted on fireside. /// Fireside background if hosted on fireside.
String _backgroundImage; String _backgroundImage;
@ -628,197 +631,218 @@ class _PodcastDetailState extends State<PodcastDetail> {
systemNavigationBarColor: Theme.of(context).primaryColor, systemNavigationBarColor: Theme.of(context).primaryColor,
systemNavigationBarIconBrightness: systemNavigationBarIconBrightness:
Theme.of(context).accentColorBrightness, Theme.of(context).accentColorBrightness,
//statusBarColor: _color,
), ),
child: Scaffold( child: WillPopScope(
body: SafeArea( onWillPop: () {
top: false, if (_playerKey.currentState != null &&
minimum: widget.hide ? EdgeInsets.only(bottom: 50) : EdgeInsets.zero, _playerKey.currentState.initSize > 100) {
child: RefreshIndicator( _playerKey.currentState.backToMini();
key: _refreshIndicatorKey, return Future.value(false);
color: Theme.of(context).accentColor, } else {
onRefresh: () async { return Future.value(true);
await _updateRssItem(context, widget.podcastLocal); }
// audio.addNewEpisode(widget.podcastLocal.id); },
}, child: Scaffold(
child: Stack( body: SafeArea(
children: <Widget>[ top: false,
Column( minimum:
mainAxisAlignment: MainAxisAlignment.start, widget.hide ? EdgeInsets.only(bottom: 50) : EdgeInsets.zero,
mainAxisSize: MainAxisSize.min, child: RefreshIndicator(
crossAxisAlignment: CrossAxisAlignment.start, key: _refreshIndicatorKey,
children: <Widget>[ color: Theme.of(context).accentColor,
Expanded( onRefresh: () async {
child: FutureBuilder<List<EpisodeBrief>>( await _updateRssItem(context, widget.podcastLocal);
future: _getRssItem(widget.podcastLocal, // audio.addNewEpisode(widget.podcastLocal.id);
count: _top, },
reverse: _reverse, child: Stack(
filter: _filter, children: <Widget>[
query: _query), Column(
builder: (context, snapshot) { mainAxisAlignment: MainAxisAlignment.start,
if (snapshot.hasError) print(snapshot.error); mainAxisSize: MainAxisSize.min,
return (snapshot.hasData) crossAxisAlignment: CrossAxisAlignment.start,
? CustomScrollView( children: <Widget>[
controller: _controller Expanded(
..addListener(() async { child: FutureBuilder<List<EpisodeBrief>>(
if (_controller.offset == future: _getRssItem(widget.podcastLocal,
_controller count: _top,
.position.maxScrollExtent && reverse: _reverse,
snapshot.data.length == _top) { filter: _filter,
if (mounted) { query: _query),
setState(() => _loadMore = true); builder: (context, snapshot) {
if (snapshot.hasError) print(snapshot.error);
return (snapshot.hasData)
? CustomScrollView(
controller: _controller
..addListener(() async {
if (_controller.offset ==
_controller
.position.maxScrollExtent &&
snapshot.data.length == _top) {
if (mounted) {
setState(() => _loadMore = true);
}
await Future.delayed(
Duration(seconds: 3));
if (mounted) {
setState(() {
_top = _top + 36;
_loadMore = false;
});
}
} }
await Future.delayed( if (_controller.offset > 0 &&
Duration(seconds: 3)); mounted &&
if (mounted) { !_scroll) {
setState(() { setState(() => _scroll = true);
_top = _top + 36;
_loadMore = false;
});
} }
}
if (_controller.offset > 0 &&
mounted &&
!_scroll) {
setState(() => _scroll = true);
}
}),
physics:
const AlwaysScrollableScrollPhysics(),
slivers: <Widget>[
SliverAppBar(
brightness: Brightness.dark,
actions: <Widget>[_rightTopMenu(context)],
elevation: 0,
iconTheme: IconThemeData(
color: Colors.white,
),
expandedHeight: 150 + context.paddingTop,
backgroundColor: _color,
floating: true,
pinned: true,
flexibleSpace: LayoutBuilder(
builder: (context, constraints) {
_topHeight = constraints.biggest.height;
return FlexibleSpaceBar(
background: Stack(
children: <Widget>[
Container(
margin: EdgeInsets.only(
top: 120 +
context.paddingTop),
padding: EdgeInsets.only(
left: 80, right: 120),
color: Colors.white10,
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
mainAxisSize:
MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Text(
widget.podcastLocal
.author ??
'',
maxLines: 1,
overflow: TextOverflow
.ellipsis,
style: TextStyle(
color:
Colors.white)),
if (widget.podcastLocal
.provider.isNotEmpty)
Text(
s.hostedOn(widget
.podcastLocal
.provider),
maxLines: 1,
style: TextStyle(
color:
Colors.white),
),
],
),
),
Container(
alignment:
Alignment.centerRight,
padding:
EdgeInsets.only(right: 10),
child: SizedBox(
height: 120,
child: Image.file(File(
"${widget.podcastLocal.imagePath}")),
),
),
Container(
alignment: Alignment.center,
child: podcastInfo(context),
),
],
),
title: _topHeight <
70 + context.paddingTop
? Text(widget.podcastLocal.title,
maxLines: 1,
overflow:
TextOverflow.ellipsis,
style: TextStyle(
color: Colors.white))
: Center(),
);
}), }),
), physics:
SliverToBoxAdapter( const AlwaysScrollableScrollPhysics(),
child: hostsList(context, _hosts), slivers: <Widget>[
), SliverAppBar(
SliverToBoxAdapter( brightness: Brightness.dark,
child: _actionBar(context)), actions: <Widget>[
EpisodeGrid( _rightTopMenu(context)
episodes: snapshot.data, ],
showFavorite: true, elevation: 0,
showNumber: _filter == Filter.all && iconTheme: IconThemeData(
!_hideListened color: Colors.white,
? true ),
: false, expandedHeight:
layout: _layout, 150 + context.paddingTop,
reverse: _reverse, backgroundColor: _color,
episodeCount: _episodeCount, floating: true,
initNum: _scroll ? 0 : 12, pinned: true,
), flexibleSpace: LayoutBuilder(
SliverList( builder: (context, constraints) {
delegate: SliverChildBuilderDelegate( _topHeight =
(context, index) { constraints.biggest.height;
return _loadMore return FlexibleSpaceBar(
? Container( background: Stack(
height: 2, children: <Widget>[
child: Container(
LinearProgressIndicator()) margin: EdgeInsets.only(
: Center(); top: 120 +
}, context.paddingTop),
childCount: 1, padding: EdgeInsets.only(
left: 80, right: 120),
color: Colors.white10,
alignment:
Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
mainAxisSize:
MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment
.start,
children: <Widget>[
Text(
widget.podcastLocal
.author ??
'',
maxLines: 1,
overflow: TextOverflow
.ellipsis,
style: TextStyle(
color: Colors
.white)),
if (widget.podcastLocal
.provider.isNotEmpty)
Text(
s.hostedOn(widget
.podcastLocal
.provider),
maxLines: 1,
style: TextStyle(
color:
Colors.white),
),
],
),
),
Container(
alignment:
Alignment.centerRight,
padding: EdgeInsets.only(
right: 10),
child: SizedBox(
height: 120,
child: Image.file(File(
"${widget.podcastLocal.imagePath}")),
),
),
Container(
alignment: Alignment.center,
child: podcastInfo(context),
),
],
),
title: _topHeight <
70 + context.paddingTop
? Text(
widget.podcastLocal.title,
maxLines: 1,
overflow:
TextOverflow.ellipsis,
style: TextStyle(
color: Colors.white))
: Center(),
);
}),
), ),
), SliverToBoxAdapter(
], child: hostsList(context, _hosts),
) ),
: Center(child: CircularProgressIndicator()); SliverToBoxAdapter(
}, child: _actionBar(context)),
EpisodeGrid(
episodes: snapshot.data,
showFavorite: true,
showNumber: _filter == Filter.all &&
!_hideListened
? true
: false,
layout: _layout,
reverse: _reverse,
episodeCount: _episodeCount,
initNum: _scroll ? 0 : 12,
),
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return _loadMore
? Container(
height: 2,
child:
LinearProgressIndicator())
: Center();
},
childCount: 1,
),
),
],
)
: Center(child: CircularProgressIndicator());
},
),
), ),
), Selector<AudioPlayerNotifier, bool>(
Selector<AudioPlayerNotifier, bool>( selector: (_, audio) => audio.playerRunning,
selector: (_, audio) => audio.playerRunning, builder: (_, data, __) {
builder: (_, data, __) { return SizedBox(
return Padding( height: data ? 70.0 : 0,
padding: EdgeInsets.only(bottom: data ? 60.0 : 0), );
); }),
}), ],
], ),
), Container(
Container(child: PlayerWidget()), child: PlayerWidget(
], playerKey: _playerKey,
)),
],
),
), ),
), ),
), ),

View File

@ -10,23 +10,22 @@ class AudioPanel extends StatefulWidget {
final Widget miniPanel; final Widget miniPanel;
final Widget expandedPanel; final Widget expandedPanel;
final Widget optionPanel; final Widget optionPanel;
final Widget cover;
final double minHeight; final double minHeight;
final double maxHeight; final double maxHeight;
AudioPanel( AudioPanel(
{@required this.miniPanel, {@required this.miniPanel,
@required this.expandedPanel, @required this.expandedPanel,
this.optionPanel, this.optionPanel,
this.cover, this.minHeight = 70,
this.minHeight = 60,
this.maxHeight = 300, this.maxHeight = 300,
Key key}) Key key})
: super(key: key); : super(key: key);
@override @override
_AudioPanelState createState() => _AudioPanelState(); AudioPanelState createState() => AudioPanelState();
} }
class _AudioPanelState extends State<AudioPanel> with TickerProviderStateMixin { class AudioPanelState extends State<AudioPanel> with TickerProviderStateMixin {
double initSize; double initSize;
double _startdy; double _startdy;
double _move = 0; double _move = 0;
@ -81,7 +80,7 @@ class _AudioPanelState extends State<AudioPanel> with TickerProviderStateMixin {
child: (_animation.value > widget.minHeight + 30) child: (_animation.value > widget.minHeight + 30)
? Positioned.fill( ? Positioned.fill(
child: GestureDetector( child: GestureDetector(
onTap: _backToMini, onTap: backToMini,
child: Container( child: Container(
color: Theme.of(context) color: Theme.of(context)
.scaffoldBackgroundColor .scaffoldBackgroundColor
@ -92,7 +91,7 @@ class _AudioPanelState extends State<AudioPanel> with TickerProviderStateMixin {
) )
: Center(), : Center(),
), ),
Container( Align(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: GestureDetector( child: GestureDetector(
onVerticalDragStart: _start, onVerticalDragStart: _start,
@ -107,9 +106,7 @@ class _AudioPanelState extends State<AudioPanel> with TickerProviderStateMixin {
opacity: _animation.value > widget.minHeight opacity: _animation.value > widget.minHeight
? (widget.minHeight + 30 - _animation.value) / 40 ? (widget.minHeight + 30 - _animation.value) / 40
: 1, : 1,
child: Container( child: widget.miniPanel,
child: widget.miniPanel,
),
), ),
) )
: Container( : Container(
@ -117,12 +114,11 @@ class _AudioPanelState extends State<AudioPanel> with TickerProviderStateMixin {
color: context.primaryColor, color: context.primaryColor,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
offset: Offset(0, -0.5), offset: Offset(0, -1),
blurRadius: 1, blurRadius: 1,
color: color: context.brightness == Brightness.light
Theme.of(context).brightness == Brightness.light ? Colors.grey[400].withOpacity(0.5)
? Colors.grey[400].withOpacity(0.5) : Colors.grey[800],
: Colors.grey[800],
), ),
], ],
), ),
@ -133,7 +129,7 @@ class _AudioPanelState extends State<AudioPanel> with TickerProviderStateMixin {
? (_animation.value - widget.minHeight) / ? (_animation.value - widget.minHeight) /
(widget.maxHeight - widget.minHeight - 50) (widget.maxHeight - widget.minHeight - 50)
: 1, : 1,
child: Container( child: SizedBox(
height: math.max(widget.maxHeight, height: math.max(widget.maxHeight,
math.min(_animation.value, _expandHeight)), math.min(_animation.value, _expandHeight)),
child: widget.expandedPanel, child: widget.expandedPanel,
@ -147,7 +143,7 @@ class _AudioPanelState extends State<AudioPanel> with TickerProviderStateMixin {
]); ]);
} }
_backToMini() { backToMini() {
setState(() { setState(() {
_animation = Tween<double>(begin: initSize, end: widget.minHeight) _animation = Tween<double>(begin: initSize, end: widget.minHeight)
.animate(_slowController); .animate(_slowController);
@ -156,6 +152,15 @@ class _AudioPanelState extends State<AudioPanel> with TickerProviderStateMixin {
_slowController.forward(); _slowController.forward();
} }
scrollToTop() {
setState(() {
_animation = Tween<double>(begin: initSize, end: _expandHeight)
.animate(_slowController);
initSize = _expandHeight;
});
_slowController.forward();
}
_start(DragStartDetails event) { _start(DragStartDetails event) {
setState(() { setState(() {
_startdy = event.localPosition.dy; _startdy = event.localPosition.dy;
@ -175,7 +180,7 @@ class _AudioPanelState extends State<AudioPanel> with TickerProviderStateMixin {
_controller.forward(); _controller.forward();
} }
_end() { _end() async {
if (_slideDirection == SlideDirection.up) { if (_slideDirection == SlideDirection.up) {
if (_move > 20) { if (_move > 20) {
if (_animation.value > widget.maxHeight + 20) { if (_animation.value > widget.maxHeight + 20) {
@ -185,15 +190,16 @@ class _AudioPanelState extends State<AudioPanel> with TickerProviderStateMixin {
.animate(_slowController); .animate(_slowController);
initSize = _expandHeight; initSize = _expandHeight;
}); });
_slowController.forward();
} else { } else {
setState(() { setState(() {
_animation = _animation =
Tween<double>(begin: _animation.value, end: widget.maxHeight) Tween<double>(begin: widget.maxHeight, end: widget.maxHeight)
.animate(_slowController); .animate(_controller);
initSize = widget.maxHeight; initSize = widget.maxHeight;
}); });
_controller.forward();
} }
_slowController.forward();
} else { } else {
setState(() { setState(() {
_animation = _animation =
@ -251,3 +257,64 @@ class _AudioPanelState extends State<AudioPanel> with TickerProviderStateMixin {
} }
} }
} }
class _AudioPanelRoute extends StatefulWidget {
_AudioPanelRoute({this.expandPanel, this.height, Key key}) : super(key: key);
final Widget expandPanel;
final double height;
@override
__AudioPanelRouteState createState() => __AudioPanelRouteState();
}
class __AudioPanelRouteState extends State<_AudioPanelRoute> {
@override
Widget build(BuildContext context) {
return MediaQuery.removePadding(
context: context,
removeTop: true,
child: Scaffold(
body: Stack(children: <Widget>[
Container(
child: Positioned.fill(
child: GestureDetector(
onTap: () => Navigator.pop(context),
// child:
// Container(
// color: Theme.of(context)
// .scaffoldBackgroundColor
// .withOpacity(0.8),
//
//),
),
),
),
Align(
alignment: Alignment.bottomCenter,
child: Container(
height: widget.height,
decoration: BoxDecoration(
color: context.primaryColor,
boxShadow: [
BoxShadow(
offset: Offset(0, -1),
blurRadius: 1,
color: context.brightness == Brightness.light
? Colors.grey[400].withOpacity(0.5)
: Colors.grey[800],
),
],
),
child: SingleChildScrollView(
physics: const NeverScrollableScrollPhysics(),
child: SizedBox(
height: 300,
child: widget.expandPanel,
),
),
),
),
]),
),
);
}
}

View File

@ -1000,3 +1000,84 @@ class LayoutButton extends StatelessWidget {
); );
} }
} }
/// Remove scroll view overlay effect.
class NoGrowBehavior extends ScrollBehavior {
@override
Widget buildViewportChrome(
BuildContext context, Widget child, AxisDirection axisDirection) {
return child;
}
}
class Meteor extends CustomPainter {
Paint _paint;
Meteor() {
_paint = Paint()
..color = Colors.white
..strokeWidth = 2.0
..strokeCap = StrokeCap.round;
}
@override
void paint(Canvas canvas, Size size) {
canvas.drawLine(Offset(0, 0), Offset(size.width, size.height), _paint);
}
@override
bool shouldRepaint(Meteor oldDelegate) {
return false;
}
}
/// Used in sleep mode widget.
class MeteorLoader extends StatefulWidget {
@override
_MeteorLoaderState createState() => _MeteorLoaderState();
}
class _MeteorLoaderState extends State<MeteorLoader>
with SingleTickerProviderStateMixin {
double _fraction = 0.0;
double _move = 0.0;
Animation animation;
AnimationController controller;
@override
void initState() {
super.initState();
controller =
AnimationController(vsync: this, duration: Duration(milliseconds: 500));
animation = Tween(begin: 0.0, end: 1.0).animate(controller)
..addListener(() {
if (mounted) {
setState(() {
_move = animation.value;
if (animation.value <= 0.5) {
_fraction = animation.value * 2;
} else {
_fraction = 2 - (animation.value) * 2;
}
});
}
});
controller.forward();
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Positioned(
top: 300 * _move + 10,
left: 150 * _move + 50,
child: SizedBox(
width: 50 * _fraction,
height: 100 * _fraction,
child: CustomPaint(painter: Meteor())),
);
}
}

View File

@ -725,7 +725,7 @@ class _OpenContainerRoute extends ModalRoute<void> {
_positionTween.end = Offset( _positionTween.end = Offset(
10, 10,
playerRunning playerRunning
? MediaQuery.of(context).size.height - 100 ? MediaQuery.of(context).size.height - 110
: MediaQuery.of(context).size.height - 40); : MediaQuery.of(context).size.height - 40);
var _width = MediaQuery.of(context).size.width; var _width = MediaQuery.of(context).size.width;