Compare commits

...

8 Commits

Author SHA1 Message Date
f1eb52518b v1.1.0+30
All checks were successful
Flutter Schmutter / build (push) Successful in 3m27s
2025-06-06 12:58:21 +02:00
c7d996a402 v1.0.29+29
All checks were successful
Flutter Schmutter / build (push) Successful in 3m28s
2025-06-06 11:29:01 +02:00
ee93ef576b xd 2025-06-06 10:10:40 +02:00
78ff1953ad v1.0.28+28
All checks were successful
Flutter Schmutter / build (push) Successful in 3m30s
2025-06-06 08:43:50 +02:00
6fb4775043 v1.0.27+27 -.-
All checks were successful
Flutter Schmutter / build (push) Successful in 3m20s
2025-06-05 21:59:02 +02:00
0d9ed1e6c1 v1.0.26+26
All checks were successful
Flutter Schmutter / build (push) Successful in 3m20s
2025-06-05 19:53:25 +02:00
bf77ccf8e3 actionchip lel 2025-06-05 11:15:16 +02:00
ae5f395331 1.0.25+25
All checks were successful
Flutter Schmutter / build (push) Successful in 3m16s
- preload adjacent media
2025-06-05 08:41:48 +02:00
18 changed files with 753 additions and 475 deletions

BIN
assets/images/menu.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -1,12 +1,27 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:f0ckapp/providers/MediaProvider.dart';
import 'package:f0ckapp/providers/ThemeProvider.dart';
import 'package:f0ckapp/screens/MediaGrid.dart';
import 'package:f0ckapp/utils/AppVersion.dart';
import 'package:provider/provider.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
runApp(const F0ckApp());
await AppVersion.init();
runApp(
MultiProvider(
providers: [
ChangeNotifierProvider(create: (context) => ThemeProvider()),
ChangeNotifierProvider(create: (context) => MediaProvider())
],
child: F0ckApp()
)
);
}
class F0ckApp extends StatelessWidget {
@ -14,11 +29,11 @@ class F0ckApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
final themeProvider = Provider.of<ThemeProvider>(context);
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
scaffoldBackgroundColor: const Color.fromARGB(255, 23, 23, 23),
),
theme: themeProvider.themeData,
home: Scaffold(
body: MediaGrid(),
),

View File

@ -34,6 +34,7 @@ class MediaItem {
String get thumbnailUrl => 'https://f0ck.me/t/$id.webp';
String get mediaUrl => 'https://f0ck.me/b/$dest';
String get coverUrl => 'https://f0ck.me/ca/$id.webp';
String get postUrl => 'https://f0ck.me/$id';
}
class Tag {

View File

@ -0,0 +1,95 @@
import 'package:f0ckapp/services/Api.dart';
import 'package:flutter/material.dart';
import 'package:f0ckapp/models/MediaItem.dart';
class MediaProvider extends ChangeNotifier {
int _typeid = 0;
int _mode = 0;
bool _random = false;
String? _tag;
int _crossAxisCount = 0;
List<MediaItem> _mediaItems = [];
bool _isLoading = false;
List<String> types = ["alles", "image", "video", "audio"];
List<String> modes = ["sfw", "nsfw", "untagged", "all"];
String get type => types[_typeid];
int get typeid => _typeid;
int get mode => _mode;
bool get random => _random;
String? get tag => _tag;
int get crossAxisCount => _crossAxisCount;
List<MediaItem> get mediaItems => _mediaItems;
bool get isLoading => _isLoading;
Function get resetMedia => _resetMedia;
void setType(String type) {
_typeid = types.indexOf(type);
_resetMedia();
}
void setMode(int mode) {
_mode = mode;
_resetMedia();
}
void toggleRandom() {
_random = !_random;
_resetMedia();
}
void setTag(String? tag) {
_tag = tag;
_resetMedia();
}
void setCrossAxisCount(int crossAxisCount) {
_crossAxisCount = crossAxisCount;
notifyListeners();
}
void setMediaItems(List<MediaItem> mediaItems) {
if (_mediaItems != mediaItems) {
_mediaItems.clear();
_mediaItems.addAll(mediaItems);
notifyListeners();
}
}
void addMediaItems(List<MediaItem> newItems) {
_mediaItems.addAll(newItems);
notifyListeners();
}
void _resetMedia() {
_mediaItems.clear();
notifyListeners();
loadMedia();
}
Future<void> loadMedia({bool notify = true}) async {
if (_isLoading) return;
_isLoading = true;
if (notify) notifyListeners();
try {
final newMedia = await fetchMedia(
older: _mediaItems.isNotEmpty ? _mediaItems.last.id : null,
type: type,
mode: mode,
random: random,
tag: tag,
);
if(_mediaItems != newMedia) {
addMediaItems(newMedia);
if (notify) notifyListeners();
}
} catch (e) {
debugPrint('Fehler beim Laden der Medien: $e');
} finally {
_isLoading = false;
}
}
}

View File

@ -0,0 +1,132 @@
import 'package:flutter/material.dart';
final ThemeData f0ckTheme = ThemeData(
brightness: Brightness.dark,
primaryColor: Color(0xFF9FFF00),
scaffoldBackgroundColor: Color(0xFF000000),
colorScheme: ColorScheme.dark(
primary: Color(0xFF9FFF00),
secondary: Color(0xFF262626),
surface: Color(0xFF232323),
onPrimary: Color(0xFF000000),
onSecondary: Color(0xFFFFFFFF),
onSurface: Color(0xFFFFFFFF),
),
appBarTheme: AppBarTheme(
backgroundColor: Color(0xFF2B2B2B),
foregroundColor: Color(0xFF9FFF00),
elevation: 2,
),
textTheme: TextTheme(
bodyLarge: TextStyle(fontFamily: 'VCR', color: Color(0xFFFFFFFF)),
bodyMedium: TextStyle(fontFamily: 'monospace', color: Color(0xFFFFFFFF)),
),
buttonTheme: ButtonThemeData(
buttonColor: Color(0xFF9FFF00),
textTheme: ButtonTextTheme.primary,
),
scrollbarTheme: ScrollbarThemeData(
thumbColor: WidgetStateProperty.all(Color(0xFF2B2B2B)),
trackColor: WidgetStateProperty.all(Color(0xFF424242)),
),
);
final ThemeData paperTheme = ThemeData(
brightness: Brightness.light,
primaryColor: Color(0xFF000000),
scaffoldBackgroundColor: Color(0xFFFFFFFF),
colorScheme: ColorScheme.light(
primary: Color(0xFF000000),
secondary: Color(0xFF262626),
surface: Color(0xFFFFFFFF),
onPrimary: Color(0xFFFFFFFF),
onSecondary: Color(0xFFFFFFFF),
onSurface: Color(0xFF000000),
),
appBarTheme: AppBarTheme(
backgroundColor: Color(0xFFFFFFFF),
foregroundColor: Color(0xFF000000),
elevation: 0,
),
textTheme: TextTheme(
bodyLarge: TextStyle(fontFamily: 'VCR', color: Color(0xFF000000)),
bodyMedium: TextStyle(fontFamily: 'monospace', color: Color(0xFF000000)),
),
buttonTheme: ButtonThemeData(
buttonColor: Color(0xFF000000),
textTheme: ButtonTextTheme.primary,
),
);
final ThemeData f0ck95Theme = ThemeData(
brightness: Brightness.light,
primaryColor: Color(0xFFC0C0C0),
scaffoldBackgroundColor: Color(0xFF008080),
colorScheme: ColorScheme.light(
primary: Color(0xFFC0C0C0),
secondary: Color(0xFF808080),
surface: Color(0xFFC0C0C0),
onPrimary: Color(0xFF000000),
onSecondary: Color(0xFFFFFFFF),
),
appBarTheme: AppBarTheme(
backgroundColor: Color(0xFFC0C0C0),
foregroundColor: Color(0xFF000000),
elevation: 2,
),
textTheme: TextTheme(
bodyLarge: TextStyle(fontFamily: 'VCR', color: Color(0xFF000000)),
bodyMedium: TextStyle(fontFamily: 'monospace', color: Color(0xFF000000)),
),
buttonTheme: ButtonThemeData(
buttonColor: Color(0xFF000000),
textTheme: ButtonTextTheme.primary,
),
scrollbarTheme: ScrollbarThemeData(
thumbColor: WidgetStateProperty.all(Color(0xFF2B2B2B)),
trackColor: WidgetStateProperty.all(Color(0xFF424242)),
),
);
final ThemeData f0ck95dTheme = ThemeData(
brightness: Brightness.dark,
primaryColor: Color(0xFFFFFFFF),
scaffoldBackgroundColor: Color(0xFF0E0F0F),
colorScheme: ColorScheme.dark(
primary: Color(0xFFFFFFFF),
secondary: Color(0xFFC0C0C0),
surface: Color(0xFF333131),
onPrimary: Color(0xFF000000),
onSecondary: Color(0xFFFFFFFF),
),
appBarTheme: AppBarTheme(
backgroundColor: Color(0xFF0B0A0A),
foregroundColor: Color(0xFFFFFFFF),
elevation: 2,
),
textTheme: TextTheme(
bodyLarge: TextStyle(fontFamily: 'VCR', color: Color(0xFFFFFFFF)),
bodyMedium: TextStyle(fontFamily: 'monospace', color: Color(0xFFFFFFFF)),
),
buttonTheme: ButtonThemeData(
buttonColor: Color(0xFFFFFFFF),
textTheme: ButtonTextTheme.primary,
),
scrollbarTheme: ScrollbarThemeData(
thumbColor: WidgetStateProperty.all(Color(0xFF2B2B2B)),
trackColor: WidgetStateProperty.all(Color(0xFF424242)),
),
);
class ThemeProvider extends ChangeNotifier {
ThemeData _themeData = f0ck95dTheme;
ThemeData get themeData => _themeData;
/*void toggleTheme() {
_themeData = _themeData == lightTheme ? darkTheme : lightTheme;
notifyListeners();
}*/
}

View File

@ -1,28 +1,21 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:provider/provider.dart';
import 'package:f0ckapp/models/MediaItem.dart';
import 'package:f0ckapp/services/Api.dart';
import 'package:f0ckapp/widgets/VideoWidget.dart';
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;
final List<MediaItem> mediaItems;
final String type;
final int mode;
final bool random;
final String? tagname;
const DetailView({
super.key,
required this.initialItemId,
required this.mediaItems,
required this.type,
required this.mode,
required this.random,
required this.tagname,
});
const DetailView({super.key, required this.initialItemId});
@override
State createState() => _DetailViewState();
@ -30,34 +23,42 @@ class DetailView extends StatefulWidget {
class _DetailViewState extends State<DetailView> {
late PageController _pageController;
late List<MediaItem> mediaItems;
String? _tagname;
int currentItemId = 0;
bool isLoading = false;
int _currentIndex = 0;
@override
void initState() {
super.initState();
mediaItems = widget.mediaItems;
_tagname = widget.tagname;
final initialIndex = mediaItems.indexWhere(
final provider = Provider.of<MediaProvider>(context, listen: false);
final initialIndex = provider.mediaItems.indexWhere(
(item) => item.id == widget.initialItemId,
);
_pageController = PageController(initialPage: initialIndex);
currentItemId = mediaItems[initialIndex].id;
_pageController.addListener(_onPageScroll);
_pageController = PageController(initialPage: initialIndex);
_currentIndex = initialIndex;
_pageController.addListener(() {
setState(() => _currentIndex = _pageController.page?.round() ?? 0);
});
_preloadAdjacentMedia(initialIndex);
}
void _onPageScroll() {
final newIndex = _pageController.page?.round();
if (newIndex != null && newIndex < mediaItems.length) {
setState(() => currentItemId = mediaItems[newIndex].id);
void _preloadAdjacentMedia(int index) async {
final provider = Provider.of<MediaProvider>(context, listen: false);
if (index + 1 < provider.mediaItems.length) {
final nextUrl = provider.mediaItems[index + 1].mediaUrl;
if (await DefaultCacheManager().getFileFromCache(nextUrl) == null) {
await DefaultCacheManager().downloadFile(nextUrl);
}
}
if (_pageController.position.pixels >=
_pageController.position.maxScrollExtent - 100) {
_loadMoreMedia();
if (index - 1 >= 0) {
final prevUrl = provider.mediaItems[index - 1].mediaUrl;
if (await DefaultCacheManager().getFileFromCache(prevUrl) == null) {
await DefaultCacheManager().downloadFile(prevUrl);
}
}
}
@ -65,114 +66,132 @@ class _DetailViewState extends State<DetailView> {
if (isLoading) return;
setState(() => isLoading = true);
final provider = Provider.of<MediaProvider>(context, listen: false);
try {
final newMedia = await fetchMedia(
older: mediaItems.last.id.toString(),
type: widget.type,
mode: widget.mode,
random: widget.random,
tag: _tagname,
older: provider.mediaItems.last.id,
type: provider.type,
mode: provider.mode,
random: provider.random,
tag: provider.tag,
);
if (mounted && newMedia.isNotEmpty) {
setState(() => mediaItems.addAll(newMedia));
setState(() => provider.mediaItems.addAll(newMedia));
}
} catch (e) {
_showError("Fehler beim Laden weiterer Medien: $e");
_showError("Fehler beim Laden der Medien: $e");
} finally {
setState(() => isLoading = false);
}
}
Future<void> _refreshMediaItem() async {
try {
final updatedItem = await fetchMediaDetail(currentItemId);
if (mounted) {
final index = mediaItems.indexWhere((item) => item.id == currentItemId);
if (index != -1) {
setState(() => mediaItems[index] = updatedItem);
}
}
} catch (e) {
_showError("Fehler beim Aktualisieren des Items: $e");
}
}
void _showError(String message) {
if (mounted) {
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text(message)));
}
if (!mounted) return;
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text(message)));
}
@override
Widget build(BuildContext context) {
final provider = Provider.of<MediaProvider>(context);
return Scaffold(
backgroundColor: const Color(0xFF171717),
appBar: AppBar(
backgroundColor: const Color(0xFF2B2B2B),
foregroundColor: Colors.white,
title: Text('f0ck #$currentItemId (${widget.type})'),
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(
controller: _pageController,
pages: mediaItems.map((item) {
return Scaffold(
body: SafeArea(
child: SmartRefreshIndicator(
onRefresh: _refreshMediaItem,
child: _buildMediaItem(item),
),
pages: provider.mediaItems.map((item) {
int itemIndex = provider.mediaItems.indexOf(item);
return SafeArea(
child: SmartRefreshIndicator(
onRefresh: _loadMoreMedia,
child: _buildMediaItem(item, _currentIndex == itemIndex),
),
);
}).toList(),
),
if (_tagname != null)
Positioned(
bottom: 60,
left: MediaQuery.of(context).size.width * 0.2,
right: MediaQuery.of(context).size.width * 0.2,
child: Container(
padding: const EdgeInsets.symmetric(
vertical: 10,
horizontal: 20,
),
decoration: BoxDecoration(
color: Colors.black.withValues(alpha: 0.8),
borderRadius: BorderRadius.circular(12),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Tag: $_tagname',
style: const TextStyle(color: Colors.white),
),
IconButton(
icon: const Icon(Icons.close, color: Colors.white),
onPressed: () {
setState(() {
_tagname = '___empty___';
Navigator.pop(context, _tagname);
});
},
),
],
),
),
),
],
),
persistentFooterButtons: provider.tag != null
? [
InputChip(
label: Text(provider.tag!),
backgroundColor: const Color(0xFF090909),
labelStyle: const TextStyle(color: Colors.white),
onDeleted: () {
provider.setTag(null);
Navigator.pop(context);
},
),
]
: null,
);
}
Widget _buildMediaItem(MediaItem item) {
Widget _buildMediaItem(MediaItem item, bool isActive) {
final provider = Provider.of<MediaProvider>(context);
return SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (item.mime.startsWith('image'))
CachedNetworkImage(
@ -182,34 +201,32 @@ class _DetailViewState extends State<DetailView> {
errorWidget: (context, url, error) => Icon(Icons.error),
)
else
VideoWidget(details: item),
const SizedBox(height: 20),
VideoWidget(details: item, isActive: isActive),
/*const SizedBox(height: 20),
Text(
item.mime,
'f0ck #${item.id.toString()}',
style: const TextStyle(color: Colors.white, fontSize: 18),
),
),*/
const SizedBox(height: 10, width: double.infinity),
Wrap(
alignment: WrapAlignment.center,
spacing: 5.0,
children: item.tags.map((tag) {
return GestureDetector(
onTap: () {
return ActionChip(
onPressed: () {
if (tag.tag == 'sfw' || tag.tag == 'nsfw') return;
setState(() {
_tagname = tag.tag;
Navigator.pop(context, _tagname);
provider.setTag(tag.tag);
Navigator.pop(context, true);
});
},
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),
),
label: Text(tag.tag),
backgroundColor: switch (tag.id) {
1 => Colors.green,
2 => Colors.red,
_ => const Color(0xFF090909),
},
labelStyle: const TextStyle(color: Colors.white),
);
}).toList(),
),

View File

@ -1,9 +1,9 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:f0ckapp/services/Api.dart';
import 'package:f0ckapp/models/MediaItem.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:provider/provider.dart';
import 'package:f0ckapp/screens/DetailView.dart';
import 'dart:async';
import 'package:f0ckapp/providers/MediaProvider.dart';
import 'package:f0ckapp/utils/AppVersion.dart';
class MediaGrid extends StatefulWidget {
const MediaGrid({super.key});
@ -14,256 +14,182 @@ class MediaGrid extends StatefulWidget {
class _MediaGridState extends State<MediaGrid> {
final ScrollController _scrollController = ScrollController();
final String _version = '1.0.24+24';
List<MediaItem> mediaItems = [];
bool isLoading = false;
Timer? _debounceTimer;
Completer<void>? _navigationCompleter;
int _crossAxisCount = 0;
String _selectedType = 'alles';
int _selectedMode = 0;
bool _random = false;
final List<String> _modes = ["sfw", "nsfw", "untagged", "all"];
String? _selectedTag;
@override
void initState() {
super.initState();
_loadMedia();
final provider = Provider.of<MediaProvider>(context, listen: false);
Future.microtask(() {
provider.loadMedia();
});
_scrollController.addListener(() {
if (_scrollController.position.pixels >=
_scrollController.position.maxScrollExtent - 100) {
_debounceLoadMedia();
_scrollController.position.maxScrollExtent - 200) {
provider.loadMedia(notify: false);
}
});
}
void _debounceLoadMedia() {
_debounceTimer?.cancel();
_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 {
if (isLoading) return;
setState(() => isLoading = true);
try {
final newMedia = await fetchMedia(
older: mediaItems.isNotEmpty ? mediaItems.last.id.toString() : null,
type: _selectedType,
mode: _selectedMode,
random: _random,
tag: _selectedTag,
);
if (mounted) {
setState(() => mediaItems.addAll(newMedia));
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Fehler beim Laden der Medien: $e')),
);
}
} finally {
if (mounted) setState(() => isLoading = false);
}
}
Future<void> _refreshMedia() async {
setState(() => isLoading = true);
try {
final freshMedia = await fetchMedia(
older: null,
type: _selectedType,
mode: _selectedMode,
random: _random,
tag: _selectedTag,
);
if (mounted) {
setState(() {
mediaItems.clear();
mediaItems.addAll(freshMedia);
});
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Fehler beim Aktualisieren: $e')),
);
}
} finally {
if (mounted) setState(() => isLoading = false);
}
}
Future<void> _navigateToDetail(MediaItem item) async {
if (_navigationCompleter?.isCompleted == false) return;
_navigationCompleter = Completer();
try {
if (mounted) {
final String? newTag = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DetailView(
initialItemId: item.id,
mediaItems: mediaItems,
type: _selectedType,
mode: _selectedMode,
random: _random,
tagname: _selectedTag,
),
),
);
if (newTag != null) {
setState(() {
if (newTag == '___empty___') {
_selectedTag = null;
}
else {
_selectedTag = newTag;
}
_refreshMedia();
});
}
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Fehler beim Laden der Details: $e')),
);
}
} finally {
_navigationCompleter?.complete();
}
int _calculateCrossAxisCount(BuildContext context, int defaultCount) {
return defaultCount == 0
? (MediaQuery.of(context).size.width / 110).clamp(3, 5).toInt()
: defaultCount;
}
@override
Widget build(BuildContext context) {
final provider = Provider.of<MediaProvider>(context);
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
return Scaffold(
key: scaffoldKey,
appBar: AppBar(
centerTitle: true,
backgroundColor: const Color.fromARGB(255, 43, 43, 43),
foregroundColor: const Color.fromARGB(255, 255, 255, 255),
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
//centerTitle: true,
title: Text('fApp v${AppVersion.version}'),
actions: [
IconButton(
icon: Icon(
provider.random ? Icons.shuffle_on_outlined : Icons.shuffle,
),
onPressed: () {
provider.toggleRandom();
_scrollController.jumpTo(0);
},
),
IconButton(
icon: const Icon(Icons.menu),
onPressed: () {
scaffoldKey.currentState?.openEndDrawer();
},
),
],
),
bottomNavigationBar: BottomAppBar(
height: 50,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text('f0ck v$_version'),
Checkbox(
value: _random,
onChanged: (bool? value) {
setState(() {
_random = !_random;
_refreshMedia();
});
Text('type: '),
DropdownButton<String>(
// type
value: provider.type,
isDense: true,
//icon: SizedBox.shrink(),
items: provider.types.map((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value, style: TextStyle(color: Colors.white)),
);
}).toList(),
onChanged: (String? newValue) {
if (newValue != null) {
provider.setType(newValue);
_scrollController.jumpTo(0);
}
},
),
Text('mode: '),
DropdownButton<String>(
// mode
value: provider.modes[provider.mode],
isDense: true,
//icon: SizedBox.shrink(),
items: provider.modes.map((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
onChanged: (String? newValue) {
if (newValue != null) {
provider.setMode(provider.modes.indexOf(newValue));
_scrollController.jumpTo(0);
}
},
),
],
),
),
bottomNavigationBar: BottomAppBar(
color: const Color.fromARGB(255, 43, 43, 43),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
DropdownButton<String>(
value: _selectedType,
dropdownColor: const Color.fromARGB(255, 43, 43, 43),
iconEnabledColor: Colors.white,
items: ["alles", "image", "video", "audio"].map((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value, style: TextStyle(color: Colors.white)),
);
}).toList(),
onChanged: (String? newValue) {
if (newValue != null) {
setState(() {
_selectedType = newValue;
_refreshMedia();
});
}
},
endDrawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
DrawerHeader(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/menu.webp'),
fit: BoxFit.cover,
alignment: Alignment.topCenter,
),
),
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();
});
}
},
),
DropdownButton<int>(
value: _crossAxisCount,
dropdownColor: const Color.fromARGB(255, 43, 43, 43),
iconEnabledColor: Colors.white,
items: [0, 3, 4].map((int value) {
return DropdownMenuItem<int>(
value: value,
child: Text(
value == 0 ? 'auto' : '$value Spalten',
style: TextStyle(color: Colors.white),
),
);
}).toList(),
onChanged: (int? newValue) {
if (newValue != null) {
setState(() {
_crossAxisCount = newValue;
});
}
},
),
],
),
child: null,
),
ListTile(
title: Text('v${AppVersion.version}'),
onTap: () {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('jooong lass das, hier ist nichts')),
);
},
),
],
),
),
body: Stack(
children: [
RefreshIndicator(
onRefresh: _refreshMedia,
child: GridView.builder(
persistentFooterButtons: provider.tag != null
? [
InputChip(
label: Text(provider.tag!),
backgroundColor: const Color(0xFF090909),
labelStyle: const TextStyle(color: Colors.white),
onDeleted: () {
provider.setTag(null);
_scrollController.jumpTo(0);
},
),
]
: null,
body: RefreshIndicator(
onRefresh: () async {
await provider.resetMedia();
_scrollController.jumpTo(0);
},
child: Consumer<MediaProvider>(
builder: (context, mediaProvider, child) {
return GridView.builder(
key: PageStorageKey('mediaGrid'),
controller: _scrollController,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: _calculateCrossAxisCount(context),
crossAxisCount: _calculateCrossAxisCount(
context,
provider.crossAxisCount,
),
crossAxisSpacing: 5.0,
mainAxisSpacing: 5.0,
),
itemCount: mediaItems.length + (isLoading ? 1 : 0),
itemCount:
provider.mediaItems.length + (provider.isLoading ? 1 : 0),
itemBuilder: (context, index) {
if (index >= mediaItems.length) {
if (index >= provider.mediaItems.length) {
return const Center(child: CircularProgressIndicator());
}
final item = mediaItems[index];
final item = provider.mediaItems[index];
return InkWell(
onTap: () => _navigateToDetail(item),
onTap: () async {
bool? ret = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
DetailView(initialItemId: item.id),
),
);
if (ret != null && ret) {
_scrollController.jumpTo(0);
}
},
child: Stack(
fit: StackFit.expand,
children: <Widget>[
@ -289,67 +215,10 @@ class _MediaGridState extends State<MediaGrid> {
),
);
},
),
),
if (_selectedTag != null)
Positioned(
bottom: 20,
left: MediaQuery.of(context).size.width * 0.2,
right: MediaQuery.of(context).size.width * 0.2,
child: Container(
padding: const EdgeInsets.symmetric(
vertical: 10,
horizontal: 20,
),
decoration: BoxDecoration(
color: Colors.black.withValues(alpha: 0.8),
borderRadius: BorderRadius.circular(12),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Tag: $_selectedTag',
style: const TextStyle(color: Colors.white),
),
IconButton(
icon: const Icon(Icons.close, color: Colors.white),
onPressed: () {
setState(() {
_selectedTag = null;
_refreshMedia();
});
_scrollController.animateTo(
0.0,
duration: const Duration(milliseconds: 500),
curve: Curves.easeOut,
);
},
),
],
),
),
),
],
);
},
),
),
/*floatingActionButton: FloatingActionButton(
backgroundColor: Colors.black.withValues(alpha: 0.8),
child: const Icon(Icons.arrow_upward, color: Colors.white),
onPressed: () {
_scrollController.animateTo(
0.0,
duration: const Duration(milliseconds: 500),
curve: Curves.easeOut,
);
},
),*/
);
}
@override
void dispose() {
_scrollController.dispose();
_debounceTimer?.cancel();
super.dispose();
}
}

View File

@ -4,7 +4,7 @@ import 'package:http/http.dart' as http;
import 'package:f0ckapp/models/MediaItem.dart';
Future<List<MediaItem>> fetchMedia({
String? older,
int? older,
String? type,
int? mode,
bool? random,
@ -16,7 +16,7 @@ Future<List<MediaItem>> fetchMedia({
'mode': (mode ?? 0).toString(),
'random': (random! ? 1 : 0).toString(),
if (tag != null) 'tag': tag,
if (older != null) 'older': older,
if (older != null) 'older': older.toString(),
},
);

10
lib/utils/AppVersion.dart Normal file
View File

@ -0,0 +1,10 @@
import 'package:package_info_plus/package_info_plus.dart';
class AppVersion {
static String version = "";
static Future<void> init() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
version = '${packageInfo.version}+${packageInfo.buildNumber}';
}
}

View File

@ -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)}";
}
}

View File

@ -7,7 +7,9 @@ import 'dart:async';
class VideoWidget extends StatefulWidget {
final MediaItem details;
const VideoWidget({super.key, required this.details});
final bool isActive;
const VideoWidget({super.key, required this.details, required this.isActive});
@override
State createState() => _VideoWidgetState();
@ -32,7 +34,9 @@ class _VideoWidgetState extends State<VideoWidget> {
setState(() {});
_controller.addListener(() => setState(() {}));
_controller.play();
if (widget.isActive) {
_controller.play();
}
_controller.setLooping(true);
}
@ -43,6 +47,16 @@ class _VideoWidgetState extends State<VideoWidget> {
super.dispose();
}
@override
void didUpdateWidget(VideoWidget oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.isActive) {
_controller.play();
} else {
_controller.pause();
}
}
void _onTap({bool ctrlButton = false}) {
if (!ctrlButton) {
setState(() => _showControls = !_showControls);
@ -50,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);
});
}
@ -81,7 +95,7 @@ class _VideoWidgetState extends State<VideoWidget> {
errorWidget: (context, url, error) => Image.asset(
'assets/images/music.webp',
fit: BoxFit.contain,
width: double.infinity
width: double.infinity,
),
)
: _controller.value.isInitialized

