//
//  Padding.swift
//  MVMCoreUI
//
//  Created by Kevin Christiano on 4/1/20.
//  Copyright © 2020 Verizon Wireless. All rights reserved.
//


/// Padding is a multiple based on the number 4.
public struct Padding {
    
    public static let OneHalf: CGFloat = 2
    public static let One: CGFloat = 4
    public static let Two: CGFloat = 8
    public static let Three: CGFloat = 12
    public static let Four: CGFloat = 16
    public static let Five: CGFloat = 24
    public static let Eight: CGFloat = 32
    public static let Ten: CGFloat = 40
    public static let Twelve: CGFloat = 48
    public static let Eighteen: CGFloat = 72
    
    public struct Component {
        public static let Standard: CGFloat = 24
        public static let HorizontalMarginSpacing: CGFloat = 16
        public static let LargeHorizontalMarginSpacing: CGFloat = 32
        public static let VerticalMarginSpacing: CGFloat = 24
        public static let LargeVerticalMarginSpacing: CGFloat = 32
        public static let HorizontalGutterSpacing: CGFloat = 12
        public static let LargeHorizontalGutterSpacing: CGFloat = 24

        public static var horizontalPaddingForApplicationWidth: CGFloat {
            horizontalPaddingForSize(MVMCoreUISplitViewController.getApplicationViewWidth())
        }
        
        public static var verticalPaddingForApplicationWidth: CGFloat {
            verticalPaddingForSize(MVMCoreUISplitViewController.getApplicationViewWidth())
        }
        
        public static var gutterForApplicationWidth: CGFloat {
            gutterFor(size: MVMCoreUISplitViewController.getApplicationViewWidth())
        }
        
        public static func horizontalPaddingForSize(_ size: CGFloat) -> CGFloat {
            let sizeObject = MFSizeObject(standardSize: HorizontalMarginSpacing)!
            return sizeObject.getValueBased(onSize: size)
        }
        
        public static func verticalPaddingForSize(_ size: CGFloat) -> CGFloat {
            MFSizeObject(scalingStandardSize: VerticalMarginSpacing)?.getValueBased(onSize: size) ?? VerticalMarginSpacing
        }
        
        public static func gutterFor(size: CGFloat) -> CGFloat {
            let sizeObject = MFSizeObject(standardSize: HorizontalGutterSpacing)!
            return sizeObject.getValueBased(onSize: size)
        }
        
        public static func columnFor(size: CGFloat) -> CGFloat {
            return (size - (3.0 * gutterFor(size: size)) - (2.0 * horizontalPaddingForSize(size))) / 4.0
        }
    }
}
