1.0.15 + random
This commit is contained in:
		@@ -13,12 +13,16 @@ class MediaGrid extends StatefulWidget {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class _MediaGridState extends State<MediaGrid> {
 | 
					class _MediaGridState extends State<MediaGrid> {
 | 
				
			||||||
  final ScrollController _scrollController = ScrollController();
 | 
					  final ScrollController _scrollController = ScrollController();
 | 
				
			||||||
 | 
					  final String _version = '1.0.15';
 | 
				
			||||||
  List<MediaItem> mediaItems = [];
 | 
					  List<MediaItem> mediaItems = [];
 | 
				
			||||||
  bool isLoading = false;
 | 
					  bool isLoading = false;
 | 
				
			||||||
  Timer? _debounceTimer;
 | 
					  Timer? _debounceTimer;
 | 
				
			||||||
  Completer<void>? _navigationCompleter;
 | 
					  Completer<void>? _navigationCompleter;
 | 
				
			||||||
  int _crossAxisCount = 3;
 | 
					  int _crossAxisCount = 0;
 | 
				
			||||||
  String _selectedMode = "alles";
 | 
					  String _selectedType = 'alles';
 | 
				
			||||||
 | 
					  int _selectedMode = 0;
 | 
				
			||||||
 | 
					  bool _random = false;
 | 
				
			||||||
 | 
					  final List<String> _modes = ["sfw", "nsfw", "untagged", "all"];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
  void initState() {
 | 
					  void initState() {
 | 
				
			||||||
@@ -37,6 +41,17 @@ class _MediaGridState extends State<MediaGrid> {
 | 
				
			|||||||
    _debounceTimer = Timer(const Duration(milliseconds: 500), _loadMedia);
 | 
					    _debounceTimer = Timer(const Duration(milliseconds: 500), _loadMedia);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int _calculateCrossAxisCount(BuildContext context) {
 | 
				
			||||||
 | 
					    if (_crossAxisCount != 0) {
 | 
				
			||||||
 | 
					      return _crossAxisCount;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    double screenWidth = MediaQuery.of(context).size.width;
 | 
				
			||||||
 | 
					    int columnCount = (screenWidth / 110).clamp(3, 5).toInt();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return columnCount;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Future<void> _loadMedia() async {
 | 
					  Future<void> _loadMedia() async {
 | 
				
			||||||
    if (isLoading) return;
 | 
					    if (isLoading) return;
 | 
				
			||||||
    setState(() => isLoading = true);
 | 
					    setState(() => isLoading = true);
 | 
				
			||||||
@@ -44,7 +59,9 @@ class _MediaGridState extends State<MediaGrid> {
 | 
				
			|||||||
    try {
 | 
					    try {
 | 
				
			||||||
      final newMedia = await fetchMedia(
 | 
					      final newMedia = await fetchMedia(
 | 
				
			||||||
        older: mediaItems.isNotEmpty ? mediaItems.last.id.toString() : null,
 | 
					        older: mediaItems.isNotEmpty ? mediaItems.last.id.toString() : null,
 | 
				
			||||||
 | 
					        type: _selectedType,
 | 
				
			||||||
        mode: _selectedMode,
 | 
					        mode: _selectedMode,
 | 
				
			||||||
 | 
					        random: _random,
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      if (mounted) {
 | 
					      if (mounted) {
 | 
				
			||||||
        setState(() => mediaItems.addAll(newMedia));
 | 
					        setState(() => mediaItems.addAll(newMedia));
 | 
				
			||||||
@@ -63,7 +80,12 @@ class _MediaGridState extends State<MediaGrid> {
 | 
				
			|||||||
  Future<void> _refreshMedia() async {
 | 
					  Future<void> _refreshMedia() async {
 | 
				
			||||||
    setState(() => isLoading = true);
 | 
					    setState(() => isLoading = true);
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
      final freshMedia = await fetchMedia(older: null, mode: _selectedMode);
 | 
					      final freshMedia = await fetchMedia(
 | 
				
			||||||
 | 
					        older: null,
 | 
				
			||||||
 | 
					        type: _selectedType,
 | 
				
			||||||
 | 
					        mode: _selectedMode,
 | 
				
			||||||
 | 
					        random: _random,
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
      if (mounted) {
 | 
					      if (mounted) {
 | 
				
			||||||
        setState(() {
 | 
					        setState(() {
 | 
				
			||||||
          mediaItems.clear();
 | 
					          mediaItems.clear();
 | 
				
			||||||
@@ -93,7 +115,9 @@ class _MediaGridState extends State<MediaGrid> {
 | 
				
			|||||||
            builder: (context) => DetailView(
 | 
					            builder: (context) => DetailView(
 | 
				
			||||||
              initialItemId: item.id,
 | 
					              initialItemId: item.id,
 | 
				
			||||||
              mediaItems: mediaItems,
 | 
					              mediaItems: mediaItems,
 | 
				
			||||||
 | 
					              type: _selectedType,
 | 
				
			||||||
              mode: _selectedMode,
 | 
					              mode: _selectedMode,
 | 
				
			||||||
 | 
					              random: _random,
 | 
				
			||||||
            ),
 | 
					            ),
 | 
				
			||||||
          ),
 | 
					          ),
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
@@ -113,12 +137,24 @@ class _MediaGridState extends State<MediaGrid> {
 | 
				
			|||||||
  Widget build(BuildContext context) {
 | 
					  Widget build(BuildContext context) {
 | 
				
			||||||
    return Scaffold(
 | 
					    return Scaffold(
 | 
				
			||||||
      appBar: AppBar(
 | 
					      appBar: AppBar(
 | 
				
			||||||
 | 
					        centerTitle: true,
 | 
				
			||||||
        backgroundColor: const Color.fromARGB(255, 43, 43, 43),
 | 
					        backgroundColor: const Color.fromARGB(255, 43, 43, 43),
 | 
				
			||||||
        foregroundColor: const Color.fromARGB(255, 255, 255, 255),
 | 
					        foregroundColor: const Color.fromARGB(255, 255, 255, 255),
 | 
				
			||||||
        title: Row(
 | 
					        title: Row(
 | 
				
			||||||
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
 | 
					          mainAxisAlignment: MainAxisAlignment.spaceBetween,
 | 
				
			||||||
          children: [const Text('f0cks')],
 | 
					          children: [
 | 
				
			||||||
        ),
 | 
					            Text('f0ck v$_version'),
 | 
				
			||||||
 | 
					            Checkbox(
 | 
				
			||||||
 | 
					              value: _random,
 | 
				
			||||||
 | 
					              onChanged: (bool? value) {
 | 
				
			||||||
 | 
					                setState(() {
 | 
				
			||||||
 | 
					                  _random = !_random;
 | 
				
			||||||
 | 
					                  _refreshMedia();
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					              },
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
 | 
					          ]
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
      ),
 | 
					      ),
 | 
				
			||||||
      bottomNavigationBar: BottomAppBar(
 | 
					      bottomNavigationBar: BottomAppBar(
 | 
				
			||||||
        color: const Color.fromARGB(255, 43, 43, 43),
 | 
					        color: const Color.fromARGB(255, 43, 43, 43),
 | 
				
			||||||
@@ -126,9 +162,10 @@ class _MediaGridState extends State<MediaGrid> {
 | 
				
			|||||||
          padding: const EdgeInsets.symmetric(horizontal: 16.0),
 | 
					          padding: const EdgeInsets.symmetric(horizontal: 16.0),
 | 
				
			||||||
          child: Row(
 | 
					          child: Row(
 | 
				
			||||||
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
 | 
					            mainAxisAlignment: MainAxisAlignment.spaceBetween,
 | 
				
			||||||
 | 
					            crossAxisAlignment: CrossAxisAlignment.end,
 | 
				
			||||||
            children: [
 | 
					            children: [
 | 
				
			||||||
              DropdownButton<String>(
 | 
					              DropdownButton<String>(
 | 
				
			||||||
                value: _selectedMode,
 | 
					                value: _selectedType,
 | 
				
			||||||
                dropdownColor: const Color.fromARGB(255, 43, 43, 43),
 | 
					                dropdownColor: const Color.fromARGB(255, 43, 43, 43),
 | 
				
			||||||
                iconEnabledColor: Colors.white,
 | 
					                iconEnabledColor: Colors.white,
 | 
				
			||||||
                items: ["alles", "image", "video", "audio"].map((String value) {
 | 
					                items: ["alles", "image", "video", "audio"].map((String value) {
 | 
				
			||||||
@@ -140,7 +177,26 @@ class _MediaGridState extends State<MediaGrid> {
 | 
				
			|||||||
                onChanged: (String? newValue) {
 | 
					                onChanged: (String? newValue) {
 | 
				
			||||||
                  if (newValue != null) {
 | 
					                  if (newValue != null) {
 | 
				
			||||||
                    setState(() {
 | 
					                    setState(() {
 | 
				
			||||||
                      _selectedMode = newValue;
 | 
					                      _selectedType = newValue;
 | 
				
			||||||
 | 
					                      _refreshMedia();
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					                  }
 | 
				
			||||||
 | 
					                },
 | 
				
			||||||
 | 
					              ),
 | 
				
			||||||
 | 
					              DropdownButton<String>(
 | 
				
			||||||
 | 
					                value: _modes[_selectedMode],
 | 
				
			||||||
 | 
					                dropdownColor: const Color.fromARGB(255, 43, 43, 43),
 | 
				
			||||||
 | 
					                iconEnabledColor: Colors.white,
 | 
				
			||||||
 | 
					                items: _modes.map((String value) {
 | 
				
			||||||
 | 
					                  return DropdownMenuItem<String>(
 | 
				
			||||||
 | 
					                    value: value,
 | 
				
			||||||
 | 
					                    child: Text(value, style: TextStyle(color: Colors.white)),
 | 
				
			||||||
 | 
					                  );
 | 
				
			||||||
 | 
					                }).toList(),
 | 
				
			||||||
 | 
					                onChanged: (String? newValue) {
 | 
				
			||||||
 | 
					                  if (newValue != null) {
 | 
				
			||||||
 | 
					                    setState(() {
 | 
				
			||||||
 | 
					                      _selectedMode = _modes.indexOf(newValue);
 | 
				
			||||||
                      _refreshMedia();
 | 
					                      _refreshMedia();
 | 
				
			||||||
                    });
 | 
					                    });
 | 
				
			||||||
                  }
 | 
					                  }
 | 
				
			||||||
@@ -150,11 +206,11 @@ class _MediaGridState extends State<MediaGrid> {
 | 
				
			|||||||
                value: _crossAxisCount,
 | 
					                value: _crossAxisCount,
 | 
				
			||||||
                dropdownColor: const Color.fromARGB(255, 43, 43, 43),
 | 
					                dropdownColor: const Color.fromARGB(255, 43, 43, 43),
 | 
				
			||||||
                iconEnabledColor: Colors.white,
 | 
					                iconEnabledColor: Colors.white,
 | 
				
			||||||
                items: [3, 4].map((int value) {
 | 
					                items: [0, 3, 4].map((int value) {
 | 
				
			||||||
                  return DropdownMenuItem<int>(
 | 
					                  return DropdownMenuItem<int>(
 | 
				
			||||||
                    value: value,
 | 
					                    value: value,
 | 
				
			||||||
                    child: Text(
 | 
					                    child: Text(
 | 
				
			||||||
                      '$value Spalten',
 | 
					                      value == 0 ? 'auto' : '$value Spalten',
 | 
				
			||||||
                      style: TextStyle(color: Colors.white),
 | 
					                      style: TextStyle(color: Colors.white),
 | 
				
			||||||
                    ),
 | 
					                    ),
 | 
				
			||||||
                  );
 | 
					                  );
 | 
				
			||||||
@@ -176,7 +232,7 @@ class _MediaGridState extends State<MediaGrid> {
 | 
				
			|||||||
        child: GridView.builder(
 | 
					        child: GridView.builder(
 | 
				
			||||||
          controller: _scrollController,
 | 
					          controller: _scrollController,
 | 
				
			||||||
          gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
 | 
					          gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
 | 
				
			||||||
            crossAxisCount: _crossAxisCount,
 | 
					            crossAxisCount: _calculateCrossAxisCount(context),
 | 
				
			||||||
            crossAxisSpacing: 5.0,
 | 
					            crossAxisSpacing: 5.0,
 | 
				
			||||||
            mainAxisSpacing: 5.0,
 | 
					            mainAxisSpacing: 5.0,
 | 
				
			||||||
          ),
 | 
					          ),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,13 +6,17 @@ import 'package:f0ckapp/widgets/video_widget.dart';
 | 
				
			|||||||
class DetailView extends StatefulWidget {
 | 
					class DetailView extends StatefulWidget {
 | 
				
			||||||
  final int initialItemId;
 | 
					  final int initialItemId;
 | 
				
			||||||
  final List<MediaItem> mediaItems;
 | 
					  final List<MediaItem> mediaItems;
 | 
				
			||||||
  final String mode;
 | 
					  final String type;
 | 
				
			||||||
 | 
					  final int mode;
 | 
				
			||||||
 | 
					  final bool random;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const DetailView({
 | 
					  const DetailView({
 | 
				
			||||||
    super.key,
 | 
					    super.key,
 | 
				
			||||||
    required this.initialItemId,
 | 
					    required this.initialItemId,
 | 
				
			||||||
    required this.mediaItems,
 | 
					    required this.mediaItems,
 | 
				
			||||||
 | 
					    required this.type,
 | 
				
			||||||
    required this.mode,
 | 
					    required this.mode,
 | 
				
			||||||
 | 
					    required this.random,
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
@@ -22,12 +26,14 @@ class DetailView extends StatefulWidget {
 | 
				
			|||||||
class _DetailViewState extends State<DetailView> {
 | 
					class _DetailViewState extends State<DetailView> {
 | 
				
			||||||
  late PageController _pageController;
 | 
					  late PageController _pageController;
 | 
				
			||||||
  late List<MediaItem> mediaItems;
 | 
					  late List<MediaItem> mediaItems;
 | 
				
			||||||
 | 
					  final List<String> _modes = ["sfw", "nsfw", "untagged", "all"];
 | 
				
			||||||
  int currentItemId = 0;
 | 
					  int currentItemId = 0;
 | 
				
			||||||
  bool isLoading = false;
 | 
					  bool isLoading = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
  void initState() {
 | 
					  void initState() {
 | 
				
			||||||
    super.initState();
 | 
					    super.initState();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mediaItems = widget.mediaItems;
 | 
					    mediaItems = widget.mediaItems;
 | 
				
			||||||
    final initialIndex = mediaItems.indexWhere(
 | 
					    final initialIndex = mediaItems.indexWhere(
 | 
				
			||||||
      (item) => item.id == widget.initialItemId,
 | 
					      (item) => item.id == widget.initialItemId,
 | 
				
			||||||
@@ -56,7 +62,9 @@ class _DetailViewState extends State<DetailView> {
 | 
				
			|||||||
    try {
 | 
					    try {
 | 
				
			||||||
      final newMedia = await fetchMedia(
 | 
					      final newMedia = await fetchMedia(
 | 
				
			||||||
        older: mediaItems.last.id.toString(),
 | 
					        older: mediaItems.last.id.toString(),
 | 
				
			||||||
 | 
					        type: widget.type,
 | 
				
			||||||
        mode: widget.mode,
 | 
					        mode: widget.mode,
 | 
				
			||||||
 | 
					        random: widget.random,
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      if (mounted) {
 | 
					      if (mounted) {
 | 
				
			||||||
        setState(() => mediaItems.addAll(newMedia));
 | 
					        setState(() => mediaItems.addAll(newMedia));
 | 
				
			||||||
@@ -72,72 +80,99 @@ class _DetailViewState extends State<DetailView> {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Future<void> _refreshMediaItem() async {
 | 
				
			||||||
 | 
					    try {
 | 
				
			||||||
 | 
					      final updatedItem = await fetchMediaDetail(currentItemId);
 | 
				
			||||||
 | 
					      if (mounted) {
 | 
				
			||||||
 | 
					        setState(() {
 | 
				
			||||||
 | 
					          final index = mediaItems.indexWhere(
 | 
				
			||||||
 | 
					            (item) => item.id == currentItemId,
 | 
				
			||||||
 | 
					          );
 | 
				
			||||||
 | 
					          if (index != -1) {
 | 
				
			||||||
 | 
					            mediaItems[index] = updatedItem;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    } catch (e) {
 | 
				
			||||||
 | 
					      if (mounted) {
 | 
				
			||||||
 | 
					        ScaffoldMessenger.of(context).showSnackBar(
 | 
				
			||||||
 | 
					          SnackBar(content: Text('Fehler beim Aktualisieren des Items: $e')),
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
  Widget build(BuildContext context) {
 | 
					  Widget build(BuildContext context) {
 | 
				
			||||||
    return Scaffold(
 | 
					    return Scaffold(
 | 
				
			||||||
      backgroundColor: Color(0xFF171717),
 | 
					      backgroundColor: const Color(0xFF171717),
 | 
				
			||||||
      appBar: AppBar(
 | 
					      appBar: AppBar(
 | 
				
			||||||
        backgroundColor: const Color(0xFF2B2B2B),
 | 
					        backgroundColor: const Color(0xFF2B2B2B),
 | 
				
			||||||
        foregroundColor: Colors.white,
 | 
					        foregroundColor: Colors.white,
 | 
				
			||||||
        title: Text('f0ck #$currentItemId (${widget.mode})'),
 | 
					        title: Text(
 | 
				
			||||||
 | 
					          'f0ck #$currentItemId (${widget.type}, ${_modes[widget.mode]})',
 | 
				
			||||||
 | 
					        ),
 | 
				
			||||||
        centerTitle: true,
 | 
					        centerTitle: true,
 | 
				
			||||||
      ),
 | 
					      ),
 | 
				
			||||||
      body: PageView.builder(
 | 
					      body: RefreshIndicator(
 | 
				
			||||||
        controller: _pageController,
 | 
					        onRefresh: _refreshMediaItem,
 | 
				
			||||||
        itemCount: mediaItems.length + (isLoading ? 1 : 0),
 | 
					        child: SingleChildScrollView(
 | 
				
			||||||
        itemBuilder: (context, index) {
 | 
					          child: Column(
 | 
				
			||||||
          if (index >= mediaItems.length) {
 | 
					            children: [
 | 
				
			||||||
            return const Center(child: CircularProgressIndicator());
 | 
					              SizedBox(
 | 
				
			||||||
          }
 | 
					                height: MediaQuery.of(context).size.height,
 | 
				
			||||||
 | 
					                child: PageView.builder(
 | 
				
			||||||
 | 
					                  controller: _pageController,
 | 
				
			||||||
 | 
					                  itemCount: mediaItems.length,
 | 
				
			||||||
 | 
					                  itemBuilder: (context, index) {
 | 
				
			||||||
 | 
					                    final item = mediaItems[index];
 | 
				
			||||||
 | 
					                    return Column(
 | 
				
			||||||
 | 
					                      children: [
 | 
				
			||||||
 | 
					                        if (item.mime.startsWith('image'))
 | 
				
			||||||
 | 
					                          Image.network(item.mediaUrl, fit: BoxFit.contain)
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                          VideoWidget(details: item),
 | 
				
			||||||
 | 
					                        const SizedBox(height: 20),
 | 
				
			||||||
 | 
					                        Text(
 | 
				
			||||||
 | 
					                          item.mime,
 | 
				
			||||||
 | 
					                          style: const TextStyle(
 | 
				
			||||||
 | 
					                            color: Colors.white,
 | 
				
			||||||
 | 
					                            fontSize: 18,
 | 
				
			||||||
 | 
					                          ),
 | 
				
			||||||
 | 
					                        ),
 | 
				
			||||||
 | 
					                        const SizedBox(height: 10),
 | 
				
			||||||
 | 
					                        Wrap(
 | 
				
			||||||
 | 
					                          alignment: WrapAlignment.center,
 | 
				
			||||||
 | 
					                          spacing: 5.0,
 | 
				
			||||||
 | 
					                          children: item.tags.map((tag) {
 | 
				
			||||||
 | 
					                            Color tagColor;
 | 
				
			||||||
 | 
					                            switch (tag.id) {
 | 
				
			||||||
 | 
					                              case 1:
 | 
				
			||||||
 | 
					                                tagColor = Colors.green;
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                              case 2:
 | 
				
			||||||
 | 
					                                tagColor = Colors.red;
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                              default:
 | 
				
			||||||
 | 
					                                tagColor = const Color(0xFF090909);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          final item = mediaItems[index];
 | 
					                            return Chip(
 | 
				
			||||||
          return SingleChildScrollView(
 | 
					                              label: Text(tag.tag),
 | 
				
			||||||
            child: Column(
 | 
					                              backgroundColor: tagColor,
 | 
				
			||||||
              mainAxisAlignment: MainAxisAlignment.start,
 | 
					                              labelStyle: const TextStyle(color: Colors.white),
 | 
				
			||||||
              crossAxisAlignment: CrossAxisAlignment.center,
 | 
					                            );
 | 
				
			||||||
              children: [
 | 
					                          }).toList(),
 | 
				
			||||||
                if (item.mime.startsWith('image')) ...[
 | 
					                        ),
 | 
				
			||||||
                  Image.network(
 | 
					                        const SizedBox(height: 40),
 | 
				
			||||||
                    item.mediaUrl,
 | 
					                      ],
 | 
				
			||||||
                    fit: BoxFit.contain,
 | 
					 | 
				
			||||||
                  ),
 | 
					 | 
				
			||||||
                ] else ...[
 | 
					 | 
				
			||||||
                  VideoWidget(details: item),
 | 
					 | 
				
			||||||
                ],
 | 
					 | 
				
			||||||
                const SizedBox(height: 20),
 | 
					 | 
				
			||||||
                Text(
 | 
					 | 
				
			||||||
                  item.mime,
 | 
					 | 
				
			||||||
                  style: const TextStyle(color: Colors.white, fontSize: 18),
 | 
					 | 
				
			||||||
                ),
 | 
					 | 
				
			||||||
                const SizedBox(height: 10),
 | 
					 | 
				
			||||||
                Wrap(
 | 
					 | 
				
			||||||
                  alignment: WrapAlignment.center,
 | 
					 | 
				
			||||||
                  spacing: 5.0,
 | 
					 | 
				
			||||||
                  children: item.tags.map((tag) {
 | 
					 | 
				
			||||||
                    Color tagColor;
 | 
					 | 
				
			||||||
                    switch (tag.id) {
 | 
					 | 
				
			||||||
                      case 1:
 | 
					 | 
				
			||||||
                        tagColor = Colors.green;
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                      case 2:
 | 
					 | 
				
			||||||
                        tagColor = Colors.red;
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                      default:
 | 
					 | 
				
			||||||
                        tagColor = Color(0xFF090909);
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    return Chip(
 | 
					 | 
				
			||||||
                      label: Text(tag.tag),
 | 
					 | 
				
			||||||
                      backgroundColor: tagColor,
 | 
					 | 
				
			||||||
                      labelStyle: const TextStyle(color: Colors.white),
 | 
					 | 
				
			||||||
                    );
 | 
					                    );
 | 
				
			||||||
                  }).toList(),
 | 
					                  },
 | 
				
			||||||
                ),
 | 
					                ),
 | 
				
			||||||
                const SizedBox(height: 40),
 | 
					              ),
 | 
				
			||||||
              ],
 | 
					            ],
 | 
				
			||||||
            ),
 | 
					          ),
 | 
				
			||||||
          );
 | 
					        ),
 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
      ),
 | 
					      ),
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,14 +2,21 @@ import 'dart:convert';
 | 
				
			|||||||
import 'package:http/http.dart' as http;
 | 
					import 'package:http/http.dart' as http;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import 'package:f0ckapp/models/mediaitem.dart';
 | 
					import 'package:f0ckapp/models/mediaitem.dart';
 | 
				
			||||||
//import 'package:f0ckapp/models/mediaitem_detail.dart';
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
Future<List<MediaItem>> fetchMedia({String? older, String? mode}) async {
 | 
					Future<List<MediaItem>> fetchMedia({
 | 
				
			||||||
  final Uri url = Uri.parse('https://api.f0ck.me/items/get')
 | 
					  String? older,
 | 
				
			||||||
    .replace(queryParameters: {
 | 
					  String? type,
 | 
				
			||||||
      'mode': mode ?? 'image',
 | 
					  int? mode,
 | 
				
			||||||
 | 
					  bool? random,
 | 
				
			||||||
 | 
					}) async {
 | 
				
			||||||
 | 
					  final Uri url = Uri.parse('https://api.f0ck.me/items/get').replace(
 | 
				
			||||||
 | 
					    queryParameters: {
 | 
				
			||||||
 | 
					      'type': type ?? 'image',
 | 
				
			||||||
 | 
					      'mode': (mode ?? 0).toString(),
 | 
				
			||||||
 | 
					      'random': (random! ? 1 : 0).toString(),
 | 
				
			||||||
      if (older != null) 'older': older,
 | 
					      if (older != null) 'older': older,
 | 
				
			||||||
    });
 | 
					    },
 | 
				
			||||||
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  final response = await http.get(url);
 | 
					  final response = await http.get(url);
 | 
				
			||||||
  if (response.statusCode == 200) {
 | 
					  if (response.statusCode == 200) {
 | 
				
			||||||
@@ -20,14 +27,17 @@ Future<List<MediaItem>> fetchMedia({String? older, String? mode}) async {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*Future<MediaItemDetail> fetchMediaDetail(int itemId) async {
 | 
					Future<MediaItem> fetchMediaDetail(int itemId) async {
 | 
				
			||||||
  final Uri url = Uri.parse('https://f0ck.me/api/v2/item/${itemId.toString()}');
 | 
					  final Uri url = Uri.parse('https://api.f0ck.me/item/${itemId.toString()}');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  final response = await http.get(url);
 | 
					  final response = await http.get(url);
 | 
				
			||||||
  if (response.statusCode == 200) {
 | 
					  if (response.statusCode == 200) {
 | 
				
			||||||
    final Map<String, dynamic> jsonResponse = jsonDecode(response.body);
 | 
					    final Map<String, dynamic> jsonResponse = jsonDecode(response.body);
 | 
				
			||||||
    return MediaItemDetail.fromJson(jsonResponse['rows']);
 | 
					
 | 
				
			||||||
 | 
					    return MediaItem.fromJson(jsonResponse);
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    throw Exception('Fehler beim Abrufen der Media-Details: ${response.statusCode}');
 | 
					    throw Exception(
 | 
				
			||||||
 | 
					      'Fehler beim Abrufen der Media-Details: ${response.statusCode}',
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}*/
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,7 +20,9 @@ class _VideoWidgetState extends State<VideoWidget> {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Future<void> _initController() async {
 | 
					  Future<void> _initController() async {
 | 
				
			||||||
    _controller = VideoPlayerController.networkUrl(Uri.parse(widget.details.mediaUrl));
 | 
					    _controller = VideoPlayerController.networkUrl(
 | 
				
			||||||
 | 
					      Uri.parse(widget.details.mediaUrl),
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
    await _controller.initialize();
 | 
					    await _controller.initialize();
 | 
				
			||||||
    setState(() {});
 | 
					    setState(() {});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -63,10 +65,7 @@ class _VideoWidgetState extends State<VideoWidget> {
 | 
				
			|||||||
                  });
 | 
					                  });
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                child: isAudio
 | 
					                child: isAudio
 | 
				
			||||||
                    ? Image.network(
 | 
					                    ? Image.network(widget.details.coverUrl, fit: BoxFit.cover)
 | 
				
			||||||
                        widget.details.coverUrl,
 | 
					 | 
				
			||||||
                        fit: BoxFit.cover,
 | 
					 | 
				
			||||||
                      )
 | 
					 | 
				
			||||||
                    : VideoPlayer(_controller),
 | 
					                    : VideoPlayer(_controller),
 | 
				
			||||||
              ),
 | 
					              ),
 | 
				
			||||||
              Align(
 | 
					              Align(
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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.0.12
 | 
					version: 1.0.15
 | 
				
			||||||
 | 
					
 | 
				
			||||||
environment:
 | 
					environment:
 | 
				
			||||||
  sdk: ^3.9.0-172.0.dev
 | 
					  sdk: ^3.9.0-172.0.dev
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user