Compare commits
20 Commits
v1.2.0+54
...
5e8983e347
Author | SHA1 | Date | |
---|---|---|---|
5e8983e347 | |||
93a89ba4b9 | |||
ba7505c2b3 | |||
39fadc009f | |||
0d42fad708 | |||
405d388db0 | |||
e30635304b | |||
7a1f76ee85 | |||
95f6dcfe2b | |||
7f0743808a | |||
840395bb69 | |||
7a88c23e57 | |||
73a44bb269 | |||
2b5aaad331 | |||
0d792fdf46 | |||
ee2db04a36 | |||
089fe1f8df | |||
e9107a7f62 | |||
14081489cc | |||
2a500144f5 |
@ -41,7 +41,7 @@ jobs:
|
|||||||
TAR_OPTIONS: --no-same-owner
|
TAR_OPTIONS: --no-same-owner
|
||||||
|
|
||||||
- name: build apk
|
- name: build apk
|
||||||
run: flutter build apk --release
|
run: flutter build apk --release --split-per-abi
|
||||||
|
|
||||||
- name: release-build
|
- name: release-build
|
||||||
uses: akkuman/gitea-release-action@v1
|
uses: akkuman/gitea-release-action@v1
|
||||||
@ -49,7 +49,9 @@ jobs:
|
|||||||
NODE_OPTIONS: '--experimental-fetch'
|
NODE_OPTIONS: '--experimental-fetch'
|
||||||
with:
|
with:
|
||||||
files: |-
|
files: |-
|
||||||
build/app/outputs/flutter-apk/app-release.apk
|
build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk
|
||||||
|
build/app/outputs/flutter-apk/app-arm64-v8a-release.apk
|
||||||
|
build/app/outputs/flutter-apk/app-x86_64-release.apk
|
||||||
token: '${{secrets.RELEASE_TOKEN}}'
|
token: '${{secrets.RELEASE_TOKEN}}'
|
||||||
|
|
||||||
- name: upload apk to f-droid server
|
- name: upload apk to f-droid server
|
||||||
@ -57,5 +59,5 @@ jobs:
|
|||||||
BUILD_NUMBER=$(grep '^version:' pubspec.yaml | sed 's/.*+//')
|
BUILD_NUMBER=$(grep '^version:' pubspec.yaml | sed 's/.*+//')
|
||||||
curl -X POST "https://flumm.io/pullfdroid.php" \
|
curl -X POST "https://flumm.io/pullfdroid.php" \
|
||||||
-F "token=${{ secrets.PULLER_TOKEN }}" \
|
-F "token=${{ secrets.PULLER_TOKEN }}" \
|
||||||
-F "apk=@build/app/outputs/flutter-apk/app-release.apk" \
|
-F "apk=@build/app/outputs/flutter-apk/app-arm64-v8a-release.apk" \
|
||||||
-F "build=$BUILD_NUMBER"
|
-F "build=$BUILD_NUMBER"
|
||||||
|
27
.metadata
27
.metadata
@ -4,8 +4,8 @@
|
|||||||
# This file should be version controlled and should not be manually edited.
|
# This file should be version controlled and should not be manually edited.
|
||||||
|
|
||||||
version:
|
version:
|
||||||
revision: "8b18dde77fa59ba7f87540c05d1aba787198e77a"
|
revision: "01fde956f0d13551843a44ae16eda7ca87478603"
|
||||||
channel: "master"
|
channel: "beta"
|
||||||
|
|
||||||
project_type: app
|
project_type: app
|
||||||
|
|
||||||
@ -13,27 +13,8 @@ project_type: app
|
|||||||
migration:
|
migration:
|
||||||
platforms:
|
platforms:
|
||||||
- platform: root
|
- platform: root
|
||||||
create_revision: 8b18dde77fa59ba7f87540c05d1aba787198e77a
|
create_revision: 01fde956f0d13551843a44ae16eda7ca87478603
|
||||||
base_revision: 8b18dde77fa59ba7f87540c05d1aba787198e77a
|
base_revision: 01fde956f0d13551843a44ae16eda7ca87478603
|
||||||
- platform: android
|
|
||||||
create_revision: 8b18dde77fa59ba7f87540c05d1aba787198e77a
|
|
||||||
base_revision: 8b18dde77fa59ba7f87540c05d1aba787198e77a
|
|
||||||
- platform: ios
|
|
||||||
create_revision: 8b18dde77fa59ba7f87540c05d1aba787198e77a
|
|
||||||
base_revision: 8b18dde77fa59ba7f87540c05d1aba787198e77a
|
|
||||||
- platform: linux
|
|
||||||
create_revision: 8b18dde77fa59ba7f87540c05d1aba787198e77a
|
|
||||||
base_revision: 8b18dde77fa59ba7f87540c05d1aba787198e77a
|
|
||||||
- platform: macos
|
|
||||||
create_revision: 8b18dde77fa59ba7f87540c05d1aba787198e77a
|
|
||||||
base_revision: 8b18dde77fa59ba7f87540c05d1aba787198e77a
|
|
||||||
- platform: web
|
|
||||||
create_revision: 8b18dde77fa59ba7f87540c05d1aba787198e77a
|
|
||||||
base_revision: 8b18dde77fa59ba7f87540c05d1aba787198e77a
|
|
||||||
- platform: windows
|
|
||||||
create_revision: 8b18dde77fa59ba7f87540c05d1aba787198e77a
|
|
||||||
base_revision: 8b18dde77fa59ba7f87540c05d1aba787198e77a
|
|
||||||
|
|
||||||
# User provided section
|
# User provided section
|
||||||
|
|
||||||
# List of Local paths (relative to this file) that should be
|
# List of Local paths (relative to this file) that should be
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# fApp
|
# fApp
|
||||||

|

