mirror of
https://github.com/StikDebug/StikDebug.git
synced 2026-10-16 04:20:30 +00:00
build logger ui
This commit is contained in:
parent
7d26b092c8
commit
86b2bb621c
2 changed files with 238 additions and 1 deletions
196
StikJIT/Views/ConsoleLogsView.swift
Normal file
196
StikJIT/Views/ConsoleLogsView.swift
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
//
|
||||
// ConsoleLogsView.swift
|
||||
// StikJIT
|
||||
//
|
||||
// Created by neoarz on 3/29/25.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import UIKit
|
||||
|
||||
struct ConsoleLogsView: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@State private var dummyLogs: [String] = [
|
||||
"Initializing StikJIT environment...",
|
||||
"Checking device compatibility...",
|
||||
"Loading system configuration...",
|
||||
"Verifying device permissions...",
|
||||
"Initializing JIT compiler...",
|
||||
"Loading pairing credentials...",
|
||||
"Configuration loaded successfully",
|
||||
"System check completed",
|
||||
"Ready for operation"
|
||||
]
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
ZStack {
|
||||
Color(UIColor.systemBackground)
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
|
||||
VStack(spacing: 0) {
|
||||
// Terminal-style logs area
|
||||
ScrollView {
|
||||
VStack(spacing: 2) {
|
||||
// Device Information
|
||||
ForEach(["Version: \(UIDevice.current.systemVersion)",
|
||||
"Name: \(UIDevice.current.name)",
|
||||
"Model: \(UIDevice.current.model)",
|
||||
"StikJIT: 1.0"], id: \.self) { info in
|
||||
HStack {
|
||||
Text("[\(timeString())]")
|
||||
.foregroundColor(.blue)
|
||||
.font(.system(size: 12, design: .monospaced))
|
||||
|
||||
Image(systemName: "checkmark.seal.fill")
|
||||
.foregroundColor(.blue)
|
||||
.font(.system(size: 10))
|
||||
|
||||
Text(info)
|
||||
.font(.system(size: 12, design: .monospaced))
|
||||
.foregroundColor(.primary)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
.padding(.vertical, 1)
|
||||
.padding(.horizontal, 8)
|
||||
}
|
||||
|
||||
Divider()
|
||||
.padding(.vertical, 4)
|
||||
|
||||
// Log entries
|
||||
ForEach(dummyLogs.indices, id: \.self) { index in
|
||||
HStack(alignment: .top, spacing: 8) {
|
||||
Text("[\(timeString(minutesAgo: dummyLogs.count - index))]")
|
||||
.foregroundColor(.gray)
|
||||
.font(.system(size: 11, design: .monospaced))
|
||||
|
||||
Text("[INFO]")
|
||||
.foregroundColor(.green)
|
||||
.font(.system(size: 11, design: .monospaced))
|
||||
|
||||
Text(dummyLogs[index])
|
||||
.font(.system(size: 11, design: .monospaced))
|
||||
.foregroundColor(.primary)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
.padding(.vertical, 1)
|
||||
.padding(.horizontal, 8)
|
||||
}
|
||||
}
|
||||
.padding(.vertical, 8)
|
||||
.background(Color(UIColor.secondarySystemBackground))
|
||||
.cornerRadius(8)
|
||||
.padding(.horizontal, 8)
|
||||
.padding(.top, 8)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
// Bottom section with error count and action buttons
|
||||
VStack(spacing: 16) {
|
||||
// Error count
|
||||
HStack {
|
||||
Text("0 Critical Errors.")
|
||||
.font(.headline)
|
||||
.foregroundColor(.white)
|
||||
.padding(.vertical, 10)
|
||||
.padding(.horizontal, 20)
|
||||
.frame(maxWidth: .infinity)
|
||||
.background(Color.red)
|
||||
.cornerRadius(8)
|
||||
}
|
||||
.padding(.horizontal)
|
||||
|
||||
// Action buttons
|
||||
VStack(spacing: 1) {
|
||||
// Share button
|
||||
Button(action: {
|
||||
let logs = dummyLogs.map { "[\(timeString())] [INFO] \($0)" }.joined(separator: "\n")
|
||||
let activityVC = UIActivityViewController(activityItems: [logs], applicationActivities: nil)
|
||||
|
||||
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
||||
let rootVC = windowScene.windows.first?.rootViewController else { return }
|
||||
rootVC.present(activityVC, animated: true)
|
||||
}) {
|
||||
HStack {
|
||||
Text("Share Logs")
|
||||
.foregroundColor(.blue)
|
||||
.padding(.leading, 2)
|
||||
Spacer()
|
||||
Image(systemName: "square.and.arrow.up")
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.padding(.vertical, 14)
|
||||
.padding(.horizontal, 20)
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.background(Color.black.opacity(0.05))
|
||||
|
||||
Divider()
|
||||
.background(Color.gray.opacity(0.3))
|
||||
|
||||
// Copy button
|
||||
Button(action: {
|
||||
let logs = dummyLogs.map { "[\(timeString())] [INFO] \($0)" }.joined(separator: "\n")
|
||||
UIPasteboard.general.string = logs
|
||||
}) {
|
||||
HStack {
|
||||
Text("Copy Logs")
|
||||
.foregroundColor(.blue)
|
||||
.padding(.leading, 2)
|
||||
Spacer()
|
||||
Image(systemName: "arrow.right")
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.padding(.vertical, 14)
|
||||
.padding(.horizontal, 20)
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.background(Color.black.opacity(0.05))
|
||||
}
|
||||
.cornerRadius(8)
|
||||
.padding(.horizontal)
|
||||
.padding(.bottom, 16)
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationTitle("Console Logs")
|
||||
.navigationBarItems(
|
||||
leading: Button(action: {
|
||||
dismiss()
|
||||
}) {
|
||||
HStack(spacing: 2) {
|
||||
Image(systemName: "chevron.left")
|
||||
.font(.system(size: 16, weight: .semibold))
|
||||
Text("Settings")
|
||||
.fontWeight(.regular)
|
||||
}
|
||||
.foregroundColor(.blue)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Helper to display current time
|
||||
private func timeString() -> String {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateFormat = "HH:mm:ss"
|
||||
return formatter.string(from: Date())
|
||||
}
|
||||
|
||||
// Helper to display time with offset for log display
|
||||
private func timeString(minutesAgo: Int) -> String {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateFormat = "HH:mm:ss"
|
||||
let date = Calendar.current.date(byAdding: .minute, value: -minutesAgo, to: Date()) ?? Date()
|
||||
return formatter.string(from: date)
|
||||
}
|
||||
}
|
||||
|
||||
// Preview provider
|
||||
struct ConsoleLogsView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ConsoleLogsView()
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,9 @@
|
|||
import SwiftUI
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
// Add this if ConsoleLogsView is in a different module (unlikely but just in case)
|
||||
// import ConsoleLogsModule
|
||||
|
||||
struct SettingsView: View {
|
||||
@AppStorage("username") private var username = "User"
|
||||
@AppStorage("customBackgroundColor") private var customBackgroundColorHex: String = Color.primaryBackground.toHex() ?? "#000000"
|
||||
|
|
@ -23,6 +26,8 @@ struct SettingsView: View {
|
|||
|
||||
@State private var mounted = false
|
||||
|
||||
@State private var showingConsoleLogsView = false
|
||||
|
||||
// Developer profile image URLs
|
||||
private let developerProfiles: [String: String] = [
|
||||
"Blu": "https://github.com/0-Blu.png",
|
||||
|
|
@ -361,8 +366,32 @@ struct SettingsView: View {
|
|||
.padding(.vertical, 20)
|
||||
.padding(.horizontal, 16)
|
||||
}
|
||||
.padding(.bottom, 16)
|
||||
|
||||
// Version text - now outside of any card, as standalone text at the bottom
|
||||
// Move System Logs section here (right after About card, before version)
|
||||
SettingsCard {
|
||||
Button(action: {
|
||||
showingConsoleLogsView = true
|
||||
}) {
|
||||
HStack {
|
||||
Text("System Logs")
|
||||
.font(.headline)
|
||||
.foregroundColor(.primary)
|
||||
|
||||
Spacer()
|
||||
|
||||
Image(systemName: "chevron.right")
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.padding(.vertical, 16)
|
||||
.padding(.horizontal, 16)
|
||||
}
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
}
|
||||
.padding(.bottom, 16)
|
||||
|
||||
// Version info should now come after System Logs
|
||||
HStack {
|
||||
Spacer()
|
||||
Text("Version 1.0 • iOS \(UIDevice.current.systemVersion)")
|
||||
|
|
@ -376,6 +405,11 @@ struct SettingsView: View {
|
|||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, 20)
|
||||
}
|
||||
|
||||
// Add this sheet at the end of the ZStack, before the final closing bracket
|
||||
.sheet(isPresented: $showingConsoleLogsView) {
|
||||
ConsoleLogsView()
|
||||
}
|
||||
}
|
||||
.fileImporter(
|
||||
isPresented: $isShowingPairingFilePicker,
|
||||
|
|
@ -655,3 +689,10 @@ struct CollaboratorRow: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Define these in a separate file if they conflict
|
||||
struct ConsoleLogsView_Preview: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ConsoleLogsView()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue