This commit is contained in:
		@@ -105,9 +105,7 @@ class _DetailViewState extends ConsumerState<DetailView> {
 | 
			
		||||
 | 
			
		||||
    if (itemIndex == -1) {
 | 
			
		||||
      Future.microtask(() {
 | 
			
		||||
        ref
 | 
			
		||||
            .read(mediaProvider.notifier)
 | 
			
		||||
            .loadMedia(/*id: widget.initialItemId + 50*/);
 | 
			
		||||
        ref.read(mediaProvider.notifier).loadMedia(id: widget.initialItemId + 50);
 | 
			
		||||
      });
 | 
			
		||||
      return Scaffold(
 | 
			
		||||
        appBar: AppBar(),
 | 
			
		||||
@@ -125,113 +123,7 @@ class _DetailViewState extends ConsumerState<DetailView> {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return Scaffold(
 | 
			
		||||
      appBar: AppBar(
 | 
			
		||||
        centerTitle: true,
 | 
			
		||||
        title: Text('f0ck #${mediaState.mediaItems[_currentIndex].id}'),
 | 
			
		||||
        automaticallyImplyLeading: false,
 | 
			
		||||
        leading: IconButton(
 | 
			
		||||
          icon: const Icon(Icons.arrow_back),
 | 
			
		||||
          onPressed: () {
 | 
			
		||||
            context.canPop() ? context.pop() : context.go('/', extra: true);
 | 
			
		||||
          },
 | 
			
		||||
        ),
 | 
			
		||||
        actions: [
 | 
			
		||||
          IconButton(
 | 
			
		||||
            icon: const Icon(Icons.fullscreen),
 | 
			
		||||
            onPressed: () {
 | 
			
		||||
              final mediaState = ref.read(mediaProvider);
 | 
			
		||||
              final currentItem = mediaState.mediaItems[_currentIndex];
 | 
			
		||||
              Navigator.of(context).push(
 | 
			
		||||
                MaterialPageRoute(
 | 
			
		||||
                  builder: (_) => FullScreenMediaView(item: currentItem),
 | 
			
		||||
                ),
 | 
			
		||||
              );
 | 
			
		||||
            },
 | 
			
		||||
          ),
 | 
			
		||||
          IconButton(
 | 
			
		||||
            icon: const Icon(Icons.download),
 | 
			
		||||
            onPressed: _downloadMedia,
 | 
			
		||||
          ),
 | 
			
		||||
          PopupMenuButton<String>(
 | 
			
		||||
            onSelected: (value) async {
 | 
			
		||||
              final item = mediaState.mediaItems[_currentIndex];
 | 
			
		||||
              switch (value) {
 | 
			
		||||
                case 'media':
 | 
			
		||||
                  File file = await DefaultCacheManager().getSingleFile(
 | 
			
		||||
                    item.mediaUrl,
 | 
			
		||||
                  );
 | 
			
		||||
                  Uint8List bytes = await file.readAsBytes();
 | 
			
		||||
                  final params = ShareParams(
 | 
			
		||||
                    files: [XFile.fromData(bytes, mimeType: item.mime)],
 | 
			
		||||
                  );
 | 
			
		||||
                  await SharePlus.instance.share(params);
 | 
			
		||||
                  break;
 | 
			
		||||
                case 'direct_link':
 | 
			
		||||
                  await SharePlus.instance.share(
 | 
			
		||||
                    ShareParams(text: item.mediaUrl),
 | 
			
		||||
                  );
 | 
			
		||||
                  break;
 | 
			
		||||
                case 'post_link':
 | 
			
		||||
                  await SharePlus.instance.share(
 | 
			
		||||
                    ShareParams(text: item.postUrl),
 | 
			
		||||
                  );
 | 
			
		||||
                  break;
 | 
			
		||||
              }
 | 
			
		||||
            },
 | 
			
		||||
            itemBuilder: (context) => [
 | 
			
		||||
              PopupMenuItem(
 | 
			
		||||
                value: 'media',
 | 
			
		||||
                child: ListTile(
 | 
			
		||||
                  leading: const Icon(Icons.image),
 | 
			
		||||
                  title: const Text('Als Datei'),
 | 
			
		||||
                ),
 | 
			
		||||
              ),
 | 
			
		||||
              PopupMenuItem(
 | 
			
		||||
                value: 'direct_link',
 | 
			
		||||
                child: ListTile(
 | 
			
		||||
                  leading: const Icon(Icons.link),
 | 
			
		||||
                  title: const Text('Link zur Datei'),
 | 
			
		||||
                ),
 | 
			
		||||
              ),
 | 
			
		||||
              PopupMenuItem(
 | 
			
		||||
                value: 'post_link',
 | 
			
		||||
                child: ListTile(
 | 
			
		||||
                  leading: const Icon(Icons.article),
 | 
			
		||||
                  title: const Text('Link zum f0ck'),
 | 
			
		||||
                ),
 | 
			
		||||
              ),
 | 
			
		||||
            ],
 | 
			
		||||
            icon: const Icon(Icons.share),
 | 
			
		||||
          ),
 | 
			
		||||
          Builder(
 | 
			
		||||
            builder: (context) {
 | 
			
		||||
              return IconButton(
 | 
			
		||||
                icon: const Icon(Icons.menu),
 | 
			
		||||
                onPressed: () {
 | 
			
		||||
                  Scaffold.of(context).openEndDrawer();
 | 
			
		||||
                },
 | 
			
		||||
              );
 | 
			
		||||
            },
 | 
			
		||||
          ),
 | 
			
		||||
        ],
 | 
			
		||||
      ),
 | 
			
		||||
      endDrawer: EndDrawer(ref: ref),
 | 
			
		||||
      body: Stack(
 | 
			
		||||
        children: [
 | 
			
		||||
          PageTransformer(
 | 
			
		||||
            controller: _pageController!,
 | 
			
		||||
            pages: mediaState.mediaItems.map((item) {
 | 
			
		||||
              int itemIndex = mediaState.mediaItems.indexOf(item);
 | 
			
		||||
              return SafeArea(
 | 
			
		||||
                child: SmartRefreshIndicator(
 | 
			
		||||
                  onRefresh: _loadMoreMedia,
 | 
			
		||||
                  child: _buildMediaItem(item, _currentIndex == itemIndex),
 | 
			
		||||
                ),
 | 
			
		||||
              );
 | 
			
		||||
            }).toList(),
 | 
			
		||||
          ),
 | 
			
		||||
        ],
 | 
			
		||||
      ),
 | 
			
		||||
      persistentFooterButtons: mediaState.tag != null
 | 
			
		||||
          ? [
 | 
			
		||||
              Center(
 | 
			
		||||
@@ -245,6 +137,120 @@ class _DetailViewState extends ConsumerState<DetailView> {
 | 
			
		||||
              ),
 | 
			
		||||
            ]
 | 
			
		||||
          : null,
 | 
			
		||||
      body: CustomScrollView(
 | 
			
		||||
        slivers: [
 | 
			
		||||
          SliverAppBar(
 | 
			
		||||
            floating: true,
 | 
			
		||||
            pinned: true,
 | 
			
		||||
            snap: true,
 | 
			
		||||
            centerTitle: true,
 | 
			
		||||
            title: Text('f0ck #${mediaState.mediaItems[_currentIndex].id}'),
 | 
			
		||||
            leading: IconButton(
 | 
			
		||||
              icon: const Icon(Icons.arrow_back),
 | 
			
		||||
              onPressed: () {
 | 
			
		||||
                context.canPop() ? context.pop() : context.go('/', extra: true);
 | 
			
		||||
              },
 | 
			
		||||
            ),
 | 
			
		||||
            actions: [
 | 
			
		||||
              IconButton(
 | 
			
		||||
                icon: const Icon(Icons.fullscreen),
 | 
			
		||||
                onPressed: () {
 | 
			
		||||
                  final currentItem = mediaState.mediaItems[_currentIndex];
 | 
			
		||||
                  Navigator.of(context).push(
 | 
			
		||||
                    MaterialPageRoute(
 | 
			
		||||
                      builder: (_) => FullScreenMediaView(item: currentItem),
 | 
			
		||||
                    ),
 | 
			
		||||
                  );
 | 
			
		||||
                },
 | 
			
		||||
              ),
 | 
			
		||||
              IconButton(
 | 
			
		||||
                icon: const Icon(Icons.download),
 | 
			
		||||
                onPressed: _downloadMedia,
 | 
			
		||||
              ),
 | 
			
		||||
              PopupMenuButton<String>(
 | 
			
		||||
                onSelected: (value) async {
 | 
			
		||||
                  final item = mediaState.mediaItems[_currentIndex];
 | 
			
		||||
                  switch (value) {
 | 
			
		||||
                    case 'media':
 | 
			
		||||
                      File file = await DefaultCacheManager().getSingleFile(
 | 
			
		||||
                        item.mediaUrl,
 | 
			
		||||
                      );
 | 
			
		||||
                      Uint8List bytes = await file.readAsBytes();
 | 
			
		||||
                      final params = ShareParams(
 | 
			
		||||
                        files: [XFile.fromData(bytes, mimeType: item.mime)],
 | 
			
		||||
                      );
 | 
			
		||||
                      await SharePlus.instance.share(params);
 | 
			
		||||
                      break;
 | 
			
		||||
                    case 'direct_link':
 | 
			
		||||
                      await SharePlus.instance.share(
 | 
			
		||||
                        ShareParams(text: item.mediaUrl),
 | 
			
		||||
                      );
 | 
			
		||||
                      break;
 | 
			
		||||
                    case 'post_link':
 | 
			
		||||
                      await SharePlus.instance.share(
 | 
			
		||||
                        ShareParams(text: item.postUrl),
 | 
			
		||||
                      );
 | 
			
		||||
                      break;
 | 
			
		||||
                  }
 | 
			
		||||
                },
 | 
			
		||||
                itemBuilder: (context) => [
 | 
			
		||||
                  PopupMenuItem(
 | 
			
		||||
                    value: 'media',
 | 
			
		||||
                    child: ListTile(
 | 
			
		||||
                      leading: const Icon(Icons.image),
 | 
			
		||||
                      title: const Text('Als Datei'),
 | 
			
		||||
                    ),
 | 
			
		||||
                  ),
 | 
			
		||||
                  PopupMenuItem(
 | 
			
		||||
                    value: 'direct_link',
 | 
			
		||||
                    child: ListTile(
 | 
			
		||||
                      leading: const Icon(Icons.link),
 | 
			
		||||
                      title: const Text('Link zur Datei'),
 | 
			
		||||
                    ),
 | 
			
		||||
                  ),
 | 
			
		||||
                  PopupMenuItem(
 | 
			
		||||
                    value: 'post_link',
 | 
			
		||||
                    child: ListTile(
 | 
			
		||||
                      leading: const Icon(Icons.article),
 | 
			
		||||
                      title: const Text('Link zum f0ck'),
 | 
			
		||||
                    ),
 | 
			
		||||
                  ),
 | 
			
		||||
                ],
 | 
			
		||||
                icon: const Icon(Icons.share),
 | 
			
		||||
              ),
 | 
			
		||||
              Builder(
 | 
			
		||||
                builder: (context) => IconButton(
 | 
			
		||||
                  icon: const Icon(Icons.menu),
 | 
			
		||||
                  onPressed: () {
 | 
			
		||||
                    Scaffold.of(context).openEndDrawer();
 | 
			
		||||
                  },
 | 
			
		||||
                ),
 | 
			
		||||
              ),
 | 
			
		||||
            ],
 | 
			
		||||
            flexibleSpace: FlexibleSpaceBar(
 | 
			
		||||
              background: Container(color: Colors.transparent),
 | 
			
		||||
            ),
 | 
			
		||||
          ),
 | 
			
		||||
          SliverPadding(
 | 
			
		||||
            padding: EdgeInsets.zero,
 | 
			
		||||
            sliver: SliverFillRemaining(
 | 
			
		||||
              child: PageTransformer(
 | 
			
		||||
                controller: _pageController!,
 | 
			
		||||
                pages: mediaState.mediaItems.map((item) {
 | 
			
		||||
                  int pageIndex = mediaState.mediaItems.indexOf(item);
 | 
			
		||||
                  return SafeArea(
 | 
			
		||||
                    top: false,
 | 
			
		||||
                    child: SmartRefreshIndicator(
 | 
			
		||||
                      onRefresh: _loadMoreMedia,
 | 
			
		||||
                      child: _buildMediaItem(item, _currentIndex == pageIndex),
 | 
			
		||||
                    ),
 | 
			
		||||
                  );
 | 
			
		||||
                }).toList(),
 | 
			
		||||
              ),
 | 
			
		||||
            ),
 | 
			
		||||
          ),
 | 
			
		||||
        ],
 | 
			
		||||
      ),
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -258,8 +264,10 @@ class _DetailViewState extends ConsumerState<DetailView> {
 | 
			
		||||
            CachedNetworkImage(
 | 
			
		||||
              imageUrl: item.mediaUrl,
 | 
			
		||||
              fit: BoxFit.contain,
 | 
			
		||||
              placeholder: (context, url) => const CircularProgressIndicator(),
 | 
			
		||||
              errorWidget: (context, url, error) => const Icon(Icons.error),
 | 
			
		||||
              placeholder: (context, url) =>
 | 
			
		||||
                  const Center(child: CircularProgressIndicator()),
 | 
			
		||||
              errorWidget: (context, url, error) =>
 | 
			
		||||
                  const Center(child: Icon(Icons.error)),
 | 
			
		||||
            )
 | 
			
		||||
          else
 | 
			
		||||
            VideoWidget(details: item, isActive: isActive),
 | 
			
		||||
 
 | 
			
		||||
@@ -62,7 +62,7 @@ class _FullScreenMediaViewState extends State<FullScreenMediaView> {
 | 
			
		||||
            child: Align(
 | 
			
		||||
              alignment: Alignment.topLeft,
 | 
			
		||||
              child: IconButton(
 | 
			
		||||
                icon: const Icon(Icons.arrow_back),
 | 
			
		||||
                icon: const Icon(Icons.arrow_back, color: Colors.white),
 | 
			
		||||
                onPressed: () => Navigator.of(context).pop(),
 | 
			
		||||
              ),
 | 
			
		||||
            ),
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user