So, today I am going to show you two tutorials in one tutorial, one, how can you create a scratch card app using Kodular and second, how can you restrict an user from multiple tasks, that user have to wait for an hour (or a several minute that is set by you) to attempt again for a task.
First of all I have created an app with Login and Signup screens, using Firebase Authentication. If you don’t know how to do so, then click here. Now let’s start main parts.
Here I have create a very simple design, I have dragged some Labels to show user name, user balance etc. After this I have dragged a button for Scratch Card. If clicked on this button it will go to another screen which is Scratch screen. Now, if your user recently scratched (within an hour) then your user will see a notice like this : You can Scratch again after an hour
I have dragged a Firebase Database here to get the Points, Name and Time (for task restriction) values. In the Signup screen the values were inserted, and saved UserID in TinyDB as id, just follow the Signup steps to know more. Now in Home screen, drag a Clock, clock will help you to get the current time and also help to know that is the Time value done or not (i.e. is 1 hour done for an user or not). So in the Clock, just untick Timer Always Fires and untick Timer Enabled.
Scratch Card Screen
Here just drag a Card View from Layout and set Height and Width as 40 percent and 60 percent, fill background with Deep Orange colour, set Align Horizontal and Align Vertical as Center. Now drag a Canvas from Drawing and Animation into the Card View and set Height and Width as fill parent. Now drag a Label after that, it will show the main Points of the user, it will be a hidden label so untick the Visible. Now drag a Notifier, Firebase Database, Tiny DB and Clock. Here Clock will work for two process, one for Scratch Card, after the users touched the scratch card or the user scratches a little and then leave it then the clock will enabled and after 3 seconds it automatically scratched fully, and another work for Clock is to store the Scratch Time to the Firebase Database to check the user scratch time. So set Clock Timer Interval to 3000 and also untick Timer Always Fires and untick Timer Enabled.