SlideShare a Scribd company logo
Extracting ui Design - part IV
Now that we reviewed the basic design elements lets apply this to the code
BaseForm
© Codename One 2017 all rights reserved
We will start with the base form which is a base class from which the top level forms will derive in the future
Toolbar tb = getToolbar();
tb.setUIID("Container");
tb.addSearchCommand(e -> onSearch((String)e.getSource()));
tb.addMaterialCommandToSideMenu("Shopping Cart", 

FontImage.MATERIAL_SHOPPING_CART, e -> {});
Label filler = new Label(" ");
filler.setPreferredSize(getTitleArea().getPreferredSize());
currentOrderValue = new Label("Your Order: " + 

L10NManager.getInstance().formatCurrency(0),
"YourOrder");
Button cart = new Button("", "ShoppingCart");
cart.addActionListener(e -> CheckoutForm.showCheckOut());
FontImage.setMaterialIcon(cart, FontImage.MATERIAL_SHOPPING_CART);
BaseForm
The init method of the base form initializes the common pieces including the search entry which is currently just a search command. It doesn’t do anything right now and
is there mostly for the icon
Toolbar tb = getToolbar();
tb.setUIID("Container");
tb.addSearchCommand(e -> onSearch((String)e.getSource()));
tb.addMaterialCommandToSideMenu("Shopping Cart", 

FontImage.MATERIAL_SHOPPING_CART, e -> {});
Label filler = new Label(" ");
filler.setPreferredSize(getTitleArea().getPreferredSize());
currentOrderValue = new Label("Your Order: " + 

L10NManager.getInstance().formatCurrency(0),
"YourOrder");
Button cart = new Button("", "ShoppingCart");
cart.addActionListener(e -> CheckoutForm.showCheckOut());
FontImage.setMaterialIcon(cart, FontImage.MATERIAL_SHOPPING_CART);
BaseForm
The PSD didn’t include a design for the side menu. It included only the icon indicating the side menu is there. I added a side menu entry to make the icon appear but it
doesn’t have any functionality or design.
Toolbar tb = getToolbar();
tb.setUIID("Container");
tb.addSearchCommand(e -> onSearch((String)e.getSource()));
tb.addMaterialCommandToSideMenu("Shopping Cart", 

FontImage.MATERIAL_SHOPPING_CART, e -> {});
Label filler = new Label(" ");
filler.setPreferredSize(getTitleArea().getPreferredSize());
currentOrderValue = new Label("Your Order: " + 

L10NManager.getInstance().formatCurrency(0),
"YourOrder");
Button cart = new Button("", "ShoppingCart");
cart.addActionListener(e -> CheckoutForm.showCheckOut());
FontImage.setMaterialIcon(cart, FontImage.MATERIAL_SHOPPING_CART);
BaseForm
I’ve mentioned the usage of a layered toolbar before. A layered toolbar “floats” on top which would mean the list of filters etc. would appear underneath it in normal
circumstances…

