Add sidebar stats for large screens
This commit is contained in:
23
lib/features/common/stats_provider.dart
Normal file
23
lib/features/common/stats_provider.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:hiddify/data/data_providers.dart';
|
||||
import 'package:hiddify/domain/singbox/singbox.dart';
|
||||
import 'package:hiddify/features/common/connectivity/connectivity_controller.dart';
|
||||
import 'package:hiddify/utils/utils.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
part 'stats_provider.g.dart';
|
||||
|
||||
@riverpod
|
||||
class Stats extends _$Stats with AppLogger {
|
||||
@override
|
||||
Stream<CoreStatus> build() async* {
|
||||
final serviceRunning = await ref.watch(serviceRunningProvider.future);
|
||||
if (serviceRunning) {
|
||||
yield* ref
|
||||
.watch(coreFacadeProvider)
|
||||
.watchCoreStatus()
|
||||
.map((event) => event.getOrElse((_) => CoreStatus.empty()));
|
||||
} else {
|
||||
yield* Stream.value(CoreStatus.empty());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user