mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: added flag emoji instead of country code in the popup view, and countryCode and flag options to the Text widget (#2916)
This commit is contained in:
@@ -1848,3 +1848,10 @@ public func isWidgetActive(_ defaults: UserDefaults?, _ widgets: [String]) -> Bo
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func countryFlag(_ code: String) -> String? {
|
||||||
|
let uppercased = code.uppercased()
|
||||||
|
guard uppercased.count == 2 else { return nil }
|
||||||
|
let scalars = uppercased.unicodeScalars.compactMap { UnicodeScalar(127397 + $0.value) }
|
||||||
|
return scalars.count == 2 ? String(String.UnicodeScalarView(scalars)) : nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -275,6 +275,8 @@ public class Network: Module {
|
|||||||
case "private": replacement = value.laddr.v4 ?? value.laddr.v6 ?? "-"
|
case "private": replacement = value.laddr.v4 ?? value.laddr.v6 ?? "-"
|
||||||
case "privateV4": replacement = value.laddr.v4 ?? "-"
|
case "privateV4": replacement = value.laddr.v4 ?? "-"
|
||||||
case "privateV6": replacement = value.laddr.v6 ?? "-"
|
case "privateV6": replacement = value.laddr.v6 ?? "-"
|
||||||
|
case "countryCode": replacement = value.raddr.countryCode ?? "-"
|
||||||
|
case "flag": replacement = value.raddr.countryCode != nil ? countryFlag(value.raddr.countryCode!) : "-"
|
||||||
default: return
|
default: return
|
||||||
}
|
}
|
||||||
case "$interface":
|
case "$interface":
|
||||||
|
|||||||
@@ -525,8 +525,13 @@ internal class Popup: PopupWrapper {
|
|||||||
}
|
}
|
||||||
var ip = addr
|
var ip = addr
|
||||||
if let cc = value.raddr.countryCode, !cc.isEmpty {
|
if let cc = value.raddr.countryCode, !cc.isEmpty {
|
||||||
|
if let flag = countryFlag(cc) {
|
||||||
|
ip += " \(flag)"
|
||||||
|
} else {
|
||||||
ip += " (\(cc))"
|
ip += " (\(cc))"
|
||||||
}
|
}
|
||||||
|
self.publicIPv4Field?.toolTip = cc
|
||||||
|
}
|
||||||
if self.publicIPv4Field?.stringValue != ip {
|
if self.publicIPv4Field?.stringValue != ip {
|
||||||
self.publicIPv4Field?.stringValue = ip
|
self.publicIPv4Field?.stringValue = ip
|
||||||
}
|
}
|
||||||
@@ -545,8 +550,13 @@ internal class Popup: PopupWrapper {
|
|||||||
}
|
}
|
||||||
var ip = addr
|
var ip = addr
|
||||||
if let cc = value.raddr.countryCode {
|
if let cc = value.raddr.countryCode {
|
||||||
|
if let flag = countryFlag(cc) {
|
||||||
|
ip += " \(flag)"
|
||||||
|
} else {
|
||||||
ip += " (\(cc))"
|
ip += " (\(cc))"
|
||||||
}
|
}
|
||||||
|
self.publicIPv6Field?.toolTip = cc
|
||||||
|
}
|
||||||
if self.publicIPv6Field?.stringValue != ip {
|
if self.publicIPv6Field?.stringValue != ip {
|
||||||
self.publicIPv6Field?.stringValue = ip
|
self.publicIPv6Field?.stringValue = ip
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ You can use a combination of any of the variables. There is only one limitation:
|
|||||||
<li><b>$addr.private</b>: <small>Private/local IP address.</small></li>
|
<li><b>$addr.private</b>: <small>Private/local IP address.</small></li>
|
||||||
<li><b>$addr.privateV4</b>: <small>Private/local IPv4 address.</small></li>
|
<li><b>$addr.privateV4</b>: <small>Private/local IPv4 address.</small></li>
|
||||||
<li><b>$addr.privateV6</b>: <small>Private/local IPv6 address.</small></li>
|
<li><b>$addr.privateV6</b>: <small>Private/local IPv6 address.</small></li>
|
||||||
|
<li><b>$addr.countryCode</b>: <small>Country code based on the public IP address.</small></li>
|
||||||
|
<li><b>$addr.flag</b>: <small>Emoji flag based on the country code.</small></li>
|
||||||
<li><b>$interface.displayName</b>: <small>Network interface name.</small></li>
|
<li><b>$interface.displayName</b>: <small>Network interface name.</small></li>
|
||||||
<li><b>$interface.BSDName</b>: <small>BSD name of the network interface.</small></li>
|
<li><b>$interface.BSDName</b>: <small>BSD name of the network interface.</small></li>
|
||||||
<li><b>$interface.address</b>: <small>MAC address of the network interface.</small></li>
|
<li><b>$interface.address</b>: <small>MAC address of the network interface.</small></li>
|
||||||
|
|||||||
@@ -1717,7 +1717,7 @@
|
|||||||
New,
|
New,
|
||||||
);
|
);
|
||||||
LastSwiftUpdateCheck = 1540;
|
LastSwiftUpdateCheck = 1540;
|
||||||
LastUpgradeCheck = 2610;
|
LastUpgradeCheck = 2620;
|
||||||
ORGANIZATIONNAME = "Serhiy Mytrovtsiy";
|
ORGANIZATIONNAME = "Serhiy Mytrovtsiy";
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
5C22299C29CCB3C400F00E69 = {
|
5C22299C29CCB3C400F00E69 = {
|
||||||
|
|||||||
Reference in New Issue
Block a user