Login Screen - 图1

Login Screen React Component

Login Screen React component represents Login Screen component.

Login Screen Components

There are following components included:

  • LoginScreen / F7LoginScreen - login screen element
  • LoginScreenTitle / F7LoginScreenTitle - login screen title element

Login Screen Properties

PropTypeDefaultDescription
<LoginScreen> properties
openedbooleanfalseAllows to open/close Login Screen and set its initial state

Login Screen Methods

<LoginScreen> methods
.open(animate)Open login screen
.close(animate)Close login screen

Login Screen Events

EventDescription
<LoginScreen> events
loginScreenOpenEvent will be triggered when Login Screen starts its opening animation
loginScreenOpenedEvent will be triggered after Login Screen completes its opening animation
loginScreenCloseEvent will be triggered when Login Screen starts its closing animation
loginScreenClosedEvent will be triggered after Login Screen completes its closing animation

Open And Close Login Screen

In addition to Login Screen open()/close() methods, you can open and close it:

  • using Login Screen API
  • by passing true or false to its opened prop
  • by clicking on Link or Button with relevant loginScreenOpen property (to open it) and loginScreenClose property to close it

Access To Login Screen Instance

You can access Login Screen initialized instance by accessing .f7LoginScreen component’s property.

Examples

  1. export default class extends React.Component {
  2. constructor(props) {
  3. super(props);
  4. this.state = {
  5. loginScreenOpened: false,
  6. username: '',
  7. password: '',
  8. };
  9. }
  10. render() {
  11. return (
  12. <Page>
  13. <Navbar title="Login Screen"></Navbar>
  14. <Block>
  15. <p>Framework7 comes with ready to use Login Screen layout. It could be used inside of page or inside of popup (Embedded) or as a standalone overlay:</p>
  16. </Block>
  17. <List>
  18. <ListItem link="/login-screen-page/" title="As Separate Page"></ListItem>
  19. </List>
  20. <Block>
  21. <Button raised large fill loginScreenOpen=".demo-login-screen">As Overlay</Button>
  22. </Block>
  23. <Block>
  24. <Button raised large fill onClick={() => {this.setState({loginScreenOpened : true})}}>Open Via Prop Change</Button>
  25. </Block>
  26. <LoginScreen className="demo-login-screen" opened={this.state.loginScreenOpened} onLoginScreenClosed={() => {this.setState({loginScreenOpened : false})}}>
  27. <Page loginScreen>
  28. <LoginScreenTitle>Framework7</LoginScreenTitle>
  29. <List form>
  30. <ListInput
  31. label="Username"
  32. type="text"
  33. placeholder="Your username"
  34. value={this.state.username}
  35. onInput={(e) => {
  36. this.setState({ username: e.target.value});
  37. }}
  38. />
  39. <ListInput
  40. label="Password"
  41. type="password"
  42. placeholder="Your password"
  43. value={this.state.password}
  44. onInput={(e) => {
  45. this.setState({ password: e.target.value});
  46. }}
  47. />
  48. </List>
  49. <List>
  50. <ListButton onClick={this.signIn.bind(this)}>Sign In</ListButton>
  51. <BlockFooter>Some text about login information.<br />Lorem ipsum dolor sit amet, consectetur adipiscing elit.</BlockFooter>
  52. </List>
  53. </Page>
  54. </LoginScreen>
  55. </Page>
  56. )
  57. }
  58. signIn() {
  59. const self = this;
  60. const app = self.$f7;
  61. app.dialog.alert(`Username: ${self.state.username}<br>Password: ${self.state.password}`, () => {
  62. app.loginScreen.close();
  63. });
  64. }
  65. };

Separate Login Screen Page

  1. export default class extends React.Component {
  2. constructor(props) {
  3. super(props);
  4. this.state = {
  5. username: '',
  6. password: '',
  7. };
  8. }
  9. render() {
  10. return (
  11. <Page noToolbar noNavbar noSwipeback loginScreen>
  12. <LoginScreenTitle>Framework7</LoginScreenTitle>
  13. <List form>
  14. <ListInput
  15. label="Username"
  16. type="text"
  17. placeholder="Your username"
  18. value={this.state.username}
  19. onInput={(e) => {
  20. this.setState({ username: e.target.value});
  21. }}
  22. />
  23. <ListInput
  24. label="Password"
  25. type="password"
  26. placeholder="Your password"
  27. value={this.state.password}
  28. onInput={(e) => {
  29. this.setState({ password: e.target.value});
  30. }}
  31. />
  32. </List>
  33. <List>
  34. <ListButton onClick={this.signIn.bind(this)}>Sign In</ListButton>
  35. <BlockFooter>Some text about login information.<br />Lorem ipsum dolor sit amet, consectetur adipiscing elit.</BlockFooter>
  36. </List>
  37. </Page>
  38. )
  39. }
  40. signIn() {
  41. const self = this;
  42. const app = self.$f7;
  43. const router = self.$f7router;
  44. app.dialog.alert(`Username: ${self.state.username}<br>Password: ${self.state.password}`, () => {
  45. router.back();
  46. });
  47. }
  48. }

← List Item

Menu →