To avoid this I added a filler label that is as tall as the toolbar area and placed it in the top portion of the form, it pushes all the other elements downwards so they don’t
overlap with the title. The background image is a part of the style and will stay in place behind everything.
Toolbar tb = getToolbar();
tb.setUIID("Container");
tb.addSearchCommand(e -> onSearch((String)e.getSource()));
tb.addMaterialCommandToSideMenu("Shopping Cart", 

FontImage.MATERIAL_SHOPPING_CART, e -> {});
Label filler = new Label(" ");
filler.setPreferredSize(getTitleArea().getPreferredSize());
currentOrderValue = new Label("Your Order: " + 

L10NManager.getInstance().formatCurrency(0),
"YourOrder");
Button cart = new Button("", "ShoppingCart");
cart.addActionListener(e -> CheckoutForm.showCheckOut());
FontImage.setMaterialIcon(cart, FontImage.MATERIAL_SHOPPING_CART);
BaseForm
We discussed the YourOrder entry in the CSS but I would like to call out the fact that I used the localization manager to format the currency price here. That’s why price is
listed as ILS instead of USD. In this particular case this is probably wrong as prices should be delivered from the server with the currency type
Toolbar tb = getToolbar();
tb.setUIID("Container");
tb.addSearchCommand(e -> onSearch((String)e.getSource()));
tb.addMaterialCommandToSideMenu("Shopping Cart", 

FontImage.MATERIAL_SHOPPING_CART, e -> {});
Label filler = new Label(" ");
filler.setPreferredSize(getTitleArea().getPreferredSize());
currentOrderValue = new Label("Your Order: " + 

L10NManager.getInstance().formatCurrency(0),
"YourOrder");
Button cart = new Button("", "ShoppingCart");
cart.addActionListener(e -> CheckoutForm.showCheckOut());
FontImage.setMaterialIcon(cart, FontImage.MATERIAL_SHOPPING_CART);
BaseForm
We discussed the shopping cart style in the CSS too, notice we apply the shopping cart style before calling the material icon which effectively used the styles from the
CSS for the icon
Container orderBar = new Container(
new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE)) {
@Override
protected Dimension calcPreferredSize() {
Dimension d= super.calcPreferredSize();
if(d.getHeight() % 2 != 0) {
d.setHeight(d.getHeight() + 1);
}
return d;
}
};
orderBar.add(BorderLayout.CENTER, currentOrderValue).
add(BorderLayout.EAST, cart);
Label opaque = new Label("", "OrderBarBackgroundOpaque");
opaque.setShowEvenIfBlank(true);
Container orderBackgroundGrid = GridLayout.encloseIn(1,
new Container(), opaque);
Container orderLayers = LayeredLayout.encloseIn(orderBackgroundGrid,
orderBar);
BaseForm
This label is placed into a grid layout with a transparent container. So the top portion shows the background image and this label abstracts it creating the effect of a line
crossing. That way it looks like the shopping cart is peeking from the bottom of the UI… 

This almost works!
Container orderBar = new Container(
new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE)) {
@Override
protected Dimension calcPreferredSize() {
Dimension d= super.calcPreferredSize();
if(d.getHeight() % 2 != 0) {
d.setHeight(d.getHeight() + 1);
}
return d;
}
};
orderBar.add(BorderLayout.CENTER, currentOrderValue).
add(BorderLayout.EAST, cart);
Label opaque = new Label("", "OrderBarBackgroundOpaque");
opaque.setShowEvenIfBlank(true);
Container orderBackgroundGrid = GridLayout.encloseIn(1,
new Container(), opaque);
Container orderLayers = LayeredLayout.encloseIn(orderBackgroundGrid,
orderBar);
BaseForm
Remember when I mentioned “going overboard” I meant this part. 

The label in the grid layout trick almost worked and this is the workaround to get it to “work”. A grid layout takes two components and gives them the exact same size to
fill up available space. This works great except for cases where the size isn’t divisible by 2 in which case one pixel at the bottom remains “empty”. The workaround was
simple, make sure the size of the order bar is always even and that way the two components get exactly the same size, otherwise in some weird cases we’d have a line
of the image “peeking” in the bottom part.
List<String> categoryList = createCategoryList();
Container topBar;
if(categoryList != null) {
Label separator = new Label("", "WhiteSeparatorLine");
separator.setShowEvenIfBlank(true);
topBar = BoxLayout.encloseY(filler, categoryList,
FlowLayout.encloseCenter(separator),
orderLayers);
} else {
topBar = BoxLayout.encloseY(filler, orderLayers);
}
topBar.setUIID("TopBar");
add(BorderLayout.NORTH, topBar);
add(BorderLayout.CENTER, createContent());
BaseForm
The category list is just a list, it’s implemented in the actual form and not within the base form which is common to all the forms. So this method might return null as not
all forms will need that list
List<String> categoryList = createCategoryList();
Container topBar;
if(categoryList != null) {
Label separator = new Label("", "WhiteSeparatorLine");
separator.setShowEvenIfBlank(true);
topBar = BoxLayout.encloseY(filler, categoryList,
FlowLayout.encloseCenter(separator),
orderLayers);
} else {
topBar = BoxLayout.encloseY(filler, orderLayers);
}
topBar.setUIID("TopBar");
add(BorderLayout.NORTH, topBar);
add(BorderLayout.CENTER, createContent());
BaseForm
I mentioned the separator line in the CSS section but here I’d like to draw your attention to set show even if blank on the label. By default an empty label is completely
removed in Codename One. This helps achieve several design aesthetics. In this case we don’t want that behavior and we can disable that by using this method
List<String> categoryList = createCategoryList();
Container topBar;
if(categoryList != null) {
Label separator = new Label("", "WhiteSeparatorLine");
separator.setShowEvenIfBlank(true);
topBar = BoxLayout.encloseY(filler, categoryList,
FlowLayout.encloseCenter(separator),
orderLayers);
} else {
topBar = BoxLayout.encloseY(filler, orderLayers);
}
topBar.setUIID("TopBar");
add(BorderLayout.NORTH, topBar);
add(BorderLayout.CENTER, createContent());
BaseForm
You might recall the top bar from the CSS, it includes the title image fill style. Again notice that the portion that supposedly doesn’t have the title image showing still has
it… It’s just obscured. The whole title area is just placed in the north section of a border layout
List<String> categoryList = createCategoryList();
Container topBar;
if(categoryList != null) {
Label separator = new Label("", "WhiteSeparatorLine");
separator.setShowEvenIfBlank(true);
topBar = BoxLayout.encloseY(filler, categoryList,
FlowLayout.encloseCenter(separator),
orderLayers);
} else {
topBar = BoxLayout.encloseY(filler, orderLayers);
}
topBar.setUIID("TopBar");
add(BorderLayout.NORTH, topBar);
add(BorderLayout.CENTER, createContent());
BaseForm
The content differs from form to form so this is the content of the main form and isn’t implemented here. We are just invoking the method of the sub class

More Related Content

Similar to Extracting ui Design - part 4 - transcript.pdf

Miscellaneous Features - Part 1.pdf
Miscellaneous Features - Part 1.pdfMiscellaneous Features - Part 1.pdf
Miscellaneous Features - Part 1.pdf
ShaiAlmog1
 
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
ShaiAlmog1
 
Creating a Facebook Clone - Part VI.pdf
Creating a Facebook Clone - Part VI.pdfCreating a Facebook Clone - Part VI.pdf
Creating a Facebook Clone - Part VI.pdf
ShaiAlmog1
 
I finished most of the program, but having trouble with some key fea.pdf
I finished most of the program, but having trouble with some key fea.pdfI finished most of the program, but having trouble with some key fea.pdf
I finished most of the program, but having trouble with some key fea.pdf
hardjasonoco14599
 
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
ShaiAlmog1
 
Initial UI Mockup - Part 2 - Transcript.pdf
Initial UI Mockup - Part 2 - Transcript.pdfInitial UI Mockup - Part 2 - Transcript.pdf
Initial UI Mockup - Part 2 - Transcript.pdf
ShaiAlmog1
 
Miscellaneous Features - Part 1 - Transcript.pdf
Miscellaneous Features - Part 1 - Transcript.pdfMiscellaneous Features - Part 1 - Transcript.pdf
Miscellaneous Features - Part 1 - Transcript.pdf
ShaiAlmog1
 
Architecture - Part 2 - Transcript.pdf
Architecture - Part 2 - Transcript.pdfArchitecture - Part 2 - Transcript.pdf
Architecture - Part 2 - Transcript.pdf
ShaiAlmog1
 
Creating an Uber Clone - Part V - Transcript.pdf
Creating an Uber Clone - Part V - Transcript.pdfCreating an Uber Clone - Part V - Transcript.pdf
Creating an Uber Clone - Part V - Transcript.pdf
ShaiAlmog1
 
Adapting to Tablets and Desktops - Part 3 - Transcript.pdf
Adapting to Tablets and Desktops - Part 3 - Transcript.pdfAdapting to Tablets and Desktops - Part 3 - Transcript.pdf
Adapting to Tablets and Desktops - Part 3 - Transcript.pdf
ShaiAlmog1
 
Ajava oep shopping application
Ajava oep shopping applicationAjava oep shopping application
Ajava oep shopping application
Paneliya Prince
 
Initial UI Mockup - Part 3.pdf
Initial UI Mockup - Part 3.pdfInitial UI Mockup - Part 3.pdf
Initial UI Mockup - Part 3.pdf
ShaiAlmog1
 
UI Design From Scratch - Part 5 - transcript.pdf
UI Design From Scratch - Part 5 - transcript.pdfUI Design From Scratch - Part 5 - transcript.pdf
UI Design From Scratch - Part 5 - transcript.pdf
ShaiAlmog1
 
How do I - Create a List of Items - Transcript.pdf
How do I - Create a List of Items - Transcript.pdfHow do I - Create a List of Items - Transcript.pdf
How do I - Create a List of Items - Transcript.pdf
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 
Initial UI Mockup - Part 2.pdf
Initial UI Mockup - Part 2.pdfInitial UI Mockup - Part 2.pdf
Initial UI Mockup - Part 2.pdf
ShaiAlmog1
 
Future of UI Automation testing and JDI
Future of UI Automation testing and JDIFuture of UI Automation testing and JDI
Future of UI Automation testing and JDI
COMAQA.BY
 
Creating an Uber Clone - Part VIII - Transcript.pdf
Creating an Uber Clone - Part VIII - Transcript.pdfCreating an Uber Clone - Part VIII - Transcript.pdf
Creating an Uber Clone - Part VIII - Transcript.pdf
ShaiAlmog1
 
16-DOMTree.pptx
16-DOMTree.pptx16-DOMTree.pptx
16-DOMTree.pptx
KhushiSingla10
 

Similar to Extracting ui Design - part 4 - transcript.pdf (20)

Miscellaneous Features - Part 1.pdf
Miscellaneous Features - Part 1.pdfMiscellaneous Features - Part 1.pdf
Miscellaneous Features - Part 1.pdf
 
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
 
Creating a Facebook Clone - Part VI.pdf
Creating a Facebook Clone - Part VI.pdfCreating a Facebook Clone - Part VI.pdf
Creating a Facebook Clone - Part VI.pdf
 
I finished most of the program, but having trouble with some key fea.pdf
I finished most of the program, but having trouble with some key fea.pdfI finished most of the program, but having trouble with some key fea.pdf
I finished most of the program, but having trouble with some key fea.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
 
Initial UI Mockup - Part 2 - Transcript.pdf
Initial UI Mockup - Part 2 - Transcript.pdfInitial UI Mockup - Part 2 - Transcript.pdf
Initial UI Mockup - Part 2 - Transcript.pdf
 
Miscellaneous Features - Part 1 - Transcript.pdf
Miscellaneous Features - Part 1 - Transcript.pdfMiscellaneous Features - Part 1 - Transcript.pdf
Miscellaneous Features - Part 1 - Transcript.pdf
 
Architecture - Part 2 - Transcript.pdf
Architecture - Part 2 - Transcript.pdfArchitecture - Part 2 - Transcript.pdf
Architecture - Part 2 - Transcript.pdf
 
Creating an Uber Clone - Part V - Transcript.pdf
Creating an Uber Clone - Part V - Transcript.pdfCreating an Uber Clone - Part V - Transcript.pdf
Creating an Uber Clone - Part V - Transcript.pdf
 
Adapting to Tablets and Desktops - Part 3 - Transcript.pdf
Adapting to Tablets and Desktops - Part 3 - Transcript.pdfAdapting to Tablets and Desktops - Part 3 - Transcript.pdf
Adapting to Tablets and Desktops - Part 3 - Transcript.pdf
 
