@@ -53,18 +53,14 @@ class _SiteTunnelsScreenState extends State<SiteTunnelsScreen> {
5353 Widget build (BuildContext context) {
5454 final double ipWidth = Utils .textSize ("000.000.000.000" , CupertinoTheme .of (context).textTheme.textStyle).width + 32 ;
5555
56- List <Widget > children = [];
57- tunnels.forEach ((hostInfo) {
58- Widget icon;
59-
56+ final List <ConfigPageItem > children = tunnels.map ((hostInfo) {
6057 final isLh = site.staticHostmap[hostInfo.vpnIp]? .lighthouse ?? false ;
61- if (isLh) {
62- icon = Icon (Icons .lightbulb_outline, color: CupertinoColors .placeholderText.resolveFrom (context));
63- } else {
64- icon = Icon (Icons .computer, color: CupertinoColors .placeholderText.resolveFrom (context));
65- }
58+ final icon = switch (isLh) {
59+ true => Icon (Icons .lightbulb_outline, color: CupertinoColors .placeholderText.resolveFrom (context)),
60+ false => Icon (Icons .computer, color: CupertinoColors .placeholderText.resolveFrom (context))
61+ };
6662
67- children. add (ConfigPageItem (
63+ return (ConfigPageItem (
6864 onPressed: () => Utils .openPage (
6965 context,
7066 (context) => HostInfoScreen (
@@ -82,14 +78,12 @@ class _SiteTunnelsScreenState extends State<SiteTunnelsScreen> {
8278 labelWidth: ipWidth,
8379 content: Container (alignment: Alignment .centerRight, child: Text (hostInfo.cert? .details.name ?? "" )),
8480 ));
85- });
81+ }). toList () ;
8682
87- Widget child;
88- if (children.length == 0 ) {
89- child = Center (child: Padding (child: Text ('No tunnels to show' ), padding: EdgeInsets .only (top: 30 )));
90- } else {
91- child = ConfigSection (children: children);
92- }
83+ final Widget child = switch (children.length) {
84+ 0 => Center (child: Padding (child: Text ('No tunnels to show' ), padding: EdgeInsets .only (top: 30 ))),
85+ _ => ConfigSection (children: children),
86+ };
9387
9488 final title = widget.pending ? 'Pending' : 'Active' ;
9589
0 commit comments