|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
fApp is the mobile application for the website [f0ck.me](https://f0ck.me). This app provides a user-friendly interface to access the content of the website and utilize its features conveniently from your mobile device.
|
fApp is the mobile application for the website [f0ck.me](https://f0ck.me). This app provides a user-friendly interface to access the content of the website and utilize its features conveniently from your mobile device.
|
||||||
|
11
assets/i18n/de_DE.json
Normal file
11
assets/i18n/de_DE.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"settings_title": "Einstellungen",
|
||||||
|
"settings_language": "Sprache",
|
||||||
|
"settings_drawer_title": "Drawer per Geste öffnen",
|
||||||
|
"settings_drawer_subtitle": "Wähle, ob der Drawer mit einer Wischgeste geschlossen/geöffnet werden kann.",
|
||||||
|
"settings_numberofcolumns_title": "Spaltenanzahl",
|
||||||
|
"settings_numberofcolumns_columns": "@count Spalten",
|
||||||
|
"settings_pageanimation_title": "Seitenwechselanimation",
|
||||||
|
"settings_cache_title": "Cache leeren",
|
||||||
|
"settings_cache_clear_button": "Leeren"
|
||||||
|
}
|
11
assets/i18n/en_US.json
Normal file
11
assets/i18n/en_US.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"settings_title": "Settings",
|
||||||
|
"settings_language": "Language",
|
||||||
|
"settings_drawer_title": "Open drawer with gesture",
|
||||||
|
"settings_drawer_subtitle": "Choose whether the drawer can be closed/opened with a swipe gesture.",
|
||||||
|
"settings_numberofcolumns_title": "Number of columns",
|
||||||
|
"settings_numberofcolumns_columns": "@count columns",
|
||||||
|
"settings_pageanimation_title": "Page change animation",
|
||||||
|
"settings_cache_title": "Clear Cache",
|
||||||
|
"settings_cache_clear_button": "Clear"
|
||||||
|
}
|
11
assets/i18n/fr_FR.json
Normal file
11
assets/i18n/fr_FR.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"settings_title": "Paramètres",
|
||||||
|
"settings_language": "Langue",
|
||||||
|
"settings_drawer_title": "Ouvrir le tiroir avec un geste",
|
||||||
|
"settings_drawer_subtitle": "Choisissez si le tiroir peut être ouvert/fermé avec un geste de balayage.",
|
||||||
|
"settings_numberofcolumns_title": "Nombre de colonnes",
|
||||||
|
"settings_numberofcolumns_columns": "@count colonnes",
|
||||||
|
"settings_pageanimation_title": "Animation de changement de page",
|
||||||
|
"settings_cache_title": "Vider le cache",
|
||||||
|
"settings_cache_clear_button": "Vider"
|
||||||
|
}
|
11
assets/i18n/nl_NL.json
Normal file
11
assets/i18n/nl_NL.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"settings_title": "Instellingen",
|
||||||
|
"settings_language": "Taal",
|
||||||
|
"settings_drawer_title": "Lade openen met een gebaar",
|
||||||
|
"settings_drawer_subtitle": "Kies of de lade geopend/gesloten kan worden met een veeggebaar.",
|
||||||
|
"settings_numberofcolumns_title": "Aantal kolommen",
|
||||||
|
"settings_numberofcolumns_columns": "@count kolommen",
|
||||||
|
"settings_pageanimation_title": "Pagina-overgangsanimatie",
|
||||||
|
"settings_cache_title": "Cache wissen",
|
||||||
|
"settings_cache_clear_button": "Wissen"
|
||||||
|
}
|
BIN
assets/images/tags/belgium.webp
Normal file
BIN
assets/images/tags/belgium.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 92 B |
BIN
assets/images/tags/dutch.webp
Normal file
BIN
assets/images/tags/dutch.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 90 B |
BIN
assets/images/tags/german.webp
Normal file
BIN
assets/images/tags/german.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 94 B |
BIN
assets/images/tags/russia.webp
Normal file
BIN
assets/images/tags/russia.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 92 B |
BIN
assets/images/tags/ukraine.webp
Normal file
BIN
assets/images/tags/ukraine.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 108 B |
108
lib/controller/authcontroller.dart
Normal file
108
lib/controller/authcontroller.dart
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:encrypt_shared_preferences/provider.dart';
|
||||||
|
|
||||||
|
import 'package:f0ckapp/models/user.dart';
|
||||||
|
|
||||||
|
class AuthController extends GetxController {
|
||||||
|
final EncryptedSharedPreferencesAsync storage =
|
||||||
|
EncryptedSharedPreferencesAsync.getInstance();
|
||||||
|
|
||||||
|
final GetConnect http = GetConnect();
|
||||||
|
|
||||||
|
RxnString token = RxnString();
|
||||||
|
Rxn<User> user = Rxn<User>();
|
||||||
|
RxBool isLoading = false.obs;
|
||||||
|
RxnString error = RxnString();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onInit() {
|
||||||
|
super.onInit();
|
||||||
|
loadToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> loadToken() async {
|
||||||
|
token.value = await storage.getString('token');
|
||||||
|
if (token.value != null) {
|
||||||
|
await fetchUserInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> saveToken(String newToken) async {
|
||||||
|
token.value = newToken;
|
||||||
|
await storage.setString('token', newToken);
|
||||||
|
await fetchUserInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> logout() async {
|
||||||
|
if (token.value != null) {
|
||||||
|
try {
|
||||||
|
await http.post(
|
||||||
|
'https://api.f0ck.me/logout',
|
||||||
|
{},
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Bearer ${token.value}',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
token.value = null;
|
||||||
|
user.value = null;
|
||||||
|
await storage.remove('token');
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> login(String username, String password) async {
|
||||||
|
isLoading.value = true;
|
||||||
|
error.value = null;
|
||||||
|
try {
|
||||||
|
final Response<dynamic> response = await http.post(
|
||||||
|
'https://api.f0ck.me/login',
|
||||||
|
json.encode({'username': username, 'password': password}),
|
||||||
|
headers: {'Content-Type': 'application/json'},
|
||||||
|
);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
final dynamic data = response.body is String
|
||||||
|
? json.decode(response.body)
|
||||||
|
: response.body;
|
||||||
|
if (data['token'] != null) {
|
||||||
|
await saveToken(data['token']);
|
||||||
|
user.value = User.fromJson(data);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
error.value = 'Kein Token erhalten';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
error.value = 'Login fehlgeschlagen';
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
error.value = e.toString();
|
||||||
|
} finally {
|
||||||
|
isLoading.value = false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> fetchUserInfo() async {
|
||||||
|
if (token.value == null) return;
|
||||||
|
try {
|
||||||
|
final Response<dynamic> response = await http.get(
|
||||||
|
'https://api.f0ck.me/login/check',
|
||||||
|
headers: {'Authorization': 'Bearer ${token.value}'},
|
||||||
|
);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
final dynamic data = response.body is String
|
||||||
|
? json.decode(response.body)
|
||||||
|
: response.body;
|
||||||
|
user.value = User.fromJson(data);
|
||||||
|
} else {
|
||||||
|
await logout();
|
||||||
|
}
|
||||||
|
} catch (_) {
|
||||||
|
await logout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool get isLoggedIn => token.value != null && token.value!.isNotEmpty;
|
||||||
|
}
|
79
lib/controller/localizationcontroller.dart
Normal file
79
lib/controller/localizationcontroller.dart
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:encrypt_shared_preferences/provider.dart';
|
||||||
|
|
||||||
|
const Map<String, Locale> supportedLocales = {
|
||||||
|
'en_US': Locale('en', 'US'),
|
||||||
|
'de_DE': Locale('de', 'DE'),
|
||||||
|
'fr_FR': Locale('fr', 'FR'),
|
||||||
|
'nl_NL': Locale('nl', 'NL'),
|
||||||
|
};
|
||||||
|
|
||||||
|
class MyTranslations extends Translations {
|
||||||
|
static final MyTranslations instance = MyTranslations._internal();
|
||||||
|
MyTranslations._internal();
|
||||||
|
|
||||||
|
static final Map<String, Map<String, String>> _translations = {};
|
||||||
|
|
||||||
|
static Future<void> loadTranslations() async {
|
||||||
|
for (final localeKey in supportedLocales.keys) {
|
||||||
|
try {
|
||||||
|
final String jsonString = await rootBundle.loadString(
|
||||||
|
'assets/i18n/$localeKey.json',
|
||||||
|
);
|
||||||
|
final Map<String, dynamic> jsonMap = json.decode(jsonString);
|
||||||
|
_translations[localeKey] = jsonMap.map(
|
||||||
|
(key, value) => MapEntry(key, value.toString()),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint('Konnte Übersetzung für $localeKey nicht laden: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, Map<String, String>> get keys => _translations;
|
||||||
|
}
|
||||||
|
|
||||||
|
class LocalizationController extends GetxController {
|
||||||
|
final EncryptedSharedPreferencesAsync storage =
|
||||||
|
EncryptedSharedPreferencesAsync.getInstance();
|
||||||
|
Rx<Locale> currentLocale = supportedLocales['en_US']!.obs;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onInit() {
|
||||||
|
super.onInit();
|
||||||
|
loadLocale();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> loadLocale() async {
|
||||||
|
String? savedLocaleKey = await storage.getString(
|
||||||
|
'locale',
|
||||||
|
defaultValue: 'en_US',
|
||||||
|
);
|
||||||
|
|
||||||
|
final Locale locale =
|
||||||
|
supportedLocales[savedLocaleKey ?? 'en_US'] ??
|
||||||
|
supportedLocales['en_US']!;
|
||||||
|
|
||||||
|
currentLocale.value = locale;
|
||||||
|
Get.locale = locale;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> changeLocale(Locale newLocale) async {
|
||||||
|
final String localeKey = supportedLocales.entries
|
||||||
|
.firstWhere(
|
||||||
|
(entry) => entry.value == newLocale,
|
||||||
|
orElse: () => supportedLocales.entries.first,
|
||||||
|
)
|
||||||
|
.key;
|
||||||
|
|
||||||
|
currentLocale.value = newLocale;
|
||||||
|
Get.updateLocale(newLocale);
|
||||||
|
await storage.setString('locale', localeKey);
|
||||||
|
}
|
||||||
|
}
|
133
lib/controller/mediacontroller.dart
Normal file
133
lib/controller/mediacontroller.dart
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import 'package:f0ckapp/models/feed.dart';
|
||||||
|
import 'package:f0ckapp/models/item.dart';
|
||||||
|
import 'package:f0ckapp/services/api.dart';
|
||||||
|
|
||||||
|
const List<String> mediaTypes = ["alles", "image", "video", "audio"];
|
||||||
|
const List<String> mediaModes = ["sfw", "nsfw", "untagged", "all"];
|
||||||
|
|
||||||
|
class MediaController extends GetxController {
|
||||||
|
final ApiService _api = Get.find<ApiService>();
|
||||||
|
|
||||||
|
RxList<MediaItem> items = <MediaItem>[].obs;
|
||||||
|
RxBool loading = false.obs;
|
||||||
|
RxBool atEnd = false.obs;
|
||||||
|
RxBool atStart = false.obs;
|
||||||
|
Rxn<String> errorMessage = Rxn<String>();
|
||||||
|
|
||||||
|
RxInt typeIndex = 0.obs;
|
||||||
|
RxInt modeIndex = 0.obs;
|
||||||
|
RxInt random = 0.obs;
|
||||||
|
Rxn<String> tag = Rxn<String>(null);
|
||||||
|
|
||||||
|
void setTypeIndex(int idx) {
|
||||||
|
typeIndex.value = idx;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setModeIndex(int idx) {
|
||||||
|
modeIndex.value = idx;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setTag(String? newTag, {bool reload = true}) {
|
||||||
|
tag.value = newTag;
|
||||||
|
if (reload) {
|
||||||
|
fetchInitial();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void toggleRandom() {
|
||||||
|
random.value = random.value == 0 ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<Favorite>?> toggleFavorite(
|
||||||
|
MediaItem item,
|
||||||
|
bool isFavorite,
|
||||||
|
) async {
|
||||||
|
try {
|
||||||
|
return await _api.toggleFavorite(item, isFavorite);
|
||||||
|
} catch (e) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Feed?> _fetchItems({int? older, int? newer}) async {
|
||||||
|
if (loading.value) return null;
|
||||||
|
loading.value = true;
|
||||||
|
errorMessage.value = null;
|
||||||
|
try {
|
||||||
|
return await _api.fetchItems(
|
||||||
|
older: older,
|
||||||
|
newer: newer,
|
||||||
|
type: typeIndex.value,
|
||||||
|
mode: modeIndex.value,
|
||||||
|
random: random.value,
|
||||||
|
tag: tag.value,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
final String errorText =
|
||||||
|
'Die Daten konnten nicht abgerufen werden. Wo Internet?';
|
||||||
|
errorMessage.value = errorText;
|
||||||
|
Get.snackbar('Fehler beim Laden', errorText);
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> fetchInitial({int? id}) async {
|
||||||
|
final Feed? result = await _fetchItems(older: id);
|
||||||
|
if (result != null) {
|
||||||
|
items.assignAll(result.items);
|
||||||
|
atEnd.value = result.atEnd;
|
||||||
|
atStart.value = result.atStart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> fetchMore() async {
|
||||||
|
if (items.isEmpty || atEnd.value) return;
|
||||||
|
final Feed? result = await _fetchItems(older: items.last.id);
|
||||||
|
if (result != null) {
|
||||||
|
final Set<int> existingIds = items.map((e) => e.id).toSet();
|
||||||
|
final List<MediaItem> newItems = result.items
|
||||||
|
.where((item) => !existingIds.contains(item.id))
|
||||||
|
.toList();
|
||||||
|
items.addAll(newItems);
|
||||||
|
items.refresh();
|
||||||
|
atEnd.value = result.atEnd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> fetchNewer() async {
|
||||||
|
if (items.isEmpty || atStart.value) return;
|
||||||
|
final Feed? result = await _fetchItems(newer: items.first.id);
|
||||||
|
if (result != null) {
|
||||||
|
final Set<int> existingIds = items.map((e) => e.id).toSet();
|
||||||
|
final List<MediaItem> newItems = result.items
|
||||||
|
.where((item) => !existingIds.contains(item.id))
|
||||||
|
.toList();
|
||||||
|
items.insertAll(0, newItems);
|
||||||
|
items.refresh();
|
||||||
|
atStart.value = result.atStart;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> handleRefresh() async {
|
||||||
|
if (loading.value) return;
|
||||||
|
if (!atStart.value) {
|
||||||
|
await fetchNewer();
|
||||||
|
} else {
|
||||||
|
await fetchInitial();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> handleLoading() async {
|
||||||
|
if (loading.value) return;
|
||||||
|
if (!loading.value && !atEnd.value) {
|
||||||
|
await fetchMore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool get isRandomEnabled => random.value == 1;
|
||||||
|
}
|
75
lib/controller/settingscontroller.dart
Normal file
75
lib/controller/settingscontroller.dart
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
import 'package:encrypt_shared_preferences/provider.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import 'package:f0ckapp/utils/animatedtransition.dart';
|
||||||
|
|
||||||
|
class _StorageKeys {
|
||||||
|
static const String muted = 'muted';
|
||||||
|
static const String crossAxisCount = 'crossAxisCount';
|
||||||
|
static const String drawerSwipeEnabled = 'drawerSwipeEnabled';
|
||||||
|
static const String transitionType = 'transitionType';
|
||||||
|
}
|
||||||
|
|
||||||
|
class SettingsController extends GetxController {
|
||||||
|
final EncryptedSharedPreferencesAsync storage =
|
||||||
|
EncryptedSharedPreferencesAsync.getInstance();
|
||||||
|
|
||||||
|
RxBool muted = false.obs;
|
||||||
|
Rx<PageTransition> transitionType = PageTransition.opacity.obs;
|
||||||
|
RxBool drawerSwipeEnabled = true.obs;
|
||||||
|
RxInt crossAxisCount = 0.obs;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onInit() {
|
||||||
|
super.onInit();
|
||||||
|
loadSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void toggleMuted() {
|
||||||
|
muted.value = !muted.value;
|
||||||
|
saveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setMuted(bool value) {
|
||||||
|
muted.value = value;
|
||||||
|
saveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setTransitionType(PageTransition type) async {
|
||||||
|
transitionType.value = type;
|
||||||
|
await saveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setCrossAxisCount(int value) async {
|
||||||
|
crossAxisCount.value = value;
|
||||||
|
await saveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setDrawerSwipeEnabled(bool enabled) async {
|
||||||
|
drawerSwipeEnabled.value = enabled;
|
||||||
|
await saveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> loadSettings() async {
|
||||||
|
muted.value = await storage.getBoolean(_StorageKeys.muted) ?? false;
|
||||||
|
crossAxisCount.value =
|
||||||
|
await storage.getInt(_StorageKeys.crossAxisCount) ?? 0;
|
||||||
|
drawerSwipeEnabled.value =
|
||||||
|
await storage.getBoolean(_StorageKeys.drawerSwipeEnabled) ?? true;
|
||||||
|
transitionType.value = PageTransition
|
||||||
|
.values[await storage.getInt(_StorageKeys.transitionType) ?? 0];
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> saveSettings() async {
|
||||||
|
await storage.setBoolean(_StorageKeys.muted, muted.value);
|
||||||
|
await storage.setInt(_StorageKeys.crossAxisCount, crossAxisCount.value);
|
||||||
|
await storage.setBoolean(
|
||||||
|
_StorageKeys.drawerSwipeEnabled,
|
||||||
|
drawerSwipeEnabled.value,
|
||||||
|
);
|
||||||
|
await storage.setInt(
|
||||||
|
_StorageKeys.transitionType,
|
||||||
|
transitionType.value.index,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|
||||||
|
|
||||||
// Definiere deine Themes wie gehabt:
|
import 'package:get/get.dart';
|
||||||
|
import 'package:encrypt_shared_preferences/provider.dart';
|
||||||
|
|
||||||
final ThemeData f0ckTheme = ThemeData(
|
final ThemeData f0ckTheme = ThemeData(
|
||||||
brightness: Brightness.dark,
|
brightness: Brightness.dark,
|
||||||
primaryColor: const Color(0xFF9FFF00),
|
primaryColor: const Color(0xFF9FFF00),
|
||||||
@ -186,7 +186,6 @@ final ThemeData f0ck95Theme = ThemeData(
|
|||||||
backgroundColor: const Color(0xFFE0E0E0),
|
backgroundColor: const Color(0xFFE0E0E0),
|
||||||
foregroundColor: Colors.black,
|
foregroundColor: Colors.black,
|
||||||
elevation: 4,
|
elevation: 4,
|
||||||
centerTitle: true,
|
|
||||||
),
|
),
|
||||||
textTheme: const TextTheme(
|
textTheme: const TextTheme(
|
||||||
bodyLarge: TextStyle(color: Colors.black),
|
bodyLarge: TextStyle(color: Colors.black),
|
||||||
@ -237,9 +236,8 @@ final ThemeData f0ck95dTheme = ThemeData(
|
|||||||
);
|
);
|
||||||
|
|
||||||
class ThemeController extends GetxController {
|
class ThemeController extends GetxController {
|
||||||
final FlutterSecureStorage secureStorage = const FlutterSecureStorage(
|
final EncryptedSharedPreferencesAsync storage =
|
||||||
aOptions: AndroidOptions(encryptedSharedPreferences: true),
|
EncryptedSharedPreferencesAsync.getInstance();
|
||||||
);
|
|
||||||
|
|
||||||
final Rx<ThemeData> currentTheme = f0ckTheme.obs;
|
final Rx<ThemeData> currentTheme = f0ckTheme.obs;
|
||||||
|
|
||||||
@ -261,13 +259,13 @@ class ThemeController extends GetxController {
|
|||||||
|
|
||||||
Future<void> _loadTheme() async {
|
Future<void> _loadTheme() async {
|
||||||
try {
|
try {
|
||||||
final String? savedThemeName = await secureStorage.read(key: 'theme');
|
final String? savedThemeName = await storage.getString('theme');
|
||||||
if (savedThemeName != null && themeMap.containsKey(savedThemeName)) {
|
if (savedThemeName != null && themeMap.containsKey(savedThemeName)) {
|
||||||
currentTheme.value = themeMap[savedThemeName]!;
|
currentTheme.value = themeMap[savedThemeName]!;
|
||||||
Get.changeTheme(currentTheme.value);
|
Get.changeTheme(currentTheme.value);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
debugPrint('Fehler beim Laden des Themes: $error');
|
Get.snackbar('', 'Fehler beim Laden des Themes: $error');
|
||||||
currentTheme.value = f0ckTheme;
|
currentTheme.value = f0ckTheme;
|
||||||
Get.changeTheme(f0ckTheme);
|
Get.changeTheme(f0ckTheme);
|
||||||
}
|
}
|
||||||
@ -275,7 +273,7 @@ class ThemeController extends GetxController {
|
|||||||
|
|
||||||
Future<void> updateTheme(String themeName) async {
|
Future<void> updateTheme(String themeName) async {
|
||||||
try {
|
try {
|
||||||
await secureStorage.write(key: 'theme', value: themeName);
|
await storage.setString('theme', themeName);
|
||||||
if (themeMap.containsKey(themeName)) {
|
if (themeMap.containsKey(themeName)) {
|
||||||
currentTheme.value = themeMap[themeName]!;
|
currentTheme.value = themeMap[themeName]!;
|
||||||
Get.changeTheme(currentTheme.value);
|
Get.changeTheme(currentTheme.value);
|
||||||
@ -284,7 +282,7 @@ class ThemeController extends GetxController {
|
|||||||
Get.changeTheme(f0ckTheme);
|
Get.changeTheme(f0ckTheme);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
debugPrint('Fehler beim Aktualisieren des Themes: $error');
|
Get.snackbar('', 'Fehler beim Aktualisieren des Themes: $error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,46 +1,75 @@
|
|||||||
import 'package:f0ckapp/providers/theme_provider.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
|
|
||||||
|
import 'package:encrypt_shared_preferences/provider.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
import 'package:f0ckapp/utils/appversion_util.dart';
|
import 'package:f0ckapp/services/api.dart';
|
||||||
import 'package:f0ckapp/services/api_service.dart';
|
import 'package:f0ckapp/controller/settingscontroller.dart';
|
||||||
import 'package:f0ckapp/screens/media_grid.dart';
|
import 'package:f0ckapp/controller/authcontroller.dart';
|
||||||
import 'package:f0ckapp/screens/settings_screen.dart';
|
import 'package:f0ckapp/controller/localizationcontroller.dart';
|
||||||
import 'package:f0ckapp/screens/detailview_screen.dart';
|
import 'package:f0ckapp/controller/themecontroller.dart';
|
||||||
|
import 'package:f0ckapp/screens/mediadetail.dart';
|
||||||
|
import 'package:f0ckapp/utils/appversion.dart';
|
||||||
|
import 'package:f0ckapp/controller/mediacontroller.dart';
|
||||||
|
import 'package:f0ckapp/screens/mediagrid.dart';
|
||||||
|
import 'package:f0ckapp/screens/login.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
|
||||||
await AppVersion.init();
|
|
||||||
final ThemeController themeController = Get.put(ThemeController());
|
|
||||||
|
|
||||||
final api = ApiService();
|
await Future.wait([
|
||||||
await api.fetchMedia();
|
EncryptedSharedPreferencesAsync.initialize('VokTnbAbemBUa2j9'),
|
||||||
Get.put(api);
|
MyTranslations.loadTranslations(),
|
||||||
|
AppVersion.init(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
Get.put(AuthController());
|
||||||
|
Get.put(ApiService());
|
||||||
|
Get.put(SettingsController());
|
||||||
|
Get.put(MediaController());
|
||||||
|
|
||||||
|
final ThemeController themeController = Get.put(ThemeController());
|
||||||
|
final LocalizationController localizationController = Get.put(
|
||||||
|
LocalizationController(),
|
||||||
|
);
|
||||||
|
|
||||||
|
Get.addTranslations(MyTranslations.instance.keys);
|
||||||
|
Get.locale = localizationController.currentLocale.value;
|
||||||
|
|
||||||
|
//Locale systemLocale = WidgetsBinding.instance.platformDispatcher.locale;
|
||||||
|
|
||||||
runApp(
|
runApp(
|
||||||
GetMaterialApp(
|
Obx(
|
||||||
theme: themeController.currentTheme.value,
|
() => MaterialApp(
|
||||||
initialRoute: '/',
|
locale: Get.locale,
|
||||||
getPages: [
|
navigatorKey: Get.key,
|
||||||
GetPage(name: '/', page: () => MediaGrid()),
|
theme: themeController.currentTheme.value,
|
||||||
GetPage(name: '/settings', page: () => SettingsPage()),
|
debugShowCheckedModeBanner: false,
|
||||||
GetPage(
|
initialRoute: '/',
|
||||||
name: '/:itemId',
|
onGenerateRoute: (RouteSettings settings) {
|
||||||
page: () {
|
final Uri uri = Uri.parse(settings.name ?? '/');
|
||||||
int? test = int.tryParse(Get.parameters['itemId']!);
|
|
||||||
if (test == null) {
|
if (uri.path == '/' || uri.pathSegments.isEmpty) {
|
||||||
return Scaffold(body: Center(child: Text('oof')));
|
return MaterialPageRoute(builder: (_) => const MediaGrid());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uri.path == '/login') {
|
||||||
|
return MaterialPageRoute(builder: (_) => LoginScreen());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uri.pathSegments.length == 1) {
|
||||||
|
try {
|
||||||
|
final int id = int.parse(uri.pathSegments.first);
|
||||||
|
return MaterialPageRoute(
|
||||||
|
builder: (_) => MediaDetailScreen(initialId: id),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
return MaterialPageRoute(builder: (_) => const MediaGrid());
|
||||||
}
|
}
|
||||||
return DetailView(initialItemId: test);
|
}
|
||||||
},
|
|
||||||
),
|
return MaterialPageRoute(builder: (_) => const MediaGrid());
|
||||||
],
|
},
|
||||||
unknownRoute: GetPage(
|
|
||||||
name: '/notfound',
|
|
||||||
page: () => Center(child: Text('oof')),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
17
lib/models/feed.dart
Normal file
17
lib/models/feed.dart
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import 'package:f0ckapp/models/item.dart';
|
||||||
|
|
||||||
|
class Feed {
|
||||||
|
final bool atEnd;
|
||||||
|
final bool atStart;
|
||||||
|
final List<MediaItem> items;
|
||||||
|
|
||||||
|
Feed({required this.atEnd, required this.atStart, required this.items});
|
||||||
|
|
||||||
|
factory Feed.fromJson(Map<String, dynamic> json) {
|
||||||
|
return Feed(
|
||||||
|
atEnd: json['atEnd'] ?? false,
|
||||||
|
atStart: json['atStart'] ?? false,
|
||||||
|
items: (json['items'] as List).map((e) => MediaItem.fromJson(e)).toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
122
lib/models/item.dart
Normal file
122
lib/models/item.dart
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
class MediaItem {
|
||||||
|
final int id;
|
||||||
|
final String mime;
|
||||||
|
final int size;
|
||||||
|
final int stamp;
|
||||||
|
final String dest;
|
||||||
|
final int mode;
|
||||||
|
final List<Tag>? tags;
|
||||||
|
final List<Favorite>? favorites;
|
||||||
|
final String? username;
|
||||||
|
final String? userchannel;
|
||||||
|
final String? usernetwork;
|
||||||
|
|
||||||
|
MediaItem({
|
||||||
|
required this.id,
|
||||||
|
required this.mime,
|
||||||
|
required this.size,
|
||||||
|
required this.stamp,
|
||||||
|
required this.dest,
|
||||||
|
required this.mode,
|
||||||
|
this.tags = const [],
|
||||||
|
this.favorites = const [],
|
||||||
|
this.username,
|
||||||
|
this.userchannel,
|
||||||
|
this.usernetwork,
|
||||||
|
});
|
||||||
|
|
||||||
|
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';
|
||||||
|
|
||||||
|
MediaItem copyWith({
|
||||||
|
int? id,
|
||||||
|
String? mime,
|
||||||
|
int? size,
|
||||||
|
int? stamp,
|
||||||
|
String? dest,
|
||||||
|
int? mode,
|
||||||
|
List<Tag>? tags,
|
||||||
|
List<Favorite>? favorites,
|
||||||
|
String? username,
|
||||||
|
String? userchannel,
|
||||||
|
String? usernetwork,
|
||||||
|
}) {
|
||||||
|
return MediaItem(
|
||||||
|
id: id ?? this.id,
|
||||||
|
mime: mime ?? this.mime,
|
||||||
|
size: size ?? this.size,
|
||||||
|
stamp: stamp ?? this.stamp,
|
||||||
|
dest: dest ?? this.dest,
|
||||||
|
mode: mode ?? this.mode,
|
||||||
|
tags: tags ?? this.tags,
|
||||||
|
favorites: favorites ?? this.favorites,
|
||||||
|
username: username ?? this.username,
|
||||||
|
userchannel: userchannel ?? this.userchannel,
|
||||||
|
usernetwork: usernetwork ?? this.usernetwork,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
factory MediaItem.fromJson(Map<String, dynamic> json) {
|
||||||
|
return MediaItem(
|
||||||
|
id: json['id'],
|
||||||
|
mime: json['mime'],
|
||||||
|
size: json['size'],
|
||||||
|
stamp: json['stamp'],
|
||||||
|
dest: json['dest'],
|
||||||
|
mode: json['mode'],
|
||||||
|
tags:
|
||||||
|
(json['tags'] as List<dynamic>?)
|
||||||
|
?.map((e) => Tag.fromJson(e))
|
||||||
|
.toList() ??
|
||||||
|
[],
|
||||||
|
favorites:
|
||||||
|
(json['favorites'] as List<dynamic>?)
|
||||||
|
?.map((e) => Favorite.fromJson(e))
|
||||||
|
.toList() ??
|
||||||
|
[],
|
||||||
|
username: json['username'],
|
||||||
|
userchannel: json['userchannel'],
|
||||||
|
usernetwork: json['usernetwork'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Tag {
|
||||||
|
final int id;
|
||||||
|
final String tag;
|
||||||
|
final String normalized;
|
||||||
|
|
||||||
|
Tag({required this.id, required this.tag, required this.normalized});
|
||||||
|
|
||||||
|
factory Tag.fromJson(Map<String, dynamic> json) {
|
||||||
|
return Tag(
|
||||||
|
id: json['id'],
|
||||||
|
tag: json['tag'],
|
||||||
|
normalized: json['normalized'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Favorite {
|
||||||
|
final int userId;
|
||||||
|
final String username;
|
||||||
|
final int avatar;
|
||||||
|
|
||||||
|
Favorite({
|
||||||
|
required this.userId,
|
||||||
|
required this.username,
|
||||||
|
required this.avatar,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Favorite.fromJson(Map<String, dynamic> json) {
|
||||||
|
return Favorite(
|
||||||
|
userId: json['userId'],
|
||||||
|
username: json['username'],
|
||||||
|
avatar: json['avatar'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String get avatarUrl => 'https://f0ck.me/t/$avatar.webp';
|
||||||
|
}
|
@ -1,54 +0,0 @@
|
|||||||
class MediaItem {
|
|
||||||
final int id;
|
|
||||||
final String mime;
|
|
||||||
final int size;
|
|
||||||
final int stamp;
|
|
||||||
final String dest;
|
|
||||||
final int mode;
|
|
||||||
final List<Tag> tags;
|
|
||||||
|
|
||||||
MediaItem({
|
|
||||||
required this.id,
|
|
||||||
required this.mime,
|
|
||||||
required this.size,
|
|
||||||
required this.stamp,
|
|
||||||
required this.dest,
|
|
||||||
required this.mode,
|
|
||||||
required this.tags,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory MediaItem.fromJson(Map<String, dynamic> json) {
|
|
||||||
return MediaItem(
|
|
||||||
id: json['id'],
|
|
||||||
mime: json['mime'],
|
|
||||||
size: json['size'],
|
|
||||||
stamp: json['stamp'],
|
|
||||||
dest: json['dest'],
|
|
||||||
mode: json['mode'],
|
|
||||||
tags: (json['tags'] as List<dynamic>)
|
|
||||||
.map((tagJson) => Tag.fromJson(tagJson))
|
|
||||||
.toList(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
|
||||||
final int id;
|
|
||||||
final String tag;
|
|
||||||
final String normalized;
|
|
||||||
|
|
||||||
Tag({required this.id, required this.tag, required this.normalized});
|
|
||||||
|
|
||||||
factory Tag.fromJson(Map<String, dynamic> json) {
|
|
||||||
return Tag(
|
|
||||||
id: json['id'],
|
|
||||||
tag: json['tag'],
|
|
||||||
normalized: json['normalized'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
17
lib/models/user.dart
Normal file
17
lib/models/user.dart
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
class User {
|
||||||
|
final int id;
|
||||||
|
final String username;
|
||||||
|
final String? avatarUrl;
|
||||||
|
|
||||||
|
User({required this.id, required this.username, this.avatarUrl});
|
||||||
|
|
||||||
|
factory User.fromJson(Map<String, dynamic> json) {
|
||||||
|
return User(
|
||||||
|
id: json['userid'],
|
||||||
|
username: json['user'],
|
||||||
|
avatarUrl: json['avatar'] != null
|
||||||
|
? 'https://f0ck.me/t/${json['avatar']}.webp'
|
||||||
|
: null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,329 +0,0 @@
|
|||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
|
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
|
||||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
|
||||||
import 'package:get/get.dart';
|
|
||||||
import 'package:share_plus/share_plus.dart';
|
|
||||||
|
|
||||||
import 'package:f0ckapp/models/mediaitem_model.dart';
|
|
||||||
import 'package:f0ckapp/services/api_service.dart';
|
|
||||||
import 'package:f0ckapp/widgets/end_drawer.dart';
|
|
||||||
import 'package:f0ckapp/screens/fullscreen_screen.dart';
|
|
||||||
import 'package:f0ckapp/widgets/video_widget.dart';
|
|
||||||
|
|
||||||
class DetailView extends StatefulWidget {
|
|
||||||
final int initialItemId;
|
|
||||||
const DetailView({super.key, required this.initialItemId});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<DetailView> createState() => _DetailViewState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _DetailViewState extends State<DetailView> {
|
|
||||||
final ApiService apiService = Get.find<ApiService>();
|
|
||||||
PageController? _pageController;
|
|
||||||
Future<void>? _loadingFuture;
|
|
||||||
int _currentPage = 0;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
if (!_mediaItemExists(widget.initialItemId)) {
|
|
||||||
_loadingFuture = _fetchAndPreloadMedia(widget.initialItemId);
|
|
||||||
} else {
|
|
||||||
_initializePageController();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool _mediaItemExists(int id) {
|
|
||||||
return apiService.mediaItems.any((media) => media.id == id);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _fetchAndPreloadMedia(int targetId) async {
|
|
||||||
try {
|
|
||||||
await apiService.setTag(null);
|
|
||||||
await apiService.fetchMedia(id: targetId + 50, reset: false);
|
|
||||||
_initializePageController();
|
|
||||||
} catch (e) {
|
|
||||||
_showMsg("Medien konnten nicht geladen werden");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _initializePageController() {
|
|
||||||
_currentPage = apiService.mediaItems.indexWhere(
|
|
||||||
(media) => media.id == widget.initialItemId,
|
|
||||||
);
|
|
||||||
if (_currentPage < 0) {
|
|
||||||
_currentPage = 0;
|
|
||||||
}
|
|
||||||
_pageController = PageController(initialPage: _currentPage)
|
|
||||||
..addListener(() {
|
|
||||||
setState(() {
|
|
||||||
_currentPage = _pageController!.page!.round();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_pageController?.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
MediaItem? _findMediaItem() {
|
|
||||||
try {
|
|
||||||
return apiService.mediaItems.firstWhere(
|
|
||||||
(media) => media.id == widget.initialItemId,
|
|
||||||
);
|
|
||||||
} catch (e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _downloadMedia(MediaItem item) async {
|
|
||||||
final File file = await DefaultCacheManager().getSingleFile(item.mediaUrl);
|
|
||||||
final MethodChannel methodChannel = const MethodChannel('MediaShit');
|
|
||||||
|
|
||||||
bool? success = await methodChannel.invokeMethod<bool>('saveFile', {
|
|
||||||
'filePath': file.path,
|
|
||||||
'fileName': item.dest,
|
|
||||||
});
|
|
||||||
|
|
||||||
success == true
|
|
||||||
? _showMsg('${item.dest} wurde in Downloads/fApp neigespeichert.')
|
|
||||||
: _showMsg('${item.dest} konnte nicht heruntergeladen werden.');
|
|
||||||
}
|
|
||||||
|
|
||||||
void _showMsg(String message) {
|
|
||||||
if (!mounted) return;
|
|
||||||
ScaffoldMessenger.of(context)
|
|
||||||
..removeCurrentSnackBar()
|
|
||||||
..showSnackBar(SnackBar(content: Text(message)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
if (_loadingFuture != null) {
|
|
||||||
return FutureBuilder<void>(
|
|
||||||
future: _loadingFuture,
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(title: const Text("Detail")),
|
|
||||||
body: const Center(child: CircularProgressIndicator()),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
MediaItem? item = _findMediaItem();
|
|
||||||
if (item == null) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(title: const Text("Detail")),
|
|
||||||
body: const Center(child: Text("f0ck nicht gefunden")),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return _buildDetail();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
MediaItem? existingItem = _findMediaItem();
|
|
||||||
if (existingItem == null) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(title: const Text("Detail")),
|
|
||||||
body: const Center(child: Text("f0ck nicht gefunden")),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return _buildDetail();
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildDetail() {
|
|
||||||
final MediaItem currentItem = apiService.mediaItems[_currentPage];
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
endDrawer: const EndDrawer(),
|
|
||||||
endDrawerEnableOpenDragGesture: false,
|
|
||||||
persistentFooterButtons: apiService.tag.value != null
|
|
||||||
? [
|
|
||||||
Center(
|
|
||||||
child: InputChip(
|
|
||||||
label: Text(apiService.tag.value!),
|
|
||||||
onDeleted: () {
|
|
||||||
apiService.setTag(null);
|
|
||||||
Get.offAllNamed('/');
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
: null,
|
|
||||||
body: CustomScrollView(
|
|
||||||
slivers: [
|
|
||||||
SliverAppBar(
|
|
||||||
floating: true,
|
|
||||||
pinned: true,
|
|
||||||
snap: true,
|
|
||||||
centerTitle: true,
|
|
||||||
title: Text('f0ck #${currentItem.id.toString()}'),
|
|
||||||
leading: IconButton(
|
|
||||||
icon: const Icon(Icons.arrow_back),
|
|
||||||
onPressed: () => Get.back(),
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.fullscreen),
|
|
||||||
onPressed: () {
|
|
||||||
Get.to(
|
|
||||||
FullScreenMediaView(item: currentItem),
|
|
||||||
fullscreenDialog: true,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.download),
|
|
||||||
onPressed: () async {
|
|
||||||
await _downloadMedia(currentItem);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
PopupMenuButton<String>(
|
|
||||||
onSelected: (value) async {
|
|
||||||
switch (value) {
|
|
||||||
case 'media':
|
|
||||||
File file = await DefaultCacheManager().getSingleFile(
|
|
||||||
currentItem.mediaUrl,
|
|
||||||
);
|
|
||||||
Uint8List bytes = await file.readAsBytes();
|
|
||||||
final params = ShareParams(
|
|
||||||
files: [
|
|
||||||
XFile.fromData(bytes, mimeType: currentItem.mime),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
await SharePlus.instance.share(params);
|
|
||||||
break;
|
|
||||||
case 'direct_link':
|
|
||||||
await SharePlus.instance.share(
|
|
||||||
ShareParams(text: currentItem.mediaUrl),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case 'post_link':
|
|
||||||
await SharePlus.instance.share(
|
|
||||||
ShareParams(text: currentItem.postUrl),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
itemBuilder: (context) => [
|
|
||||||
PopupMenuItem(
|
|
||||||
value: 'media',
|
|
||||||
child: ListTile(
|
|
||||||
leading: const Icon(Icons.image),
|
|
||||||
title: const Text('Als Datei'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
PopupMenuItem(
|
|
||||||
value: 'direct_link',
|
|
||||||
child: ListTile(
|
|
||||||
leading: const Icon(Icons.link),
|
|
||||||
title: const Text('Link zur Datei'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
PopupMenuItem(
|
|
||||||
value: 'post_link',
|
|
||||||
child: ListTile(
|
|
||||||
leading: const Icon(Icons.article),
|
|
||||||
title: const Text('Link zum f0ck'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
icon: const Icon(Icons.share),
|
|
||||||
),
|
|
||||||
Builder(
|
|
||||||
builder: (context) => IconButton(
|
|
||||||
icon: const Icon(Icons.menu),
|
|
||||||
onPressed: () {
|
|
||||||
Scaffold.of(context).openEndDrawer();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SliverFillRemaining(
|
|
||||||
child: PageView.builder(
|
|
||||||
controller: _pageController,
|
|
||||||
itemCount: apiService.mediaItems.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final MediaItem pageItem = apiService.mediaItems[index];
|
|
||||||
return AnimatedBuilder(
|
|
||||||
animation: _pageController!,
|
|
||||||
builder: (context, child) {
|
|
||||||
double value = 0;
|
|
||||||
if (_pageController!.position.haveDimensions) {
|
|
||||||
value = (_pageController!.page! - index).abs();
|
|
||||||
}
|
|
||||||
double factor = Curves.easeOut.transform(
|
|
||||||
1 - value.clamp(0.0, 1.0),
|
|
||||||
);
|
|
||||||
double scale = 0.8 + factor * 0.2;
|
|
||||||
return Transform.scale(scale: scale, child: child);
|
|
||||||
},
|
|
||||||
child: SafeArea(
|
|
||||||
top: false,
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
if (pageItem.mime.startsWith('image'))
|
|
||||||
CachedNetworkImage(
|
|
||||||
imageUrl: pageItem.mediaUrl,
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
placeholder: (context, url) => const Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
),
|
|
||||||
errorWidget: (context, url, error) =>
|
|
||||||
const Center(child: Icon(Icons.error)),
|
|
||||||
)
|
|
||||||
else
|
|
||||||
VideoWidget(
|
|
||||||
details: pageItem,
|
|
||||||
isActive: index == _currentPage,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10, width: double.infinity),
|
|
||||||
Wrap(
|
|
||||||
alignment: WrapAlignment.center,
|
|
||||||
spacing: 5.0,
|
|
||||||
children: pageItem.tags.map((tag) {
|
|
||||||
return ActionChip(
|
|
||||||
onPressed: () {
|
|
||||||
if (tag.tag == 'sfw' || tag.tag == 'nsfw') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
apiService.setTag(tag.tag);
|
|
||||||
Get.offAllNamed('/');
|
|
||||||
},
|
|
||||||
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),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
96
lib/screens/fullscreen.dart
Normal file
96
lib/screens/fullscreen.dart
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
|
|
||||||
|
import 'package:f0ckapp/models/item.dart';
|
||||||
|
import 'package:f0ckapp/widgets/video_widget.dart';
|
||||||
|
|
||||||
|
class FullScreenMediaView extends StatefulWidget {
|
||||||
|
final MediaItem item;
|
||||||
|
final Duration? initialPosition;
|
||||||
|
|
||||||
|
const FullScreenMediaView({
|
||||||
|
super.key,
|
||||||
|
required this.item,
|
||||||
|
this.initialPosition,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State createState() => _FullScreenMediaViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FullScreenMediaViewState extends State<FullScreenMediaView> {
|
||||||
|
final GlobalKey<VideoWidgetState> _videoKey = GlobalKey<VideoWidgetState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
SystemChrome.setPreferredOrientations(DeviceOrientation.values);
|
||||||
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||||
|
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _popWithPosition() {
|
||||||
|
Duration? currentPosition;
|
||||||
|
if (widget.item.mime.startsWith('video') && _videoKey.currentState != null) {
|
||||||
|
currentPosition = _videoKey.currentState!.videoController.value.position;
|
||||||
|
}
|
||||||
|
Navigator.of(context).pop(currentPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return PopScope(
|
||||||
|
onPopInvokedWithResult: (bool didPop, Object? result) async {
|
||||||
|
return _popWithPosition();
|
||||||
|
},
|
||||||
|
child: Scaffold(
|
||||||
|
backgroundColor: Colors.black,
|
||||||
|
body: Stack(
|
||||||
|
children: [
|
||||||
|
Positioned.fill(
|
||||||
|
child: widget.item.mime.startsWith('image')
|
||||||
|
? InteractiveViewer(
|
||||||
|
minScale: 1.0,
|
||||||
|
maxScale: 7.0,
|
||||||
|
child: CachedNetworkImage(
|
||||||
|
imageUrl: widget.item.mediaUrl,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
placeholder: (context, url) =>
|
||||||
|
const Center(child: CircularProgressIndicator()),
|
||||||
|
errorWidget: (context, url, error) =>
|
||||||
|
const Icon(Icons.error),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Center(
|
||||||
|
child: VideoWidget(
|
||||||
|
key: _videoKey,
|
||||||
|
details: widget.item,
|
||||||
|
isActive: true,
|
||||||
|
fullScreen: true,
|
||||||
|
initialPosition: widget.initialPosition,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SafeArea(
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.topLeft,
|
||||||
|
child: IconButton(
|
||||||
|
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
||||||
|
onPressed: _popWithPosition,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,74 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
|
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
|
||||||
|
|
||||||
import 'package:f0ckapp/models/mediaitem_model.dart';
|
|
||||||
import 'package:f0ckapp/widgets/video_widget.dart';
|
|
||||||
|
|
||||||
class FullScreenMediaView extends StatefulWidget {
|
|
||||||
final MediaItem item;
|
|
||||||
|
|
||||||
const FullScreenMediaView({super.key, required this.item});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State createState() => _FullScreenMediaViewState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _FullScreenMediaViewState extends State<FullScreenMediaView> {
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
SystemChrome.setPreferredOrientations(DeviceOrientation.values);
|
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
|
||||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: Colors.black,
|
|
||||||
body: Stack(
|
|
||||||
children: [
|
|
||||||
Positioned.fill(
|
|
||||||
child: widget.item.mime.startsWith('image')
|
|
||||||
? InteractiveViewer(
|
|
||||||
minScale: 1.0,
|
|
||||||
maxScale: 7.0,
|
|
||||||
child: CachedNetworkImage(
|
|
||||||
imageUrl: widget.item.mediaUrl,
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
placeholder: (context, url) =>
|
|
||||||
const Center(child: CircularProgressIndicator()),
|
|
||||||
errorWidget: (context, url, error) =>
|
|
||||||
const Icon(Icons.error),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: SizedBox.expand(
|
|
||||||
child: VideoWidget(
|
|
||||||
details: widget.item,
|
|
||||||
isActive: true,
|
|
||||||
fullScreen: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SafeArea(
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.topLeft,
|
|
||||||
child: IconButton(
|
|
||||||
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
134
lib/screens/login.dart
Normal file
134
lib/screens/login.dart
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import 'package:f0ckapp/controller/authcontroller.dart';
|
||||||
|
|
||||||
|
class LoginScreen extends StatefulWidget {
|
||||||
|
const LoginScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<LoginScreen> createState() => _LoginScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LoginScreenState extends State<LoginScreen> {
|
||||||
|
final AuthController authController = Get.put(AuthController());
|
||||||
|
final TextEditingController usernameController = TextEditingController();
|
||||||
|
final TextEditingController passwordController = TextEditingController();
|
||||||
|
|
||||||
|
bool _isLoading = false;
|
||||||
|
|
||||||
|
void _showMsg(String message, {String title = ''}) {
|
||||||
|
Get
|
||||||
|
..closeAllSnackbars()
|
||||||
|
..snackbar(title, message, snackPosition: SnackPosition.BOTTOM);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
usernameController.dispose();
|
||||||
|
passwordController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
body: Center(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.all(24),
|
||||||
|
child: Card(
|
||||||
|
elevation: 8,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(24),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.arrow_back),
|
||||||
|
tooltip: 'Zurück',
|
||||||
|
onPressed: () => Get.back(),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
'Login',
|
||||||
|
style: Theme.of(context).textTheme.headlineMedium,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
TextField(
|
||||||
|
controller: usernameController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Benutzername',
|
||||||
|
prefixIcon: Icon(Icons.person),
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
TextField(
|
||||||
|
controller: passwordController,
|
||||||
|
obscureText: true,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Passwort',
|
||||||
|
prefixIcon: Icon(Icons.lock),
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
if (authController.error.value != null)
|
||||||
|
Text(
|
||||||
|
authController.error.value!,
|
||||||
|
style: const TextStyle(color: Colors.red),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: _isLoading
|
||||||
|
? null
|
||||||
|
: () async {
|
||||||
|
setState(() => _isLoading = true);
|
||||||
|
final bool success = await authController.login(
|
||||||
|
usernameController.text,
|
||||||
|
passwordController.text,
|
||||||
|
);
|
||||||
|
setState(() => _isLoading = false);
|
||||||
|
if (!success) {
|
||||||
|
_showMsg(
|
||||||
|
'Login fehlgeschlagen!',
|
||||||
|
title: 'Fehler',
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
Get.offAllNamed('/');
|
||||||
|
_showMsg(
|
||||||
|
'Erfolgreich eingeloggt.',
|
||||||
|
title: 'Login',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: _isLoading
|
||||||
|
? const SizedBox(
|
||||||
|
width: 24,
|
||||||
|
height: 24,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const Text('Login'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,134 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import 'package:get/get.dart';
|
|
||||||
|
|
||||||
import 'package:f0ckapp/services/api_service.dart';
|
|
||||||
import 'package:f0ckapp/widgets/media_tile.dart';
|
|
||||||
import 'package:f0ckapp/widgets/end_drawer.dart';
|
|
||||||
import 'package:f0ckapp/widgets/filter_bar.dart';
|
|
||||||
import 'package:f0ckapp/utils/customsearchdelegate_util.dart';
|
|
||||||
|
|
||||||
class MediaGrid extends StatefulWidget {
|
|
||||||
const MediaGrid({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<StatefulWidget> createState() => _MediaGrid();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MediaGrid extends State<MediaGrid> {
|
|
||||||
final ApiService apiService = Get.find<ApiService>();
|
|
||||||
final ScrollController _scrollController = ScrollController();
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_scrollController.addListener(() async {
|
|
||||||
if (_scrollController.position.pixels >=
|
|
||||||
_scrollController.position.maxScrollExtent - 300) {
|
|
||||||
await apiService.fetchMedia();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
endDrawer: EndDrawer(),
|
|
||||||
persistentFooterButtons: [
|
|
||||||
Obx(() {
|
|
||||||
if (apiService.tag.value != null) {
|
|
||||||
return Center(
|
|
||||||
child: InputChip(
|
|
||||||
label: Text(apiService.tag.value!),
|
|
||||||
onDeleted: () {
|
|
||||||
apiService.setTag(null);
|
|
||||||
Get.offAllNamed('/');
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return SizedBox.shrink();
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
body: CustomScrollView(
|
|
||||||
controller: _scrollController,
|
|
||||||
slivers: [
|
|
||||||
SliverAppBar(
|
|
||||||
floating: true,
|
|
||||||
snap: true,
|
|
||||||
title: GestureDetector(
|
|
||||||
onTap: () async {
|
|
||||||
apiService.setTag(null);
|
|
||||||
},
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Image.asset(
|
|
||||||
'assets/images/f0ck_small.webp',
|
|
||||||
fit: BoxFit.fitHeight,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 10),
|
|
||||||
const Text('fApp', style: TextStyle(fontSize: 24)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.search),
|
|
||||||
onPressed: () async {
|
|
||||||
await showSearch(
|
|
||||||
context: context,
|
|
||||||
delegate: CustomSearchDelegate(),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Obx(
|
|
||||||
() => IconButton(
|
|
||||||
icon: Icon(
|
|
||||||
apiService.random.value
|
|
||||||
? Icons.shuffle_on_outlined
|
|
||||||
: Icons.shuffle,
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
apiService.toggleRandom();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Builder(
|
|
||||||
builder: (context) {
|
|
||||||
return IconButton(
|
|
||||||
icon: const Icon(Icons.menu),
|
|
||||||
onPressed: () {
|
|
||||||
Scaffold.of(context).openEndDrawer();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SliverPadding(
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
sliver: Obx(
|
|
||||||
() => SliverGrid(
|
|
||||||
delegate: SliverChildBuilderDelegate((context, index) {
|
|
||||||
return MediaTile(item: apiService.mediaItems[index]);
|
|
||||||
}, childCount: apiService.mediaItems.length),
|
|
||||||
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
|
||||||
maxCrossAxisExtent: 150,
|
|
||||||
crossAxisSpacing: 5,
|
|
||||||
mainAxisSpacing: 5,
|
|
||||||
childAspectRatio: 1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
bottomNavigationBar: FilterBar(scrollController: _scrollController),
|
|
||||||
floatingActionButton: FloatingActionButton(
|
|
||||||
onPressed: () {},
|
|
||||||
child: Icon(Icons.add),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
526
lib/screens/mediadetail.dart
Normal file
526
lib/screens/mediadetail.dart
Normal file
@ -0,0 +1,526 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
|
import 'package:flutter_cache_manager/file.dart';
|
||||||
|
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:pullex/pullex.dart';
|
||||||
|
import 'package:share_plus/share_plus.dart';
|
||||||
|
import 'package:timeago/timeago.dart' as timeago;
|
||||||
|
|
||||||
|
import 'package:f0ckapp/services/api.dart';
|
||||||
|
import 'package:f0ckapp/widgets/tagfooter.dart';
|
||||||
|
import 'package:f0ckapp/utils/animatedtransition.dart';
|
||||||
|
import 'package:f0ckapp/controller/authcontroller.dart';
|
||||||
|
import 'package:f0ckapp/widgets/favoritesection.dart';
|
||||||
|
import 'package:f0ckapp/screens/fullscreen.dart';
|
||||||
|
import 'package:f0ckapp/widgets/end_drawer.dart';
|
||||||
|
import 'package:f0ckapp/controller/settingscontroller.dart';
|
||||||
|
import 'package:f0ckapp/controller/mediacontroller.dart';
|
||||||
|
import 'package:f0ckapp/models/item.dart';
|
||||||
|
import 'package:f0ckapp/widgets/tagsection.dart';
|
||||||
|
import 'package:f0ckapp/widgets/video_widget.dart';
|
||||||
|
|
||||||
|
enum ShareAction { media, directLink, postLink }
|
||||||
|
|
||||||
|
class MediaDetailScreen extends StatefulWidget {
|
||||||
|
final int initialId;
|
||||||
|
const MediaDetailScreen({super.key, required this.initialId});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MediaDetailScreen> createState() => _MediaDetailScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MediaDetailScreenState extends State<MediaDetailScreen> {
|
||||||
|
PageController? _pageController;
|
||||||
|
final MediaController mediaController = Get.find<MediaController>();
|
||||||
|
final SettingsController settingsController = Get.find<SettingsController>();
|
||||||
|
final AuthController authController = Get.find<AuthController>();
|
||||||
|
final RxInt _currentIndex = 0.obs;
|
||||||
|
final MethodChannel _mediaSaverChannel = const MethodChannel('MediaShit');
|
||||||
|
final Map<int, PullexRefreshController> _refreshControllers = {};
|
||||||
|
final Map<int, GlobalKey<VideoWidgetState>> _videoWidgetKeys = {};
|
||||||
|
|
||||||
|
bool _isLoading = true;
|
||||||
|
bool _itemNotFound = false;
|
||||||
|
final RxSet<int> _readyItemIds = <int>{}.obs;
|
||||||
|
final Rxn<int> _animatingFavoriteId = Rxn<int>();
|
||||||
|
|
||||||
|
final List<PopupMenuEntry<ShareAction>> _shareMenuItems = const [
|
||||||
|
PopupMenuItem(
|
||||||
|
value: ShareAction.media,
|
||||||
|
child: ListTile(leading: Icon(Icons.image), title: Text('Als Datei')),
|
||||||
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
value: ShareAction.directLink,
|
||||||
|
child: ListTile(leading: Icon(Icons.link), title: Text('Link zur Datei')),
|
||||||
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
value: ShareAction.postLink,
|
||||||
|
child: ListTile(
|
||||||
|
leading: Icon(Icons.article),
|
||||||
|
title: Text('Link zum f0ck'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
timeago.setLocaleMessages('de', timeago.DeMessages());
|
||||||
|
_loadInitialItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadInitialItem() async {
|
||||||
|
int initialIndex = mediaController.items.indexWhere(
|
||||||
|
(item) => item.id == widget.initialId,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (initialIndex < 0) {
|
||||||
|
await mediaController.fetchInitial(id: widget.initialId + 20);
|
||||||
|
initialIndex = mediaController.items.indexWhere(
|
||||||
|
(item) => item.id == widget.initialId,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (initialIndex < 0) {
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {
|
||||||
|
_itemNotFound = true;
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mounted) {
|
||||||
|
_currentIndex.value = initialIndex;
|
||||||
|
_pageController = PageController(initialPage: initialIndex);
|
||||||
|
if (mediaController.items[initialIndex].mime.startsWith('image/')) {
|
||||||
|
_readyItemIds.add(mediaController.items[initialIndex].id);
|
||||||
|
}
|
||||||
|
setState(() => _isLoading = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showMsg(String message) {
|
||||||
|
if (!mounted) return;
|
||||||
|
Get
|
||||||
|
..closeAllSnackbars()
|
||||||
|
..snackbar('hehe', message, snackPosition: SnackPosition.BOTTOM);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _onRefresh(
|
||||||
|
int itemId,
|
||||||
|
PullexRefreshController controller,
|
||||||
|
) async {
|
||||||
|
if (mediaController.loading.value) {
|
||||||
|
controller.refreshCompleted();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
final MediaItem item = await ApiService().fetchItemById(itemId);
|
||||||
|
final int index = mediaController.items.indexWhere(
|
||||||
|
(item) => item.id == itemId,
|
||||||
|
);
|
||||||
|
if (index != -1) {
|
||||||
|
mediaController.items[index] = item;
|
||||||
|
mediaController.items.refresh();
|
||||||
|
}
|
||||||
|
controller.refreshCompleted();
|
||||||
|
} catch (e) {
|
||||||
|
_showMsg('Fehler beim Aktualisieren: $e');
|
||||||
|
controller.refreshFailed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onPageChanged(int idx) {
|
||||||
|
if (idx != _currentIndex.value) {
|
||||||
|
_currentIndex.value = idx;
|
||||||
|
final MediaItem item = mediaController.items[idx];
|
||||||
|
if (item.mime.startsWith('image/') && !_readyItemIds.contains(item.id)) {
|
||||||
|
_readyItemIds.add(item.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (idx + 1 < mediaController.items.length) {
|
||||||
|
DefaultCacheManager().downloadFile(
|
||||||
|
mediaController.items[idx + 1].mediaUrl,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (idx - 1 >= 0) {
|
||||||
|
DefaultCacheManager().downloadFile(
|
||||||
|
mediaController.items[idx - 1].mediaUrl,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (idx >= mediaController.items.length - 2 &&
|
||||||
|
!mediaController.loading.value &&
|
||||||
|
!mediaController.atEnd.value) {
|
||||||
|
mediaController.fetchMore();
|
||||||
|
} else if (idx <= 1 &&
|
||||||
|
!mediaController.loading.value &&
|
||||||
|
!mediaController.atStart.value) {
|
||||||
|
mediaController.fetchNewer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _downloadMedia(MediaItem item) async {
|
||||||
|
try {
|
||||||
|
final File file = await DefaultCacheManager().getSingleFile(
|
||||||
|
item.mediaUrl,
|
||||||
|
);
|
||||||
|
|
||||||
|
final bool? success = await _mediaSaverChannel.invokeMethod<bool>(
|
||||||
|
'saveFile',
|
||||||
|
{'filePath': file.path, 'fileName': item.dest},
|
||||||
|
);
|
||||||
|
|
||||||
|
success == true
|
||||||
|
? _showMsg('${item.dest} wurde in Downloads/fApp neigespeichert.')
|
||||||
|
: _showMsg('${item.dest} konnte nicht heruntergeladen werden.');
|
||||||
|
} catch (e) {
|
||||||
|
_showMsg('Fehler beim Download: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleShareAction(ShareAction value, MediaItem item) async {
|
||||||
|
try {
|
||||||
|
if (value == ShareAction.media) {
|
||||||
|
final File file = await DefaultCacheManager().getSingleFile(
|
||||||
|
item.mediaUrl,
|
||||||
|
);
|
||||||
|
final Uint8List bytes = await file.readAsBytes();
|
||||||
|
final ShareParams params = ShareParams(
|
||||||
|
files: [XFile.fromData(bytes, mimeType: item.mime)],
|
||||||
|
);
|
||||||
|
await SharePlus.instance.share(params);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String textToShare;
|
||||||
|
switch (value) {
|
||||||
|
case ShareAction.directLink:
|
||||||
|
textToShare = item.mediaUrl;
|
||||||
|
break;
|
||||||
|
case ShareAction.postLink:
|
||||||
|
textToShare = item.postUrl;
|
||||||
|
break;
|
||||||
|
case ShareAction.media:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await SharePlus.instance.share(ShareParams(text: textToShare));
|
||||||
|
} catch (e) {
|
||||||
|
_showMsg('Fehler beim Teilen: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleFullScreen(MediaItem currentItem) async {
|
||||||
|
if (currentItem.mime.startsWith('image')) {
|
||||||
|
Get.to(
|
||||||
|
() => FullScreenMediaView(item: currentItem),
|
||||||
|
fullscreenDialog: true,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final GlobalKey<VideoWidgetState>? key = _videoWidgetKeys[currentItem.id];
|
||||||
|
final VideoWidgetState? videoState = key?.currentState;
|
||||||
|
if (videoState == null || !videoState.videoController.value.isInitialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Duration position = videoState.videoController.value.position;
|
||||||
|
await videoState.videoController.pause();
|
||||||
|
|
||||||
|
final Duration? newPosition = await Get.to<Duration?>(
|
||||||
|
() => FullScreenMediaView(item: currentItem, initialPosition: position),
|
||||||
|
fullscreenDialog: true,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (mounted && videoState.mounted) {
|
||||||
|
if (newPosition != null) {
|
||||||
|
await videoState.videoController.seekTo(newPosition);
|
||||||
|
}
|
||||||
|
await videoState.videoController.play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_pageController?.dispose();
|
||||||
|
for (PullexRefreshController controller in _refreshControllers.values) {
|
||||||
|
controller.dispose();
|
||||||
|
}
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleFavoriteToggle(MediaItem item, bool isFavorite) async {
|
||||||
|
if (!authController.isLoggedIn) return;
|
||||||
|
HapticFeedback.lightImpact();
|
||||||
|
|
||||||
|
final List<Favorite>? newFavorites = await mediaController.toggleFavorite(
|
||||||
|
item,
|
||||||
|
isFavorite,
|
||||||
|
);
|
||||||
|
|
||||||
|
final int index = mediaController.items.indexWhere((i) => i.id == item.id);
|
||||||
|
|
||||||
|
if (newFavorites != null && index != -1) {
|
||||||
|
mediaController.items[index] = item.copyWith(favorites: newFavorites);
|
||||||
|
mediaController.items.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
_animatingFavoriteId.value = item.id;
|
||||||
|
Future.delayed(const Duration(milliseconds: 700), () {
|
||||||
|
if (_animatingFavoriteId.value == item.id) {
|
||||||
|
_animatingFavoriteId.value = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildMedia(MediaItem item, bool isActive) {
|
||||||
|
Widget mediaWidget;
|
||||||
|
final bool isFavorite =
|
||||||
|
item.favorites?.any((f) => f.userId == authController.user.value?.id) ??
|
||||||
|
false;
|
||||||
|
|
||||||
|
if (item.mime.startsWith('image/')) {
|
||||||
|
mediaWidget = CachedNetworkImage(
|
||||||
|
imageUrl: item.mediaUrl,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
placeholder: (context, url) =>
|
||||||
|
const Center(child: CircularProgressIndicator()),
|
||||||
|
errorWidget: (c, e, s) => const Icon(Icons.broken_image, size: 100),
|
||||||
|
);
|
||||||
|
} else if (item.mime.startsWith('video/') ||
|
||||||
|
item.mime.startsWith('audio/')) {
|
||||||
|
final GlobalKey<VideoWidgetState> key = _videoWidgetKeys.putIfAbsent(
|
||||||
|
item.id,
|
||||||
|
() => GlobalKey<VideoWidgetState>(),
|
||||||
|
);
|
||||||
|
mediaWidget = VideoWidget(
|
||||||
|
key: key,
|
||||||
|
details: item,
|
||||||
|
isActive: isActive,
|
||||||
|
onInitialized: () {
|
||||||
|
if (mounted && !_readyItemIds.contains(item.id)) {
|
||||||
|
_readyItemIds.add(item.id);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
mediaWidget = const Icon(Icons.help_outline, size: 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Hero(
|
||||||
|
tag: 'media_${item.id}',
|
||||||
|
child: Stack(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
children: [
|
||||||
|
GestureDetector(
|
||||||
|
onDoubleTap: () => _handleFavoriteToggle(item, isFavorite),
|
||||||
|
child: mediaWidget,
|
||||||
|
),
|
||||||
|
Obx(() {
|
||||||
|
final showAnimation = _animatingFavoriteId.value == item.id;
|
||||||
|
return AnimatedOpacity(
|
||||||
|
opacity: showAnimation ? 1.0 : 0.0,
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
child: AnimatedScale(
|
||||||
|
scale: showAnimation ? 1.0 : 0.5,
|
||||||
|
duration: const Duration(milliseconds: 400),
|
||||||
|
curve: Curves.easeOutBack,
|
||||||
|
child: Icon(
|
||||||
|
isFavorite ? Icons.favorite : Icons.favorite_outline,
|
||||||
|
color: Colors.red,
|
||||||
|
size: 100,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
PreferredSizeWidget _buildAppBar(BuildContext context) {
|
||||||
|
return AppBar(
|
||||||
|
title: Obx(() {
|
||||||
|
if (_isLoading) {
|
||||||
|
return Text('Lade f0ck #${widget.initialId}...');
|
||||||
|
}
|
||||||
|
if (_itemNotFound ||
|
||||||
|
mediaController.items.isEmpty ||
|
||||||
|
_currentIndex.value >= mediaController.items.length) {
|
||||||
|
return const Text('Fehler');
|
||||||
|
}
|
||||||
|
final MediaItem currentItem =
|
||||||
|
mediaController.items[_currentIndex.value];
|
||||||
|
return Text('f0ck #${currentItem.id}');
|
||||||
|
}),
|
||||||
|
actions: [
|
||||||
|
Obx(() {
|
||||||
|
final bool showActions =
|
||||||
|
!_isLoading &&
|
||||||
|
!_itemNotFound &&
|
||||||
|
mediaController.items.isNotEmpty &&
|
||||||
|
_currentIndex.value < mediaController.items.length;
|
||||||
|
|
||||||
|
if (!showActions) {
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
final MediaItem currentItem =
|
||||||
|
mediaController.items[_currentIndex.value];
|
||||||
|
return Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.fullscreen),
|
||||||
|
onPressed: () => _handleFullScreen(currentItem),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.download),
|
||||||
|
onPressed: () async => await _downloadMedia(currentItem),
|
||||||
|
),
|
||||||
|
PopupMenuButton<ShareAction>(
|
||||||
|
onSelected: (value) => _handleShareAction(value, currentItem),
|
||||||
|
itemBuilder: (context) => _shareMenuItems,
|
||||||
|
icon: const Icon(Icons.share),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
Builder(
|
||||||
|
builder: (context) => IconButton(
|
||||||
|
icon: const Icon(Icons.menu),
|
||||||
|
onPressed: () => Scaffold.of(context).openEndDrawer(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildBody(BuildContext context) {
|
||||||
|
if (_isLoading) {
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_itemNotFound) {
|
||||||
|
return const Center(child: Text('f0ck nicht gefunden.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Obx(() {
|
||||||
|
if (mediaController.items.isEmpty) {
|
||||||
|
return const Center(child: Text('Keine Items zum Anzeigen.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return PageView.builder(
|
||||||
|
controller: _pageController!,
|
||||||
|
itemCount: mediaController.items.length,
|
||||||
|
onPageChanged: _onPageChanged,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if (index >= mediaController.items.length) {
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
final MediaItem item = mediaController.items[index];
|
||||||
|
final PullexRefreshController refreshController = _refreshControllers
|
||||||
|
.putIfAbsent(item.id, () => PullexRefreshController());
|
||||||
|
|
||||||
|
return Obx(() {
|
||||||
|
final bool isReady = _readyItemIds.contains(item.id);
|
||||||
|
return PullexRefresh(
|
||||||
|
onRefresh: () => _onRefresh(item.id, refreshController),
|
||||||
|
header: const WaterDropHeader(),
|
||||||
|
controller: refreshController,
|
||||||
|
child: CustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: AnimatedBuilder(
|
||||||
|
animation: _pageController!,
|
||||||
|
builder: (context, child) {
|
||||||
|
return buildAnimatedTransition(
|
||||||
|
context: context,
|
||||||
|
pageController: _pageController!,
|
||||||
|
index: index,
|
||||||
|
child: child!,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Obx(
|
||||||
|
() => _buildMedia(item, index == _currentIndex.value),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (isReady)
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
TagSection(tags: item.tags ?? []),
|
||||||
|
Obx(() {
|
||||||
|
if (!authController.isLoggedIn) {
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
final TextStyle? infoTextStyle = Theme.of(
|
||||||
|
context,
|
||||||
|
).textTheme.bodySmall;
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 24.0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
FavoriteSection(item: item, index: index),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Text(
|
||||||
|
"Dateigröße: ${(item.size / 1024).toStringAsFixed(1)} KB",
|
||||||
|
style: infoTextStyle,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"Typ: ${item.mime}",
|
||||||
|
style: infoTextStyle,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"ID: ${item.id}",
|
||||||
|
style: infoTextStyle,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"Hochgeladen: ${timeago.format(DateTime.fromMillisecondsSinceEpoch(item.stamp * 1000), locale: 'de')}",
|
||||||
|
style: infoTextStyle,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SliverToBoxAdapter(
|
||||||
|
child: SafeArea(child: SizedBox.shrink()),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
endDrawer: const EndDrawer(),
|
||||||
|
endDrawerEnableOpenDragGesture:
|
||||||
|
settingsController.drawerSwipeEnabled.value,
|
||||||
|
appBar: _buildAppBar(context),
|
||||||
|
body: _buildBody(context),
|
||||||
|
persistentFooterButtons: mediaController.tag.value != null
|
||||||
|
? [TagFooter()]
|
||||||
|
: null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
264
lib/screens/mediagrid.dart
Normal file
264
lib/screens/mediagrid.dart
Normal file
@ -0,0 +1,264 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:pullex/pullex.dart';
|
||||||
|
|
||||||
|
import 'package:f0ckapp/models/item.dart';
|
||||||
|
import 'package:f0ckapp/widgets/tagfooter.dart';
|
||||||
|
import 'package:f0ckapp/utils/customsearchdelegate.dart';
|
||||||
|
import 'package:f0ckapp/widgets/end_drawer.dart';
|
||||||
|
import 'package:f0ckapp/widgets/filter_bar.dart';
|
||||||
|
import 'package:f0ckapp/widgets/media_tile.dart';
|
||||||
|
import 'package:f0ckapp/controller/settingscontroller.dart';
|
||||||
|
import 'package:f0ckapp/controller/mediacontroller.dart';
|
||||||
|
|
||||||
|
class MediaGrid extends StatefulWidget {
|
||||||
|
const MediaGrid({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MediaGrid> createState() => _MediaGrid();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MediaGrid extends State<MediaGrid> {
|
||||||
|
final ScrollController _scrollController = ScrollController();
|
||||||
|
final MediaController _mediaController = Get.put(MediaController());
|
||||||
|
final SettingsController _settingsController = Get.put(SettingsController());
|
||||||
|
final PullexRefreshController _refreshController = PullexRefreshController(
|
||||||
|
initialRefresh: false,
|
||||||
|
);
|
||||||
|
|
||||||
|
late final _MediaGridAppBar _appBar;
|
||||||
|
late final _MediaGridBody _body;
|
||||||
|
Worker? _filterWorker;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_mediaController.fetchInitial();
|
||||||
|
|
||||||
|
_filterWorker = everAll(
|
||||||
|
[
|
||||||
|
_mediaController.typeIndex,
|
||||||
|
_mediaController.modeIndex,
|
||||||
|
_mediaController.tag,
|
||||||
|
_mediaController.random,
|
||||||
|
],
|
||||||
|
(_) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
_refreshController.requestRefresh();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
_appBar = _MediaGridAppBar(mediaController: _mediaController);
|
||||||
|
_body = _MediaGridBody(
|
||||||
|
refreshController: _refreshController,
|
||||||
|
mediaController: _mediaController,
|
||||||
|
settingsController: _settingsController,
|
||||||
|
scrollController: _scrollController,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_filterWorker?.dispose();
|
||||||
|
_scrollController.dispose();
|
||||||
|
_refreshController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Obx(() {
|
||||||
|
if (_mediaController.loading.value && _mediaController.items.isEmpty) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: _appBar,
|
||||||
|
body: const Center(child: CircularProgressIndicator()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_mediaController.errorMessage.value != null &&
|
||||||
|
_mediaController.items.isEmpty) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: _appBar,
|
||||||
|
body: Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.error_outline, color: Colors.red, size: 60),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Text(
|
||||||
|
'${_mediaController.errorMessage.value}',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () => _mediaController.fetchInitial(),
|
||||||
|
child: const Text('Erneut versuchen'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
endDrawer: const EndDrawer(),
|
||||||
|
endDrawerEnableOpenDragGesture:
|
||||||
|
_settingsController.drawerSwipeEnabled.value,
|
||||||
|
bottomNavigationBar: FilterBar(),
|
||||||
|
appBar: _appBar,
|
||||||
|
body: _body,
|
||||||
|
persistentFooterButtons: _mediaController.tag.value != null
|
||||||
|
? [TagFooter()]
|
||||||
|
: null,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MediaGridAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||||
|
const _MediaGridAppBar({required this.mediaController});
|
||||||
|
|
||||||
|
final MediaController mediaController;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AppBar(
|
||||||
|
title: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
if (mediaController.tag.value != null) {
|
||||||
|
mediaController.setTag(null);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Image.asset('assets/images/f0ck_small.webp', fit: BoxFit.fitHeight),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
const Text('fApp', style: TextStyle(fontSize: 24)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.search),
|
||||||
|
onPressed: () async {
|
||||||
|
await showSearch(
|
||||||
|
context: context,
|
||||||
|
delegate: CustomSearchDelegate(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Obx(
|
||||||
|
() => IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
mediaController.isRandomEnabled
|
||||||
|
? Icons.shuffle_on_outlined
|
||||||
|
: Icons.shuffle,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
mediaController.toggleRandom();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.menu),
|
||||||
|
onPressed: () => Scaffold.of(context).openEndDrawer(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MediaGridBody extends StatelessWidget {
|
||||||
|
const _MediaGridBody({
|
||||||
|
required this.refreshController,
|
||||||
|
required this.mediaController,
|
||||||
|
required this.settingsController,
|
||||||
|
required this.scrollController,
|
||||||
|
});
|
||||||
|
|
||||||
|
final PullexRefreshController refreshController;
|
||||||
|
final MediaController mediaController;
|
||||||
|
final SettingsController settingsController;
|
||||||
|
final ScrollController scrollController;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
if (mediaController.items.isEmpty && !mediaController.loading.value) {
|
||||||
|
return const Center(
|
||||||
|
child: Text(
|
||||||
|
'Keine f0cks gefunden.\n\nVersuch mal andere Filter.',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return NotificationListener<ScrollNotification>(
|
||||||
|
onNotification: (scrollInfo) {
|
||||||
|
if (!mediaController.loading.value &&
|
||||||
|
!mediaController.atEnd.value &&
|
||||||
|
scrollInfo.metrics.pixels >=
|
||||||
|
scrollInfo.metrics.maxScrollExtent - 600) {
|
||||||
|
mediaController.handleLoading();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
child: PullexRefresh(
|
||||||
|
controller: refreshController,
|
||||||
|
onRefresh: () async {
|
||||||
|
try {
|
||||||
|
await mediaController.handleRefresh();
|
||||||
|
} finally {
|
||||||
|
refreshController.refreshCompleted();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
header: const WaterDropHeader(),
|
||||||
|
child: Obx(
|
||||||
|
() => GridView.builder(
|
||||||
|
addAutomaticKeepAlives: false,
|
||||||
|
controller: scrollController,
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
padding: const EdgeInsets.all(4),
|
||||||
|
itemCount: mediaController.items.length,
|
||||||
|
gridDelegate: settingsController.crossAxisCount.value == 0
|
||||||
|
? const SliverGridDelegateWithMaxCrossAxisExtent(
|
||||||
|
maxCrossAxisExtent: 150,
|
||||||
|
crossAxisSpacing: 5,
|
||||||
|
mainAxisSpacing: 5,
|
||||||
|
childAspectRatio: 1,
|
||||||
|
)
|
||||||
|
: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
|
crossAxisCount: settingsController.crossAxisCount.value,
|
||||||
|
crossAxisSpacing: 5,
|
||||||
|
mainAxisSpacing: 5,
|
||||||
|
childAspectRatio: 1,
|
||||||
|
),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final MediaItem item = mediaController.items[index];
|
||||||
|
return Hero(
|
||||||
|
tag: 'media_${item.id}',
|
||||||
|
child: Material(
|
||||||
|
type: MaterialType.transparency,
|
||||||
|
child: GestureDetector(
|
||||||
|
key: ValueKey(item.id),
|
||||||
|
onTap: () => Get.toNamed('/${item.id}'),
|
||||||
|
child: MediaTile(item: item),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
163
lib/screens/settings.dart
Normal file
163
lib/screens/settings.dart
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import 'package:f0ckapp/controller/localizationcontroller.dart';
|
||||||
|
import 'package:f0ckapp/controller/settingscontroller.dart';
|
||||||
|
import 'package:f0ckapp/utils/animatedtransition.dart';
|
||||||
|
|
||||||
|
class SettingsPage extends StatefulWidget {
|
||||||
|
const SettingsPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StatefulWidget> createState() => _SettingsPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SettingsPageState extends State<SettingsPage> {
|
||||||
|
final SettingsController settingsController = Get.find<SettingsController>();
|
||||||
|
final LocalizationController localizationController = Get.find<LocalizationController>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
body: CustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
SliverAppBar(
|
||||||
|
floating: false,
|
||||||
|
pinned: true,
|
||||||
|
title: Text('settings_title'.tr),
|
||||||
|
),
|
||||||
|
SliverList(
|
||||||
|
delegate: SliverChildListDelegate([
|
||||||
|
ListTile(
|
||||||
|
title: Text('settings_numberofcolumns_title'.tr),
|
||||||
|
trailing: Obx(
|
||||||
|
() => DropdownButton<int>(
|
||||||
|
value: settingsController.crossAxisCount.value,
|
||||||
|
dropdownColor: const Color.fromARGB(255, 43, 43, 43),
|
||||||
|
iconEnabledColor: Colors.white,
|
||||||
|
items: [0, 3, 4, 5].map((int value) {
|
||||||
|
return DropdownMenuItem<int>(
|
||||||
|
value: value,
|
||||||
|
child: Text(
|
||||||
|
value == 0
|
||||||
|
? 'auto'
|
||||||
|
: 'settings_numberofcolumns_columns'.trParams({
|
||||||
|
'count': value.toString(),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
onChanged: (int? newValue) async {
|
||||||
|
if (newValue != null) {
|
||||||
|
await settingsController.setCrossAxisCount(newValue);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Divider(),
|
||||||
|
ListTile(
|
||||||
|
title: Text('settings_pageanimation_title'.tr),
|
||||||
|
trailing: Obx(
|
||||||
|
() => DropdownButton<PageTransition>(
|
||||||
|
value: settingsController.transitionType.value,
|
||||||
|
dropdownColor: const Color.fromARGB(255, 43, 43, 43),
|
||||||
|
iconEnabledColor: Colors.white,
|
||||||
|
items: PageTransition.values.map((PageTransition type) {
|
||||||
|
String label;
|
||||||
|
switch (type) {
|
||||||
|
case PageTransition.opacity:
|
||||||
|
label = 'Opacity';
|
||||||
|
break;
|
||||||
|
case PageTransition.scale:
|
||||||
|
label = 'Scale';
|
||||||
|
break;
|
||||||
|
case PageTransition.slide:
|
||||||
|
label = 'Slide';
|
||||||
|
break;
|
||||||
|
case PageTransition.rotate:
|
||||||
|
label = 'Rotate';
|
||||||
|
break;
|
||||||
|
case PageTransition.flip:
|
||||||
|
label = 'Flip';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return DropdownMenuItem<PageTransition>(
|
||||||
|
value: type,
|
||||||
|
child: Text(label),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
onChanged: (PageTransition? newValue) async {
|
||||||
|
if (newValue != null) {
|
||||||
|
await settingsController.setTransitionType(newValue);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
const Divider(),
|
||||||
|
SwitchListTile(
|
||||||
|
title: Text('settings_drawer_title'.tr),
|
||||||
|
subtitle: Text('settings_drawer_subtitle'.tr),
|
||||||
|
value: settingsController.drawerSwipeEnabled.value,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
await settingsController.setDrawerSwipeEnabled(value);
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const Divider(),
|
||||||
|
ListTile(
|
||||||
|
title: Text('settings_language'.tr),
|
||||||
|
trailing: Obx(
|
||||||
|
() => DropdownButton<Locale>(
|
||||||
|
value: localizationController.currentLocale.value,
|
||||||
|
dropdownColor: const Color.fromARGB(255, 43, 43, 43),
|
||||||
|
iconEnabledColor: Colors.white,
|
||||||
|
items: const [
|
||||||
|
DropdownMenuItem<Locale>(
|
||||||
|
value: Locale('en', 'US'),
|
||||||
|
child: Text('English'),
|
||||||
|
),
|
||||||
|
DropdownMenuItem<Locale>(
|
||||||
|
value: Locale('de', 'DE'),
|
||||||
|
child: Text('Deutsch'),
|
||||||
|
),
|
||||||
|
DropdownMenuItem<Locale>(
|
||||||
|
value: Locale('fr', 'FR'),
|
||||||
|
child: Text('Français'),
|
||||||
|
),
|
||||||
|
DropdownMenuItem<Locale>(
|
||||||
|
value: Locale('nl', 'NL'),
|
||||||
|
child: Text('Nederlands'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
onChanged: (Locale? newLocale) async {
|
||||||
|
if (newLocale != null) {
|
||||||
|
await localizationController.changeLocale(newLocale);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Divider(),
|
||||||
|
ListTile(
|
||||||
|
title: Text('settings_cache_title'.tr),
|
||||||
|
trailing: ElevatedButton(
|
||||||
|
onPressed: () async {
|
||||||
|
await DefaultCacheManager().emptyCache();
|
||||||
|
if (!mounted) return;
|
||||||
|
Get.snackbar('', 'der Cache wurde geleert.');
|
||||||
|
},
|
||||||
|
child: Text('settings_cache_clear_button'.tr),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,106 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
|
||||||
|
|
||||||
import 'package:f0ckapp/widgets/end_drawer.dart';
|
|
||||||
import 'package:get/get.dart';
|
|
||||||
|
|
||||||
class SettingsPage extends StatefulWidget {
|
|
||||||
const SettingsPage({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<StatefulWidget> createState() => _SettingsPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _SettingsPageState extends State<SettingsPage> {
|
|
||||||
int _columns = 3;
|
|
||||||
bool _drawerSwipeEnabled = true;
|
|
||||||
|
|
||||||
void _showMsg(String message, BuildContext context) {
|
|
||||||
ScaffoldMessenger.of(context)
|
|
||||||
..removeCurrentSnackBar()
|
|
||||||
..showSnackBar(SnackBar(content: Text(message)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
endDrawerEnableOpenDragGesture: _drawerSwipeEnabled,
|
|
||||||
endDrawer: EndDrawer(),
|
|
||||||
body: CustomScrollView(
|
|
||||||
slivers: [
|
|
||||||
SliverAppBar(
|
|
||||||
floating: false,
|
|
||||||
pinned: true,
|
|
||||||
title: const Text('Settings'),
|
|
||||||
leading: IconButton(
|
|
||||||
icon: const Icon(Icons.arrow_back),
|
|
||||||
onPressed: () {
|
|
||||||
Get.back();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SliverList(
|
|
||||||
delegate: SliverChildListDelegate([
|
|
||||||
/*Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: Text(
|
|
||||||
"Anzahl der Spalten",
|
|
||||||
style: Theme.of(context).textTheme.titleLarge,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: const Text("Spaltenanzahl"),
|
|
||||||
trailing: DropdownButton<int>(
|
|
||||||
value: mediaState.crossAxisCount,
|
|
||||||
dropdownColor: const Color.fromARGB(255, 43, 43, 43),
|
|
||||||
iconEnabledColor: Colors.white,
|
|
||||||
items: [0, 3, 4, 5].map((int value) {
|
|
||||||
return DropdownMenuItem<int>(
|
|
||||||
value: value,
|
|
||||||
child: Text(value == 0 ? 'auto' : '$value Spalten'),
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
onChanged: (int? newValue) {
|
|
||||||
if (newValue != null) {
|
|
||||||
setState(() {
|
|
||||||
_columns = newValue;
|
|
||||||
mediaNotifier.setCrossAxisCount(newValue);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),*/
|
|
||||||
const Divider(),
|
|
||||||
SwitchListTile(
|
|
||||||
title: const Text("Drawer per Geste öffnen"),
|
|
||||||
subtitle: const Text(
|
|
||||||
"Wähle, ob der Drawer mit einer Wischgeste geschlossen/ geöffnet werden kann.",
|
|
||||||
),
|
|
||||||
value: _drawerSwipeEnabled,
|
|
||||||
onChanged: (bool value) {
|
|
||||||
setState(() {
|
|
||||||
_drawerSwipeEnabled = value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const Divider(),
|
|
||||||
ListTile(
|
|
||||||
title: Text("Cache löschen"),
|
|
||||||
trailing: ElevatedButton(
|
|
||||||
onPressed: () async {
|
|
||||||
await DefaultCacheManager().emptyCache();
|
|
||||||
if (!mounted) return;
|
|
||||||
_showMsg('Cache wurde geleert.', context);
|
|
||||||
},
|
|
||||||
child: const Text("Löschen"),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
110
lib/services/api.dart
Normal file
110
lib/services/api.dart
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import 'package:f0ckapp/controller/authcontroller.dart';
|
||||||
|
import 'package:f0ckapp/models/item.dart';
|
||||||
|
import 'package:f0ckapp/models/feed.dart';
|
||||||
|
|
||||||
|
class ApiService extends GetConnect {
|
||||||
|
final AuthController _authController = Get.find<AuthController>();
|
||||||
|
|
||||||
|
Future<Feed> fetchItems({
|
||||||
|
int? older,
|
||||||
|
int? newer,
|
||||||
|
int type = 0,
|
||||||
|
int mode = 0,
|
||||||
|
int random = 0,
|
||||||
|
String? tag,
|
||||||
|
}) async {
|
||||||
|
String? token = _authController.token.value;
|
||||||
|
final params = <String, String>{
|
||||||
|
'type': type.toString(),
|
||||||
|
'mode': mode.toString(),
|
||||||
|
'random': random.toString(),
|
||||||
|
};
|
||||||
|
if (older != null) params['older'] = older.toString();
|
||||||
|
if (newer != null) params['newer'] = newer.toString();
|
||||||
|
if (tag != null) params['tag'] = tag;
|
||||||
|
|
||||||
|
final Map<String, String> headers = <String, String>{};
|
||||||
|
if (token != null && token.isNotEmpty) {
|
||||||
|
headers['Authorization'] = 'Bearer $token';
|
||||||
|
}
|
||||||
|
|
||||||
|
final Response<dynamic> response = await get(
|
||||||
|
'https://api.f0ck.me/items/get',
|
||||||
|
query: params,
|
||||||
|
headers: headers,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.status.code == 200 && response.body is Map<String, dynamic>) {
|
||||||
|
final Feed feed = Feed.fromJson(response.body as Map<String, dynamic>);
|
||||||
|
feed.items.sort((a, b) => b.id.compareTo(a.id));
|
||||||
|
return feed;
|
||||||
|
} else {
|
||||||
|
if (!Get.isSnackbarOpen) {
|
||||||
|
Get.snackbar('Fehler', 'Fehler beim Laden der Items');
|
||||||
|
}
|
||||||
|
throw Exception('Fehler beim Laden der Items');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<MediaItem> fetchItemById(int itemId) async {
|
||||||
|
String? token = _authController.token.value;
|
||||||
|
final Map<String, String> headers = <String, String>{};
|
||||||
|
if (token != null && token.isNotEmpty) {
|
||||||
|
headers['Authorization'] = 'Bearer $token';
|
||||||
|
}
|
||||||
|
|
||||||
|
final Response<dynamic> response = await get(
|
||||||
|
'https://api.f0ck.me/item/$itemId',
|
||||||
|
headers: headers,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.status.code == 200 && response.body is Map<String, dynamic>) {
|
||||||
|
return MediaItem.fromJson(response.body as Map<String, dynamic>);
|
||||||
|
} else {
|
||||||
|
if (!Get.isSnackbarOpen) {
|
||||||
|
Get.snackbar('Fehler', 'Fehler beim Laden des Items');
|
||||||
|
}
|
||||||
|
throw Exception('Fehler beim Laden des Items');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<Favorite>?> toggleFavorite(
|
||||||
|
MediaItem item,
|
||||||
|
bool isFavorite,
|
||||||
|
) async {
|
||||||
|
String? token = _authController.token.value;
|
||||||
|
if (token == null || token.isEmpty) return null;
|
||||||
|
|
||||||
|
final Map<String, String> headers = {
|
||||||
|
'Authorization': 'Bearer $token',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
Response response;
|
||||||
|
if (!isFavorite) {
|
||||||
|
response = await put(
|
||||||
|
'https://api.f0ck.me/favorites/${item.id}',
|
||||||
|
null,
|
||||||
|
headers: headers,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
response = await delete(
|
||||||
|
'https://api.f0ck.me/favorites/${item.id}',
|
||||||
|
headers: headers,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (response.status.code == 200 && response.body is List) {
|
||||||
|
return (response.body as List)
|
||||||
|
.map((json) => Favorite.fromJson(json))
|
||||||
|
.toList();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,94 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import 'package:get/get.dart';
|
|
||||||
|
|
||||||
import 'package:f0ckapp/models/mediaitem_model.dart';
|
|
||||||
|
|
||||||
const List<String> mediaTypes = ["alles", "image", "video", "audio"];
|
|
||||||
const List<String> mediaModes = ["sfw", "nsfw", "untagged", "all"];
|
|
||||||
|
|
||||||
class ApiService extends GetConnect {
|
|
||||||
RxList<MediaItem> mediaItems = <MediaItem>[].obs;
|
|
||||||
RxnString tag = RxnString();
|
|
||||||
RxInt type = 0.obs;
|
|
||||||
RxInt mode = 0.obs;
|
|
||||||
RxBool random = false.obs;
|
|
||||||
|
|
||||||
bool _isFetching = false;
|
|
||||||
DateTime? _lastFetchTime;
|
|
||||||
final Duration _minFetchInterval = Duration(milliseconds: 500);
|
|
||||||
|
|
||||||
@override
|
|
||||||
void onInit() {
|
|
||||||
super.onInit();
|
|
||||||
everAll([tag, type, mode, random], (_) => fetchMedia(reset: true));
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> setTag(String? newTag) async {
|
|
||||||
tag.value = newTag;
|
|
||||||
return await fetchMedia(reset: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> setType(int newType) async {
|
|
||||||
type.value = newType >= 0 && newType < mediaTypes.length ? newType : 0;
|
|
||||||
return await fetchMedia(reset: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> setMode(int newMode) async {
|
|
||||||
mode.value = newMode >= 0 && newMode < mediaModes.length ? newMode : 0;
|
|
||||||
return await fetchMedia(reset: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> toggleRandom() async {
|
|
||||||
random.value = !random.value;
|
|
||||||
return await fetchMedia(reset: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future fetchMedia({int? id, bool reset = false}) async {
|
|
||||||
if (!reset) {
|
|
||||||
if (_isFetching) return;
|
|
||||||
if (_lastFetchTime != null &&
|
|
||||||
DateTime.now().difference(_lastFetchTime!) < _minFetchInterval) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_lastFetchTime = DateTime.now();
|
|
||||||
_isFetching = true;
|
|
||||||
|
|
||||||
if (reset) mediaItems.clear();
|
|
||||||
|
|
||||||
final int? older =
|
|
||||||
id ?? (mediaItems.isNotEmpty ? mediaItems.last.id : null);
|
|
||||||
final Uri url = Uri.parse('https://api.f0ck.me/items/get').replace(
|
|
||||||
queryParameters: {
|
|
||||||
'type': mediaTypes[type.value],
|
|
||||||
'mode': mode.value.toString(),
|
|
||||||
'random': (random.value ? 1 : 0).toString(),
|
|
||||||
if (tag.value != null) 'tag': tag.value,
|
|
||||||
if (older != null) 'older': older.toString(),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
|
||||||
final Response<dynamic> response = await get(url.toString());
|
|
||||||
|
|
||||||
if (response.isOk && response.body is List) {
|
|
||||||
List<MediaItem> newMedia = (response.body as List)
|
|
||||||
.map((json) => MediaItem.fromJson(json))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
if (reset) {
|
|
||||||
mediaItems.assignAll(newMedia);
|
|
||||||
} else {
|
|
||||||
mediaItems.addAll(newMedia);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
debugPrint('Fehler beim Laden der MediaItems: ${response.statusText}');
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
debugPrint('Exception beim Laden der MediaItems: $e');
|
|
||||||
} finally {
|
|
||||||
_isFetching = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
49
lib/utils/animatedtransition.dart
Normal file
49
lib/utils/animatedtransition.dart
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import 'package:f0ckapp/controller/settingscontroller.dart';
|
||||||
|
|
||||||
|
enum PageTransition { opacity, scale, slide, rotate, flip }
|
||||||
|
|
||||||
|
Widget buildAnimatedTransition({
|
||||||
|
required BuildContext context,
|
||||||
|
required Widget child,
|
||||||
|
required PageController pageController,
|
||||||
|
required int index,
|
||||||
|
}) {
|
||||||
|
final SettingsController settingsController = Get.find<SettingsController>();
|
||||||
|
final double value = pageController.position.haveDimensions
|
||||||
|
? pageController.page! - index
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
switch (settingsController.transitionType.value) {
|
||||||
|
case PageTransition.opacity:
|
||||||
|
return Opacity(
|
||||||
|
opacity: Curves.easeOut.transform(1 - value.abs().clamp(0.0, 1.0)),
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
case PageTransition.scale:
|
||||||
|
return Transform.scale(
|
||||||
|
scale:
|
||||||
|
0.8 +
|
||||||
|
Curves.easeOut.transform(1 - value.abs().clamp(0.0, 1.0)) * 0.2,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
case PageTransition.slide:
|
||||||
|
return child;
|
||||||
|
case PageTransition.rotate:
|
||||||
|
return Opacity(
|
||||||
|
opacity: (1 - value.abs()).clamp(0.0, 1.0),
|
||||||
|
child: Transform.rotate(angle: value.abs() * 0.5, child: child),
|
||||||
|
);
|
||||||
|
case PageTransition.flip:
|
||||||
|
return Transform(
|
||||||
|
transform: Matrix4.identity()
|
||||||
|
..setEntry(3, 2, 0.001)
|
||||||
|
..rotateY(value.abs()),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
12
lib/utils/appversion.dart
Normal file
12
lib/utils/appversion.dart
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
class AppVersion {
|
||||||
|
static late String version;
|
||||||
|
|
||||||
|
static Future<void> init() async {
|
||||||
|
final String yaml = await rootBundle.loadString('pubspec.yaml');
|
||||||
|
final RegExpMatch? match = RegExp(r'^version:\s*(.*)$', multiLine: true).firstMatch(yaml);
|
||||||
|
final String? v = match?.group(1)!.replaceAll('"', '').replaceAll("'", '').trim();
|
||||||
|
version = v ?? "";
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +0,0 @@
|
|||||||
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}';
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,13 +4,13 @@ import 'dart:convert';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:http/http.dart' as http;
|
|
||||||
|
|
||||||
import 'package:f0ckapp/services/api_service.dart';
|
import 'package:f0ckapp/controller/mediacontroller.dart';
|
||||||
import 'package:f0ckapp/models/suggestion_model.dart';
|
import 'package:f0ckapp/models/suggestion.dart';
|
||||||
|
|
||||||
class CustomSearchDelegate extends SearchDelegate<String> {
|
class CustomSearchDelegate extends SearchDelegate<String> {
|
||||||
final ApiService apiService = Get.find<ApiService>();
|
final MediaController controller = Get.find<MediaController>();
|
||||||
|
final GetConnect http = GetConnect();
|
||||||
Timer? _debounceTimer;
|
Timer? _debounceTimer;
|
||||||
List<Suggestion>? _suggestions;
|
List<Suggestion>? _suggestions;
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
@ -48,14 +48,16 @@ class CustomSearchDelegate extends SearchDelegate<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Suggestion>> fetchSuggestions(String query) async {
|
Future<List<Suggestion>> fetchSuggestions(String query) async {
|
||||||
final Uri uri = Uri.parse('https://api.f0ck.me/search/?q=$query');
|
final String url = 'https://api.f0ck.me/search/?q=$query';
|
||||||
try {
|
try {
|
||||||
final http.Response response = await http
|
final Response<dynamic> response = await http
|
||||||
.get(uri)
|
.get(url)
|
||||||
.timeout(const Duration(seconds: 5));
|
.timeout(const Duration(seconds: 5));
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
final dynamic decoded = jsonDecode(response.body);
|
final dynamic decoded = response.body is String
|
||||||
|
? jsonDecode(response.body)
|
||||||
|
: response.body;
|
||||||
if (decoded is List) {
|
if (decoded is List) {
|
||||||
final suggestions = decoded
|
final suggestions = decoded
|
||||||
.map((item) => Suggestion.fromJson(item as Map<String, dynamic>))
|
.map((item) => Suggestion.fromJson(item as Map<String, dynamic>))
|
||||||
@ -66,7 +68,9 @@ class CustomSearchDelegate extends SearchDelegate<String> {
|
|||||||
throw Exception('Unerwartetes Format: Es wurde eine Liste erwartet.');
|
throw Exception('Unerwartetes Format: Es wurde eine Liste erwartet.');
|
||||||
}
|
}
|
||||||
} else if (response.statusCode == 400) {
|
} else if (response.statusCode == 400) {
|
||||||
final dynamic error = jsonDecode(response.body);
|
final dynamic error = response.body is String
|
||||||
|
? jsonDecode(response.body)
|
||||||
|
: response.body;
|
||||||
final String message = error is Map<String, dynamic>
|
final String message = error is Map<String, dynamic>
|
||||||
? error['detail']?.toString() ?? 'Unbekannter Fehler.'
|
? error['detail']?.toString() ?? 'Unbekannter Fehler.'
|
||||||
: 'Unbekannter Fehler.';
|
: 'Unbekannter Fehler.';
|
||||||
@ -144,8 +148,8 @@ class CustomSearchDelegate extends SearchDelegate<String> {
|
|||||||
'Getaggt: ${suggestion.tagged}x • Score: ${suggestion.score.toStringAsFixed(2)}',
|
'Getaggt: ${suggestion.tagged}x • Score: ${suggestion.score.toStringAsFixed(2)}',
|
||||||
style: TextStyle(fontSize: 12),
|
style: TextStyle(fontSize: 12),
|
||||||
),
|
),
|
||||||
onTap: () async {
|
onTap: () {
|
||||||
await apiService.setTag(suggestion.tag);
|
controller.setTag(suggestion.tag);
|
||||||
close(context, suggestion.tag);
|
close(context, suggestion.tag);
|
||||||
},
|
},
|
||||||
);
|
);
|
@ -1,28 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class SmartRefreshIndicator extends StatelessWidget {
|
|
||||||
final Future<void> Function() onRefresh;
|
|
||||||
final Widget child;
|
|
||||||
|
|
||||||
const SmartRefreshIndicator({
|
|
||||||
super.key,
|
|
||||||
required this.onRefresh,
|
|
||||||
required this.child,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(context) {
|
|
||||||
return LayoutBuilder(
|
|
||||||
builder: (context, constraints) => RefreshIndicator(
|
|
||||||
onRefresh: onRefresh,
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
|
||||||
child: ConstrainedBox(
|
|
||||||
constraints: BoxConstraints(minHeight: constraints.maxHeight),
|
|
||||||
child: child,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
74
lib/widgets/actiontag.dart
Normal file
74
lib/widgets/actiontag.dart
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:f0ckapp/models/item.dart';
|
||||||
|
|
||||||
|
class ActionTag extends StatelessWidget {
|
||||||
|
final Tag tag;
|
||||||
|
final void Function(String tag) onTagTap;
|
||||||
|
|
||||||
|
const ActionTag(this.tag, this.onTagTap, {super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () => onTagTap(tag.tag),
|
||||||
|
child:
|
||||||
|
['german', 'dutch', 'ukraine', 'russia', 'belgium'].contains(tag.tag)
|
||||||
|
? Stack(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
border: Border.all(color: Colors.white, width: 1),
|
||||||
|
),
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/tags/${tag.tag}.webp',
|
||||||
|
height: 27,
|
||||||
|
width: 60,
|
||||||
|
repeat: ImageRepeat.repeat,
|
||||||
|
fit: BoxFit.fill,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 9,
|
||||||
|
vertical: 6,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
tag.tag,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
: Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 5),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
border: Border.all(color: Colors.white, width: 1),
|
||||||
|
color: switch (tag.id) {
|
||||||
|
1 => Colors.green,
|
||||||
|
2 => Colors.red,
|
||||||
|
_ => const Color(0xFF090909),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
tag.tag,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -2,89 +2,102 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
import 'package:f0ckapp/providers/theme_provider.dart';
|
import 'package:f0ckapp/controller/authcontroller.dart';
|
||||||
//import 'package:f0ckapp/services/api_service.dart';
|
import 'package:f0ckapp/controller/themecontroller.dart';
|
||||||
import 'package:f0ckapp/utils/appversion_util.dart';
|
import 'package:f0ckapp/screens/login.dart';
|
||||||
|
import 'package:f0ckapp/screens/settings.dart';
|
||||||
|
import 'package:f0ckapp/utils/appversion.dart';
|
||||||
|
|
||||||
class EndDrawer extends StatelessWidget {
|
class EndDrawer extends StatelessWidget {
|
||||||
const EndDrawer({super.key});
|
const EndDrawer({super.key});
|
||||||
|
|
||||||
void _showMsg(String message, BuildContext context) {
|
void _showMsg(String message, {String title = ''}) {
|
||||||
ScaffoldMessenger.of(context)
|
Get
|
||||||
..removeCurrentSnackBar()
|
..closeAllSnackbars()
|
||||||
..showSnackBar(SnackBar(content: Text(message)));
|
..snackbar(message, title, snackPosition: SnackPosition.BOTTOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
//final ApiService c = Get.find<ApiService>();
|
|
||||||
final ThemeController themeController = Get.find();
|
final ThemeController themeController = Get.find();
|
||||||
|
final AuthController authController = Get.find();
|
||||||
|
|
||||||
return Drawer(
|
return Drawer(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
children: [
|
children: [
|
||||||
DrawerHeader(
|
Obx(() {
|
||||||
decoration: const BoxDecoration(
|
if (authController.token.value != null &&
|
||||||
image: DecorationImage(
|
authController.user.value?.avatarUrl != null) {
|
||||||
image: AssetImage('assets/images/menu.webp'),
|
return DrawerHeader(
|
||||||
fit: BoxFit.cover,
|
decoration: BoxDecoration(
|
||||||
alignment: Alignment.topCenter,
|
image: DecorationImage(
|
||||||
),
|
image: NetworkImage(authController.user.value!.avatarUrl!),
|
||||||
),
|
fit: BoxFit.cover,
|
||||||
child: null,
|
alignment: Alignment.topCenter,
|
||||||
),
|
|
||||||
/*ExpansionTile(
|
|
||||||
title: const Text('Login'),
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
TextField(
|
|
||||||
readOnly: true,
|
|
||||||
controller: _usernameController,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText: 'Benutzername',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
TextField(
|
|
||||||
readOnly: true,
|
|
||||||
controller: _passwordController,
|
|
||||||
obscureText: true,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText: 'Passwort',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () async {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
const SnackBar(
|
|
||||||
content: Text("noch nicht implementiert lol"),
|
|
||||||
),
|
|
||||||
final success = await login(
|
|
||||||
_usernameController.text,
|
|
||||||
_passwordController.text,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (success) {
|
|
||||||
Navigator.pop(context);
|
|
||||||
} else {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text("Login fehlgeschlagen!")),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: const Text('Login'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
child: null,
|
||||||
),*/
|
);
|
||||||
|
} else {
|
||||||
|
return DrawerHeader(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
image: DecorationImage(
|
||||||
|
image: AssetImage('assets/images/menu.webp'),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
alignment: Alignment.topCenter,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
Obx(() {
|
||||||
|
if (authController.token.value != null) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
if (authController.user.value?.username != null)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||||
|
child: Text(
|
||||||
|
'Hamlo ${authController.user.value?.username}',
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () async {
|
||||||
|
await authController.logout();
|
||||||
|
_showMsg('Erfolgreich ausgeloggt.');
|
||||||
|
},
|
||||||
|
child: const Text('Logout'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'Du bist nicht eingeloggt.',
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
Get.to(() => LoginScreen());
|
||||||
|
},
|
||||||
|
child: const Text('Login'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
ExpansionTile(
|
ExpansionTile(
|
||||||
title: const Text('Theme'),
|
title: const Text('Theme'),
|
||||||
children: [
|
children: [
|
||||||
@ -115,14 +128,14 @@ class EndDrawer extends StatelessWidget {
|
|||||||
title: const Text('Settings'),
|
title: const Text('Settings'),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
Get.toNamed('/settings');
|
Get.bottomSheet(SettingsPage());
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text('v${AppVersion.version}'),
|
title: Text('v${AppVersion.version}'),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
_showMsg('jooong lass das, hier ist nichts', context);
|
_showMsg('jooong lass das, hier ist nichts');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
74
lib/widgets/favoritesection.dart
Normal file
74
lib/widgets/favoritesection.dart
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import 'package:f0ckapp/controller/authcontroller.dart';
|
||||||
|
import 'package:f0ckapp/controller/mediacontroller.dart';
|
||||||
|
import 'package:f0ckapp/models/item.dart';
|
||||||
|
|
||||||
|
class FavoriteSection extends StatelessWidget {
|
||||||
|
final MediaItem item;
|
||||||
|
final int index;
|
||||||
|
final MediaController mediaController = Get.find<MediaController>();
|
||||||
|
final AuthController authController = Get.find<AuthController>();
|
||||||
|
|
||||||
|
FavoriteSection({super.key, required this.item, required this.index});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final bool isFavorite =
|
||||||
|
item.favorites?.any((f) => f.userId == authController.user.value?.id) ??
|
||||||
|
false;
|
||||||
|
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
...(item.favorites ?? []).map((favorite) {
|
||||||
|
return Container(
|
||||||
|
height: 32,
|
||||||
|
width: 32,
|
||||||
|
margin: const EdgeInsets.only(right: 5.0),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(
|
||||||
|
color: Theme.of(context).brightness == Brightness.dark
|
||||||
|
? Colors.white
|
||||||
|
: Colors.black,
|
||||||
|
width: 1.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: CachedNetworkImage(
|
||||||
|
imageUrl: favorite.avatarUrl,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: isFavorite
|
||||||
|
? const Icon(Icons.favorite)
|
||||||
|
: const Icon(Icons.favorite_outline),
|
||||||
|
color: Colors.red,
|
||||||
|
onPressed: () async {
|
||||||
|
final List<Favorite>? newFavorites = await mediaController
|
||||||
|
.toggleFavorite(item, isFavorite);
|
||||||
|
if (newFavorites != null) {
|
||||||
|
mediaController.items[index] = item.copyWith(
|
||||||
|
favorites: newFavorites,
|
||||||
|
);
|
||||||
|
mediaController.items.refresh();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -2,19 +2,14 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
import 'package:f0ckapp/services/api_service.dart';
|
import 'package:f0ckapp/controller/mediacontroller.dart';
|
||||||
|
|
||||||
class FilterBar extends StatelessWidget {
|
class FilterBar extends StatelessWidget {
|
||||||
final ScrollController scrollController;
|
const FilterBar({super.key});
|
||||||
|
|
||||||
const FilterBar({
|
|
||||||
super.key,
|
|
||||||
required this.scrollController,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final ApiService c = Get.find<ApiService>();
|
final MediaController c = Get.find<MediaController>();
|
||||||
|
|
||||||
return BottomAppBar(
|
return BottomAppBar(
|
||||||
height: 50,
|
height: 50,
|
||||||
@ -22,39 +17,41 @@ class FilterBar extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: [
|
children: [
|
||||||
const Text('type: '),
|
const Text('type: '),
|
||||||
Obx(() => DropdownButton<String>(
|
Obx(
|
||||||
value: mediaTypes[c.type.value],
|
() => DropdownButton<String>(
|
||||||
isDense: true,
|
value: mediaTypes[c.typeIndex.value],
|
||||||
items: mediaTypes.map((String value) {
|
isDense: true,
|
||||||
return DropdownMenuItem<String>(
|
items: mediaTypes.map((String value) {
|
||||||
value: value,
|
return DropdownMenuItem<String>(
|
||||||
child: Text(value),
|
value: value,
|
||||||
);
|
child: Text(value),
|
||||||
}).toList(),
|
);
|
||||||
onChanged: (String? newValue) {
|
}).toList(),
|
||||||
if (newValue != null) {
|
onChanged: (String? newValue) {
|
||||||
c.setType(mediaTypes.indexOf(newValue));
|
if (newValue != null) {
|
||||||
scrollController.jumpTo(0);
|
c.setTypeIndex(mediaTypes.indexOf(newValue));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)),
|
),
|
||||||
|
),
|
||||||
const Text('mode: '),
|
const Text('mode: '),
|
||||||
Obx(() => DropdownButton<String>(
|
Obx(
|
||||||
value: mediaModes[c.mode.value],
|
() => DropdownButton<String>(
|
||||||
isDense: true,
|
value: mediaModes[c.modeIndex.value],
|
||||||
items: mediaModes.map((String value) {
|
isDense: true,
|
||||||
return DropdownMenuItem<String>(
|
items: mediaModes.map((String value) {
|
||||||
value: value,
|
return DropdownMenuItem<String>(
|
||||||
child: Text(value),
|
value: value,
|
||||||
);
|
child: Text(value),
|
||||||
}).toList(),
|
);
|
||||||
onChanged: (String? newValue) {
|
}).toList(),
|
||||||
if (newValue != null) {
|
onChanged: (String? newValue) {
|
||||||
c.setMode(mediaModes.indexOf(newValue));
|
if (newValue != null) {
|
||||||
scrollController.jumpTo(0);
|
c.setModeIndex(mediaModes.indexOf(newValue));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -1,46 +1,41 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:get/get.dart';
|
|
||||||
|
|
||||||
import 'package:f0ckapp/models/mediaitem_model.dart';
|
import 'package:f0ckapp/models/item.dart';
|
||||||
|
|
||||||
class MediaTile extends StatelessWidget {
|
class MediaTile extends StatelessWidget {
|
||||||
final MediaItem item;
|
final MediaItem item;
|
||||||
|
|
||||||
const MediaTile({super.key, required this.item});
|
const MediaTile({super.key, required this.item});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return InkWell(
|
return RepaintBoundary(
|
||||||
onTap: () {
|
child: InkWell(
|
||||||
//Navigator.pushNamed(context, '/${item.id}');
|
child: Stack(
|
||||||
Get.toNamed('/${item.id}');
|
fit: StackFit.expand,
|
||||||
},
|
children: [
|
||||||
child: Stack(
|
CachedNetworkImage(
|
||||||
fit: StackFit.expand,
|
|
||||||
children: [
|
|
||||||
Hero(
|
|
||||||
tag: 'media-${item.id}',
|
|
||||||
child: CachedNetworkImage(
|
|
||||||
imageUrl: item.thumbnailUrl,
|
imageUrl: item.thumbnailUrl,
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
errorWidget: (context, url, error) => const Icon(Icons.error),
|
placeholder: (context, url) => Container(color: Colors.grey[900]),
|
||||||
|
errorWidget: (context, url, error) =>
|
||||||
|
const Icon(Icons.broken_image),
|
||||||
),
|
),
|
||||||
),
|
Align(
|
||||||
Align(
|
alignment: Alignment.bottomRight,
|
||||||
alignment: Alignment.bottomRight,
|
child: Icon(
|
||||||
child: Icon(
|
Icons.square,
|
||||||
Icons.square,
|
color: switch (item.mode) {
|
||||||
color: switch (item.mode) {
|
1 => Colors.green,
|
||||||
1 => Colors.green,
|
2 => Colors.red,
|
||||||
2 => Colors.red,
|
_ => Colors.yellow,
|
||||||
_ => Colors.yellow,
|
},
|
||||||
},
|
size: 15.0,
|
||||||
size: 15.0,
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
30
lib/widgets/tagfooter.dart
Normal file
30
lib/widgets/tagfooter.dart
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import 'package:f0ckapp/controller/mediacontroller.dart';
|
||||||
|
|
||||||
|
class TagFooter extends StatelessWidget {
|
||||||
|
final MediaController mediaController = Get.find<MediaController>();
|
||||||
|
|
||||||
|
TagFooter({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Obx(() {
|
||||||
|
if (mediaController.tag.value != null) {
|
||||||
|
return Center(
|
||||||
|
child: InputChip(
|
||||||
|
label: Text(mediaController.tag.value!),
|
||||||
|
onDeleted: () {
|
||||||
|
mediaController.setTag(null);
|
||||||
|
Get.offAllNamed('/');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
62
lib/widgets/tagsection.dart
Normal file
62
lib/widgets/tagsection.dart
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import 'package:f0ckapp/models/item.dart';
|
||||||
|
import 'package:f0ckapp/widgets/actiontag.dart';
|
||||||
|
import 'package:f0ckapp/controller/mediacontroller.dart';
|
||||||
|
|
||||||
|
class TagSection extends StatefulWidget {
|
||||||
|
final List<Tag> tags;
|
||||||
|
const TagSection({super.key, required this.tags});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<TagSection> createState() => _TagSectionState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _TagSectionState extends State<TagSection> {
|
||||||
|
bool _areTagsExpanded = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final MediaController mediaController = Get.find<MediaController>();
|
||||||
|
final bool hasMoreTags = widget.tags.length > 5;
|
||||||
|
final List<Tag> tagsToShow = _areTagsExpanded
|
||||||
|
? widget.tags
|
||||||
|
: widget.tags.take(5).toList();
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Wrap(
|
||||||
|
spacing: 6.0,
|
||||||
|
runSpacing: 4.0,
|
||||||
|
alignment: WrapAlignment.center,
|
||||||
|
children: [
|
||||||
|
...tagsToShow.map(
|
||||||
|
(tag) => ActionTag(
|
||||||
|
tag,
|
||||||
|
(tag.tag == 'sfw' || tag.tag == 'nsfw')
|
||||||
|
? (onTagTap) => {}
|
||||||
|
: (onTagTap) {
|
||||||
|
mediaController.setTag(onTagTap);
|
||||||
|
Get.offAllNamed('/');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (hasMoreTags)
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
setState(() => _areTagsExpanded = !_areTagsExpanded);
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
_areTagsExpanded
|
||||||
|
? 'Weniger anzeigen'
|
||||||
|
: 'Alle ${widget.tags.length} Tags anzeigen',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
261
lib/widgets/video_controls_overlay.dart
Normal file
261
lib/widgets/video_controls_overlay.dart
Normal file
@ -0,0 +1,261 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:cached_video_player_plus/cached_video_player_plus.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import 'package:f0ckapp/controller/settingscontroller.dart';
|
||||||
|
|
||||||
|
class VideoControlsOverlay extends StatefulWidget {
|
||||||
|
final CachedVideoPlayerPlusController controller;
|
||||||
|
|
||||||
|
const VideoControlsOverlay({
|
||||||
|
super.key,
|
||||||
|
required this.controller,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<VideoControlsOverlay> createState() => _VideoControlsOverlayState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _VideoControlsOverlayState extends State<VideoControlsOverlay> {
|
||||||
|
final SettingsController _settingsController = Get.find();
|
||||||
|
Timer? _hideTimer;
|
||||||
|
bool _controlsVisible = false;
|
||||||
|
|
||||||
|
bool _isScrubbing = false;
|
||||||
|
Duration _scrubbingStartPosition = Duration.zero;
|
||||||
|
double _scrubbingStartDx = 0.0;
|
||||||
|
Duration _scrubbingSeekPosition = Duration.zero;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
widget.controller.addListener(_listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_hideTimer?.cancel();
|
||||||
|
widget.controller.removeListener(_listener);
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _listener() {
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _startHideTimer() {
|
||||||
|
_hideTimer?.cancel();
|
||||||
|
_hideTimer = Timer(const Duration(seconds: 5), () {
|
||||||
|
if (mounted) {
|
||||||
|
setState(() => _controlsVisible = false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _toggleControlsVisibility() {
|
||||||
|
setState(() => _controlsVisible = !_controlsVisible);
|
||||||
|
if (_controlsVisible) {
|
||||||
|
_startHideTimer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _handlePlayPause() {
|
||||||
|
widget.controller.value.isPlaying
|
||||||
|
? widget.controller.pause()
|
||||||
|
: widget.controller.play();
|
||||||
|
_startHideTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onHorizontalDragStart(DragStartDetails details) {
|
||||||
|
if (!widget.controller.value.isInitialized || !_controlsVisible) return;
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_isScrubbing = true;
|
||||||
|
_scrubbingStartPosition = widget.controller.value.position;
|
||||||
|
_scrubbingStartDx = details.globalPosition.dx;
|
||||||
|
_scrubbingSeekPosition = widget.controller.value.position;
|
||||||
|
});
|
||||||
|
_hideTimer?.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onHorizontalDragUpdate(DragUpdateDetails details) {
|
||||||
|
if (!_isScrubbing) return;
|
||||||
|
|
||||||
|
final double delta = details.globalPosition.dx - _scrubbingStartDx;
|
||||||
|
final int seekMillis =
|
||||||
|
_scrubbingStartPosition.inMilliseconds + (delta * 300).toInt();
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
final Duration duration = widget.controller.value.duration;
|
||||||
|
final Duration seekDuration = Duration(milliseconds: seekMillis);
|
||||||
|
final Duration clampedSeekDuration = seekDuration < Duration.zero
|
||||||
|
? Duration.zero
|
||||||
|
: (seekDuration > duration ? duration : seekDuration);
|
||||||
|
_scrubbingSeekPosition = clampedSeekDuration;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onHorizontalDragEnd(DragEndDetails details) {
|
||||||
|
if (!_isScrubbing) return;
|
||||||
|
|
||||||
|
widget.controller.seekTo(_scrubbingSeekPosition);
|
||||||
|
setState(() => _isScrubbing = false);
|
||||||
|
_startHideTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onHorizontalDragCancel() {
|
||||||
|
if (!_isScrubbing) return;
|
||||||
|
setState(() => _isScrubbing = false);
|
||||||
|
_startHideTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
String _formatDuration(Duration? duration) {
|
||||||
|
if (duration == null) return '00:00';
|
||||||
|
String twoDigits(int n) => n.toString().padLeft(2, '0');
|
||||||
|
return "${twoDigits(duration.inMinutes % 60)}:${twoDigits(duration.inSeconds % 60)}";
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
Positioned.fill(
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: _toggleControlsVisibility,
|
||||||
|
onHorizontalDragStart: _controlsVisible ? _onHorizontalDragStart : null,
|
||||||
|
onHorizontalDragUpdate: _controlsVisible ? _onHorizontalDragUpdate : null,
|
||||||
|
onHorizontalDragEnd: _controlsVisible ? _onHorizontalDragEnd : null,
|
||||||
|
onHorizontalDragCancel: _controlsVisible ? _onHorizontalDragCancel : null,
|
||||||
|
child: AnimatedContainer(
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
color: _controlsVisible && !_isScrubbing
|
||||||
|
? Colors.black.withValues(alpha: 0.5)
|
||||||
|
: Colors.transparent,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
AnimatedOpacity(
|
||||||
|
opacity: _isScrubbing ? 1.0 : 0.0,
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
child: _buildScrubbingIndicator(),
|
||||||
|
),
|
||||||
|
AnimatedOpacity(
|
||||||
|
opacity: _controlsVisible && !_isScrubbing ? 1.0 : 0.0,
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.bottomCenter,
|
||||||
|
child: _buildBottomBar(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildScrubbingIndicator() {
|
||||||
|
final Duration positionChange =
|
||||||
|
_scrubbingSeekPosition - _scrubbingStartPosition;
|
||||||
|
final String changeSign = positionChange.isNegative ? '-' : '+';
|
||||||
|
final String changeText = _formatDuration(positionChange.abs());
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.black.withValues(alpha: 0.7),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
_formatDuration(_scrubbingSeekPosition),
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 22,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'[$changeSign$changeText]',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white.withValues(alpha: 0.8),
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildBottomBar() {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(12, 0, 12, 5),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
widget.controller.value.isPlaying
|
||||||
|
? Icons.pause
|
||||||
|
: Icons.play_arrow,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
size: 24,
|
||||||
|
),
|
||||||
|
onPressed: _handlePlayPause,
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
_formatDuration(widget.controller.value.position),
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
|
child: VideoProgressIndicator(
|
||||||
|
widget.controller,
|
||||||
|
allowScrubbing: true,
|
||||||
|
colors: VideoProgressColors(
|
||||||
|
playedColor: Theme.of(context).colorScheme.primary,
|
||||||
|
backgroundColor: Colors.white.withValues(alpha: 0.3),
|
||||||
|
bufferedColor: Colors.white.withValues(alpha: 0.6),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
_formatDuration(widget.controller.value.duration),
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Obx(
|
||||||
|
() => IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
_settingsController.muted.value
|
||||||
|
? Icons.volume_off
|
||||||
|
: Icons.volume_up,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
size: 24,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
_settingsController.toggleMuted();
|
||||||
|
_startHideTimer();
|
||||||
|
},
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,190 +1,139 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
|
import 'package:cached_video_player_plus/cached_video_player_plus.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:cached_video_player_plus/cached_video_player_plus.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
|
||||||
|
|
||||||
import 'package:f0ckapp/models/mediaitem_model.dart';
|
import 'package:f0ckapp/models/item.dart';
|
||||||
import 'package:f0ckapp/widgets/videooverlay_widget.dart';
|
import 'package:f0ckapp/widgets/video_controls_overlay.dart';
|
||||||
|
import 'package:f0ckapp/controller/settingscontroller.dart';
|
||||||
|
import 'package:f0ckapp/controller/mediacontroller.dart';
|
||||||
|
|
||||||
class VideoWidget extends StatefulWidget {
|
class VideoWidget extends StatefulWidget {
|
||||||
final MediaItem details;
|
final MediaItem details;
|
||||||
final bool isActive;
|
final bool isActive;
|
||||||
final bool fullScreen;
|
final bool fullScreen;
|
||||||
|
final VoidCallback? onInitialized;
|
||||||
|
final Duration? initialPosition;
|
||||||
|
|
||||||
const VideoWidget({
|
const VideoWidget({
|
||||||
super.key,
|
super.key,
|
||||||
required this.details,
|
required this.details,
|
||||||
required this.isActive,
|
required this.isActive,
|
||||||
this.fullScreen = false,
|
this.fullScreen = false,
|
||||||
|
this.onInitialized,
|
||||||
|
this.initialPosition,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<VideoWidget> createState() => _VideoWidgetState();
|
State<VideoWidget> createState() => VideoWidgetState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _VideoWidgetState extends State<VideoWidget> {
|
class VideoWidgetState extends State<VideoWidget> {
|
||||||
late CachedVideoPlayerPlusController _controller;
|
final MediaController mediaController = Get.find<MediaController>();
|
||||||
bool _showControls = false;
|
final SettingsController settingsController = Get.find<SettingsController>();
|
||||||
Timer? _hideControlsTimer;
|
late CachedVideoPlayerPlusController videoController;
|
||||||
|
late Worker _muteWorker;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_initController();
|
_initController();
|
||||||
|
_muteWorker = ever(settingsController.muted, (bool muted) {
|
||||||
|
if (videoController.value.isInitialized) {
|
||||||
|
videoController.setVolume(muted ? 0.0 : 1.0);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _initController() async {
|
Future<void> _initController() async {
|
||||||
_controller = CachedVideoPlayerPlusController.networkUrl(
|
videoController = CachedVideoPlayerPlusController.networkUrl(
|
||||||
Uri.parse(widget.details.mediaUrl),
|
Uri.parse(widget.details.mediaUrl),
|
||||||
|
videoPlayerOptions: VideoPlayerOptions(mixWithOthers: true),
|
||||||
);
|
);
|
||||||
await _controller.initialize();
|
await videoController.initialize();
|
||||||
|
if (!mounted) return;
|
||||||
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
|
||||||
_controller.addListener(() => setState(() {}));
|
if (widget.initialPosition != null) {
|
||||||
|
await videoController.seekTo(widget.initialPosition!);
|
||||||
|
}
|
||||||
|
widget.onInitialized?.call();
|
||||||
|
videoController.setLooping(true);
|
||||||
|
videoController.setVolume(settingsController.muted.value ? 0.0 : 1.0);
|
||||||
|
|
||||||
if (widget.isActive) {
|
if (widget.isActive) {
|
||||||
_controller.play();
|
videoController.play();
|
||||||
}
|
}
|
||||||
_controller.setLooping(true);
|
|
||||||
|
|
||||||
//final bool muted = ref.read(mediaProvider).muted;
|
|
||||||
//_controller.setVolume(muted ? 0.0 : 1.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didUpdateWidget(covariant VideoWidget oldWidget) {
|
void didUpdateWidget(covariant VideoWidget oldWidget) {
|
||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
|
|
||||||
|
if (widget.details.mediaUrl != oldWidget.details.mediaUrl) {
|
||||||
|
videoController.dispose();
|
||||||
|
_initController();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (widget.isActive != oldWidget.isActive) {
|
if (widget.isActive != oldWidget.isActive) {
|
||||||
if (widget.isActive) {
|
if (videoController.value.isInitialized) {
|
||||||
_controller.play();
|
if (widget.isActive) {
|
||||||
} else {
|
videoController.play();
|
||||||
_controller.pause();
|
} else {
|
||||||
|
videoController.pause();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_controller.dispose();
|
_muteWorker.dispose();
|
||||||
_hideControlsTimer?.cancel();
|
videoController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onTap({bool ctrlButton = false}) {
|
|
||||||
if (!ctrlButton) {
|
|
||||||
setState(() => _showControls = !_showControls);
|
|
||||||
}
|
|
||||||
if (_showControls) {
|
|
||||||
_hideControlsTimer?.cancel();
|
|
||||||
_hideControlsTimer = Timer(const Duration(seconds: 2), () {
|
|
||||||
setState(() => _showControls = false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
//final bool muted = ref.watch(mediaProvider).muted;
|
final bool isInitialized = videoController.value.isInitialized;
|
||||||
//if (_controller.value.isInitialized &&
|
final bool isAudio = widget.details.mime.startsWith('audio');
|
||||||
// _controller.value.volume != (muted ? 0.0 : 1.0)) {
|
|
||||||
// _controller.setVolume(muted ? 0.0 : 1.0);
|
|
||||||
//}
|
|
||||||
|
|
||||||
bool isAudio = widget.details.mime.startsWith('audio');
|
Widget mediaContent;
|
||||||
|
if (isAudio) {
|
||||||
if (widget.fullScreen) {
|
mediaContent = CachedNetworkImage(
|
||||||
return Stack(
|
imageUrl: widget.details.coverUrl,
|
||||||
children: [
|
fit: BoxFit.cover,
|
||||||
Center(
|
errorWidget: (c, e, s) => Image.asset(
|
||||||
child: AspectRatio(
|
'assets/images/music.webp',
|
||||||
aspectRatio: _controller.value.isInitialized
|
fit: BoxFit.contain,
|
||||||
? _controller.value.aspectRatio
|
width: double.infinity,
|
||||||
: 9 / 16,
|
),
|
||||||
child: GestureDetector(
|
|
||||||
onTap: _onTap,
|
|
||||||
child: isAudio
|
|
||||||
? CachedNetworkImage(
|
|
||||||
imageUrl: widget.details.coverUrl,
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
placeholder: (context, url) =>
|
|
||||||
const CircularProgressIndicator(),
|
|
||||||
errorWidget: (context, url, error) => Image.asset(
|
|
||||||
'assets/images/music.webp',
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
width: double.infinity,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: _controller.value.isInitialized
|
|
||||||
? CachedVideoPlayerPlus(_controller)
|
|
||||||
: const Center(child: CircularProgressIndicator()),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (_controller.value.isInitialized && _showControls)
|
|
||||||
Positioned.fill(
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: _onTap,
|
|
||||||
child: Container(
|
|
||||||
color: Colors.black.withValues(alpha: 0.5),
|
|
||||||
child: VideoControlsOverlay(
|
|
||||||
controller: _controller,
|
|
||||||
button: () => _onTap(ctrlButton: true),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return Column(
|
mediaContent = isInitialized
|
||||||
mainAxisSize: MainAxisSize.min,
|
? CachedVideoPlayerPlus(videoController)
|
||||||
children: [
|
: const Center(child: CircularProgressIndicator());
|
||||||
AspectRatio(
|
|
||||||
aspectRatio: _controller.value.isInitialized
|
|
||||||
? _controller.value.aspectRatio
|
|
||||||
: 9 / 16,
|
|
||||||
child: Stack(
|
|
||||||
alignment: Alignment.topCenter,
|
|
||||||
children: [
|
|
||||||
GestureDetector(
|
|
||||||
onTap: _onTap,
|
|
||||||
child: isAudio
|
|
||||||
? CachedNetworkImage(
|
|
||||||
imageUrl: widget.details.coverUrl,
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
placeholder: (context, url) =>
|
|
||||||
const CircularProgressIndicator(),
|
|
||||||
errorWidget: (context, url, error) => Image.asset(
|
|
||||||
'assets/images/music.webp',
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
width: double.infinity,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: _controller.value.isInitialized
|
|
||||||
? CachedVideoPlayerPlus(_controller)
|
|
||||||
: const Center(child: CircularProgressIndicator()),
|
|
||||||
),
|
|
||||||
if (_controller.value.isInitialized && _showControls) ...[
|
|
||||||
IgnorePointer(
|
|
||||||
ignoring: true,
|
|
||||||
child: Container(
|
|
||||||
color: Colors.black.withValues(alpha: 0.5),
|
|
||||||
width: double.infinity,
|
|
||||||
height: double.infinity,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
VideoControlsOverlay(
|
|
||||||
controller: _controller,
|
|
||||||
button: () => _onTap(ctrlButton: true),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return AspectRatio(
|
||||||
|
aspectRatio: isInitialized
|
||||||
|
? videoController.value.aspectRatio
|
||||||
|
: (isAudio ? 16 / 9 : 9 / 16),
|
||||||
|
child: Stack(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
children: [
|
||||||
|
mediaContent,
|
||||||
|
if (isInitialized)
|
||||||
|
Positioned.fill(
|
||||||
|
child: VideoControlsOverlay(controller: videoController),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,136 +0,0 @@
|
|||||||
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)}',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
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, size: size),
|
|
||||||
onPressed: onPressed,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
322
pubspec.lock
322
pubspec.lock
@ -1,6 +1,22 @@
|
|||||||
# Generated by pub
|
# Generated by pub
|
||||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||||
packages:
|
packages:
|
||||||
|
args:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: args
|
||||||
|
sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.7.0"
|
||||||
|
asn1lib:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: asn1lib
|
||||||
|
sha256: "0511d6be23b007e95105ae023db599aea731df604608978dada7f9faf2637623"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.6.4"
|
||||||
async:
|
async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -73,6 +89,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.19.1"
|
version: "1.19.1"
|
||||||
|
convert:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: convert
|
||||||
|
sha256: b30acd5944035672bc15c6b7a8b47d773e41e2f17de064350988c5d02adb1c68
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.1.2"
|
||||||
cross_file:
|
cross_file:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -97,14 +121,46 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.2"
|
version: "1.0.2"
|
||||||
cupertino_icons:
|
devtools_shared:
|
||||||
dependency: "direct main"
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: cupertino_icons
|
name: devtools_shared
|
||||||
sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6
|
sha256: "659e2d65aa5ef5c3551163811c5c6fa1b973b3df80d8cac6f618035edcdc1096"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.8"
|
version: "11.2.1"
|
||||||
|
dtd:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: dtd
|
||||||
|
sha256: "14a0360d898ded87c3d99591fc386b8a6ea5d432927bee709b22130cd25b993a"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.5.1"
|
||||||
|
encrypt:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: encrypt
|
||||||
|
sha256: "62d9aa4670cc2a8798bab89b39fc71b6dfbacf615de6cf5001fb39f7e4a996a2"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "5.0.3"
|
||||||
|
encrypt_shared_preferences:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: encrypt_shared_preferences
|
||||||
|
sha256: ab8a957db7ae645c8b0341e8aee85c1cd046a5cb9a0529459ea417ebd6040ba2
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.9.9"
|
||||||
|
extension_discovery:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: extension_discovery
|
||||||
|
sha256: de1fce715ab013cdfb00befc3bdf0914bea5e409c3a567b7f8f144bc061611a7
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
fake_async:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -143,7 +199,7 @@ packages:
|
|||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
flutter_cache_manager:
|
flutter_cache_manager:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: flutter_cache_manager
|
name: flutter_cache_manager
|
||||||
sha256: "400b6592f16a4409a7f2bb929a9a7e38c72cceb8ffb99ee57bbf2cb2cecf8386"
|
sha256: "400b6592f16a4409a7f2bb929a9a7e38c72cceb8ffb99ee57bbf2cb2cecf8386"
|
||||||
@ -158,54 +214,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.0.0"
|
version: "6.0.0"
|
||||||
flutter_secure_storage:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: flutter_secure_storage
|
|
||||||
sha256: "9cad52d75ebc511adfae3d447d5d13da15a55a92c9410e50f67335b6d21d16ea"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "9.2.4"
|
|
||||||
flutter_secure_storage_linux:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: flutter_secure_storage_linux
|
|
||||||
sha256: be76c1d24a97d0b98f8b54bce6b481a380a6590df992d0098f868ad54dc8f688
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.2.3"
|
|
||||||
flutter_secure_storage_macos:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: flutter_secure_storage_macos
|
|
||||||
sha256: "6c0a2795a2d1de26ae202a0d78527d163f4acbb11cde4c75c670f3a0fc064247"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "3.1.3"
|
|
||||||
flutter_secure_storage_platform_interface:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: flutter_secure_storage_platform_interface
|
|
||||||
sha256: cf91ad32ce5adef6fba4d736a542baca9daf3beac4db2d04be350b87f69ac4a8
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.1.2"
|
|
||||||
flutter_secure_storage_web:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: flutter_secure_storage_web
|
|
||||||
sha256: f4ebff989b4f07b2656fb16b47852c0aab9fed9b4ec1c70103368337bc1886a9
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.2.1"
|
|
||||||
flutter_secure_storage_windows:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: flutter_secure_storage_windows
|
|
||||||
sha256: b20b07cb5ed4ed74fc567b78a72936203f587eba460af1df11281c9326cd3709
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "3.1.2"
|
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
@ -241,7 +249,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "0.15.6"
|
version: "0.15.6"
|
||||||
http:
|
http:
|
||||||
dependency: "direct main"
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: http
|
name: http
|
||||||
sha256: "2c11f3f94c687ee9bad77c171151672986360b2b001d109814ee7140b2cf261b"
|
sha256: "2c11f3f94c687ee9bad77c171151672986360b2b001d109814ee7140b2cf261b"
|
||||||
@ -256,14 +264,30 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.1.2"
|
version: "4.1.2"
|
||||||
|
intl:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: intl
|
||||||
|
sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.20.2"
|
||||||
js:
|
js:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: js
|
name: js
|
||||||
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
|
sha256: "53385261521cc4a0c4658fd0ad07a7d14591cf8fc33abbceae306ddb974888dc"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.6.7"
|
version: "0.7.2"
|
||||||
|
json_rpc_2:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: json_rpc_2
|
||||||
|
sha256: "246b321532f0e8e2ba474b4d757eaa558ae4fdd0688fdbc1e1ca9705f9b8ca0e"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.3"
|
||||||
leak_tracker:
|
leak_tracker:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -296,6 +320,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.0.0"
|
version: "6.0.0"
|
||||||
|
logging:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: logging
|
||||||
|
sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.3.0"
|
||||||
matcher:
|
matcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -336,22 +368,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
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:
|
path:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -424,6 +440,30 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.8"
|
version: "2.1.8"
|
||||||
|
pointycastle:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: pointycastle
|
||||||
|
sha256: "4be0097fcf3fd3e8449e53730c631200ebc7b88016acecab2b0da2f0149222fe"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.9.1"
|
||||||
|
pool:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: pool
|
||||||
|
sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.5.1"
|
||||||
|
pullex:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: pullex
|
||||||
|
sha256: f29a0b5eef4c16e32ae4b32cf6ad1a6eea0778d5bad8ee6cb29edb7d44496c1c
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.0"
|
||||||
rxdart:
|
rxdart:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -448,6 +488,70 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.0.0"
|
version: "6.0.0"
|
||||||
|
shared_preferences:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences
|
||||||
|
sha256: "6e8bf70b7fef813df4e9a36f658ac46d107db4b4cfe1048b477d4e453a8159f5"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.5.3"
|
||||||
|
shared_preferences_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_android
|
||||||
|
sha256: "20cbd561f743a342c76c151d6ddb93a9ce6005751e7aa458baad3858bfbfb6ac"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.10"
|
||||||
|
shared_preferences_foundation:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_foundation
|
||||||
|
sha256: "6a52cfcdaeac77cad8c97b539ff688ccfc458c007b4db12be584fbe5c0e49e03"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.5.4"
|
||||||
|
shared_preferences_linux:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_linux
|
||||||
|
sha256: "580abfd40f415611503cae30adf626e6656dfb2f0cee8f465ece7b6defb40f2f"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.1"
|
||||||
|
shared_preferences_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_platform_interface
|
||||||
|
sha256: "57cbf196c486bc2cf1f02b85784932c6094376284b3ad5779d1b1c6c6a816b80"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.1"
|
||||||
|
shared_preferences_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_web
|
||||||
|
sha256: c49bd060261c9a3f0ff445892695d6212ff603ef3115edbb448509d407600019
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.3"
|
||||||
|
shared_preferences_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_windows
|
||||||
|
sha256: "94ef0f72b2d71bc3e700e025db3710911bd51a71cefb65cc609dd0d9a982e3c1"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.1"
|
||||||
|
shelf:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shelf
|
||||||
|
sha256: e7dd780a7ffb623c57850b33f43309312fc863fb6aa3d276a754bb299839ef12
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.4.2"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@ -509,6 +613,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.0"
|
version: "2.4.0"
|
||||||
|
sse:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: sse
|
||||||
|
sha256: fcc97470240bb37377f298e2bd816f09fd7216c07928641c0560719f50603643
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.1.8"
|
||||||
stack_trace:
|
stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -557,6 +669,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.6"
|
version: "0.7.6"
|
||||||
|
timeago:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: timeago
|
||||||
|
sha256: b05159406a97e1cbb2b9ee4faa9fb096fe0e2dfcd8b08fcd2a00553450d3422e
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.7.1"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -565,6 +685,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.4.0"
|
version: "1.4.0"
|
||||||
|
unified_analytics:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: unified_analytics
|
||||||
|
sha256: c8abdcad84b55b78f860358aae90077b8f54f98169a75e16d97796a1b3c95590
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "8.0.1"
|
||||||
url_launcher_linux:
|
url_launcher_linux:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -649,10 +777,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vm_service
|
name: vm_service
|
||||||
sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02
|
sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "15.0.0"
|
version: "15.0.2"
|
||||||
web:
|
web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -661,14 +789,38 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.1"
|
version: "1.1.1"
|
||||||
|
web_socket:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: web_socket
|
||||||
|
sha256: "34d64019aa8e36bf9842ac014bb5d2f5586ca73df5e4d9bf5c936975cae6982c"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.1"
|
||||||
|
web_socket_channel:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: web_socket_channel
|
||||||
|
sha256: d645757fb0f4773d602444000a8131ff5d48c9e47adfe9772652dd1a4f2d45c8
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.3"
|
||||||
|
webkit_inspection_protocol:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: webkit_inspection_protocol
|
||||||
|
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.2.1"
|
||||||
win32:
|
win32:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: win32
|
name: win32
|
||||||
sha256: "329edf97fdd893e0f1e3b9e88d6a0e627128cc17cc316a8d67fda8f1451178ba"
|
sha256: "66814138c3562338d05613a6e368ed8cfb237ad6d64a9e9334be3f309acfca03"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.13.0"
|
version: "5.14.0"
|
||||||
xdg_directories:
|
xdg_directories:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -677,6 +829,22 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.1.0"
|
||||||
|
yaml:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: yaml
|
||||||
|
sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.1.3"
|
||||||
|
yaml_edit:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: yaml_edit
|
||||||
|
sha256: fb38626579fb345ad00e674e2af3a5c9b0cc4b9bfb8fd7f7ff322c7c9e62aef5
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.2"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.9.0-100.2.beta <4.0.0"
|
dart: ">=3.9.0-100.2.beta <4.0.0"
|
||||||
flutter: ">=3.29.0"
|
flutter: ">=3.29.0"
|
||||||
|
18
pubspec.yaml
18
pubspec.yaml
@ -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.2.0+54
|
version: 1.4.9+70
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.9.0-100.2.beta
|
sdk: ^3.9.0-100.2.beta
|
||||||
@ -30,17 +30,14 @@ environment:
|
|||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
http: ^1.4.0
|
get: ^4.7.2
|
||||||
|
encrypt_shared_preferences: ^0.9.9
|
||||||
# The following adds the Cupertino Icons font to your application.
|
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
|
||||||
cupertino_icons: ^1.0.8
|
|
||||||
cached_network_image: ^3.4.1
|
cached_network_image: ^3.4.1
|
||||||
cached_video_player_plus: ^3.0.3
|
cached_video_player_plus: ^3.0.3
|
||||||
package_info_plus: ^8.3.0
|
|
||||||
share_plus: ^11.0.0
|
share_plus: ^11.0.0
|
||||||
flutter_secure_storage: ^9.2.4
|
flutter_cache_manager: ^3.4.1
|
||||||
get: ^4.7.2
|
pullex: ^1.0.0
|
||||||
|
timeago: ^3.7.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
@ -67,6 +64,9 @@ flutter:
|
|||||||
# 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/
|
- assets/images/
|
||||||
|
- assets/images/tags/
|
||||||
|
- assets/i18n/
|
||||||
|
- pubspec.yaml
|
||||||
# - 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