Ajava oep shopping application
Ajava oep shopping applicationAjava oep shopping application
Ajava oep shopping application
 
Initial UI Mockup - Part 3.pdf
Initial UI Mockup - Part 3.pdfInitial UI Mockup - Part 3.pdf
Initial UI Mockup - Part 3.pdf
 
UI Design From Scratch - Part 5 - transcript.pdf
UI Design From Scratch - Part 5 - transcript.pdfUI Design From Scratch - Part 5 - transcript.pdf
UI Design From Scratch - Part 5 - transcript.pdf
 
How do I - Create a List of Items - Transcript.pdf
How do I - Create a List of Items - Transcript.pdfHow do I - Create a List of Items - Transcript.pdf
How do I - Create a List of Items - 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 XXXIX.pdf
Creating an Uber Clone - Part XXXIX.pdfCreating an Uber Clone - Part XXXIX.pdf
Creating an Uber Clone - Part XXXIX.pdf
 
Initial UI Mockup - Part 2.pdf
Initial UI Mockup - Part 2.pdfInitial UI Mockup - Part 2.pdf
Initial UI Mockup - Part 2.pdf
 
Future of UI Automation testing and JDI
Future of UI Automation testing and JDIFuture of UI Automation testing and JDI
Future of UI Automation testing and JDI
 
Creating an Uber Clone - Part VIII - Transcript.pdf
Creating an Uber Clone - Part VIII - Transcript.pdfCreating an Uber Clone - Part VIII - Transcript.pdf
Creating an Uber Clone - Part VIII - Transcript.pdf
 
16-DOMTree.pptx
16-DOMTree.pptx16-DOMTree.pptx
16-DOMTree.pptx
 

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.pdf
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 
create-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfcreate-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdf
ShaiAlmog1
 
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
ShaiAlmog1
 
create-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfcreate-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdf
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 
create-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfcreate-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdf
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 

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

Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 

Recently uploaded (20)

Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 

Extracting ui Design - part 4 - transcript.pdf

  • 1. Extracting ui Design - part IV Now that we reviewed the basic design elements lets apply this to the code
  • 2. BaseForm © Codename One 2017 all rights reserved We will start with the base form which is a base class from which the top level forms will derive in the future
  • 3. Toolbar tb = getToolbar(); tb.setUIID("Container"); tb.addSearchCommand(e -> onSearch((String)e.getSource())); tb.addMaterialCommandToSideMenu("Shopping Cart", 
 FontImage.MATERIAL_SHOPPING_CART, e -> {}); Label filler = new Label(" "); filler.setPreferredSize(getTitleArea().getPreferredSize()); currentOrderValue = new Label("Your Order: " + 
 L10NManager.getInstance().formatCurrency(0), "YourOrder"); Button cart = new Button("", "ShoppingCart"); cart.addActionListener(e -> CheckoutForm.showCheckOut()); FontImage.setMaterialIcon(cart, FontImage.MATERIAL_SHOPPING_CART); BaseForm The init method of the base form initializes the common pieces including the search entry which is currently just a search command. It doesn’t do anything right now and is there mostly for the icon
  • 4. Toolbar tb = getToolbar(); tb.setUIID("Container"); tb.addSearchCommand(e -> onSearch((String)e.getSource())); tb.addMaterialCommandToSideMenu("Shopping Cart", 
 FontImage.MATERIAL_SHOPPING_CART, e -> {}); Label filler = new Label(" "); filler.setPreferredSize(getTitleArea().getPreferredSize()); currentOrderValue = new Label("Your Order: " + 
 L10NManager.getInstance().formatCurrency(0), "YourOrder"); Button cart = new Button("", "ShoppingCart"); cart.addActionListener(e -> CheckoutForm.showCheckOut()); FontImage.setMaterialIcon(cart, FontImage.MATERIAL_SHOPPING_CART); BaseForm The PSD didn’t include a design for the side menu. It included only the icon indicating the side menu is there. I added a side menu entry to make the icon appear but it doesn’t have any functionality or design.
  • 5. Toolbar tb = getToolbar(); tb.setUIID("Container"); tb.addSearchCommand(e -> onSearch((String)e.getSource())); tb.addMaterialCommandToSideMenu("Shopping Cart", 
 FontImage.MATERIAL_SHOPPING_CART, e -> {}); Label filler = new Label(" "); filler.setPreferredSize(getTitleArea().getPreferredSize()); currentOrderValue = new Label("Your Order: " + 
 L10NManager.getInstance().formatCurrency(0), "YourOrder"); Button cart = new Button("", "ShoppingCart"); cart.addActionListener(e -> CheckoutForm.showCheckOut()); FontImage.setMaterialIcon(cart, FontImage.MATERIAL_SHOPPING_CART); BaseForm I’ve mentioned the usage of a layered toolbar before. A layered toolbar “floats” on top which would mean the list of filters etc. would appear underneath it in normal circumstances…
 To avoid this I added a filler label that is as tall as the toolbar area and placed it in the top portion of the form, it pushes all the other elements downwards so they don’t overlap with the title. The background image is a part of the style and will stay in place behind everything.
  • 6. Toolbar tb = getToolbar(); tb.setUIID("Container"); tb.addSearchCommand(e -> onSearch((String)e.getSource())); tb.addMaterialCommandToSideMenu("Shopping Cart", 
 FontImage.MATERIAL_SHOPPING_CART, e -> {}); Label filler = new Label(" "); filler.setPreferredSize(getTitleArea().getPreferredSize()); currentOrderValue = new Label("Your Order: " + 
 L10NManager.getInstance().formatCurrency(0), "YourOrder"); Button cart = new Button("", "ShoppingCart"); cart.addActionListener(e -> CheckoutForm.showCheckOut()); FontImage.setMaterialIcon(cart, FontImage.MATERIAL_SHOPPING_CART); BaseForm We discussed the YourOrder entry in the CSS but I would like to call out the fact that I used the localization manager to format the currency price here. That’s why price is listed as ILS instead of USD. In this particular case this is probably wrong as prices should be delivered from the server with the currency type
  • 7. Toolbar tb = getToolbar(); tb.setUIID("Container"); tb.addSearchCommand(e -> onSearch((String)e.getSource())); tb.addMaterialCommandToSideMenu("Shopping Cart", 
 FontImage.MATERIAL_SHOPPING_CART, e -> {}); Label filler = new Label(" "); filler.setPreferredSize(getTitleArea().getPreferredSize()); currentOrderValue = new Label("Your Order: " + 
 L10NManager.getInstance().formatCurrency(0), "YourOrder"); Button cart = new Button("", "ShoppingCart"); cart.addActionListener(e -> CheckoutForm.showCheckOut()); FontImage.setMaterialIcon(cart, FontImage.MATERIAL_SHOPPING_CART); BaseForm We discussed the shopping cart style in the CSS too, notice we apply the shopping cart style before calling the material icon which effectively used the styles from the CSS for the icon
  • 8. Container orderBar = new Container( new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE)) { @Override protected Dimension calcPreferredSize() { Dimension d= super.calcPreferredSize(); if(d.getHeight() % 2 != 0) { d.setHeight(d.getHeight() + 1); } return d; } }; orderBar.add(BorderLayout.CENTER, currentOrderValue). add(BorderLayout.EAST, cart); Label opaque = new Label("", "OrderBarBackgroundOpaque"); opaque.setShowEvenIfBlank(true); Container orderBackgroundGrid = GridLayout.encloseIn(1, new Container(), opaque); Container orderLayers = LayeredLayout.encloseIn(orderBackgroundGrid, orderBar); BaseForm This label is placed into a grid layout with a transparent container. So the top portion shows the background image and this label abstracts it creating the effect of a line crossing. That way it looks like the shopping cart is peeking from the bottom of the UI… 
 This almost works!
  • 9. Container orderBar = new Container( new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE)) { @Override protected Dimension calcPreferredSize() { Dimension d= super.calcPreferredSize(); if(d.getHeight() % 2 != 0) { d.setHeight(d.getHeight() + 1); } return d; } }; orderBar.add(BorderLayout.CENTER, currentOrderValue). add(BorderLayout.EAST, cart); Label opaque = new Label("", "OrderBarBackgroundOpaque"); opaque.setShowEvenIfBlank(true); Container orderBackgroundGrid = GridLayout.encloseIn(1, new Container(), opaque); Container orderLayers = LayeredLayout.encloseIn(orderBackgroundGrid, orderBar); BaseForm Remember when I mentioned “going overboard” I meant this part. The label in the grid layout trick almost worked and this is the workaround to get it to “work”. A grid layout takes two components and gives them the exact same size to fill up available space. This works great except for cases where the size isn’t divisible by 2 in which case one pixel at the bottom remains “empty”. The workaround was simple, make sure the size of the order bar is always even and that way the two components get exactly the same size, otherwise in some weird cases we’d have a line of the image “peeking” in the bottom part.
  • 10. List<String> categoryList = createCategoryList(); Container topBar; if(categoryList != null) { Label separator = new Label("", "WhiteSeparatorLine"); separator.setShowEvenIfBlank(true); topBar = BoxLayout.encloseY(filler, categoryList, FlowLayout.encloseCenter(separator), orderLayers); } else { topBar = BoxLayout.encloseY(filler, orderLayers); } topBar.setUIID("TopBar"); add(BorderLayout.NORTH, topBar); add(BorderLayout.CENTER, createContent()); BaseForm The category list is just a list, it’s implemented in the actual form and not within the base form which is common to all the forms. So this method might return null as not all forms will need that list
  • 11. List<String> categoryList = createCategoryList(); Container topBar; if(categoryList != null) { Label separator = new Label("", "WhiteSeparatorLine"); separator.setShowEvenIfBlank(true); topBar = BoxLayout.encloseY(filler, categoryList, FlowLayout.encloseCenter(separator), orderLayers); } else { topBar = BoxLayout.encloseY(filler, orderLayers); } topBar.setUIID("TopBar"); add(BorderLayout.NORTH, topBar); add(BorderLayout.CENTER, createContent()); BaseForm I mentioned the separator line in the CSS section but here I’d like to draw your attention to set show even if blank on the label. By default an empty label is completely removed in Codename One. This helps achieve several design aesthetics. In this case we don’t want that behavior and we can disable that by using this method
  • 12. List<String> categoryList = createCategoryList(); Container topBar; if(categoryList != null) { Label separator = new Label("", "WhiteSeparatorLine"); separator.setShowEvenIfBlank(true); topBar = BoxLayout.encloseY(filler, categoryList, FlowLayout.encloseCenter(separator), orderLayers); } else { topBar = BoxLayout.encloseY(filler, orderLayers); } topBar.setUIID("TopBar"); add(BorderLayout.NORTH, topBar); add(BorderLayout.CENTER, createContent()); BaseForm You might recall the top bar from the CSS, it includes the title image fill style. Again notice that the portion that supposedly doesn’t have the title image showing still has it… It’s just obscured. The whole title area is just placed in the north section of a border layout
  • 13. List<String> categoryList = createCategoryList(); Container topBar; if(categoryList != null) { Label separator = new Label("", "WhiteSeparatorLine"); separator.setShowEvenIfBlank(true); topBar = BoxLayout.encloseY(filler, categoryList, FlowLayout.encloseCenter(separator), orderLayers); } else { topBar = BoxLayout.encloseY(filler, orderLayers); } topBar.setUIID("TopBar"); add(BorderLayout.NORTH, topBar); add(BorderLayout.CENTER, createContent()); BaseForm The content differs from form to form so this is the content of the main form and isn’t implemented here. We are just invoking the method of the sub class