mirror of
https://github.com/StikDebug/StikDebug.git
synced 2026-10-15 20:10:30 +00:00
This reverts commit 2d10756ca4.
This commit is contained in:
parent
2d10756ca4
commit
74d7de5fe7
4 changed files with 4 additions and 128 deletions
|
|
@ -1,18 +0,0 @@
|
|||
[
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Welcome!",
|
||||
"body": "Thank you for using StikDebug. Stay tuned for updates.",
|
||||
"date": "2025-06-04",
|
||||
"time": "12:00",
|
||||
"visible": true
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "New Feature",
|
||||
"body": "Announcements are now shown on the home screen.",
|
||||
"date": "2025-06-04",
|
||||
"time": "12:30",
|
||||
"visible": true
|
||||
}
|
||||
]
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
import Foundation
|
||||
|
||||
struct Announcement: Identifiable, Codable {
|
||||
let id: Int
|
||||
let title: String
|
||||
let body: String
|
||||
let date: String
|
||||
let time: String
|
||||
let visible: Bool
|
||||
}
|
||||
|
||||
class AnnouncementManager {
|
||||
private static let announcementsURL = "https://raw.githubusercontent.com/0-Blu/StikJIT/main/StikJIT/Resources/announcements.json"
|
||||
|
||||
static func fetchAnnouncements(completion: @escaping ([Announcement]) -> Void) {
|
||||
guard let url = URL(string: announcementsURL) else {
|
||||
completion([])
|
||||
return
|
||||
}
|
||||
|
||||
URLSession.shared.dataTask(with: url) { data, response, _ in
|
||||
guard let data = data,
|
||||
(response as? HTTPURLResponse)?.statusCode == 200,
|
||||
let announcements = try? JSONDecoder().decode([Announcement].self, from: data) else {
|
||||
DispatchQueue.main.async {
|
||||
completion([])
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
let visibleAnnouncements = announcements.filter { $0.visible }
|
||||
|
||||
DispatchQueue.main.async {
|
||||
completion(visibleAnnouncements)
|
||||
}
|
||||
}.resume()
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
import SwiftUI
|
||||
|
||||
struct AnnouncementCard: View {
|
||||
var announcement: Announcement
|
||||
@AppStorage("customAccentColor") private var customAccentColorHex: String = ""
|
||||
|
||||
private var accentColor: Color {
|
||||
if customAccentColorHex.isEmpty {
|
||||
return .blue
|
||||
} else {
|
||||
return Color(hex: customAccentColorHex) ?? .blue
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Text(announcement.title)
|
||||
.font(.headline)
|
||||
.foregroundColor(.primary)
|
||||
Text(announcement.body)
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.secondary)
|
||||
Text("\(announcement.date) \(announcement.time)")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.padding()
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.background(Color(UIColor.secondarySystemBackground))
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 16)
|
||||
.stroke(accentColor, lineWidth: 2)
|
||||
)
|
||||
.cornerRadius(16)
|
||||
.shadow(color: Color.black.opacity(0.08), radius: 3, x: 0, y: 2)
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
AnnouncementCard(
|
||||
announcement: Announcement(
|
||||
id: 0,
|
||||
title: "Title",
|
||||
body: "Body",
|
||||
date: "2025-01-01",
|
||||
time: "00:00",
|
||||
visible: true
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
@ -8,9 +8,6 @@
|
|||
import SwiftUI
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
// Load announcements from remote JSON
|
||||
import Foundation
|
||||
|
||||
extension UIDocumentPickerViewController {
|
||||
@objc func fix_init(forOpeningContentTypes contentTypes: [UTType], asCopy: Bool) -> UIDocumentPickerViewController {
|
||||
return fix_init(forOpeningContentTypes: contentTypes, asCopy: true)
|
||||
|
|
@ -35,8 +32,6 @@ struct HomeView: View {
|
|||
@State private var isImportingFile = false
|
||||
@State private var showingConsoleLogsView = false
|
||||
@State private var importProgress: Float = 0.0
|
||||
|
||||
@State private var announcements: [Announcement] = []
|
||||
|
||||
@State private var pidTextAlertShow = false
|
||||
@State private var pidStr = ""
|
||||
|
|
@ -65,23 +60,14 @@ struct HomeView: View {
|
|||
Text("Welcome to StikDebug \(username)!")
|
||||
.font(.system(.largeTitle, design: .rounded))
|
||||
.fontWeight(.bold)
|
||||
|
||||
|
||||
Text(pairingFileExists ? "Click connect to get started" : "Pick pairing file to get started")
|
||||
.font(.system(.subheadline, design: .rounded))
|
||||
.foregroundStyle(.secondary)
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
.padding(.top, 40)
|
||||
|
||||
if !announcements.isEmpty {
|
||||
VStack(spacing: 12) {
|
||||
ForEach(announcements) { announcement in
|
||||
AnnouncementCard(announcement: announcement)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 20)
|
||||
}
|
||||
|
||||
|
||||
Button(action: {
|
||||
|
||||
|
||||
|
|
@ -217,14 +203,10 @@ struct HomeView: View {
|
|||
checkPairingFileExists()
|
||||
// Don't initialize specific color value when empty - empty means "use system theme"
|
||||
// This was causing the toggle to turn off when returning to settings
|
||||
|
||||
|
||||
// Initialize background color
|
||||
refreshBackground()
|
||||
|
||||
AnnouncementManager.fetchAnnouncements { loaded in
|
||||
announcements = loaded
|
||||
}
|
||||
|
||||
|
||||
// Add notification observer for showing pairing file picker
|
||||
NotificationCenter.default.addObserver(
|
||||
forName: NSNotification.Name("ShowPairingFilePicker"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue