From 11863ff7637f8f629d0c54701d00d58c4d8a819e Mon Sep 17 00:00:00 2001 From: Stephen <158498287+0-Blu@users.noreply.github.com> Date: Thu, 27 Mar 2025 07:25:17 -0400 Subject: [PATCH] Better UI --- .../HapticFeedbackHelper.swift | 15 +++++ .../Extensions & Stuff/RoundedTextField.swift | 34 +++++++++++ StikJIT/Views/HomeView.swift | 59 +++++++++++++++---- 3 files changed, 95 insertions(+), 13 deletions(-) create mode 100644 StikJIT/Extensions & Stuff/HapticFeedbackHelper.swift create mode 100644 StikJIT/Extensions & Stuff/RoundedTextField.swift diff --git a/StikJIT/Extensions & Stuff/HapticFeedbackHelper.swift b/StikJIT/Extensions & Stuff/HapticFeedbackHelper.swift new file mode 100644 index 0000000..cebb8de --- /dev/null +++ b/StikJIT/Extensions & Stuff/HapticFeedbackHelper.swift @@ -0,0 +1,15 @@ +// +// HapticFeedbackHelper.swift +// StikJIT +// +// Created by Stephen on 3/27/25. +// + +import SwiftUI + +struct HapticFeedbackHelper { + static func trigger() { + let generator = UIImpactFeedbackGenerator(style: .medium) + generator.impactOccurred() + } +} diff --git a/StikJIT/Extensions & Stuff/RoundedTextField.swift b/StikJIT/Extensions & Stuff/RoundedTextField.swift new file mode 100644 index 0000000..04970a9 --- /dev/null +++ b/StikJIT/Extensions & Stuff/RoundedTextField.swift @@ -0,0 +1,34 @@ +// +// RoundedTextField.swift +// StikJIT +// +// Created by Stephen on 3/27/25. +// + +import SwiftUI + +struct RoundedTextField: View { + var placeholder: String + @Binding var text: String + + var body: some View { + HStack { + TextField(placeholder, text: $text) + .font(.system(.body, design: .rounded)) + .autocapitalization(.none) + .disableAutocorrection(true) + .foregroundColor(.primary) + + if !text.isEmpty { + Button(action: { text = "" }) { + Image(systemName: "xmark.circle.fill") + .foregroundColor(.gray) + } + .buttonStyle(.plain) + } + } + .padding() + .background(RoundedRectangle(cornerRadius: 12).fill(Color(.secondarySystemBackground))) + .overlay(RoundedRectangle(cornerRadius: 12).stroke(Color(.tertiaryLabel), lineWidth: 0.5)) + } +} diff --git a/StikJIT/Views/HomeView.swift b/StikJIT/Views/HomeView.swift index e5f4798..d035752 100644 --- a/StikJIT/Views/HomeView.swift +++ b/StikJIT/Views/HomeView.swift @@ -8,28 +8,58 @@ import SwiftUI struct HomeView: View { - @AppStorage("bundleID") var bundleID: String = "com.stossy11.MeloNX" + @AppStorage("bundleID") private var bundleID: String = "com.stossy11.MeloNX" + @State private var isProcessing = false var body: some View { - VStack(spacing: 20) { - TextField("Enter Bundle ID", text: $bundleID) - .textFieldStyle(RoundedBorderTextFieldStyle()) - .padding() + ZStack { + Color(.systemGroupedBackground) + .edgesIgnoringSafeArea(.all) - Button(action: startJITInBackground) { - Text("Enable Jit") - .padding() - .background(Color.blue) - .foregroundColor(.white) - .cornerRadius(8) + VStack(spacing: 25) { + Spacer() + VStack(spacing: 5) { + Text("StikJIT") + .font(.system(.largeTitle, design: .rounded)) + .fontWeight(.bold) + + Text("Enter the app's Bundle ID and enable JIT.") + .font(.system(.subheadline, design: .rounded)) + .foregroundStyle(.secondary) + .multilineTextAlignment(.center) + } + .padding(.top, 40) + RoundedTextField(placeholder: "Enter Bundle ID", text: $bundleID) + .padding(.horizontal, 20) + Button(action: { + HapticFeedbackHelper.trigger() + startJITInBackground() + }) { + Label(isProcessing ? "Enabling..." : "Enable JIT", systemImage: isProcessing ? "hourglass" : "bolt.fill") + .font(.system(.title3, design: .rounded)) + .fontWeight(.semibold) + .frame(maxWidth: .infinity) + .padding() + .background(isProcessing ? Color.gray.opacity(0.6) : Color.blue) + .foregroundColor(.white) + .cornerRadius(16) + .shadow(color: .blue.opacity(0.3), radius: 8, x: 0, y: 4) + .animation(.easeInOut(duration: 0.2), value: isProcessing) + } + .disabled(isProcessing) + .padding(.horizontal, 20) + + Spacer() } + .padding() } - .padding() } - func startJITInBackground() { + private func startJITInBackground() { + isProcessing = true DispatchQueue.global(qos: .background).async { guard let cBundleID = strdup(bundleID) else { + DispatchQueue.main.async { isProcessing = false } return } @@ -41,6 +71,9 @@ struct HomeView: View { } free(cBundleID) + DispatchQueue.main.async { + isProcessing = false + } } } }