Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pickle-debug committed Oct 12, 2021
1 parent 332baa5 commit ebea2ed
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 45 deletions.
6 changes: 6 additions & 0 deletions Run/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>开启已用于跑步中定位</string>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
Expand All @@ -21,6 +23,10 @@
</array>
</dict>
</dict>
<key>UIBackgroundModes</key>
<array>
<string>location</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion Run/Model/Model.xcdatamodeld/Model.xcdatamodel/contents
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="19206" systemVersion="20G165" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="18154" systemVersion="20D75" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="Location" representedClassName="Location" syncable="YES" codeGenerationType="class">
<attribute name="latitude" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="YES"/>
<attribute name="longitude" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="YES"/>
Expand Down
38 changes: 18 additions & 20 deletions Run/View/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
<objects>
<viewController id="BYZ-38-t0r" customClass="HomePageVC" customModule="Run" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="842"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="tAn-jA-vJn">
<rect key="frame" x="157" y="707" width="100" height="100"/>
<rect key="frame" x="157" y="653" width="100" height="100"/>
<color key="backgroundColor" systemColor="systemOrangeColor"/>
<constraints>
<constraint firstAttribute="width" constant="100" id="5ms-ju-XRh"/>
Expand All @@ -33,7 +33,7 @@
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<segue destination="YHx-Ss-Obk" kind="modal" id="gvR-tq-LIm"/>
<segue destination="YHx-Ss-Obk" kind="modal" identifier="controller" id="gvR-tq-LIm"/>
</connections>
</button>
</subviews>
Expand Down Expand Up @@ -125,7 +125,7 @@
</constraints>
<fontDescription key="fontDescription" type="system" weight="black" pointSize="40"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="暂停"/>
<state key="normal" title="跑步"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
<integer key="value" value="50"/>
Expand Down Expand Up @@ -173,7 +173,7 @@
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="00/00" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="u4o-IJ-8fw">
<rect key="frame" x="0.0" y="0.0" width="110.5" height="48"/>
<fontDescription key="fontDescription" type="system" pointSize="40"/>
<nil key="textColor"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="日期" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ItY-8E-NfF">
Expand All @@ -196,7 +196,7 @@
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="_'__&quot;" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6nv-HM-4gL">
<rect key="frame" x="0.0" y="0.0" width="91" height="50"/>
<fontDescription key="fontDescription" type="system" pointSize="40"/>
<nil key="textColor"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="配速" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="S5M-be-YmS">
Expand All @@ -213,7 +213,7 @@
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="00:00" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AKr-vD-Stm">
<rect key="frame" x="0.0" y="0.0" width="107.5" height="48"/>
<fontDescription key="fontDescription" type="system" pointSize="40"/>
<nil key="textColor"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="时间" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sZV-Hc-Y7X">
Expand All @@ -235,7 +235,7 @@
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0.00" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZOm-w9-omt">
<rect key="frame" x="0.0" y="0.0" width="82.5" height="48"/>
<fontDescription key="fontDescription" type="system" pointSize="40"/>
<nil key="textColor"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="距离" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iP8-JW-H03">
Expand All @@ -252,7 +252,7 @@
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zlK-l3-arS">
<rect key="frame" x="8" y="0.0" width="25" height="48"/>
<fontDescription key="fontDescription" type="system" pointSize="40"/>
<nil key="textColor"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="步频" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XBY-uu-A2y">
Expand All @@ -269,28 +269,29 @@
</stackView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="zF3-Rr-4ER">
<rect key="frame" x="157" y="675" width="100" height="100"/>
<color key="backgroundColor" systemColor="linkColor"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" constant="100" id="fuR-5V-1jA"/>
<constraint firstAttribute="height" constant="100" id="m0I-zB-lpG"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="black" pointSize="40"/>
<color key="tintColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<state key="normal" title="确定"/>
<state key="normal" title="确定">
<color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
<integer key="value" value="50"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<action selector="closeAction:" destination="PSq-vi-vtJ" eventType="touchUpInside" id="4l2-mr-V4C"/>
<action selector="closeButton:" destination="PSq-vi-vtJ" eventType="touchUpInside" id="27Q-of-VUt"/>
<action selector="flipButton" destination="YHx-Ss-Obk" eventType="touchUpInside" id="UWD-H0-pmG"/>
<action selector="closeAction:" destination="PSq-vi-vtJ" eventType="touchUpInside" id="htQ-Gc-Suq"/>
<segue destination="BYZ-38-t0r" kind="modal" id="I9F-ft-mGX"/>
</connections>
</button>
</subviews>
<viewLayoutGuide key="safeArea" id="4hK-xy-n8n"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="4hK-xy-n8n" firstAttribute="bottom" secondItem="zF3-Rr-4ER" secondAttribute="bottom" constant="33" id="0ec-FE-Lel"/>
<constraint firstItem="WTS-rQ-Ug6" firstAttribute="top" secondItem="0c5-OX-ELO" secondAttribute="bottom" constant="36" id="22e-7E-F4c"/>
Expand All @@ -302,7 +303,7 @@
</view>
<navigationItem key="navigationItem" id="nRc-NF-omX"/>
<connections>
<outlet property="closeButton" destination="zF3-Rr-4ER" id="kuk-zP-UeL"/>
<outlet property="closeButton" destination="zF3-Rr-4ER" id="bBI-FW-rTv"/>
<outlet property="dateLabel" destination="u4o-IJ-8fw" id="TDn-Wt-MdP"/>
<outlet property="distanceLabel" destination="ZOm-w9-omt" id="mLd-4p-9i5"/>
<outlet property="speedLabel" destination="6nv-HM-4gL" id="J2S-Cs-8dm"/>
Expand All @@ -311,16 +312,13 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="xvh-vJ-HPR" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1624.6376811594205" y="79.6875"/>
<point key="canvasLocation" x="1816" y="80"/>
</scene>
</scenes>
<resources>
<namedColor name="gray">
<color red="0.57599997520446777" green="0.58399999141693115" blue="0.59200000762939453" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<systemColor name="linkColor">
<color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
Expand Down
17 changes: 2 additions & 15 deletions Run/ViewController/ViewController/RunPageVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,11 @@ class RunPageVC: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
// controlButton.transform = CGAffineTransform(rotationAngle: CGFloat.pi / 4)

