/* * Smart GWT (GWT for SmartClient) * Copyright 2008 and beyond, Isomorphic Software, Inc. * * Smart GWT is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. Smart GWT is also * available under typical commercial license terms - see * http://smartclient.com/license * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.types.NavigationDirection; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.layout.FlowLayout; import com.smartgwt.client.widgets.layout.NavigationBar; import com.smartgwt.client.widgets.layout.NavigationBarViewState; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.layout.events.NavigationClickEvent; import com.smartgwt.client.widgets.layout.events.NavigationClickHandler; import com.google.gwt.core.client.EntryPoint; public class MobileAnimatedTransitionsSample implements EntryPoint { public void onModuleLoad() { final NavigationBar navBar = new NavigationBar(); navBar.setWidth(296); navBar.setLeftButtonTitle("Folders"); navBar.setRightButtonTitle("New"); navBar.setShowRightButton(true); navBar.setTitle("Inbox"); navBar.setAnimateStateChanges(true); navBar.addNavigationClickHandler(new NavigationClickHandler() { @Override public void onNavigationClick(NavigationClickEvent event) { if (event.getDirection().equals(NavigationDirection.BACK)) { if (navBar.getLeftButtonTitle().equals("Inbox")) { navBar.setRightButtonTitle("New"); NavigationBarViewState viewState = new NavigationBarViewState(); viewState.setLeftButtonTitle("Folders"); viewState.setTitle("Inbox"); navBar.setViewState(viewState, NavigationDirection.BACK); } else if (navBar.getLeftButtonTitle().equals("Folders")) { navBar.setRightButtonTitle("Inbox"); NavigationBarViewState viewState = new NavigationBarViewState(); viewState.setLeftButtonTitle("Exit"); viewState.setTitle("Folders"); navBar.setViewState(viewState, NavigationDirection.BACK); } else if (navBar.getLeftButtonTitle().equals("Exit")) { SC.say("Exiting"); } } else { if (navBar.getTitle().equals("Inbox")) { navBar.setRightButtonTitle("Done"); NavigationBarViewState viewState = new NavigationBarViewState(); viewState.setLeftButtonTitle(navBar.getTitle()); viewState.setTitle("New Message"); navBar.setViewState(viewState, NavigationDirection.FORWARD); } else if (navBar.getTitle().equals("Folders")) { navBar.setRightButtonTitle("New"); NavigationBarViewState viewState = new NavigationBarViewState(); viewState.setLeftButtonTitle("Folders"); viewState.setTitle("Inbox"); navBar.setViewState(viewState, NavigationDirection.FORWARD); } else if (navBar.getTitle().equals("New Message")) { SC.say("Sending message"); navBar.setRightButtonTitle("New"); if (navBar.getLeftButtonTitle().equals("Inbox")) { NavigationBarViewState viewState = new NavigationBarViewState(); viewState.setLeftButtonTitle("Folders"); viewState.setTitle("Inbox"); navBar.setViewState(viewState, NavigationDirection.BACK); } else if (navBar.getLeftButtonTitle().equals("Folders")) { NavigationBarViewState viewState = new NavigationBarViewState(); viewState.setLeftButtonTitle("Exit"); viewState.setTitle("Folders"); navBar.setViewState(viewState, NavigationDirection.BACK); } } } } }); navBar.draw(); } }