Open scalable album art on tap
This commit is contained in:
parent
df3b7d3d63
commit
e959827cdb
@ -29,7 +29,7 @@ class PlayerHelper {
|
|||||||
QueueSource queueSource;
|
QueueSource queueSource;
|
||||||
LoopMode repeatType = LoopMode.off;
|
LoopMode repeatType = LoopMode.off;
|
||||||
//Find queue index by id
|
//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 {
|
Future start() async {
|
||||||
//Subscribe to custom events
|
//Subscribe to custom events
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:audio_service/audio_service.dart';
|
import 'package:audio_service/audio_service.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@ -14,6 +15,7 @@ import 'package:freezer/ui/tiles.dart';
|
|||||||
import 'package:async/async.dart';
|
import 'package:async/async.dart';
|
||||||
import 'package:just_audio/just_audio.dart';
|
import 'package:just_audio/just_audio.dart';
|
||||||
import 'package:marquee/marquee.dart';
|
import 'package:marquee/marquee.dart';
|
||||||
|
import 'package:photo_view/photo_view.dart';
|
||||||
|
|
||||||
import 'cached_image.dart';
|
import 'cached_image.dart';
|
||||||
import '../api/definitions.dart';
|
import '../api/definitions.dart';
|
||||||
@ -429,6 +431,8 @@ class _BigAlbumArtState extends State<BigAlbumArt> {
|
|||||||
);
|
);
|
||||||
StreamSubscription _currentItemSub;
|
StreamSubscription _currentItemSub;
|
||||||
bool _animationLock = true;
|
bool _animationLock = true;
|
||||||
|
PhotoViewController controller;
|
||||||
|
bool photoViewOpened = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -438,6 +442,8 @@ class _BigAlbumArtState extends State<BigAlbumArt> {
|
|||||||
_animationLock = false;
|
_animationLock = false;
|
||||||
});
|
});
|
||||||
super.initState();
|
super.initState();
|
||||||
|
controller = PhotoViewController()
|
||||||
|
..outputStateStream.listen(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -447,6 +453,14 @@ class _BigAlbumArtState extends State<BigAlbumArt> {
|
|||||||
super.dispose();
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
@ -461,10 +475,32 @@ class _BigAlbumArtState extends State<BigAlbumArt> {
|
|||||||
if (_animationLock) return;
|
if (_animationLock) return;
|
||||||
AudioService.skipToQueueItem(AudioService.queue[index].id);
|
AudioService.skipToQueueItem(AudioService.queue[index].id);
|
||||||
},
|
},
|
||||||
children: List.generate(AudioService.queue.length, (i) => CachedImage(
|
children: List.generate(AudioService.queue.length, (i) {
|
||||||
url: AudioService.queue[i].artUri,
|
String artUri = AudioService.queue[i].artUri;
|
||||||
|
return FlatButton(
|
||||||
|
child: CachedImage(
|
||||||
|
url: artUri,
|
||||||
fullThumb: true,
|
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"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.1"
|
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:
|
platform:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -69,6 +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:
|
||||||
|
|
||||||
audio_session: ^0.0.9
|
audio_session: ^0.0.9
|
||||||
audio_service:
|
audio_service:
|
||||||
|
Loading…
Reference in New Issue
Block a user