This commit is contained in:
		@@ -16,9 +16,6 @@ class FullScreenMediaView extends StatefulWidget {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class _FullScreenMediaViewState extends State<FullScreenMediaView> {
 | 
			
		||||
  double _dragOffset = 0.0;
 | 
			
		||||
  int _pointerCount = 0;
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  void initState() {
 | 
			
		||||
    super.initState();
 | 
			
		||||
@@ -33,68 +30,44 @@ class _FullScreenMediaViewState extends State<FullScreenMediaView> {
 | 
			
		||||
    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(),
 | 
			
		||||
      body: Stack(
 | 
			
		||||
        children: [
 | 
			
		||||
          Positioned.fill(
 | 
			
		||||
            child: widget.item.mime.startsWith('image')
 | 
			
		||||
                ? InteractiveViewer(
 | 
			
		||||
                    minScale: 1.0,
 | 
			
		||||
                    maxScale: 6.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),
 | 
			
		||||
                    ),
 | 
			
		||||
                  )
 | 
			
		||||
                : SizedBox.expand(
 | 
			
		||||
                    child: VideoWidget(
 | 
			
		||||
                      details: widget.item,
 | 
			
		||||
                      isActive: true,
 | 
			
		||||
                      fullScreen: true,
 | 
			
		||||
                    ),
 | 
			
		||||
                  ),
 | 
			
		||||
                ),
 | 
			
		||||
              ],
 | 
			
		||||
          ),
 | 
			
		||||
          SafeArea(
 | 
			
		||||
            child: Align(
 | 
			
		||||
              alignment: Alignment.topLeft,
 | 
			
		||||
              child: IconButton(
 | 
			
		||||
                icon: const Icon(Icons.arrow_back),
 | 
			
		||||
                onPressed: () => Navigator.of(context).pop(),
 | 
			
		||||
              ),
 | 
			
		||||
            ),
 | 
			
		||||
          ),
 | 
			
		||||
        ),
 | 
			
		||||
        ],
 | 
			
		||||
      ),
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user