Clean up SiteTunnelsScreen & Fix padding for the Checkbox config item (#239)

* Clean up SiteTunnelsScreen

* Adding padding to the checkmark in ConfigCheckboxItem
This commit is contained in:
Caleb Jasik 2025-01-29 16:08:08 -06:00 committed by GitHub
parent af1c582984
commit f69f7cc9a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 19 deletions

View file

@ -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()
],
));

View file

@ -53,18 +53,14 @@ class _SiteTunnelsScreenState extends State<SiteTunnelsScreen> {
Widget build(BuildContext context) {
final double ipWidth = Utils.textSize("000.000.000.000", CupertinoTheme.of(context).textTheme.textStyle).width + 32;
List<Widget> children = [];
tunnels.forEach((hostInfo) {
Widget icon;
final List<ConfigPageItem> 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<SiteTunnelsScreen> {
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';