Skip to content

Commit

Permalink
* 修复手势冲突
Browse files Browse the repository at this point in the history
  • Loading branch information
Caffe-del committed Sep 23, 2020
1 parent b6ab5bf commit 4362044
Show file tree
Hide file tree
Showing 16 changed files with 134 additions and 55 deletions.
13 changes: 1 addition & 12 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ playground.xcworkspace
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
.build/

# CocoaPods
Expand All @@ -47,9 +46,6 @@ playground.xcworkspace
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
#
Expand All @@ -67,12 +63,5 @@ Carthage/Build

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/screenshots
fastlane/test_output

# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/
45 changes: 37 additions & 8 deletions BottomBar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
9548FF0F251B9ED500EF9017 /* BaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9548FF0E251B9ED500EF9017 /* BaseViewController.swift */; };
9548FF15251BA88200EF9017 /* Runtime.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9548FF14251BA88200EF9017 /* Runtime.swift */; };
954AE2DA24F5576C001D9D7C /* MusicDetailVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 954AE2D924F5576C001D9D7C /* MusicDetailVC.swift */; };
954AE2DC24F563F7001D9D7C /* UIConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 954AE2DB24F563F7001D9D7C /* UIConstants.swift */; };
9559289B2501396D00F6775F /* RootTabBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9559289A2501396D00F6775F /* RootTabBarItem.swift */; };
Expand All @@ -15,7 +17,6 @@
955A38182517A1EC00FEA429 /* PushAnimatedTransitionAsFromBottomToTop.swift in Sources */ = {isa = PBXBuildFile; fileRef = 955A38172517A1EC00FEA429 /* PushAnimatedTransitionAsFromBottomToTop.swift */; };
955A381A2517A20900FEA429 /* PopAnimatedTransitioningAsFromTopToBottom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 955A38192517A20900FEA429 /* PopAnimatedTransitioningAsFromTopToBottom.swift */; };
956738D624F24B9B00A37838 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 956738D524F24B9B00A37838 /* AppDelegate.swift */; };
956738DA24F24B9B00A37838 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 956738D924F24B9B00A37838 /* ViewController.swift */; };
956738DD24F24B9B00A37838 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 956738DB24F24B9B00A37838 /* Main.storyboard */; };
956738DF24F24B9E00A37838 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 956738DE24F24B9E00A37838 /* Assets.xcassets */; };
956738E224F24B9E00A37838 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 956738E024F24B9E00A37838 /* LaunchScreen.storyboard */; };
Expand All @@ -28,6 +29,8 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
9548FF0E251B9ED500EF9017 /* BaseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseViewController.swift; sourceTree = "<group>"; };
9548FF14251BA88200EF9017 /* Runtime.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Runtime.swift; sourceTree = "<group>"; };
954AE2D924F5576C001D9D7C /* MusicDetailVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicDetailVC.swift; sourceTree = "<group>"; };
954AE2DB24F563F7001D9D7C /* UIConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIConstants.swift; sourceTree = "<group>"; };
9559289A2501396D00F6775F /* RootTabBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootTabBarItem.swift; sourceTree = "<group>"; };
Expand All @@ -37,7 +40,6 @@
955A38192517A20900FEA429 /* PopAnimatedTransitioningAsFromTopToBottom.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopAnimatedTransitioningAsFromTopToBottom.swift; sourceTree = "<group>"; };
956738D224F24B9B00A37838 /* BottomBar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BottomBar.app; sourceTree = BUILT_PRODUCTS_DIR; };
956738D524F24B9B00A37838 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
956738D924F24B9B00A37838 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
956738DC24F24B9B00A37838 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
956738DE24F24B9E00A37838 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
956738E124F24B9E00A37838 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
Expand Down Expand Up @@ -82,7 +84,8 @@
children = (
956738F324F2B45300A37838 /* Branch */,
956738D524F24B9B00A37838 /* AppDelegate.swift */,
956738D924F24B9B00A37838 /* ViewController.swift */,
9548FF0E251B9ED500EF9017 /* BaseViewController.swift */,
9548FF14251BA88200EF9017 /* Runtime.swift */,
955A38152517950B00FEA429 /* BaseNavigationController.swift */,
955A38172517A1EC00FEA429 /* PushAnimatedTransitionAsFromBottomToTop.swift */,
955A38192517A20900FEA429 /* PopAnimatedTransitioningAsFromTopToBottom.swift */,
Expand Down Expand Up @@ -121,6 +124,7 @@
956738CE24F24B9B00A37838 /* Sources */,
956738CF24F24B9B00A37838 /* Frameworks */,
956738D024F24B9B00A37838 /* Resources */,
9548FF0B251B9B1600EF9017 /* ShellScript */,
);
buildRules = (
);
Expand Down Expand Up @@ -177,6 +181,26 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
9548FF0B251B9B1600EF9017 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "REVEAL_APP_PATH=$(mdfind kMDItemCFBundleIdentifier=\"com.ittybittyapps.Reveal2\" | head -n 1)\nBUILD_SCRIPT_PATH=\"${REVEAL_APP_PATH}/Contents/SharedSupport/Scripts/reveal_server_build_phase.sh\"\nif [ \"${REVEAL_APP_PATH}\" -a -e \"${BUILD_SCRIPT_PATH}\" ]; then\n \"${BUILD_SCRIPT_PATH}\"\nelse\n echo \"Reveal Server not loaded: Cannot find a compatible Reveal app.\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
956738CE24F24B9B00A37838 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand All @@ -187,13 +211,14 @@
956738F024F25D6100A37838 /* BBSViewController.swift in Sources */,
958E7D962507D28A00D65F94 /* VideoDetailVC.swift in Sources */,
955A381A2517A20900FEA429 /* PopAnimatedTransitioningAsFromTopToBottom.swift in Sources */,
9548FF0F251B9ED500EF9017 /* BaseViewController.swift in Sources */,
956738EC24F25D2C00A37838 /* MusicViewController.swift in Sources */,
956738F224F25D6900A37838 /* AccountViewController.swift in Sources */,
9559289D2501398400F6775F /* RootTabBar.swift in Sources */,
954AE2DA24F5576C001D9D7C /* MusicDetailVC.swift in Sources */,
956738DA24F24B9B00A37838 /* ViewController.swift in Sources */,
956738EA24F25B8C00A37838 /* RootTabBarController.swift in Sources */,
954AE2DC24F563F7001D9D7C /* UIConstants.swift in Sources */,
9548FF15251BA88200EF9017 /* Runtime.swift in Sources */,
9559289B2501396D00F6775F /* RootTabBarItem.swift in Sources */,
956738EE24F25D3600A37838 /* VideoViewController.swift in Sources */,
956738D624F24B9B00A37838 /* AppDelegate.swift in Sources */,
Expand Down Expand Up @@ -340,8 +365,9 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = QNB8842V82;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = KJ7B9R8CS3;
INFOPLIST_FILE = BottomBar/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -350,6 +376,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = Darren.BottomBar;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "Dev-Wildcard";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand All @@ -359,8 +386,9 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = QNB8842V82;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = KJ7B9R8CS3;
INFOPLIST_FILE = BottomBar/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -369,6 +397,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = Darren.BottomBar;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "Dev-Wildcard";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand Down
2 changes: 1 addition & 1 deletion BottomBar/AccountViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import UIKit

class AccountViewController: UIViewController {
class AccountViewController: BaseViewController {

override func viewDidLoad() {
super.viewDidLoad()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions BottomBar/Assets.xcassets/Nav_dismiss.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
2 changes: 1 addition & 1 deletion BottomBar/BBSViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import UIKit

class BBSViewController: UIViewController {
class BBSViewController: BaseViewController {

override func viewDidLoad() {
super.viewDidLoad()
Expand Down
6 changes: 4 additions & 2 deletions BottomBar/BaseNavigationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class BaseNavigationController: UINavigationController, UINavigationControllerDe

override func viewDidLoad() {
super.viewDidLoad()
self.navigationBar.isTranslucent = false
self.delegate = self
}

Expand Down Expand Up @@ -63,7 +64,7 @@ class BaseNavigationController: UINavigationController, UINavigationControllerDe
screenEdgesPanGesture.isEnabled = true
viewController.view.addGestureRecognizer(screenEdgesPanGesture)


panGesture.require(toFail: screenEdgesPanGesture)
}

}
Expand All @@ -78,11 +79,12 @@ class BaseNavigationController: UINavigationController, UINavigationControllerDe
if screenEdgesPanGesture == gesture {
velocity = screenEdgesPanGesture.velocity(in: screenEdgesPanGesture.view).x
process = screenEdgesPanGesture.translation(in: screenEdgesPanGesture.view).x / screenWidth
process = pow(min(1.0, max(0.0, process)), 2) // 增加手势梯度
isScreenEdge = true
} else {
velocity = panGesture.velocity(in: panGesture.view).y
process = panGesture.translation(in: panGesture.view).y / CGFloat(screenHeight - 190)

process = pow(min(1.0, max(0.0, process)), 2) // 增加手势梯度
}

if gesture.state == .began {
Expand Down
19 changes: 19 additions & 0 deletions BottomBar/BaseViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// BaseViewController.swift
// BottomBar
//
// Created by 全达晖 on 2020/9/23.
// Copyright © 2020 全达晖. All rights reserved.
//

import UIKit

class BaseViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
self.extendedLayoutIncludesOpaqueBars = true;
self.automaticallyAdjustsScrollViewInsets = true;
}

}
25 changes: 16 additions & 9 deletions BottomBar/MusicDetailVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,32 @@

import UIKit

class MusicDetailVC: UIViewController {
class MusicDetailVC: BaseViewController {

override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = .systemGray
self.view.backgroundColor = .systemRed
self.navigationController?.navigationBar.isHidden = true

let switchBtn = UISwitch.init(frame: CGRect.init(origin: self.view.center, size: CGSize.init(width: 60, height: 50)))
switchBtn.isOn = true
self.view.addSubview(switchBtn)
let backBtn = UIButton.init(frame: CGRect.init(x: 10, y: statusBarHeight, width: 60, height: 60))
backBtn.addTarget(self, action: #selector(handleNaviBackClick), for: .touchUpInside)
backBtn.setImage(UIImage.init(named: "Nav_dismiss"), for: .normal)
self.view.addSubview(backBtn)
// Do any additional setup after loading the view.
}

override func viewWillAppear(_ animated: Bool) {
if let tabBarController = self.tabBarController as? RootTabBarController {
tabBarController.updateBottomStyle(.miniPlayViewOnly)
tabBarController.updateBottomStyle(.none)
}
}

// override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
// self.navigationController?.popViewController(animated: true)
// }
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
self.navigationController?.navigationBar.isHidden = false
}

@objc func handleNaviBackClick() {
self.navigationController?.popViewController(animated: true)
}
}
2 changes: 1 addition & 1 deletion BottomBar/MusicViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import UIKit

class MusicViewController: UIViewController {
class MusicViewController: BaseViewController {

override func viewDidLoad() {
super.viewDidLoad()
Expand Down
27 changes: 27 additions & 0 deletions BottomBar/Runtime.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// Runtime.swift
// BottomBar
//
// Created by 全达晖 on 2020/9/24.
// Copyright © 2020 全达晖. All rights reserved.
//

import Foundation
import UIKit

extension UIViewController {
// 嵌套结构体
private struct AssociatedKeys {
static var isDelayShowBottomBarKey = "isDelayShowBottomBarKey"
}

// 当前vc是否需要延迟做动画
var isDelayShowBottomBar: Bool {
get {
return objc_getAssociatedObject(self, &AssociatedKeys.isDelayShowBottomBarKey) as! Bool
}
set {
objc_setAssociatedObject(self, &AssociatedKeys.isDelayShowBottomBarKey, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
}
}
4 changes: 3 additions & 1 deletion BottomBar/UIConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ var tabBarHeight: CGFloat {
let screenFrame: CGRect = UIScreen.main.bounds
let screenWidth = screenFrame.size.width
let screenHeight = screenFrame.size.height
let safeAreaTopHeight: CGFloat = (screenHeight >= 812.0 && UIDevice.current.model == "iPhone" ? 88 : 64)
let statusBarHeight: CGFloat = (screenHeight >= 812.0 && UIDevice.current.model == "iPhone" ? 44 : 20)
let navigationBarHeight: CGFloat = 44
let safeAreaTopHeight: CGFloat = navigationBarHeight + statusBarHeight
let safeAreaBottomHeight: CGFloat = (screenHeight >= 812.0 && UIDevice.current.model == "iPhone" ? 30 : 0)

let sharedGloble = Globle()
Expand Down
2 changes: 1 addition & 1 deletion BottomBar/VideoDetailVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import UIKit

class VideoDetailVC: UIViewController {
class VideoDetailVC: BaseViewController {

override func viewDidLoad() {
super.viewDidLoad()
Expand Down
2 changes: 1 addition & 1 deletion BottomBar/VideoViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import UIKit

class VideoViewController: UIViewController {
class VideoViewController: BaseViewController {

override func viewDidLoad() {
super.viewDidLoad()
Expand Down
18 changes: 0 additions & 18 deletions BottomBar/ViewController.swift

This file was deleted.

0 comments on commit 4362044

Please sign in to comment.