mirror of
https://github.com/tw93/Mole.git
synced 2026-02-15 18:05:05 +00:00
Optimize the compatibility display of status
This commit is contained in:
BIN
bin/status-go
BIN
bin/status-go
Binary file not shown.
@@ -387,19 +387,16 @@ func renderNetworkCard(netStats []NetworkStatus, proxy ProxyStatus) cardData {
|
|||||||
txBar := netBar(totalTx)
|
txBar := netBar(totalTx)
|
||||||
lines = append(lines, fmt.Sprintf("Down %s %s", rxBar, formatRate(totalRx)))
|
lines = append(lines, fmt.Sprintf("Down %s %s", rxBar, formatRate(totalRx)))
|
||||||
lines = append(lines, fmt.Sprintf("Up %s %s", txBar, formatRate(totalTx)))
|
lines = append(lines, fmt.Sprintf("Up %s %s", txBar, formatRate(totalTx)))
|
||||||
// Proxy + IP
|
// Show proxy and IP in one line
|
||||||
info := ""
|
var infoParts []string
|
||||||
if proxy.Enabled {
|
if proxy.Enabled {
|
||||||
info = okStyle.Render("Proxy: " + proxy.Type)
|
infoParts = append(infoParts, "Proxy "+proxy.Type)
|
||||||
}
|
}
|
||||||
if primaryIP != "" {
|
if primaryIP != "" {
|
||||||
if info != "" {
|
infoParts = append(infoParts, primaryIP)
|
||||||
info += " · "
|
|
||||||
}
|
}
|
||||||
info += primaryIP
|
if len(infoParts) > 0 {
|
||||||
}
|
lines = append(lines, subtleStyle.Render(strings.Join(infoParts, " · ")))
|
||||||
if info != "" {
|
|
||||||
lines = append(lines, subtleStyle.Render(info))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cardData{icon: iconNetwork, title: "Network", lines: lines}
|
return cardData{icon: iconNetwork, title: "Network", lines: lines}
|
||||||
@@ -430,13 +427,18 @@ func renderBatteryCard(batts []BatteryStatus, thermal ThermalStatus) cardData {
|
|||||||
lines = append(lines, subtleStyle.Render("No battery"))
|
lines = append(lines, subtleStyle.Render("No battery"))
|
||||||
} else {
|
} else {
|
||||||
b := batts[0]
|
b := batts[0]
|
||||||
// Line 1: label + percentage + bar
|
// Line 1: label + bar + percentage (consistent with other cards)
|
||||||
lines = append(lines, fmt.Sprintf("Level %3.0f%% %s", b.Percent, progressBar(b.Percent)))
|
// Only show red when battery is critically low
|
||||||
|
statusLower := strings.ToLower(b.Status)
|
||||||
|
percentText := fmt.Sprintf("%5.1f%%", b.Percent)
|
||||||
|
if b.Percent < 20 && statusLower != "charging" && statusLower != "charged" {
|
||||||
|
percentText = dangerStyle.Render(percentText)
|
||||||
|
}
|
||||||
|
lines = append(lines, fmt.Sprintf("Level %s %s", batteryProgressBar(b.Percent), percentText))
|
||||||
|
|
||||||
// Line 2: status
|
// Line 2: status
|
||||||
statusIcon := ""
|
statusIcon := ""
|
||||||
statusStyle := subtleStyle
|
statusStyle := subtleStyle
|
||||||
statusLower := strings.ToLower(b.Status)
|
|
||||||
if statusLower == "charging" || statusLower == "charged" {
|
if statusLower == "charging" || statusLower == "charged" {
|
||||||
statusIcon = " ⚡"
|
statusIcon = " ⚡"
|
||||||
statusStyle = okStyle
|
statusStyle = okStyle
|
||||||
@@ -541,6 +543,30 @@ func progressBar(percent float64) string {
|
|||||||
return colorizePercent(percent, builder.String())
|
return colorizePercent(percent, builder.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func batteryProgressBar(percent float64) string {
|
||||||
|
total := 18
|
||||||
|
if percent < 0 {
|
||||||
|
percent = 0
|
||||||
|
}
|
||||||
|
if percent > 100 {
|
||||||
|
percent = 100
|
||||||
|
}
|
||||||
|
filled := int(percent / 100 * float64(total))
|
||||||
|
if filled > total {
|
||||||
|
filled = total
|
||||||
|
}
|
||||||
|
|
||||||
|
var builder strings.Builder
|
||||||
|
for i := 0; i < total; i++ {
|
||||||
|
if i < filled {
|
||||||
|
builder.WriteString("█")
|
||||||
|
} else {
|
||||||
|
builder.WriteString("░")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return colorizeBattery(percent, builder.String())
|
||||||
|
}
|
||||||
|
|
||||||
func colorizePercent(percent float64, s string) string {
|
func colorizePercent(percent float64, s string) string {
|
||||||
switch {
|
switch {
|
||||||
case percent >= 90:
|
case percent >= 90:
|
||||||
@@ -552,6 +578,17 @@ func colorizePercent(percent float64, s string) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func colorizeBattery(percent float64, s string) string {
|
||||||
|
switch {
|
||||||
|
case percent < 20:
|
||||||
|
return dangerStyle.Render(s)
|
||||||
|
case percent < 50:
|
||||||
|
return warnStyle.Render(s)
|
||||||
|
default:
|
||||||
|
return okStyle.Render(s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func colorizeTemp(t float64) string {
|
func colorizeTemp(t float64) string {
|
||||||
switch {
|
switch {
|
||||||
case t >= 85:
|
case t >= 85:
|
||||||
|
|||||||
2
mole
2
mole
@@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|||||||
source "$SCRIPT_DIR/lib/core/common.sh"
|
source "$SCRIPT_DIR/lib/core/common.sh"
|
||||||
|
|
||||||
# Version info
|
# Version info
|
||||||
VERSION="1.11.14"
|
VERSION="1.11.15"
|
||||||
MOLE_TAGLINE="can dig deep to clean your Mac."
|
MOLE_TAGLINE="can dig deep to clean your Mac."
|
||||||
|
|
||||||
# Check if Touch ID is already configured
|
# Check if Touch ID is already configured
|
||||||
|
|||||||
Reference in New Issue
Block a user