Skip to content

Commit f69f7cc

Browse files
authored
Clean up SiteTunnelsScreen & Fix padding for the Checkbox config item (#239)
* Clean up SiteTunnelsScreen * Adding padding to the checkmark in ConfigCheckboxItem
1 parent af1c582 commit f69f7cc

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

lib/components/config/ConfigCheckboxItem.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ class ConfigCheckboxItem extends StatelessWidget {
1616
@override
1717
Widget build(BuildContext context) {
1818
Widget item = Container(
19-
padding: EdgeInsets.only(left: 15),
19+
padding: EdgeInsets.symmetric(horizontal: 15),
2020
constraints: BoxConstraints(minHeight: Utils.minInteractiveSize, minWidth: double.infinity),
2121
child: Row(
2222
crossAxisAlignment: CrossAxisAlignment.center,
2323
children: <Widget>[
2424
label != null ? Container(width: labelWidth, child: label) : Container(),
2525
Expanded(child: Container(child: content, padding: EdgeInsets.only(right: 10))),
2626
checked
27-
? Icon(CupertinoIcons.check_mark, color: CupertinoColors.systemBlue.resolveFrom(context), size: 34)
27+
? Icon(CupertinoIcons.check_mark, color: CupertinoColors.systemBlue.resolveFrom(context))
2828
: Container()
2929
],
3030
));

lib/screens/SiteTunnelsScreen.dart

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)