Skip to content

Commit

Permalink
Show a message the case doesn't have the AirPods inside
Browse files Browse the repository at this point in the history
  • Loading branch information
Cosmin Anghel committed Apr 21, 2020
1 parent dd55c68 commit 29e6eb2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ class BatteryView: NSView {

leftBatteryValue.stringValue = "\(viewModel.leftBatteryValue) %"
rightBatteryValue.stringValue = "\(viewModel.rightBatteryValue) %"
caseBatteryValue.stringValue = "\(viewModel.caseBatteryValue) %"

if viewModel.caseBatteryValue == 0 {
caseBatteryValue.stringValue = "Place AirPods\ninside the case"
} else {
caseBatteryValue.stringValue = "\(viewModel.caseBatteryValue) %"
}

leftBatteryStack.isHidden = viewModel.connectionStatus == .connected ? false : true
rightBatteryStack.isHidden = viewModel.connectionStatus == .connected ? false : true
Expand Down
60 changes: 30 additions & 30 deletions AirpodsPro Battery/AirpodsPro Battery/Views/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -13,55 +13,55 @@
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="Airpods_Battery_Monitor" customModuleProvider="target"/>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="AirPods_Battery" customModuleProvider="target"/>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<customObject id="sS3-a3-GGc" userLabel="StatusMenuController" customClass="StatusMenuController" customModule="Airpods_Battery_Monitor" customModuleProvider="target">
<customObject id="sS3-a3-GGc" userLabel="StatusMenuController" customClass="StatusMenuController" customModule="AirPods_Battery" customModuleProvider="target">
<connections>
<outlet property="batteryView" destination="s4L-EI-m6g" id="mOq-b7-lpx"/>
<outlet property="statusMenu" destination="LDO-oe-B5G" id="V6k-UX-cjl"/>
</connections>
</customObject>
<customView id="s4L-EI-m6g" userLabel="BatteryStatusView" customClass="BatteryView" customModule="Airpods_Battery_Monitor" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="440" height="390"/>
<customView id="s4L-EI-m6g" userLabel="BatteryStatusView" customClass="BatteryView" customModule="AirPods_Battery" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="440" height="310"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<stackView distribution="fill" orientation="vertical" alignment="centerX" spacing="20" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="F0n-z4-FQ6">
<rect key="frame" x="20" y="20" width="400" height="350"/>
<rect key="frame" x="20" y="20" width="400" height="270"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="INM-9Z-7xD">
<rect key="frame" x="105" y="322" width="190" height="28"/>
<rect key="frame" x="105" y="242" width="190" height="28"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" allowsUndo="NO" alignment="center" title="Cosmin's AirPods" usesSingleLineMode="YES" id="8XM-nD-blI">
<font key="font" metaFont="system" size="24"/>
<color key="textColor" red="0.19607843137254902" green="0.19607843137254902" blue="0.19607843137254902" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<stackView distribution="fillEqually" orientation="horizontal" alignment="centerY" spacing="50" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="bST-Eq-7SO">
<rect key="frame" x="0.0" y="40" width="400" height="262"/>
<rect key="frame" x="0.0" y="40" width="400" height="182"/>
<subviews>
<stackView distribution="fillEqually" orientation="horizontal" alignment="centerY" spacing="20" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Utz-bn-cTv" userLabel="AirPods Stack View">
<rect key="frame" x="0.0" y="29" width="175" height="205"/>
<rect key="frame" x="0.0" y="1" width="175" height="180"/>
<subviews>
<stackView distribution="fill" orientation="vertical" alignment="trailing" spacing="20" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="q4K-Li-oeD" userLabel="Left Stack View">
<rect key="frame" x="0.0" y="0.0" width="78" height="205"/>
<rect key="frame" x="0.0" y="0.0" width="78" height="180"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="443-U1-VmX" userLabel="Pod Left">
<rect key="frame" x="0.0" y="55" width="78" height="150"/>
<rect key="frame" x="0.0" y="55" width="78" height="125"/>
<constraints>
<constraint firstAttribute="height" constant="150" id="osp-if-jQo"/>
<constraint firstAttribute="height" constant="125" id="osp-if-jQo"/>
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="pod_left" id="RBW-Ue-Rhg"/>
</imageView>
<stackView distribution="fill" orientation="vertical" alignment="centerX" spacing="0.0" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fZu-FI-Pxv">
<rect key="frame" x="52" y="0.0" width="26" height="35"/>
<rect key="frame" x="48" y="0.0" width="30" height="35"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="LBQ-QY-daO">
<rect key="frame" x="1" y="15" width="24" height="20"/>
<rect key="frame" x="3" y="15" width="24" height="20"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="battery/50" id="uKG-xC-8eC"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="fuR-jc-k7r">
<rect key="frame" x="-2" y="0.0" width="30" height="15"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="50%" id="Uh5-ZO-CtW">
<rect key="frame" x="-2" y="0.0" width="34" height="15"/>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="50%" id="Uh5-ZO-CtW">
<font key="font" metaFont="cellTitle"/>
<color key="textColor" red="0.1960784314" green="0.1960784314" blue="0.1960784314" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
Expand All @@ -88,25 +88,25 @@
</customSpacing>
</stackView>
<stackView distribution="fill" orientation="vertical" alignment="leading" spacing="20" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="YMk-BW-TXT" userLabel="Right Stack View">
<rect key="frame" x="98" y="0.0" width="77" height="205"/>
<rect key="frame" x="98" y="0.0" width="77" height="180"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="1yH-u5-nqo" userLabel="Pod Right">
<rect key="frame" x="0.0" y="55" width="77" height="150"/>
<rect key="frame" x="0.0" y="55" width="77" height="125"/>
<constraints>
<constraint firstAttribute="height" constant="150" id="7C0-Kb-5Ob"/>
<constraint firstAttribute="height" constant="125" id="7C0-Kb-5Ob"/>
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="pod_right" id="v2y-yt-wDt"/>
</imageView>
<stackView distribution="fill" orientation="vertical" alignment="centerX" spacing="0.0" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pM2-Yy-ErQ">
<rect key="frame" x="0.0" y="0.0" width="25" height="35"/>
<rect key="frame" x="0.0" y="0.0" width="29" height="35"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="lhQ-SJ-oEx">
<rect key="frame" x="0.0" y="15" width="24" height="20"/>
<rect key="frame" x="2" y="15" width="24" height="20"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="battery/25" id="DrK-7d-31d"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ttK-0o-aWH">
<rect key="frame" x="-2" y="0.0" width="29" height="15"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="25%" id="CcM-62-R6G">
<rect key="frame" x="-2" y="0.0" width="33" height="15"/>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="25%" id="CcM-62-R6G">
<font key="font" metaFont="cellTitle"/>
<color key="textColor" red="0.1960784314" green="0.1960784314" blue="0.1960784314" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
Expand Down Expand Up @@ -143,25 +143,25 @@
</customSpacing>
</stackView>
<stackView distribution="fill" orientation="vertical" alignment="centerX" spacing="20" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="hs7-1O-hGS" userLabel="Case Stack View">
<rect key="frame" x="225" y="29" width="175" height="205"/>
<rect key="frame" x="225" y="1" width="175" height="180"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="D2D-a0-SY9">
<rect key="frame" x="0.0" y="55" width="175" height="150"/>
<rect key="frame" x="0.0" y="55" width="175" height="125"/>
<constraints>
<constraint firstAttribute="height" constant="150" id="kVR-fX-W0A"/>
<constraint firstAttribute="height" constant="125" id="kVR-fX-W0A"/>
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="case" id="Us9-7V-t23"/>
</imageView>
<stackView distribution="fill" orientation="vertical" alignment="centerX" spacing="0.0" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ecf-ej-8JI">
<rect key="frame" x="72" y="0.0" width="31" height="35"/>
<rect key="frame" x="70" y="0.0" width="35" height="35"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="8lf-Bl-3H4">
<rect key="frame" x="4" y="15" width="24" height="20"/>
<rect key="frame" x="6" y="15" width="24" height="20"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="battery/100" id="PbU-7Y-tUc"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="RUM-Iq-Bao">
<rect key="frame" x="-2" y="0.0" width="35" height="15"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="100%" id="aft-I3-1bl">
<rect key="frame" x="-2" y="0.0" width="39" height="15"/>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="100%" id="aft-I3-1bl">
<font key="font" metaFont="cellTitle"/>
<color key="textColor" red="0.1960784314" green="0.1960784314" blue="0.1960784314" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
Expand Down Expand Up @@ -273,7 +273,7 @@
<outlet property="rightBatteryValue" destination="ttK-0o-aWH" id="hrn-jY-gvS"/>
<outlet property="titleLabel" destination="INM-9Z-7xD" id="iaD-cB-ak4"/>
</connections>
<point key="canvasLocation" x="570" y="131"/>
<point key="canvasLocation" x="570" y="92"/>
</customView>
<menu title="Menu" id="LDO-oe-B5G">
<items>
Expand Down

0 comments on commit 29e6eb2

Please sign in to comment.