- fix deeplink - add mute button
This commit is contained in:
		@@ -1,6 +1,7 @@
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
 | 
			
		||||
import 'package:get/get.dart';
 | 
			
		||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
 | 
			
		||||
 | 
			
		||||
import 'package:f0ckapp/models/mediaitem_model.dart';
 | 
			
		||||
 | 
			
		||||
@@ -8,11 +9,15 @@ const List<String> mediaTypes = ["alles", "image", "video", "audio"];
 | 
			
		||||
const List<String> mediaModes = ["sfw", "nsfw", "untagged", "all"];
 | 
			
		||||
 | 
			
		||||
class ApiService extends GetConnect {
 | 
			
		||||
  final _storage = const FlutterSecureStorage(
 | 
			
		||||
    aOptions: AndroidOptions(encryptedSharedPreferences: true),
 | 
			
		||||
  );
 | 
			
		||||
  RxList<MediaItem> mediaItems = <MediaItem>[].obs;
 | 
			
		||||
  RxnString tag = RxnString();
 | 
			
		||||
  RxInt type = 0.obs;
 | 
			
		||||
  RxInt mode = 0.obs;
 | 
			
		||||
  RxBool random = false.obs;
 | 
			
		||||
  RxBool muted = false.obs;
 | 
			
		||||
 | 
			
		||||
  bool _isFetching = false;
 | 
			
		||||
  DateTime? _lastFetchTime;
 | 
			
		||||
@@ -21,9 +26,20 @@ class ApiService extends GetConnect {
 | 
			
		||||
  @override
 | 
			
		||||
  void onInit() {
 | 
			
		||||
    super.onInit();
 | 
			
		||||
    loadMutedState();
 | 
			
		||||
    everAll([tag, type, mode, random], (_) => fetchMedia(reset: true));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Future<void> loadMutedState() async {
 | 
			
		||||
    String? value = await _storage.read(key: 'muted');
 | 
			
		||||
    muted.value = value == 'true';
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Future<void> toggleMuted() async {
 | 
			
		||||
    muted.value = !muted.value;
 | 
			
		||||
    await _storage.write(key: 'muted', value: muted.value.toString());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Future<void> setTag(String? newTag) async {
 | 
			
		||||
    tag.value = newTag;
 | 
			
		||||
    return await fetchMedia(reset: true);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user