import {
    USER_NAVIGATED
} from '../types'

const {
    contentViewID,
    headerHeight
} = window.appSettings

const contentID = '#' + contentViewID

export const navigateToView = (destination, callback=()=>{}) => {
    switch (destination) {
        case 'home':
            return toggleHomeView(false, callback)
        case 'content':
            return toggleHomeView(true, callback)
        case 'settings':
            // TODO: write this action
            return gotoSettings(callback)
        default:
            throw new Error(`Invalid navigation destination '${destination}'`)
    }
}

export const toggleHomeView = (override, callback=()=>{}) => {
    let top;

    return (dispatch, getState) => {
        if (typeof override !== "undefined") {
            top = override
                ? window.innerHeight - headerHeight + 2 + "px"
                : 0
        } else {
            top = getState().display.activeView !== "home"
                ? window.innerHeight - headerHeight + 2 + "px"
                : 0
        }

        // 2px +- used to cover border
        const navigatedTo = top === 0 ? 'content' : 'home'
        console.warn("changing to", navigatedTo);
        console.warn("top", top);
        console.warn("element is", $(contentID));


        return $(contentID).velocity({top}, {
            duration: 400,
            easing: 'ease-out',
            complete: () => {
                dispatch(userNavigated(navigatedTo))
                callback(navigatedTo)
            }
        })
    }
}

const userNavigated = (navigatedTo) => {
    return {
        type: USER_NAVIGATED,
        payload: navigatedTo
    }
}

@@ -672,16 +672,124 @@
 let top;
+%0A    const easing_in = %5B0.23, 1, 0.32, 1%5D%0A    const easing_out = %5B0.23, 1, 0.32, 1%5D%0A    const duration = 600
 %0A%0A    re
@@ -1260,130 +1260,53 @@
 cons
-ole.warn(%22changing to%22, navigatedTo);%0A        console.warn(%22top%22, top);%0A        console.warn(%22element is%22, $(contentID));%0A
+t easing = top === 0 ? easing_out : easing_in
 %0A%0A  
@@ -1373,45 +1373,16 @@
 tion
-: 400,%0A            easing: 'ease-out'
+, easing
 ,%0A  

Add quint easing