Unverified Commit 71d26ebc authored by Zach Knox's avatar Zach Knox
Browse files

fixed up some hud stuff

parent 65d6cf5b
......@@ -573,9 +573,9 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<visualEffectView opaque="NO" contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Lgh-hp-DYn">
<rect key="frame" x="67" y="213" width="240" height="240"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" ambiguous="YES" insetsLayoutMarginsFromSafeArea="NO" id="4AQ-Us-J9W">
<visualEffectView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Lgh-hp-DYn">
<rect key="frame" x="67.5" y="173.5" width="240" height="240"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="4AQ-Us-J9W">
<rect key="frame" x="0.0" y="0.0" width="240" height="240"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
......@@ -586,16 +586,16 @@
<rect key="frame" x="0.0" y="0.0" width="240" height="240"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="4E3-3w-Ok6">
<rect key="frame" x="60" y="39" width="120" height="120"/>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="4E3-3w-Ok6">
<rect key="frame" x="54" y="39" width="120" height="120"/>
<constraints>
<constraint firstAttribute="width" secondItem="4E3-3w-Ok6" secondAttribute="height" multiplier="1:1" id="0VL-p9-vbu"/>
<constraint firstAttribute="height" constant="120" id="Pvz-Zl-HEY"/>
<constraint firstAttribute="width" constant="120" id="q8e-Vl-Hvr"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Added to Favorites" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7K0-OX-ykH">
<rect key="frame" x="48" y="180" width="144" height="24"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Added to Favorites" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7K0-OX-ykH">
<rect key="frame" x="28" y="181" width="184" height="51"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="20"/>
<nil key="textColor"/>
......@@ -604,10 +604,11 @@
</subviews>
<constraints>
<constraint firstItem="4E3-3w-Ok6" firstAttribute="top" secondItem="Dus-NM-gD9" secondAttribute="top" constant="39" id="4RV-pU-Zqd"/>
<constraint firstAttribute="bottom" secondItem="7K0-OX-ykH" secondAttribute="bottom" constant="39" id="8lB-wn-qAk"/>
<constraint firstItem="4E3-3w-Ok6" firstAttribute="centerX" secondItem="Dus-NM-gD9" secondAttribute="centerX" id="Ai8-Wj-cd8"/>
<constraint firstItem="7K0-OX-ykH" firstAttribute="top" secondItem="4E3-3w-Ok6" secondAttribute="bottom" constant="21" id="BzJ-ey-c6S"/>
<constraint firstItem="7K0-OX-ykH" firstAttribute="leading" secondItem="Dus-NM-gD9" secondAttribute="leading" constant="28" id="D4g-Gx-XEX"/>
<constraint firstItem="7K0-OX-ykH" firstAttribute="centerX" secondItem="Dus-NM-gD9" secondAttribute="centerX" id="MFb-bJ-x3a"/>
<constraint firstAttribute="trailing" secondItem="7K0-OX-ykH" secondAttribute="trailing" constant="28" id="PuM-Xj-zAJ"/>
</constraints>
</view>
<vibrancyEffect>
......@@ -618,6 +619,7 @@
</view>
<constraints>
<constraint firstAttribute="width" secondItem="Lgh-hp-DYn" secondAttribute="height" multiplier="1:1" id="SNx-c5-tvi"/>
<constraint firstAttribute="width" constant="240" id="dxp-B5-4SX"/>
</constraints>
<blurEffect style="light"/>
</visualEffectView>
......
......@@ -16,7 +16,8 @@ class DetailViewButtonsViewController: UIViewController, INUIAddVoiceShortcutVie
@IBOutlet var facilityDetailView: UIView!
private var infoBubbleView: HUDViewController!
private var infoHUD: HUDViewController!
private var isInfoHUDDisplayed = false
var detailViewController: WOPFacilityDetailViewController?
var facility: WOPFacility!
......@@ -40,20 +41,30 @@ class DetailViewButtonsViewController: UIViewController, INUIAddVoiceShortcutVie
if(WOPUtilities.isFavoriteFacility(facility)) { // if the facility is a favorite
_ = WOPUtilities.removeFavoriteFacility(facility) // remove it from favorites
loadChild("Removed from Favorites", image: UIImage(named: "empty_heart_big"))
DispatchQueue.main.asyncAfter(deadline: .now() + 1.1) { [weak self] in
self?.unloadChild()
if !isInfoHUDDisplayed {
isInfoHUDDisplayed = true
loadChild("Removed from Favorites", image: UIImage(named: "empty_heart_big"))
DispatchQueue.main.asyncAfter(deadline: .now() + 1.1) { [weak self] in
self?.unloadChild()
self?.isInfoHUDDisplayed = false
}
}
}
else { // else add it to favorites
_ = WOPUtilities.addFavoriteFacility(facility)
loadChild("Added to Favorites", image: UIImage(named: "filled_heart_big"))
DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in
self?.unloadChild()
}
if !isInfoHUDDisplayed {
isInfoHUDDisplayed = true
loadChild("Added to Favorites", image: UIImage(named: "filled_heart_big"))
DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in
self?.unloadChild()
self?.isInfoHUDDisplayed = false
}
}
}
setFavoriteButtonText()
......@@ -61,27 +72,27 @@ class DetailViewButtonsViewController: UIViewController, INUIAddVoiceShortcutVie
func loadChild(_ title: String, image: UIImage?) {
DispatchQueue.main.async {
self.addSubview(self.infoBubbleView.view, toView: (self.detailViewController?.view)!)
self.infoBubbleView.view.alpha = 0
self.detailViewController!.addChild(self.infoBubbleView)
self.infoBubbleView.didMove(toParent: self.detailViewController)
self.addSubview(self.infoHUD.view, toView: (self.detailViewController?.view)!)
self.infoHUD.view.alpha = 0
self.detailViewController!.addChild(self.infoHUD)
self.infoHUD.didMove(toParent: self.detailViewController)
UIView.animate(withDuration: 0.35, animations: {
self.infoBubbleView.view.alpha = 1
self.infoHUD.view.alpha = 1
})
self.infoBubbleView.label.text = title
self.infoBubbleView.image.image = image
self.infoHUD.label.text = title
self.infoHUD.image.image = image
}
}
func unloadChild() {
DispatchQueue.main.async {
UIView.animate(withDuration: 0.35, animations: {
self.infoBubbleView.view.alpha = 0
self.infoHUD.view.alpha = 0
}, completion: { (completed) in
self.infoBubbleView.willMove(toParent: nil)
self.infoBubbleView.removeFromParent()
self.infoBubbleView.view.removeFromSuperview()
self.infoHUD.willMove(toParent: nil)
self.infoHUD.removeFromParent()
self.infoHUD.view.removeFromSuperview()
})
}
}
......@@ -172,7 +183,7 @@ class DetailViewButtonsViewController: UIViewController, INUIAddVoiceShortcutVie
let interaction = INInteraction(intent: facility.createIntent(), response: WOPViewFacilityIntentUtils.getIntentResponse(facility, userActivity: activity))
interaction.donate(completion: nil)
infoBubbleView = storyboard?.instantiateViewController(withIdentifier: "HUD") as! HUDViewController
infoHUD = storyboard?.instantiateViewController(withIdentifier: "HUD") as! HUDViewController
// Do any additional setup after loading the view.
// yah yah, yah yAH
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment