mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-15 02:05:58 -07:00
feature: Video quality options (#234)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
parent
957ad6c991
commit
935d6fe176
25 changed files with 644 additions and 232 deletions
39
lib/providers/connectivity_provider.dart
Normal file
39
lib/providers/connectivity_provider.dart
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
part 'connectivity_provider.g.dart';
|
||||
|
||||
enum ConnectionState {
|
||||
offline,
|
||||
mobile,
|
||||
wifi,
|
||||
ethernet;
|
||||
|
||||
bool get homeInternet => switch (this) {
|
||||
ConnectionState.offline => false,
|
||||
ConnectionState.mobile => false,
|
||||
ConnectionState.wifi => true,
|
||||
ConnectionState.ethernet => true,
|
||||
};
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
class ConnectivityStatus extends _$ConnectivityStatus {
|
||||
@override
|
||||
ConnectionState build() {
|
||||
Connectivity().onConnectivityChanged.listen(onStateChange);
|
||||
return ConnectionState.offline;
|
||||
}
|
||||
|
||||
void onStateChange(List<ConnectivityResult> connectivityResult) {
|
||||
if (connectivityResult.contains(ConnectivityResult.ethernet)) {
|
||||
state = ConnectionState.ethernet;
|
||||
} else if (connectivityResult.contains(ConnectivityResult.wifi)) {
|
||||
state = ConnectionState.wifi;
|
||||
} else if (connectivityResult.contains(ConnectivityResult.mobile)) {
|
||||
state = ConnectionState.mobile;
|
||||
} else if (connectivityResult.contains(ConnectivityResult.none)) {
|
||||
state = ConnectionState.offline;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue