Welcome back.
We finished from Uber Clue map.
We created the box that contains Google Map, expandable fab and disappearing scale bar Composables.
Now let's move to the Firebase section.
We need to create Firebase Firestore database that stores markers.
So when the user requests a ride his current location will be uploaded to the markers collection in
Firebase Firestore database.
Then received and retrieved by the driver in order to display the markers for the driver.
So we have two types the driver and the user or a customer okay.
So we have two types of permissions or users.
The customer the the one who need a drive driver and the driver itself okay.
So we need to upload the marker to Firebase Firestore following the MVVM architecture we're going to
start with the new package called repository.
So create a new repository package I'll name it as repositories.
Inside this repository create a new Kotlin.
You can create them in one file or you can make them in a separate file.
We need the marker repository and the marker repository implementation.
The first one is interface and the second one is a class.
So as we learned before we have the interface for the repository and its implementation, which is a
class I prefer to make everything separate and very clear.
So let's start with marker repository.
This interface for now has one function called add marker.
So marker is of type lat long and name it's of type string.
We can add more more parameters, but for now, it's good.
Now let's create its implementation.
Kotlin new class named as marker repository implementation.
This class needs to inject the constructor and as we learned before we need to set the firebase which
is Firebase Firestore parameter.
If you have any question please don't be shy.
Ask me and I'll respond.
Also if you have any doubt you can refer to the previous examples and the previous sections in order
to learn more about dependency injection.
But don't worry I will lecture here in a quick recap.
What we've done here.
We created the marker repository interface.
Marker repository is a Kotlin interface, which is for example, a contract that defines what methods
a class should implement.
The suspend function means this function is a suspending function, so it can be called inside a coroutine.
It takes a marker object Latlong.
Latitude and longitude coordinates and the name which is of type string.
It doesn't return any thing.
The marker repository implementation is a class that implements the marker repository interface.
The inject constructor tells a dependency injection framework, which is in this case the hilt framework.
How to create this class?
It needs a Firebase Firestore instance passed in automatically.
Firebase Firestore.
This is the Firebase Firestore database object from the Firebase SDK used to read or write data in your
Firestore Database.
So the first step is creating this interface to define what your repository does.
The capability to add a marker without carrying how it does it makes your code testable and swappable.
You can later have Firebase marker repository that tries to Firebase uh, also saving a local database
or for testing.
Okay.
So we're going to use it as a marker in order to insert markers into database.
So we use this clean architecture interface defines what you can do.
This interface defines what you can do.
The repository implementation defines how you do it okay.
The interface defines what you can do like adding markers.
The implementation defines how you do it okay.
Here we need to implement the function add marker.
And here we're going to define how we can do it how we can add markers.
So I want from you to understand concepts guys I'm not uh I don't uh want from you to copy and paste
codes or follow me typing.
I want from you to understand concepts.
So here we are defining what you can do.
Add marker.
Remove marker.
Delete database.
Delete markers.
Clean architecture.
Clean the whole map, draw Polylines.
Here inside the implementation we define how we can do it.
So we have this red line.
This arrow we need to implement members which is the add marker inherited from marker repository okay.
In the next video we're going to continue with this add marker.
And we're going to define how we can do the add marker function.