This commit is contained in:
@ -1,3 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@ -8,6 +10,7 @@ import 'package:f0ckapp/utils/SmartRefreshIndicator.dart';
|
||||
import 'package:f0ckapp/utils/PageTransformer.dart';
|
||||
import 'package:f0ckapp/providers/MediaProvider.dart';
|
||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
class DetailView extends StatefulWidget {
|
||||
final int initialItemId;
|
||||
@ -95,7 +98,62 @@ class _DetailViewState extends State<DetailView> {
|
||||
final provider = Provider.of<MediaProvider>(context);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(centerTitle: true, title: const Text('f0ck')),
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text(
|
||||
'f0ck #${provider.mediaItems.elementAt(_currentIndex).id.toString()}',
|
||||
),
|
||||
actions: [
|
||||
PopupMenuButton<String>(
|
||||
onSelected: (value) {
|
||||
final item = provider.mediaItems.elementAt(_currentIndex);
|
||||
switch (value) {
|
||||
case 'media':
|
||||
final params = ShareParams(
|
||||
files: [
|
||||
XFile.fromData(
|
||||
utf8.encode(item.mediaUrl),
|
||||
mimeType: item.mime,
|
||||
),
|
||||
],
|
||||
);
|
||||
SharePlus.instance.share(params);
|
||||
break;
|
||||
case 'direct_link':
|
||||
SharePlus.instance.share(ShareParams(text: item.mediaUrl));
|
||||
break;
|
||||
case 'post_link':
|
||||
SharePlus.instance.share(ShareParams(text: item.postUrl));
|
||||
break;
|
||||
}
|
||||
},
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: 'media',
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.image),
|
||||
title: Text('Als Datei'),
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'direct_link',
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.link),
|
||||
title: Text('Link zum Bild'),
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'post_link',
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.article),
|
||||
title: Text('Link zum Post'),
|
||||
),
|
||||
),
|
||||
],
|
||||
icon: Icon(Icons.share),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Stack(
|
||||
children: [
|
||||
PageTransformer(
|
||||
@ -115,20 +173,14 @@ class _DetailViewState extends State<DetailView> {
|
||||
),
|
||||
persistentFooterButtons: provider.tag != null
|
||||
? [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('tag: '),
|
||||
InputChip(
|
||||
label: Text(provider.tag!),
|
||||
backgroundColor: const Color(0xFF090909),
|
||||
labelStyle: const TextStyle(color: Colors.white),
|
||||
onDeleted: () {
|
||||
provider.setTag(null);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
InputChip(
|
||||
label: Text(provider.tag!),
|
||||
backgroundColor: const Color(0xFF090909),
|
||||
labelStyle: const TextStyle(color: Colors.white),
|
||||
onDeleted: () {
|
||||
provider.setTag(null);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
]
|
||||
: null,
|
||||
@ -150,11 +202,11 @@ class _DetailViewState extends State<DetailView> {
|
||||
)
|
||||
else
|
||||
VideoWidget(details: item, isActive: isActive),
|
||||
const SizedBox(height: 20),
|
||||
/*const SizedBox(height: 20),
|
||||
Text(
|
||||
'f0ck #${item.id.toString()}',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 18),
|
||||
),
|
||||
),*/
|
||||
const SizedBox(height: 10, width: double.infinity),
|
||||
Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
|
@ -33,8 +33,10 @@ class _MediaGridState extends State<MediaGrid> {
|
||||
});
|
||||
}
|
||||
|
||||
void scrollToTop() {
|
||||
_scrollController.jumpTo(0);
|
||||
int _calculateCrossAxisCount(BuildContext context, int defaultCount) {
|
||||
return defaultCount == 0
|
||||
? (MediaQuery.of(context).size.width / 110).clamp(3, 5).toInt()
|
||||
: defaultCount;
|
||||
}
|
||||
|
||||
@override
|
||||
@ -116,28 +118,36 @@ class _MediaGridState extends State<MediaGrid> {
|
||||
padding: EdgeInsets.zero,
|
||||
children: [
|
||||
DrawerHeader(
|
||||
padding: EdgeInsets.all(0),
|
||||
child: Image.asset('assets/images/menu.webp', fit: BoxFit.cover),
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/images/menu.webp'),
|
||||
fit: BoxFit.cover,
|
||||
alignment: Alignment.topCenter,
|
||||
),
|
||||
),
|
||||
child: null,
|
||||
),
|
||||
ListTile(
|
||||
title: Text('v${AppVersion.version}'),
|
||||
onTap: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('jooong lass das, hier ist nichts')),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
persistentFooterButtons: provider.tag != null
|
||||
? [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('tag: '),
|
||||
InputChip(
|
||||
label: Text(provider.tag!),
|
||||
backgroundColor: const Color(0xFF090909),
|
||||
labelStyle: const TextStyle(color: Colors.white),
|
||||
onDeleted: () {
|
||||
provider.setTag(null);
|
||||
_scrollController.jumpTo(0);
|
||||
},
|
||||
),
|
||||
],
|
||||
InputChip(
|
||||
label: Text(provider.tag!),
|
||||
backgroundColor: const Color(0xFF090909),
|
||||
labelStyle: const TextStyle(color: Colors.white),
|
||||
onDeleted: () {
|
||||
provider.setTag(null);
|
||||
_scrollController.jumpTo(0);
|
||||
},
|
||||
),
|
||||
]
|
||||
: null,
|
||||
@ -152,11 +162,10 @@ class _MediaGridState extends State<MediaGrid> {
|
||||
key: PageStorageKey('mediaGrid'),
|
||||
controller: _scrollController,
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: mediaProvider.crossAxisCount == 0
|
||||
? (MediaQuery.of(context).size.width / 110)
|
||||
.clamp(3, 5)
|
||||
.toInt()
|
||||
: mediaProvider.crossAxisCount,
|
||||
crossAxisCount: _calculateCrossAxisCount(
|
||||
context,
|
||||
provider.crossAxisCount,
|
||||
),
|
||||
crossAxisSpacing: 5.0,
|
||||
mainAxisSpacing: 5.0,
|
||||
),
|
||||
@ -170,14 +179,15 @@ class _MediaGridState extends State<MediaGrid> {
|
||||
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
bool test = await Navigator.push(
|
||||
bool? ret = await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => DetailView(initialItemId: item.id),
|
||||
builder: (context) =>
|
||||
DetailView(initialItemId: item.id),
|
||||
),
|
||||
);
|
||||
if (test) {
|
||||
scrollToTop();
|
||||
if (ret != null && ret) {
|
||||
_scrollController.jumpTo(0);
|
||||
}
|
||||
},
|
||||
child: Stack(
|
||||
|
Reference in New Issue
Block a user