0xapurv / Bear_Log_In

A Flutter Log In Page using Flare Animations
12 stars 6 forks source link

How to apply to multiple forms? #1

Open ghost opened 2 years ago

ghost commented 2 years ago

For example, I got a login form and register form in the same auth screen, they are controlled by the authformstate.

When click a button Not have an account, it renders register form, so the same with the login form.

In this case the bearController seems not working.

class AuthPage extends HookConsumerWidget {
  const AuthPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    late final bearController = BearController();
    EdgeInsets devicePadding = MediaQuery.of(context).padding;

    final formState = useState<AuthFormState>(AuthFormState.login);
   // login form
    final Widget _loginForm = Form(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          TrackingTextInput(
            label: "Email or Username",
            hint: "What's your email address?",
            onCaretMoved: (Offset? caret) {
              bearController.lookAt(caret);
            },
            onTextChanged: (value) {
              identifier.value = value;
            },
          ),
          TrackingTextInput(
            label: "Password",
            hint: "I'm not watching",
            isObscured: true,
            onCaretMoved: (Offset? caret) {
              bearController.coverEyes(caret != null);
              bearController.lookAt(null);
            },
            onTextChanged: (String value) {
              bearController.setPassword(value);
            },
          ),
    ...]);
  // register form 

 ...

Widget build(BuildContext build, WidgetRef ref){
   return Scaffold(
     body: ....
           Form(child: formState.value == AuthFormState.register ? _registerForm  : formState.value == AuthFormState.forgotPassword ? _forgotPasswordForm  : _loginForm ),
           ...

 );
  }
 }
}
0xapurv commented 2 years ago

Hey @lodisy, I'm facing the same issue. Kindly make a PR if you know how to resolve it.