Skip to content

Latest commit

 

History

History
158 lines (118 loc) · 4.36 KB

README.md

File metadata and controls

158 lines (118 loc) · 4.36 KB

🕙 ClockWork

A basic clock app, with all the main features like alarms,stopwatch and clock as available natively in a smartphone.

👷 Description

The clock app in our phone is a very interesting one, it has alarms, stopwatch ,timmer,clock (obiously 😀).Implementing them togerther was fun ,and here are the results that I came forward with.

⏰ Alarm Clock

The alarm clock which can be used obiously to create alarms.This sub app consists of 2 parts creating an

  • Show Alarms The alarms will be shown here with a option to turn off the alrms

  • Creating Alarms Now we will create an alarm , An alarm can have 4 arguments, The argumets are self explanitory.

    • Daily or Once
    • Alarm Label Notification Title
    • Vibrate
    • Delete after turned off
  • Alarms For the alarms we take help of which gives us the ability to run Isolates in background, and paired up with flutter_local_notifications and flutter_vibrate helps to create a perfect alarm.

android_alarm_manager_plus: ^2.0.5
flutter_local_notifications: ^9.7.0
flutter_vibrate: ^1.3.0
How to use Alarm manager

As it's the most difficult topic in this project, so it's good to share some snippets

One shot Alarm This alarm will be assigned only once in the given
  DateTime dateTime
  await AndroidAlarmManager.oneShotAt(
    datetime,
    alarm_id,
    (){
      // A function inplementing the background call
    },
    alarmClock: true,
    wakeup: true,
    exact: true);
Periodic Alarms This alarm will be assigned periodically
  DateTime dateTime
 await AndroidAlarmManager.periodic(
    const Duration(days: 1), // periodic range
        0, // alarmID
        (){
          // A function implementing the background call
        },
        startAt: dateTime, // After what time to start the periodic call
        wakeup: true,
        exact: true,
      );

🕰️ Clock

There is no clock app without a clock itself 😆. Thus I made a simple analog clock, which shows the current time. Simple right. But the cache is 🤟you can add multiple timezones which shows there's time.

Timezone The timezone data is being taken from http://worldtimeapi.org/

Schema for the api
   curl "http://worldtimeapi.org/api/timezone/Asia/Kolkata"
{
  "abbreviation": "IST",
  "client_ip": "202.78.234.207",
  "datetime": "2022-10-01T23:42:19.812452+05:30",
  "day_of_week": 6,
  "day_of_year": 274,
  "dst": false,
  "dst_from": null,
  "dst_offset": 0,
  "dst_until": null,
  "raw_offset": 19800,
  "timezone": "Asia/Kolkata",
  "unixtime": 1664647939,
  "utc_datetime": "2022-10-01T18:12:19.812452+00:00",
  "utc_offset": "+05:30",
  "week_number": 39
}

The timezone data is then cached to the localstorage with hive.So that there is just a single api call , then the data can be loaded from the database.

⏱ Stopwatch

This sub app is a simple stopwatch with the functionality to create laps. ⚠️ These laps are not be saved in a database, but the laps are persistance in the app lifecycle.

♻️ Run this app

To contribute to this project follow the instructions

  git clone https://github.com/tuuhin/clockwork
  cd clockwork

Adding dependencies

  flutter pub get
  flutter pub run build_runner build

Run the project

  flutter run

🔚 Conclusion

Its a basic all in one clock app , the stopwatch and clock works well , there is some bugs associated with it, mainly the the alarm clock part but I am ending the project here, as it meets most of the requirements of a clock app