From f23477e796b23d81af52a40d2d1e6f022374901c Mon Sep 17 00:00:00 2001 From: Aalok Kamble Date: Fri, 8 Mar 2024 17:26:22 +0000 Subject: [PATCH] Feature: machine status icon added. (#167) * Feature: machine status icon added. Signed-off-by: Aalok Kamble * Update ui.go Aligned dot vertically with lowercase letters for machine names. Reverted 'Machine' to 'My devices' Signed-off-by: Aalok Kamble * status dot changed from string to drawdisc Signed-off-by: Aalok Kamble --------- Signed-off-by: Aalok Kamble --- cmd/tailscale/ui.go | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/cmd/tailscale/ui.go b/cmd/tailscale/ui.go index e6ecbf5..0e28a17 100644 --- a/cmd/tailscale/ui.go +++ b/cmd/tailscale/ui.go @@ -1317,10 +1317,31 @@ func (ui *UI) layoutPeer(gtx layout.Context, sysIns system.Insets, p *UIPeer, us gtx.Constraints.Min.X = gtx.Constraints.Max.X return layout.Flex{Axis: layout.Vertical}.Layout(gtx, layout.Rigid(func(gtx C) D { - return layout.Inset{Bottom: unit.Dp(4)}.Layout(gtx, func(gtx C) D { - name := p.Peer.DisplayName(p.Peer.User == user) - return material.H6(ui.theme, name).Layout(gtx) - }) + return layout.Stack{}.Layout(gtx, + layout.Expanded(func(gtx C) D { + return layout.Stack{Alignment: layout.W}.Layout(gtx, + layout.Stacked(func(gtx C) D { + return layout.Inset{Bottom: unit.Dp(8)}.Layout(gtx, func(gtx C) D { + return layout.N.Layout(gtx, func(gtx C) D { + if p.Peer.Online != nil && *p.Peer.Online { + drawDisc(gtx.Ops, 24, rgb(0x009966)) + } else { + drawDisc(gtx.Ops, 24, rgb(0xcccccc)) + } + return layout.Dimensions{Size: image.Pt(0, 0)} + }) + }) + }), + layout.Stacked(func(gtx C) D { + return layout.Inset{Left: unit.Dp(16), Bottom: unit.Dp(4)}.Layout(gtx, func(gtx C) D { + name := p.Peer.DisplayName(p.Peer.User == user) + return material.H6(ui.theme, name).Layout(gtx) + }) + }), + ) + }), + ) + }), layout.Rigid(func(gtx C) D { var bestIP netip.Addr // IP to show; first IPv4, or first IPv6 if no IPv4 @@ -1472,7 +1493,7 @@ func (ui *UI) layoutSearchbar(gtx layout.Context, sysIns system.Insets) layout.D return ui.icons.search.Layout(gtx, col) }), layout.Flexed(1, - material.Editor(ui.theme, &ui.search, "Search by machine name...").Layout, + material.Editor(ui.theme, &ui.search, "Search by device name...").Layout, ), ) })