// Do any additional setup after loading the view.
startRun()
}

// @IBAction func closeAction(_ sender: AnyObject) {
// self.dismiss(animated: true, completion: nil)
// interactiveTransition?.finish()
// }
//
@IBAction func flipButton() {
if(controlButton.titleLabel?.text == "开始跑步") {
startRun()
controlButton.setTitle("暂停", for: .normal)
} else {
stopRun()
controlButton.setTitle("开始跑步", for: .normal)
controlButton.setTitle("跑步", for: .normal)
let alertController = UIAlertController(title: "跑完了?",
message: "你想结束跑步吗?",
preferredStyle: .actionSheet)
Expand All @@ -61,7 +49,6 @@ class RunPageVC: UIViewController {
})

present(alertController, animated: true)
}
}

private func startRun(){
Expand Down
34 changes: 25 additions & 9 deletions Run/ViewController/ViewController/StopRunVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@
import UIKit
import BubbleTransition

class StopRunVC: UIViewController {
class StopRunVC: UIViewController, UIViewControllerTransitioningDelegate{

@IBOutlet weak var distanceLabel: UILabel!
@IBOutlet weak var dateLabel: UILabel!
@IBOutlet weak var timeLabel:UILabel!
@IBOutlet weak var speedLabel: UILabel!

@IBOutlet weak var closeButton: UIButton!
weak var interactiveTransition: BubbleInteractiveTransition?


let transition = BubbleTransition()

var run: Run!

Expand All @@ -41,9 +39,27 @@ class StopRunVC: UIViewController {
speedLabel.text = "\(formattedspeed)"
}

@IBAction func closeAction(_ sender: AnyObject) {
self.dismiss(animated: true, completion: nil)
interactiveTransition?.finish()
public override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let controller = segue.destination
controller.transitioningDelegate = self
controller.modalPresentationCapturesStatusBarAppearance = true
controller.modalPresentationStyle = .custom
}

// MARK: UIViewControllerTransitioningDelegate

public func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
transition.transitionMode = .present
transition.startingPoint = closeButton.center
transition.bubbleColor = closeButton.backgroundColor!
return transition
}

public func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
transition.transitionMode = .dismiss
transition.startingPoint = closeButton.center
transition.bubbleColor = closeButton.backgroundColor!
return transition
}

}

}

0 comments on commit ebea2ed

Please sign in to comment.