11import 'package:flutter/material.dart' ;
2+ import 'package:flutter_riverpod/flutter_riverpod.dart' ;
23import '../../../app/theme/tokens.dart' ;
3- import '../../../app/widgets/app_card .dart' ;
4+ import '../../../state/mycelium_providers .dart' ;
45
5- class PeerDetailsSheet extends StatelessWidget {
6+ class PeerDetailsSheet extends ConsumerWidget {
7+ final String ip;
68 final String country;
79 final String city;
810 final String latency;
911 final String status;
12+ final bool isUserPeer;
1013
11- const PeerDetailsSheet ({super .key, required this .country, required this .city, required this .latency, required this .status});
14+ const PeerDetailsSheet (
15+ {super .key,
16+ required this .country,
17+ required this .city,
18+ required this .latency,
19+ required this .status,
20+ required this .ip,
21+ this .isUserPeer = false });
1222
1323 @override
14- Widget build (BuildContext context) {
24+ Widget build (BuildContext context, WidgetRef ref) {
25+ final peersNotifier = ref.read (peersProvider.notifier);
1526 return Padding (
1627 padding: const EdgeInsets .all (AppSpacing .lg),
1728 child: Column (
1829 mainAxisSize: MainAxisSize .min,
1930 children: [
20- Container (height: 4 , width: 40 , margin: const EdgeInsets .only (bottom: AppSpacing .lg), decoration: BoxDecoration (color: Theme .of (context).colorScheme.outline, borderRadius: BorderRadius .circular (2 ))),
31+ Container (
32+ height: 4 ,
33+ width: 40 ,
34+ margin: const EdgeInsets .only (bottom: AppSpacing .lg),
35+ decoration: BoxDecoration (
36+ color: Theme .of (context).colorScheme.outline,
37+ borderRadius: BorderRadius .circular (2 ))),
2138 Row (children: [
2239 const CircleAvatar (radius: 16 , child: Text ('US' )),
2340 const SizedBox (width: AppSpacing .lg),
24- Expanded (child: Text (country, style: Theme .of (context).textTheme.titleMedium, overflow: TextOverflow .ellipsis)),
41+ Expanded (
42+ child: Text (country,
43+ style: Theme .of (context).textTheme.titleMedium,
44+ overflow: TextOverflow .ellipsis)),
2545 const SizedBox (width: AppSpacing .lg),
2646 Text (latency, style: Theme .of (context).textTheme.labelMedium),
2747 ]),
28- const SizedBox (height: AppSpacing .xxl),
29- AppCard (
30- child: Column (crossAxisAlignment: CrossAxisAlignment .start, children: [
31- Text ('Health Check' , style: Theme .of (context).textTheme.titleMedium),
32- const SizedBox (height: AppSpacing .lg),
33- Row (children: [
34- _Kpi (title: 'Ping Status' , value: 'Reachable' ),
48+ const SizedBox (height: AppSpacing .lg),
49+ Row (
50+ children: [
51+ Expanded (
52+ child: OutlinedButton (
53+ onPressed: () {},
54+ child: const Text ('Ping Test' ),
55+ ),
56+ ),
57+ if (isUserPeer) ...[
3558 const SizedBox (width: AppSpacing .lg),
36- _Kpi (title: 'Latency' , value: latency),
37- ]),
38- ]),
59+ Expanded (
60+ child: FilledButton .tonal (
61+ onPressed: () async {
62+ await peersNotifier.removePeer (ip);
63+ if (context.mounted) {
64+ Navigator .of (context).pop ();
65+ }
66+ },
67+ child: const Text ('Remove Peer' ),
68+ ),
69+ ),
70+ ],
71+ ],
3972 ),
4073 const SizedBox (height: AppSpacing .lg),
41- Row (children: [
42- Expanded (child: OutlinedButton (onPressed: () {}, child: const Text ('Ping Test' ))),
43- const SizedBox (width: AppSpacing .lg),
44- Expanded (child: FilledButton .tonal (onPressed: () {}, child: const Text ('Remove Peer' ))),
45- ]),
46- const SizedBox (height: AppSpacing .lg),
4774 ],
4875 ),
4976 );
@@ -59,7 +86,9 @@ class _Kpi extends StatelessWidget {
5986 Widget build (BuildContext context) {
6087 return Expanded (
6188 child: Container (
62- decoration: BoxDecoration (color: Theme .of (context).colorScheme.surfaceContainerHighest, borderRadius: BorderRadius .circular (AppRadii .md)),
89+ decoration: BoxDecoration (
90+ color: Theme .of (context).colorScheme.surfaceContainerHighest,
91+ borderRadius: BorderRadius .circular (AppRadii .md)),
6392 padding: const EdgeInsets .all (AppSpacing .lg),
6493 child: Column (crossAxisAlignment: CrossAxisAlignment .start, children: [
6594 Text (title, style: Theme .of (context).textTheme.labelMedium),
@@ -70,5 +99,3 @@ class _Kpi extends StatelessWidget {
7099 );
71100 }
72101}
73-
74-
0 commit comments