carrythroughcovid / ctc-app

React Native app for CTC
0 stars 0 forks source link

Implement business sign up form as a WebView #15

Open shadforth opened 4 years ago

shadforth commented 4 years ago

High-level overview

We currently navigate users from the About screen to the business sign up form on carrythroughcovid.com via Linking. This method is a little bit janky because it means users will be redirected on their phones to their default web browser in order to view this page.

A more seamless way to view the business sign up form is via WebView. ✨

With WebView, users can view the webpage "natively" within the application without the need to navigate away from the app. The page is effectively embedded within the app.

Technical implementation

The current implementation of linking to the business form is below.

// Users' default web browser is opened when pressing 'Sign up now'
<TouchableOpacity
   onPress={() =>
      Linking.openURL("https://carrythroughcovid.com/signup")
   }
>
   <Text>Sign up now</Text>
</TouchableOpacity>

With WebView, instead we can register the screen as its own component.

// Register the WebView as its own component
const BusinessSignUpScreen = () => {
  return (
    <WebView
      source={{ uri: "https://carrythroughcovid.com/signup" }}
    />
  );
};

With this implementation, the TouchableOpacity changes to the snippet below.

<TouchableOpacity
   onPress={() => navigation.navigate("BusinessSignUp")}
>
   <Text>Sign up now</Text>
</TouchableOpacity>

Callouts

POC branch

A proof of concept can be found on the spike-business-webview branch.

Screenshot

webview

peroh commented 4 years ago

This is awesome. The the other thing to think about is whether we disable some functionality from the webview so that they can only sign up, and not visit other links. I think you can inject some javascript before the page loads so we could look into that.

And maybe we could update some styles as well?

Regardless I think this is a good option. Are you happy to card it up?

shadforth commented 4 years ago

Good call, I'll card it up and look at it this week!