This commit is contained in:
@ -1,18 +1,14 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:encrypt_shared_preferences/provider.dart';
|
||||
|
||||
import 'package:f0ckapp/models/feed.dart';
|
||||
import 'package:f0ckapp/models/item.dart';
|
||||
import 'package:f0ckapp/services/api.dart';
|
||||
import 'package:f0ckapp/utils/animatedtransition.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>();
|
||||
final EncryptedSharedPreferencesAsync storage =
|
||||
EncryptedSharedPreferencesAsync.getInstance();
|
||||
|
||||
RxList<MediaItem> items = <MediaItem>[].obs;
|
||||
RxBool loading = false.obs;
|
||||
@ -23,12 +19,6 @@ class MediaController extends GetxController {
|
||||
RxInt modeIndex = 0.obs;
|
||||
RxInt random = 0.obs;
|
||||
Rxn<String> tag = Rxn<String>(null);
|
||||
RxBool muted = false.obs;
|
||||
Rx<PageTransition> transitionType = PageTransition.opacity.obs;
|
||||
RxBool drawerSwipeEnabled = true.obs;
|
||||
RxInt crossAxisCount = 0.obs;
|
||||
RxInt videoControlsTimerNotifier = 0.obs;
|
||||
RxInt hideControlsNotifier = 0.obs;
|
||||
|
||||
void setTypeIndex(int idx) {
|
||||
typeIndex.value = idx;
|
||||
@ -137,58 +127,10 @@ class MediaController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
void toggleMuted() {
|
||||
muted.value = !muted.value;
|
||||
}
|
||||
|
||||
void setMuted(bool value) {
|
||||
muted.value = value;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
void toggleRandom() {
|
||||
random.value = random.value == 1 ? 0 : 1;
|
||||
fetchInitial();
|
||||
}
|
||||
|
||||
void resetVideoControlsTimer() => videoControlsTimerNotifier.value++;
|
||||
void hideVideoControls() => hideControlsNotifier.value++;
|
||||
|
||||
@override
|
||||
void onInit() async {
|
||||
super.onInit();
|
||||
await loadSettings();
|
||||
}
|
||||
|
||||
Future<void> loadSettings() async {
|
||||
muted.value = await storage.getBoolean('muted') ?? false;
|
||||
crossAxisCount.value = await storage.getInt('crossAxisCount') ?? 0;
|
||||
drawerSwipeEnabled.value =
|
||||
await storage.getBoolean('drawerSwipeEnabled') ?? true;
|
||||
transitionType.value =
|
||||
PageTransition.values[await storage.getInt('transitionType') ?? 0];
|
||||
}
|
||||
|
||||
Future<void> saveSettings() async {
|
||||
await storage.setBoolean('muted', muted.value);
|
||||
await storage.setInt('crossAxisCount', crossAxisCount.value);
|
||||
await storage.setBoolean('drawerSwipeEnabled', drawerSwipeEnabled.value);
|
||||
await storage.setInt('transitionType', transitionType.value.index);
|
||||
}
|
||||
|
||||
bool get isRandomEnabled => random.value == 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user