- fullscreen
This commit is contained in:
parent
13f957f016
commit
82fb23dbfd
@ -1,6 +1,7 @@
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:f0ckapp/screens/fullscreen_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
@ -133,7 +134,13 @@ class _DetailViewState extends ConsumerState<DetailView> {
|
||||
IconButton(
|
||||
icon: const Icon(Icons.fullscreen),
|
||||
onPressed: () {
|
||||
_showMsg('fullscreen ist wip');
|
||||
final mediaState = ref.read(mediaProvider);
|
||||
final currentItem = mediaState.mediaItems[_currentIndex];
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => FullScreenMediaView(item: currentItem),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
|
101
lib/screens/fullscreen_screen.dart
Normal file
101
lib/screens/fullscreen_screen.dart
Normal file
@ -0,0 +1,101 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
|
||||
import 'package:f0ckapp/models/mediaitem_model.dart';
|
||||
import 'package:f0ckapp/widgets/video_widget.dart';
|
||||
|
||||
class FullScreenMediaView extends StatefulWidget {
|
||||
final MediaItem item;
|
||||
|
||||
const FullScreenMediaView({super.key, required this.item});
|
||||
|
||||
@override
|
||||
State createState() => _FullScreenMediaViewState();
|
||||
}
|
||||
|
||||
class _FullScreenMediaViewState extends State<FullScreenMediaView> {
|
||||
double _dragOffset = 0.0;
|
||||
int _pointerCount = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
SystemChrome.setPreferredOrientations(DeviceOrientation.values);
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.black,
|
||||
body: Listener(
|
||||
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: [
|
||||
Center(
|
||||
child: widget.item.mime.startsWith('image')
|
||||
? InteractiveViewer(
|
||||
minScale: 1.0,
|
||||
maxScale: 4.0,
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: widget.item.mediaUrl,
|
||||
fit: BoxFit.contain,
|
||||
placeholder: (context, url) => const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
errorWidget: (context, url, error) =>
|
||||
const Icon(Icons.error, color: Colors.white),
|
||||
),
|
||||
)
|
||||
: VideoWidget(details: widget.item, isActive: true),
|
||||
),
|
||||
SafeArea(
|
||||
child: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -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
|
||||
# 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.
|
||||
version: 1.1.17+47
|
||||
version: 1.1.18+48
|
||||
|
||||
environment:
|
||||
sdk: ^3.9.0-100.2.beta
|
||||
|
Loading…
x
Reference in New Issue
Block a user