Minor improvements

This commit is contained in:
exttex 2020-11-01 20:23:24 +01:00
parent 563a460e48
commit 5725737385
6 changed files with 155 additions and 125 deletions

View File

@ -24,7 +24,8 @@
<service <service
android:name=".DownloadService" android:name=".DownloadService"
android:enabled="true" android:enabled="true"
android:exported="true"></service> android:exported="true"
android:process=':downloads'></service>
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"

View File

@ -430,7 +430,7 @@ class ImageDetails {
//JSON //JSON
factory ImageDetails.fromPrivateString(String art, {String type='cover'}) => ImageDetails( factory ImageDetails.fromPrivateString(String art, {String type='cover'}) => ImageDetails(
fullUrl: 'https://e-cdns-images.dzcdn.net/images/$type/$art/1400x1400-000000-80-0-0.jpg', fullUrl: 'https://e-cdns-images.dzcdn.net/images/$type/$art/1400x1400-000000-80-0-0.jpg',
thumbUrl: 'https://e-cdns-images.dzcdn.net/images/$type/$art/180x180-000000-80-0-0.jpg' thumbUrl: 'https://e-cdns-images.dzcdn.net/images/$type/$art/140x140-000000-80-0-0.jpg'
); );
factory ImageDetails.fromPrivateJson(Map<dynamic, dynamic> json) => ImageDetails.fromPrivateString( factory ImageDetails.fromPrivateJson(Map<dynamic, dynamic> json) => ImageDetails.fromPrivateString(
json['MD5'].split('-').first, json['MD5'].split('-').first,

View File

@ -148,7 +148,19 @@ class _HomePageScreenState extends State<HomePageScreen> {
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
itemCount: _homePage.sections.length, itemCount: _homePage.sections.length,
itemBuilder: (context, i) { itemBuilder: (context, i) {
HomePageSection section = _homePage.sections[i]; return HomepageSectionWidget(_homePage.sections[i]);
},
);
}
}
class HomepageSectionWidget extends StatelessWidget {
final HomePageSection section;
HomepageSectionWidget(this.section);
@override
Widget build(BuildContext context) {
return Column( return Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -196,7 +208,6 @@ class _HomePageScreenState extends State<HomePageScreen> {
} }
return Container(height: 0, width: 0); return Container(height: 0, width: 0);
} }
//Show item //Show item
HomePageItem item = section.items[i]; HomePageItem item = section.items[i];
return HomePageItemWidget(item); return HomePageItemWidget(item);
@ -206,12 +217,11 @@ class _HomePageScreenState extends State<HomePageScreen> {
Container(height: 8.0), Container(height: 8.0),
], ],
); );
},
);
} }
} }
class HomePageItemWidget extends StatelessWidget { class HomePageItemWidget extends StatelessWidget {
HomePageItem item; HomePageItem item;

View File

@ -182,6 +182,7 @@ class _PlayerScreenHorizontalState extends State<PlayerScreenHorizontal> {
setState(() => _lyrics = !_lyrics); setState(() => _lyrics = !_lyrics);
}, },
), ),
if (AudioService.currentMediaItem.extras['qualityString'] != null)
FlatButton( FlatButton(
onPressed: () => Navigator.push( onPressed: () => Navigator.push(
context, context,
@ -192,6 +193,7 @@ class _PlayerScreenHorizontalState extends State<PlayerScreenHorizontal> {
style: TextStyle(fontSize: ScreenUtil().setSp(24)), style: TextStyle(fontSize: ScreenUtil().setSp(24)),
), ),
), ),
RepeatButton(ScreenUtil().setWidth(32)),
IconButton( IconButton(
icon: Icon(Icons.more_vert, size: ScreenUtil().setWidth(32)), icon: Icon(Icons.more_vert, size: ScreenUtil().setWidth(32)),
onPressed: () { onPressed: () {
@ -305,6 +307,7 @@ class _PlayerScreenVerticalState extends State<PlayerScreenVertical> {
setState(() => _lyrics = !_lyrics); setState(() => _lyrics = !_lyrics);
}, },
), ),
if (AudioService.currentMediaItem.extras['qualityString'] != null)
FlatButton( FlatButton(
onPressed: () => Navigator.push( onPressed: () => Navigator.push(
context, context,
@ -317,15 +320,7 @@ class _PlayerScreenVerticalState extends State<PlayerScreenVertical> {
), ),
), ),
), ),
IconButton( RepeatButton(ScreenUtil().setWidth(46)),
icon: Icon(Icons.sentiment_very_dissatisfied, size: ScreenUtil().setWidth(46)),
onPressed: () async {
await deezerAPI.dislikeTrack(AudioService.currentMediaItem.id);
if (playerHelper.queueIndex < (AudioService.queue??[]).length - 1) {
AudioService.skipToNext();
}
}
),
IconButton( IconButton(
icon: Icon(Icons.more_vert, size: ScreenUtil().setWidth(46)), icon: Icon(Icons.more_vert, size: ScreenUtil().setWidth(46)),
onPressed: () { onPressed: () {
@ -342,6 +337,54 @@ class _PlayerScreenVerticalState extends State<PlayerScreenVertical> {
} }
} }
class RepeatButton extends StatefulWidget {
final double iconSize;
RepeatButton(this.iconSize, {Key key}): super(key: key);
@override
_RepeatButtonState createState() => _RepeatButtonState();
}
class _RepeatButtonState extends State<RepeatButton> {
Icon get repeatIcon {
switch (playerHelper.repeatType) {
case LoopMode.off:
return Icon(
Icons.repeat,
size: widget.iconSize
);
case LoopMode.all:
return Icon(
Icons.repeat,
color: Theme.of(context).primaryColor,
size: widget.iconSize
);
case LoopMode.one:
return Icon(
Icons.repeat_one,
color: Theme.of(context).primaryColor,
size: widget.iconSize
);
}
}
@override
Widget build(BuildContext context) {
return IconButton(
icon: repeatIcon,
onPressed: () async {
await playerHelper.changeRepeat();
setState(() {});
},
);
}
}
class PlaybackControls extends StatefulWidget { class PlaybackControls extends StatefulWidget {
final double iconSize; final double iconSize;
@ -353,28 +396,6 @@ class PlaybackControls extends StatefulWidget {
class _PlaybackControlsState extends State<PlaybackControls> { class _PlaybackControlsState extends State<PlaybackControls> {
Icon get repeatIcon {
switch (playerHelper.repeatType) {
case LoopMode.off:
return Icon(
Icons.repeat,
size: widget.iconSize * 0.64
);
case LoopMode.all:
return Icon(
Icons.repeat,
color: Theme.of(context).primaryColor,
size: widget.iconSize * 0.64
);
case LoopMode.one:
return Icon(
Icons.repeat_one,
color: Theme.of(context).primaryColor,
size: widget.iconSize * 0.64,
);
}
}
Icon get libraryIcon { Icon get libraryIcon {
if (cache.checkTrackFavorite(Track.fromMediaItem(AudioService.currentMediaItem))) { if (cache.checkTrackFavorite(Track.fromMediaItem(AudioService.currentMediaItem))) {
return Icon(Icons.favorite, size: widget.iconSize * 0.64); return Icon(Icons.favorite, size: widget.iconSize * 0.64);
@ -391,11 +412,13 @@ class _PlaybackControlsState extends State<PlaybackControls> {
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
children: [ children: [
IconButton( IconButton(
icon: repeatIcon, icon: Icon(Icons.sentiment_very_dissatisfied, size: ScreenUtil().setWidth(46)),
onPressed: () async { onPressed: () async {
await playerHelper.changeRepeat(); await deezerAPI.dislikeTrack(AudioService.currentMediaItem.id);
setState(() {}); if (playerHelper.queueIndex < (AudioService.queue??[]).length - 1) {
}, AudioService.skipToNext();
}
}
), ),
PrevNextButton(widget.iconSize, prev: true), PrevNextButton(widget.iconSize, prev: true),
PlayPauseButton(widget.iconSize * 1.25), PlayPauseButton(widget.iconSize * 1.25),

View File

@ -134,9 +134,8 @@ class ArtistTile extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SizedBox( return SizedBox(
width: 150, width: 150,
child: Card( child: Container(
color: Theme.of(context).scaffoldBackgroundColor, color: Theme.of(context).scaffoldBackgroundColor,
elevation: 0.0,
child: InkWell( child: InkWell(
onTap: onTap, onTap: onTap,
onLongPress: onHold, onLongPress: onHold,
@ -245,9 +244,8 @@ class PlaylistCardTile extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Card( return Container(
color: Theme.of(context).scaffoldBackgroundColor, color: Theme.of(context).scaffoldBackgroundColor,
elevation: 0.0,
child: InkWell( child: InkWell(
onTap: onTap, onTap: onTap,
onLongPress: onHold, onLongPress: onHold,
@ -291,8 +289,7 @@ class SmartTrackListTile extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Card( return Container(
elevation: 0,
color: Theme.of(context).scaffoldBackgroundColor, color: Theme.of(context).scaffoldBackgroundColor,
child: InkWell( child: InkWell(
onTap: onTap, onTap: onTap,
@ -338,9 +335,8 @@ class AlbumCard extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Card( return Container(
color: Theme.of(context).scaffoldBackgroundColor, color: Theme.of(context).scaffoldBackgroundColor,
elevation: 0.0,
child: InkWell( child: InkWell(
onTap: onTap, onTap: onTap,
onLongPress: onHold, onLongPress: onHold,

View File

@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at # Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.6.1+1 version: 0.6.2+1
environment: environment:
sdk: ">=2.8.0 <3.0.0" sdk: ">=2.8.0 <3.0.0"
@ -69,7 +69,7 @@ dependencies:
share: ^0.6.5+2 share: ^0.6.5+2
numberpicker: ^1.2.1 numberpicker: ^1.2.1
quick_actions: ^0.4.0+10 quick_actions: ^0.4.0+10
photo_view: photo_view: ^0.10.2
audio_session: ^0.0.9 audio_session: ^0.0.9
audio_service: audio_service: