actionchip lel
This commit is contained in:
		@@ -99,12 +99,13 @@ class _DetailViewState extends State<DetailView> {
 | 
			
		||||
        tag: _tagname,
 | 
			
		||||
      );
 | 
			
		||||
      if (mounted && newMedia.isNotEmpty) {
 | 
			
		||||
        setState(() => mediaItems.addAll(newMedia));
 | 
			
		||||
        setState(() {
 | 
			
		||||
          mediaItems.addAll(newMedia);
 | 
			
		||||
          isLoading = false;
 | 
			
		||||
        });
 | 
			
		||||
      }
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
      _showError("Fehler beim Laden weiterer Medien: $e");
 | 
			
		||||
    } finally {
 | 
			
		||||
      setState(() => isLoading = false);
 | 
			
		||||
      _showError("Ein unerwarteter Fehler ist aufgetreten: $e");
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -123,11 +124,11 @@ class _DetailViewState extends State<DetailView> {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  void _showError(String message) {
 | 
			
		||||
    if (mounted) {
 | 
			
		||||
      ScaffoldMessenger.of(
 | 
			
		||||
        context,
 | 
			
		||||
      ).showSnackBar(SnackBar(content: Text(message)));
 | 
			
		||||
    }
 | 
			
		||||
    if (!mounted) return;
 | 
			
		||||
 | 
			
		||||
    final messenger = ScaffoldMessenger.of(context);
 | 
			
		||||
    messenger.hideCurrentSnackBar();
 | 
			
		||||
    messenger.showSnackBar(SnackBar(content: Text(message)));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
@@ -219,23 +220,27 @@ class _DetailViewState extends State<DetailView> {
 | 
			
		||||
            alignment: WrapAlignment.center,
 | 
			
		||||
            spacing: 5.0,
 | 
			
		||||
            children: item.tags.map((tag) {
 | 
			
		||||
              return GestureDetector(
 | 
			
		||||
                onTap: () {
 | 
			
		||||
                  if (tag.tag == 'sfw' || tag.tag == 'nsfw') return;
 | 
			
		||||
                  setState(() {
 | 
			
		||||
                    _tagname = tag.tag;
 | 
			
		||||
                    Navigator.pop(context, _tagname);
 | 
			
		||||
                  });
 | 
			
		||||
                },
 | 
			
		||||
                child: Chip(
 | 
			
		||||
                  label: Text(tag.tag),
 | 
			
		||||
                  backgroundColor: switch (tag.id) {
 | 
			
		||||
                    1 => Colors.green,
 | 
			
		||||
                    2 => Colors.red,
 | 
			
		||||
                    _ => const Color(0xFF090909),
 | 
			
		||||
                  },
 | 
			
		||||
                  labelStyle: const TextStyle(color: Colors.white),
 | 
			
		||||
              return ActionChip(
 | 
			
		||||
                label: Text(
 | 
			
		||||
                  tag.tag,
 | 
			
		||||
                  style: const TextStyle(
 | 
			
		||||
                    color: Colors.white,
 | 
			
		||||
                    fontWeight: FontWeight.bold,
 | 
			
		||||
                  ),
 | 
			
		||||
                ),
 | 
			
		||||
                backgroundColor: switch (tag.id) {
 | 
			
		||||
                  1 => Colors.green,
 | 
			
		||||
                  2 => Colors.red,
 | 
			
		||||
                  _ => const Color(0xFF090909),
 | 
			
		||||
                },
 | 
			
		||||
                padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
 | 
			
		||||
                shape: RoundedRectangleBorder(
 | 
			
		||||
                  borderRadius: BorderRadius.circular(12),
 | 
			
		||||
                ),
 | 
			
		||||
                onPressed: () async {
 | 
			
		||||
                  if (tag.tag == 'sfw' || tag.tag == 'nsfw') return;
 | 
			
		||||
                  setState(() => Navigator.pop(context, tag.tag));
 | 
			
		||||
                },
 | 
			
		||||
              );
 | 
			
		||||
            }).toList(),
 | 
			
		||||
          ),
 | 
			
		||||
 
 | 
			
		||||
@@ -22,9 +22,10 @@ class VideoControlsOverlay extends StatelessWidget {
 | 
			
		||||
            children: [
 | 
			
		||||
              _ControlButton(Icons.replay_10, () {
 | 
			
		||||
                button();
 | 
			
		||||
                controller.seekTo(
 | 
			
		||||
                  controller.value.position - Duration(seconds: 10),
 | 
			
		||||
                );
 | 
			
		||||
                Duration newPosition =
 | 
			
		||||
                    controller.value.position - const Duration(seconds: 10);
 | 
			
		||||
                if (newPosition < Duration.zero) newPosition = Duration.zero;
 | 
			
		||||
                controller.seekTo(newPosition);
 | 
			
		||||
              }),
 | 
			
		||||
              SizedBox(width: 40),
 | 
			
		||||
              _ControlButton(
 | 
			
		||||
@@ -40,17 +41,75 @@ class VideoControlsOverlay extends StatelessWidget {
 | 
			
		||||
              SizedBox(width: 40),
 | 
			
		||||
              _ControlButton(Icons.forward_10, () {
 | 
			
		||||
                button();
 | 
			
		||||
                controller.seekTo(
 | 
			
		||||
                  controller.value.position + Duration(seconds: 10),
 | 
			
		||||
                );
 | 
			
		||||
                Duration newPosition =
 | 
			
		||||
                    controller.value.position + const Duration(seconds: 10);
 | 
			
		||||
                if (newPosition > controller.value.duration) {
 | 
			
		||||
                  newPosition = controller.value.duration;
 | 
			
		||||
                }
 | 
			
		||||
                controller.seekTo(newPosition);
 | 
			
		||||
              }),
 | 
			
		||||
            ],
 | 
			
		||||
          ),
 | 
			
		||||
        ),
 | 
			
		||||
        _ProgressIndicator(controller: controller)
 | 
			
		||||
        Align(
 | 
			
		||||
          alignment: Alignment.bottomCenter,
 | 
			
		||||
          child: Padding(
 | 
			
		||||
            padding: const EdgeInsets.only(bottom: 0),
 | 
			
		||||
            child: Stack(
 | 
			
		||||
              clipBehavior: Clip.none,
 | 
			
		||||
              children: [
 | 
			
		||||
                Positioned(
 | 
			
		||||
                  left: 10,
 | 
			
		||||
                  bottom: 12,
 | 
			
		||||
                  child: Text(
 | 
			
		||||
                    '${_formatDuration(controller.value.position)} / ${_formatDuration(controller.value.duration)}',
 | 
			
		||||
                    style: TextStyle(color: Colors.white),
 | 
			
		||||
                  ),
 | 
			
		||||
                ),
 | 
			
		||||
                Listener(
 | 
			
		||||
                  onPointerDown: (_) {
 | 
			
		||||
                    button();
 | 
			
		||||
                  },
 | 
			
		||||
                  child: VideoProgressIndicator(
 | 
			
		||||
                    controller,
 | 
			
		||||
                    allowScrubbing: true,
 | 
			
		||||
                    padding: const EdgeInsets.only(top: 25.0),
 | 
			
		||||
                    colors: const VideoProgressColors(
 | 
			
		||||
                      playedColor: Colors.red,
 | 
			
		||||
                      backgroundColor: Colors.grey,
 | 
			
		||||
                      bufferedColor: Colors.white54,
 | 
			
		||||
                    ),
 | 
			
		||||
                  ),
 | 
			
		||||
                ),
 | 
			
		||||
                Positioned(
 | 
			
		||||
                  left:
 | 
			
		||||
                      (controller.value.position.inMilliseconds /
 | 
			
		||||
                              controller.value.duration.inMilliseconds) *
 | 
			
		||||
                          MediaQuery.of(context).size.width -
 | 
			
		||||
                      6,
 | 
			
		||||
                  bottom: -4,
 | 
			
		||||
                  child: Container(
 | 
			
		||||
                    width: 12,
 | 
			
		||||
                    height: 12,
 | 
			
		||||
                    decoration: BoxDecoration(
 | 
			
		||||
                      shape: BoxShape.circle,
 | 
			
		||||
                      color: Colors.red,
 | 
			
		||||
                      border: Border.all(color: Colors.red, width: 2),
 | 
			
		||||
                    ),
 | 
			
		||||
                  ),
 | 
			
		||||
                ),
 | 
			
		||||
              ],
 | 
			
		||||
            ),
 | 
			
		||||
          ),
 | 
			
		||||
        ),
 | 
			
		||||
      ],
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  String _formatDuration(Duration duration) {
 | 
			
		||||
    String twoDigits(int n) => n.toString().padLeft(2, '0');
 | 
			
		||||
    return "${twoDigits(duration.inMinutes % 60)}:${twoDigits(duration.inSeconds % 60)}";
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class _ControlButton extends StatelessWidget {
 | 
			
		||||
@@ -74,61 +133,3 @@ class _ControlButton extends StatelessWidget {
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class _ProgressIndicator extends StatelessWidget {
 | 
			
		||||
  final CachedVideoPlayerPlusController controller;
 | 
			
		||||
 | 
			
		||||
  const _ProgressIndicator({required this.controller});
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context) {
 | 
			
		||||
    return Align(
 | 
			
		||||
      alignment: Alignment.bottomCenter,
 | 
			
		||||
      child: Stack(
 | 
			
		||||
        clipBehavior: Clip.none,
 | 
			
		||||
        children: [
 | 
			
		||||
          VideoProgressIndicator(
 | 
			
		||||
            controller,
 | 
			
		||||
            allowScrubbing: true,
 | 
			
		||||
            padding: const EdgeInsets.only(top: 25.0),
 | 
			
		||||
            colors: VideoProgressColors(
 | 
			
		||||
              playedColor: Colors.red,
 | 
			
		||||
              backgroundColor: Colors.grey,
 | 
			
		||||
              bufferedColor: Colors.white54,
 | 
			
		||||
            ),
 | 
			
		||||
          ),
 | 
			
		||||
          Positioned(
 | 
			
		||||
            left:
 | 
			
		||||
                (controller.value.position.inMilliseconds /
 | 
			
		||||
                        controller.value.duration.inMilliseconds) *
 | 
			
		||||
                    MediaQuery.of(context).size.width -
 | 
			
		||||
                6,
 | 
			
		||||
            bottom: -4,
 | 
			
		||||
            child: Container(
 | 
			
		||||
              width: 12,
 | 
			
		||||
              height: 12,
 | 
			
		||||
              decoration: BoxDecoration(
 | 
			
		||||
                shape: BoxShape.circle,
 | 
			
		||||
                color: Colors.red,
 | 
			
		||||
                border: Border.all(color: Colors.red, width: 2),
 | 
			
		||||
              ),
 | 
			
		||||
            ),
 | 
			
		||||
          ),
 | 
			
		||||
          Positioned(
 | 
			
		||||
            left: 16,
 | 
			
		||||
            bottom: 10,
 | 
			
		||||
            child: Text(
 | 
			
		||||
              '${_formatDuration(controller.value.position)} / ${_formatDuration(controller.value.duration)}',
 | 
			
		||||
              style: TextStyle(color: Colors.white),
 | 
			
		||||
            ),
 | 
			
		||||
          ),
 | 
			
		||||
        ],
 | 
			
		||||
      ),
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  String _formatDuration(Duration duration) {
 | 
			
		||||
    String twoDigits(int n) => n.toString().padLeft(2, '0');
 | 
			
		||||
    return "${twoDigits(duration.inMinutes % 60)}:${twoDigits(duration.inSeconds % 60)}";
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -64,7 +64,7 @@ class _VideoWidgetState extends State<VideoWidget> {
 | 
			
		||||
 | 
			
		||||
    if (_showControls) {
 | 
			
		||||
      _hideControlsTimer?.cancel();
 | 
			
		||||
      _hideControlsTimer = Timer(Duration(seconds: 5), () {
 | 
			
		||||
      _hideControlsTimer = Timer(Duration(seconds: 2), () {
 | 
			
		||||
        setState(() => _showControls = false);
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user