spot
spot is a geo-tagged video sharing app, meaning every video recorded in spot is saved on a location. anybody can scroll though the map and find the videos recorded in any location in the world.
discover with spot, you can view what is going on anywhere in the world. all videos in spot are geo-tagged, meaning they are marked at the location they were recorded. that means if you want to take a look at what is going on in new york right now, you just go to newyork within the app and view what people are posting. same for la, paris, tokyo or anywhere else in the world!
create you can record spot videos to let your everyone else know what is happening wherever you are. with our intuitive video recorder, you will be able to capture the moment easily.
enjoy how you utilise spot is up to you! you may be able to check out the local festival without actual going there, discover hidden local amazing restaurants, or virtually visit your favorite city in the world. when you visit amazing places, don’t forget to save that memory inside spot so that the world can know about that place!
schema
CREATE TABLE IF NOT EXISTS if not exists public.users (
id uuid references auth.users on delete cascade not null primary key,
name varchar(18) not null unique,
description varchar(320) not null,
image_url text,
constraint username_validation check (char_length(name) >= 1)
);
comment on table public.users is 'holds all of users profile information';
alter table public.users enable row level security;
create policy "public profiles are viewable by everyone." on public.users for select using (true);
create policy "can insert user" on public.users for insert with check (auth.uid() = id);
create policy "can update user" on public.users for update using (auth.uid() = id) with check (auth.uid() = id);
create policy "can delete user" on public.users for delete using (auth.uid() = id);
CREATE TABLE IF NOT EXISTS if not exists public.videos (
id uuid not null primary key default uuid_generate_v4 (),
user_id uuid references public.users on delete cascade not null,
created_at timestamp with time zone default timezone('utc' :: text, now()) not null,
url text not null,
image_url text not null,
thumbnail_url text not null,
gif_url text not null,
description varchar(320) not null,
location geography(point) not null
);
comment on table public.videos is 'holds all the video videos.';
alter table public.videos enable row level security;
create policy "videos are viewable by everyone. " on public.videos for select using (true);
create policy "can insert videos" on public.videos for insert with check (auth.uid() = user_id);
create policy "can update videos" on public.videos for update using (auth.uid() = user_id) with check (auth.uid() = user_id);
create policy "can delete videos" on public.videos for delete using (auth.uid() = user_id);
CREATE TABLE IF NOT EXISTS if not exists public.comments (
id uuid not null primary key default uuid_generate_v4 (),
video_id uuid references public.videos on delete cascade not null,
user_id uuid references public.users on delete cascade not null,
created_at timestamp with time zone default timezone('utc' :: text, now()) not null,
text varchar(320) not null,
constraint comment_length check (char_length(text) >= 1)
);
comment on table public.comments is 'holds all of the comments created by the users.';
alter table public.comments enable row level security;
create policy "comments are viewable by everyone. " on public.comments for select using (true);
create policy "can insert comments" on public.comments for insert with check (auth.uid() = user_id);
create policy "can update comments" on public.comments for update using (auth.uid() = user_id) with check (auth.uid() = user_id);
create policy "can delete comments" on public.comments for delete using (auth.uid() = user_id);
CREATE TABLE IF NOT EXISTS if not exists public.likes (
video_id uuid references public.videos on delete cascade not null,
user_id uuid references public.users on delete cascade not null,
created_at timestamp with time zone default timezone('utc' :: text, now()) not null,
primary key (video_id, user_id)
);
comment on table public.likes is 'holds all of the like data created by thee users.';
alter table public.likes enable row level security;
create policy "likes are viewable by everyone. " on public.likes for select using (true);
create policy "users can insert their own likes." on public.likes for insert with check (auth.uid() = user_id);
create policy "users can delete own likes." on public.likes for delete using (auth.uid() = user_id);
CREATE TABLE IF NOT EXISTS if not exists public.follow (
following_user_id uuid references public.users on delete cascade not null,
followed_user_id uuid references public.users on delete cascade not null,
followed_at timestamp with time zone default timezone('utc' :: text, now()) not null,
primary key (following_user_id, followed_user_id)
);
comment on table public.follow is 'creates follow follower relationships.';
alter table public.follow enable row level security;
create policy "follows are viewable by everyone. " on public.follow for select using (true);
create policy "users can follow anyone" on public.follow for insert with check (auth.uid() = following_user_id);
create policy "users can unfollow their follows and ssers can remove their followers" on public.follow for delete using (auth.uid() = following_user_id or auth.uid() = followed_user_id);
CREATE TABLE IF NOT EXISTS if not exists public.blocks (
user_id uuid references public.users on delete cascade not null,
blocked_user_id uuid references public.users on delete cascade not null,
created_at timestamp with time zone default timezone('utc' :: text, now()) not null,
primary key (user_id, blocked_user_id),
constraint username_validation check (user_id != blocked_user_id)
);
comment on table public.blocks is 'holds information of who is blocking who.';
alter table public.blocks enable row level security;
create policy "users can view who they are blocking." on public.blocks for select using (auth.uid() = user_id);
create policy "users can block anyone by themselves. " on public.blocks for insert with check (auth.uid() = user_id);
CREATE TABLE IF NOT EXISTS if not exists public.reports (
id uuid not null primary key default uuid_generate_v4 (),
user_id uuid references public.users on delete cascade not null,
video_id uuid references public.videos on delete cascade not null,
reason text not null,
created_at timestamp with time zone default timezone('utc' :: text, now()) not null
);
comment on table public.reports is 'who reported which video for what reason.';
alter table public.reports enable row level security;
create policy "users can view their own reports." on public.reports for select using (auth.uid() = user_id);
create policy "users can report a video." on public.reports for insert with check (auth.uid() = user_id);
create or replace view video_comments
as
select
comments.id,
comments.text,
comments.created_at,
comments.video_id,
users.id as user_id,
users.name as user_name,
users.description as user_description,
users.image_url as user_image_url
from comments
join users on comments.user_id = users.id;
create or replace function nearby_videos(location text, user_id uuid)
returns table(id uuid, url text, image_url text, thumbnail_url text, gif_url text, location text, created_at timestamptz, description text, user_id uuid, user_name text, user_description text, user_image_url text)
as
$func$
select
videos.id,
videos.url,
videos.image_url,
videos.thumbnail_url,
videos.gif_url,
st_astext(videos.location) as location,
videos.created_at,
videos.description,
users.id as user_id,
users.name as user_name,
users.description as user_description,
users.image_url as user_image_url
from videos
join users on videos.user_id = users.id
where users.id not in (select blocked_user_id from blocks where user_id = user_id)
order by location <-> st_geogfromtext($1);
$func$
language sql;
create or replace function videos_in_bouding_box(min_lng decimal, min_lat decimal, max_lng decimal, max_lat decimal, user_id uuid)
returns table(id uuid, url text, image_url text, thumbnail_url text, gif_url text, location text, created_at timestamptz, description text, user_id uuid, user_name text, user_description text, user_image_url text)
as
$func$
select
videos.id,
videos.url,
videos.image_url,
videos.thumbnail_url,
videos.gif_url,
st_astext(videos.location) as location,
videos.created_at,
videos.description,
users.id as user_id,
users.name as user_name,
users.description as user_description,
users.image_url as user_image_url
from videos
join users on videos.user_id = users.id
where users.id not in (select blocked_user_id from blocks where user_id = user_id)
and location && st_setsrid(st_makebox2d(st_point(min_lng, min_lat), st_point(max_lng, max_lat)),4326);
$func$
language sql;
create or replace function get_video_detail(video_id uuid, user_id uuid)
returns table(id uuid, url text, image_url text, thumbnail_url text, gif_url text, created_at timestamptz, description text, user_id uuid, user_name text, user_description text, user_image_url text, location text, like_count int, comment_count int, have_liked int)
as
$func$
select
videos.id,
videos.url,
videos.image_url,
videos.thumbnail_url,
videos.gif_url,
videos.created_at,
videos.description,
users.id as user_id,
users.name as user_name,
users.description as user_description,
users.image_url as user_image_url,
st_astext(videos.location) as location,
(select count(*) from likes where video_id = videos.id)::int as like_count,
(select count(*) from comments where video_id = videos.id)::int as comment_count,
(select count(*) from likes where video_id = videos.id and videos.user_id = $2)::int as have_liked
from videos
join users on videos.user_id = users.id
where videos.id = $1;
$func$
language sql;
create or replace view notifications
as
select
'like' as type,
videos.user_id as receiver_user_id,
null as comment_text,
videos.id as video_id,
videos.thumbnail_url as video_thumbnail_url,
likes.user_id as action_user_id,
users.name as action_user_name,
users.image_url as action_user_image_url,
likes.created_at
from likes
join users on likes.user_id = users.id
join videos on videos.id = likes.video_id
union all
select
'comment' as type,
videos.user_id as receiver_user_id,
comments.text as comment_text,
videos.id as video_id,
videos.thumbnail_url as video_thumbnail_url,
comments.user_id as action_user_id,
users.name as action_user_name,
users.image_url as action_user_image_url,
comments.created_at
from comments
join users on comments.user_id = users.id
join videos on videos.id = comments.video_id
union all
select
'follow' as type,
follow.followed_user_id as receiver_user_id,
null as commennt_text,
null as video_id,
null as video_thumbnail_url,
follow.following_user_id as action_user_id,
users.name as action_user_name,
users.image_url as action_user_image_url,
follow.followed_at as created_at
from follow
join users on follow.following_user_id = users.id
order by created_at desc;
-- configure storage
INSERT IGNORE INTO storage.buckets (id, name) values ('videos', 'videos');
INSERT IGNORE INTO storage.buckets (id, name) values ('profiles', 'profiles');
create policy "videos buckets are public" on storage.objects for select using (bucket_id = 'videos');
create policy "profiles buckets are public" on storage.objects for select using (bucket_id = 'profiles');
create policy "uid has to be the first element in path_tokens" on storage.objects for insert with check (auth.uid()::text = path_tokens[1] and array_length(path_tokens, 1) = 2);
-- needed to use extensions from the app
grant usage on schema extensions to anon;
grant usage on schema extensions to authenticated;
getting started ��
this project contains 3 flavors:
- development
- staging
- production
to run the desired flavor either use the launch configuration in vscode/android studio or use the following commands:
# development
$ flutter run --flavor development --target lib/main_development.dart --dart-define=supabase_url=[supabase url] --dart-define=supabase_annon_key=[supabase annon key]
# staging
$ flutter run --flavor staging --target lib/main_staging.dart
# production
$ flutter run --flavor production --target lib/main_production.dart --dart-define=supabase_url=[supabase url] --dart-define=supabase_annon_key=[supabase annon key]
*spot works on ios and android.
running tests ��
to run all unit and widget tests use the following command:
$ flutter test --coverage --test-randomize-ordering-seed random
to view the generated coverage report you can use lcov.
# generate coverage report
$ genhtml coverage/lcov.info -o coverage/
# open coverage report
$ open coverage/index.html
working with translations ��
this project relies on [flutter_localizations][flutter_localizations_link] and follows the [official internationalization guide for flutter][internationalization_link].
adding strings
- to add a new localizable string, open the
app_en.arb
file atlib/l10n/arb/app_en.arb
.
{
"@@locale": "en",
"counterappbartitle": "counter",
"@counterappbartitle": {
"description": "text shown in the appbar of the counter page"
}
}
- then add a new key/value and description
{
"@@locale": "en",
"counterappbartitle": "counter",
"@counterappbartitle": {
"description": "text shown in the appbar of the counter page"
},
"helloworld": "hello world",
"@helloworld": {
"description": "hello world text"
}
}
- use the new string
import 'package:spot/l10n/l10n.dart';
@override
widget build(buildcontext context) {
final l10n = context.l10n;
return text(l10n.helloworld);
}
adding supported locales
update the cfbundlelocalizations
array in the info.plist
at ios/runner/info.plist
to include the new locale.
...
<key>cfbundlelocalizations</key>
<array>
<string>en</string>
<string>es</string>
</array>
...
adding translations
- for each supported locale, add a new arb file in
lib/l10n/arb
.
├── l10n
│ ├── arb
│ │ ├── app_en.arb
│ │ └── app_es.arb
- add the translated strings to each
.arb
file:
app_en.arb
{
"@@locale": "en",
"counterappbartitle": "counter",
"@counterappbartitle": {
"description": "text shown in the appbar of the counter page"
}
}
app_es.arb
{
"@@locale": "es",
"counterappbartitle": "contador",
"@counterappbartitle": {
"description": "texto mostrado en la appbar de la página del contador"
}
}
Comments are closed.