r/reactnative • u/monitoringaspects • Dec 07 '19
I made a visual timer using react native!
8
u/monitoringaspects Dec 07 '19 edited Dec 07 '19
I want to have a nice customizable visual timer but it was hard to fulfill my needs from other apps. So I decided to make one for myself. I had an experience with swift though, I’m preferred to write js code so I used react native.
My biggest huddle was performance and still worrisome. The clock animation is a part of react-native-svg with d3js calculation function and it is not that fast on the js layer of RN. I put memorization on that code then it is better than before. I want to replace this part soon.
My regrettable decision was that I choose react-native-mongodb for storing data. It is good for simple thing but the maintenance stopped after I started using it ☹️ I didn’t see that coming. At least I have a service layer for manipulating data so I hope I can replace the package sometime in the future.
I want to put the app on Android too but somehow it is very slow then I expected. Also, I have 0 knowledge from Android. I spent a lot of time on android build for config, setting, etc. then decided to stop at this moment because my final is next week. My family is an android family except me... so I should look it up again.
I’m happy when someone puts the nicest things on my app review. It doesn’t make big money but I made something good for someone else. Also, I like my app as a user ☺️☺️
Let me know if you have any questions. Thanks for the reading and happy coding!
If you want to see the app, here is the link you can check: https://apps.apple.com/app/id1458639178
1
u/readitron Dec 28 '19
dang, I'm building an app right now using mongodb. what would you go instead? seems like a lot of people are using monogodb. are you saying its not good for scalability?
3
u/Dyka94 Dec 08 '19
Nice job and that UI I love it.
How much time do you spent with it?
2
u/monitoringaspects Dec 08 '19
I didn’t have a record or something but I spent total approx. 3 months before the initial release. The core development was around 1.5-2 months, then took a lot of time for resource prep such as screenshot for app store, language support, images and sounds in the app. I think I did 20hrs per week most of time and did some crunch (near 40hrs) before release.
2
2
2
u/ismael_m Dec 07 '19
Do the timers continue when you kill the app or send to background? This is one good looking app dude! Congratulations
3
u/monitoringaspects Dec 07 '19
Thank you :) iOS has a limitation on background, but the app sends a push notification when the timer ends even the app is on the background or terminated.
2
2
2
u/rajatrao777 Dec 08 '19
Vey nice...did you build the on completion part ribbon celebration etc animation using css ?
2
u/monitoringaspects Dec 08 '19
I used lottie from Airbnb. They provide react-native-lottie too. It is a super cool library.
2
u/JackRyu iOS & Android Dec 08 '19
App link please....
1
u/monitoringaspects Dec 08 '19
Thanks for asking. The link is here: https://apps.apple.com/app/id1458639178
2
u/yhjohn Dec 08 '19
Hey without looking at code,. What did you use to do timer? As far as I know it. Setinterval has a limitation that is the timer will drift compared to the actual time.
2
u/monitoringaspects Dec 08 '19
Yes, setInverval is inaccurate if the code depends on the time interval directly. So I made that setInterval updates new datetime into state and the components rely on that state.
1
Dec 20 '19
Can you elaborate on what you mean by code depends on time interval directly?
2
u/monitoringaspects Dec 20 '19
This code doesn't guarantee 1 execution per second.
setInterval(() => { doSomething(); }, 1000);So you need something like this.
let now = new Date(); setInterval(() => { const newDate = new Date(); if (newDate - now >= 1000) { now = newDate; doSomething(); } }, 0);1
Dec 20 '19
Ah, got it. So in the do something, you would display the timer or something like that.
1
u/monitoringaspects Dec 20 '19
Yes I did calculation using new date when interval hits.
1
Dec 23 '19
What role is the const playing here?
Because the interval for setinterval is 0 with your workaround, is there any downsides to it constantly running? I know the do something isn't happening every time but still.
1
u/monitoringaspects Dec 23 '19
0 is an example number. I put 66-ish. `newDate` gets the current time and compares the time with stored time.
1
Dec 23 '19
Oh okay. I thought that you had put 0.
How come sometimes we use "let" and sometimes we use "var"?
I'm trying to implement a timer. The irony of my Reddit username and me figuring this out is not lost on me.
2
1
u/thedevxen Dec 22 '19
The UI is awesome. Can I ask which UI framework did you used, or you styled them your own?
2
u/monitoringaspects Dec 22 '19
I styled the components using StyleSheet which is builtin styling. It wasn’t that hard than I thought.
2
2
2
2
2
1
1
May 01 '20
Sort of stuck on implementing my own timer because I don't think I understand the basics.
0
Dec 20 '19
[deleted]
1
u/monitoringaspects Dec 22 '19
I made these components by myself and it wasn’t that hard if you are familiar with CSS styling. The watchface is the only part that I uses d3js.
20
u/[deleted] Dec 07 '19
Love the UI, almost 1-1 native. Reminds me of Siri Shortcuts good job.