SlideShare a Scribd company logo
Creating a Facebook Clone - Part VIII
We are nearing the end of the signup wizard UI
© Codename One 2017 all rights reserved
The next stage would be
© Codename One 2017 all rights reserved
Your mobile number but that’s a bit of a special case
© Codename One 2017 all rights reserved
Because it leads to the email address & both of these are effectively the same form
© Codename One 2017 all rights reserved
They both look pretty similar to one another and similar between iOS/Android with the obvious platform differences.
s.createNextButton(e -> createNumber().show()));
return s;
}
public static SignupForm createNumber() {
return createMobileOrEmail("Mobile Number",
"What's Your Mobile Number?",
"Sign Up With Email Address",
TextArea.PHONENUMBER,
e -> createEmail().show());
}
private static SignupForm createMobileOrEmail(String formTitle,
String subtitle, String signUpWith, int constraint,
ActionListener goToOther) {
SignupForm s = new SignupForm(formTitle, getCurrentForm().getTitle(),
getCurrentForm());
Label title = new Label(subtitle, "SignupSubHeader");
TextComponent textEntry = new TextComponent().
label(formTitle).
columns(20).
constraint(constraint);
Container textContainer = new Container(new TextModeLayout(1, 1),
SignupForm
This is createNumber() notice that it delegates all of the work to createMobileOrEmail so lets start there first and come back.
TextArea.PHONENUMBER,
e -> createEmail().show());
}
private static SignupForm createMobileOrEmail(String formTitle,
String subtitle, String signUpWith, int constraint,
ActionListener goToOther) {
SignupForm s = new SignupForm(formTitle, getCurrentForm().getTitle(),
getCurrentForm());
Label title = new Label(subtitle, "SignupSubHeader");
TextComponent textEntry = new TextComponent().
label(formTitle).
columns(20).
constraint(constraint);
Container textContainer = new Container(new TextModeLayout(1, 1),
"PaddedContainer");
textContainer.add(textEntry);
Button mobile = new Button(signUpWith, "BoldBlueLink");
mobile.addActionListener(goToOther);
s.south.addComponent(0, mobile);
s.content.addAll(title, textContainer,
s.createNextButton(e ->
SignupForm
We can reach this Form either from gender or from Email/Number based on going back & forth. So the title of the back command can differ
TextArea.PHONENUMBER,
e -> createEmail().show());
}
private static SignupForm createMobileOrEmail(String formTitle,
String subtitle, String signUpWith, int constraint,
ActionListener goToOther) {
SignupForm s = new SignupForm(formTitle, getCurrentForm().getTitle(),
getCurrentForm());
Label title = new Label(subtitle, "SignupSubHeader");
TextComponent textEntry = new TextComponent().
label(formTitle).
columns(20).
constraint(constraint);
Container textContainer = new Container(new TextModeLayout(1, 1),
"PaddedContainer");
textContainer.add(textEntry);
Button mobile = new Button(signUpWith, "BoldBlueLink");
mobile.addActionListener(goToOther);
s.south.addComponent(0, mobile);
s.content.addAll(title, textContainer,
s.createNextButton(e ->
SignupForm
The text entry is just one text field so the UI is pretty trivial
TextArea.PHONENUMBER,
e -> createEmail().show());
}
private static SignupForm createMobileOrEmail(String formTitle,
String subtitle, String signUpWith, int constraint,
ActionListener goToOther) {
SignupForm s = new SignupForm(formTitle, getCurrentForm().getTitle(),
getCurrentForm());
Label title = new Label(subtitle, "SignupSubHeader");
TextComponent textEntry = new TextComponent().
label(formTitle).
columns(20).
constraint(constraint);
Container textContainer = new Container(new TextModeLayout(1, 1),
"PaddedContainer");
textContainer.add(textEntry);
Button mobile = new Button(signUpWith, "BoldBlueLink");
mobile.addActionListener(goToOther);
s.south.addComponent(0, mobile);
s.content.addAll(title, textContainer,
s.createNextButton(e ->
SignupForm
Notice I use constraint which will determine the type of virtual keyboard I’ll use
String subtitle, String signUpWith, int constraint,
ActionListener goToOther) {
SignupForm s = new SignupForm(formTitle, getCurrentForm().getTitle(),
getCurrentForm());
Label title = new Label(subtitle, "SignupSubHeader");
TextComponent textEntry = new TextComponent().
label(formTitle).
columns(20).
constraint(constraint);
Container textContainer = new Container(new TextModeLayout(1, 1),
"PaddedContainer");
textContainer.add(textEntry);
Button mobile = new Button(signUpWith, "BoldBlueLink");
mobile.addActionListener(goToOther);
s.south.addComponent(0, mobile);
s.content.addAll(title, textContainer,
s.createNextButton(e ->
createPassword(TextArea.PHONENUMBER == constraint,
textEntry.getText()).show()));
return s;
}
SignupForm
We pass the action listener on the link, it will navigate to the "other" form. E.g. If we are in phone entry it will go to email entry
String subtitle, String signUpWith, int constraint,
ActionListener goToOther) {
SignupForm s = new SignupForm(formTitle, getCurrentForm().getTitle(),
getCurrentForm());
Label title = new Label(subtitle, "SignupSubHeader");
TextComponent textEntry = new TextComponent().
label(formTitle).
columns(20).
constraint(constraint);
Container textContainer = new Container(new TextModeLayout(1, 1),
"PaddedContainer");
textContainer.add(textEntry);
Button mobile = new Button(signUpWith, "BoldBlueLink");
mobile.addActionListener(goToOther);
s.south.addComponent(0, mobile);
s.content.addAll(title, textContainer,
s.createNextButton(e ->
createPassword(TextArea.PHONENUMBER == constraint,
textEntry.getText()).show()));
return s;
}
SignupForm
We add a button to the south Container. This is the "Sign Up With Email Address" link or the similar "Sign Up With Mobile Number"
String subtitle, String signUpWith, int constraint,
ActionListener goToOther) {
SignupForm s = new SignupForm(formTitle, getCurrentForm().getTitle(),
getCurrentForm());
Label title = new Label(subtitle, "SignupSubHeader");
TextComponent textEntry = new TextComponent().
label(formTitle).
columns(20).
constraint(constraint);
Container textContainer = new Container(new TextModeLayout(1, 1),
"PaddedContainer");
textContainer.add(textEntry);
Button mobile = new Button(signUpWith, "BoldBlueLink");
mobile.addActionListener(goToOther);
s.south.addComponent(0, mobile);
s.content.addAll(title, textContainer,
s.createNextButton(e ->
createPassword(TextArea.PHONENUMBER == constraint,
textEntry.getText()).show()));
return s;
}
SignupForm
We pass true if this is a phone number & false for email. We also pass the text of the phone/email. We'll display that in the confirmation Form. That was mostly standard
stuff it will be further clarified with the actual calls to this method:
s.createNextButton(e -> createNumber().show()));
return s;
}
public static SignupForm createNumber() {
return createMobileOrEmail("Mobile Number",
"What's Your Mobile Number?",
"Sign Up With Email Address",
TextArea.PHONENUMBER,
e -> createEmail().show());
}
private static SignupForm createMobileOrEmail(String formTitle,
String subtitle, String signUpWith, int constraint,
ActionListener goToOther) {
SignupForm s = new SignupForm(formTitle, getCurrentForm().getTitle(),
getCurrentForm());
Label title = new Label(subtitle, "SignupSubHeader");
TextComponent textEntry = new TextComponent().
label(formTitle).
columns(20).
constraint(constraint);
Container textContainer = new Container(new TextModeLayout(1, 1),
SignupForm
These are the labels we show in the Form
s.createNextButton(e -> createNumber().show()));
return s;
}
public static SignupForm createNumber() {
return createMobileOrEmail("Mobile Number",
"What's Your Mobile Number?",
"Sign Up With Email Address",
TextArea.PHONENUMBER,
e -> createEmail().show());
}
private static SignupForm createMobileOrEmail(String formTitle,
String subtitle, String signUpWith, int constraint,
ActionListener goToOther) {
SignupForm s = new SignupForm(formTitle, getCurrentForm().getTitle(),
getCurrentForm());
Label title = new Label(subtitle, "SignupSubHeader");
TextComponent textEntry = new TextComponent().
label(formTitle).
columns(20).
constraint(constraint);
Container textContainer = new Container(new TextModeLayout(1, 1),
SignupForm
The text input constraint, in this case it's a phone number. In the other case it will be an email address constraint
s.createNextButton(e -> createNumber().show()));
return s;
}
public static SignupForm createNumber() {
return createMobileOrEmail("Mobile Number",
"What's Your Mobile Number?",
"Sign Up With Email Address",
TextArea.PHONENUMBER,
e -> createEmail().show());
}
private static SignupForm createMobileOrEmail(String formTitle,
String subtitle, String signUpWith, int constraint,
ActionListener goToOther) {
SignupForm s = new SignupForm(formTitle, getCurrentForm().getTitle(),
getCurrentForm());
Label title = new Label(subtitle, "SignupSubHeader");
TextComponent textEntry = new TextComponent().
label(formTitle).
columns(20).
constraint(constraint);
Container textContainer = new Container(new TextModeLayout(1, 1),
SignupForm
Navigation to the "other" Form here we navigate to the email entry form and there we'll navigate to the number
mobile.addActionListener(goToOther);
s.south.addComponent(0, mobile);
s.content.addAll(title, textContainer,
s.createNextButton(e ->
createPassword(TextArea.PHONENUMBER == constraint,
textEntry.getText()).show()));
return s;
}
public static SignupForm createEmail() {
return createMobileOrEmail("Email Address",
"What's Your Email Address?",
"Sign Up With Mobile Number",
TextArea.EMAILADDR,
e -> createNumber().show());
}
public static SignupForm createPassword(boolean phone, String value) {
SignupForm s = new SignupForm("Password",
getCurrentForm().getTitle(),
getCurrentForm());
Label title = new Label("Choose a Password", "SignupSubHeader");
TextComponent password = new TextComponent().
label("Password").
SignupForm
As you can see the email version is practically identical.
BoldBlueLink {
cn1-derive: BlueLink;
font-family: "native:MainBold";
}
theme.css
That's pretty much it for these two forms, we will need one CSS entry though. It's the same as `BlueLink` only bold. Once we do this email/number toggle should work...
© Codename One 2017 all rights reserved
There is nothing interesting here. I considered making a generic method that would generate this and the phone number/email form but decided against that. I think that
would have overgeneralized. It would have created overly confusing code.
"What's Your Email Address?",
"Sign Up With Mobile Number",
TextArea.EMAILADDR,
e -> createNumber().show());
}
public static SignupForm createPassword(boolean phone, String value) {
SignupForm s = new SignupForm("Password",
getCurrentForm().getTitle(),
getCurrentForm());
Label title = new Label("Choose a Password", "SignupSubHeader");
TextComponent password = new TextComponent().
label("Password").
columns(20);
Container textContainer = new Container(new TextModeLayout(1, 1),
"PaddedContainer");
textContainer.add(password);
s.content.addAll(title, textContainer,
s.createNextButton(e -> createConfirmation(phone, value).show()));
return s;
}
public static SignupForm createConfirmation(
SignupForm
The code is pretty much text book boilerplate. Nothing much to talk about.
"What's Your Email Address?",
"Sign Up With Mobile Number",
TextArea.EMAILADDR,
e -> createNumber().show());
}
public static SignupForm createPassword(boolean phone, String value) {
SignupForm s = new SignupForm("Password",
getCurrentForm().getTitle(),
getCurrentForm());
Label title = new Label("Choose a Password", "SignupSubHeader");
TextComponent password = new TextComponent().
label("Password").
columns(20);
Container textContainer = new Container(new TextModeLayout(1, 1),
"PaddedContainer");
textContainer.add(password);
s.content.addAll(title, textContainer,
s.createNextButton(e -> createConfirmation(phone, value).show()));
return s;
}
public static SignupForm createConfirmation(
SignupForm
The only thing worth noticing in this form is the `phone` & `value` variables that are passed right through the method to the confirmation form. We can now move to the
last stage of signup as there is no CSS or anything else to this form!
s.content.addAll(title, textContainer,
s.createNextButton(e -> createConfirmation(phone, value).show()));
return s;
}
public static SignupForm createConfirmation(
boolean phone, String value) {
SignupForm s = new SignupForm("Account Confirmation", "Password",
getCurrentForm());
SpanLabel title;
if(phone) {
title = new SpanLabel("Enter the code from your mobile phone",
"SignupSubHeader");
} else {
title = new SpanLabel("Enter the code from your email",
"SignupSubHeader");
}
SpanLabel line;
if(phone) {
line = new SpanLabel("Let us know this phone belongs to you. "
+ "Enter the code in the SMS sent to " + value, "CenterLabel");
} else {
line = new SpanLabel("Let us know this email belongs to you. "
+ "Enter the code in the message sent to " + value,
"CenterLabel");
SignupForm
The final stage of the signup process is the account confirmation Form
© Codename One 2017 all rights reserved
This is a trivial form as well but it does include minor things to notice.
s.content.addAll(title, textContainer,
s.createNextButton(e -> createConfirmation(phone, value).show()));
return s;
}
public static SignupForm createConfirmation(
boolean phone, String value) {
SignupForm s = new SignupForm("Account Confirmation", "Password",
getCurrentForm());
SpanLabel title;
if(phone) {
title = new SpanLabel("Enter the code from your mobile phone",
"SignupSubHeader");
} else {
title = new SpanLabel("Enter the code from your email",
"SignupSubHeader");
}
SpanLabel line;
if(phone) {
line = new SpanLabel("Let us know this phone belongs to you. "
+ "Enter the code in the SMS sent to " + value, "CenterLabel");
} else {
line = new SpanLabel("Let us know this email belongs to you. "
+ "Enter the code in the message sent to " + value,
"CenterLabel");
SignupForm
The subtitle can span lines here depending on the size of the phone screen
title = new SpanLabel("Enter the code from your mobile phone",
"SignupSubHeader");
} else {
title = new SpanLabel("Enter the code from your email",
"SignupSubHeader");
}
SpanLabel line;
if(phone) {
line = new SpanLabel("Let us know this phone belongs to you. "
+ "Enter the code in the SMS sent to " + value, "CenterLabel");
} else {
line = new SpanLabel("Let us know this email belongs to you. "
+ "Enter the code in the message sent to " + value,
"CenterLabel");
}
TextComponent confirm = new TextComponent().
label("Confirmation Code").
columns(20).
constraint(TextArea.NUMERIC);
Container textContainer = new Container(new TextModeLayout(1, 1),
"PaddedContainer");
textContainer.add(confirm);
SignupForm
We have a special center aligned message that includes the content we passed from the phone/email stage of the wizard
SpanLabel line;
if(phone) {
line = new SpanLabel("Let us know this phone belongs to you. "
+ "Enter the code in the SMS sent to " + value, "CenterLabel");
} else {
line = new SpanLabel("Let us know this email belongs to you. "
+ "Enter the code in the message sent to " + value,
"CenterLabel");
}
TextComponent confirm = new TextComponent().
label("Confirmation Code").
columns(20).
constraint(TextArea.NUMERIC);
Container textContainer = new Container(new TextModeLayout(1, 1),
"PaddedContainer");
textContainer.add(confirm);
Button done = s.createNextButton(e -> UIController.showMainUI());
done.setText("Confirm");
s.content.addAll(title, line, textContainer, done);
return s;
}
}
SignupForm
When done we show the main UI, I’ll add a stub for this method soon
CenterLabel {
text-align: center;
font-size: 2.2mm;
}
theme.css
We just have one more tiny change to the CSS, we need to add the new CenterLabel style
public static void showSignup() {
SignupForm.createTerms().show();
}
public static void showMainUI() {
}
UIController
Finally we need to add some wiring to show the signup process. In UIController we'll add a new signup call and we will also need a stub for showMainUI() so the signup
wizard will compile
signUp.addActionListener(e -> UIController.showSignup());
LoginForm
And finally we bind the signup wizrd to the LoginForm constructor using this code…

