Add missing routing asset warning

This commit is contained in:
problematicconsumer
2023-12-12 17:35:44 +03:30
parent 339aabda3f
commit 4c2a412820
6 changed files with 59 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ import 'package:hiddify/core/localization/translations.dart';
import 'package:hiddify/features/geo_asset/overview/geo_assets_overview_notifier.dart';
import 'package:hiddify/features/geo_asset/widget/geo_asset_tile.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:sliver_tools/sliver_tools.dart';
class GeoAssetsOverviewPage extends HookConsumerWidget {
const GeoAssetsOverviewPage({super.key});
@@ -17,6 +18,7 @@ class GeoAssetsOverviewPage extends HookConsumerWidget {
slivers: [
SliverAppBar(
title: Text(t.settings.geoAssets.pageTitle),
pinned: true,
actions: [
PopupMenuButton(
itemBuilder: (context) {
@@ -34,6 +36,17 @@ class GeoAssetsOverviewPage extends HookConsumerWidget {
),
],
),
if (state case AsyncData(value: final geoAssets))
SliverPinnedHeader(
child: AnimatedSwitcher(
duration: const Duration(milliseconds: 200),
child: geoAssets
.where((e) => e.$1.active && e.$2 == null)
.isNotEmpty
? const MissingRoutingAssetsCard()
: const SizedBox(),
),
),
switch (state) {
AsyncData(value: final geoAssets) => SliverList.builder(
itemBuilder: (context, index) {
@@ -54,3 +67,39 @@ class GeoAssetsOverviewPage extends HookConsumerWidget {
);
}
}
class MissingRoutingAssetsCard extends HookConsumerWidget {
const MissingRoutingAssetsCard({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final t = ref.watch(translationsProvider);
return Card(
margin: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 4,
),
child: Row(
children: [
const Padding(
padding: EdgeInsets.all(8.0),
child: Icon(Icons.lightbulb),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding:
const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
child: Text(t.settings.geoAssets.missingGeoAssetsMsg),
),
],
),
),
],
),
);
}
}