//
//  TrendDirection.swift
//  Andromida
//
//  Represents the direction of a trend for insight visualization.
//

import SwiftUI
import Bedrock

/// Represents the direction of change in a metric.
enum TrendDirection {
    case up
    case down
    case stable
    
    var symbolName: String {
        switch self {
        case .up: return "arrow.up.right"
        case .down: return "arrow.down.right"
        case .stable: return "arrow.right"
        }
    }
    
    var color: Color {
        switch self {
        case .up: return AppStatus.success
        case .down: return AppStatus.warning
        case .stable: return AppTextColors.secondary
        }
    }
    
    var accessibilityLabel: String {
        switch self {
        case .up: return String(localized: "Trending up")
        case .down: return String(localized: "Trending down")
        case .stable: return String(localized: "Stable")
        }
    }
    
    /// Determines trend direction based on percentage change.
    /// - Parameter percentageChange: The change as a decimal (e.g., 0.1 for 10% increase)
    /// - Returns: The appropriate trend direction
    static func from(percentageChange: Double) -> TrendDirection {
        if percentageChange > 0.05 {
            return .up
        } else if percentageChange < -0.05 {
            return .down
        } else {
            return .stable
        }
    }
}
