Skip to content
This repository was archived by the owner on Jun 27, 2024. It is now read-only.

Commit 61c1a8f

Browse files
Matthew BenedictMatthew Benedict
authored andcommitted
Wi-Fi details view
1 parent a68827c commit 61c1a8f

File tree

5 files changed

+155
-25
lines changed

5 files changed

+155
-25
lines changed

Control Center.xcodeproj/project.pbxproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
01FE0F5224B9BE1800FD673A /* PreferencesWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 01FE0F5024B9BE1800FD673A /* PreferencesWindow.xib */; };
2121
01FE0F5724B9C94200FD673A /* APIKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01FE0F5624B9C94200FD673A /* APIKey.swift */; };
2222
01FE0F5924BC312200FD673A /* nightlight in Resources */ = {isa = PBXBuildFile; fileRef = 01FE0F5824BC312200FD673A /* nightlight */; };
23+
483CA15629DF39B6008392F2 /* WiFiDetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 483CA15529DF39B6008392F2 /* WiFiDetailsView.swift */; };
2324
/* End PBXBuildFile section */
2425

2526
/* Begin PBXFileReference section */
@@ -40,6 +41,7 @@
4041
01FE0F5824BC312200FD673A /* nightlight */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = nightlight; sourceTree = "<group>"; };
4142
101B2B451AB8F61B5481FD5E /* Pods_Control_Center.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Control_Center.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4243
10FF59AA878FAE0476FD6102 /* Pods-Control Center.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Control Center.release.xcconfig"; path = "Target Support Files/Pods-Control Center/Pods-Control Center.release.xcconfig"; sourceTree = "<group>"; };
44+
483CA15529DF39B6008392F2 /* WiFiDetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WiFiDetailsView.swift; sourceTree = "<group>"; };
4345
EE321580286F2268FBD02F40 /* Pods-Control Center.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Control Center.debug.xcconfig"; path = "Target Support Files/Pods-Control Center/Pods-Control Center.debug.xcconfig"; sourceTree = "<group>"; };
4446
/* End PBXFileReference section */
4547

