diff --git a/lib/home/audio_player.dart b/lib/home/audio_player.dart index cac4a22..75da670 100644 --- a/lib/home/audio_player.dart +++ b/lib/home/audio_player.dart @@ -370,138 +370,150 @@ class _PlayerWidgetState extends State { } Widget _expandedPanel() => Container( - height: 300, - color: Colors.grey[100], - padding: EdgeInsets.symmetric(horizontal: 10.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Container( - padding: EdgeInsets.all(30), - alignment: Alignment.center, - child: (_title.length > 50) - ? Marquee( - text: _title, - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 35), - scrollAxis: Axis.horizontal, - crossAxisAlignment: CrossAxisAlignment.start, - blankSpace: 30.0, - velocity: 50.0, - pauseAfterRound: Duration(seconds: 1), - startPadding: 30.0, - accelerationDuration: Duration(seconds: 1), - accelerationCurve: Curves.linear, - decelerationDuration: Duration(milliseconds: 500), - decelerationCurve: Curves.easeOut, - ) - : Text( - _title, - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 20), - ), + height: 300, + color: Colors.grey[100], + padding: EdgeInsets.symmetric(horizontal: 10.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Container( + height: 100.0, + padding: EdgeInsets.all(30), + alignment: Alignment.center, + child: (_title.length > 10) + ? Marquee( + text: _title, + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 20), + scrollAxis: Axis.horizontal, + crossAxisAlignment: CrossAxisAlignment.start, + blankSpace: 30.0, + velocity: 50.0, + pauseAfterRound: Duration(seconds: 1), + startPadding: 30.0, + accelerationDuration: Duration(seconds: 1), + accelerationCurve: Curves.linear, + decelerationDuration: Duration(milliseconds: 500), + decelerationCurve: Curves.easeOut, + ) + : Text( + _title, + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 20), + ), + ), + Container( + padding: EdgeInsets.only(left: 40, right: 40, top: 20), + child: SliderTheme( + data: SliderTheme.of(context).copyWith( + activeTrackColor: Colors.blue[100], + inactiveTrackColor: Colors.grey[300], + trackHeight: 3.0, + thumbColor: Colors.blue[400], + thumbShape: RoundSliderThumbShape(enabledThumbRadius: 6.0), + overlayColor: Colors.blue.withAlpha(32), + overlayShape: RoundSliderOverlayShape(overlayRadius: 14.0), + ), + child: Slider( + value: _seekSliderValue, + onChanged: (double val) { + setState(() => _seekSliderValue = val); + final double positionSeconds = + val * _backgroundAudioDurationSeconds; + _backgroundAudio.seek(positionSeconds); + AudioSystem.instance + .setPlaybackState(true, positionSeconds); + }), ), - Container( - padding: EdgeInsets.only(left: 40, right: 40, top: 20), - child: SliderTheme( - data: SliderTheme.of(context).copyWith( - activeTrackColor: Colors.blue[100], - inactiveTrackColor: Colors.grey[300], - trackHeight: 3.0, - thumbColor: Colors.blue[400], - thumbShape: - RoundSliderThumbShape(enabledThumbRadius: 6.0), - overlayColor: Colors.blue.withAlpha(32), - overlayShape: - RoundSliderOverlayShape(overlayRadius: 14.0), + ), + Container( + height: 20.0, + padding: EdgeInsets.symmetric(horizontal: 50.0), + child: Row( + children: [ + Text( + _stringForSeconds(_backgroundAudioPositionSeconds) ?? '', + style: TextStyle(fontSize: 10), ), - child: Slider( - value: _seekSliderValue, - onChanged: (double val) { - setState(() => _seekSliderValue = val); - final double positionSeconds = - val * _backgroundAudioDurationSeconds; - _backgroundAudio.seek(positionSeconds); - AudioSystem.instance - .setPlaybackState(true, positionSeconds); - }), - ), - ), - Container( - height: 20.0, - padding: EdgeInsets.symmetric(horizontal: 50.0), - child: Row( - children: [ - Text( - _stringForSeconds(_backgroundAudioPositionSeconds) ?? - '', - style: TextStyle(fontSize: 10), + Expanded( + child: Container( + alignment: Alignment.center, + child: _remoteErrorMessage != null + ? Text(_remoteErrorMessage, + style: const TextStyle( + color: const Color(0xFFFF0000))) + : Text( + _remoteAudioLoading ? 'Buffring...' : '', + style: TextStyle(color: Colors.blue), + ), ), - Expanded( - child: Container( - alignment: Alignment.center, - child: _remoteErrorMessage != null - ? Text(_remoteErrorMessage, - style: const TextStyle( - color: const Color(0xFFFF0000))) - : Text( - _remoteAudioLoading ? 'Buffring...' : '', - style: TextStyle(color: Colors.blue), - ), - ), - ), - Text( - _stringForSeconds(_backgroundAudioDurationSeconds) ?? - '', - style: TextStyle(fontSize: 10), - ), - ], - ), - ), - Row( - mainAxisSize: MainAxisSize.min, - children: [ - IconButton( - padding: EdgeInsets.symmetric(horizontal: 30.0), - onPressed: _backgroundAudioPlaying - ? () => _forwardBackgroundAudio(-10) - : null, - iconSize: 32.0, - icon: Icon(Icons.replay_10), - color: Colors.black), - _backgroundAudioPlaying - ? IconButton( - padding: EdgeInsets.symmetric(horizontal: 30.0), - onPressed: _backgroundAudioPlaying - ? () { - _pauseBackgroundAudio(); - } - : null, - iconSize: 40.0, - icon: Icon(Icons.pause_circle_filled), - color: Colors.black) - : IconButton( - padding: EdgeInsets.symmetric(horizontal: 30.0), - onPressed: _backgroundAudioPlaying - ? null - : () { - _resumeBackgroundAudio(); - }, - iconSize: 40.0, - icon: Icon(Icons.play_circle_filled), - color: Colors.black), - IconButton( - padding: EdgeInsets.symmetric(horizontal: 30.0), - onPressed: _backgroundAudioPlaying - ? () => _forwardBackgroundAudio(30) - : null, - iconSize: 32.0, - icon: Icon(Icons.forward_30), - color: Colors.black), + ), + Text( + _stringForSeconds(_backgroundAudioDurationSeconds) ?? '', + style: TextStyle(fontSize: 10), + ), ], ), - ]), + ), + Container( + height: 100, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Material( + color: Colors.transparent, + child: IconButton( + padding: EdgeInsets.symmetric(horizontal: 30.0), + onPressed: _backgroundAudioPlaying + ? () => _forwardBackgroundAudio(-10) + : null, + iconSize: 32.0, + icon: Icon(Icons.replay_10), + color: Colors.black), + ), + _backgroundAudioPlaying + ? Material( + color: Colors.transparent, + child: IconButton( + padding: EdgeInsets.symmetric(horizontal: 30.0), + onPressed: _backgroundAudioPlaying + ? () { + _pauseBackgroundAudio(); + } + : null, + iconSize: 40.0, + icon: Icon(Icons.pause_circle_filled), + color: Colors.black), + ) + : Material( + color: Colors.transparent, + child: IconButton( + padding: EdgeInsets.symmetric(horizontal: 30.0), + onPressed: _backgroundAudioPlaying + ? null + : () { + _resumeBackgroundAudio(); + }, + iconSize: 40.0, + icon: Icon(Icons.play_circle_filled), + color: Colors.black), + ), + Material( + color: Colors.transparent, + child: IconButton( + padding: EdgeInsets.symmetric(horizontal: 30.0), + onPressed: _backgroundAudioPlaying + ? () => _forwardBackgroundAudio(30) + : null, + iconSize: 32.0, + icon: Icon(Icons.forward_30), + color: Colors.black), + ), + ], + ), + ), + ]), ); Widget _miniPanel() => Container( height: 60, @@ -524,12 +536,13 @@ class _PlayerWidgetState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( + alignment: Alignment.centerLeft, width: 220, child: (_title.length > 30) ? Marquee( text: _title, style: TextStyle(fontWeight: FontWeight.bold), - scrollAxis: Axis.horizontal, + scrollAxis: Axis.vertical, crossAxisAlignment: CrossAxisAlignment.start, blankSpace: 30.0, velocity: 50.0, @@ -543,25 +556,32 @@ class _PlayerWidgetState extends State { : Text( _title, style: TextStyle(fontWeight: FontWeight.bold), + maxLines: 2, ), ), Spacer(), Container( padding: EdgeInsets.symmetric(horizontal: 20.0), - child: Row( - children: [ - Text( - _stringForSeconds(_backgroundAudioDurationSeconds - - _backgroundAudioPositionSeconds) ?? - '', - style: TextStyle(color: _c), - ), - Text( - ' Left', - style: TextStyle(color: _c), - ), - ], - ), + child: _remoteAudioLoading + ? Text( + 'Buffring...', + style: TextStyle(color: Colors.blue), + ) + : Row( + children: [ + Text( + _stringForSeconds( + _backgroundAudioDurationSeconds - + _backgroundAudioPositionSeconds) ?? + '', + style: TextStyle(color: _c), + ), + Text( + ' Left', + style: TextStyle(color: _c), + ), + ], + ), ), Row( mainAxisSize: MainAxisSize.min, diff --git a/lib/home/audiopanel.dart b/lib/home/audiopanel.dart index e76febc..3723ab9 100644 --- a/lib/home/audiopanel.dart +++ b/lib/home/audiopanel.dart @@ -20,7 +20,6 @@ class _AudioPanelState extends State @override void initState() { - super.initState(); initSize = minSize; _controller = AnimationController(vsync: this, duration: Duration(milliseconds: 100)) @@ -29,6 +28,7 @@ class _AudioPanelState extends State }); _animation = Tween(begin: initSize, end: initSize).animate(_controller); + super.initState(); } @override @@ -39,63 +39,81 @@ class _AudioPanelState extends State @override Widget build(BuildContext context) { - return GestureDetector( - onVerticalDragStart: (event) => _start(event), - onVerticalDragUpdate: (event) => _update(event), - onVerticalDragEnd: (event) => _end(), - child: Container( - height: (_animation.value >= maxSize) - ? maxSize - : (_animation.value <= minSize) ? minSize : _animation.value, - child: _animation.value < minSize + 30 - ? Opacity( - opacity: _animation.value > minSize - ? (minSize + 30 - _animation.value) / 40 - : 1, - child: Container( - child: widget.miniPanel, - ), - ) - : Container( - decoration: BoxDecoration( - color: Colors.grey[100], - boxShadow: [ - - BoxShadow( - color: Colors.grey[400].withOpacity(0.8), - spreadRadius: 3, - blurRadius: 6, - offset: Offset(0, -1), - ) - ], - ), - child: SingleChildScrollView( - child: Opacity( - opacity: _animation.value < (maxSize - 50) - ? (_animation.value - minSize) / - (maxSize - minSize - 50) - : 1, - child: Container( - height: maxSize, - child: widget.expandedPanel, - ), + return Stack(children: [ + Container( + child: (_animation.value > minSize + 30) + ? Positioned.fill( + child: GestureDetector( + onTap: () => _backToMini(), + child: Container( + color: Colors.white.withOpacity(0.5), ), ), - ), + ) + : Center(), ), - ); + Container( + alignment: Alignment.bottomCenter, + child: GestureDetector( + onVerticalDragStart: (event) => _start(event), + onVerticalDragUpdate: (event) => _update(event), + onVerticalDragEnd: (event) => _end(), + child: Container( + height: (_animation.value >= maxSize) + ? maxSize + : (_animation.value <= minSize) ? minSize : _animation.value, + child: _animation.value < minSize + 30 + ? Container( + color: Colors.grey[100], + child: Opacity( + opacity: _animation.value > minSize + ? (minSize + 30 - _animation.value) / 40 + : 1, + child: Container( + child: widget.miniPanel, + ), + ), + ) + : Container( + color: Colors.grey[100], + child: SingleChildScrollView( + child: Opacity( + opacity: _animation.value < (maxSize - 50) + ? (_animation.value - minSize) / + (maxSize - minSize - 50) + : 1, + child: Container( + height: maxSize, + child: widget.expandedPanel, + ), + ), + ), + ), + ), + ), + ), + ]); + } + + _backToMini() { + setState(() { + _animation = + Tween(begin: initSize, end: minSize).animate(_controller); + initSize = minSize; + }); + _controller.forward(); } _start(DragStartDetails event) { - print(event.localPosition.dy); setState(() { _startdy = event.localPosition.dy; + _animation = + Tween(begin: initSize, end: initSize).animate(_controller); }); _controller.forward(); } _update(DragUpdateDetails event) { - print(event.localPosition.dy); setState(() { _move = _startdy - event.localPosition.dy; _animation = Tween(begin: initSize, end: initSize + _move) @@ -105,7 +123,6 @@ class _AudioPanelState extends State } _end() { - print(_animation.value); if (_animation.value >= (maxSize + minSize) / 2.2 && _animation.value < maxSize) { setState(() { diff --git a/lib/home/home.dart b/lib/home/home.dart index 0c2f9e2..bb97128 100644 --- a/lib/home/home.dart +++ b/lib/home/home.dart @@ -16,6 +16,11 @@ class Home extends StatefulWidget { } class _HomeState extends State { + @override + void initState(){ + super.initState(); + } + @override Widget build(BuildContext context) { return Stack(children: [ @@ -53,7 +58,6 @@ class _HomeState extends State { ], ), Container( - alignment: Alignment.bottomCenter, child: PlayerWidget()), ]); } diff --git a/lib/home/homescroll.dart b/lib/home/homescroll.dart index 5c92bad..d8a99cf 100644 --- a/lib/home/homescroll.dart +++ b/lib/home/homescroll.dart @@ -170,19 +170,22 @@ class _PodcastPreviewState extends State { Text(widget.podcastLocal.title, style: TextStyle(fontWeight: FontWeight.bold, color: _c)), Spacer(), - IconButton( - icon: Icon(Icons.arrow_forward), - splashColor: Colors.transparent, - tooltip: 'See All', - onPressed: () { - Navigator.push( - context, - SlideLeftRoute( - page: PodcastDetail( - podcastLocal: widget.podcastLocal, - )), - ); - }, + Material( + color: Colors.transparent, + child: IconButton( + icon: Icon(Icons.arrow_forward), + splashColor: Colors.transparent, + tooltip: 'See All', + onPressed: () { + Navigator.push( + context, + SlideLeftRoute( + page: PodcastDetail( + podcastLocal: widget.podcastLocal, + )), + ); + }, + ), ), ], ), @@ -228,7 +231,7 @@ class ShowEpisode extends StatelessWidget { ScaleRoute( page: EpisodeDetail( episodeItem: podcast[index], - heroTag: 'scroll', + heroTag: 'scroll', //unique hero tag )), );