Add sidebar stats for large screens
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';
|
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';
|
||||||
import 'package:hiddify/core/core_providers.dart';
|
import 'package:hiddify/core/core_providers.dart';
|
||||||
import 'package:hiddify/core/router/router.dart';
|
import 'package:hiddify/core/router/router.dart';
|
||||||
|
import 'package:hiddify/features/common/side_bar_stats_overview.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
|
||||||
abstract interface class RootScaffold {
|
abstract interface class RootScaffold {
|
||||||
@@ -55,6 +56,12 @@ class AdaptiveRootScaffold extends HookConsumerWidget {
|
|||||||
drawerDestinationRange: useMobileRouter ? (2, null) : (0, null),
|
drawerDestinationRange: useMobileRouter ? (2, null) : (0, null),
|
||||||
bottomDestinationRange: (0, 2),
|
bottomDestinationRange: (0, 2),
|
||||||
useBottomSheet: useMobileRouter,
|
useBottomSheet: useMobileRouter,
|
||||||
|
sidebarTrailing: const Expanded(
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.bottomCenter,
|
||||||
|
child: SideBarStatsOverview(),
|
||||||
|
),
|
||||||
|
),
|
||||||
body: navigator,
|
body: navigator,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -68,6 +75,7 @@ class _CustomAdaptiveScaffold extends HookConsumerWidget {
|
|||||||
required this.drawerDestinationRange,
|
required this.drawerDestinationRange,
|
||||||
required this.bottomDestinationRange,
|
required this.bottomDestinationRange,
|
||||||
this.useBottomSheet = false,
|
this.useBottomSheet = false,
|
||||||
|
this.sidebarTrailing,
|
||||||
required this.body,
|
required this.body,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -77,6 +85,7 @@ class _CustomAdaptiveScaffold extends HookConsumerWidget {
|
|||||||
final (int, int?) drawerDestinationRange;
|
final (int, int?) drawerDestinationRange;
|
||||||
final (int, int?) bottomDestinationRange;
|
final (int, int?) bottomDestinationRange;
|
||||||
final bool useBottomSheet;
|
final bool useBottomSheet;
|
||||||
|
final Widget? sidebarTrailing;
|
||||||
final Widget body;
|
final Widget body;
|
||||||
|
|
||||||
List<NavigationDestination> destinationsSlice((int, int?) range) =>
|
List<NavigationDestination> destinationsSlice((int, int?) range) =>
|
||||||
@@ -134,6 +143,7 @@ class _CustomAdaptiveScaffold extends HookConsumerWidget {
|
|||||||
.map((_) => AdaptiveScaffold.toRailDestination(_))
|
.map((_) => AdaptiveScaffold.toRailDestination(_))
|
||||||
.toList(),
|
.toList(),
|
||||||
onDestinationSelected: onSelectedIndexChange,
|
onDestinationSelected: onSelectedIndexChange,
|
||||||
|
trailing: sidebarTrailing,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,19 +2,18 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:gap/gap.dart';
|
import 'package:gap/gap.dart';
|
||||||
import 'package:hiddify/core/core_providers.dart';
|
import 'package:hiddify/core/core_providers.dart';
|
||||||
import 'package:hiddify/domain/singbox/singbox.dart';
|
import 'package:hiddify/domain/singbox/singbox.dart';
|
||||||
import 'package:hiddify/features/common/stats/stats_notifier.dart';
|
import 'package:hiddify/features/common/stats_provider.dart';
|
||||||
import 'package:hiddify/utils/utils.dart';
|
import 'package:hiddify/utils/utils.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
|
||||||
class StatsOverview extends HookConsumerWidget {
|
class SideBarStatsOverview extends HookConsumerWidget {
|
||||||
const StatsOverview({super.key});
|
const SideBarStatsOverview({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final t = ref.watch(translationsProvider);
|
final t = ref.watch(translationsProvider);
|
||||||
|
|
||||||
final stats =
|
final stats = ref.watch(statsProvider).asData?.value ?? CoreStatus.empty();
|
||||||
ref.watch(statsNotifierProvider).asData?.value ?? CoreStatus.empty();
|
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16),
|
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16),
|
||||||
@@ -4,10 +4,10 @@ import 'package:hiddify/features/common/connectivity/connectivity_controller.dar
|
|||||||
import 'package:hiddify/utils/utils.dart';
|
import 'package:hiddify/utils/utils.dart';
|
||||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
|
||||||
part 'stats_notifier.g.dart';
|
part 'stats_provider.g.dart';
|
||||||
|
|
||||||
@riverpod
|
@riverpod
|
||||||
class StatsNotifier extends _$StatsNotifier with AppLogger {
|
class Stats extends _$Stats with AppLogger {
|
||||||
@override
|
@override
|
||||||
Stream<CoreStatus> build() async* {
|
Stream<CoreStatus> build() async* {
|
||||||
final serviceRunning = await ref.watch(serviceRunningProvider.future);
|
final serviceRunning = await ref.watch(serviceRunningProvider.future);
|
||||||
Reference in New Issue
Block a user