Coder Social home page Coder Social logo

ersiver / gymific Goto Github PK

View Code? Open in Web Editor NEW
50.0 1.0 13.0 93.29 MB

Home-workout app. Demonstrates DataStore, Hilt, MVVM, DataBinding, Kotlin Flow.

License: Apache License 2.0

Kotlin 100.00%
datastore-android hilt mvvm mvvm-architecture workout-apps android-architecture-components datastore-kotlin kotlin-coroutines kotlin-flow workmanager

gymific's Introduction

Gymific

Gymific is a home workout app illustrating Android development best practices: Hilt, Preferences DataStore, WorkManager, DataBinding, Kotlin Coroutines & Flow.

Overview

  • Gymific has 3 main destinations that can be accessible from anywhere in the app by the Bottom Navigation set with Navigation Components.
  • The Home and Workout screens start with lists of pre-populated data. Loading raw data into Room database is scheduled with WorkManager's OneTimeWorkRequest.
  • The Workout screen consists of ViewPager2 with Tabs that organize workouts across 3 different screens basing on workout's categories.
  • The Favourite screen displays list of user's selections. The list of favourite has an option to sort data. UserPreferenceRepository class holds the sort order, defined as an enum. The current sort order is saved in Jetpack DataStore.
  • The Detail screen demonstrates custom ProgressBar that displays running time in the center of the "moving" ring. The timer has an option to pause the time, which is then stored in Jetpack DataStore.
  • WorkoutRepository is responsible for providing the workouts and exposes them via Flow, which are converted to LiveData in the ViewModels and the UiModel objects wrap the objects that needs to be displayed in the UI.
  • Data Binding Library is used to display recurrent lists and workout details, handle clickListeners and manage buttons behaviours. Where data binding was not an intuitive option, the UI components were bind programmatically.

Tech stack & Open-source libraries

Android Architecture Components & good practices:

  • DataBinding - the app binds the UI components in the XML layout to data sources using a DataBinding and custom BindingAdapters.
  • Room Persistent Library - to access app's SQLite database.
  • DataStore - used to persist sort order and paused the workout time.
  • ViewModel - hold all the elements necessary to build the data that needs to be displayed in the UI.
  • Lifecycles - create a UI that automatically responds to lifecycle events.
  • WorkManager - to pre-populate Room database with raw data.
  • LiveData - build data objects that notify views when the underlying database changes.
  • Navigation for navigation between different screens.
  • SafeArgs for passing data between fragments.
  • Dagger-Hilt for dependency injection.

Third party:

  • Kotlin Coroutines and Flow for managing background threads with simplified code and reducing needs for callbacks
  • Timber for logs.

Architecture:

  • MVVM Architecture
  • Repository pattern

Testing

Device Tests:

  • App Navigation Test - Navigation between screens is tested using Espresso UI framework and ActivityScenario for lifecycle state. Hilt provides test version of Repository and automatically generates a new set of components for each test. This is done with use of a CustomTestRunner that uses an Application configured with Hilt. In order to make Espresso aware of data binding DataBindingIdlingResource is registered for UI test.
  • Database Testing - Database is tested with small instrumented unit tests. The project creates an in memory database for each database test but still runs them on the device.
  • WorkManager Testing - The app tests CoroutineWorkers with TestListenableWorkerBuilder. WorkerFactory is injected with use of HiltAndroidRule.

Local Tests:

  • ViewModel Tests - ViewModels are tested using local unit tests with implementation of Repository mocked using Mockito.
  • Repository Tests - Repository is tested using local unit tests with mock versions of dao.

Design

  • Gymific is built with Material Components for Android.
  • The app has a Bottom Navigation, which provides access to main destinations.
  • The home screen displays horizontally and vertically oriented lists.
  • The Workout screen has swipe views with tabs (using ViewPager2) and top app bars, that hides on scroll.
  • The detail screen demonstrates custom ProgressBar with gradient ring.
  • The sort menu is built with checkable menu items and the only one item from the group can be checked with use of radio buttons.
  • Adding a workout to the list of favourite takes place by pressing the icon in the menu. The icon will changed appropriately indicating an option to remove the.
  • The buttons, menus and progress indicators are customized for colors and shapes.
  • All clickable components behave intuitively changing their appearance when they are pressed.

Resource

Gymific uses graphic resources from freepik.

Preview



License

License

Copyright 2020 Ersiver

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

gymific's People

Contributors

ersiver avatar thanosfisherman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

gymific's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.