Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ShowAppMenu RPC #184

Merged
merged 5 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,560 changes: 789 additions & 771 deletions build/bundle.js

Large diffs are not rendered by default.

17 changes: 16 additions & 1 deletion src/js/AppHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import MenuIcon from './containers/MenuIcon';
import Name from './containers/Name';
import MenuLink from './containers/AppsButton'
import store from './store'

import {resetShowAppMenu} from './actions'



Expand Down Expand Up @@ -85,6 +85,21 @@ class AppHeader extends React.Component {
this.props.router.push("/" + nextProps.displayLayout)
}
}
else if(nextProps.triggerShowAppMenu){
if(nextProps.activeSubMenu){
// If menuID is specified, activate that sub menu
if(!this.props.router.isActive("/inapplist")){
this.props.router.push('/inapplist')
}
}
else{
// If NO menuID is specifed, show menu
if(!this.props.router.isActive("/inappmenu")){
this.props.router.push('/inappmenu')
}
}
store.dispatch(resetShowAppMenu(nextProps.activeApp))
}

}
}
Expand Down
9 changes: 8 additions & 1 deletion src/js/Controllers/UIController.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
setDisplayLayout,
alert,
closeAlert,
activateApp
activateApp,
showAppMenu
} from '../actions'
import store from '../store'
import sdlController from './SDLController'
Expand Down Expand Up @@ -88,6 +89,12 @@ class UIController {
rpc.params.menuID
))
return true
case "ShowAppMenu":
store.dispatch(showAppMenu(
rpc.params.appID,
rpc.params.menuID
))
return true
case "OnButtonSubscription":
store.dispatch(subscribeButton(
rpc.params.appID,
Expand Down
17 changes: 17 additions & 0 deletions src/js/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export const Actions = {
SUBSCRIBE_BUTTON: "SUBSCRIBE_BUTTON",
ACTIVATE_SUB_MENU: "ACTIVATE_SUB_MENU",
DEACTIVATE_SUB_MENU: "DEACTIVATE_SUB_MENU",
SHOW_APP_MENU: "SHOW_APP_MENU",
RESET_SHOW_APP_MENU: "RESET_SHOW_APP_MENU",
PERFORM_INTERACTION: "PERFORM_INTERACTION",
DEACTIVATE_INTERACTION: "DEACTIVATE_INTERACTION",
TIMEOUT_PERFORM_INTERACTION: "TIMEOUT_PERFORM_INTERACTION",
Expand Down Expand Up @@ -130,6 +132,21 @@ export const deactivateSubMenu = (appID) => {
}
}

export const showAppMenu = (appID, menuID) => {
return {
type: Actions.SHOW_APP_MENU,
menuID: menuID,
appID: appID
}
}

export const resetShowAppMenu = (appID) => {
return {
type: Actions.RESET_SHOW_APP_MENU,
appID: appID
}
}

export const deactivateInteraction = (appID) => {
return {
type: Actions.DEACTIVATE_INTERACTION,
Expand Down
8 changes: 6 additions & 2 deletions src/js/containers/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ const mapStateToProps = (state) => {

var theme = state.theme
var colorScheme = null;
var triggerShowAppMenu = (state.ui[activeApp]) ? state.ui[activeApp].triggerShowAppMenu : false;
var activeSubMenu = (state.ui[activeApp]) ? state.ui[activeApp].activeSubMenu : null;

if (theme === true) { //Dark theme
if(app.nightColorScheme) {
if(app.nightColorScheme.backgroundColor) {
Expand All @@ -48,8 +51,9 @@ const mapStateToProps = (state) => {
alertName: alertAppName,
theme: theme,
activeApp: activeApp,
colorScheme: colorScheme

colorScheme: colorScheme,
triggerShowAppMenu: triggerShowAppMenu,
activeSubMenu: activeSubMenu
}
}

Expand Down
15 changes: 15 additions & 0 deletions src/js/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function newAppState () {
softButtons: [],
icon: null,
menu: [],
triggerShowAppMenu: false,
activeSubMenu: null,
subscribedButtons: {},
isPerformingInteraction: false,
Expand Down Expand Up @@ -329,6 +330,14 @@ function ui(state = {}, action) {
})
menu.splice(i, 1)
return newState
case Actions.SHOW_APP_MENU:
var newState = { ...state }
var app = newState[action.appID] ? newState[action.appID] : newAppState()
app.triggerShowAppMenu = true
// If action has menuID, activate submenu otherwise deactivate sub menu
app.activeSubMenu = (action.menuID) ? action.menuID : null;
newState[action.appID] = app
return newState
case Actions.SUBSCRIBE_BUTTON:
var newState = { ...state }
var app = newState[action.appID] ? newState[action.appID] : newAppState()
Expand Down Expand Up @@ -506,6 +515,12 @@ function ui(state = {}, action) {
var newState = { ...state }
var app = newState[action.appID] ? newState[action.appID] : newAppState()
return newState
case Actions.RESET_SHOW_APP_MENU:
var newState = { ...state }
var app = newState[action.appID] ? newState[action.appID] : newAppState()
app.triggerShowAppMenu = false
newState[action.appID] = app
return newState
default:
return state
}
Expand Down