actionchip lel
This commit is contained in:
		@@ -99,12 +99,13 @@ class _DetailViewState extends State<DetailView> {
 | 
				
			|||||||
        tag: _tagname,
 | 
					        tag: _tagname,
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      if (mounted && newMedia.isNotEmpty) {
 | 
					      if (mounted && newMedia.isNotEmpty) {
 | 
				
			||||||
        setState(() => mediaItems.addAll(newMedia));
 | 
					        setState(() {
 | 
				
			||||||
 | 
					          mediaItems.addAll(newMedia);
 | 
				
			||||||
 | 
					          isLoading = false;
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    } catch (e) {
 | 
					    } catch (e) {
 | 
				
			||||||
      _showError("Fehler beim Laden weiterer Medien: $e");
 | 
					      _showError("Ein unerwarteter Fehler ist aufgetreten: $e");
 | 
				
			||||||
    } finally {
 | 
					 | 
				
			||||||
      setState(() => isLoading = false);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -123,11 +124,11 @@ class _DetailViewState extends State<DetailView> {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void _showError(String message) {
 | 
					  void _showError(String message) {
 | 
				
			||||||
    if (mounted) {
 | 
					    if (!mounted) return;
 | 
				
			||||||
      ScaffoldMessenger.of(
 | 
					
 | 
				
			||||||
        context,
 | 
					    final messenger = ScaffoldMessenger.of(context);
 | 
				
			||||||
      ).showSnackBar(SnackBar(content: Text(message)));
 | 
					    messenger.hideCurrentSnackBar();
 | 
				
			||||||
    }
 | 
					    messenger.showSnackBar(SnackBar(content: Text(message)));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
@@ -219,23 +220,27 @@ class _DetailViewState extends State<DetailView> {
 | 
				
			|||||||
            alignment: WrapAlignment.center,
 | 
					            alignment: WrapAlignment.center,
 | 
				
			||||||
            spacing: 5.0,
 | 
					            spacing: 5.0,
 | 
				
			||||||
            children: item.tags.map((tag) {
 | 
					            children: item.tags.map((tag) {
 | 
				
			||||||
              return GestureDetector(
 | 
					              return ActionChip(
 | 
				
			||||||
                onTap: () {
 | 
					                label: Text(
 | 
				
			||||||
                  if (tag.tag == 'sfw' || tag.tag == 'nsfw') return;
 | 
					                  tag.tag,
 | 
				
			||||||
                  setState(() {
 | 
					                  style: const TextStyle(
 | 
				
			||||||
                    _tagname = tag.tag;
 | 
					                    color: Colors.white,
 | 
				
			||||||
                    Navigator.pop(context, _tagname);
 | 
					                    fontWeight: FontWeight.bold,
 | 
				
			||||||
                  });
 | 
					                  ),
 | 
				
			||||||
                },
 | 
					 | 
				
			||||||
                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),
 | 
					 | 
				
			||||||
                ),
 | 
					                ),
 | 
				
			||||||
 | 
					                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(),
 | 
					            }).toList(),
 | 
				
			||||||
          ),
 | 
					          ),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,9 +22,10 @@ class VideoControlsOverlay extends StatelessWidget {
 | 
				
			|||||||
            children: [
 | 
					            children: [
 | 
				
			||||||
              _ControlButton(Icons.replay_10, () {
 | 
					              _ControlButton(Icons.replay_10, () {
 | 
				
			||||||
                button();
 | 
					                button();
 | 
				
			||||||
                controller.seekTo(
 | 
					                Duration newPosition =
 | 
				
			||||||
                  controller.value.position - Duration(seconds: 10),
 | 
					                    controller.value.position - const Duration(seconds: 10);
 | 
				
			||||||
                );
 | 
					                if (newPosition < Duration.zero) newPosition = Duration.zero;
 | 
				
			||||||
 | 
					                controller.seekTo(newPosition);
 | 
				
			||||||
              }),
 | 
					              }),
 | 
				
			||||||
              SizedBox(width: 40),
 | 
					              SizedBox(width: 40),
 | 
				
			||||||
              _ControlButton(
 | 
					              _ControlButton(
 | 
				
			||||||
@@ -40,17 +41,75 @@ class VideoControlsOverlay extends StatelessWidget {
 | 
				
			|||||||
              SizedBox(width: 40),
 | 
					              SizedBox(width: 40),
 | 
				
			||||||
              _ControlButton(Icons.forward_10, () {
 | 
					              _ControlButton(Icons.forward_10, () {
 | 
				
			||||||
                button();
 | 
					                button();
 | 
				
			||||||
                controller.seekTo(
 | 
					                Duration newPosition =
 | 
				
			||||||
                  controller.value.position + Duration(seconds: 10),
 | 
					                    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 {
 | 
					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) {
 | 
					    if (_showControls) {
 | 
				
			||||||
      _hideControlsTimer?.cancel();
 | 
					      _hideControlsTimer?.cancel();
 | 
				
			||||||
      _hideControlsTimer = Timer(Duration(seconds: 5), () {
 | 
					      _hideControlsTimer = Timer(Duration(seconds: 2), () {
 | 
				
			||||||
        setState(() => _showControls = false);
 | 
					        setState(() => _showControls = false);
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user