Open scalable album art on tap
This commit is contained in:
parent
df3b7d3d63
commit
e959827cdb
@ -29,7 +29,7 @@ class PlayerHelper {
|
||||
QueueSource queueSource;
|
||||
LoopMode repeatType = LoopMode.off;
|
||||
//Find queue index by id
|
||||
int get queueIndex => AudioService.queue.indexWhere((mi) => mi.id == AudioService.currentMediaItem?.id??'Random string so it returns -1');
|
||||
int get queueIndex => AudioService.queue == null ? 0 : AudioService.queue.indexWhere((mi) => mi.id == AudioService.currentMediaItem?.id??'Random string so it returns -1');
|
||||
|
||||
Future start() async {
|
||||
//Subscribe to custom events
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:audio_service/audio_service.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@ -14,6 +15,7 @@ import 'package:freezer/ui/tiles.dart';
|
||||
import 'package:async/async.dart';
|
||||
import 'package:just_audio/just_audio.dart';
|
||||
import 'package:marquee/marquee.dart';
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
|
||||
import 'cached_image.dart';
|
||||
import '../api/definitions.dart';
|
||||
@ -429,6 +431,8 @@ class _BigAlbumArtState extends State<BigAlbumArt> {
|
||||
);
|
||||
StreamSubscription _currentItemSub;
|
||||
bool _animationLock = true;
|
||||
PhotoViewController controller;
|
||||
bool photoViewOpened = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -438,6 +442,8 @@ class _BigAlbumArtState extends State<BigAlbumArt> {
|
||||
_animationLock = false;
|
||||
});
|
||||
super.initState();
|
||||
controller = PhotoViewController()
|
||||
..outputStateStream.listen(listener);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -447,6 +453,14 @@ class _BigAlbumArtState extends State<BigAlbumArt> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
// Listener of PhotoView scale changes. Used for closing PhotoView by pinch-in
|
||||
void listener(PhotoViewControllerValue value){
|
||||
if (value.scale < 0.16 && photoViewOpened) {
|
||||
Navigator.pop(context);
|
||||
photoViewOpened = false; // to avoid multiple pop() when picture are being scaled out too slowly
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
@ -461,10 +475,32 @@ class _BigAlbumArtState extends State<BigAlbumArt> {
|
||||
if (_animationLock) return;
|
||||
AudioService.skipToQueueItem(AudioService.queue[index].id);
|
||||
},
|
||||
children: List.generate(AudioService.queue.length, (i) => CachedImage(
|
||||
url: AudioService.queue[i].artUri,
|
||||
children: List.generate(AudioService.queue.length, (i) {
|
||||
String artUri = AudioService.queue[i].artUri;
|
||||
return FlatButton(
|
||||
child: CachedImage(
|
||||
url: artUri,
|
||||
fullThumb: true,
|
||||
)),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(PageRouteBuilder(
|
||||
opaque: false, // transparent background
|
||||
pageBuilder: (context, a, b) {
|
||||
if (AudioService.queue != null) {
|
||||
photoViewOpened = true;
|
||||
return PhotoView(
|
||||
imageProvider: CachedNetworkImageProvider(artUri),
|
||||
maxScale: 8.0,
|
||||
minScale: 0.2,
|
||||
controller: controller,
|
||||
backgroundDecoration: BoxDecoration(
|
||||
color: Color.fromARGB(0x90, 0, 0, 0)));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
});
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -651,6 +651,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
photo_view:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: photo_view
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.10.2"
|
||||
platform:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -69,6 +69,7 @@ dependencies:
|
||||
share: ^0.6.5+2
|
||||
numberpicker: ^1.2.1
|
||||
quick_actions: ^0.4.0+10
|
||||
photo_view:
|
||||
|
||||
audio_session: ^0.0.9
|
||||
audio_service:
|
||||
|
Loading…
Reference in New Issue
Block a user