From 6f250df004082e222468349d8fa4ef37837557d3 Mon Sep 17 00:00:00 2001 From: exttex Date: Sun, 19 Jul 2020 14:41:05 +0200 Subject: [PATCH] Text styling, download fix, small bugs --- .../main/java/f/f/freezer/MainActivity.java | 9 +++ lib/api/download.dart | 4 ++ lib/settings.dart | 1 + lib/ui/login_screen.dart | 6 +- lib/ui/player_bar.dart | 53 +++++++------- lib/ui/player_screen.dart | 70 +++++++++++++------ pubspec.lock | 14 ++++ pubspec.yaml | 1 + 8 files changed, 110 insertions(+), 48 deletions(-) diff --git a/android/app/src/main/java/f/f/freezer/MainActivity.java b/android/app/src/main/java/f/f/freezer/MainActivity.java index a6e1005..9244ba3 100644 --- a/android/app/src/main/java/f/f/freezer/MainActivity.java +++ b/android/app/src/main/java/f/f/freezer/MainActivity.java @@ -1,5 +1,7 @@ package f.f.freezer; +import android.content.Intent; +import android.net.Uri; import android.util.Log; import androidx.annotation.NonNull; @@ -47,6 +49,13 @@ public class MainActivity extends FlutterActivity { decryptTrack(path, tid); result.success(0); } + //Android media scanner + if (call.method.equals("rescanLibrary")) { + String path = call.argument("path"); + Uri uri = Uri.fromFile(new File(path)); + sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri)); + result.success(0); + } //Add tags to track if (call.method.equals("tagTrack")) { try { diff --git a/lib/api/download.dart b/lib/api/download.dart index bd7b7f5..b7bf692 100644 --- a/lib/api/download.dart +++ b/lib/api/download.dart @@ -543,6 +543,10 @@ class Download { 'cover': _cover, 'trackNumber': track.trackNumber }); + //Rescan android library + await platformChannel.invokeMethod('rescanLibrary', { + 'path': path + }); } //Remove encrypted await File(path + '.ENC').delete(); diff --git a/lib/settings.dart b/lib/settings.dart index 1cef627..02567bb 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -78,6 +78,7 @@ class Settings { accentColor: primaryColor, sliderTheme: _sliderTheme, toggleableActiveColor: primaryColor, + bottomAppBarColor: Color(0xfff7f7f7) ); case Themes.Dark: return ThemeData( diff --git a/lib/ui/login_screen.dart b/lib/ui/login_screen.dart index 6d61638..d4b6bea 100644 --- a/lib/ui/login_screen.dart +++ b/lib/ui/login_screen.dart @@ -129,7 +129,7 @@ class _LoginWidgetState extends State { "Please login using your Deezer account.", textAlign: TextAlign.center, style: TextStyle( - fontSize: 18.0 + fontSize: 16.0 ), ), Container(height: 16.0,), @@ -183,7 +183,7 @@ class _LoginWidgetState extends State { "If you don't have account, you can register on deezer.com for free.", textAlign: TextAlign.center, style: TextStyle( - fontSize: 18.0 + fontSize: 16.0 ), ), Padding( @@ -202,7 +202,7 @@ class _LoginWidgetState extends State { "By using this app, you don't agree with the Deezer ToS", textAlign: TextAlign.center, style: TextStyle( - fontSize: 18.0 + fontSize: 16.0 ), ) ], diff --git a/lib/ui/player_bar.dart b/lib/ui/player_bar.dart index 1de6df9..6c9d4b3 100644 --- a/lib/ui/player_bar.dart +++ b/lib/ui/player_bar.dart @@ -25,31 +25,34 @@ class PlayerBar extends StatelessWidget { return Column( mainAxisSize: MainAxisSize.min, children: [ - ListTile( - onTap: () => Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) => PlayerScreen())), - leading: CachedImage( - width: 50, - height: 50, - url: AudioService.currentMediaItem.artUri, - ), - title: Text( - AudioService.currentMediaItem.displayTitle, - overflow: TextOverflow.clip, - maxLines: 1, - ), - subtitle: Text( - AudioService.currentMediaItem.displaySubtitle, - overflow: TextOverflow.clip, - maxLines: 1, - ), - trailing: Row( - mainAxisSize: MainAxisSize.min, - children: [ - PrevNextButton(iconSize, prev: true, hidePrev: true,), - PlayPauseButton(iconSize), - PrevNextButton(iconSize) - ], - ) + Container( + color: Theme.of(context).bottomAppBarColor, + child: ListTile( + onTap: () => Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) => PlayerScreen())), + leading: CachedImage( + width: 50, + height: 50, + url: AudioService.currentMediaItem.artUri, + ), + title: Text( + AudioService.currentMediaItem.displayTitle, + overflow: TextOverflow.clip, + maxLines: 1, + ), + subtitle: Text( + AudioService.currentMediaItem.displaySubtitle, + overflow: TextOverflow.clip, + maxLines: 1, + ), + trailing: Row( + mainAxisSize: MainAxisSize.min, + children: [ + PrevNextButton(iconSize, prev: true, hidePrev: true,), + PlayPauseButton(iconSize), + PrevNextButton(iconSize) + ], + ) + ), ), Container( height: 3.0, diff --git a/lib/ui/player_screen.dart b/lib/ui/player_screen.dart index 28ca37f..9af003a 100644 --- a/lib/ui/player_screen.dart +++ b/lib/ui/player_screen.dart @@ -10,6 +10,7 @@ import 'package:freezer/ui/menu.dart'; import 'package:freezer/ui/settings_screen.dart'; import 'package:freezer/ui/tiles.dart'; import 'package:async/async.dart'; +import 'package:marquee/marquee.dart'; import 'cached_image.dart'; import '../api/definitions.dart'; @@ -115,15 +116,29 @@ class _PlayerScreenHorizontalState extends State { Column( mainAxisSize: MainAxisSize.min, children: [ - Text( - AudioService.currentMediaItem.displayTitle, - maxLines: 1, - textAlign: TextAlign.center, - overflow: TextOverflow.clip, - style: TextStyle( - fontSize: ScreenUtil().setSp(40), - fontWeight: FontWeight.bold - ), + Container( + height: ScreenUtil().setSp(40), + child: AudioService.currentMediaItem.displayTitle.length >= 22 ? + Marquee( + text: AudioService.currentMediaItem.displayTitle, + style: TextStyle( + fontSize: ScreenUtil().setSp(40), + fontWeight: FontWeight.bold + ), + blankSpace: 32.0, + startPadding: 10.0, + accelerationDuration: Duration(seconds: 1), + pauseAfterRound: Duration(seconds: 2), + ): + Text( + AudioService.currentMediaItem.displayTitle, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: ScreenUtil().setSp(40), + fontWeight: FontWeight.bold + ), + ) ), Container(height: 4,), Text( @@ -241,15 +256,29 @@ class _PlayerScreenVerticalState extends State { Column( mainAxisSize: MainAxisSize.min, children: [ - Text( - AudioService.currentMediaItem.displayTitle, - maxLines: 1, - textAlign: TextAlign.center, - overflow: TextOverflow.clip, - style: TextStyle( + Container( + height: ScreenUtil().setSp(64), + child: AudioService.currentMediaItem.displayTitle.length >= 24 ? + Marquee( + text: AudioService.currentMediaItem.displayTitle, + style: TextStyle( fontSize: ScreenUtil().setSp(64), fontWeight: FontWeight.bold - ), + ), + blankSpace: 32.0, + startPadding: 10.0, + accelerationDuration: Duration(seconds: 1), + pauseAfterRound: Duration(seconds: 2), + ): + Text( + AudioService.currentMediaItem.displayTitle, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: ScreenUtil().setSp(64), + fontWeight: FontWeight.bold + ), + ) ), Container(height: 4,), Text( @@ -338,6 +367,7 @@ class _LyricsWidgetState extends State { Timer _timer; int _currentIndex; double _boxHeight; + double _lyricHeight = 128; String _trackId; Future _load() async { @@ -380,7 +410,7 @@ class _LyricsWidgetState extends State { //Scroll to current lyric if (_currentIndex <= 0) return; _scrollController.animateTo( - (_boxHeight * _currentIndex), + (_lyricHeight * _currentIndex) + (_lyricHeight / 2) - (_boxHeight / 2), duration: Duration(milliseconds: 250), curve: Curves.ease ); @@ -425,7 +455,7 @@ class _LyricsWidgetState extends State { child: Column( children: List.generate(_l.lyrics.length, (i) { return Container( - height: _boxHeight, + height: _lyricHeight, child: Center( child: Stack( children: [ @@ -433,7 +463,7 @@ class _LyricsWidgetState extends State { _l.lyrics[i].text, textAlign: TextAlign.center, style: TextStyle( - fontSize: 36.0, + fontSize: 28.0, fontWeight: (_currentIndex == i)?FontWeight.bold:FontWeight.normal, foreground: Paint() ..strokeWidth = 6 @@ -446,7 +476,7 @@ class _LyricsWidgetState extends State { textAlign: TextAlign.center, style: TextStyle( color: _textColor, - fontSize: 36.0, + fontSize: 28.0, fontWeight: (_currentIndex == i)?FontWeight.bold:FontWeight.normal ), ), diff --git a/pubspec.lock b/pubspec.lock index 884593a..ed3238f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -239,6 +239,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.3" + fading_edge_scrollview: + dependency: transitive + description: + name: fading_edge_scrollview + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.4" file: dependency: transitive description: @@ -445,6 +452,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.11.4" + marquee: + dependency: "direct main" + description: + name: marquee + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.2" matcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index a96278f..96ebdb3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -57,6 +57,7 @@ dependencies: async: ^2.4.1 html: ^0.14.0+3 flutter_screenutil: ^2.3.0 + marquee: ^1.5.2 just_audio: git: https://notabug.org/exttex/just_audio.git