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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Widget item = Container( Widget item = Container(
padding: EdgeInsets.only(left: 15), padding: EdgeInsets.symmetric(horizontal: 15),
constraints: BoxConstraints(minHeight: Utils.minInteractiveSize, minWidth: double.infinity), constraints: BoxConstraints(minHeight: Utils.minInteractiveSize, minWidth: double.infinity),
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
@ -24,7 +24,7 @@ class ConfigCheckboxItem extends StatelessWidget {
label != null ? Container(width: labelWidth, child: label) : Container(), label != null ? Container(width: labelWidth, child: label) : Container(),
Expanded(child: Container(child: content, padding: EdgeInsets.only(right: 10))), Expanded(child: Container(child: content, padding: EdgeInsets.only(right: 10))),
checked checked
? Icon(CupertinoIcons.check_mark, color: CupertinoColors.systemBlue.resolveFrom(context), size: 34) ? Icon(CupertinoIcons.check_mark, color: CupertinoColors.systemBlue.resolveFrom(context))
: Container() : Container()
], ],
)); ));

View file

@ -53,18 +53,14 @@ class _SiteTunnelsScreenState extends State<SiteTunnelsScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final double ipWidth = Utils.textSize("000.000.000.000", CupertinoTheme.of(context).textTheme.textStyle).width + 32; final double ipWidth = Utils.textSize("000.000.000.000", CupertinoTheme.of(context).textTheme.textStyle).width + 32;
List<Widget> children = []; final List<ConfigPageItem> children = tunnels.map((hostInfo) {
tunnels.forEach((hostInfo) {
Widget icon;
final isLh = site.staticHostmap[hostInfo.vpnIp]?.lighthouse ?? false; final isLh = site.staticHostmap[hostInfo.vpnIp]?.lighthouse ?? false;
if (isLh) { final icon = switch (isLh) {
icon = Icon(Icons.lightbulb_outline, color: CupertinoColors.placeholderText.resolveFrom(context)); true => Icon(Icons.lightbulb_outline, color: CupertinoColors.placeholderText.resolveFrom(context)),
} else { false => Icon(Icons.computer, color: CupertinoColors.placeholderText.resolveFrom(context))
icon = Icon(Icons.computer, color: CupertinoColors.placeholderText.resolveFrom(context)); };
}
children.add(ConfigPageItem( return (ConfigPageItem(
onPressed: () => Utils.openPage( onPressed: () => Utils.openPage(
context, context,
(context) => HostInfoScreen( (context) => HostInfoScreen(
@ -82,14 +78,12 @@ class _SiteTunnelsScreenState extends State<SiteTunnelsScreen> {
labelWidth: ipWidth, labelWidth: ipWidth,
content: Container(alignment: Alignment.centerRight, child: Text(hostInfo.cert?.details.name ?? "")), content: Container(alignment: Alignment.centerRight, child: Text(hostInfo.cert?.details.name ?? "")),
)); ));
}); }).toList();
Widget child; final Widget child = switch (children.length) {
if (children.length == 0) { 0 => Center(child: Padding(child: Text('No tunnels to show'), padding: EdgeInsets.only(top: 30))),
child = Center(child: Padding(child: Text('No tunnels to show'), padding: EdgeInsets.only(top: 30))); _ => ConfigSection(children: children),
} else { };
child = ConfigSection(children: children);
}
final title = widget.pending ? 'Pending' : 'Active'; final title = widget.pending ? 'Pending' : 'Active';