With that the signup process mockup is done and we can move to mocking up the main UI.

More Related Content

PDF
Creating a Facebook Clone - Part VIII.pdf
PDF
Creating a Facebook Clone - Part VI.pdf
PDF
Creating a Facebook Clone - Part VI - Transcript.pdf
PDF
Creating a Facebook Clone - Part XXVIII - Transcript.pdf
PDF
Creating a Facebook Clone - Part VII.pdf
PDF
Creating a Facebook Clone - Part XXVIII.pdf
PDF
Creating a Facebook Clone - Part IV - Transcript.pdf
PDF
Creating a Facebook Clone - Part IV.pdf
Creating a Facebook Clone - Part VIII.pdf
Creating a Facebook Clone - Part VI.pdf
Creating a Facebook Clone - Part VI - Transcript.pdf
Creating a Facebook Clone - Part XXVIII - Transcript.pdf
Creating a Facebook Clone - Part VII.pdf
Creating a Facebook Clone - Part XXVIII.pdf
Creating a Facebook Clone - Part IV - Transcript.pdf
Creating a Facebook Clone - Part IV.pdf

Similar to Creating a Facebook Clone - Part VIII - Transcript.pdf (14)

PDF
How do I - Create a List of Items - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part X - Transcript.pdf
PDF
Creating an Uber - Part VI - Transcript.pdf
PDF
Creating a Facebook Clone - Part XXX.pdf
PDF
Adapting to Tablets and Desktops - Part 1 - Transcript.pdf
PDF
Creating an Uber Clone - Part XIV - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part X.pdf
PDF
How do I - Create a List of Items.pdf
PDF
Creating an Uber Clone - Part V.pdf
PDF
Creating a Facebook Clone - Part XXX - Transcript.pdf
PDF
Creating an Uber - Part VI.pdf
PDF
Creating a Facebook Clone - Part V - Transcript.pdf
PDF
Building web apps with vaadin 10
PDF
Creating a Facebook Clone - Part XLVI - Transcript.pdf
How do I - Create a List of Items - Transcript.pdf
Creating a Whatsapp Clone - Part X - Transcript.pdf
Creating an Uber - Part VI - Transcript.pdf
Creating a Facebook Clone - Part XXX.pdf
Adapting to Tablets and Desktops - Part 1 - Transcript.pdf
Creating an Uber Clone - Part XIV - Transcript.pdf
Creating a Whatsapp Clone - Part X.pdf
How do I - Create a List of Items.pdf
Creating an Uber Clone - Part V.pdf
Creating a Facebook Clone - Part XXX - Transcript.pdf
Creating an Uber - Part VI.pdf
Creating a Facebook Clone - Part V - Transcript.pdf
Building web apps with vaadin 10
Creating a Facebook Clone - Part XLVI - Transcript.pdf

More from ShaiAlmog1 (20)

PDF
The Duck Teaches Learn to debug from the masters. Local to production- kill ...
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
The Duck Teaches Learn to debug from the masters. Local to production- kill ...
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

Recently uploaded (20)

PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
KodekX | Application Modernization Development
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
cuic standard and advanced reporting.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Cloud computing and distributed systems.
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Empathic Computing: Creating Shared Understanding
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
Chapter 3 Spatial Domain Image Processing.pdf
Spectroscopy.pptx food analysis technology
KodekX | Application Modernization Development
NewMind AI Weekly Chronicles - August'25 Week I
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Understanding_Digital_Forensics_Presentation.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Unlocking AI with Model Context Protocol (MCP)
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
cuic standard and advanced reporting.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Machine learning based COVID-19 study performance prediction
Cloud computing and distributed systems.
“AI and Expert System Decision Support & Business Intelligence Systems”
Empathic Computing: Creating Shared Understanding
Network Security Unit 5.pdf for BCA BBA.
The Rise and Fall of 3GPP – Time for a Sabbatical?

Creating a Facebook Clone - Part VIII - Transcript.pdf

  • 1. Creating a Facebook Clone - Part VIII We are nearing the end of the signup wizard UI
  • 2. © Codename One 2017 all rights reserved The next stage would be
  • 3. © Codename One 2017 all rights reserved Your mobile number but that’s a bit of a special case
  • 4. © Codename One 2017 all rights reserved Because it leads to the email address & both of these are effectively the same form
  • 5. © Codename One 2017 all rights reserved They both look pretty similar to one another and similar between iOS/Android with the obvious platform differences.
  • 6. s.createNextButton(e -> createNumber().show())); return s; } public static SignupForm createNumber() { return createMobileOrEmail("Mobile Number", "What's Your Mobile Number?", "Sign Up With Email Address", TextArea.PHONENUMBER, e -> createEmail().show()); } private static SignupForm createMobileOrEmail(String formTitle, String subtitle, String signUpWith, int constraint, ActionListener goToOther) { SignupForm s = new SignupForm(formTitle, getCurrentForm().getTitle(), getCurrentForm()); Label title = new Label(subtitle, "SignupSubHeader"); TextComponent textEntry = new TextComponent(). label(formTitle). columns(20). constraint(constraint); Container textContainer = new Container(new TextModeLayout(1, 1), SignupForm This is createNumber() notice that it delegates all of the work to createMobileOrEmail so lets start there first and come back.
  • 7. TextArea.PHONENUMBER, e -> createEmail().show()); } private static SignupForm createMobileOrEmail(String formTitle, String subtitle, String signUpWith, int constraint, ActionListener goToOther) { SignupForm s = new SignupForm(formTitle, getCurrentForm().getTitle(), getCurrentForm()); Label title = new Label(subtitle, "SignupSubHeader"); TextComponent textEntry = new TextComponent(). label(formTitle). columns(20). constraint(constraint); Container textContainer = new Container(new TextModeLayout(1, 1), "PaddedContainer"); textContainer.add(textEntry); Button mobile = new Button(signUpWith, "BoldBlueLink"); mobile.addActionListener(goToOther); s.south.addComponent(0, mobile); s.content.addAll(title, textContainer, s.createNextButton(e -> SignupForm We can reach this Form either from gender or from Email/Number based on going back & forth. So the title of the back command can differ
  • 8. TextArea.PHONENUMBER, e -> createEmail().show()); } private static SignupForm createMobileOrEmail(String formTitle, String subtitle, String signUpWith, int constraint, ActionListener goToOther) { SignupForm s = new SignupForm(formTitle, getCurrentForm().getTitle(), getCurrentForm()); Label title = new Label(subtitle, "SignupSubHeader"); TextComponent textEntry = new TextComponent(). label(formTitle). columns(20). constraint(constraint); Container textContainer = new Container(new TextModeLayout(1, 1), "PaddedContainer"); textContainer.add(textEntry); Button mobile = new Button(signUpWith, "BoldBlueLink"); mobile.addActionListener(goToOther); s.south.addComponent(0, mobile); s.content.addAll(title, textContainer, s.createNextButton(e -> SignupForm The text entry is just one text field so the UI is pretty trivial
  • 9. TextArea.PHONENUMBER, e -> createEmail().show()); } private static SignupForm createMobileOrEmail(String formTitle, String subtitle, String signUpWith, int constraint, ActionListener goToOther) { SignupForm s = new SignupForm(formTitle, getCurrentForm().getTitle(), getCurrentForm()); Label title = new Label(subtitle, "SignupSubHeader"); TextComponent textEntry = new TextComponent(). label(formTitle). columns(20). constraint(constraint); Container textContainer = new Container(new TextModeLayout(1, 1), "PaddedContainer"); textContainer.add(textEntry); Button mobile = new Button(signUpWith, "BoldBlueLink"); mobile.addActionListener(goToOther); s.south.addComponent(0, mobile); s.content.addAll(title, textContainer, s.createNextButton(e -> SignupForm Notice I use constraint which will determine the type of virtual keyboard I’ll use
  • 10. String subtitle, String signUpWith, int constraint, ActionListener goToOther) { SignupForm s = new SignupForm(formTitle, getCurrentForm().getTitle(), getCurrentForm()); Label title = new Label(subtitle, "SignupSubHeader"); TextComponent textEntry = new TextComponent(). label(formTitle). columns(20). constraint(constraint); Container textContainer = new Container(new TextModeLayout(1, 1), "PaddedContainer"); textContainer.add(textEntry); Button mobile = new Button(signUpWith, "BoldBlueLink"); mobile.addActionListener(goToOther); s.south.addComponent(0, mobile); s.content.addAll(title, textContainer, s.createNextButton(e -> createPassword(TextArea.PHONENUMBER == constraint, textEntry.getText()).show())); return s; } SignupForm We pass the action listener on the link, it will navigate to the "other" form. E.g. If we are in phone entry it will go to email entry
  • 11. String subtitle, String signUpWith, int constraint, ActionListener goToOther) { SignupForm s = new SignupForm(formTitle, getCurrentForm().getTitle(), getCurrentForm()); Label title = new Label(subtitle, "SignupSubHeader"); TextComponent textEntry = new TextComponent(). label(formTitle). columns(20). constraint(constraint); Container textContainer = new Container(new TextModeLayout(1, 1), "PaddedContainer"); textContainer.add(textEntry); Button mobile = new Button(signUpWith, "BoldBlueLink"); mobile.addActionListener(goToOther); s.south.addComponent(0, mobile); s.content.addAll(title, textContainer, s.createNextButton(e -> createPassword(TextArea.PHONENUMBER == constraint, textEntry.getText()).show())); return s; } SignupForm We add a button to the south Container. This is the "Sign Up With Email Address" link or the similar "Sign Up With Mobile Number"
  • 12. String subtitle, String signUpWith, int constraint, ActionListener goToOther) { SignupForm s = new SignupForm(formTitle, getCurrentForm().getTitle(), getCurrentForm()); Label title = new Label(subtitle, "SignupSubHeader"); TextComponent textEntry = new TextComponent(). label(formTitle). columns(20). constraint(constraint); Container textContainer = new Container(new TextModeLayout(1, 1), "PaddedContainer"); textContainer.add(textEntry); Button mobile = new Button(signUpWith, "BoldBlueLink"); mobile.addActionListener(goToOther); s.south.addComponent(0, mobile); s.content.addAll(title, textContainer, s.createNextButton(e -> createPassword(TextArea.PHONENUMBER == constraint, textEntry.getText()).show())); return s; } SignupForm We pass true if this is a phone number & false for email. We also pass the text of the phone/email. We'll display that in the confirmation Form. That was mostly standard stuff it will be further clarified with the actual calls to this method:
  • 13. s.createNextButton(e -> createNumber().show())); return s; } public static SignupForm createNumber() { return createMobileOrEmail("Mobile Number", "What's Your Mobile Number?", "Sign Up With Email Address", TextArea.PHONENUMBER, e -> createEmail().show()); } private static SignupForm createMobileOrEmail(String formTitle, String subtitle, String signUpWith, int constraint, ActionListener goToOther) { SignupForm s = new SignupForm(formTitle, getCurrentForm().getTitle(), getCurrentForm()); Label title = new Label(subtitle, "SignupSubHeader"); TextComponent textEntry = new TextComponent(). label(formTitle). columns(20). constraint(constraint); Container textContainer = new Container(new TextModeLayout(1, 1), SignupForm These are the labels we show in the Form
  • 14. s.createNextButton(e -> createNumber().show())); return s; } public static SignupForm createNumber() { return createMobileOrEmail("Mobile Number", "What's Your Mobile Number?", "Sign Up With Email Address", TextArea.PHONENUMBER, e -> createEmail().show()); } private static SignupForm createMobileOrEmail(String formTitle, String subtitle, String signUpWith, int constraint, ActionListener goToOther) { SignupForm s = new SignupForm(formTitle, getCurrentForm().getTitle(), getCurrentForm()); Label title = new Label(subtitle, "SignupSubHeader"); TextComponent textEntry = new TextComponent(). label(formTitle). columns(20). constraint(constraint); Container textContainer = new Container(new TextModeLayout(1, 1), SignupForm The text input constraint, in this case it's a phone number. In the other case it will be an email address constraint
  • 15. s.createNextButton(e -> createNumber().show())); return s; } public static SignupForm createNumber() { return createMobileOrEmail("Mobile Number", "What's Your Mobile Number?", "Sign Up With Email Address", TextArea.PHONENUMBER, e -> createEmail().show()); } private static SignupForm createMobileOrEmail(String formTitle, String subtitle, String signUpWith, int constraint, ActionListener goToOther) { SignupForm s = new SignupForm(formTitle, getCurrentForm().getTitle(), getCurrentForm()); Label title = new Label(subtitle, "SignupSubHeader"); TextComponent textEntry = new TextComponent(). label(formTitle). columns(20). constraint(constraint); Container textContainer = new Container(new TextModeLayout(1, 1), SignupForm Navigation to the "other" Form here we navigate to the email entry form and there we'll navigate to the number
  • 16. mobile.addActionListener(goToOther); s.south.addComponent(0, mobile); s.content.addAll(title, textContainer, s.createNextButton(e -> createPassword(TextArea.PHONENUMBER == constraint, textEntry.getText()).show())); return s; } public static SignupForm createEmail() { return createMobileOrEmail("Email Address", "What's Your Email Address?", "Sign Up With Mobile Number", TextArea.EMAILADDR, e -> createNumber().show()); } public static SignupForm createPassword(boolean phone, String value) { SignupForm s = new SignupForm("Password", getCurrentForm().getTitle(), getCurrentForm()); Label title = new Label("Choose a Password", "SignupSubHeader"); TextComponent password = new TextComponent(). label("Password"). SignupForm As you can see the email version is practically identical.
  • 17. BoldBlueLink { cn1-derive: BlueLink; font-family: "native:MainBold"; } theme.css That's pretty much it for these two forms, we will need one CSS entry though. It's the same as `BlueLink` only bold. Once we do this email/number toggle should work...
  • 18. © Codename One 2017 all rights reserved There is nothing interesting here. I considered making a generic method that would generate this and the phone number/email form but decided against that. I think that would have overgeneralized. It would have created overly confusing code.
  • 19. "What's Your Email Address?", "Sign Up With Mobile Number", TextArea.EMAILADDR, e -> createNumber().show()); } public static SignupForm createPassword(boolean phone, String value) { SignupForm s = new SignupForm("Password", getCurrentForm().getTitle(), getCurrentForm()); Label title = new Label("Choose a Password", "SignupSubHeader"); TextComponent password = new TextComponent(). label("Password"). columns(20); Container textContainer = new Container(new TextModeLayout(1, 1), "PaddedContainer"); textContainer.add(password); s.content.addAll(title, textContainer, s.createNextButton(e -> createConfirmation(phone, value).show())); return s; } public static SignupForm createConfirmation( SignupForm The code is pretty much text book boilerplate. Nothing much to talk about.
  • 20. "What's Your Email Address?", "Sign Up With Mobile Number", TextArea.EMAILADDR, e -> createNumber().show()); } public static SignupForm createPassword(boolean phone, String value) { SignupForm s = new SignupForm("Password", getCurrentForm().getTitle(), getCurrentForm()); Label title = new Label("Choose a Password", "SignupSubHeader"); TextComponent password = new TextComponent(). label("Password"). columns(20); Container textContainer = new Container(new TextModeLayout(1, 1), "PaddedContainer"); textContainer.add(password); s.content.addAll(title, textContainer, s.createNextButton(e -> createConfirmation(phone, value).show())); return s; } public static SignupForm createConfirmation( SignupForm The only thing worth noticing in this form is the `phone` & `value` variables that are passed right through the method to the confirmation form. We can now move to the last stage of signup as there is no CSS or anything else to this form!
  • 21. s.content.addAll(title, textContainer, s.createNextButton(e -> createConfirmation(phone, value).show())); return s; } public static SignupForm createConfirmation( boolean phone, String value) { SignupForm s = new SignupForm("Account Confirmation", "Password", getCurrentForm()); SpanLabel title; if(phone) { title = new SpanLabel("Enter the code from your mobile phone", "SignupSubHeader"); } else { title = new SpanLabel("Enter the code from your email", "SignupSubHeader"); } SpanLabel line; if(phone) { line = new SpanLabel("Let us know this phone belongs to you. " + "Enter the code in the SMS sent to " + value, "CenterLabel"); } else { line = new SpanLabel("Let us know this email belongs to you. " + "Enter the code in the message sent to " + value, "CenterLabel"); SignupForm The final stage of the signup process is the account confirmation Form
  • 22. © Codename One 2017 all rights reserved This is a trivial form as well but it does include minor things to notice.
  • 23. s.content.addAll(title, textContainer, s.createNextButton(e -> createConfirmation(phone, value).show())); return s; } public static SignupForm createConfirmation( boolean phone, String value) { SignupForm s = new SignupForm("Account Confirmation", "Password", getCurrentForm()); SpanLabel title; if(phone) { title = new SpanLabel("Enter the code from your mobile phone", "SignupSubHeader"); } else { title = new SpanLabel("Enter the code from your email", "SignupSubHeader"); } SpanLabel line; if(phone) { line = new SpanLabel("Let us know this phone belongs to you. " + "Enter the code in the SMS sent to " + value, "CenterLabel"); } else { line = new SpanLabel("Let us know this email belongs to you. " + "Enter the code in the message sent to " + value, "CenterLabel"); SignupForm The subtitle can span lines here depending on the size of the phone screen
  • 24. title = new SpanLabel("Enter the code from your mobile phone", "SignupSubHeader"); } else { title = new SpanLabel("Enter the code from your email", "SignupSubHeader"); } SpanLabel line; if(phone) { line = new SpanLabel("Let us know this phone belongs to you. " + "Enter the code in the SMS sent to " + value, "CenterLabel"); } else { line = new SpanLabel("Let us know this email belongs to you. " + "Enter the code in the message sent to " + value, "CenterLabel"); } TextComponent confirm = new TextComponent(). label("Confirmation Code"). columns(20). constraint(TextArea.NUMERIC); Container textContainer = new Container(new TextModeLayout(1, 1), "PaddedContainer"); textContainer.add(confirm); SignupForm We have a special center aligned message that includes the content we passed from the phone/email stage of the wizard
  • 25. SpanLabel line; if(phone) { line = new SpanLabel("Let us know this phone belongs to you. " + "Enter the code in the SMS sent to " + value, "CenterLabel"); } else { line = new SpanLabel("Let us know this email belongs to you. " + "Enter the code in the message sent to " + value, "CenterLabel"); } TextComponent confirm = new TextComponent(). label("Confirmation Code"). columns(20). constraint(TextArea.NUMERIC); Container textContainer = new Container(new TextModeLayout(1, 1), "PaddedContainer"); textContainer.add(confirm); Button done = s.createNextButton(e -> UIController.showMainUI()); done.setText("Confirm"); s.content.addAll(title, line, textContainer, done); return s; } } SignupForm When done we show the main UI, I’ll add a stub for this method soon
  • 26. CenterLabel { text-align: center; font-size: 2.2mm; } theme.css We just have one more tiny change to the CSS, we need to add the new CenterLabel style
  • 27. public static void showSignup() { SignupForm.createTerms().show(); } public static void showMainUI() { } UIController Finally we need to add some wiring to show the signup process. In UIController we'll add a new signup call and we will also need a stub for showMainUI() so the signup wizard will compile
  • 28. signUp.addActionListener(e -> UIController.showSignup()); LoginForm And finally we bind the signup wizrd to the LoginForm constructor using this code… With that the signup process mockup is done and we can move to mocking up the main UI.