Skip to content

Commit a33a0f7

Browse files
committed
Feature: Adjust status bar position
1 parent b1b43a0 commit a33a0f7

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

ClashX/AppDelegate.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
4545
self.updateProxyList()
4646
}
4747
setupData()
48-
// os_log(<#T##message: StaticString##StaticString#>, <#T##args: CVarArg...##CVarArg#>)
4948
}
5049

5150

@@ -68,7 +67,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
6867
.showNetSpeedIndicatorObservable
6968
.bind {[unowned self] (show) in
7069
self.showNetSpeedIndicatorMenuItem.state = (show ?? true) ? .on : .off
71-
self.statusItem = NSStatusBar.system.statusItem(withLength: (show ?? true) ? 57 : 22)
70+
self.statusItem = NSStatusBar.system.statusItem(withLength: (show ?? true) ? 65 : 25)
7271
self.statusItem.view = self.statusItemView
7372
self.statusItemView.showSpeedContainer(show: (show ?? true))
7473
self.statusItemView.statusItem = self.statusItem

ClashX/ViewControllers/StatusItemView.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class StatusItemView: NSView {
2020
@IBOutlet weak var speedContainerView: NSView!
2121
weak var statusItem:NSStatusItem?
2222
var disposeBag = DisposeBag()
23+
var isDarkMode = false
2324

2425
var onPopUpMenuAction:(()->())? = nil
2526

@@ -43,6 +44,7 @@ class StatusItemView: NSView {
4344
let darkMode = (value ?? "Light") == "Dark"
4445
let image = NSImage(named: NSImage.Name(rawValue: "menu_icon"))!.tint(color: darkMode ? NSColor.white : NSColor.black)
4546
self.imageView.image = image
47+
self.isDarkMode = darkMode
4648
}.disposed(by: disposeBag)
4749
}
4850

@@ -96,5 +98,10 @@ extension StatusItemView:NSMenuDelegate {
9698
statusItem?.drawStatusBarBackground(in: self.bounds, withHighlight: highlight)
9799
image.unlockFocus()
98100
self.layer?.contents = image
101+
102+
if !self.isDarkMode {
103+
self.uploadSpeedLabel.textColor = highlight ? NSColor.white : NSColor.black
104+
self.downloadSpeedLabel.textColor = highlight ? NSColor.white : NSColor.black
105+
}
99106
}
100107
}

ClashX/ViewControllers/StatusItemView.xib

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
1616
<subviews>
1717
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="7SZ-08-T0A">
18-
<rect key="frame" x="0.0" y="2" width="18" height="18"/>
18+
<rect key="frame" x="3" y="2" width="18" height="18"/>
1919
<constraints>
2020
<constraint firstAttribute="width" constant="18" id="2lK-hJ-kRz"/>
2121
<constraint firstAttribute="width" secondItem="7SZ-08-T0A" secondAttribute="height" multiplier="1:1" id="SFy-Pa-ZDj"/>
2222
</constraints>
2323
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="menu_icon" id="Hsk-Wu-8gc"/>
2424
</imageView>
2525
<customView translatesAutoresizingMaskIntoConstraints="NO" id="x4I-nn-92U">
26-
<rect key="frame" x="26" y="0.0" width="31" height="22"/>
26+
<rect key="frame" x="23" y="0.0" width="31" height="22"/>
2727
<subviews>
2828
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Hlw-Vg-wLD">
2929
<rect key="frame" x="-2" y="1" width="35" height="11"/>
@@ -54,10 +54,10 @@
5454
</subviews>
5555
<constraints>
5656
<constraint firstItem="x4I-nn-92U" firstAttribute="centerY" secondItem="c22-O7-iKe" secondAttribute="centerY" id="75I-1m-KLi"/>
57-
<constraint firstAttribute="trailing" secondItem="x4I-nn-92U" secondAttribute="trailing" id="QUu-S7-d1r"/>
57+
<constraint firstAttribute="trailing" secondItem="x4I-nn-92U" secondAttribute="trailing" constant="3" id="QUu-S7-d1r"/>
5858
<constraint firstItem="7SZ-08-T0A" firstAttribute="centerY" secondItem="c22-O7-iKe" secondAttribute="centerY" id="YW6-Cv-OQs"/>
5959
<constraint firstAttribute="bottom" secondItem="x4I-nn-92U" secondAttribute="bottom" id="mZu-Sw-ZNJ"/>
60-
<constraint firstItem="7SZ-08-T0A" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" id="uUH-eW-Jyi"/>
60+
<constraint firstItem="7SZ-08-T0A" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" constant="3" id="uUH-eW-Jyi"/>
6161
<constraint firstItem="x4I-nn-92U" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" id="yw8-7n-aCe"/>
6262
</constraints>
6363
<connections>
@@ -70,6 +70,6 @@
7070
</customView>
7171
</objects>
7272
<resources>
73-
<image name="menu_icon" width="18" height="18"/>
73+
<image name="menu_icon" width="16" height="16"/>
7474
</resources>
7575
</document>

0 commit comments

Comments
 (0)