@@ -82,6 +84,7 @@
8284
014FC54D24B69AB000344772 /* StatusMenuController.swift */,
8385
014FC55724B6F70D00344772 /* ControlCenterView.swift */,
8486
01FE0F4F24B9BE1800FD673A /* PreferencesWindow.swift */,
87+
483CA15529DF39B6008392F2 /* WiFiDetailsView.swift */,
8588
014FC55924B701EA00344772 /* WeatherAPI.swift */,
8689
014FC54124B6158600344772 /* Assets.xcassets */,
8790
014FC54324B6158600344772 /* ControlCenter.xib */,
@@ -238,6 +241,7 @@
238241
buildActionMask = 2147483647;
239242
files = (
240243
014FC54E24B69AB000344772 /* StatusMenuController.swift in Sources */,
244+
483CA15629DF39B6008392F2 /* WiFiDetailsView.swift in Sources */,
241245
01FE0F5724B9C94200FD673A /* APIKey.swift in Sources */,
242246
01FE0F5124B9BE1800FD673A /* PreferencesWindow.swift in Sources */,
243247
014FC55A24B701EA00344772 /* WeatherAPI.swift in Sources */,
@@ -310,7 +314,7 @@
310314
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
311315
GCC_WARN_UNUSED_FUNCTION = YES;
312316
GCC_WARN_UNUSED_VARIABLE = YES;
313-
MACOSX_DEPLOYMENT_TARGET = 10.14;
317+
MACOSX_DEPLOYMENT_TARGET = 10.12.2;
314318
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
315319
MTL_FAST_MATH = YES;
316320
ONLY_ACTIVE_ARCH = YES;
@@ -364,7 +368,7 @@
364368
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
365369
GCC_WARN_UNUSED_FUNCTION = YES;
366370
GCC_WARN_UNUSED_VARIABLE = YES;
367-
MACOSX_DEPLOYMENT_TARGET = 10.14;
371+
MACOSX_DEPLOYMENT_TARGET = 10.12.2;
368372
MTL_ENABLE_DEBUG_INFO = NO;
369373
MTL_FAST_MATH = YES;
370374
SDKROOT = macosx;

Control Center/Base.lproj/ControlCenter.xib

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15705" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15705"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17701"/>
66
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
77
</dependencies>
88
<objects>
@@ -52,72 +52,88 @@
5252
<box fixedFrame="YES" borderType="bezel" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="PrZ-Xi-Vae" userLabel="DoNotDisturbBox">
5353
<rect key="frame" x="170" y="396" width="170" height="78"/>
5454
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
55-
<view key="contentView" ambiguous="YES" id="olc-uZ-rhF">
55+
<view key="contentView" id="olc-uZ-rhF">
5656
<rect key="frame" x="3" y="3" width="164" height="72"/>
5757
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
5858
</view>
5959
</box>
6060
<box fixedFrame="YES" borderType="bezel" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="bZc-jV-wA0" userLabel="SleepDisplayBox">
6161
<rect key="frame" x="170" y="313" width="84" height="83"/>
6262
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
63-
<view key="contentView" ambiguous="YES" id="84d-3y-hNs">
63+
<view key="contentView" id="84d-3y-hNs">
6464
<rect key="frame" x="3" y="3" width="78" height="77"/>
6565
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
6666
</view>
6767
</box>
6868
<box fixedFrame="YES" borderType="bezel" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="zzI-UX-Jjr" userLabel="SettingsBox">
6969
<rect key="frame" x="5" y="2" width="84" height="82"/>
7070
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
71-
<view key="contentView" ambiguous="YES" id="a6S-eF-xk7">
71+
<view key="contentView" id="a6S-eF-xk7">
7272
<rect key="frame" x="3" y="3" width="78" height="76"/>
7373
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
7474
</view>
7575
</box>
7676
<box fixedFrame="YES" borderType="bezel" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="9Ct-xi-Gcx" userLabel="NightShiftBox">
7777
<rect key="frame" x="256" y="313" width="84" height="83"/>
7878
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
79-
<view key="contentView" ambiguous="YES" id="QTx-Qu-eer">
79+
<view key="contentView" id="QTx-Qu-eer">
8080
<rect key="frame" x="3" y="3" width="78" height="77"/>
8181
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
8282
</view>
8383
</box>
8484
<box fixedFrame="YES" borderType="bezel" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="hzG-SM-UtE" userLabel="DisplayBox">
8585
<rect key="frame" x="5" y="241" width="335" height="70"/>
8686
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
87-
<view key="contentView" ambiguous="YES" id="yWS-wQ-ppp">
87+
<view key="contentView" id="yWS-wQ-ppp">
8888
<rect key="frame" x="3" y="3" width="329" height="64"/>
8989
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
9090
</view>
9191
</box>
9292
<box fixedFrame="YES" borderType="bezel" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="0yJ-kB-Nqn" userLabel="MusicBox">
9393
<rect key="frame" x="91" y="2" width="249" height="82"/>
9494
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
95-
<view key="contentView" ambiguous="YES" id="yT4-zr-9EC">
95+
<view key="contentView" id="yT4-zr-9EC">
9696
<rect key="frame" x="3" y="3" width="243" height="76"/>
9797
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
9898
</view>
9999
</box>
100100
<box fixedFrame="YES" borderType="bezel" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="uyj-Nl-kVF" userLabel="SoundBox">
101101
<rect key="frame" x="5" y="169" width="335" height="70"/>
102102
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
103-
<view key="contentView" ambiguous="YES" id="fOr-l5-5ZF">
103+
<view key="contentView" id="fOr-l5-5ZF">
104104
<rect key="frame" x="3" y="3" width="329" height="64"/>
105105
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
106106
</view>
107107
</box>
108108
<box fixedFrame="YES" borderType="bezel" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="SQV-XW-3aC" userLabel="WeatherBox">
109109
<rect key="frame" x="5" y="86" width="336" height="81"/>
110110
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
111-
<view key="contentView" ambiguous="YES" id="upe-HH-PuA">
111+
<view key="contentView" id="upe-HH-PuA">
112112
<rect key="frame" x="3" y="3" width="330" height="75"/>
113113
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
114114
</view>
115115
</box>
116116
<box fixedFrame="YES" borderType="bezel" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="HlV-1N-l2E" userLabel="ConnectionsBox">
117-
<rect key="frame" x="5" y="313" width="163" height="161"/>
117+
<rect key="frame" x="5" y="313" width="163" height="54"/>
118118
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
119-
<view key="contentView" ambiguous="YES" id="8cj-kF-hr9">
120-
<rect key="frame" x="3" y="3" width="157" height="155"/>
119+
<view key="contentView" id="8cj-kF-hr9">
120+
<rect key="frame" x="3" y="3" width="157" height="48"/>
121+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
122+
</view>
123+
</box>
124+
<box fixedFrame="YES" borderType="bezel" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="mIy-qR-dZY" userLabel="ConnectionsBox">
125+
<rect key="frame" x="5" y="367" width="163" height="54"/>
126+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
127+
<view key="contentView" id="tdp-5U-tPx">
128+
<rect key="frame" x="3" y="3" width="157" height="48"/>
129+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
130+
</view>
131+
</box>
132+
<box fixedFrame="YES" borderType="bezel" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="N3T-g9-Kpl" userLabel="ConnectionsBox">
133+
<rect key="frame" x="5" y="420" width="163" height="54"/>
134+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
135+
<view key="contentView" id="wnO-yq-ED4">
136+
<rect key="frame" x="3" y="3" width="157" height="48"/>
121137
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
122138
</view>
123139
</box>
@@ -259,7 +275,7 @@
259275
<rect key="frame" x="18" y="284" width="57" height="19"/>
260276
<autoresizingMask key="autoresizingMask"/>
261277
<textFieldCell key="cell" lineBreakMode="clipping" title="Display" id="t43-hW-nS5">
262-
<font key="font" size="15" name=".AppleSystemUIFontDemi"/>
278+
<font key="font" metaFont="systemSemibold" size="15"/>
263279
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
264280
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
265281
</textFieldCell>
@@ -268,7 +284,7 @@
268284
<rect key="frame" x="18" y="211" width="50" height="19"/>
269285
<autoresizingMask key="autoresizingMask"/>
270286
<textFieldCell key="cell" lineBreakMode="clipping" title="Sound" id="N8a-KK-qxE">
271-
<font key="font" size="15" name=".AppleSystemUIFontDemi"/>
287+
<font key="font" metaFont="systemSemibold" size="15"/>
272288
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
273289
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
274290
</textFieldCell>
@@ -428,9 +444,9 @@
428444
</connections>
429445
</button>
430446
<button toolTip="Switch between Light and Dark Mode" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="LHb-CW-1CL">
431-
<rect key="frame" x="14" y="323" width="48" height="48"/>
447+
<rect key="frame" x="14" y="318" width="48" height="48"/>
432448
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
433-
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="bulb_blank" imagePosition="only" alignment="center" imageScaling="proportionallyUpOrDown" inset="2" id="e6t-EY-2y7">
449+
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="bulb_blank" imagePosition="overlaps" alignment="center" imageScaling="proportionallyUpOrDown" inset="2" id="e6t-EY-2y7">
434450
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
435451
<font key="font" metaFont="system"/>
436452
</buttonCell>
@@ -512,6 +528,17 @@
512528
<action selector="preferencesClicked:" target="aHq-GP-m7e" id="OTf-ZA-zRu"/>
513529
</connections>
514530
</button>
531+
<button toolTip="Turn Wi-Fi On/Off" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="wPJ-fw-XpR">
532+
<rect key="frame" x="61" y="424" width="104" height="48"/>
533+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
534+
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="bulb_blank" imagePosition="only" alignment="center" imageScaling="proportionallyUpOrDown" inset="2" id="gXt-Wf-eix">
535+
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
536+
<font key="font" metaFont="system"/>
537+
</buttonCell>
538+
<connections>
539+
<action selector="wifiDetailsClicked:" target="aHq-GP-m7e" id="Vb6-Lo-QAt"/>
540+
</connections>
541+
</button>
515542
</subviews>
516543
<connections>
517544
<outlet property="BluetoothBulb" destination="SjH-9G-zse" id="6Lj-mC-RU6"/>

Control Center/ControlCenterView.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,6 @@ class ControlCenterView: NSView {
352352
}
353353

354354
func getDisplayBrightness() -> Float {
355-
356355
var brightness: Float = 1.0
357356
var service: io_object_t = 1
358357
var iterator: io_iterator_t = 0

Control Center/StatusMenuController.swift

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class StatusMenuController: NSObject, NSMenuDelegate, WeatherAPIDelegate {
4848

4949
@IBOutlet weak var window: NSWindow!
5050
@IBOutlet weak var CCMenu: NSMenu!
51-
@IBOutlet weak var ControlCenterView: ControlCenterView!
51+
@IBOutlet weak var controlCenterView: ControlCenterView!
5252
@IBOutlet weak var brightnessSlider: NSSlider!
5353
@IBOutlet weak var volumeSlider: NSSlider!
5454
@IBOutlet weak var wifiStatus: NSTextField!
@@ -70,18 +70,22 @@ class StatusMenuController: NSObject, NSMenuDelegate, WeatherAPIDelegate {
7070
let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength)
7171
var weatherAPI: WeatherAPI!
7272
var preferencesWindow: PreferencesWindow!
73+
var wifiDetailsView: WiFiDetailsView!
7374

7475
override func awakeFromNib() {
75-
ControlCenterView.window?.isOpaque = true
76-
ControlCenterView.window?.backgroundColor = NSColor.clear
76+
controlCenterView.window?.isOpaque = true
77+
controlCenterView.window?.backgroundColor = NSColor.clear
7778

7879
let menuicon = NSImage(named: "controlcenter")
7980
menuicon?.isTemplate = true
8081
statusItem.image = menuicon
8182
statusItem.menu = CCMenu
8283
controlCenterMenuItem = CCMenu.item(withTitle: "ControlCenter")
83-
controlCenterMenuItem.view = ControlCenterView
84+
controlCenterMenuItem.view = controlCenterView
8485
preferencesWindow = PreferencesWindow()
86+
wifiDetailsView = WiFiDetailsView(frame: controlCenterView.frame)
87+
wifiDetailsView.backButton.target = self
88+
wifiDetailsView.backButton.action = #selector(returnFromWiFiClicked(_:))
8589

8690
// Insert code here to initialize your application
8791
weatherAPI = WeatherAPI(delegate: self)
@@ -93,6 +97,18 @@ class StatusMenuController: NSObject, NSMenuDelegate, WeatherAPIDelegate {
9397
preferencesWindow.showWindow(self)
9498
}
9599

100+
@IBAction func wifiDetailsClicked(_ sender: NSButton) {
101+
controlCenterMenuItem.view = wifiDetailsView
102+
controlCenterView.isHidden = true
103+
wifiDetailsView.isHidden = false
104+
}
105+
106+
@objc func returnFromWiFiClicked(_ sender: NSButton) {
107+
controlCenterMenuItem.view = controlCenterView
108+
controlCenterView.isHidden = false
109+
wifiDetailsView.isHidden = true
110+
}
111+
96112
func updateAll() {
97113
updateBrightnessSlider()
98114
updateVolumeSlider()
@@ -298,7 +314,7 @@ class StatusMenuController: NSObject, NSMenuDelegate, WeatherAPIDelegate {
298314
let defaults = UserDefaults.standard
299315
let city = defaults.string(forKey: "city") ?? DEFAULT_CITY
300316
weatherAPI.fetchWeather(city) { weather in
301-
self.ControlCenterView.update(weather)
317+
self.controlCenterView.update(weather)
302318
}
303319
}
304320

0 commit comments

Comments
 (0)