SlideShare a Scribd company logo
Creating an Uber Clone - Part III
Country Button
© Codename One 2017 all rights reserved
Country Button
© Codename One 2017 all rights reserved
public class CountryCodePicker extends Button {
private Resources flagResource;
public CountryCodePicker() {
setUIID("CountryCodePicker");
addActionListener(e -> showPickerForm());
String code = L10NManager.getInstance().getLocale();
if(code != null) {
String[] countryCodes;
if(code.length() == 2) {
countryCodes = COUNTRY_ISO2;
} else {
if(code.length() == 3) {
countryCodes = COUNTRY_ISO3;
} else {
return;
}
}
code = code.toUpperCase();
try {
flagResource = Resources.open("/flags.res");
} catch(IOException err) {
CountryCodePicker
public class CountryCodePicker extends Button {
private Resources flagResource;
public CountryCodePicker() {
setUIID("CountryCodePicker");
addActionListener(e -> showPickerForm());
String code = L10NManager.getInstance().getLocale();
if(code != null) {
String[] countryCodes;
if(code.length() == 2) {
countryCodes = COUNTRY_ISO2;
} else {
if(code.length() == 3) {
countryCodes = COUNTRY_ISO3;
} else {
return;
}
}
code = code.toUpperCase();
try {
flagResource = Resources.open("/flags.res");
} catch(IOException err) {
CountryCodePicker
public class CountryCodePicker extends Button {
private Resources flagResource;
public CountryCodePicker() {
setUIID("CountryCodePicker");
addActionListener(e -> showPickerForm());
String code = L10NManager.getInstance().getLocale();
if(code != null) {
String[] countryCodes;
if(code.length() == 2) {
countryCodes = COUNTRY_ISO2;
} else {
if(code.length() == 3) {
countryCodes = COUNTRY_ISO3;
} else {
return;
}
}
code = code.toUpperCase();
try {
flagResource = Resources.open("/flags.res");
} catch(IOException err) {
CountryCodePicker
public class CountryCodePicker extends Button {
private Resources flagResource;
public CountryCodePicker() {
setUIID("CountryCodePicker");
addActionListener(e -> showPickerForm());
String code = L10NManager.getInstance().getLocale();
if(code != null) {
String[] countryCodes;
if(code.length() == 2) {
countryCodes = COUNTRY_ISO2;
} else {
if(code.length() == 3) {
countryCodes = COUNTRY_ISO3;
} else {
return;
}
}
code = code.toUpperCase();
try {
flagResource = Resources.open("/flags.res");
} catch(IOException err) {
CountryCodePicker
try {
flagResource = Resources.open("/flags.res");
} catch(IOException err) {
Log.e(err);
}
Image blankIcon = Image.createImage(100, 70, 0);
for(int iter = 0 ; iter < countryCodes.length ; iter++) {
if(code.equals(countryCodes[iter])) {
setText("+" + COUNTRY_CODES[iter]);
setIcon(flagResource.getImage(COUNTRY_FLAGS[iter]));
if(getIcon() == null) {
setIcon(blankIcon);
}
return;
}
}
}
}
protected void showPickerForm() {
final Form f = getCurrentForm();
final Transition t = f.getTransitionOutAnimator();
CountryCodePicker
setIcon(blankIcon);
}
return;
}
}
}
}
protected void showPickerForm() {
final Form f = getCurrentForm();
final Transition t = f.getTransitionOutAnimator();
f.setTransitionOutAnimator(CommonTransitions.createEmpty());
Form tf = new CountryPickerForm(this, flagResource);
tf.addShowListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
f.setTransitionOutAnimator(t);
f.removeShowListener(this);
}
});
tf.show();
}
CountryCodePicker
CountryCodePicker
© Codename One 2017 all rights reserved
CountryCodePicker
© Codename One 2017 all rights reserved
CountryCodePicker
© Codename One 2017 all rights reserved
CountryCodePicker
© Codename One 2017 all rights reserved
public class LoginForm extends Form {
public LoginForm() {
super(new BorderLayout());
Label squareLogo = new Label("",
Resources.getGlobalResources().getImage("uber-logo.png"),
"SquareLogo") {
@Override
protected Dimension calcPreferredSize() {
Dimension size = super.calcPreferredSize();
size.setHeight(size.getWidth());
return size;
}
};
Container logo = BorderLayout.centerAbsolute(squareLogo);
logo.setUIID("LogoBackground");
add(CENTER, logo);
Label getMovingWithUber = new Label("Get moving with Uber", "GetMovingWithUber");
CountryCodePicker countryCodeButton = new CountryCodePicker() {
@Override
LoginForm
public class LoginForm extends Form {
public LoginForm() {
super(new BorderLayout());
Label squareLogo = new Label("",
Resources.getGlobalResources().getImage("uber-logo.png"),
"SquareLogo") {
@Override
protected Dimension calcPreferredSize() {
Dimension size = super.calcPreferredSize();
size.setHeight(size.getWidth());
return size;
}
};
Container logo = BorderLayout.centerAbsolute(squareLogo);
logo.setUIID("LogoBackground");
add(CENTER, logo);
Label getMovingWithUber = new Label("Get moving with Uber", "GetMovingWithUber");
CountryCodePicker countryCodeButton = new CountryCodePicker() {
@Override
LoginForm
public class LoginForm extends Form {
public LoginForm() {
super(new BorderLayout());
Label squareLogo = new Label("",
Resources.getGlobalResources().getImage("uber-logo.png"),
"SquareLogo") {
@Override
protected Dimension calcPreferredSize() {
Dimension size = super.calcPreferredSize();
size.setHeight(size.getWidth());
return size;
}
};
Container logo = BorderLayout.centerAbsolute(squareLogo);
logo.setUIID("LogoBackground");
add(CENTER, logo);
Label getMovingWithUber = new Label("Get moving with Uber", "GetMovingWithUber");
CountryCodePicker countryCodeButton = new CountryCodePicker() {
@Override
LoginForm
CountryCodePicker countryCodeButton = new CountryCodePicker() {
@Override
protected void showPickerForm() {
new EnterMobileNumberForm().show();
}
};
SpanButton phoneNumber = new SpanButton("Enter your mobile number",
"PhoneNumberHint");
phoneNumber.getTextComponent().setColumns(80);
phoneNumber.getTextComponent().setRows(2);
phoneNumber.getTextComponent().setGrowByContent(false);
phoneNumber.setUIID("Container");
phoneNumber.addActionListener(e -> new EnterMobileNumberForm().show());
Container phonePicking = BorderLayout.centerCenterEastWest(
phoneNumber,
null, countryCodeButton);
phonePicking.setUIID("Separator");
Button social = new Button("Or connect with social", "ConnectWithSocialButton");
social.addActionListener(e -> new FacebookOrGoogleLoginForm().show());
LoginForm
CountryCodePicker countryCodeButton = new CountryCodePicker() {
@Override
protected void showPickerForm() {
new EnterMobileNumberForm().show();
}
};
SpanButton phoneNumber = new SpanButton("Enter your mobile number",
"PhoneNumberHint");
phoneNumber.getTextComponent().setColumns(80);
phoneNumber.getTextComponent().setRows(2);
phoneNumber.getTextComponent().setGrowByContent(false);
phoneNumber.setUIID("Container");
phoneNumber.addActionListener(e -> new EnterMobileNumberForm().show());
Container phonePicking = BorderLayout.centerCenterEastWest(
phoneNumber,
null, countryCodeButton);
phonePicking.setUIID("Separator");
Button social = new Button("Or connect with social", "ConnectWithSocialButton");
social.addActionListener(e -> new FacebookOrGoogleLoginForm().show());
LoginForm
phoneNumber.addActionListener(e -> new EnterMobileNumberForm().show());
Container phonePicking = BorderLayout.centerCenterEastWest(
phoneNumber,
null, countryCodeButton);
phonePicking.setUIID("Separator");
Button social = new Button("Or connect with social", "ConnectWithSocialButton");
social.addActionListener(e -> new FacebookOrGoogleLoginForm().show());
add(SOUTH, BoxLayout.encloseY(getMovingWithUber, phonePicking, social));
}
@Override
protected boolean shouldPaintStatusBar() {
return false;
}
@Override
protected void initGlobalToolbar() {
}
}
LoginForm
Tile & Logo
© Codename One 2017 all rights reserved
Square Logo
© Codename One 2017 all rights reserved
Square Logo
© Codename One 2017 all rights reserved
Square Logo
© Codename One 2017 all rights reserved
LogoBackground
© Codename One 2017 all rights reserved
LogoBackground
© Codename One 2017 all rights reserved
LogoBackground
© Codename One 2017 all rights reserved
GetMovingWithUber
© Codename One 2017 all rights reserved
GetMovingWithUber
© Codename One 2017 all rights reserved
GetMovingWithUber
© Codename One 2017 all rights reserved
PhoneNumberHint
© Codename One 2017 all rights reserved
PhoneNumberHint
© Codename One 2017 all rights reserved
PhoneNumberHint
© Codename One 2017 all rights reserved
Separator
© Codename One 2017 all rights reserved
Separator
© Codename One 2017 all rights reserved
Separator
© Codename One 2017 all rights reserved
Separator
© Codename One 2017 all rights reserved
ConnectWithSocialButton
© Codename One 2017 all rights reserved
ConnectWithSocialButton
© Codename One 2017 all rights reserved
ConnectWithSocialButton
© Codename One 2017 all rights reserved
ConnectWithSocialButton
© Codename One 2017 all rights reserved
The Login Form
© Codename One 2017 all rights reserved

More Related Content

PDF
Creating an Uber Clone - Part III - Transcript.pdf
PDF
Creating an Uber Clone - Part V.pdf
PDF
Creating an Uber Clone - Part V - Transcript.pdf
PDF
Creating an Uber - Part VI - Transcript.pdf
PDF
Creating an Uber - Part VI.pdf
PDF
Creating a Facebook Clone - Part XXVIII - Transcript.pdf
PDF
Creating a Facebook Clone - Part VIII.pdf
PDF
The Duck Teaches Learn to debug from the masters. Local to production- kill ...
Creating an Uber Clone - Part III - Transcript.pdf
Creating an Uber Clone - Part V.pdf
Creating an Uber Clone - Part V - Transcript.pdf
Creating an Uber - Part VI - Transcript.pdf
Creating an Uber - Part VI.pdf
Creating a Facebook Clone - Part XXVIII - Transcript.pdf
Creating a Facebook Clone - Part VIII.pdf
The Duck Teaches Learn to debug from the masters. Local to production- kill ...

More from ShaiAlmog1 (20)

PDF
create-netflix-clone-06-client-ui.pdf
PDF
create-netflix-clone-01-introduction_transcript.pdf
PDF
create-netflix-clone-02-server_transcript.pdf
PDF
create-netflix-clone-04-server-continued_transcript.pdf
PDF
create-netflix-clone-01-introduction.pdf
PDF
create-netflix-clone-06-client-ui_transcript.pdf
PDF
create-netflix-clone-03-server.pdf
PDF
create-netflix-clone-04-server-continued.pdf
PDF
create-netflix-clone-05-client-model_transcript.pdf
PDF
create-netflix-clone-03-server_transcript.pdf
PDF
create-netflix-clone-02-server.pdf
PDF
create-netflix-clone-05-client-model.pdf
PDF
Creating a Whatsapp Clone - Part II.pdf
PDF
Creating a Whatsapp Clone - Part IX - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part II - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part V - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part IV - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part IV.pdf
PDF
Creating a Whatsapp Clone - Part I - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part IX.pdf
create-netflix-clone-06-client-ui.pdf
create-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-02-server_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-01-introduction.pdf
create-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-03-server.pdf
create-netflix-clone-04-server-continued.pdf
create-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-03-server_transcript.pdf
create-netflix-clone-02-server.pdf
create-netflix-clone-05-client-model.pdf
Creating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part IX.pdf
Ad

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
cuic standard and advanced reporting.pdf
PPTX
Machine Learning_overview_presentation.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Encapsulation theory and applications.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Spectroscopy.pptx food analysis technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Cloud computing and distributed systems.
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
A Presentation on Artificial Intelligence
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Empathic Computing: Creating Shared Understanding
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
cuic standard and advanced reporting.pdf
Machine Learning_overview_presentation.pptx
The AUB Centre for AI in Media Proposal.docx
Per capita expenditure prediction using model stacking based on satellite ima...
Encapsulation theory and applications.pdf
Review of recent advances in non-invasive hemoglobin estimation
Spectroscopy.pptx food analysis technology
Encapsulation_ Review paper, used for researhc scholars
Digital-Transformation-Roadmap-for-Companies.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Network Security Unit 5.pdf for BCA BBA.
Cloud computing and distributed systems.
sap open course for s4hana steps from ECC to s4
Programs and apps: productivity, graphics, security and other tools
A Presentation on Artificial Intelligence
Mobile App Security Testing_ A Comprehensive Guide.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Ad

Creating an Uber Clone - Part III.pdf

  • 1. Creating an Uber Clone - Part III
  • 2. Country Button © Codename One 2017 all rights reserved
  • 3. Country Button © Codename One 2017 all rights reserved
  • 4. public class CountryCodePicker extends Button { private Resources flagResource; public CountryCodePicker() { setUIID("CountryCodePicker"); addActionListener(e -> showPickerForm()); String code = L10NManager.getInstance().getLocale(); if(code != null) { String[] countryCodes; if(code.length() == 2) { countryCodes = COUNTRY_ISO2; } else { if(code.length() == 3) { countryCodes = COUNTRY_ISO3; } else { return; } } code = code.toUpperCase(); try { flagResource = Resources.open("/flags.res"); } catch(IOException err) { CountryCodePicker
  • 5. public class CountryCodePicker extends Button { private Resources flagResource; public CountryCodePicker() { setUIID("CountryCodePicker"); addActionListener(e -> showPickerForm()); String code = L10NManager.getInstance().getLocale(); if(code != null) { String[] countryCodes; if(code.length() == 2) { countryCodes = COUNTRY_ISO2; } else { if(code.length() == 3) { countryCodes = COUNTRY_ISO3; } else { return; } } code = code.toUpperCase(); try { flagResource = Resources.open("/flags.res"); } catch(IOException err) { CountryCodePicker
  • 6. public class CountryCodePicker extends Button { private Resources flagResource; public CountryCodePicker() { setUIID("CountryCodePicker"); addActionListener(e -> showPickerForm()); String code = L10NManager.getInstance().getLocale(); if(code != null) { String[] countryCodes; if(code.length() == 2) { countryCodes = COUNTRY_ISO2; } else { if(code.length() == 3) { countryCodes = COUNTRY_ISO3; } else { return; } } code = code.toUpperCase(); try { flagResource = Resources.open("/flags.res"); } catch(IOException err) { CountryCodePicker
  • 7. public class CountryCodePicker extends Button { private Resources flagResource; public CountryCodePicker() { setUIID("CountryCodePicker"); addActionListener(e -> showPickerForm()); String code = L10NManager.getInstance().getLocale(); if(code != null) { String[] countryCodes; if(code.length() == 2) { countryCodes = COUNTRY_ISO2; } else { if(code.length() == 3) { countryCodes = COUNTRY_ISO3; } else { return; } } code = code.toUpperCase(); try { flagResource = Resources.open("/flags.res"); } catch(IOException err) { CountryCodePicker
  • 8. try { flagResource = Resources.open("/flags.res"); } catch(IOException err) { Log.e(err); } Image blankIcon = Image.createImage(100, 70, 0); for(int iter = 0 ; iter < countryCodes.length ; iter++) { if(code.equals(countryCodes[iter])) { setText("+" + COUNTRY_CODES[iter]); setIcon(flagResource.getImage(COUNTRY_FLAGS[iter])); if(getIcon() == null) { setIcon(blankIcon); } return; } } } } protected void showPickerForm() { final Form f = getCurrentForm(); final Transition t = f.getTransitionOutAnimator(); CountryCodePicker
  • 9. setIcon(blankIcon); } return; } } } } protected void showPickerForm() { final Form f = getCurrentForm(); final Transition t = f.getTransitionOutAnimator(); f.setTransitionOutAnimator(CommonTransitions.createEmpty()); Form tf = new CountryPickerForm(this, flagResource); tf.addShowListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { f.setTransitionOutAnimator(t); f.removeShowListener(this); } }); tf.show(); } CountryCodePicker
  • 10. CountryCodePicker © Codename One 2017 all rights reserved
  • 11. CountryCodePicker © Codename One 2017 all rights reserved
  • 12. CountryCodePicker © Codename One 2017 all rights reserved
  • 13. CountryCodePicker © Codename One 2017 all rights reserved
  • 14. public class LoginForm extends Form { public LoginForm() { super(new BorderLayout()); Label squareLogo = new Label("", Resources.getGlobalResources().getImage("uber-logo.png"), "SquareLogo") { @Override protected Dimension calcPreferredSize() { Dimension size = super.calcPreferredSize(); size.setHeight(size.getWidth()); return size; } }; Container logo = BorderLayout.centerAbsolute(squareLogo); logo.setUIID("LogoBackground"); add(CENTER, logo); Label getMovingWithUber = new Label("Get moving with Uber", "GetMovingWithUber"); CountryCodePicker countryCodeButton = new CountryCodePicker() { @Override LoginForm
  • 15. public class LoginForm extends Form { public LoginForm() { super(new BorderLayout()); Label squareLogo = new Label("", Resources.getGlobalResources().getImage("uber-logo.png"), "SquareLogo") { @Override protected Dimension calcPreferredSize() { Dimension size = super.calcPreferredSize(); size.setHeight(size.getWidth()); return size; } }; Container logo = BorderLayout.centerAbsolute(squareLogo); logo.setUIID("LogoBackground"); add(CENTER, logo); Label getMovingWithUber = new Label("Get moving with Uber", "GetMovingWithUber"); CountryCodePicker countryCodeButton = new CountryCodePicker() { @Override LoginForm
  • 16. public class LoginForm extends Form { public LoginForm() { super(new BorderLayout()); Label squareLogo = new Label("", Resources.getGlobalResources().getImage("uber-logo.png"), "SquareLogo") { @Override protected Dimension calcPreferredSize() { Dimension size = super.calcPreferredSize(); size.setHeight(size.getWidth()); return size; } }; Container logo = BorderLayout.centerAbsolute(squareLogo); logo.setUIID("LogoBackground"); add(CENTER, logo); Label getMovingWithUber = new Label("Get moving with Uber", "GetMovingWithUber"); CountryCodePicker countryCodeButton = new CountryCodePicker() { @Override LoginForm
  • 17. CountryCodePicker countryCodeButton = new CountryCodePicker() { @Override protected void showPickerForm() { new EnterMobileNumberForm().show(); } }; SpanButton phoneNumber = new SpanButton("Enter your mobile number", "PhoneNumberHint"); phoneNumber.getTextComponent().setColumns(80); phoneNumber.getTextComponent().setRows(2); phoneNumber.getTextComponent().setGrowByContent(false); phoneNumber.setUIID("Container"); phoneNumber.addActionListener(e -> new EnterMobileNumberForm().show()); Container phonePicking = BorderLayout.centerCenterEastWest( phoneNumber, null, countryCodeButton); phonePicking.setUIID("Separator"); Button social = new Button("Or connect with social", "ConnectWithSocialButton"); social.addActionListener(e -> new FacebookOrGoogleLoginForm().show()); LoginForm
  • 18. CountryCodePicker countryCodeButton = new CountryCodePicker() { @Override protected void showPickerForm() { new EnterMobileNumberForm().show(); } }; SpanButton phoneNumber = new SpanButton("Enter your mobile number", "PhoneNumberHint"); phoneNumber.getTextComponent().setColumns(80); phoneNumber.getTextComponent().setRows(2); phoneNumber.getTextComponent().setGrowByContent(false); phoneNumber.setUIID("Container"); phoneNumber.addActionListener(e -> new EnterMobileNumberForm().show()); Container phonePicking = BorderLayout.centerCenterEastWest( phoneNumber, null, countryCodeButton); phonePicking.setUIID("Separator"); Button social = new Button("Or connect with social", "ConnectWithSocialButton"); social.addActionListener(e -> new FacebookOrGoogleLoginForm().show()); LoginForm
  • 19. phoneNumber.addActionListener(e -> new EnterMobileNumberForm().show()); Container phonePicking = BorderLayout.centerCenterEastWest( phoneNumber, null, countryCodeButton); phonePicking.setUIID("Separator"); Button social = new Button("Or connect with social", "ConnectWithSocialButton"); social.addActionListener(e -> new FacebookOrGoogleLoginForm().show()); add(SOUTH, BoxLayout.encloseY(getMovingWithUber, phonePicking, social)); } @Override protected boolean shouldPaintStatusBar() { return false; } @Override protected void initGlobalToolbar() { } } LoginForm
  • 20. Tile & Logo © Codename One 2017 all rights reserved
  • 21. Square Logo © Codename One 2017 all rights reserved
  • 22. Square Logo © Codename One 2017 all rights reserved
  • 23. Square Logo © Codename One 2017 all rights reserved
  • 24. LogoBackground © Codename One 2017 all rights reserved
  • 25. LogoBackground © Codename One 2017 all rights reserved
  • 26. LogoBackground © Codename One 2017 all rights reserved
  • 27. GetMovingWithUber © Codename One 2017 all rights reserved
  • 28. GetMovingWithUber © Codename One 2017 all rights reserved
  • 29. GetMovingWithUber © Codename One 2017 all rights reserved
  • 30. PhoneNumberHint © Codename One 2017 all rights reserved
  • 31. PhoneNumberHint © Codename One 2017 all rights reserved
  • 32. PhoneNumberHint © Codename One 2017 all rights reserved
  • 33. Separator © Codename One 2017 all rights reserved
  • 34. Separator © Codename One 2017 all rights reserved
  • 35. Separator © Codename One 2017 all rights reserved
  • 36. Separator © Codename One 2017 all rights reserved
  • 37. ConnectWithSocialButton © Codename One 2017 all rights reserved
  • 38. ConnectWithSocialButton © Codename One 2017 all rights reserved
  • 39. ConnectWithSocialButton © Codename One 2017 all rights reserved
  • 40. ConnectWithSocialButton © Codename One 2017 all rights reserved
  • 41. The Login Form © Codename One 2017 all rights reserved