Skip to content

Commit

Permalink
Merge pull request #26 from noppefoxwolf/hotfix/preferredScreenEdgesD…
Browse files Browse the repository at this point in the history
…eferringSystemGestures

Hotfix/preferred screen edges deferring system gestures
  • Loading branch information
noppefoxwolf authored Dec 30, 2021
2 parents 3fd2f47 + 04d857b commit 04f413c
Show file tree
Hide file tree
Showing 13 changed files with 232 additions and 5 deletions.
44 changes: 39 additions & 5 deletions Example.swiftpm/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ let package = Package(
],
products: [
.iOSApplication(
name: "Example",
targets: ["AppModule"],
bundleIdentifier: "dev.noppe.DebugMenu.Example",
name: "SwiftUIExample",
targets: ["SwiftUIExampleModule"],
bundleIdentifier: "dev.noppe.DebugMenu.SwiftUIExample",
teamIdentifier: "FBQ6Z8AF3U",
displayVersion: "1.0",
bundleVersion: "1",
Expand All @@ -32,14 +32,48 @@ let package = Package(
.landscapeLeft,
.portraitUpsideDown(.when(deviceFamilies: [.pad]))
]
)
),
.iOSApplication(
name: "UIKitExample",
targets: ["UIKItExampleModule"],
bundleIdentifier: "dev.noppe.DebugMenu.UIKitExample",
teamIdentifier: "FBQ6Z8AF3U",
displayVersion: "1.0",
bundleVersion: "1",
iconAssetName: "AppIcon",
accentColorAssetName: "AccentColor",
supportedDeviceFamilies: [
.pad,
.phone
],
supportedInterfaceOrientations: [
.portrait,
.landscapeRight,
.landscapeLeft,
.portraitUpsideDown(.when(deviceFamilies: [.pad]))
]
),
],
dependencies: [
.package(name: "DebugMenu", path: "../")
],
targets: [
.executableTarget(
name: "AppModule",
name: "SwiftUIExampleModule",
dependencies: [
.productItem(name: "DebugMenu", package: "DebugMenu", condition: nil),
"Shared"
]
),
.executableTarget(
name: "UIKItExampleModule",
dependencies: [
.productItem(name: "DebugMenu", package: "DebugMenu", condition: nil),
"Shared"
]
),
.target(
name: "Shared",
dependencies: [
.productItem(name: "DebugMenu", package: "DebugMenu", condition: nil)
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import SwiftUI
import DebugMenu
import Shared

@main
struct App: SwiftUI.App {
Expand Down
73 changes: 73 additions & 0 deletions Example.swiftpm/Source/UIKItExampleModule/App.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import UIKit
import DebugMenu
import Shared

@main
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
return true
}

func application(
_ application: UIApplication,
configurationForConnecting connectingSceneSession: UISceneSession,
options: UIScene.ConnectionOptions
) -> UISceneConfiguration {
let configuration = UISceneConfiguration(name: nil, sessionRole: connectingSceneSession.role)
configuration.sceneClass = UIWindowScene.self
configuration.delegateClass = SceneDelegate.self
return configuration
}
}

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?

func scene(
_ scene: UIScene, willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions
) {
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: windowScene)
window?.rootViewController = RootViewController()
window?.makeKeyAndVisible()

DebugMenu.install(
windowScene: windowScene,
items: [
ViewControllerDebugItem<ColorViewController>(builder: { $0.init(color: .blue) }),
ClearCacheDebugItem(),
UserDefaultsResetDebugItem(),
CustomDebugItem(),
SliderDebugItem(title: "Attack Rate", current: { 0.1 }, range: 0.0...100.0, onChange: { value in print(value) }),
KeyValueDebugItem(title: "UserDefaults", fetcher: { completions in
let envelops = UserDefaults.standard.dictionaryRepresentation().map({ Envelope(key: $0.key, value: "\($0.value)") })
completions(envelops)
}),
GroupDebugItem(title: "Info", items: [
AppInfoDebugItem(),
DeviceInfoDebugItem(),
]),
], dashboardItems: [
CPUUsageDashboardItem(),
CPUGraphDashboardItem(),
GPUMemoryUsageDashboardItem(),
MemoryUsageDashboardItem(),
NetworkUsageDashboardItem(),
FPSDashboardItem(),
ThermalStateDashboardItem(),
CustomDashboardItem(),
IntervalDashboardItem(title: "Reduce time", name: "dev.noppe.calc")
], options: [.showsWidgetOnLaunch]
)
}
}

class RootViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .systemBackground
}

override var preferredScreenEdgesDeferringSystemGestures: UIRectEdge { .all }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
4 changes: 4 additions & 0 deletions Sources/DebugMenu/View/InAppDebuggerWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ public class InAppDebuggerWindow: UIWindow {
dashboardItems: dashboardItems,
options: options
)
// visible時にディスプレイサイズと同じサイズだとスクリーンエッジの設定を決める対象に選ばれるので避ける
window.frame.size.width += 1
window.makeKeyAndVisible()
window.frame.size.width -= 1

keyWindow?.makeKeyAndVisible()
windows.append(window)
}
Expand Down

0 comments on commit 04f413c

Please sign in to comment.