Skip to content

FastheDeveloper/ScottsScooter

Repository files navigation

Getting Started

Note: Make sure you have completed the React Native - Environment Setup instructions till "Creating a new application" step, before proceeding.

Step 1: Start your Application

Let Metro Bundler run in its own terminal. Open a new terminal from the root of your React Native project. Run the following command to start your Android or iOS app:

For Android

npx expo run android

For iOS

npx expo run ios

Step 2: Setup Supabse

Note: Make sure you have completed the Build a User Management App with Expo React Native instructions with setting up a supabase account and project with Auth.

Create 'Scooters' table, using this sql query in the sql editor

create table if not exists public.scooters (
	id int generated by default as identity primary key,
	location geography(POINT) not null,
  battery float default 0
);

Enable postgis extension in supabase dashboard

Create GEO Index

create index scooters_geo_index
  on public.scooters
  using GIST (location);

Add location data to match your location

insert into public.scooters(location)
values
  (st_point(2.1589, 41.3907)),
  (st_point(2.1765, 41.3835)),
  (st_point(2.1897, 41.3942)),
  (st_point(2.1614, 41.3768))...

Create nearby_function to be called from the mobile app

create or replace function nearby_scooters(lat float, long float)
returns table (id public.scooters.id%TYPE, battery public.scooters.battery%TYPE, lat float, long float, dist_meters float)
language sql
as $$
  select id, battery, st_y(location::geometry) as lat, st_x(location::geometry) as long, st_distance(location, st_point(long, lat)::geography) as dist_meters
  from public.scooters
  order by location <-> st_point(long, lat)::geography;
$$;

Copy Supabase url

Copy Supabase Anon key

Step 3: Setup MapBox

Create a Mapbox account

Copy Mapbox public key

Step 4: Setup .env file

EXPO_PUBLIC_MAPBOX_PK=
EXPO_PUBLIC_SUPABASE_URL=
EXPO_PUBLIC_SUPABASE_ANON_KEY=

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published