From 64b5c54e6e73ca74961d08d973a6c7482314be6c Mon Sep 17 00:00:00 2001 From: crane-hiromu Date: Mon, 26 Dec 2022 01:37:55 +0900 Subject: [PATCH] update debugview --- .../View/Debug/DroidJoystickDebugView.swift | 69 ------------------- .../View/Debug/DroidKitDebugView.swift | 14 ++++ .../View/Joystick/DroidJoystickView.swift | 3 +- 3 files changed, 16 insertions(+), 70 deletions(-) delete mode 100644 Sources/DroidKit/View/Debug/DroidJoystickDebugView.swift diff --git a/Sources/DroidKit/View/Debug/DroidJoystickDebugView.swift b/Sources/DroidKit/View/Debug/DroidJoystickDebugView.swift deleted file mode 100644 index 084b9bd..0000000 --- a/Sources/DroidKit/View/Debug/DroidJoystickDebugView.swift +++ /dev/null @@ -1,69 +0,0 @@ -// -// DroidJoystickDebugView.swift -// -// -// Created by h.tsuruta on 2022/12/26. -// - -import Combine -import SwiftUI -import SwiftUIJoystick - -// MARK: - View -@available(iOS 15.0, *) -public struct DroidJoystickDebugView: View { - @StateObject private var viewModel = DroidJoystickViewModel() - - public var body: some View { - VStack { - Text("XY Point = (x: \(viewModel.monitor.xyPoint.x), y: \(viewModel.monitor.xyPoint.y))") - .fixedSize() - - Text("Polor Point = (\(viewModel.monitor.polarPoint.degrees), \(viewModel.monitor.polarPoint.distance)))") - .fixedSize() - - JoystickBuilder( - monitor: viewModel.monitor, - width: viewModel.output.radius, - shape: .circle, - background: { backgroundCircle }, - foreground: { foregroundCircle }, - locksInPlace: false) - } - .padding() - } -} - -// MARK: - Private -@available(iOS 15.0, *) -private extension DroidJoystickDebugView { - - var backgroundCircle: some View { - let overlay = Circle() - .stroke(.black) - .shadow(color: .white, radius: 5) - - return ZStack { - Circle() - .fill(.gray) - .overlay(overlay) - } - } - - var foregroundCircle: some View { - let gradient = RadialGradient( - colors: [.white, .gray], - center: .center, - startRadius: 1, - endRadius: 30 - ) - let overlay = Circle() - .stroke(.gray, lineWidth: 4) - .blur(radius: 4) - .shadow(color: .white, radius: 5) - - return Circle() - .fill(gradient) - .overlay(overlay) - } -} diff --git a/Sources/DroidKit/View/Debug/DroidKitDebugView.swift b/Sources/DroidKit/View/Debug/DroidKitDebugView.swift index 89280ff..40456ba 100644 --- a/Sources/DroidKit/View/Debug/DroidKitDebugView.swift +++ b/Sources/DroidKit/View/Debug/DroidKitDebugView.swift @@ -26,6 +26,7 @@ public struct DroidKitDebugView: View { rotationSection colorSection soundSection + joystickSection } .padding([.top, .bottom], 32) } @@ -156,6 +157,19 @@ private extension DroidKitDebugView { } } } + + var joystickSection: some View { + Group { + if #available(iOS 15.0, *) { + VStack(spacing: 16) { + DroidKitSectionTitle(title: "Joystick") + DroidJoystickView() + } + } else { + EmptyView() + } + } + } } #endif diff --git a/Sources/DroidKit/View/Joystick/DroidJoystickView.swift b/Sources/DroidKit/View/Joystick/DroidJoystickView.swift index 9cc696f..1660d8a 100644 --- a/Sources/DroidKit/View/Joystick/DroidJoystickView.swift +++ b/Sources/DroidKit/View/Joystick/DroidJoystickView.swift @@ -21,7 +21,8 @@ public struct DroidJoystickView: View { shape: .circle, background: { backgroundCircle }, foreground: { foregroundCircle }, - locksInPlace: false) + locksInPlace: false + ) } }