SlideShare a Scribd company logo
1 of 11
Download to read offline
Adapting to Tablets & Desktops - Part III
In this module we dig into the TabletUI class
public void start() {
if(current != null){
current.show();
return;
}
AppSettings app = AppStorage.getInstance().fetchAppSettings();
if(app.logo.get() == null) {
app.setLogo(theme.getImage("icon.png"));
app.setTitleBackground(theme.getImage("title-image.jpg"));
}
if(Display.getInstance().isTablet()) {
Toolbar.setPermanentSideMenu(true);
new TabletUI(app);
}
BaseNavigationForm.showDishForm(app);
Display.getInstance().callSerially(() -> {
Display.getInstance().registerPush(new Hashtable(), true);
});
}
RestaurantAppBuilder
The tablet UI is created by the main class of the application, we initialize it here so when base navigation form uses the generic code it would already be initialized. We
also initialize the permanent side menu which makes the side menu stay open all the time without the button. That’s a UI paradigm that makes sense on tablets and
desktops.
public class TabletUI extends Form {
private static TabletUI instance;
public TabletUI(AppSettings app) {
super(new BorderLayout());
instance = this;
Toolbar tb = getToolbar();
Style titleStyle = tb.getUnselectedStyle();
titleStyle.setBorder(Border.createEmpty());
titleStyle.setBgImage(app.getTitleBackground());
titleStyle.setBackgroundType(Style.BACKGROUND_IMAGE_SCALED_FILL);
titleStyle.setPaddingUnit(Style.UNIT_TYPE_DIPS);
titleStyle.setPadding(4, 4, 4, 4);
TextField title = new TextField(Restaurant.getInstance().name.get());
title.setUIID("NavigationTitle");
title.addActionListener(a -> {
Restaurant.getInstance().name.set(title.getText());
new Builder().updateRestaurantSettings(app);
});
TextField tagline = new TextField(Restaurant.getInstance().tagline.get());
tagline.setUIID("Tagline");
TabletUI
The tablet UI class is a form that encapsulates the full layout on a tablet

It’s a singleton because we have just one form in the application and one UI
public class TabletUI extends Form {
private static TabletUI instance;
public TabletUI(AppSettings app) {
super(new BorderLayout());
instance = this;
Toolbar tb = getToolbar();
Style titleStyle = tb.getUnselectedStyle();
titleStyle.setBorder(Border.createEmpty());
titleStyle.setBgImage(app.getTitleBackground());
titleStyle.setBackgroundType(Style.BACKGROUND_IMAGE_SCALED_FILL);
titleStyle.setPaddingUnit(Style.UNIT_TYPE_DIPS);
titleStyle.setPadding(4, 4, 4, 4);
TextField title = new TextField(Restaurant.getInstance().name.get());
title.setUIID("NavigationTitle");
title.addActionListener(a -> {
Restaurant.getInstance().name.set(title.getText());
new Builder().updateRestaurantSettings(app);
});
TextField tagline = new TextField(Restaurant.getInstance().tagline.get());
tagline.setUIID("Tagline");
TabletUI
We use a border layout and place the content of the UI in the center so we can replace it when navigating between UIAbstraction instances
public class TabletUI extends Form {
private static TabletUI instance;
public TabletUI(AppSettings app) {
super(new BorderLayout());
instance = this;
Toolbar tb = getToolbar();
Style titleStyle = tb.getUnselectedStyle();
titleStyle.setBorder(Border.createEmpty());
titleStyle.setBgImage(app.getTitleBackground());
titleStyle.setBackgroundType(Style.BACKGROUND_IMAGE_SCALED_FILL);
titleStyle.setPaddingUnit(Style.UNIT_TYPE_DIPS);
titleStyle.setPadding(4, 4, 4, 4);
TextField title = new TextField(Restaurant.getInstance().name.get());
title.setUIID("NavigationTitle");
title.addActionListener(a -> {
Restaurant.getInstance().name.set(title.getText());
new Builder().updateRestaurantSettings(app);
});
TextField tagline = new TextField(Restaurant.getInstance().tagline.get());
tagline.setUIID("Tagline");
TabletUI
The title and subtitle are editable here too, this is effectively a copy of the code from base navigation form adapted for the tablet form factor
tagline.addActionListener(a -> {
Restaurant.getInstance().tagline.set(tagline.getText());
new Builder().updateRestaurantSettings(app);
});
tb.setTitleComponent(BoxLayout.encloseY(title, tagline));
Button logoImage = new Button("", app.getRoundedScaledLogo(), "TabletLogoImage");
logoImage.addActionListener(e -> {
new ImagePickerForm(512, 512, "Icon", app.getLogo(),
newImage -> {
app.setLogo(newImage);
logoImage.setIcon(app.getRoundedScaledLogo());
}).show();
});
tb.addComponentToSideMenu(logoImage);
ButtonGroup bg = new ButtonGroup();
tb.addComponentToSideMenu(createSideNavigationEntry(bg, "Dish List",
FontImage.MATERIAL_RESTAURANT_MENU, true,
e -> BaseNavigationForm.showDishForm(app)));
TabletUI
This is also a copy from base navigation form, but thanks to the available space we don’t need to jump thru hoops to make this look good or fit. So the code here is
much simpler
tagline.addActionListener(a -> {
Restaurant.getInstance().tagline.set(tagline.getText());
new Builder().updateRestaurantSettings(app);
});
tb.setTitleComponent(BoxLayout.encloseY(title, tagline));
Button logoImage = new Button("", app.getRoundedScaledLogo(), "TabletLogoImage");
logoImage.addActionListener(e -> {
new ImagePickerForm(512, 512, "Icon", app.getLogo(),
newImage -> {
app.setLogo(newImage);
logoImage.setIcon(app.getRoundedScaledLogo());
}).show();
});
tb.addComponentToSideMenu(logoImage);
ButtonGroup bg = new ButtonGroup();
tb.addComponentToSideMenu(createSideNavigationEntry(bg, "Dish List",
FontImage.MATERIAL_RESTAURANT_MENU, true,
e -> BaseNavigationForm.showDishForm(app)));
TabletUI
The logo image is now just an icon on the side menu which makes it look far better overall
tb.addComponentToSideMenu(createSideNavigationEntry(bg, "Details",
FontImage.MATERIAL_DESCRIPTION,
e -> BaseNavigationForm.showDetailsForm(app)));
tb.addComponentToSideMenu(createSideNavigationEntry(bg, "Billing",
FontImage.MATERIAL_CREDIT_CARD,
e -> BaseNavigationForm.showBillingForm(app)));
tb.addComponentToSideMenu(createSideNavigationEntry(bg, "Build the App",
FontImage.MATERIAL_PHONE_IPHONE,
e -> BaseNavigationForm.showAppForm(app)));
tb.addComponentToSideMenu(createSideNavigationEntry(bg, "About Us",
FontImage.MATERIAL_INFO,
e -> BaseNavigationForm.showAboutForm(app)));
tb.addCommandToRightBar("Edit Background", null, e -> {
new ImagePickerForm(750, 295, "Background Image", app.getTitleBackground(),
newImage -> {
app.setTitleBackground(newImage);
titleStyle.setBgImage(newImage);
}).show();
});
}
TabletUI
You’ll notice that all the side menu entries are marked here but I’ll only highlight one as they are all mostly the same. Since we don’t derive from the base navigation form
this code is a bit duplicate but it’s much simpler as we don’t need the whole hack with marking the selection.

Notice we aren’t adding commands but rather adding components using the generic createSideNavigationEntry method. We’ll discuss that method soon but notice the
bg argument we pass to each one of them. That’s a button group and these methods return a radio button this allows us to have the selection effect
tb.addComponentToSideMenu(createSideNavigationEntry(bg, "Details",
FontImage.MATERIAL_DESCRIPTION,
e -> BaseNavigationForm.showDetailsForm(app)));
tb.addComponentToSideMenu(createSideNavigationEntry(bg, "Billing",
FontImage.MATERIAL_CREDIT_CARD,
e -> BaseNavigationForm.showBillingForm(app)));
tb.addComponentToSideMenu(createSideNavigationEntry(bg, "Build the App",
FontImage.MATERIAL_PHONE_IPHONE,
e -> BaseNavigationForm.showAppForm(app)));
tb.addComponentToSideMenu(createSideNavigationEntry(bg, "About Us",
FontImage.MATERIAL_INFO,
e -> BaseNavigationForm.showAboutForm(app)));
tb.addCommandToRightBar("Edit Background", null, e -> {
new ImagePickerForm(750, 295, "Background Image", app.getTitleBackground(),
newImage -> {
app.setTitleBackground(newImage);
titleStyle.setBgImage(newImage);
}).show();
});
}
TabletUI
We also add the edit background image button to the side, it’s relatively trivial as there isn’t that much we need to do here.
private RadioButton createSideNavigationEntry(ButtonGroup bg, String title, char icon,
ActionListener<ActionEvent> ac) {
return createSideNavigationEntry(bg, title, icon, false, ac);
}
private RadioButton createSideNavigationEntry(ButtonGroup bg, String title, char icon,
boolean selected, ActionListener<ActionEvent> ac) {
RadioButton a = RadioButton.createToggle(title, bg);
a.setSelected(selected);
a.setUIID("SideCommand");
FontImage.setMaterialIcon(a, icon, 4);
a.addActionListener(ac);
return a;
}
void showContainer(Container cnt, boolean direction) {
if(getContentPane().getComponentCount() == 0) {
add(BorderLayout.CENTER, cnt);
show();
} else {
getContentPane().replace(getContentPane().getComponentAt(0), cnt,
CommonTransitions.createCover(CommonTransitions.SLIDE_HORIZONTAL,
direction, 150));
}
}
TabletUI
createSideNavigationEntry just generalizes the code that creates a radio button toggle button. It mostly saves some boilerplate and doesn’t feature much logic
private RadioButton createSideNavigationEntry(ButtonGroup bg, String title, char icon,
ActionListener<ActionEvent> ac) {
return createSideNavigationEntry(bg, title, icon, false, ac);
}
private RadioButton createSideNavigationEntry(ButtonGroup bg, String title, char icon,
boolean selected, ActionListener<ActionEvent> ac) {
RadioButton a = RadioButton.createToggle(title, bg);
a.setSelected(selected);
a.setUIID("SideCommand");
FontImage.setMaterialIcon(a, icon, 4);
a.addActionListener(ac);
return a;
}
void showContainer(Container cnt, boolean direction) {
if(getContentPane().getComponentCount() == 0) {
add(BorderLayout.CENTER, cnt);
show();
} else {
getContentPane().replace(getContentPane().getComponentAt(0), cnt,
CommonTransitions.createCover(CommonTransitions.SLIDE_HORIZONTAL,
direction, 150));
}
}
TabletUI
However, showContainer is pretty interesting. It’s the method that’s effectively invoked when show() or showBack() are invoked.

There are two modes here. For the very first screen we need to use add. From that point on we’ll always use replace to show the next UIAbstraction instance.

More Related Content

Similar to Adapting to Tablets and Desktops - Part 3 - Transcript.pdf

Adapting to Tablets and Desktops - Part 1 - Transcript.pdf
Adapting to Tablets and Desktops - Part 1 - Transcript.pdfAdapting to Tablets and Desktops - Part 1 - Transcript.pdf
Adapting to Tablets and Desktops - Part 1 - Transcript.pdfShaiAlmog1
 
Adapting to Tablets and Desktops - Part 1.pdf
Adapting to Tablets and Desktops - Part 1.pdfAdapting to Tablets and Desktops - Part 1.pdf
Adapting to Tablets and Desktops - Part 1.pdfShaiAlmog1
 
Academy PRO: React native - building first scenes
Academy PRO: React native - building first scenesAcademy PRO: React native - building first scenes
Academy PRO: React native - building first scenesBinary Studio
 
Extracting ui Design - part 5 - transcript.pdf
Extracting ui Design - part 5 - transcript.pdfExtracting ui Design - part 5 - transcript.pdf
Extracting ui Design - part 5 - transcript.pdfShaiAlmog1
 
SQLite and ORM Binding - Part 2 - Transcript.pdf
SQLite and ORM Binding - Part 2 - Transcript.pdfSQLite and ORM Binding - Part 2 - Transcript.pdf
SQLite and ORM Binding - Part 2 - Transcript.pdfShaiAlmog1
 
Creating an Uber Clone - Part XXXIX.pdf
Creating an Uber Clone - Part XXXIX.pdfCreating an Uber Clone - Part XXXIX.pdf
Creating an Uber Clone - Part XXXIX.pdfShaiAlmog1
 
Miscellaneous Features - Part 3 - Transcript.pdf
Miscellaneous Features - Part 3 - Transcript.pdfMiscellaneous Features - Part 3 - Transcript.pdf
Miscellaneous Features - Part 3 - Transcript.pdfShaiAlmog1
 
Creating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdfCreating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdfShaiAlmog1
 
Creating an Uber Clone - Part XXXIV - Transcript.pdf
Creating an Uber Clone - Part XXXIV - Transcript.pdfCreating an Uber Clone - Part XXXIV - Transcript.pdf
Creating an Uber Clone - Part XXXIV - Transcript.pdfShaiAlmog1
 
Extracting ui Design - part 6 - transcript.pdf
Extracting ui Design - part 6 - transcript.pdfExtracting ui Design - part 6 - transcript.pdf
Extracting ui Design - part 6 - transcript.pdfShaiAlmog1
 
JSLab. Алексей Волков. "React на практике"
JSLab. Алексей Волков. "React на практике"JSLab. Алексей Волков. "React на практике"
JSLab. Алексей Волков. "React на практике"GeeksLab Odessa
 
Creating a Facebook Clone - Part VII.pdf
Creating a Facebook Clone - Part VII.pdfCreating a Facebook Clone - Part VII.pdf
Creating a Facebook Clone - Part VII.pdfShaiAlmog1
 
Creating a Facebook Clone - Part XXVIII.pdf
Creating a Facebook Clone - Part XXVIII.pdfCreating a Facebook Clone - Part XXVIII.pdf
Creating a Facebook Clone - Part XXVIII.pdfShaiAlmog1
 
Creating a Facebook Clone - Part XXVIII - Transcript.pdf
Creating a Facebook Clone - Part XXVIII - Transcript.pdfCreating a Facebook Clone - Part XXVIII - Transcript.pdf
Creating a Facebook Clone - Part XXVIII - Transcript.pdfShaiAlmog1
 
Advancing the UI — Part 1: Look, Motion, and Gestures
Advancing the UI — Part 1: Look, Motion, and GesturesAdvancing the UI — Part 1: Look, Motion, and Gestures
Advancing the UI — Part 1: Look, Motion, and GesturesSamsung Developers
 
Creating an Uber Clone - Part XXXX - Transcript.pdf
Creating an Uber Clone - Part XXXX - Transcript.pdfCreating an Uber Clone - Part XXXX - Transcript.pdf
Creating an Uber Clone - Part XXXX - Transcript.pdfShaiAlmog1
 
mobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkelingmobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkelingDevnology
 
Extracting ui Design - part 4 - transcript.pdf
Extracting ui Design - part 4 - transcript.pdfExtracting ui Design - part 4 - transcript.pdf
Extracting ui Design - part 4 - transcript.pdfShaiAlmog1
 
Different types of sticker apps
Different types of sticker appsDifferent types of sticker apps
Different types of sticker appsJelena Krmar
 

Similar to Adapting to Tablets and Desktops - Part 3 - Transcript.pdf (20)

Adapting to Tablets and Desktops - Part 1 - Transcript.pdf
Adapting to Tablets and Desktops - Part 1 - Transcript.pdfAdapting to Tablets and Desktops - Part 1 - Transcript.pdf
Adapting to Tablets and Desktops - Part 1 - Transcript.pdf
 
Adapting to Tablets and Desktops - Part 1.pdf
Adapting to Tablets and Desktops - Part 1.pdfAdapting to Tablets and Desktops - Part 1.pdf
Adapting to Tablets and Desktops - Part 1.pdf
 
Academy PRO: React native - building first scenes
Academy PRO: React native - building first scenesAcademy PRO: React native - building first scenes
Academy PRO: React native - building first scenes
 
Extracting ui Design - part 5 - transcript.pdf
Extracting ui Design - part 5 - transcript.pdfExtracting ui Design - part 5 - transcript.pdf
Extracting ui Design - part 5 - transcript.pdf
 
SQLite and ORM Binding - Part 2 - Transcript.pdf
SQLite and ORM Binding - Part 2 - Transcript.pdfSQLite and ORM Binding - Part 2 - Transcript.pdf
SQLite and ORM Binding - Part 2 - Transcript.pdf
 
Creating an Uber Clone - Part XXXIX.pdf
Creating an Uber Clone - Part XXXIX.pdfCreating an Uber Clone - Part XXXIX.pdf
Creating an Uber Clone - Part XXXIX.pdf
 
Miscellaneous Features - Part 3 - Transcript.pdf
Miscellaneous Features - Part 3 - Transcript.pdfMiscellaneous Features - Part 3 - Transcript.pdf
Miscellaneous Features - Part 3 - Transcript.pdf
 
Creating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdfCreating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdf
 
Creating an Uber Clone - Part XXXIV - Transcript.pdf
Creating an Uber Clone - Part XXXIV - Transcript.pdfCreating an Uber Clone - Part XXXIV - Transcript.pdf
Creating an Uber Clone - Part XXXIV - Transcript.pdf
 
Extracting ui Design - part 6 - transcript.pdf
Extracting ui Design - part 6 - transcript.pdfExtracting ui Design - part 6 - transcript.pdf
Extracting ui Design - part 6 - transcript.pdf
 
JSLab. Алексей Волков. "React на практике"
JSLab. Алексей Волков. "React на практике"JSLab. Алексей Волков. "React на практике"
JSLab. Алексей Волков. "React на практике"
 
Creating a Facebook Clone - Part VII.pdf
Creating a Facebook Clone - Part VII.pdfCreating a Facebook Clone - Part VII.pdf
Creating a Facebook Clone - Part VII.pdf
 
Creating a Facebook Clone - Part XXVIII.pdf
Creating a Facebook Clone - Part XXVIII.pdfCreating a Facebook Clone - Part XXVIII.pdf
Creating a Facebook Clone - Part XXVIII.pdf
 
Creating a Facebook Clone - Part XXVIII - Transcript.pdf
Creating a Facebook Clone - Part XXVIII - Transcript.pdfCreating a Facebook Clone - Part XXVIII - Transcript.pdf
Creating a Facebook Clone - Part XXVIII - Transcript.pdf
 
Team pdf ionic
Team pdf ionicTeam pdf ionic
Team pdf ionic
 
Advancing the UI — Part 1: Look, Motion, and Gestures
Advancing the UI — Part 1: Look, Motion, and GesturesAdvancing the UI — Part 1: Look, Motion, and Gestures
Advancing the UI — Part 1: Look, Motion, and Gestures
 
Creating an Uber Clone - Part XXXX - Transcript.pdf
Creating an Uber Clone - Part XXXX - Transcript.pdfCreating an Uber Clone - Part XXXX - Transcript.pdf
Creating an Uber Clone - Part XXXX - Transcript.pdf
 
mobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkelingmobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkeling
 
Extracting ui Design - part 4 - transcript.pdf
Extracting ui Design - part 4 - transcript.pdfExtracting ui Design - part 4 - transcript.pdf
Extracting ui Design - part 4 - transcript.pdf
 
Different types of sticker apps
Different types of sticker appsDifferent types of sticker apps
Different types of sticker apps
 

More from ShaiAlmog1

The Duck Teaches Learn to debug from the masters. Local to production- kill ...
The Duck Teaches  Learn to debug from the masters. Local to production- kill ...The Duck Teaches  Learn to debug from the masters. Local to production- kill ...
The Duck Teaches Learn to debug from the masters. Local to production- kill ...ShaiAlmog1
 
create-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdfcreate-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdfShaiAlmog1
 
create-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdfcreate-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdfShaiAlmog1
 
create-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdfcreate-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdfShaiAlmog1
 
create-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdfcreate-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdfShaiAlmog1
 
create-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfcreate-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfShaiAlmog1
 
create-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdfcreate-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdfShaiAlmog1
 
create-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfcreate-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfShaiAlmog1
 
create-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdfcreate-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdfShaiAlmog1
 
create-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdfcreate-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdfShaiAlmog1
 
create-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdfcreate-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdfShaiAlmog1
 
create-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfcreate-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfShaiAlmog1
 
create-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdfcreate-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdfCreating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdfCreating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfCreating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdfCreating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdfCreating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdfCreating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdfCreating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdfShaiAlmog1
 

More from ShaiAlmog1 (20)

The Duck Teaches Learn to debug from the masters. Local to production- kill ...
The Duck Teaches  Learn to debug from the masters. Local to production- kill ...The Duck Teaches  Learn to debug from the masters. Local to production- kill ...
The Duck Teaches Learn to debug from the masters. Local to production- kill ...
 
create-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdfcreate-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdf
 
create-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdfcreate-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdf
 
create-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdfcreate-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdf
 
create-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdfcreate-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdf
 
create-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfcreate-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdf
 
create-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdfcreate-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdf
 
create-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfcreate-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdf
 
create-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdfcreate-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdf
 
create-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdfcreate-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdf
 
create-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdfcreate-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdf
 
create-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfcreate-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdf
 
create-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdfcreate-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdf
 
Creating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdfCreating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdf
 
Creating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdfCreating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdf
 
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfCreating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdf
 
Creating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdfCreating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdf
 
Creating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdfCreating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdf
 
Creating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdfCreating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdf
 
Creating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdfCreating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdf
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 

Recently uploaded (20)

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

Adapting to Tablets and Desktops - Part 3 - Transcript.pdf

  • 1. Adapting to Tablets & Desktops - Part III In this module we dig into the TabletUI class
  • 2. public void start() { if(current != null){ current.show(); return; } AppSettings app = AppStorage.getInstance().fetchAppSettings(); if(app.logo.get() == null) { app.setLogo(theme.getImage("icon.png")); app.setTitleBackground(theme.getImage("title-image.jpg")); } if(Display.getInstance().isTablet()) { Toolbar.setPermanentSideMenu(true); new TabletUI(app); } BaseNavigationForm.showDishForm(app); Display.getInstance().callSerially(() -> { Display.getInstance().registerPush(new Hashtable(), true); }); } RestaurantAppBuilder The tablet UI is created by the main class of the application, we initialize it here so when base navigation form uses the generic code it would already be initialized. We also initialize the permanent side menu which makes the side menu stay open all the time without the button. That’s a UI paradigm that makes sense on tablets and desktops.
  • 3. public class TabletUI extends Form { private static TabletUI instance; public TabletUI(AppSettings app) { super(new BorderLayout()); instance = this; Toolbar tb = getToolbar(); Style titleStyle = tb.getUnselectedStyle(); titleStyle.setBorder(Border.createEmpty()); titleStyle.setBgImage(app.getTitleBackground()); titleStyle.setBackgroundType(Style.BACKGROUND_IMAGE_SCALED_FILL); titleStyle.setPaddingUnit(Style.UNIT_TYPE_DIPS); titleStyle.setPadding(4, 4, 4, 4); TextField title = new TextField(Restaurant.getInstance().name.get()); title.setUIID("NavigationTitle"); title.addActionListener(a -> { Restaurant.getInstance().name.set(title.getText()); new Builder().updateRestaurantSettings(app); }); TextField tagline = new TextField(Restaurant.getInstance().tagline.get()); tagline.setUIID("Tagline"); TabletUI The tablet UI class is a form that encapsulates the full layout on a tablet It’s a singleton because we have just one form in the application and one UI
  • 4. public class TabletUI extends Form { private static TabletUI instance; public TabletUI(AppSettings app) { super(new BorderLayout()); instance = this; Toolbar tb = getToolbar(); Style titleStyle = tb.getUnselectedStyle(); titleStyle.setBorder(Border.createEmpty()); titleStyle.setBgImage(app.getTitleBackground()); titleStyle.setBackgroundType(Style.BACKGROUND_IMAGE_SCALED_FILL); titleStyle.setPaddingUnit(Style.UNIT_TYPE_DIPS); titleStyle.setPadding(4, 4, 4, 4); TextField title = new TextField(Restaurant.getInstance().name.get()); title.setUIID("NavigationTitle"); title.addActionListener(a -> { Restaurant.getInstance().name.set(title.getText()); new Builder().updateRestaurantSettings(app); }); TextField tagline = new TextField(Restaurant.getInstance().tagline.get()); tagline.setUIID("Tagline"); TabletUI We use a border layout and place the content of the UI in the center so we can replace it when navigating between UIAbstraction instances
  • 5. public class TabletUI extends Form { private static TabletUI instance; public TabletUI(AppSettings app) { super(new BorderLayout()); instance = this; Toolbar tb = getToolbar(); Style titleStyle = tb.getUnselectedStyle(); titleStyle.setBorder(Border.createEmpty()); titleStyle.setBgImage(app.getTitleBackground()); titleStyle.setBackgroundType(Style.BACKGROUND_IMAGE_SCALED_FILL); titleStyle.setPaddingUnit(Style.UNIT_TYPE_DIPS); titleStyle.setPadding(4, 4, 4, 4); TextField title = new TextField(Restaurant.getInstance().name.get()); title.setUIID("NavigationTitle"); title.addActionListener(a -> { Restaurant.getInstance().name.set(title.getText()); new Builder().updateRestaurantSettings(app); }); TextField tagline = new TextField(Restaurant.getInstance().tagline.get()); tagline.setUIID("Tagline"); TabletUI The title and subtitle are editable here too, this is effectively a copy of the code from base navigation form adapted for the tablet form factor
  • 6. tagline.addActionListener(a -> { Restaurant.getInstance().tagline.set(tagline.getText()); new Builder().updateRestaurantSettings(app); }); tb.setTitleComponent(BoxLayout.encloseY(title, tagline)); Button logoImage = new Button("", app.getRoundedScaledLogo(), "TabletLogoImage"); logoImage.addActionListener(e -> { new ImagePickerForm(512, 512, "Icon", app.getLogo(), newImage -> { app.setLogo(newImage); logoImage.setIcon(app.getRoundedScaledLogo()); }).show(); }); tb.addComponentToSideMenu(logoImage); ButtonGroup bg = new ButtonGroup(); tb.addComponentToSideMenu(createSideNavigationEntry(bg, "Dish List", FontImage.MATERIAL_RESTAURANT_MENU, true, e -> BaseNavigationForm.showDishForm(app))); TabletUI This is also a copy from base navigation form, but thanks to the available space we don’t need to jump thru hoops to make this look good or fit. So the code here is much simpler
  • 7. tagline.addActionListener(a -> { Restaurant.getInstance().tagline.set(tagline.getText()); new Builder().updateRestaurantSettings(app); }); tb.setTitleComponent(BoxLayout.encloseY(title, tagline)); Button logoImage = new Button("", app.getRoundedScaledLogo(), "TabletLogoImage"); logoImage.addActionListener(e -> { new ImagePickerForm(512, 512, "Icon", app.getLogo(), newImage -> { app.setLogo(newImage); logoImage.setIcon(app.getRoundedScaledLogo()); }).show(); }); tb.addComponentToSideMenu(logoImage); ButtonGroup bg = new ButtonGroup(); tb.addComponentToSideMenu(createSideNavigationEntry(bg, "Dish List", FontImage.MATERIAL_RESTAURANT_MENU, true, e -> BaseNavigationForm.showDishForm(app))); TabletUI The logo image is now just an icon on the side menu which makes it look far better overall
  • 8. tb.addComponentToSideMenu(createSideNavigationEntry(bg, "Details", FontImage.MATERIAL_DESCRIPTION, e -> BaseNavigationForm.showDetailsForm(app))); tb.addComponentToSideMenu(createSideNavigationEntry(bg, "Billing", FontImage.MATERIAL_CREDIT_CARD, e -> BaseNavigationForm.showBillingForm(app))); tb.addComponentToSideMenu(createSideNavigationEntry(bg, "Build the App", FontImage.MATERIAL_PHONE_IPHONE, e -> BaseNavigationForm.showAppForm(app))); tb.addComponentToSideMenu(createSideNavigationEntry(bg, "About Us", FontImage.MATERIAL_INFO, e -> BaseNavigationForm.showAboutForm(app))); tb.addCommandToRightBar("Edit Background", null, e -> { new ImagePickerForm(750, 295, "Background Image", app.getTitleBackground(), newImage -> { app.setTitleBackground(newImage); titleStyle.setBgImage(newImage); }).show(); }); } TabletUI You’ll notice that all the side menu entries are marked here but I’ll only highlight one as they are all mostly the same. Since we don’t derive from the base navigation form this code is a bit duplicate but it’s much simpler as we don’t need the whole hack with marking the selection. Notice we aren’t adding commands but rather adding components using the generic createSideNavigationEntry method. We’ll discuss that method soon but notice the bg argument we pass to each one of them. That’s a button group and these methods return a radio button this allows us to have the selection effect
  • 9. tb.addComponentToSideMenu(createSideNavigationEntry(bg, "Details", FontImage.MATERIAL_DESCRIPTION, e -> BaseNavigationForm.showDetailsForm(app))); tb.addComponentToSideMenu(createSideNavigationEntry(bg, "Billing", FontImage.MATERIAL_CREDIT_CARD, e -> BaseNavigationForm.showBillingForm(app))); tb.addComponentToSideMenu(createSideNavigationEntry(bg, "Build the App", FontImage.MATERIAL_PHONE_IPHONE, e -> BaseNavigationForm.showAppForm(app))); tb.addComponentToSideMenu(createSideNavigationEntry(bg, "About Us", FontImage.MATERIAL_INFO, e -> BaseNavigationForm.showAboutForm(app))); tb.addCommandToRightBar("Edit Background", null, e -> { new ImagePickerForm(750, 295, "Background Image", app.getTitleBackground(), newImage -> { app.setTitleBackground(newImage); titleStyle.setBgImage(newImage); }).show(); }); } TabletUI We also add the edit background image button to the side, it’s relatively trivial as there isn’t that much we need to do here.
  • 10. private RadioButton createSideNavigationEntry(ButtonGroup bg, String title, char icon, ActionListener<ActionEvent> ac) { return createSideNavigationEntry(bg, title, icon, false, ac); } private RadioButton createSideNavigationEntry(ButtonGroup bg, String title, char icon, boolean selected, ActionListener<ActionEvent> ac) { RadioButton a = RadioButton.createToggle(title, bg); a.setSelected(selected); a.setUIID("SideCommand"); FontImage.setMaterialIcon(a, icon, 4); a.addActionListener(ac); return a; } void showContainer(Container cnt, boolean direction) { if(getContentPane().getComponentCount() == 0) { add(BorderLayout.CENTER, cnt); show(); } else { getContentPane().replace(getContentPane().getComponentAt(0), cnt, CommonTransitions.createCover(CommonTransitions.SLIDE_HORIZONTAL, direction, 150)); } } TabletUI createSideNavigationEntry just generalizes the code that creates a radio button toggle button. It mostly saves some boilerplate and doesn’t feature much logic
  • 11. private RadioButton createSideNavigationEntry(ButtonGroup bg, String title, char icon, ActionListener<ActionEvent> ac) { return createSideNavigationEntry(bg, title, icon, false, ac); } private RadioButton createSideNavigationEntry(ButtonGroup bg, String title, char icon, boolean selected, ActionListener<ActionEvent> ac) { RadioButton a = RadioButton.createToggle(title, bg); a.setSelected(selected); a.setUIID("SideCommand"); FontImage.setMaterialIcon(a, icon, 4); a.addActionListener(ac); return a; } void showContainer(Container cnt, boolean direction) { if(getContentPane().getComponentCount() == 0) { add(BorderLayout.CENTER, cnt); show(); } else { getContentPane().replace(getContentPane().getComponentAt(0), cnt, CommonTransitions.createCover(CommonTransitions.SLIDE_HORIZONTAL, direction, 150)); } } TabletUI However, showContainer is pretty interesting. It’s the method that’s effectively invoked when show() or showBack() are invoked. There are two modes here. For the very first screen we need to use add. From that point on we’ll always use replace to show the next UIAbstraction instance.