b48a47ce10
- 1A: Notificación mensual de resumen de portfolio (día 5 de cada mes) - 1B: Badge de racha mensual en Dashboard (streak counter) - 1C: Empty states mejorados en Goals y Journal con CTAs claros - 2A: Quick Update sheet — actualiza todas las fuentes desde una pantalla - 2B: Notificación batch update redirige al Quick Update sheet - 2C: Widget deep link portfoliojournal://quickupdate abre Quick Update - 3A: App Store version check banner en Settings - 3C: What's New sheet en primer launch de versión nueva - Localización completa en 7 idiomas para todas las nuevas strings Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
116 lines
3.4 KiB
Swift
116 lines
3.4 KiB
Swift
import Foundation
|
|
|
|
struct DashboardSectionConfig: Identifiable, Codable, Hashable {
|
|
let id: String
|
|
var isVisible: Bool
|
|
var isCollapsed: Bool
|
|
var columnSpan: Int
|
|
|
|
init(id: String, isVisible: Bool, isCollapsed: Bool, columnSpan: Int = 1) {
|
|
self.id = id
|
|
self.isVisible = isVisible
|
|
self.isCollapsed = isCollapsed
|
|
self.columnSpan = columnSpan
|
|
}
|
|
|
|
init(from decoder: Decoder) throws {
|
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
|
id = try container.decode(String.self, forKey: .id)
|
|
isVisible = try container.decode(Bool.self, forKey: .isVisible)
|
|
isCollapsed = try container.decode(Bool.self, forKey: .isCollapsed)
|
|
columnSpan = try container.decodeIfPresent(Int.self, forKey: .columnSpan) ?? 1
|
|
}
|
|
}
|
|
|
|
enum DashboardSection: String, CaseIterable, Identifiable {
|
|
case totalValue
|
|
case monthlyCheckIn
|
|
case momentumStreaks
|
|
case monthlySummary
|
|
case evolution
|
|
case categoryBreakdown
|
|
case goals
|
|
case pendingUpdates
|
|
case periodReturns
|
|
case contributionsVsReturns
|
|
|
|
var id: String { rawValue }
|
|
|
|
var title: String {
|
|
switch self {
|
|
case .totalValue:
|
|
return "Total Portfolio Value"
|
|
case .monthlyCheckIn:
|
|
return "Monthly Check-in"
|
|
case .momentumStreaks:
|
|
return "Momentum & Streaks"
|
|
case .monthlySummary:
|
|
return "Cashflow vs Growth"
|
|
case .evolution:
|
|
return "Portfolio Evolution"
|
|
case .categoryBreakdown:
|
|
return "By Category"
|
|
case .goals:
|
|
return "Goals"
|
|
case .pendingUpdates:
|
|
return "Pending Updates"
|
|
case .periodReturns:
|
|
return "Returns"
|
|
case .contributionsVsReturns:
|
|
return "Invested vs. Returns"
|
|
}
|
|
}
|
|
}
|
|
|
|
enum DashboardLayoutStore {
|
|
private static let storageKey = "dashboardLayoutConfig"
|
|
|
|
static func load() -> [DashboardSectionConfig] {
|
|
let defaults = defaultConfigs()
|
|
guard let data = UserDefaults.standard.data(forKey: storageKey),
|
|
let decoded = try? JSONDecoder().decode([DashboardSectionConfig].self, from: data) else {
|
|
return defaults
|
|
}
|
|
|
|
var merged: [DashboardSectionConfig] = []
|
|
for config in decoded {
|
|
if let section = DashboardSection(rawValue: config.id) {
|
|
merged.append(config)
|
|
} else {
|
|
continue
|
|
}
|
|
}
|
|
|
|
for section in DashboardSection.allCases {
|
|
if !merged.contains(where: { $0.id == section.id }) {
|
|
merged.append(defaults.first(where: { $0.id == section.id }) ?? DashboardSectionConfig(
|
|
id: section.id,
|
|
isVisible: true,
|
|
isCollapsed: false
|
|
))
|
|
}
|
|
}
|
|
|
|
return merged
|
|
}
|
|
|
|
static func save(_ configs: [DashboardSectionConfig]) {
|
|
guard let data = try? JSONEncoder().encode(configs) else { return }
|
|
UserDefaults.standard.set(data, forKey: storageKey)
|
|
}
|
|
|
|
static func reset() {
|
|
UserDefaults.standard.removeObject(forKey: storageKey)
|
|
}
|
|
|
|
private static func defaultConfigs() -> [DashboardSectionConfig] {
|
|
DashboardSection.allCases.map { section in
|
|
DashboardSectionConfig(
|
|
id: section.id,
|
|
isVisible: true,
|
|
isCollapsed: false
|
|
)
|
|
}
|
|
}
|
|
}
|