Compare commits
14 Commits
v1.0.21+21
...
v1.0.26+26
Author | SHA1 | Date | |
---|---|---|---|
0d9ed1e6c1 | |||
bf77ccf8e3 | |||
ae5f395331 | |||
05484b342a | |||
97d9259fab | |||
b69a9843a7 | |||
acacdef003 | |||
3699e62efc | |||
666a02d293 | |||
28c4a17c43 | |||
189f9a6efd | |||
7130ad9817 | |||
c236049c0a | |||
003797981e |
@ -13,6 +13,13 @@ jobs:
|
|||||||
- name: checkout code
|
- name: checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: cache pub deps
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ~/.pub-cache
|
||||||
|
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }}
|
||||||
|
restore-keys: ${{ runner.os }}-pub-
|
||||||
|
|
||||||
- name: set up jdk
|
- name: set up jdk
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
|
BIN
assets/images/menu.webp
Normal file
BIN
assets/images/menu.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
assets/images/music.webp
Normal file
BIN
assets/images/music.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 634 KiB |
@ -1,12 +1,25 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
import 'package:f0ckapp/mediagrid.dart';
|
import 'package:f0ckapp/providers/MediaProvider.dart';
|
||||||
|
import 'package:f0ckapp/providers/ThemeProvider.dart';
|
||||||
|
import 'package:f0ckapp/screens/MediaGrid.dart';
|
||||||
|
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||||
runApp(const F0ckApp());
|
|
||||||
|
runApp(
|
||||||
|
MultiProvider(
|
||||||
|
providers: [
|
||||||
|
ChangeNotifierProvider(create: (context) => ThemeProvider()),
|
||||||
|
ChangeNotifierProvider(create: (context) => MediaProvider())
|
||||||
|
],
|
||||||
|
child: F0ckApp()
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class F0ckApp extends StatelessWidget {
|
class F0ckApp extends StatelessWidget {
|
||||||
@ -14,11 +27,11 @@ class F0ckApp extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final themeProvider = Provider.of<ThemeProvider>(context);
|
||||||
|
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
theme: ThemeData(
|
theme: themeProvider.themeData,
|
||||||
scaffoldBackgroundColor: const Color.fromARGB(255, 23, 23, 23),
|
|
||||||
),
|
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
body: MediaGrid(),
|
body: MediaGrid(),
|
||||||
),
|
),
|
||||||
|
@ -1,285 +0,0 @@
|
|||||||
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:f0ckapp/screens/detailview.dart';
|
|
||||||
import 'dart:async';
|
|
||||||
|
|
||||||
class MediaGrid extends StatefulWidget {
|
|
||||||
const MediaGrid({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State createState() => _MediaGridState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MediaGridState extends State<MediaGrid> {
|
|
||||||
final ScrollController _scrollController = ScrollController();
|
|
||||||
final String _version = '1.0.21+21';
|
|
||||||
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"];
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_loadMedia();
|
|
||||||
_scrollController.addListener(() {
|
|
||||||
if (_scrollController.position.pixels >=
|
|
||||||
_scrollController.position.maxScrollExtent - 100) {
|
|
||||||
_debounceLoadMedia();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
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,
|
|
||||||
);
|
|
||||||
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,
|
|
||||||
);
|
|
||||||
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) {
|
|
||||||
await Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => DetailView(
|
|
||||||
initialItemId: item.id,
|
|
||||||
mediaItems: mediaItems,
|
|
||||||
type: _selectedType,
|
|
||||||
mode: _selectedMode,
|
|
||||||
random: _random,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
if (mounted) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text('Fehler beim Laden der Details: $e')),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
_navigationCompleter?.complete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
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,
|
|
||||||
children: [
|
|
||||||
Text('f0ck v$_version'),
|
|
||||||
Checkbox(
|
|
||||||
value: _random,
|
|
||||||
onChanged: (bool? value) {
|
|
||||||
setState(() {
|
|
||||||
_random = !_random;
|
|
||||||
_refreshMedia();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
),
|
|
||||||
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();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
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;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
body: RefreshIndicator(
|
|
||||||
onRefresh: _refreshMedia,
|
|
||||||
child: GridView.builder(
|
|
||||||
controller: _scrollController,
|
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
||||||
crossAxisCount: _calculateCrossAxisCount(context),
|
|
||||||
crossAxisSpacing: 5.0,
|
|
||||||
mainAxisSpacing: 5.0,
|
|
||||||
),
|
|
||||||
itemCount: mediaItems.length + (isLoading ? 1 : 0),
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
if (index >= mediaItems.length) {
|
|
||||||
return const Center(child: CircularProgressIndicator());
|
|
||||||
}
|
|
||||||
final item = mediaItems[index];
|
|
||||||
|
|
||||||
return InkWell(
|
|
||||||
onTap: () => _navigateToDetail(item),
|
|
||||||
child: Stack(
|
|
||||||
fit: StackFit.expand,
|
|
||||||
children: <Widget>[
|
|
||||||
CachedNetworkImage(
|
|
||||||
imageUrl: item.thumbnailUrl,
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
placeholder: (context, url) => CircularProgressIndicator(),
|
|
||||||
errorWidget: (context, url, error) => Icon(Icons.error),
|
|
||||||
),
|
|
||||||
Align(
|
|
||||||
alignment: FractionalOffset.bottomRight,
|
|
||||||
child: Icon(
|
|
||||||
Icons.square,
|
|
||||||
color: switch (item.mode) {
|
|
||||||
1 => Colors.green,
|
|
||||||
2 => Colors.red,
|
|
||||||
_ => Colors.yellow
|
|
||||||
},
|
|
||||||
size: 15.0
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_scrollController.dispose();
|
|
||||||
_debounceTimer?.cancel();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
88
lib/providers/MediaProvider.dart
Normal file
88
lib/providers/MediaProvider.dart
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
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;
|
||||||
|
final 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;
|
||||||
|
|
||||||
|
void setType(String type) {
|
||||||
|
_typeid = types.indexOf(type);
|
||||||
|
loadMedia(reload: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setMode(int mode) {
|
||||||
|
_mode = mode;
|
||||||
|
loadMedia(reload: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void toggleRandom() {
|
||||||
|
_random = !_random;
|
||||||
|
loadMedia(reload: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setTag(String? tag) {
|
||||||
|
_tag = tag;
|
||||||
|
loadMedia(reload: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setCrossAxisCount(int crossAxisCount) {
|
||||||
|
_crossAxisCount = crossAxisCount;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setMediaItems(List<MediaItem> mediaItems) {
|
||||||
|
_mediaItems.clear();
|
||||||
|
addMediaItems(mediaItems);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void addMediaItems(List<MediaItem> newItems) {
|
||||||
|
_mediaItems.addAll(newItems);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> loadMedia({bool reload = false}) async {
|
||||||
|
if (_isLoading) return;
|
||||||
|
_isLoading = true;
|
||||||
|
notifyListeners();
|
||||||
|
|
||||||
|
try {
|
||||||
|
final newMedia = await fetchMedia(
|
||||||
|
older: reload
|
||||||
|
? null
|
||||||
|
: _mediaItems.isNotEmpty
|
||||||
|
? _mediaItems.last.id
|
||||||
|
: null,
|
||||||
|
type: type,
|
||||||
|
mode: mode,
|
||||||
|
random: random,
|
||||||
|
tag: tag,
|
||||||
|
);
|
||||||
|
|
||||||
|
reload ? setMediaItems(newMedia) : addMediaItems(newMedia);
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint('Fehler beim Laden der Medien: $e');
|
||||||
|
} finally {
|
||||||
|
_isLoading = false;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
132
lib/providers/ThemeProvider.dart
Normal file
132
lib/providers/ThemeProvider.dart
Normal 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();
|
||||||
|
}*/
|
||||||
|
}
|
180
lib/screens/DetailView.dart
Normal file
180
lib/screens/DetailView.dart
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
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';
|
||||||
|
|
||||||
|
class DetailView extends StatefulWidget {
|
||||||
|
final int initialItemId;
|
||||||
|
|
||||||
|
const DetailView({super.key, required this.initialItemId});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State createState() => _DetailViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DetailViewState extends State<DetailView> {
|
||||||
|
late PageController _pageController;
|
||||||
|
bool isLoading = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
final provider = Provider.of<MediaProvider>(context, listen: false);
|
||||||
|
|
||||||
|
final initialIndex = provider.mediaItems.indexWhere(
|
||||||
|
(item) => item.id == widget.initialItemId,
|
||||||
|
);
|
||||||
|
_pageController = PageController(initialPage: initialIndex);
|
||||||
|
|
||||||
|
_preloadAdjacentMedia(initialIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 (index - 1 >= 0) {
|
||||||
|
final prevUrl = provider.mediaItems[index - 1].mediaUrl;
|
||||||
|
if (await DefaultCacheManager().getFileFromCache(prevUrl) == null) {
|
||||||
|
await DefaultCacheManager().downloadFile(prevUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadMoreMedia() async {
|
||||||
|
if (isLoading) return;
|
||||||
|
setState(() => isLoading = true);
|
||||||
|
|
||||||
|
final provider = Provider.of<MediaProvider>(context, listen: false);
|
||||||
|
|
||||||
|
try {
|
||||||
|
final newMedia = await fetchMedia(
|
||||||
|
older: provider.mediaItems.last.id,
|
||||||
|
type: provider.type,
|
||||||
|
mode: provider.mode,
|
||||||
|
random: provider.random,
|
||||||
|
tag: provider.tag,
|
||||||
|
);
|
||||||
|
if (mounted && newMedia.isNotEmpty) {
|
||||||
|
setState(() => provider.mediaItems.addAll(newMedia));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_showError("Fehler beim Laden der Medien: $e");
|
||||||
|
} finally {
|
||||||
|
setState(() => isLoading = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showError(String 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(
|
||||||
|
appBar: AppBar(
|
||||||
|
centerTitle: true,
|
||||||
|
title: Text('f0ck #${widget.initialItemId} (${provider.type})'),
|
||||||
|
),
|
||||||
|
body: Stack(
|
||||||
|
children: [
|
||||||
|
PageTransformer(
|
||||||
|
controller: _pageController,
|
||||||
|
pages: provider.mediaItems.map((item) {
|
||||||
|
return SafeArea(
|
||||||
|
child: SmartRefreshIndicator(
|
||||||
|
onRefresh: _loadMoreMedia,
|
||||||
|
child: _buildMediaItem(item),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
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);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
|
: null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildMediaItem(MediaItem item) {
|
||||||
|
final provider = Provider.of<MediaProvider>(context);
|
||||||
|
|
||||||
|
return SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
if (item.mime.startsWith('image'))
|
||||||
|
CachedNetworkImage(
|
||||||
|
imageUrl: item.mediaUrl,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
placeholder: (context, url) => CircularProgressIndicator(),
|
||||||
|
errorWidget: (context, url, error) => Icon(Icons.error),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
VideoWidget(details: item, isActive: true),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Text(
|
||||||
|
item.mime,
|
||||||
|
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 ActionChip(
|
||||||
|
onPressed: () {
|
||||||
|
if (tag.tag == 'sfw' || tag.tag == 'nsfw') return;
|
||||||
|
setState(() {
|
||||||
|
provider.setTag(tag.tag);
|
||||||
|
Navigator.pop(context);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
label: Text(tag.tag),
|
||||||
|
backgroundColor: switch (tag.id) {
|
||||||
|
1 => Colors.green,
|
||||||
|
2 => Colors.red,
|
||||||
|
_ => const Color(0xFF090909),
|
||||||
|
},
|
||||||
|
labelStyle: const TextStyle(color: Colors.white),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
217
lib/screens/MediaGrid.dart
Normal file
217
lib/screens/MediaGrid.dart
Normal file
@ -0,0 +1,217 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:f0ckapp/screens/DetailView.dart';
|
||||||
|
import 'package:f0ckapp/services/Api.dart';
|
||||||
|
import 'package:f0ckapp/providers/MediaProvider.dart';
|
||||||
|
|
||||||
|
class MediaGrid extends StatefulWidget {
|
||||||
|
const MediaGrid({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State createState() => _MediaGridState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MediaGridState extends State<MediaGrid> {
|
||||||
|
final ScrollController _scrollController = ScrollController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
final provider = Provider.of<MediaProvider>(context, listen: false);
|
||||||
|
|
||||||
|
Future.microtask(() {
|
||||||
|
provider.loadMedia();
|
||||||
|
});
|
||||||
|
|
||||||
|
_scrollController.addListener(() {
|
||||||
|
if (_scrollController.position.pixels >=
|
||||||
|
_scrollController.position.maxScrollExtent - 100) {
|
||||||
|
provider.loadMedia();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@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,
|
||||||
|
title: Text('f0ck v1.0.26+26'),
|
||||||
|
actions: [
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.menu),
|
||||||
|
onPressed: () {
|
||||||
|
scaffoldKey.currentState?.openEndDrawer();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
endDrawer: Drawer(
|
||||||
|
child: ListView(
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
children: [
|
||||||
|
DrawerHeader(
|
||||||
|
padding: EdgeInsets.all(0),
|
||||||
|
child: Image.asset('assets/images/menu.webp', fit: BoxFit.cover),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
'All',
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: provider.type == 'alles'
|
||||||
|
? FontWeight.bold
|
||||||
|
: FontWeight.normal,
|
||||||
|
color: provider.type == 'alles' ? Colors.blue : Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
provider.setType('all');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
'Images',
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: provider.type == 'image'
|
||||||
|
? FontWeight.bold
|
||||||
|
: FontWeight.normal,
|
||||||
|
color: provider.type == 'image' ? Colors.blue : Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
provider.setType('image');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
'Videos',
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: provider.type == 'video'
|
||||||
|
? FontWeight.bold
|
||||||
|
: FontWeight.normal,
|
||||||
|
color: provider.type == 'video' ? Colors.blue : Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
provider.setType('video');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
'Audio',
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: provider.type == 'audio'
|
||||||
|
? FontWeight.bold
|
||||||
|
: FontWeight.normal,
|
||||||
|
color: provider.type == 'audio' ? Colors.blue : Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
provider.setType('audio');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
|
: null,
|
||||||
|
body: RefreshIndicator(
|
||||||
|
onRefresh: () async {
|
||||||
|
await provider.loadMedia(reload: true);
|
||||||
|
},
|
||||||
|
child: Consumer<MediaProvider>(
|
||||||
|
builder: (context, mediaProvider, child) {
|
||||||
|
return GridView.builder(
|
||||||
|
controller: _scrollController,
|
||||||
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
|
crossAxisCount: mediaProvider.crossAxisCount == 0
|
||||||
|
? (MediaQuery.of(context).size.width / 110)
|
||||||
|
.clamp(3, 5)
|
||||||
|
.toInt()
|
||||||
|
: mediaProvider.crossAxisCount,
|
||||||
|
crossAxisSpacing: 5.0,
|
||||||
|
mainAxisSpacing: 5.0,
|
||||||
|
),
|
||||||
|
itemCount:
|
||||||
|
provider.mediaItems.length + (provider.isLoading ? 1 : 0),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if (index >= provider.mediaItems.length) {
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
}
|
||||||
|
final item = provider.mediaItems[index];
|
||||||
|
|
||||||
|
return InkWell(
|
||||||
|
onTap: () => Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => DetailView(initialItemId: item.id),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Stack(
|
||||||
|
fit: StackFit.expand,
|
||||||
|
children: <Widget>[
|
||||||
|
CachedNetworkImage(
|
||||||
|
imageUrl: item.thumbnailUrl,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
placeholder: (context, url) => SizedBox.shrink(),
|
||||||
|
errorWidget: (context, url, error) => Icon(Icons.error),
|
||||||
|
),
|
||||||
|
Align(
|
||||||
|
alignment: FractionalOffset.bottomRight,
|
||||||
|
child: Icon(
|
||||||
|
Icons.square,
|
||||||
|
color: switch (item.mode) {
|
||||||
|
1 => Colors.green,
|
||||||
|
2 => Colors.red,
|
||||||
|
_ => Colors.yellow,
|
||||||
|
},
|
||||||
|
size: 15.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,169 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
|
||||||
import 'package:f0ckapp/models/mediaitem.dart';
|
|
||||||
import 'package:f0ckapp/services/api.dart';
|
|
||||||
import 'package:f0ckapp/widgets/video_widget.dart';
|
|
||||||
import 'package:f0ckapp/utils/SmartRefreshIndicator.dart';
|
|
||||||
|
|
||||||
class DetailView extends StatefulWidget {
|
|
||||||
final int initialItemId;
|
|
||||||
final List<MediaItem> mediaItems;
|
|
||||||
final String type;
|
|
||||||
final int mode;
|
|
||||||
final bool random;
|
|
||||||
|
|
||||||
const DetailView({
|
|
||||||
super.key,
|
|
||||||
required this.initialItemId,
|
|
||||||
required this.mediaItems,
|
|
||||||
required this.type,
|
|
||||||
required this.mode,
|
|
||||||
required this.random,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State createState() => _DetailViewState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _DetailViewState extends State<DetailView> {
|
|
||||||
late PageController _pageController;
|
|
||||||
late List<MediaItem> mediaItems;
|
|
||||||
int currentItemId = 0;
|
|
||||||
bool isLoading = false;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
mediaItems = widget.mediaItems;
|
|
||||||
final initialIndex = mediaItems.indexWhere(
|
|
||||||
(item) => item.id == widget.initialItemId,
|
|
||||||
);
|
|
||||||
_pageController = PageController(initialPage: initialIndex);
|
|
||||||
currentItemId = mediaItems[initialIndex].id;
|
|
||||||
|
|
||||||
_pageController.addListener(_onPageScroll);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onPageScroll() {
|
|
||||||
final newIndex = _pageController.page?.round();
|
|
||||||
if (newIndex != null && newIndex < mediaItems.length) {
|
|
||||||
setState(() => currentItemId = mediaItems[newIndex].id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_pageController.position.pixels >=
|
|
||||||
_pageController.position.maxScrollExtent - 100) {
|
|
||||||
_loadMoreMedia();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _loadMoreMedia() async {
|
|
||||||
if (isLoading) return;
|
|
||||||
setState(() => isLoading = true);
|
|
||||||
|
|
||||||
try {
|
|
||||||
final newMedia = await fetchMedia(
|
|
||||||
older: mediaItems.last.id.toString(),
|
|
||||||
type: widget.type,
|
|
||||||
mode: widget.mode,
|
|
||||||
random: widget.random,
|
|
||||||
);
|
|
||||||
if (mounted && newMedia.isNotEmpty) {
|
|
||||||
setState(() => mediaItems.addAll(newMedia));
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
_showError("Fehler beim Laden weiterer 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)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: const Color(0xFF171717),
|
|
||||||
appBar: AppBar(
|
|
||||||
backgroundColor: const Color(0xFF2B2B2B),
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
title: Text('f0ck #$currentItemId (${widget.type})'),
|
|
||||||
centerTitle: true,
|
|
||||||
),
|
|
||||||
body: PageView.builder(
|
|
||||||
controller: _pageController,
|
|
||||||
itemCount: mediaItems.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final MediaItem item = mediaItems[index];
|
|
||||||
return Scaffold(
|
|
||||||
body: SafeArea(
|
|
||||||
child: SmartRefreshIndicator(
|
|
||||||
onRefresh: _refreshMediaItem,
|
|
||||||
child: _buildMediaItem(item)
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildMediaItem(MediaItem item) {
|
|
||||||
return SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
if (item.mime.startsWith('image'))
|
|
||||||
CachedNetworkImage(
|
|
||||||
imageUrl: item.mediaUrl,
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
placeholder: (context, url) => CircularProgressIndicator(),
|
|
||||||
errorWidget: (context, url, error) => Icon(Icons.error),
|
|
||||||
)
|
|
||||||
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) {
|
|
||||||
return Chip(
|
|
||||||
label: Text(tag.tag),
|
|
||||||
backgroundColor: switch (tag.id) {
|
|
||||||
1 => Colors.green,
|
|
||||||
2 => Colors.red,
|
|
||||||
_ => const Color(0xFF090909)
|
|
||||||
},
|
|
||||||
labelStyle: const TextStyle(color: Colors.white),
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +1,22 @@
|
|||||||
import 'dart:convert';
|
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';
|
||||||
|
|
||||||
Future<List<MediaItem>> fetchMedia({
|
Future<List<MediaItem>> fetchMedia({
|
||||||
String? older,
|
int? older,
|
||||||
String? type,
|
String? type,
|
||||||
int? mode,
|
int? mode,
|
||||||
bool? random,
|
bool? random,
|
||||||
|
String? tag,
|
||||||
}) async {
|
}) async {
|
||||||
final Uri url = Uri.parse('https://api.f0ck.me/items/get').replace(
|
final Uri url = Uri.parse('https://api.f0ck.me/items/get').replace(
|
||||||
queryParameters: {
|
queryParameters: {
|
||||||
'type': type ?? 'image',
|
'type': type ?? 'image',
|
||||||
'mode': (mode ?? 0).toString(),
|
'mode': (mode ?? 0).toString(),
|
||||||
'random': (random! ? 1 : 0).toString(),
|
'random': (random! ? 1 : 0).toString(),
|
||||||
if (older != null) 'older': older,
|
if (tag != null) 'tag': tag,
|
||||||
|
if (older != null) 'older': older.toString(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
42
lib/utils/PageTransformer.dart
Normal file
42
lib/utils/PageTransformer.dart
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class PageTransformer extends StatelessWidget {
|
||||||
|
final List<Widget> pages;
|
||||||
|
final PageController controller;
|
||||||
|
|
||||||
|
const PageTransformer({
|
||||||
|
super.key,
|
||||||
|
required this.pages,
|
||||||
|
required this.controller,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return PageView.builder(
|
||||||
|
controller: controller,
|
||||||
|
itemCount: pages.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return _buildPage(pages[index], index);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildPage(Widget page, int index) {
|
||||||
|
return AnimatedBuilder(
|
||||||
|
animation: controller,
|
||||||
|
builder: (context, child) {
|
||||||
|
double value = 1.0;
|
||||||
|
if (controller.position.haveDimensions) {
|
||||||
|
value = controller.page! - index;
|
||||||
|
value = (1 - (value.abs() * 0.5)).clamp(0.0, 1.0);
|
||||||
|
}
|
||||||
|
return Transform(
|
||||||
|
transform: Matrix4.identity()..scale(value, value),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: page,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
135
lib/widgets/VideoOverlay.dart
Normal file
135
lib/widgets/VideoOverlay.dart
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:cached_video_player_plus/cached_video_player_plus.dart';
|
||||||
|
|
||||||
|
class VideoControlsOverlay extends StatelessWidget {
|
||||||
|
final CachedVideoPlayerPlusController controller;
|
||||||
|
final VoidCallback button;
|
||||||
|
|
||||||
|
const VideoControlsOverlay({
|
||||||
|
super.key,
|
||||||
|
required this.controller,
|
||||||
|
required this.button,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Stack(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
children: [
|
||||||
|
Center(
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
_ControlButton(Icons.replay_10, () {
|
||||||
|
button();
|
||||||
|
Duration newPosition =
|
||||||
|
controller.value.position - const Duration(seconds: 10);
|
||||||
|
if (newPosition < Duration.zero) newPosition = Duration.zero;
|
||||||
|
controller.seekTo(newPosition);
|
||||||
|
}),
|
||||||
|
SizedBox(width: 40),
|
||||||
|
_ControlButton(
|
||||||
|
controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
|
||||||
|
() {
|
||||||
|
button();
|
||||||
|
controller.value.isPlaying
|
||||||
|
? controller.pause()
|
||||||
|
: controller.play();
|
||||||
|
},
|
||||||
|
size: 64,
|
||||||
|
),
|
||||||
|
SizedBox(width: 40),
|
||||||
|
_ControlButton(Icons.forward_10, () {
|
||||||
|
button();
|
||||||
|
Duration newPosition =
|
||||||
|
controller.value.position + const Duration(seconds: 10);
|
||||||
|
if (newPosition > controller.value.duration) {
|
||||||
|
newPosition = controller.value.duration;
|
||||||
|
}
|
||||||
|
controller.seekTo(newPosition);
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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 {
|
||||||
|
final IconData icon;
|
||||||
|
final VoidCallback onPressed;
|
||||||
|
final double size;
|
||||||
|
|
||||||
|
const _ControlButton(this.icon, this.onPressed, {this.size = 24});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: Colors.black.withValues(alpha: 0.4),
|
||||||
|
),
|
||||||
|
child: IconButton(
|
||||||
|
icon: Icon(icon, color: Colors.white, size: size),
|
||||||
|
onPressed: onPressed,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,22 +1,24 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:video_player/video_player.dart';
|
import 'package:cached_video_player_plus/cached_video_player_plus.dart';
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:f0ckapp/models/mediaitem.dart';
|
import 'package:f0ckapp/models/MediaItem.dart';
|
||||||
import 'package:f0ckapp/widgets/video_overlay.dart';
|
import 'package:f0ckapp/widgets/VideoOverlay.dart';
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
class VideoWidget extends StatefulWidget {
|
class VideoWidget extends StatefulWidget {
|
||||||
final MediaItem details;
|
final MediaItem details;
|
||||||
const VideoWidget({super.key, required this.details});
|
final bool isActive;
|
||||||
|
|
||||||
|
const VideoWidget({super.key, required this.details, required this.isActive});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State createState() => _VideoWidgetState();
|
State createState() => _VideoWidgetState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _VideoWidgetState extends State<VideoWidget> {
|
class _VideoWidgetState extends State<VideoWidget> {
|
||||||
late VideoPlayerController _controller;
|
late CachedVideoPlayerPlusController _controller;
|
||||||
bool _showControls = false;
|
bool _showControls = false;
|
||||||
|
Timer? _hideControlsTimer;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -25,23 +27,49 @@ class _VideoWidgetState extends State<VideoWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _initController() async {
|
Future<void> _initController() async {
|
||||||
_controller = VideoPlayerController.networkUrl(
|
_controller = CachedVideoPlayerPlusController.networkUrl(
|
||||||
Uri.parse(widget.details.mediaUrl),
|
Uri.parse(widget.details.mediaUrl),
|
||||||
);
|
);
|
||||||
await _controller.initialize();
|
await _controller.initialize();
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
|
||||||
_controller.addListener(() => setState(() {}));
|
_controller.addListener(() => setState(() {}));
|
||||||
_controller.play();
|
if (widget.isActive) {
|
||||||
|
_controller.play();
|
||||||
|
}
|
||||||
_controller.setLooping(true);
|
_controller.setLooping(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_controller.dispose();
|
_controller.dispose();
|
||||||
|
_hideControlsTimer?.cancel();
|
||||||
super.dispose();
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_showControls) {
|
||||||
|
_hideControlsTimer?.cancel();
|
||||||
|
_hideControlsTimer = Timer(Duration(seconds: 2), () {
|
||||||
|
setState(() => _showControls = false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
bool isAudio = widget.details.mime.startsWith('audio');
|
bool isAudio = widget.details.mime.startsWith('audio');
|
||||||
@ -54,27 +82,24 @@ class _VideoWidgetState extends State<VideoWidget> {
|
|||||||
? _controller.value.aspectRatio
|
? _controller.value.aspectRatio
|
||||||
: 9 / 16,
|
: 9 / 16,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.topCenter,
|
||||||
children: [
|
children: [
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: _onTap,
|
||||||
setState(() {
|
|
||||||
_showControls = !_showControls;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: isAudio
|
child: isAudio
|
||||||
? CachedNetworkImage(
|
? CachedNetworkImage(
|
||||||
imageUrl: widget.details.coverUrl,
|
imageUrl: widget.details.coverUrl,
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
placeholder: (context, url) =>
|
placeholder: (context, url) =>
|
||||||
CircularProgressIndicator(),
|
CircularProgressIndicator(),
|
||||||
errorWidget: (context, url, error) => Image.network(
|
errorWidget: (context, url, error) => Image.asset(
|
||||||
"https://f0ck.me/s/img/music.webp",
|
'assets/images/music.webp',
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
|
width: double.infinity,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: _controller.value.isInitialized
|
: _controller.value.isInitialized
|
||||||
? VideoPlayer(_controller)
|
? CachedVideoPlayerPlus(_controller)
|
||||||
: Center(child: CircularProgressIndicator()),
|
: Center(child: CircularProgressIndicator()),
|
||||||
),
|
),
|
||||||
if (_controller.value.isInitialized && _showControls) ...[
|
if (_controller.value.isInitialized && _showControls) ...[
|
||||||
@ -86,7 +111,10 @@ class _VideoWidgetState extends State<VideoWidget> {
|
|||||||
height: double.infinity,
|
height: double.infinity,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
VideoControlsOverlay(controller: _controller),
|
VideoControlsOverlay(
|
||||||
|
controller: _controller,
|
||||||
|
button: () => _onTap(ctrlButton: true),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
@ -1,130 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:video_player/video_player.dart';
|
|
||||||
|
|
||||||
class VideoControlsOverlay extends StatelessWidget {
|
|
||||||
final VideoPlayerController controller;
|
|
||||||
const VideoControlsOverlay({super.key, required this.controller});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Stack(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
children: [
|
|
||||||
Center(
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
_ControlButton(Icons.replay_10, () {
|
|
||||||
controller.seekTo(
|
|
||||||
controller.value.position - Duration(seconds: 10),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
SizedBox(width: 32),
|
|
||||||
_ControlButton(
|
|
||||||
controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
|
|
||||||
() {
|
|
||||||
controller.value.isPlaying
|
|
||||||
? controller.pause()
|
|
||||||
: controller.play();
|
|
||||||
},
|
|
||||||
size: 64,
|
|
||||||
),
|
|
||||||
SizedBox(width: 32),
|
|
||||||
_ControlButton(Icons.forward_10, () {
|
|
||||||
controller.seekTo(
|
|
||||||
controller.value.position + Duration(seconds: 10),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
_ProgressIndicator(controller: controller),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ControlButton extends StatelessWidget {
|
|
||||||
final IconData icon;
|
|
||||||
final VoidCallback onPressed;
|
|
||||||
final double size;
|
|
||||||
|
|
||||||
const _ControlButton(this.icon, this.onPressed, {this.size = 24});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
color: Colors.black.withValues(alpha: 0.4),
|
|
||||||
),
|
|
||||||
child: IconButton(
|
|
||||||
icon: Icon(icon, color: Colors.white, size: size),
|
|
||||||
onPressed: onPressed,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ProgressIndicator extends StatelessWidget {
|
|
||||||
final VideoPlayerController controller;
|
|
||||||
const _ProgressIndicator({required this.controller});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Align(
|
|
||||||
alignment: Alignment.bottomCenter,
|
|
||||||
child: Stack(
|
|
||||||
clipBehavior: Clip.none,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
height: 20,
|
|
||||||
alignment: Alignment.bottomCenter,
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: VideoProgressIndicator(
|
|
||||||
controller,
|
|
||||||
allowScrubbing: true,
|
|
||||||
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');
|
|
||||||
final minutes = twoDigits(duration.inMinutes.remainder(60));
|
|
||||||
final seconds = twoDigits(duration.inSeconds.remainder(60));
|
|
||||||
return "$minutes:$seconds";
|
|
||||||
}
|
|
||||||
}
|
|
48
pubspec.lock
48
pubspec.lock
@ -41,6 +41,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.1"
|
version: "1.3.1"
|
||||||
|
cached_video_player_plus:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: cached_video_player_plus
|
||||||
|
sha256: "451ee48bdbd28fac3d49b4389929c44d259b1def5be6dab0c5bfd3ae1f05e8b5"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.3"
|
||||||
characters:
|
characters:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -152,6 +160,22 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
get:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: get
|
||||||
|
sha256: c79eeb4339f1f3deffd9ec912f8a923834bec55f7b49c9e882b8fef2c139d425
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.7.2"
|
||||||
|
get_storage:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: get_storage
|
||||||
|
sha256: "39db1fffe779d0c22b3a744376e86febe4ade43bf65e06eab5af707dc84185a2"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.1"
|
||||||
html:
|
html:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -232,6 +256,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.16.0"
|
version: "1.16.0"
|
||||||
|
nested:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: nested
|
||||||
|
sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.0"
|
||||||
octo_image:
|
octo_image:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -312,6 +344,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.8"
|
version: "2.1.8"
|
||||||
|
provider:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: provider
|
||||||
|
sha256: "4abbd070a04e9ddc287673bf5a030c7ca8b685ff70218720abab8b092f53dd84"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.1.5"
|
||||||
rxdart:
|
rxdart:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -453,14 +493,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.0"
|
version: "2.2.0"
|
||||||
video_player:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: video_player
|
|
||||||
sha256: "7d78f0cfaddc8c19d4cb2d3bebe1bfef11f2103b0a03e5398b303a1bf65eeb14"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.9.5"
|
|
||||||
video_player_android:
|
video_player_android:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -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.21+21
|
version: 1.0.26+26
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.9.0-100.2.beta
|
sdk: ^3.9.0-100.2.beta
|
||||||
@ -31,12 +31,13 @@ dependencies:
|
|||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
http: ^1.4.0
|
http: ^1.4.0
|
||||||
video_player: ^2.2.10
|
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^1.0.8
|
cupertino_icons: ^1.0.8
|
||||||
cached_network_image: ^3.4.1
|
cached_network_image: ^3.4.1
|
||||||
|
cached_video_player_plus: ^3.0.3
|
||||||
|
provider: ^6.1.5
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
@ -61,7 +62,8 @@ flutter:
|
|||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|
||||||
# To add assets to your application, add an assets section, like this:
|
# To add assets to your application, add an assets section, like this:
|
||||||
# assets:
|
assets:
|
||||||
|
- assets/images/
|
||||||
# - images/a_dot_burr.jpeg
|
# - images/a_dot_burr.jpeg
|
||||||
# - images/a_dot_ham.jpeg
|
# - images/a_dot_ham.jpeg
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user