This commit is contained in:
parent
82fb23dbfd
commit
a4d50289c2
@ -16,9 +16,6 @@ class FullScreenMediaView extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _FullScreenMediaViewState extends State<FullScreenMediaView> {
|
class _FullScreenMediaViewState extends State<FullScreenMediaView> {
|
||||||
double _dragOffset = 0.0;
|
|
||||||
int _pointerCount = 0;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -33,69 +30,45 @@ class _FullScreenMediaViewState extends State<FullScreenMediaView> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onVerticalDragUpdate(DragUpdateDetails details) {
|
|
||||||
if (_pointerCount != 1) return;
|
|
||||||
setState(() => _dragOffset += details.delta.dy);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onVerticalDragEnd(DragEndDetails details) {
|
|
||||||
if (_dragOffset < -100 || _dragOffset > 100) {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
} else {
|
|
||||||
setState(() => _dragOffset = 0.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.black,
|
backgroundColor: Colors.black,
|
||||||
body: Listener(
|
body: Stack(
|
||||||
onPointerDown: (_) {
|
|
||||||
setState(() => _pointerCount++);
|
|
||||||
},
|
|
||||||
onPointerUp: (_) {
|
|
||||||
setState(() => _pointerCount = (_pointerCount - 1).clamp(0, 10));
|
|
||||||
},
|
|
||||||
child: GestureDetector(
|
|
||||||
behavior: HitTestBehavior.opaque,
|
|
||||||
onVerticalDragUpdate: _onVerticalDragUpdate,
|
|
||||||
onVerticalDragEnd: _onVerticalDragEnd,
|
|
||||||
child: Transform.translate(
|
|
||||||
offset: Offset(0, _dragOffset),
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
children: [
|
||||||
Center(
|
Positioned.fill(
|
||||||
child: widget.item.mime.startsWith('image')
|
child: widget.item.mime.startsWith('image')
|
||||||
? InteractiveViewer(
|
? InteractiveViewer(
|
||||||
minScale: 1.0,
|
minScale: 1.0,
|
||||||
maxScale: 4.0,
|
maxScale: 6.0,
|
||||||
child: CachedNetworkImage(
|
child: CachedNetworkImage(
|
||||||
imageUrl: widget.item.mediaUrl,
|
imageUrl: widget.item.mediaUrl,
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
placeholder: (context, url) => const Center(
|
placeholder: (context, url) =>
|
||||||
child: CircularProgressIndicator(),
|
const Center(child: CircularProgressIndicator()),
|
||||||
),
|
|
||||||
errorWidget: (context, url, error) =>
|
errorWidget: (context, url, error) =>
|
||||||
const Icon(Icons.error, color: Colors.white),
|
const Icon(Icons.error),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: VideoWidget(details: widget.item, isActive: true),
|
: SizedBox.expand(
|
||||||
|
child: VideoWidget(
|
||||||
|
details: widget.item,
|
||||||
|
isActive: true,
|
||||||
|
fullScreen: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SafeArea(
|
SafeArea(
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.topLeft,
|
alignment: Alignment.topLeft,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
icon: const Icon(Icons.arrow_back),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,14 @@ import 'package:f0ckapp/providers/media_provider.dart';
|
|||||||
class VideoWidget extends ConsumerStatefulWidget {
|
class VideoWidget extends ConsumerStatefulWidget {
|
||||||
final MediaItem details;
|
final MediaItem details;
|
||||||
final bool isActive;
|
final bool isActive;
|
||||||
|
final bool fullScreen;
|
||||||
|
|
||||||
const VideoWidget({super.key, required this.details, required this.isActive});
|
const VideoWidget({
|
||||||
|
super.key,
|
||||||
|
required this.details,
|
||||||
|
required this.isActive,
|
||||||
|
this.fullScreen = false,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ConsumerState<VideoWidget> createState() => _VideoWidgetState();
|
ConsumerState<VideoWidget> createState() => _VideoWidgetState();
|
||||||
@ -90,6 +96,50 @@ class _VideoWidgetState extends ConsumerState<VideoWidget> {
|
|||||||
|
|
||||||
bool isAudio = widget.details.mime.startsWith('audio');
|
bool isAudio = widget.details.mime.startsWith('audio');
|
||||||
|
|
||||||
|
if (widget.fullScreen) {
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
Center(
|
||||||
|
child: AspectRatio(
|
||||||
|
aspectRatio: _controller.value.isInitialized
|
||||||
|
? _controller.value.aspectRatio
|
||||||
|
: 9 / 16,
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: _onTap,
|
||||||
|
child: isAudio
|
||||||
|
? CachedNetworkImage(
|
||||||
|
imageUrl: widget.details.coverUrl,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
placeholder: (context, url) =>
|
||||||
|
const CircularProgressIndicator(),
|
||||||
|
errorWidget: (context, url, error) => Image.asset(
|
||||||
|
'assets/images/music.webp',
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
width: double.infinity,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: _controller.value.isInitialized
|
||||||
|
? CachedVideoPlayerPlus(_controller)
|
||||||
|
: const Center(child: CircularProgressIndicator()),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (_controller.value.isInitialized && _showControls)
|
||||||
|
Positioned.fill(
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: _onTap,
|
||||||
|
child: Container(
|
||||||
|
color: Colors.black.withValues(alpha: 0.5),
|
||||||
|
child: VideoControlsOverlay(
|
||||||
|
controller: _controller,
|
||||||
|
button: () => _onTap(ctrlButton: true),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
@ -138,4 +188,5 @@ class _VideoWidgetState extends ConsumerState<VideoWidget> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: f0ckapp
|
name: f0ckapp
|
||||||
description: "A new Flutter project."
|
description: "f0ck schm0ck"
|
||||||
# The following line prevents the package from being accidentally published to
|
# The following line prevents the package from being accidentally published to
|
||||||
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
||||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||||
@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||||||
# 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
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 1.1.18+48
|
version: 1.1.19+49
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.9.0-100.2.beta
|
sdk: ^3.9.0-100.2.beta
|
||||||
|
Loading…
x
Reference in New Issue
Block a user