View File

@ -6,6 +6,10 @@
#include "generated_plugin_registrant.h"
#include <url_launcher_linux/url_launcher_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
}

View File

@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
url_launcher_linux
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST

View File

@ -5,12 +5,16 @@
import FlutterMacOS
import Foundation
import package_info_plus
import path_provider_foundation
import share_plus
import sqflite_darwin
import video_player_avfoundation
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin"))
}

View File

@ -73,6 +73,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.19.1"
cross_file:
dependency: transitive
description:
name: cross_file
sha256: "7caf6a750a0c04effbb52a676dce9a4a592e10ad35c34d6d2d0e4811160d5670"
url: "https://pub.dev"
source: hosted
version: "0.3.4+2"
crypto:
dependency: transitive
description:
@ -256,6 +264,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.16.0"
mime:
dependency: transitive
description:
name: mime
sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
nested:
dependency: transitive
description:
name: nested
sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
octo_image:
dependency: transitive
description:
@ -264,6 +288,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.0"
package_info_plus:
dependency: "direct main"
description:
name: package_info_plus
sha256: "7976bfe4c583170d6cdc7077e3237560b364149fcd268b5f53d95a991963b191"
url: "https://pub.dev"
source: hosted
version: "8.3.0"
package_info_plus_platform_interface:
dependency: transitive
description:
name: package_info_plus_platform_interface
sha256: "6c935fb612dff8e3cc9632c2b301720c77450a126114126ffaafe28d2e87956c"
url: "https://pub.dev"
source: hosted
version: "3.2.0"
path:
dependency: transitive
description:
@ -336,6 +376,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.8"
provider:
dependency: "direct main"
description:
name: provider
sha256: "4abbd070a04e9ddc287673bf5a030c7ca8b685ff70218720abab8b092f53dd84"
url: "https://pub.dev"
source: hosted
version: "6.1.5"
rxdart:
dependency: transitive
description:
@ -344,6 +392,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.28.0"
share_plus:
dependency: "direct main"
description:
name: share_plus
sha256: b2961506569e28948d75ec346c28775bb111986bb69dc6a20754a457e3d97fa0
url: "https://pub.dev"
source: hosted
version: "11.0.0"
share_plus_platform_interface:
dependency: transitive
description:
name: share_plus_platform_interface
sha256: "1032d392bc5d2095a77447a805aa3f804d2ae6a4d5eef5e6ebb3bd94c1bc19ef"
url: "https://pub.dev"
source: hosted
version: "6.0.0"
sky_engine:
dependency: transitive
description: flutter
@ -461,6 +525,38 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.4.0"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
sha256: "4e9ba368772369e3e08f231d2301b4ef72b9ff87c31192ef471b380ef29a4935"
url: "https://pub.dev"
source: hosted
version: "3.2.1"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
sha256: "4bd2b7b4dc4d4d0b94e5babfffbca8eac1a126c7f3d6ecbc1a11013faa3abba2"
url: "https://pub.dev"
source: hosted
version: "2.4.1"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
sha256: "3284b6d2ac454cf34f114e1d3319866fdd1e19cdc329999057e44ffe936cfa77"
url: "https://pub.dev"
source: hosted
version: "3.1.4"
uuid:
dependency: transitive
description:
@ -525,6 +621,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.1.1"
win32:
dependency: transitive
description:
name: win32
sha256: "329edf97fdd893e0f1e3b9e88d6a0e627128cc17cc316a8d67fda8f1451178ba"
url: "https://pub.dev"
source: hosted
version: "5.13.0"
xdg_directories:
dependency: transitive
description:

View File

@ -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
# 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.
version: 1.0.24+24
version: 1.1.0+30
environment:
sdk: ^3.9.0-100.2.beta
@ -37,6 +37,9 @@ dependencies:
cupertino_icons: ^1.0.8
cached_network_image: ^3.4.1
cached_video_player_plus: ^3.0.3
provider: ^6.1.5
package_info_plus: ^8.3.0
share_plus: ^11.0.0
dev_dependencies:
flutter_test:

View File

@ -6,6 +6,12 @@
#include "generated_plugin_registrant.h"
#include <share_plus/share_plus_windows_plugin_c_api.h>
#include <url_launcher_windows/url_launcher_windows.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
SharePlusWindowsPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi"));
UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
}

View File

@ -3,6 +3,8 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
share_plus
url_launcher_windows
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST