mute schmute
This commit is contained in:
@ -1,6 +1,8 @@
|
|||||||
import 'package:f0ckapp/services/Api.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
|
|
||||||
import 'package:f0ckapp/models/MediaItem.dart';
|
import 'package:f0ckapp/models/MediaItem.dart';
|
||||||
|
import 'package:f0ckapp/services/Api.dart';
|
||||||
|
|
||||||
class MediaProvider extends ChangeNotifier {
|
class MediaProvider extends ChangeNotifier {
|
||||||
int _typeid = 0;
|
int _typeid = 0;
|
||||||
@ -10,6 +12,10 @@ class MediaProvider extends ChangeNotifier {
|
|||||||
int _crossAxisCount = 0;
|
int _crossAxisCount = 0;
|
||||||
List<MediaItem> _mediaItems = [];
|
List<MediaItem> _mediaItems = [];
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
|
bool _muted = false;
|
||||||
|
final storage = FlutterSecureStorage(
|
||||||
|
aOptions: const AndroidOptions(encryptedSharedPreferences: true),
|
||||||
|
);
|
||||||
|
|
||||||
List<String> types = ["alles", "image", "video", "audio"];
|
List<String> types = ["alles", "image", "video", "audio"];
|
||||||
List<String> modes = ["sfw", "nsfw", "untagged", "all"];
|
List<String> modes = ["sfw", "nsfw", "untagged", "all"];
|
||||||
@ -22,8 +28,14 @@ class MediaProvider extends ChangeNotifier {
|
|||||||
int get crossAxisCount => _crossAxisCount;
|
int get crossAxisCount => _crossAxisCount;
|
||||||
List<MediaItem> get mediaItems => _mediaItems;
|
List<MediaItem> get mediaItems => _mediaItems;
|
||||||
bool get isLoading => _isLoading;
|
bool get isLoading => _isLoading;
|
||||||
|
bool get muted => _muted;
|
||||||
|
|
||||||
Function get resetMedia => _resetMedia;
|
Function get resetMedia => _resetMedia;
|
||||||
|
|
||||||
|
MediaProvider() {
|
||||||
|
_loadMutedState();
|
||||||
|
}
|
||||||
|
|
||||||
void setType(String type) {
|
void setType(String type) {
|
||||||
_typeid = types.indexOf(type);
|
_typeid = types.indexOf(type);
|
||||||
_resetMedia();
|
_resetMedia();
|
||||||
@ -68,6 +80,22 @@ class MediaProvider extends ChangeNotifier {
|
|||||||
loadMedia();
|
loadMedia();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void toggleMute() {
|
||||||
|
_muted = !_muted;
|
||||||
|
_saveMutedState();
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadMutedState() async {
|
||||||
|
_muted = (await storage.read(key: 'muted') == 'true');
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _saveMutedState() async {
|
||||||
|
await storage.write(key: 'muted', value: _muted ? 'false' : 'true');
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> loadMedia({bool notify = true}) async {
|
Future<void> loadMedia({bool notify = true}) async {
|
||||||
if (_isLoading) return;
|
if (_isLoading) return;
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
|
@ -105,6 +105,15 @@ class _DetailViewState extends State<DetailView> {
|
|||||||
'f0ck #${provider.mediaItems.elementAt(_currentIndex).id.toString()}',
|
'f0ck #${provider.mediaItems.elementAt(_currentIndex).id.toString()}',
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
provider.muted ? Icons.volume_up : Icons.volume_off,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
provider.toggleMute();
|
||||||
|
},
|
||||||
|
),
|
||||||
PopupMenuButton<String>(
|
PopupMenuButton<String>(
|
||||||
onSelected: (value) async {
|
onSelected: (value) async {
|
||||||
final item = provider.mediaItems.elementAt(_currentIndex);
|
final item = provider.mediaItems.elementAt(_currentIndex);
|
||||||
@ -121,10 +130,14 @@ class _DetailViewState extends State<DetailView> {
|
|||||||
await SharePlus.instance.share(params);
|
await SharePlus.instance.share(params);
|
||||||
break;
|
break;
|
||||||
case 'direct_link':
|
case 'direct_link':
|
||||||
await SharePlus.instance.share(ShareParams(text: item.mediaUrl));
|
await SharePlus.instance.share(
|
||||||
|
ShareParams(text: item.mediaUrl),
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
case 'post_link':
|
case 'post_link':
|
||||||
await SharePlus.instance.share(ShareParams(text: item.postUrl));
|
await SharePlus.instance.share(
|
||||||
|
ShareParams(text: item.postUrl),
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import 'package:f0ckapp/services/Api.dart';
|
|
||||||
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:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
@ -48,8 +48,10 @@ Future<MediaItem> fetchMediaDetail(int itemId) async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> login(String username, String password) async {
|
Future<bool> login(String username, String password) async {
|
||||||
|
final Uri url = Uri.parse('https://api.f0ck.me/login');
|
||||||
|
|
||||||
final response = await http.post(
|
final response = await http.post(
|
||||||
Uri.parse('https://api.f0ck.me/login'),
|
url,
|
||||||
body: {'username': username, 'password': password},
|
body: {'username': username, 'password': password},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user