diff --git a/lib/components/config/ConfigCheckboxItem.dart b/lib/components/config/ConfigCheckboxItem.dart index f013378..8947b3d 100644 --- a/lib/components/config/ConfigCheckboxItem.dart +++ b/lib/components/config/ConfigCheckboxItem.dart @@ -16,7 +16,7 @@ class ConfigCheckboxItem extends StatelessWidget { @override Widget build(BuildContext context) { Widget item = Container( - padding: EdgeInsets.only(left: 15), + padding: EdgeInsets.symmetric(horizontal: 15), constraints: BoxConstraints(minHeight: Utils.minInteractiveSize, minWidth: double.infinity), child: Row( crossAxisAlignment: CrossAxisAlignment.center, @@ -24,7 +24,7 @@ class ConfigCheckboxItem extends StatelessWidget { label != null ? Container(width: labelWidth, child: label) : Container(), Expanded(child: Container(child: content, padding: EdgeInsets.only(right: 10))), checked - ? Icon(CupertinoIcons.check_mark, color: CupertinoColors.systemBlue.resolveFrom(context), size: 34) + ? Icon(CupertinoIcons.check_mark, color: CupertinoColors.systemBlue.resolveFrom(context)) : Container() ], )); diff --git a/lib/screens/SiteTunnelsScreen.dart b/lib/screens/SiteTunnelsScreen.dart index d9d4b72..7b3e6c8 100644 --- a/lib/screens/SiteTunnelsScreen.dart +++ b/lib/screens/SiteTunnelsScreen.dart @@ -53,18 +53,14 @@ class _SiteTunnelsScreenState extends State { Widget build(BuildContext context) { final double ipWidth = Utils.textSize("000.000.000.000", CupertinoTheme.of(context).textTheme.textStyle).width + 32; - List children = []; - tunnels.forEach((hostInfo) { - Widget icon; - + final List children = tunnels.map((hostInfo) { final isLh = site.staticHostmap[hostInfo.vpnIp]?.lighthouse ?? false; - if (isLh) { - icon = Icon(Icons.lightbulb_outline, color: CupertinoColors.placeholderText.resolveFrom(context)); - } else { - icon = Icon(Icons.computer, color: CupertinoColors.placeholderText.resolveFrom(context)); - } + final icon = switch (isLh) { + true => Icon(Icons.lightbulb_outline, color: CupertinoColors.placeholderText.resolveFrom(context)), + false => Icon(Icons.computer, color: CupertinoColors.placeholderText.resolveFrom(context)) + }; - children.add(ConfigPageItem( + return (ConfigPageItem( onPressed: () => Utils.openPage( context, (context) => HostInfoScreen( @@ -82,14 +78,12 @@ class _SiteTunnelsScreenState extends State { labelWidth: ipWidth, content: Container(alignment: Alignment.centerRight, child: Text(hostInfo.cert?.details.name ?? "")), )); - }); + }).toList(); - Widget child; - if (children.length == 0) { - child = Center(child: Padding(child: Text('No tunnels to show'), padding: EdgeInsets.only(top: 30))); - } else { - child = ConfigSection(children: children); - } + final Widget child = switch (children.length) { + 0 => Center(child: Padding(child: Text('No tunnels to show'), padding: EdgeInsets.only(top: 30))), + _ => ConfigSection(children: children), + }; final title = widget.pending ? 'Pending' : 'Active';