├── linux ├── .gitignore ├── main.cc ├── flutter │ ├── generated_plugin_registrant.h │ ├── generated_plugin_registrant.cc │ ├── generated_plugins.cmake │ └── CMakeLists.txt ├── my_application.h └── my_application.cc ├── ios ├── Flutter │ ├── Debug.xcconfig │ ├── Release.xcconfig │ └── AppFrameworkInfo.plist ├── Runner │ ├── Runner-Bridging-Header.h │ ├── Assets.xcassets │ │ ├── LaunchImage.imageset │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ ├── README.md │ │ │ └── Contents.json │ │ └── AppIcon.appiconset │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ └── Contents.json │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard │ └── Info.plist ├── Runner.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── WorkspaceSettings.xcsettings │ │ └── IDEWorkspaceChecks.plist ├── RunnerTests │ └── RunnerTests.swift └── .gitignore ├── macos ├── Flutter │ ├── Flutter-Debug.xcconfig │ ├── Flutter-Release.xcconfig │ └── GeneratedPluginRegistrant.swift ├── Runner │ ├── Configs │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ ├── Warnings.xcconfig │ │ └── AppInfo.xcconfig │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ ├── app_icon_1024.png │ │ │ ├── app_icon_128.png │ │ │ ├── app_icon_16.png │ │ │ ├── app_icon_256.png │ │ │ ├── app_icon_32.png │ │ │ ├── app_icon_512.png │ │ │ ├── app_icon_64.png │ │ │ └── Contents.json │ ├── AppDelegate.swift │ ├── Release.entitlements │ ├── DebugProfile.entitlements │ ├── MainFlutterWindow.swift │ └── Info.plist ├── .gitignore ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── Runner.xcodeproj │ ├── project.xcworkspace │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme └── RunnerTests │ └── RunnerTests.swift ├── web ├── favicon.png ├── icons │ ├── Icon-192.png │ ├── Icon-512.png │ ├── Icon-maskable-192.png │ └── Icon-maskable-512.png ├── manifest.json └── index.html ├── screenshots ├── list.png ├── activity.png ├── activity1.png ├── Screenshot from 2023-10-02 15-46-00.png ├── Screenshot from 2023-10-02 15-46-05.png ├── Screenshot from 2023-10-02 15-46-11.png └── Screenshot from 2023-10-02 15-46-14.png ├── l10n.yaml ├── android ├── gradle.properties ├── app │ ├── src │ │ ├── main │ │ │ ├── res │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── drawable │ │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable-v21 │ │ │ │ │ └── launch_background.xml │ │ │ │ ├── values │ │ │ │ │ └── styles.xml │ │ │ │ └── values-night │ │ │ │ │ └── styles.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── run_tracker │ │ │ │ │ └── MainActivity.kt │ │ │ └── AndroidManifest.xml │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ └── profile │ │ │ └── AndroidManifest.xml │ └── build.gradle ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── .gitignore ├── settings.gradle └── build.gradle ├── windows ├── runner │ ├── resources │ │ └── app_icon.ico │ ├── resource.h │ ├── utils.h │ ├── runner.exe.manifest │ ├── flutter_window.h │ ├── main.cpp │ ├── CMakeLists.txt │ ├── utils.cpp │ ├── flutter_window.cpp │ ├── Runner.rc │ └── win32_window.h ├── .gitignore ├── flutter │ ├── generated_plugin_registrant.h │ ├── generated_plugin_registrant.cc │ ├── generated_plugins.cmake │ └── CMakeLists.txt └── CMakeLists.txt ├── lib ├── l10n │ ├── support_locale.dart │ ├── app_en.arb │ └── app_en_US.arb ├── presentation │ ├── common │ │ ├── core │ │ │ ├── utils │ │ │ │ ├── ui_utils.dart │ │ │ │ ├── share_utils.dart │ │ │ │ ├── map_utils.dart │ │ │ │ ├── color_utils.dart │ │ │ │ ├── form_utils.dart │ │ │ │ ├── activity_utils.dart │ │ │ │ └── image_utils.dart │ │ │ ├── widgets │ │ │ │ ├── date.dart │ │ │ │ └── share_map_button.dart │ │ │ ├── validators │ │ │ │ └── login_validators.dart │ │ │ └── services │ │ │ │ └── text_to_speech_service.dart │ │ ├── metrics │ │ │ ├── view_model │ │ │ │ ├── metrics_state.dart │ │ │ │ └── metrics_view_model.dart │ │ │ └── widgets │ │ │ │ └── metrics.dart │ │ ├── timer │ │ │ ├── widgets │ │ │ │ ├── timer_sized.dart │ │ │ │ ├── timer_text.dart │ │ │ │ ├── timer_pause.dart │ │ │ │ └── timer_start.dart │ │ │ └── viewmodel │ │ │ │ └── timer_state.dart │ │ └── location │ │ │ ├── widgets │ │ │ ├── location_map.dart │ │ │ └── current_location_map.dart │ │ │ └── view_model │ │ │ ├── location_state.dart │ │ │ └── location_view_model.dart │ ├── home │ │ ├── view_model │ │ │ ├── home_state.dart │ │ │ └── home_view_model.dart │ │ └── screen │ │ │ └── home_screen.dart │ ├── settings │ │ └── view_model │ │ │ ├── settings_state.dart │ │ │ └── settings_view_model.dart │ ├── send_new_password │ │ └── view_model │ │ │ ├── send_new_password_state.dart │ │ │ └── send_new_password_view_model.dart │ ├── login │ │ └── view_model │ │ │ ├── login_state.dart │ │ │ └── login_view_model.dart │ ├── sum_up │ │ ├── view_model │ │ │ ├── sum_up_state.dart │ │ │ └── sum_up_view_model.dart │ │ └── widgets │ │ │ └── save_button.dart │ ├── activity_details │ │ ├── widgets │ │ │ └── back_to_home_button.dart │ │ └── view_model │ │ │ └── activitie_details_state.dart │ ├── activity_list │ │ ├── view_model │ │ │ ├── activity_list_state.dart │ │ │ └── activity_list_view_model.dart │ │ └── screen │ │ │ └── activity_list_screen.dart │ ├── registration │ │ └── view_model │ │ │ ├── registration_state.dart │ │ │ └── registration_view_model.dart │ ├── edit_password │ │ └── view_model │ │ │ ├── edit_password_state.dart │ │ │ └── edit_password_view_model.dart │ └── new_activity │ │ └── screen │ │ └── new_activity_screen.dart ├── core │ ├── error.dart │ └── utils │ │ └── sharedPrefs_utils.dart ├── data │ ├── model │ │ ├── request │ │ │ ├── send_new_password_request.dart │ │ │ ├── login_request.dart │ │ │ ├── edit_password_request.dart │ │ │ ├── location_request.dart │ │ │ └── activity_request.dart │ │ └── response │ │ │ ├── login_response.dart │ │ │ ├── location_response.dart │ │ │ └── activity_response.dart │ ├── repositories │ │ ├── activity_repository_impl.dart │ │ └── user_repository_impl.dart │ └── api │ │ ├── activity_api.dart │ │ └── user_api.dart ├── domain │ ├── entities │ │ ├── location.dart │ │ ├── enum │ │ │ └── activity_type.dart │ │ └── activity.dart │ └── repositories │ │ ├── activity_repository.dart │ │ └── user_repository.dart └── main.dart ├── README.md ├── .gitignore ├── pubspec.yaml ├── analysis_options.yaml └── .metadata /linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/web/favicon.png -------------------------------------------------------------------------------- /screenshots/list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/screenshots/list.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/web/icons/Icon-512.png -------------------------------------------------------------------------------- /l10n.yaml: -------------------------------------------------------------------------------- 1 | arb-dir: lib/l10n 2 | template-arb-file: app_en.arb 3 | output-localization-file: app_localizations.dart -------------------------------------------------------------------------------- /screenshots/activity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/screenshots/activity.png -------------------------------------------------------------------------------- /screenshots/activity1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/screenshots/activity1.png -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /screenshots/Screenshot from 2023-10-02 15-46-00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/screenshots/Screenshot from 2023-10-02 15-46-00.png -------------------------------------------------------------------------------- /screenshots/Screenshot from 2023-10-02 15-46-05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/screenshots/Screenshot from 2023-10-02 15-46-05.png -------------------------------------------------------------------------------- /screenshots/Screenshot from 2023-10-02 15-46-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/screenshots/Screenshot from 2023-10-02 15-46-11.png -------------------------------------------------------------------------------- /screenshots/Screenshot from 2023-10-02 15-46-14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/screenshots/Screenshot from 2023-10-02 15-46-14.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mo7amedaliEbaid/run-tracker/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /lib/l10n/support_locale.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | interface class L10n { 4 | static const List support = [ 5 | Locale("en"), 6 | Locale("en", "US"), 7 | ]; 8 | } 9 | -------------------------------------------------------------------------------- /linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/run_tracker/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.run_tracker 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip 6 | -------------------------------------------------------------------------------- /macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/presentation/common/core/utils/ui_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_spinkit/flutter_spinkit.dart'; 3 | 4 | interface class UIUtils { 5 | 6 | static const loader = SpinKitThreeBounce( 7 | color: Colors.blueGrey, 8 | size: 50.0, 9 | ); 10 | } 11 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/core/error.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | interface class Failure extends Equatable { 4 | final String message; 5 | 6 | const Failure({required this.message}); 7 | 8 | @override 9 | List get props => [message]; 10 | 11 | @override 12 | bool get stringify => true; 13 | } 14 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /ios/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /macos/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import FlutterMacOS 2 | import Cocoa 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /lib/presentation/home/view_model/home_state.dart: -------------------------------------------------------------------------------- 1 | interface class HomeState { 2 | final int currentIndex; 3 | 4 | const HomeState({required this.currentIndex}); 5 | 6 | factory HomeState.initial() { 7 | return const HomeState(currentIndex: 0); 8 | } 9 | 10 | HomeState copyWith({ 11 | int? currentIndex, 12 | }) { 13 | return HomeState( 14 | currentIndex: currentIndex ?? this.currentIndex, 15 | ); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/data/model/request/send_new_password_request.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | interface class SendNewPasswordRequest extends Equatable { 4 | final String email; 5 | 6 | const SendNewPasswordRequest({required this.email}); 7 | 8 | @override 9 | List get props => [email]; 10 | 11 | Map toMap() { 12 | return {'email': email}; 13 | } 14 | 15 | @override 16 | bool get stringify => true; 17 | } 18 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lib/presentation/settings/view_model/settings_state.dart: -------------------------------------------------------------------------------- 1 | interface class SettingsState { 2 | final bool isLoading; 3 | 4 | const SettingsState({ 5 | required this.isLoading, 6 | }); 7 | 8 | factory SettingsState.initial() { 9 | return const SettingsState( 10 | isLoading: false, 11 | ); 12 | } 13 | 14 | SettingsState copyWith({ 15 | bool? isLoading, 16 | }) { 17 | return SettingsState( 18 | isLoading: isLoading ?? this.isLoading, 19 | ); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib/domain/entities/location.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | interface class Location extends Equatable { 4 | final String id; 5 | final DateTime datetime; 6 | final double latitude; 7 | final double longitude; 8 | 9 | const Location({ 10 | required this.id, 11 | required this.datetime, 12 | required this.latitude, 13 | required this.longitude, 14 | }); 15 | 16 | @override 17 | List get props => [id, datetime, latitude, longitude]; 18 | } 19 | -------------------------------------------------------------------------------- /lib/domain/repositories/activity_repository.dart: -------------------------------------------------------------------------------- 1 | import '../../data/model/request/activity_request.dart'; 2 | import '../entities/activity.dart'; 3 | 4 | abstract class ActivityRepository { 5 | Future> getActivities(); 6 | 7 | Future getActivityById({required String id}); 8 | 9 | Future removeActivity({required String id}); 10 | 11 | Future addActivity(ActivityRequest request); 12 | 13 | Future editActivity(ActivityRequest request); 14 | } 15 | -------------------------------------------------------------------------------- /windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # run_tracker 2 | A flutter run tracker app - live tracking - Clean architecture. 3 | 4 | It's a run tracker app to track the distance , speed and time of your activity (running, cycling,......). 5 | 6 | ### State Management 7 | - Riverpod 8 | 9 | ## Demo Video 10 | 11 | 12 | -------------------------------------------------------------------------------- /lib/data/model/request/login_request.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | interface class LoginRequest extends Equatable { 4 | final String username; 5 | final String password; 6 | 7 | const LoginRequest({ 8 | required this.username, 9 | required this.password, 10 | }); 11 | 12 | @override 13 | List get props => [username, password]; 14 | 15 | Map toMap() { 16 | return { 17 | 'username': username, 18 | 'password': password, 19 | }; 20 | } 21 | 22 | @override 23 | bool get stringify => true; 24 | } 25 | -------------------------------------------------------------------------------- /lib/data/model/response/login_response.dart: -------------------------------------------------------------------------------- 1 | interface class LoginResponse { 2 | final String refreshedToken; 3 | final String token; 4 | final String message; 5 | 6 | const LoginResponse({ 7 | required this.refreshedToken, 8 | required this.token, 9 | required this.message, 10 | }); 11 | 12 | factory LoginResponse.fromMap(Map map) { 13 | return LoginResponse( 14 | refreshedToken: map['refreshToken']?.toString() ?? '', 15 | token: map['token']?.toString() ?? '', 16 | message: map['message']?.toString() ?? '', 17 | ); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/domain/entities/enum/activity_type.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_gen/gen_l10n/app_localizations.dart'; 2 | 3 | enum ActivityType { running, walking, cycling } 4 | 5 | extension ActivityTypeExtension on ActivityType { 6 | String getTranslatedName(AppLocalizations localization) { 7 | switch (this) { 8 | case ActivityType.running: 9 | return localization.running; 10 | case ActivityType.walking: 11 | return localization.walking; 12 | case ActivityType.cycling: 13 | return localization.cycling; 14 | default: 15 | return ''; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | 11 | void fl_register_plugins(FlPluginRegistry* registry) { 12 | g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar = 13 | fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin"); 14 | flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar); 15 | } 16 | -------------------------------------------------------------------------------- /lib/presentation/home/view_model/home_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 2 | 3 | import 'home_state.dart'; 4 | 5 | final homeViewModelProvider = 6 | StateNotifierProvider.autoDispose( 7 | (ref) => HomeViewModel(ref), 8 | ); 9 | 10 | interface class HomeViewModel extends StateNotifier { 11 | final Ref ref; 12 | 13 | HomeViewModel(this.ref) : super(HomeState.initial()); 14 | 15 | int getCurrentIndex() { 16 | return state.currentIndex; 17 | } 18 | 19 | void setCurrentIndex(int index) { 20 | state = state.copyWith(currentIndex: index); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/data/model/request/edit_password_request.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | interface class EditPasswordRequest extends Equatable { 4 | final String currentPassword; 5 | final String password; 6 | 7 | const EditPasswordRequest({ 8 | required this.currentPassword, 9 | required this.password, 10 | }); 11 | 12 | @override 13 | List get props => [currentPassword, password]; 14 | 15 | Map toMap() { 16 | return { 17 | 'currentPassword': currentPassword, 18 | 'password': password, 19 | }; 20 | } 21 | 22 | @override 23 | bool get stringify => true; 24 | } 25 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /lib/domain/repositories/user_repository.dart: -------------------------------------------------------------------------------- 1 | import '../../data/model/request/edit_password_request.dart'; 2 | import '../../data/model/request/login_request.dart'; 3 | import '../../data/model/request/send_new_password_request.dart'; 4 | import '../../data/model/response/login_response.dart'; 5 | 6 | abstract class UserRepository { 7 | Future register(LoginRequest request); 8 | 9 | Future login(LoginRequest request); 10 | 11 | Future logout(); 12 | 13 | Future deleteaccount(); 14 | 15 | Future sendNewPasswordByMail(SendNewPasswordRequest request); 16 | 17 | Future editPassword(EditPasswordRequest request); 18 | } 19 | -------------------------------------------------------------------------------- /macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = run_tracker 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.runTracker 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2023 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /lib/presentation/send_new_password/view_model/send_new_password_state.dart: -------------------------------------------------------------------------------- 1 | interface class SendNewPasswordState { 2 | final String email; 3 | 4 | final bool isSending; 5 | 6 | const SendNewPasswordState({ 7 | required this.email, 8 | required this.isSending, 9 | }); 10 | 11 | factory SendNewPasswordState.initial() { 12 | return const SendNewPasswordState( 13 | email: '', 14 | isSending: false, 15 | ); 16 | } 17 | 18 | SendNewPasswordState copyWith({ 19 | String? email, 20 | bool? isSending, 21 | }) { 22 | return SendNewPasswordState( 23 | email: email ?? this.email, 24 | isSending: isSending ?? this.isSending, 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.7.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.3.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | tasks.register("clean", Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /lib/data/model/request/location_request.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | interface class LocationRequest extends Equatable { 4 | final String? id; 5 | final DateTime datetime; 6 | final double latitude; 7 | final double longitude; 8 | 9 | const LocationRequest({ 10 | this.id, 11 | required this.datetime, 12 | required this.latitude, 13 | required this.longitude, 14 | }); 15 | 16 | @override 17 | List get props => [datetime, latitude, longitude]; 18 | 19 | Map toMap() { 20 | return { 21 | 'id': id, 22 | 'datetime': datetime.toIso8601String(), 23 | 'latitude': latitude, 24 | 'longitude': longitude, 25 | }; 26 | } 27 | 28 | @override 29 | bool get stringify => true; 30 | } 31 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | void RegisterPlugins(flutter::PluginRegistry* registry) { 14 | FlutterSecureStorageWindowsPluginRegisterWithRegistrar( 15 | registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin")); 16 | FlutterTtsPluginRegisterWithRegistrar( 17 | registry->GetRegistrarForPlugin("FlutterTtsPlugin")); 18 | GeolocatorWindowsRegisterWithRegistrar( 19 | registry->GetRegistrarForPlugin("GeolocatorWindows")); 20 | } 21 | -------------------------------------------------------------------------------- /lib/presentation/common/core/widgets/date.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_gen/gen_l10n/app_localizations.dart'; 3 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 4 | import 'package:intl/intl.dart'; 5 | 6 | class Date extends HookConsumerWidget { 7 | final DateTime date; 8 | 9 | 10 | const Date({Key? key, required this.date}) : super(key: key); 11 | 12 | @override 13 | Widget build(BuildContext context, WidgetRef ref) { 14 | final appLocalizations = AppLocalizations.of(context); 15 | final formattedDateTime = 16 | DateFormat('dd/MM/yyyy ${appLocalizations!.hours_pronoun} HH:mm') 17 | .format(date); 18 | 19 | return Text( 20 | '${appLocalizations.date_pronoun} $formattedDateTime', 21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/presentation/login/view_model/login_state.dart: -------------------------------------------------------------------------------- 1 | interface class LoginState { 2 | final String username; 3 | 4 | final String password; 5 | 6 | final bool isLogging; 7 | 8 | const LoginState({ 9 | required this.username, 10 | required this.password, 11 | required this.isLogging, 12 | }); 13 | 14 | factory LoginState.initial() { 15 | return const LoginState( 16 | username: '', 17 | password: '', 18 | isLogging: false, 19 | ); 20 | } 21 | 22 | LoginState copyWith({ 23 | String? username, 24 | String? password, 25 | bool? isLogging, 26 | }) { 27 | return LoginState( 28 | username: username ?? this.username, 29 | password: password ?? this.password, 30 | isLogging: isLogging ?? this.isLogging, 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/presentation/sum_up/view_model/sum_up_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | 3 | import '../../../domain/entities/enum/activity_type.dart'; 4 | 5 | interface class SumUpState { 6 | final bool isSaving; 7 | final ActivityType type; 8 | final GlobalKey boundaryKey; 9 | 10 | const SumUpState( 11 | {required this.type, required this.isSaving, required this.boundaryKey}); 12 | 13 | factory SumUpState.initial() { 14 | return SumUpState( 15 | isSaving: false, type: ActivityType.running, boundaryKey: GlobalKey()); 16 | } 17 | 18 | SumUpState copyWith({ 19 | bool? isSaving, 20 | ActivityType? type, 21 | }) { 22 | return SumUpState( 23 | isSaving: isSaving ?? this.isSaving, 24 | type: type ?? this.type, 25 | boundaryKey: boundaryKey); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/presentation/activity_details/widgets/back_to_home_button.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 3 | 4 | import '../../activity_list/view_model/activity_list_view_model.dart'; 5 | 6 | /// A floating action button widget that allows the user to navigate back to the home screen. 7 | class BackToHomeButton extends HookConsumerWidget { 8 | const BackToHomeButton({Key? key}) : super(key: key); 9 | 10 | @override 11 | Widget build(BuildContext context, WidgetRef ref) { 12 | final provider = ref.watch(activityListViewModelProvider.notifier); 13 | 14 | return FloatingActionButton( 15 | backgroundColor: Colors.teal.shade800, 16 | elevation: 4.0, 17 | child: const Icon(Icons.arrow_back), 18 | onPressed: () { 19 | provider.backToHome(); 20 | }, 21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/presentation/common/metrics/view_model/metrics_state.dart: -------------------------------------------------------------------------------- 1 | /// Represents the state of metrics. 2 | class MetricsState { 3 | /// The distance covered. 4 | final double distance; 5 | 6 | /// The global speed. 7 | final double globalSpeed; 8 | 9 | /// Creates a new instance of [MetricsState]. 10 | const MetricsState({required this.distance, required this.globalSpeed}); 11 | 12 | /// Creates an initial instance of [MetricsState] with default values. 13 | factory MetricsState.initial() { 14 | return const MetricsState(distance: 0, globalSpeed: 0); 15 | } 16 | 17 | /// Creates a copy of [MetricsState] with optional updates. 18 | MetricsState copyWith({double? distance, double? globalSpeed}) { 19 | return MetricsState( 20 | distance: distance ?? this.distance, 21 | globalSpeed: globalSpeed ?? this.globalSpeed, 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | flutter_secure_storage_linux 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Symbolication related 36 | app.*.symbols 37 | 38 | # Obfuscation related 39 | app.*.map.json 40 | 41 | # Android Studio will place build artifacts here 42 | /android/app/debug 43 | /android/app/profile 44 | /android/app/release 45 | -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 11.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | flutter_secure_storage_windows 7 | flutter_tts 8 | geolocator_windows 9 | ) 10 | 11 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 12 | ) 13 | 14 | set(PLUGIN_BUNDLED_LIBRARIES) 15 | 16 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 17 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 18 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 20 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 21 | endforeach(plugin) 22 | 23 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 24 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 25 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 26 | endforeach(ffi_plugin) 27 | -------------------------------------------------------------------------------- /lib/presentation/common/timer/widgets/timer_sized.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 3 | 4 | import '../viewmodel/timer_view_model.dart'; 5 | import 'timer_text.dart'; 6 | 7 | /// A widget that displays the timer text with a fixed size. 8 | class TimerTextSized extends HookConsumerWidget { 9 | const TimerTextSized({Key? key}) : super(key: key); 10 | 11 | @override 12 | Widget build(BuildContext context, WidgetRef ref) { 13 | // ignore: unused_local_variable 14 | final state = ref.watch(timerViewModelProvider); 15 | // ignore: unused_local_variable 16 | final timerViewModel = ref.watch(timerViewModelProvider.notifier); 17 | 18 | return const Column( 19 | children: [ 20 | SizedBox( 21 | height: 125, 22 | child: Center( 23 | child: TimerText(), 24 | ), 25 | ) 26 | ], 27 | ); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /lib/presentation/common/timer/widgets/timer_text.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 3 | 4 | import '../viewmodel/timer_view_model.dart'; 5 | 6 | /// A widget that displays the timer text. 7 | class TimerText extends HookConsumerWidget { 8 | final int? timeInMs; 9 | 10 | const TimerText({Key? key, this.timeInMs}) : super(key: key); 11 | 12 | @override 13 | Widget build(BuildContext context, WidgetRef ref) { 14 | // ignore: unused_local_variable 15 | final state = ref.watch(timerViewModelProvider); 16 | final timerViewModel = ref.watch(timerViewModelProvider.notifier); 17 | 18 | const TextStyle timerTextStyle = 19 | TextStyle(fontSize: 60.0, fontFamily: "Open Sans"); 20 | 21 | return Text( 22 | timeInMs != null 23 | ? timerViewModel.getFormattedTime(timeInMs) 24 | : timerViewModel.getFormattedTime(), 25 | style: timerTextStyle, 26 | ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/domain/entities/activity.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | import 'enum/activity_type.dart'; 4 | import 'location.dart'; 5 | 6 | 7 | interface class Activity extends Equatable { 8 | final String id; 9 | final ActivityType type; 10 | final DateTime startDatetime; 11 | final DateTime endDatetime; 12 | final double distance; 13 | final double speed; 14 | final double time; 15 | final Iterable locations; 16 | 17 | const Activity({ 18 | required this.id, 19 | required this.type, 20 | required this.startDatetime, 21 | required this.endDatetime, 22 | required this.distance, 23 | required this.speed, 24 | required this.time, 25 | required this.locations, 26 | }); 27 | 28 | @override 29 | List get props => [ 30 | id, 31 | type, 32 | startDatetime, 33 | endDatetime, 34 | distance, 35 | speed, 36 | time, 37 | ...locations, 38 | ]; 39 | } 40 | -------------------------------------------------------------------------------- /macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import flutter_secure_storage_macos 9 | import flutter_tts 10 | import geolocator_apple 11 | import path_provider_foundation 12 | import shared_preferences_foundation 13 | import wakelock_macos 14 | 15 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 16 | FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin")) 17 | FlutterTtsPlugin.register(with: registry.registrar(forPlugin: "FlutterTtsPlugin")) 18 | GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin")) 19 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 20 | SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) 21 | WakelockMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockMacosPlugin")) 22 | } 23 | -------------------------------------------------------------------------------- /lib/presentation/activity_list/view_model/activity_list_state.dart: -------------------------------------------------------------------------------- 1 | import '../../../domain/entities/activity.dart'; 2 | 3 | /// The state class for the activity list. 4 | class ActivityListState { 5 | final List activities; // List of activities 6 | final bool isLoading; // Indicates if the list is currently loading 7 | 8 | const ActivityListState({required this.activities, required this.isLoading}); 9 | 10 | /// Factory method to create the initial state. 11 | factory ActivityListState.initial() { 12 | return const ActivityListState(activities: [], isLoading: false); 13 | } 14 | 15 | /// Method to create a copy of the state with updated values. 16 | ActivityListState copyWith({ 17 | List? activities, // Updated list of activities 18 | bool? isLoading, // Updated loading state 19 | }) { 20 | return ActivityListState( 21 | activities: activities ?? this.activities, 22 | isLoading: isLoading ?? this.isLoading, 23 | ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/presentation/common/core/utils/share_utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:typed_data'; 2 | 3 | import 'package:esys_flutter_share_plus/esys_flutter_share_plus.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_gen/gen_l10n/app_localizations.dart'; 6 | 7 | interface class ShareUtils { 8 | static Future shareImage(BuildContext context, Uint8List image) async { 9 | await Share.file('Run Flutter Run', 'run.png', image, 'image/png'); 10 | } 11 | 12 | /// Display a snackbar when share image failed 13 | static void showShareFailureSnackBar(BuildContext context) { 14 | ScaffoldMessenger.of(context).showSnackBar( 15 | SnackBar( 16 | content: Text(AppLocalizations.of(context)!.share_failed), 17 | duration: const Duration(seconds: 3), 18 | action: SnackBarAction( 19 | label: AppLocalizations.of(context)!.close, 20 | onPressed: () { 21 | ScaffoldMessenger.of(context).hideCurrentSnackBar(); 22 | }, 23 | ), 24 | ), 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "run_tracker", 3 | "short_name": "run_tracker", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /lib/presentation/registration/view_model/registration_state.dart: -------------------------------------------------------------------------------- 1 | interface class RegistrationState { 2 | final String username; 3 | final String password; 4 | final String checkPassword; 5 | final bool isLogging; 6 | 7 | /// Creates a new instance of [RegistrationState]. 8 | const RegistrationState({ 9 | required this.username, 10 | required this.password, 11 | required this.checkPassword, 12 | required this.isLogging, 13 | }); 14 | 15 | factory RegistrationState.initial() { 16 | return const RegistrationState( 17 | username: '', 18 | password: '', 19 | checkPassword: '', 20 | isLogging: false, 21 | ); 22 | } 23 | 24 | RegistrationState copyWith({ 25 | String? username, 26 | String? password, 27 | String? checkPassword, 28 | bool? isLogging, 29 | }) { 30 | return RegistrationState( 31 | username: username ?? this.username, 32 | password: password ?? this.password, 33 | checkPassword: checkPassword ?? this.checkPassword, 34 | isLogging: isLogging ?? this.isLogging, 35 | ); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/presentation/sum_up/widgets/save_button.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 3 | 4 | import '../view_model/sum_up_view_model.dart'; 5 | 6 | class SaveButton extends HookConsumerWidget { 7 | final bool disabled; 8 | 9 | const SaveButton({Key? key, required this.disabled}) : super(key: key); 10 | 11 | @override 12 | Widget build(BuildContext context, WidgetRef ref) { 13 | final provider = ref.read(sumUpViewModelProvider.notifier); 14 | const animationDuration = Duration(milliseconds: 300); 15 | 16 | return AnimatedOpacity( 17 | opacity: disabled ? 0.5 : 1.0, 18 | duration: animationDuration, 19 | child: FloatingActionButton( 20 | backgroundColor: Colors.teal.shade800, 21 | elevation: 4.0, 22 | onPressed: disabled 23 | ? null 24 | : () { 25 | provider.save(); 26 | Future.delayed(animationDuration, () { 27 | }); 28 | }, 29 | child: const Icon(Icons.save), 30 | ), 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/data/model/response/location_response.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | import '../../../domain/entities/location.dart'; 4 | 5 | interface class LocationResponse extends Equatable { 6 | final String id; 7 | final DateTime datetime; 8 | final double latitude; 9 | final double longitude; 10 | 11 | const LocationResponse({ 12 | required this.id, 13 | required this.datetime, 14 | required this.latitude, 15 | required this.longitude, 16 | }); 17 | 18 | @override 19 | List get props => [ 20 | id, 21 | datetime, 22 | latitude, 23 | longitude, 24 | ]; 25 | 26 | factory LocationResponse.fromMap(Map map) { 27 | return LocationResponse( 28 | id: map['id'].toString(), 29 | datetime: DateTime.parse(map['datetime']), 30 | latitude: (map['latitude'] as num?)?.toDouble() ?? 0.0, 31 | longitude: (map['longitude'] as num?)?.toDouble() ?? 0.0, 32 | ); 33 | } 34 | 35 | Location toEntity() { 36 | return Location( 37 | id: id, 38 | datetime: datetime, 39 | latitude: latitude, 40 | longitude: longitude, 41 | ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: run_tracker 2 | description: A new Flutter project. 3 | 4 | publish_to: 'none' 5 | 6 | version: 1.0.0+1 7 | 8 | environment: 9 | sdk: '>=3.0.5 <4.0.0' 10 | 11 | 12 | dependencies: 13 | flutter: 14 | sdk: flutter 15 | flutter_localizations: 16 | sdk: flutter 17 | geolocator: ^9.0.2 18 | intl: ^0.18.0 19 | 20 | 21 | cupertino_icons: ^1.0.2 22 | flutter_tts: ^3.6.2 23 | hooks_riverpod: ^2.3.6 24 | flutter_hooks: ^0.18.5+1 25 | flutter_map: ^4.0.0 26 | latlong2: ^0.8.1 27 | equatable: ^2.0.5 28 | dio: ^5.1.2 29 | stack_trace: ^1.11.0 30 | flutter_riverpod: ^2.3.6 31 | dio_smart_retry: ^5.0.0 32 | shared_preferences: ^2.1.2 33 | wakelock: ^0.6.2 34 | flutter_secure_storage: ^8.0.0 35 | email_validator: ^2.1.17 36 | quickalert: ^1.0.1 37 | flutter_spinkit: ^5.2.0 38 | coverage: ^1.6.3 39 | mockito: ^5.4.2 40 | screenshot: ^2.1.0 41 | image_gallery_saver: ^2.0.3 42 | path_provider: ^2.0.15 43 | esys_flutter_share_plus: ^2.2.0 44 | image: ^4.0.17 45 | 46 | dev_dependencies: 47 | flutter_test: 48 | sdk: flutter 49 | 50 | 51 | flutter_lints: ^2.0.0 52 | 53 | 54 | flutter: 55 | 56 | 57 | uses-material-design: true 58 | generate: true 59 | 60 | -------------------------------------------------------------------------------- /lib/data/model/request/activity_request.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | import '../../../domain/entities/enum/activity_type.dart'; 4 | import 'location_request.dart'; 5 | 6 | interface class ActivityRequest extends Equatable { 7 | final String? id; 8 | final ActivityType type; 9 | final DateTime startDatetime; 10 | final DateTime endDatetime; 11 | final double distance; 12 | final List locations; 13 | 14 | const ActivityRequest({ 15 | this.id, 16 | required this.type, 17 | required this.startDatetime, 18 | required this.endDatetime, 19 | required this.distance, 20 | required this.locations, 21 | }); 22 | 23 | @override 24 | List get props => 25 | [id, type, startDatetime, endDatetime, distance, locations]; 26 | 27 | Map toMap() { 28 | return { 29 | 'id': id, 30 | 'type': type.toString().split('.').last.toUpperCase(), 31 | 'startDatetime': startDatetime.toIso8601String(), 32 | 'endDatetime': endDatetime.toIso8601String(), 33 | 'distance': distance, 34 | 'locations': locations.map((location) => location.toMap()).toList(), 35 | }; 36 | } 37 | 38 | @override 39 | bool get stringify => true; 40 | } 41 | -------------------------------------------------------------------------------- /lib/presentation/common/timer/viewmodel/timer_state.dart: -------------------------------------------------------------------------------- 1 | class TimerState { 2 | final DateTime startDatetime; 3 | final int hours; 4 | final int minutes; 5 | final int seconds; 6 | final bool isRunning; 7 | 8 | /// Represents the state of a timer. 9 | const TimerState({ 10 | required this.startDatetime, 11 | required this.hours, 12 | required this.minutes, 13 | required this.seconds, 14 | required this.isRunning, 15 | }); 16 | 17 | /// Creates the initial state of a timer. 18 | factory TimerState.initial() { 19 | return TimerState( 20 | startDatetime: DateTime.now(), 21 | hours: 0, 22 | minutes: 0, 23 | seconds: 0, 24 | isRunning: false, 25 | ); 26 | } 27 | 28 | /// Creates a copy of the current state with optional changes. 29 | TimerState copyWith({ 30 | DateTime? startDatetime, 31 | int? hours, 32 | int? minutes, 33 | int? seconds, 34 | bool? isRunning, 35 | }) { 36 | return TimerState( 37 | startDatetime: startDatetime ?? this.startDatetime, 38 | hours: hours ?? this.hours, 39 | minutes: minutes ?? this.minutes, 40 | seconds: seconds ?? this.seconds, 41 | isRunning: isRunning ?? this.isRunning, 42 | ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /lib/presentation/common/core/validators/login_validators.dart: -------------------------------------------------------------------------------- 1 | import 'package:email_validator/email_validator.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_gen/gen_l10n/app_localizations.dart'; 4 | 5 | interface class LoginValidators { 6 | 7 | static String? email(BuildContext context, String? value) { 8 | if (value == null || value.isEmpty) { 9 | return AppLocalizations.of(context)!.form_description_email_empty; 10 | } 11 | /* if (!EmailValidator.validate(value)) { 12 | return AppLocalizations.of(context)!.form_description_email_not_valid; 13 | }*/ 14 | return null; 15 | } 16 | 17 | 18 | static String? password(BuildContext context, String? value) { 19 | if (value == null || value.isEmpty) { 20 | return AppLocalizations.of(context)!.form_description_password_empty; 21 | } 22 | return null; 23 | } 24 | 25 | 26 | static String? confirmPassword( 27 | BuildContext context, String? value, String? password) { 28 | if (value == null || value.isEmpty) { 29 | return AppLocalizations.of(context)!.form_description_password_empty; 30 | } 31 | if (value != password) { 32 | return AppLocalizations.of(context)!.passwords_do_not_match; 33 | } 34 | return null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/presentation/edit_password/view_model/edit_password_state.dart: -------------------------------------------------------------------------------- 1 | interface class EditPasswordState { 2 | final String currentPassword; 3 | final String password; 4 | final String checkPassword; 5 | final bool isEditing; 6 | final bool errorOnRequest; 7 | 8 | const EditPasswordState( 9 | {required this.currentPassword, 10 | required this.password, 11 | required this.checkPassword, 12 | required this.isEditing, 13 | required this.errorOnRequest}); 14 | 15 | factory EditPasswordState.initial() { 16 | return const EditPasswordState( 17 | currentPassword: '', 18 | password: '', 19 | checkPassword: '', 20 | isEditing: false, 21 | errorOnRequest: false); 22 | } 23 | 24 | EditPasswordState copyWith( 25 | {String? currentPassword, 26 | String? password, 27 | String? checkPassword, 28 | bool? isEditing, 29 | bool? errorOnRequest}) { 30 | return EditPasswordState( 31 | currentPassword: currentPassword ?? this.currentPassword, 32 | password: password ?? this.password, 33 | checkPassword: checkPassword ?? this.checkPassword, 34 | isEditing: isEditing ?? this.isEditing, 35 | errorOnRequest: errorOnRequest ?? this.errorOnRequest); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/core/utils/sharedPrefs_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:shared_preferences/shared_preferences.dart'; 2 | 3 | interface class PrefsUtils { 4 | 5 | static Future getRefreshToken() async { 6 | final prefs = await SharedPreferences.getInstance(); 7 | return prefs.getString('refreshToken'); 8 | } 9 | 10 | static Future removeRefreshToken() async { 11 | final prefs = await SharedPreferences.getInstance(); 12 | return prefs.remove('refreshToken'); 13 | } 14 | 15 | static Future setRefreshToken(String refreshToken) async { 16 | final prefs = await SharedPreferences.getInstance(); 17 | return prefs.setString('refreshToken', refreshToken); 18 | } 19 | 20 | 21 | static Future getJwt() async { 22 | final prefs = await SharedPreferences.getInstance(); 23 | return prefs.getString('jwt'); 24 | } 25 | 26 | 27 | static Future removeJwt() async { 28 | final prefs = await SharedPreferences.getInstance(); 29 | return prefs.remove('jwt'); 30 | } 31 | 32 | 33 | static Future setJwt(String jwt) async { 34 | final prefs = await SharedPreferences.getInstance(); 35 | return prefs.setString('jwt', jwt); 36 | } 37 | 38 | 39 | static Future removeCachedDataFromUrl(String url) async { 40 | final prefs = await SharedPreferences.getInstance(); 41 | return prefs.remove(url); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lib/presentation/activity_details/view_model/activitie_details_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | 3 | import '../../../domain/entities/activity.dart'; 4 | import '../../../domain/entities/enum/activity_type.dart'; 5 | 6 | /// Represents the state of the activity details screen. 7 | class ActivityDetailsState { 8 | final Activity? activity; 9 | final ActivityType? type; 10 | final bool isLoading; 11 | final bool isEditing; 12 | final GlobalKey boundaryKey; 13 | 14 | const ActivityDetailsState( 15 | {this.activity, 16 | this.type, 17 | required this.isLoading, 18 | required this.isEditing, 19 | required this.boundaryKey}); 20 | 21 | /// Creates an initial state with no activity. 22 | factory ActivityDetailsState.initial() { 23 | return ActivityDetailsState( 24 | isLoading: false, isEditing: false, boundaryKey: GlobalKey()); 25 | } 26 | 27 | /// Creates a new state with the provided activity, or retains the existing activity if not provided. 28 | ActivityDetailsState copyWith( 29 | {Activity? activity, 30 | bool? isLoading, 31 | ActivityType? type, 32 | bool? isEditing}) { 33 | return ActivityDetailsState( 34 | activity: activity ?? this.activity, 35 | isLoading: isLoading ?? this.isLoading, 36 | type: type ?? this.type, 37 | isEditing: isEditing ?? this.isEditing, 38 | boundaryKey: boundaryKey); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.Create(L"run_tracker", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /lib/presentation/common/timer/widgets/timer_pause.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 3 | 4 | import '../viewmodel/timer_view_model.dart'; 5 | 6 | /// A floating action button used to pause or resume the timer. 7 | class TimerPause extends HookConsumerWidget { 8 | const TimerPause({Key? key}) : super(key: key); 9 | 10 | @override 11 | Widget build(BuildContext context, WidgetRef ref) { 12 | final isRunning = ref.watch(timerViewModelProvider).isRunning; 13 | final timerViewModel = ref.watch(timerViewModelProvider.notifier); 14 | 15 | if (timerViewModel.hasTimerStarted()) { 16 | return AnimatedSwitcher( 17 | duration: const Duration(milliseconds: 300), 18 | transitionBuilder: (child, animation) { 19 | return ScaleTransition( 20 | scale: animation, 21 | child: child, 22 | ); 23 | }, 24 | child: FloatingActionButton( 25 | backgroundColor: Colors.teal.shade800, 26 | key: ValueKey(isRunning), 27 | tooltip: timerViewModel.isTimerRunning() ? 'Pause' : 'Resume', 28 | child: Icon(isRunning ? Icons.pause : Icons.play_arrow), 29 | onPressed: () { 30 | if (timerViewModel.isTimerRunning()) { 31 | timerViewModel.pauseTimer(); 32 | } else { 33 | timerViewModel.startTimer(); 34 | } 35 | }, 36 | ), 37 | ); 38 | } 39 | return const SizedBox.shrink(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/presentation/settings/view_model/settings_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 2 | import 'package:shared_preferences/shared_preferences.dart'; 3 | 4 | import '../../../data/repositories/user_repository_impl.dart'; 5 | import '../../../main.dart'; 6 | import 'settings_state.dart'; 7 | 8 | final settingsViewModelProvider = 9 | StateNotifierProvider.autoDispose( 10 | (ref) => SettingsViewModel(ref), 11 | ); 12 | 13 | class SettingsViewModel extends StateNotifier { 14 | Ref ref; 15 | 16 | 17 | SettingsViewModel(this.ref) : super(SettingsState.initial()); 18 | 19 | Future logoutUser() async { 20 | try { 21 | state = state.copyWith(isLoading: true); 22 | await ref.read(userRepositoryProvider).logout(); 23 | await clearStorage(); 24 | navigatorKey.currentState?.pushReplacementNamed("/login"); 25 | } catch (error) { 26 | state = state.copyWith(isLoading: false); 27 | } 28 | } 29 | 30 | Future deleteUserAccount() async { 31 | try { 32 | state = state.copyWith(isLoading: true); 33 | await ref.read(userRepositoryProvider).deleteaccount(); 34 | await clearStorage(); 35 | navigatorKey.currentState?.pushReplacementNamed("/login"); 36 | } catch (error) { 37 | state = state.copyWith(isLoading: false); 38 | } 39 | } 40 | 41 | Future clearStorage() async { 42 | SharedPreferences prefs = await SharedPreferences.getInstance(); 43 | await prefs.clear(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib/data/repositories/activity_repository_impl.dart: -------------------------------------------------------------------------------- 1 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 2 | 3 | import '../../domain/entities/activity.dart'; 4 | import '../../domain/repositories/activity_repository.dart'; 5 | import '../api/activity_api.dart'; 6 | import '../model/request/activity_request.dart'; 7 | 8 | final activityRepositoryProvider = 9 | Provider((ref) => ActivityRepoImpl()); 10 | 11 | interface class ActivityRepoImpl extends ActivityRepository { 12 | ActivityRepoImpl(); 13 | 14 | @override 15 | Future> getActivities() async { 16 | final activityResponses = await ActivityApi.getrecentActivities(); 17 | return activityResponses.map((response) => response.toEntity()).toList(); 18 | } 19 | 20 | @override 21 | Future getActivityById({required String id}) async { 22 | final activityResponse = await ActivityApi.getrecentActivityById(id); 23 | return activityResponse.toEntity(); 24 | } 25 | 26 | @override 27 | Future removeActivity({required String id}) async { 28 | return await ActivityApi.removeActivity(id); 29 | } 30 | 31 | @override 32 | Future addActivity(ActivityRequest request) async { 33 | final activityResponse = await ActivityApi.addActivity(request); 34 | return activityResponse?.toEntity(); 35 | } 36 | 37 | @override 38 | Future editActivity(ActivityRequest request) async { 39 | final activityResponse = await ActivityApi.editActivity(request); 40 | return activityResponse.toEntity(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /lib/presentation/common/core/utils/map_utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:latlong2/latlong.dart'; 4 | 5 | interface class MapUtils { 6 | 7 | static LatLng getCenterOfMap(List points) { 8 | double sumLat = 0.0; 9 | double sumLng = 0.0; 10 | 11 | for (LatLng coordinate in points) { 12 | sumLat += coordinate.latitude; 13 | sumLng += coordinate.longitude; 14 | } 15 | 16 | double centerLat = sumLat / points.length; 17 | double centerLng = sumLng / points.length; 18 | 19 | return LatLng(centerLat, centerLng); 20 | } 21 | 22 | 23 | static double getDistance(LatLng point1, LatLng point2) { 24 | return const Distance().as(LengthUnit.Meter, point1, point2); 25 | } 26 | 27 | 28 | static double getRadius(List points, LatLng center) { 29 | double maxDistance = 0.0; 30 | 31 | for (LatLng coordinate in points) { 32 | final distance = getDistance(center, coordinate); 33 | if (distance > maxDistance) { 34 | maxDistance = distance; 35 | } 36 | } 37 | 38 | return maxDistance; 39 | } 40 | 41 | 42 | static double getZoomLevel(List points, LatLng center) { 43 | final radius = getRadius(points, center); 44 | 45 | double zoomLevel = 11; 46 | if (radius > 0) { 47 | final radiusElevated = radius + radius / 2; 48 | final scale = radiusElevated / 500; 49 | zoomLevel = 16 - (log(scale) / log(2)); 50 | } 51 | zoomLevel = double.parse(zoomLevel.toStringAsFixed(2)) - 0.25; 52 | return zoomLevel; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | # Additional information about this file can be found at 29 | # https://dart.dev/guides/language/analysis-options 30 | -------------------------------------------------------------------------------- /lib/presentation/common/timer/widgets/timer_start.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 3 | 4 | import '../viewmodel/timer_view_model.dart'; 5 | 6 | /// A widget that displays the timer start button. 7 | class TimerStart extends HookConsumerWidget { 8 | const TimerStart({Key? key}) : super(key: key); 9 | 10 | @override 11 | Widget build(BuildContext context, WidgetRef ref) { 12 | // ignore: unused_local_variable 13 | final state = ref.watch(timerViewModelProvider); 14 | final timerViewModel = ref.watch(timerViewModelProvider.notifier); 15 | 16 | return FloatingActionButton( 17 | backgroundColor: timerViewModel.hasTimerStarted() 18 | ? Colors.red.shade700 19 | : Colors.teal.shade800, 20 | elevation: 4.0, 21 | child: AnimatedSwitcher( 22 | duration: const Duration(milliseconds: 300), 23 | transitionBuilder: (child, animation) { 24 | return ScaleTransition( 25 | scale: animation, 26 | child: FadeTransition( 27 | opacity: animation, 28 | child: child, 29 | ), 30 | ); 31 | }, 32 | child: Icon( 33 | timerViewModel.hasTimerStarted() ? Icons.stop : Icons.play_arrow, 34 | key: ValueKey(timerViewModel.hasTimerStarted()), 35 | ), 36 | ), 37 | onPressed: () { 38 | if (timerViewModel.hasTimerStarted()) { 39 | timerViewModel.stopTimer(); 40 | } else { 41 | timerViewModel.startTimer(); 42 | } 43 | }, 44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /lib/presentation/common/core/utils/color_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | interface class ColorUtils { 4 | static List colorList = [ 5 | Colors.teal, 6 | Colors.orange, 7 | Colors.blueGrey, 8 | Colors.red 9 | ]; 10 | 11 | 12 | static Color generateDarkColor(Color baseColor) { 13 | final luminance = baseColor.computeLuminance(); 14 | final darkColor = 15 | luminance > 0.5 ? baseColor.withOpacity(0.8) : baseColor.darker(); 16 | return darkColor; 17 | } 18 | 19 | 20 | static Color generateLightColor(Color baseColor) { 21 | final luminance = baseColor.computeLuminance(); 22 | final lightColor = 23 | luminance > 0.5 ? baseColor.lighter() : baseColor.withOpacity(0.8); 24 | return lightColor; 25 | } 26 | 27 | 28 | static List generateColorTupleFromIndex(int index) { 29 | final baseColor = colorList[index % colorList.length]; 30 | final darkColor = generateDarkColor(baseColor); 31 | final lightColor = generateLightColor(baseColor); 32 | return [darkColor, lightColor]; 33 | } 34 | } 35 | 36 | extension ColorExtension on Color { 37 | 38 | Color darker([double factor = 0.1]) { 39 | return Color.fromARGB( 40 | alpha, 41 | (red * (1.0 - factor)).round(), 42 | (green * (1.0 - factor)).round(), 43 | (blue * (1.0 - factor)).round(), 44 | ); 45 | } 46 | 47 | Color lighter([double factor = 0.1]) { 48 | return Color.fromARGB( 49 | alpha, 50 | (red + (255 - red) * factor).round(), 51 | (green + (255 - green) * factor).round(), 52 | (blue + (255 - blue) * factor).round(), 53 | ); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /lib/presentation/send_new_password/view_model/send_new_password_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 3 | 4 | import '../../../data/model/request/send_new_password_request.dart'; 5 | import '../../../data/repositories/user_repository_impl.dart'; 6 | import '../../../main.dart'; 7 | import 'send_new_password_state.dart'; 8 | 9 | final sendNewPasswordViewModelProvider = StateNotifierProvider.autoDispose< 10 | SendNewPasswordViewModel, SendNewPasswordState>( 11 | (ref) => SendNewPasswordViewModel(ref), 12 | ); 13 | 14 | interface class SendNewPasswordViewModel extends StateNotifier { 15 | final Ref ref; 16 | 17 | SendNewPasswordViewModel(this.ref) : super(SendNewPasswordState.initial()); 18 | 19 | void setEmail(String? email) { 20 | state = state.copyWith(email: email ?? ''); 21 | } 22 | 23 | Future submitForm( 24 | BuildContext context, GlobalKey formKey) async { 25 | if (formKey.currentState!.validate()) { 26 | formKey.currentState!.save(); 27 | 28 | state = state.copyWith(isSending: true); 29 | 30 | final userRepository = ref.read(userRepositoryProvider); 31 | final sendNewPasswordRequest = SendNewPasswordRequest(email: state.email); 32 | 33 | try { 34 | await userRepository.sendNewPasswordByMail(sendNewPasswordRequest); 35 | 36 | state = state.copyWith(isSending: false); 37 | 38 | navigatorKey.currentState?.pop(); 39 | } catch (error) { 40 | state = state.copyWith(isSending: false); 41 | navigatorKey.currentState?.pop(); 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib/presentation/common/metrics/widgets/metrics.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 3 | 4 | import '../view_model/metrics_view_model.dart'; 5 | 6 | /// A widget that displays the metrics information such as speed and distance. 7 | class Metrics extends HookConsumerWidget { 8 | final double? speed; 9 | final double? distance; 10 | 11 | /// Creates a Metrics widget. 12 | const Metrics({Key? key, this.speed, this.distance}) : super(key: key); 13 | 14 | @override 15 | Widget build(BuildContext context, WidgetRef ref) { 16 | final state = ref.watch(metricsViewModelProvider); 17 | const textStyle = TextStyle(fontSize: 30.0); 18 | 19 | double speedToDisplay = state.globalSpeed; 20 | double distanceToDisplay = state.distance; 21 | 22 | if (speed != null) { 23 | speedToDisplay = speed!; 24 | } 25 | if (distance != null) { 26 | distanceToDisplay = distance!; 27 | } 28 | 29 | return Center( 30 | child: Row( 31 | mainAxisSize: MainAxisSize.min, 32 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, 33 | children: [ 34 | const Icon(Icons.location_on), 35 | const SizedBox(width: 8), 36 | Text( 37 | '${distanceToDisplay.toStringAsFixed(2)} km', 38 | style: textStyle, 39 | ), 40 | const SizedBox(width: 40), 41 | const Icon(Icons.speed), 42 | const SizedBox(width: 8), 43 | Text( 44 | '${speedToDisplay.toStringAsFixed(2)} km/h', 45 | style: textStyle, 46 | ), 47 | ], 48 | ), 49 | ); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /lib/data/repositories/user_repository_impl.dart: -------------------------------------------------------------------------------- 1 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 2 | 3 | import '../../core/utils/sharedPrefs_utils.dart'; 4 | import '../../domain/repositories/user_repository.dart'; 5 | import '../api/user_api.dart'; 6 | import '../model/request/edit_password_request.dart'; 7 | import '../model/request/login_request.dart'; 8 | import '../model/request/send_new_password_request.dart'; 9 | import '../model/response/login_response.dart'; 10 | 11 | final userRepositoryProvider = 12 | Provider((ref) => UserRepoImpl()); 13 | 14 | interface class UserRepoImpl extends UserRepository { 15 | UserRepoImpl(); 16 | 17 | @override 18 | Future register(LoginRequest request) async { 19 | return UserApi.createUser(request); 20 | } 21 | 22 | @override 23 | Future login(LoginRequest request) async { 24 | LoginResponse response = await UserApi.login(request); 25 | await PrefsUtils.setJwt(response.token); 26 | await PrefsUtils.setRefreshToken(response.refreshedToken); 27 | return response; 28 | } 29 | 30 | @override 31 | Future logout() async { 32 | await UserApi.logout(); 33 | await PrefsUtils.removeJwt(); 34 | await PrefsUtils.removeRefreshToken(); 35 | return; 36 | } 37 | 38 | @override 39 | Future deleteaccount() async { 40 | return UserApi.delete(); 41 | } 42 | 43 | @override 44 | Future sendNewPasswordByMail(SendNewPasswordRequest request) async { 45 | await UserApi.sendNewPasswordByMail(request); 46 | } 47 | 48 | @override 49 | Future editPassword(EditPasswordRequest request) async { 50 | await UserApi.editPassword(request); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /lib/data/api/activity_api.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | 3 | import '../model/request/activity_request.dart'; 4 | import '../model/response/activity_response.dart'; 5 | import 'helpers/api_helper.dart'; 6 | 7 | interface class ActivityApi { 8 | static String URL = '${ApiHelper.BASEURL}private/activity/'; 9 | 10 | 11 | static Future> getrecentActivities() async { 12 | Response? response = 13 | await ApiHelper.makeRequest('${ActivityApi.URL}all', 'GET'); 14 | final data = List>.from(response?.data); 15 | return data.map((e) => ActivityResponse.fromMap(e)).toList(); 16 | } 17 | 18 | 19 | static Future getrecentActivityById(String id) async { 20 | Response? response = 21 | await ApiHelper.makeRequest('${ActivityApi.URL}$id', 'GET'); 22 | return ActivityResponse.fromMap(response?.data); 23 | } 24 | 25 | 26 | static Future removeActivity(String id) async { 27 | Response? response = await ApiHelper.makeRequest(ActivityApi.URL, 'DELETE', 28 | queryParams: {'id': int.parse(id)}); 29 | return response?.data?.toString(); 30 | } 31 | 32 | 33 | static Future addActivity(ActivityRequest request) async { 34 | Response? response = await ApiHelper.makeRequest(ActivityApi.URL, 'POST', 35 | data: request.toMap()); 36 | return response != null ? ActivityResponse.fromMap(response.data) : null; 37 | } 38 | 39 | 40 | static Future editActivity(ActivityRequest request) async { 41 | Response? response = await ApiHelper.makeRequest(ActivityApi.URL, 'PUT', 42 | data: request.toMap()); 43 | return ActivityResponse.fromMap(response?.data); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib/presentation/common/core/services/text_to_speech_service.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui' as ui; 2 | 3 | import 'package:flutter_gen/gen_l10n/app_localizations.dart'; 4 | import 'package:flutter_tts/flutter_tts.dart'; 5 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 6 | 7 | import '../../../../main.dart'; 8 | 9 | /// A provider for the text-to-speech service. 10 | final textToSpeechService = Provider((ref) { 11 | return TextToSpeechService(ref); 12 | }); 13 | 14 | /// A service for text-to-speech functionality. 15 | class TextToSpeechService { 16 | late dynamic ref; 17 | late AppLocalizations translate; 18 | FlutterTts flutterTts = FlutterTts(); 19 | 20 | TextToSpeechService(this.ref); 21 | 22 | /// Initializes the text-to-speech service. 23 | Future init() async { 24 | var lang = ui.window.locale.languageCode; 25 | await flutterTts.setLanguage(lang); 26 | translate = await ref.read(myAppProvider).getLocalizedConf(); 27 | } 28 | 29 | /// Says "Good luck" using text-to-speech. 30 | Future sayGoodLuck() async { 31 | await flutterTts.speak(translate.good_luck); 32 | } 33 | 34 | /// Says the activity sum-up using text-to-speech. 35 | Future sayActivitySumUp() async { 36 | await flutterTts.speak(translate.activity_sumup); 37 | } 38 | 39 | /// Says "Pause" using text-to-speech. 40 | Future sayPause() async { 41 | await flutterTts.speak(translate.pause_activity); 42 | } 43 | 44 | /// Says "Resume" using text-to-speech. 45 | Future sayResume() async { 46 | await flutterTts.speak(translate.resume_activity); 47 | } 48 | 49 | /// Says the given text using text-to-speech. 50 | Future say(String text) async { 51 | await flutterTts.speak(text); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled. 5 | 6 | version: 7 | revision: 796c8ef79279f9c774545b3771238c3098dbefab 8 | channel: stable 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 796c8ef79279f9c774545b3771238c3098dbefab 17 | base_revision: 796c8ef79279f9c774545b3771238c3098dbefab 18 | - platform: android 19 | create_revision: 796c8ef79279f9c774545b3771238c3098dbefab 20 | base_revision: 796c8ef79279f9c774545b3771238c3098dbefab 21 | - platform: ios 22 | create_revision: 796c8ef79279f9c774545b3771238c3098dbefab 23 | base_revision: 796c8ef79279f9c774545b3771238c3098dbefab 24 | - platform: linux 25 | create_revision: 796c8ef79279f9c774545b3771238c3098dbefab 26 | base_revision: 796c8ef79279f9c774545b3771238c3098dbefab 27 | - platform: macos 28 | create_revision: 796c8ef79279f9c774545b3771238c3098dbefab 29 | base_revision: 796c8ef79279f9c774545b3771238c3098dbefab 30 | - platform: web 31 | create_revision: 796c8ef79279f9c774545b3771238c3098dbefab 32 | base_revision: 796c8ef79279f9c774545b3771238c3098dbefab 33 | - platform: windows 34 | create_revision: 796c8ef79279f9c774545b3771238c3098dbefab 35 | base_revision: 796c8ef79279f9c774545b3771238c3098dbefab 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Run Tracker 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | run_tracker 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | UIApplicationSupportsIndirectInputEvents 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /lib/l10n/app_en.arb: -------------------------------------------------------------------------------- 1 | { 2 | "@@locale": "en", 3 | "activity": "Activity", 4 | "activity_list": " Activity list", 5 | "activity_sumup": "Activity Sumup", 6 | "ask_account_removal": "Are you sure to delete your account", 7 | "ask_activity_removal": "Are you sure to delete this activity", 8 | "back": "Back", 9 | "cancel": "Cancel", 10 | "close": "Close", 11 | "congrats": "End of activity. Congratulations.", 12 | "current_password": "Current Password", 13 | "cycling": "Cycling", 14 | "date_pronoun": "On", 15 | "delete": "Delete", 16 | "delete_account": "Delete account", 17 | "distance": "Distance", 18 | "duration": "Duration", 19 | "edit_password": "Edit the password", 20 | "edit_password_error": "Error: the password was not edited", 21 | "email": "Email", 22 | "end": "End", 23 | "form_description_email_empty": "Type your email", 24 | "form_description_email_not_valid": "Type a valid email", 25 | "form_description_password_empty": "Type your password", 26 | "good_luck": "Let start, good luck", 27 | "hello": "Hello", 28 | "hours": "hours", 29 | "hours_pronoun": "at", 30 | "kilometers": "kilometers", 31 | "list": "List", 32 | "login": "Log in", 33 | "login_page": "Login", 34 | "logout": "Log out", 35 | "minutes": "minutes", 36 | "new_password": "New password", 37 | "password": "Password", 38 | "passwords_do_not_match": "Passwords do not match", 39 | "pause_activity": "Activity paused", 40 | "per": "per", 41 | "registration": "Registration", 42 | "resume_activity": "Activity resumed", 43 | "running": "Running", 44 | "seconds": "seconds", 45 | "send_mail": "Send the mail", 46 | "send_new_password": "Forgot your password ?", 47 | "settings": "Settings", 48 | "share_failed": "Activity sharing failed", 49 | "speed": "Speed", 50 | "start": "Start", 51 | "validate": "Validate", 52 | "verify": "Verify", 53 | "walking": "Walking", 54 | "welcome": "Welcome" 55 | } -------------------------------------------------------------------------------- /lib/presentation/new_activity/screen/new_activity_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 3 | 4 | import '../../common/location/widgets/current_location_map.dart'; 5 | import '../../common/metrics/widgets/metrics.dart'; 6 | import '../../common/timer/viewmodel/timer_view_model.dart'; 7 | import '../../common/timer/widgets/timer_pause.dart'; 8 | import '../../common/timer/widgets/timer_sized.dart'; 9 | import '../../common/timer/widgets/timer_start.dart'; 10 | 11 | /// The screen for creating a new activity. 12 | class NewActivityScreen extends HookConsumerWidget { 13 | const NewActivityScreen({Key? key}) : super(key: key); 14 | 15 | @override 16 | Widget build(BuildContext context, WidgetRef ref) { 17 | final timerViewModel = ref.watch(timerViewModelProvider.notifier); 18 | // ignore: unused_local_variable 19 | final isRunning = 20 | ref.watch(timerViewModelProvider.select((value) => value.isRunning)); 21 | 22 | return Scaffold( 23 | body: const SafeArea( 24 | child: Column( 25 | children: [ 26 | TimerTextSized(), 27 | Metrics(), 28 | SizedBox(height: 10), 29 | CurrentLocationMap(), 30 | ], 31 | ), 32 | ), 33 | floatingActionButton: timerViewModel.hasTimerStarted() 34 | ? const Stack( 35 | children: [ 36 | Positioned( 37 | bottom: 16, 38 | right: 80, 39 | child: TimerPause(), 40 | ), 41 | Positioned( 42 | bottom: 16, 43 | left: 80, 44 | child: TimerStart(), 45 | ), 46 | ], 47 | ) 48 | : const TimerStart(), 49 | floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, 50 | ); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /lib/l10n/app_en_US.arb: -------------------------------------------------------------------------------- 1 | { 2 | "@@locale": "en_US", 3 | "activity": "Activity", 4 | "activity_list": " Activity list", 5 | "activity_sumup": "Activity Sumup", 6 | "ask_account_removal": "Are you sure to delete your account", 7 | "ask_activity_removal": "Are you sure to delete this activity", 8 | "back": "Back", 9 | "cancel": "Cancel", 10 | "close": "Close", 11 | "congrats": "End of activity. Congratulations.", 12 | "current_password": "Current Password", 13 | "cycling": "Cycling", 14 | "date_pronoun": "On", 15 | "delete": "Delete", 16 | "delete_account": "Delete account", 17 | "distance": "Distance", 18 | "duration": "Duration", 19 | "edit_password": "Edit the password", 20 | "edit_password_error": "Error: the password was not edited", 21 | "email": "Email", 22 | "end": "End", 23 | "form_description_email_empty": "Type your email", 24 | "form_description_email_not_valid": "Type a valid email", 25 | "form_description_password_empty": "Type your password", 26 | "good_luck": "Let start, good luck", 27 | "hello": "Hello", 28 | "hours": "hours", 29 | "hours_pronoun": "at", 30 | "kilometers": "kilometers", 31 | "list": "List", 32 | "login": "Log in", 33 | "login_page": "Login", 34 | "logout": "Log out", 35 | "minutes": "minutes", 36 | "new_password": "New password", 37 | "password": "Password", 38 | "passwords_do_not_match": "Passwords do not match", 39 | "pause_activity": "Activity paused", 40 | "per": "per", 41 | "registration": "Registration", 42 | "resume_activity": "Activity resumed", 43 | "running": "Running", 44 | "seconds": "seconds", 45 | "send_mail": "Send the mail", 46 | "send_new_password": "Forgot your password ?", 47 | "settings": "Settings", 48 | "share_failed": "Activity sharing failed", 49 | "speed": "Speed", 50 | "start": "Start", 51 | "validate": "Validate", 52 | "verify": "Verify", 53 | "walking": "Walking", 54 | "welcome": "Welcome" 55 | } -------------------------------------------------------------------------------- /lib/presentation/common/core/utils/form_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | interface class FormUtils { 4 | static final ButtonStyle buttonStyle = 5 | createButtonStyle(Colors.teal.shade800); 6 | 7 | static const TextStyle textFormFieldStyle = TextStyle(fontSize: 20); 8 | 9 | static const TextStyle darkTextFormFieldStyle = 10 | TextStyle(fontSize: 20, color: Colors.white); 11 | 12 | static ButtonStyle createButtonStyle(Color backgroundColor) { 13 | return ButtonStyle( 14 | textStyle: MaterialStateProperty.all(const TextStyle(fontSize: 20)), 15 | minimumSize: MaterialStateProperty.all(const Size(150, 50)), 16 | backgroundColor: MaterialStateProperty.all(backgroundColor), 17 | shape: MaterialStateProperty.all( 18 | RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), 19 | ), 20 | ); 21 | } 22 | 23 | 24 | static InputDecoration createInputDecorative(String text, 25 | {bool? dark, IconData? icon}) { 26 | dark ??= false; 27 | final color = dark ? Colors.teal.shade200 : Colors.teal.shade800; 28 | final errorColor = dark ? Colors.red.shade200 : Colors.red.shade600; 29 | 30 | return InputDecoration( 31 | icon: icon != null ? Icon(icon) : null, 32 | iconColor: color, 33 | errorStyle: TextStyle(color: errorColor), 34 | errorBorder: 35 | UnderlineInputBorder(borderSide: BorderSide(color: errorColor)), 36 | focusedBorder: UnderlineInputBorder(borderSide: BorderSide(color: color)), 37 | border: UnderlineInputBorder(borderSide: BorderSide(color: color)), 38 | enabledBorder: UnderlineInputBorder(borderSide: BorderSide(color: color)), 39 | focusedErrorBorder: 40 | UnderlineInputBorder(borderSide: BorderSide(color: errorColor)), 41 | focusColor: color, 42 | labelStyle: TextStyle(color: color), 43 | labelText: text, 44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /lib/presentation/activity_list/screen/activity_list_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_gen/gen_l10n/app_localizations.dart'; 3 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 4 | 5 | import '../../common/core/utils/ui_utils.dart'; 6 | import '../view_model/activity_list_view_model.dart'; 7 | import '../widgets/activity_item.dart'; 8 | 9 | class ActivityListScreen extends HookConsumerWidget { 10 | const ActivityListScreen({Key? key}) : super(key: key); 11 | 12 | @override 13 | Widget build(BuildContext context, WidgetRef ref) { 14 | final activities = ref.watch(activityListViewModelProvider).activities; 15 | final isLoading = ref.watch(activityListViewModelProvider).isLoading; 16 | 17 | return Scaffold( 18 | body: isLoading 19 | ? const Center(child: UIUtils.loader) 20 | : SafeArea( 21 | child: Column( 22 | children: [ 23 | Container( 24 | padding: const EdgeInsets.only(left: 0, top: 12), 25 | child: Text( 26 | AppLocalizations.of(context)!.activity_list, 27 | style: const TextStyle( 28 | color: Colors.blueGrey, 29 | fontSize: 28, 30 | fontWeight: FontWeight.bold), 31 | ), 32 | ), 33 | const Divider(), 34 | Expanded( 35 | child: ListView.builder( 36 | itemCount: activities.length, 37 | itemBuilder: (context, index) { 38 | return ActivityItem( 39 | index: index, activity: activities[index]); 40 | }, 41 | ), 42 | ), 43 | ], 44 | ), 45 | ), 46 | ); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") 37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 38 | 39 | # Run the Flutter tool portions of the build. This must not be removed. 40 | add_dependencies(${BINARY_NAME} flutter_assemble) 41 | -------------------------------------------------------------------------------- /lib/presentation/edit_password/view_model/edit_password_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 3 | 4 | import '../../../data/model/request/edit_password_request.dart'; 5 | import '../../../data/repositories/user_repository_impl.dart'; 6 | import '../../../main.dart'; 7 | import 'edit_password_state.dart'; 8 | 9 | final editPasswordViewModelProvider = 10 | StateNotifierProvider.autoDispose( 11 | (ref) => EditPasswordViewModel(ref), 12 | ); 13 | 14 | interface class EditPasswordViewModel extends StateNotifier { 15 | Ref ref; 16 | 17 | EditPasswordViewModel(this.ref) : super(EditPasswordState.initial()); 18 | 19 | void setCurrentPassword(String? currentPassword) { 20 | state = state.copyWith(currentPassword: currentPassword); 21 | } 22 | 23 | void setPassword(String? password) { 24 | state = state.copyWith(password: password); 25 | } 26 | 27 | void setCheckPassword(String? checkPassword) { 28 | state = state.copyWith(checkPassword: checkPassword); 29 | } 30 | 31 | Future submitForm( 32 | BuildContext context, GlobalKey formKey) async { 33 | state = state.copyWith(errorOnRequest: false); 34 | if (formKey.currentState!.validate()) { 35 | formKey.currentState!.save(); 36 | 37 | state = state.copyWith(isEditing: true); 38 | 39 | final userRepository = ref.read(userRepositoryProvider); 40 | final editPasswordRequest = EditPasswordRequest( 41 | currentPassword: state.currentPassword, 42 | password: state.password, 43 | ); 44 | 45 | try { 46 | await userRepository.editPassword(editPasswordRequest); 47 | navigatorKey.currentState?.pop(); 48 | } catch (e) { 49 | state = state.copyWith(errorOnRequest: true); 50 | } finally { 51 | state = state.copyWith(isEditing: false); 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /lib/presentation/common/location/widgets/location_map.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_map/flutter_map.dart'; 3 | import 'package:flutter_map/plugin_api.dart'; 4 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 5 | import 'package:latlong2/latlong.dart'; 6 | 7 | import '../../core/utils/map_utils.dart'; 8 | import '../view_model/location_view_model.dart'; 9 | 10 | /// Widget that displays a map with markers and polylines representing locations. 11 | class LocationMap extends HookConsumerWidget { 12 | final List points; 13 | final List markers; 14 | 15 | const LocationMap({Key? key, required this.points, required this.markers}) 16 | : super(key: key); 17 | 18 | @override 19 | Widget build(BuildContext context, WidgetRef ref) { 20 | final provider = ref.read(locationViewModelProvider.notifier); 21 | final state = ref.watch(locationViewModelProvider); 22 | 23 | final center = MapUtils.getCenterOfMap(points); 24 | final zoomLevel = MapUtils.getZoomLevel(points, center); 25 | 26 | return Expanded( 27 | child: SizedBox( 28 | height: 500, 29 | child: FlutterMap( 30 | mapController: provider.mapController, 31 | options: MapOptions( 32 | center: points.isNotEmpty 33 | ? center 34 | : LatLng(state.currentPosition?.latitude ?? 0, 35 | state.currentPosition?.longitude ?? 0), 36 | zoom: zoomLevel, 37 | ), 38 | nonRotatedChildren: const [], 39 | children: [ 40 | TileLayer( 41 | urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', 42 | ), 43 | PolylineLayer( 44 | polylines: [ 45 | Polyline( 46 | points: points, strokeWidth: 4, color: Colors.blueGrey), 47 | ], 48 | ), 49 | MarkerLayer(markers: markers), 50 | ], 51 | ), 52 | ), 53 | ); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /lib/presentation/common/location/view_model/location_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:geolocator/geolocator.dart'; 2 | 3 | import '../../../../../data/model/request/location_request.dart'; 4 | 5 | /// Represents the state of the location. 6 | class LocationState { 7 | /// The current position. 8 | final Position? currentPosition; 9 | 10 | /// The last recorded position. 11 | final Position? lastPosition; 12 | 13 | /// The list of saved positions. 14 | final List savedPositions; 15 | 16 | /// Creates a [LocationState] instance. 17 | /// 18 | /// The [currentPosition] is the current position. 19 | /// The [lastPosition] is the last recorded position. 20 | /// The [savedPositions] is the list of saved positions. 21 | const LocationState({ 22 | this.currentPosition, 23 | this.lastPosition, 24 | required this.savedPositions, 25 | }); 26 | 27 | /// Creates an initial [LocationState] instance. 28 | factory LocationState.initial() { 29 | return const LocationState(savedPositions: []); 30 | } 31 | 32 | /// Creates a copy of this [LocationState] instance with the given fields replaced with the new values. 33 | LocationState copyWith({ 34 | Position? currentPosition, 35 | Position? lastPosition, 36 | List? savedPositions, 37 | }) { 38 | return LocationState( 39 | currentPosition: currentPosition ?? this.currentPosition, 40 | lastPosition: lastPosition ?? this.lastPosition, 41 | savedPositions: savedPositions ?? this.savedPositions, 42 | ); 43 | } 44 | 45 | @override 46 | bool operator ==(Object other) => 47 | identical(this, other) || 48 | other is LocationState && 49 | runtimeType == other.runtimeType && 50 | currentPosition == other.currentPosition && 51 | lastPosition == other.lastPosition && 52 | savedPositions == other.savedPositions; 53 | 54 | @override 55 | int get hashCode => 56 | currentPosition.hashCode ^ 57 | lastPosition.hashCode ^ 58 | savedPositions.hashCode; 59 | } 60 | -------------------------------------------------------------------------------- /lib/presentation/common/location/widgets/current_location_map.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_map/flutter_map.dart'; 3 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 4 | import 'package:latlong2/latlong.dart'; 5 | 6 | import '../view_model/location_view_model.dart'; 7 | import 'location_map.dart'; 8 | 9 | /// Widget that displays the current location on a map. 10 | class CurrentLocationMap extends HookConsumerWidget { 11 | const CurrentLocationMap({Key? key}) : super(key: key); 12 | 13 | @override 14 | Widget build(BuildContext context, WidgetRef ref) { 15 | final state = ref.watch(locationViewModelProvider); 16 | final provider = ref.read(locationViewModelProvider.notifier); 17 | 18 | final points = provider.savedPositionsLatLng(); 19 | 20 | final currentPosition = state.currentPosition; 21 | final currentLatitude = currentPosition?.latitude ?? 0; 22 | final currentLongitude = currentPosition?.longitude ?? 0; 23 | 24 | final markers = [ 25 | Marker( 26 | width: 80, 27 | height: 80, 28 | point: LatLng(currentLatitude, currentLongitude), 29 | builder: (ctx) => const Icon( 30 | Icons.run_circle_sharp, 31 | size: 30, 32 | color: Colors.red, 33 | ), 34 | ), 35 | ]; 36 | 37 | if (points.isNotEmpty) { 38 | markers.add( 39 | Marker( 40 | width: 80.0, 41 | height: 80.0, 42 | point: LatLng( 43 | points.first.latitude, 44 | points.first.longitude, 45 | ), 46 | builder: (ctx) => Column( 47 | children: [ 48 | IconButton( 49 | icon: const Icon(Icons.location_on_rounded), 50 | color: Colors.green.shade700, 51 | iconSize: 35.0, 52 | onPressed: () {}, 53 | ), 54 | ], 55 | ), 56 | ), 57 | ); 58 | } 59 | 60 | return LocationMap(points: points, markers: markers); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr) 51 | -1; // remove the trailing null character 52 | int input_length = (int)wcslen(utf16_string); 53 | std::string utf8_string; 54 | if (target_length <= 0 || target_length > utf8_string.max_size()) { 55 | return utf8_string; 56 | } 57 | utf8_string.resize(target_length); 58 | int converted_length = ::WideCharToMultiByte( 59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 60 | input_length, utf8_string.data(), target_length, nullptr, nullptr); 61 | if (converted_length == 0) { 62 | return std::string(); 63 | } 64 | return utf8_string; 65 | } 66 | -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | run_tracker 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 18 | 22 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | return true; 35 | } 36 | 37 | void FlutterWindow::OnDestroy() { 38 | if (flutter_controller_) { 39 | flutter_controller_ = nullptr; 40 | } 41 | 42 | Win32Window::OnDestroy(); 43 | } 44 | 45 | LRESULT 46 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 47 | WPARAM const wparam, 48 | LPARAM const lparam) noexcept { 49 | // Give Flutter, including plugins, an opportunity to handle window messages. 50 | if (flutter_controller_) { 51 | std::optional result = 52 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 53 | lparam); 54 | if (result) { 55 | return *result; 56 | } 57 | } 58 | 59 | switch (message) { 60 | case WM_FONTCHANGE: 61 | flutter_controller_->engine()->ReloadSystemFonts(); 62 | break; 63 | } 64 | 65 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 66 | } 67 | -------------------------------------------------------------------------------- /lib/presentation/common/core/utils/activity_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_gen/gen_l10n/app_localizations.dart'; 3 | 4 | import '../../../../domain/entities/enum/activity_type.dart'; 5 | import '../../../activity_details/view_model/activity_details_view_model.dart'; 6 | import '../../../sum_up/view_model/sum_up_view_model.dart'; 7 | 8 | interface class ActivityUtils { 9 | 10 | static IconData getActivityTypeIcon(ActivityType type) { 11 | switch (type) { 12 | case ActivityType.running: 13 | return Icons.run_circle_outlined; 14 | case ActivityType.walking: 15 | return Icons.nordic_walking; 16 | case ActivityType.cycling: 17 | return Icons.pedal_bike; 18 | default: 19 | return Icons.run_circle_rounded; 20 | } 21 | } 22 | 23 | static String translateActivityTypeValue( 24 | AppLocalizations localization, ActivityType type) { 25 | return type.getTranslatedName(localization); 26 | } 27 | 28 | static Widget buildActivityTypeDropdown( 29 | BuildContext context, 30 | ActivityType selectedType, 31 | T provider, 32 | ) { 33 | List> dropdownItems = ActivityType.values 34 | .map((ActivityType value) => DropdownMenuItem( 35 | value: value, 36 | child: Row(children: [ 37 | Icon(ActivityUtils.getActivityTypeIcon(value)), 38 | const SizedBox(width: 10), 39 | Text( 40 | ActivityUtils.translateActivityTypeValue( 41 | AppLocalizations.of(context)!, 42 | value, 43 | ), 44 | ) 45 | ]), 46 | )) 47 | .toList(); 48 | 49 | return DropdownButton( 50 | value: selectedType, 51 | items: dropdownItems, 52 | onChanged: (ActivityType? newValue) { 53 | if (newValue != null && provider is ActivityDetailsViewModel) { 54 | provider.setType(newValue); 55 | } else if (newValue != null && provider is SumUpViewModel) { 56 | provider.setType(newValue); 57 | } 58 | }, 59 | ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /lib/data/api/user_api.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | 3 | import '../../core/utils/sharedPrefs_utils.dart'; 4 | import '../model/request/edit_password_request.dart'; 5 | import '../model/request/login_request.dart'; 6 | import '../model/request/send_new_password_request.dart'; 7 | import '../model/response/login_response.dart'; 8 | import 'helpers/api_helper.dart'; 9 | 10 | interface class UserApi { 11 | 12 | static Future createUser(LoginRequest request) async { 13 | Response? response = await ApiHelper.makeRequest( 14 | '${ApiHelper.BASEURL}user/register', 'POST', 15 | data: request.toMap()); 16 | return response?.data; 17 | } 18 | 19 | 20 | static Future login(LoginRequest request) async { 21 | Response? response = await ApiHelper.makeRequest( 22 | '${ApiHelper.BASEURL}user/login', 'POST', 23 | data: request.toMap()); 24 | 25 | return LoginResponse.fromMap(response?.data); 26 | } 27 | 28 | static Future logout() async { 29 | await ApiHelper.makeRequest( 30 | '${ApiHelper.BASEURL}private/user/logout', 'POST'); 31 | } 32 | 33 | static Future delete() async { 34 | await ApiHelper.makeRequest('${ApiHelper.BASEURL}private/user', 'DELETE'); 35 | } 36 | 37 | 38 | static Future refreshToken() async { 39 | String? refreshToken = await PrefsUtils.getRefreshToken(); 40 | 41 | Response? response = await ApiHelper.makeRequest( 42 | '${ApiHelper.BASEURL}user/refreshToken', 'POST', 43 | data: {'token': refreshToken}); 44 | 45 | String? jwt = response?.data['token']; 46 | await PrefsUtils.setJwt(response?.data['token']); 47 | 48 | return jwt; 49 | } 50 | 51 | 52 | static Future sendNewPasswordByMail( 53 | SendNewPasswordRequest request) async { 54 | Response? response = await ApiHelper.makeRequest( 55 | '${ApiHelper.BASEURL}user/sendNewPasswordByMail', 'POST', 56 | queryParams: request.toMap()); 57 | 58 | return response?.data; 59 | } 60 | 61 | 62 | static Future editPassword(EditPasswordRequest request) async { 63 | await ApiHelper.makeRequest( 64 | '${ApiHelper.BASEURL}private/user/editPassword', 'PUT', 65 | data: request.toMap()); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /lib/presentation/home/screen/home_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_gen/gen_l10n/app_localizations.dart'; 3 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 4 | 5 | import '../../activity_list/screen/activity_list_screen.dart'; 6 | import '../../common/location/view_model/location_view_model.dart'; 7 | import '../../new_activity/screen/new_activity_screen.dart'; 8 | import '../../settings/screen/settings_screen.dart'; 9 | import '../view_model/home_view_model.dart'; 10 | 11 | enum Tabs { home, list, settings } 12 | 13 | class HomeScreen extends HookConsumerWidget { 14 | const HomeScreen({Key? key}) : super(key: key); 15 | 16 | @override 17 | Widget build(BuildContext context, WidgetRef ref) { 18 | final state = ref.watch(homeViewModelProvider); 19 | final homeViewModel = ref.watch(homeViewModelProvider.notifier); 20 | final locationViewModel = ref.read(locationViewModelProvider.notifier); 21 | final currentIndex = state.currentIndex; 22 | 23 | if (currentIndex == 0) { 24 | locationViewModel.startGettingLocation(); 25 | } 26 | 27 | final tabs = [ 28 | const NewActivityScreen(), 29 | const ActivityListScreen(), 30 | const SettingsScreen(), 31 | ]; 32 | 33 | return Scaffold( 34 | body: SafeArea(child: tabs[currentIndex]), 35 | bottomNavigationBar: BottomNavigationBar( 36 | currentIndex: currentIndex, 37 | onTap: (value) { 38 | locationViewModel.cancelLocationStream(); 39 | homeViewModel.setCurrentIndex(value); 40 | }, 41 | showSelectedLabels: true, 42 | selectedItemColor: Colors.teal.shade700, 43 | showUnselectedLabels: true, 44 | items: [ 45 | BottomNavigationBarItem( 46 | icon: const Icon(Icons.home), 47 | label: AppLocalizations.of(context)!.activity, 48 | ), 49 | BottomNavigationBarItem( 50 | icon: const Icon(Icons.list), 51 | label: AppLocalizations.of(context)!.list, 52 | ), 53 | BottomNavigationBarItem( 54 | icon: const Icon(Icons.settings), 55 | label: AppLocalizations.of(context)!.settings, 56 | ), 57 | ], 58 | ), 59 | ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /lib/presentation/registration/view_model/registration_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 3 | 4 | import '../../../data/model/request/login_request.dart'; 5 | import '../../../data/repositories/user_repository_impl.dart'; 6 | import '../../../main.dart'; 7 | import 'registration_state.dart'; 8 | 9 | final registrationViewModelProvider = 10 | StateNotifierProvider.autoDispose( 11 | (ref) => RegistrationViewModel(ref), 12 | ); 13 | 14 | interface class RegistrationViewModel extends StateNotifier { 15 | Ref ref; 16 | 17 | RegistrationViewModel(this.ref) : super(RegistrationState.initial()); 18 | 19 | void setUsername(String? username) { 20 | state = state.copyWith(username: username); 21 | } 22 | 23 | void setPassword(String? password) { 24 | state = state.copyWith(password: password); 25 | } 26 | 27 | void setCheckPassword(String? checkPassword) { 28 | state = state.copyWith(checkPassword: checkPassword); 29 | } 30 | 31 | Future submitForm( 32 | BuildContext context, GlobalKey formKey) async { 33 | if (formKey.currentState!.validate()) { 34 | formKey.currentState!.save(); 35 | 36 | state = state.copyWith(isLogging: true); 37 | 38 | final userRepository = ref.read(userRepositoryProvider); 39 | final loginRequest = LoginRequest( 40 | username: state.username, 41 | password: state.password, 42 | ); 43 | 44 | try { 45 | await userRepository.register(loginRequest); 46 | navigatorKey.currentState?.pop(); 47 | } catch (error) { 48 | showDialog( 49 | context: context, 50 | builder: (context) { 51 | return AlertDialog( 52 | title: const Text('Error'), 53 | content: Text(error.toString()), 54 | actions: [ 55 | TextButton( 56 | child: const Text('OK'), 57 | onPressed: () { 58 | Navigator.pop(context); 59 | }, 60 | ), 61 | ], 62 | ); 63 | }, 64 | ); 65 | } finally { 66 | state = state.copyWith(isLogging: false); 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /lib/presentation/login/view_model/login_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 3 | 4 | import '../../../data/model/request/login_request.dart'; 5 | import '../../../data/repositories/user_repository_impl.dart'; 6 | import '../../../main.dart'; 7 | import '../../home/screen/home_screen.dart'; 8 | import 'login_state.dart'; 9 | 10 | final loginViewModelProvider = 11 | StateNotifierProvider.autoDispose( 12 | (ref) => LoginViewModel(ref), 13 | ); 14 | 15 | interface class LoginViewModel extends StateNotifier { 16 | final Ref ref; 17 | 18 | LoginViewModel(this.ref) : super(LoginState.initial()); 19 | 20 | void setUsername(String? username) { 21 | state = state.copyWith(username: username ?? ''); 22 | } 23 | 24 | void setPassword(String? password) { 25 | state = state.copyWith(password: password ?? ''); 26 | } 27 | 28 | Future submitForm( 29 | BuildContext context, GlobalKey formKey) async { 30 | if (formKey.currentState!.validate()) { 31 | formKey.currentState!.save(); 32 | 33 | state = state.copyWith(isLogging: true); 34 | 35 | final userRepository = ref.read(userRepositoryProvider); 36 | final loginRequest = LoginRequest( 37 | username: state.username, 38 | password: state.password, 39 | ); 40 | 41 | try { 42 | await userRepository.login(loginRequest); 43 | 44 | state = state.copyWith(isLogging: false); 45 | 46 | navigatorKey.currentState?.pushReplacement( 47 | MaterialPageRoute(builder: (context) => const HomeScreen()), 48 | ); 49 | } catch (error) { 50 | state = state.copyWith(isLogging: false); 51 | showDialog( 52 | context: context, 53 | builder: (context) { 54 | return AlertDialog( 55 | title: const Text('Error'), 56 | content: Text(error.toString()), 57 | actions: [ 58 | TextButton( 59 | child: const Text('OK'), 60 | onPressed: () { 61 | Navigator.pop(context); 62 | }, 63 | ), 64 | ], 65 | ); 66 | }, 67 | ); 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /lib/presentation/common/core/widgets/share_map_button.dart: -------------------------------------------------------------------------------- 1 | import 'dart:typed_data'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_gen/gen_l10n/app_localizations.dart'; 4 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 5 | import 'package:run_tracker/main.dart'; 6 | import '../../../../domain/entities/activity.dart'; 7 | import '../../timer/viewmodel/timer_view_model.dart'; 8 | import '../utils/activity_utils.dart'; 9 | import '../utils/image_utils.dart'; 10 | import '../utils/share_utils.dart'; 11 | 12 | class ShareMapButton extends HookConsumerWidget { 13 | final GlobalKey boundaryKey; 14 | final Activity activity; 15 | 16 | const ShareMapButton( 17 | {Key? key, required this.boundaryKey, required this.activity}) 18 | : super(key: key); 19 | 20 | @override 21 | Widget build(BuildContext context, WidgetRef ref) { 22 | final appLocalizations = AppLocalizations.of(context); 23 | final timerViewModel = ref.read(timerViewModelProvider.notifier); 24 | 25 | Future shareImageWithText(Uint8List image) async { 26 | String duration = 27 | "${appLocalizations!.duration}: ${timerViewModel.getFormattedTime(activity.time.toInt())}"; 28 | String distance = 29 | "${appLocalizations.distance}: ${activity.distance.toStringAsFixed(2)} km"; 30 | String speed = 31 | "${appLocalizations.speed}: ${activity.speed.toStringAsFixed(2)} km/h"; 32 | 33 | Uint8List? imageEdited = await ImageUtils.addTextToImage( 34 | image, 35 | ActivityUtils.translateActivityTypeValue( 36 | appLocalizations, activity.type), 37 | "$duration - $distance - $speed", 38 | ); 39 | 40 | if (imageEdited != null) { 41 | await ShareUtils.shareImage(navigatorKey.currentContext!, imageEdited); 42 | } else { 43 | throw Exception(); 44 | } 45 | } 46 | 47 | return FloatingActionButton( 48 | onPressed: () async { 49 | try { 50 | Uint8List? image = await ImageUtils.captureWidgetToImage(boundaryKey); 51 | if (image == null) throw Exception(); 52 | 53 | await shareImageWithText(image); 54 | } catch (e) { 55 | ShareUtils.showShareFailureSnackBar(context); 56 | } 57 | }, 58 | backgroundColor: Colors.teal.shade800, 59 | elevation: 4.0, 60 | child: const Icon(Icons.share), 61 | ); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | namespace "com.example.run_tracker" 30 | compileSdkVersion 33 31 | ndkVersion flutter.ndkVersion 32 | 33 | compileOptions { 34 | sourceCompatibility JavaVersion.VERSION_1_8 35 | targetCompatibility JavaVersion.VERSION_1_8 36 | } 37 | 38 | kotlinOptions { 39 | jvmTarget = '1.8' 40 | } 41 | 42 | sourceSets { 43 | main.java.srcDirs += 'src/main/kotlin' 44 | } 45 | 46 | defaultConfig { 47 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 48 | applicationId "com.example.run_tracker" 49 | // You can update the following values to match your application needs. 50 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. 51 | minSdkVersion 21 52 | targetSdkVersion flutter.targetSdkVersion 53 | versionCode flutterVersionCode.toInteger() 54 | versionName flutterVersionName 55 | } 56 | 57 | buildTypes { 58 | release { 59 | // TODO: Add your own signing config for the release build. 60 | // Signing with the debug keys for now, so `flutter run --release` works. 61 | signingConfig signingConfigs.debug 62 | } 63 | } 64 | } 65 | 66 | flutter { 67 | source '../..' 68 | } 69 | 70 | dependencies { 71 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 72 | } 73 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /lib/data/model/response/activity_response.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | import '../../../domain/entities/activity.dart'; 4 | import '../../../domain/entities/enum/activity_type.dart'; 5 | import '../../../domain/entities/location.dart'; 6 | import 'location_response.dart'; 7 | 8 | interface class ActivityResponse extends Equatable { 9 | final String id; 10 | final ActivityType type; 11 | final DateTime startDatetime; 12 | final DateTime endDatetime; 13 | final double distance; 14 | final double speed; 15 | final double time; 16 | final Iterable locations; 17 | 18 | const ActivityResponse({ 19 | required this.id, 20 | required this.type, 21 | required this.startDatetime, 22 | required this.endDatetime, 23 | required this.distance, 24 | required this.speed, 25 | required this.time, 26 | required this.locations, 27 | }); 28 | 29 | @override 30 | List get props => [ 31 | id, 32 | type, 33 | startDatetime, 34 | endDatetime, 35 | distance, 36 | speed, 37 | time, 38 | ...locations, 39 | ]; 40 | 41 | factory ActivityResponse.fromMap(Map map) { 42 | final activityTypeString = map['type']?.toString().toLowerCase(); 43 | final activityType = ActivityType.values.firstWhere( 44 | (type) => type.name.toLowerCase() == activityTypeString, 45 | orElse: () => ActivityType.running, 46 | ); 47 | 48 | return ActivityResponse( 49 | id: map['id'].toString(), 50 | type: activityType, 51 | startDatetime: DateTime.parse(map['startDatetime']), 52 | endDatetime: DateTime.parse(map['endDatetime']), 53 | distance: map['distance'].toDouble(), 54 | speed: map['speed'] is String 55 | ? double.parse(map['speed']) 56 | : map['speed'].toDouble(), 57 | time: map['time'].toDouble(), 58 | locations: (map['locations'] as List) 59 | .map((item) => LocationResponse.fromMap(item)) 60 | .toList(), 61 | ); 62 | } 63 | 64 | Activity toEntity() { 65 | final activityLocations = locations.map((location) { 66 | return Location( 67 | id: location.id, 68 | datetime: location.datetime, 69 | latitude: location.latitude, 70 | longitude: location.longitude, 71 | ); 72 | }).toList() 73 | ..sort((a, b) => a.datetime.compareTo(b.datetime)); 74 | 75 | return Activity( 76 | id: id, 77 | type: type, 78 | startDatetime: startDatetime, 79 | endDatetime: endDatetime, 80 | distance: distance, 81 | speed: speed, 82 | time: time, 83 | locations: activityLocations, 84 | ); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /lib/presentation/activity_list/view_model/activity_list_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 3 | 4 | import '../../../data/repositories/activity_repository_impl.dart'; 5 | import '../../../domain/entities/activity.dart'; 6 | import '../../../main.dart'; 7 | import '../../activity_details/screen/activity_details_screen.dart'; 8 | import 'activity_list_state.dart'; 9 | 10 | /// The provider for the activity list view model. 11 | final activityListViewModelProvider = 12 | StateNotifierProvider.autoDispose( 13 | (ref) => ActivityListViewModel(ref)); 14 | 15 | /// The view model for the activity list screen. 16 | class ActivityListViewModel extends StateNotifier { 17 | late final Ref ref; 18 | 19 | ActivityListViewModel(this.ref) : super(ActivityListState.initial()) { 20 | fetchActivities(); 21 | } 22 | 23 | /// Fetches the list of activities. 24 | Future fetchActivities() async { 25 | state = state.copyWith(isLoading: true); 26 | 27 | try { 28 | final activities = 29 | await ref.read(activityRepositoryProvider).getActivities(); 30 | state = state.copyWith(activities: activities, isLoading: false); 31 | } catch (error) { 32 | // Handle error 33 | state = state.copyWith(isLoading: false); 34 | } 35 | } 36 | 37 | /// Retrieves the details of an activity. 38 | Future getActivityDetails(Activity activity) async { 39 | state = state.copyWith(isLoading: true); 40 | 41 | try { 42 | final activityDetails = await ref 43 | .read(activityRepositoryProvider) 44 | .getActivityById(id: activity.id); 45 | state = state.copyWith(isLoading: false); 46 | return activityDetails; 47 | } catch (error) { 48 | // Handle error 49 | state = state.copyWith(isLoading: false); 50 | rethrow; 51 | } 52 | } 53 | 54 | /// Navigates back to the home screen. 55 | void backToHome() { 56 | navigatorKey.currentState?.pop(); 57 | } 58 | 59 | /// Navigates to the activity details screen. 60 | void goToActivity(Activity activityDetails) { 61 | navigatorKey.currentState?.push( 62 | PageRouteBuilder( 63 | transitionDuration: const Duration(milliseconds: 500), 64 | pageBuilder: (context, animation, secondaryAnimation) => 65 | SlideTransition( 66 | position: Tween( 67 | begin: const Offset(1.0, 0.0), 68 | end: Offset.zero, 69 | ).animate(animation), 70 | child: ActivityDetailsScreen(activity: activityDetails), 71 | ), 72 | ), 73 | ); 74 | } 75 | 76 | /// Reload the state with new list of activities 77 | void reloadActivities(List activities) { 78 | state = state.copyWith(activities: activities); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.example" "\0" 93 | VALUE "FileDescription", "run_tracker" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "run_tracker" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2023 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "run_tracker.exe" "\0" 98 | VALUE "ProductName", "run_tracker" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /lib/presentation/sum_up/view_model/sum_up_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 2 | import 'package:run_tracker/domain/entities/activity.dart'; 3 | import 'package:run_tracker/domain/entities/location.dart'; 4 | 5 | import '../../../data/model/request/activity_request.dart'; 6 | import '../../../data/repositories/activity_repository_impl.dart'; 7 | import '../../../domain/entities/enum/activity_type.dart'; 8 | import '../../../main.dart'; 9 | import '../../common/location/view_model/location_view_model.dart'; 10 | import '../../common/metrics/view_model/metrics_view_model.dart'; 11 | import '../../common/timer/viewmodel/timer_view_model.dart'; 12 | import 'sum_up_state.dart'; 13 | 14 | final sumUpViewModel = Provider.autoDispose((ref) { 15 | return SumUpViewModel(ref); 16 | }); 17 | 18 | final sumUpViewModelProvider = 19 | StateNotifierProvider.autoDispose( 20 | (ref) => SumUpViewModel(ref), 21 | ); 22 | 23 | interface class SumUpViewModel extends StateNotifier { 24 | late Ref ref; 25 | 26 | SumUpViewModel(this.ref) : super(SumUpState.initial()); 27 | 28 | void setType(ActivityType type) { 29 | state = state.copyWith(type: type); 30 | } 31 | 32 | void save() { 33 | state = state.copyWith(isSaving: true); 34 | 35 | final startDatetime = ref.read(timerViewModelProvider).startDatetime; 36 | final endDatetime = startDatetime.add(Duration( 37 | hours: ref.read(timerViewModelProvider).hours, 38 | minutes: ref.read(timerViewModelProvider).minutes, 39 | seconds: ref.read(timerViewModelProvider).seconds, 40 | )); 41 | 42 | final locations = ref.read(locationViewModelProvider).savedPositions; 43 | 44 | ref 45 | .read(activityRepositoryProvider) 46 | .addActivity(ActivityRequest( 47 | type: state.type, 48 | startDatetime: startDatetime, 49 | endDatetime: endDatetime, 50 | distance: ref.read(metricsViewModelProvider).distance, 51 | locations: locations, 52 | )) 53 | .then((value) { 54 | ref.read(timerViewModelProvider.notifier).resetTimer(); 55 | ref.read(locationViewModelProvider.notifier).resetSavedPositions(); 56 | ref.read(metricsViewModelProvider.notifier).reset(); 57 | ref.read(locationViewModelProvider.notifier).startGettingLocation(); 58 | 59 | state = state.copyWith(isSaving: false); 60 | navigatorKey.currentState?.pop(); 61 | }); 62 | } 63 | 64 | getActivity() { 65 | final startDatetime = ref.read(timerViewModelProvider).startDatetime; 66 | final endDatetime = startDatetime.add(Duration( 67 | hours: ref.read(timerViewModelProvider).hours, 68 | minutes: ref.read(timerViewModelProvider).minutes, 69 | seconds: ref.read(timerViewModelProvider).seconds, 70 | )); 71 | final locations = ref.read(locationViewModelProvider).savedPositions; 72 | final distance = ref.read(metricsViewModelProvider).distance; 73 | final speed = ref.read(metricsViewModelProvider).globalSpeed; 74 | 75 | Duration difference = endDatetime.difference(startDatetime); 76 | double differenceInMilliseconds = difference.inMilliseconds.toDouble(); 77 | 78 | return Activity( 79 | id: '', 80 | type: state.type, 81 | startDatetime: startDatetime, 82 | endDatetime: endDatetime, 83 | distance: distance, 84 | speed: speed, 85 | time: differenceInMilliseconds, 86 | locations: locations 87 | .map((l) => Location( 88 | id: '', 89 | datetime: l.datetime, 90 | latitude: l.latitude, 91 | longitude: l.longitude)) 92 | .toList()); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /lib/presentation/common/location/view_model/location_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter_map/flutter_map.dart'; 4 | import 'package:geolocator/geolocator.dart'; 5 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 6 | import 'package:latlong2/latlong.dart'; 7 | 8 | import '../../../../../data/model/request/location_request.dart'; 9 | import '../../metrics/view_model/metrics_view_model.dart'; 10 | import '../../timer/viewmodel/timer_view_model.dart'; 11 | import 'location_state.dart'; 12 | 13 | /// Provider for the [LocationViewModel]. 14 | final locationViewModelProvider = 15 | StateNotifierProvider.autoDispose( 16 | (ref) => LocationViewModel(ref), 17 | ); 18 | 19 | /// View model for managing location-related functionality. 20 | class LocationViewModel extends StateNotifier { 21 | final Ref ref; 22 | final MapController mapController = MapController(); 23 | StreamSubscription? _positionStream; 24 | 25 | /// Creates a [LocationViewModel] instance. 26 | /// 27 | /// The [ref] is a reference to the current provider reference. 28 | LocationViewModel(this.ref) : super(LocationState.initial()); 29 | 30 | @override 31 | void dispose() { 32 | super.dispose(); 33 | cancelLocationStream(); 34 | } 35 | 36 | /// Starts getting the user's location updates. 37 | Future startGettingLocation() async { 38 | final metricsProvider = ref.read(metricsViewModelProvider.notifier); 39 | 40 | await Geolocator.requestPermission(); 41 | _positionStream ??= 42 | Geolocator.getPositionStream().listen((Position position) { 43 | if (mounted) { 44 | mapController.move( 45 | LatLng(position.latitude, position.longitude), 46 | 17, 47 | ); 48 | 49 | final timerProvider = ref.read(timerViewModelProvider.notifier); 50 | if (timerProvider.isTimerRunning() && timerProvider.hasTimerStarted()) { 51 | metricsProvider.updateMetrics(); 52 | 53 | final positions = List.from(state.savedPositions); 54 | positions.add( 55 | LocationRequest( 56 | datetime: DateTime.now(), 57 | latitude: position.latitude, 58 | longitude: position.longitude, 59 | ), 60 | ); 61 | state = state.copyWith(savedPositions: positions); 62 | } 63 | 64 | state = state.copyWith( 65 | currentPosition: position, 66 | lastPosition: state.currentPosition ?? position, 67 | ); 68 | } 69 | }); 70 | } 71 | 72 | /// Retrieves the saved positions as a list of [LatLng] objects. 73 | List savedPositionsLatLng() { 74 | return state.savedPositions 75 | .map((position) => LatLng(position.latitude, position.longitude)) 76 | .toList(); 77 | } 78 | 79 | /// Resets the saved positions to an empty list. 80 | void resetSavedPositions() { 81 | state = state.copyWith(savedPositions: []); 82 | } 83 | 84 | /// Pauses the location stream. 85 | void stopLocationStream() { 86 | _positionStream?.pause(); 87 | } 88 | 89 | /// Resumes the location stream. 90 | void resumeLocationStream() { 91 | _positionStream?.resume(); 92 | } 93 | 94 | /// Cancels the location stream and cleans up resources. 95 | void cancelLocationStream() async { 96 | await _positionStream?.cancel().whenComplete(() { 97 | _positionStream = null; 98 | state = state.copyWith(currentPosition: null); 99 | }); 100 | } 101 | 102 | /// Checks if the location stream is currently paused. 103 | bool isLocationStreamPaused() { 104 | return _positionStream?.isPaused ?? false; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates a win32 window with |title| that is positioned and sized using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size this function will scale the inputted width and height as 35 | // as appropriate for the default monitor. The window is invisible until 36 | // |Show| is called. Returns true if the window was created successfully. 37 | bool Create(const std::wstring& title, const Point& origin, const Size& size); 38 | 39 | // Show the current window. Returns true if the window was successfully shown. 40 | bool Show(); 41 | 42 | // Release OS resources associated with window. 43 | void Destroy(); 44 | 45 | // Inserts |content| into the window tree. 46 | void SetChildContent(HWND content); 47 | 48 | // Returns the backing Window handle to enable clients to set icon and other 49 | // window properties. Returns nullptr if the window has been destroyed. 50 | HWND GetHandle(); 51 | 52 | // If true, closing this window will quit the application. 53 | void SetQuitOnClose(bool quit_on_close); 54 | 55 | // Return a RECT representing the bounds of the current client area. 56 | RECT GetClientArea(); 57 | 58 | protected: 59 | // Processes and route salient window messages for mouse handling, 60 | // size change and DPI. Delegates handling of these to member overloads that 61 | // inheriting classes can handle. 62 | virtual LRESULT MessageHandler(HWND window, 63 | UINT const message, 64 | WPARAM const wparam, 65 | LPARAM const lparam) noexcept; 66 | 67 | // Called when CreateAndShow is called, allowing subclass window-related 68 | // setup. Subclasses should return false if setup fails. 69 | virtual bool OnCreate(); 70 | 71 | // Called when Destroy is called. 72 | virtual void OnDestroy(); 73 | 74 | private: 75 | friend class WindowClassRegistrar; 76 | 77 | // OS callback called by message pump. Handles the WM_NCCREATE message which 78 | // is passed when the non-client area is being created and enables automatic 79 | // non-client DPI scaling so that the non-client area automatically 80 | // responds to changes in DPI. All other messages are handled by 81 | // MessageHandler. 82 | static LRESULT CALLBACK WndProc(HWND const window, 83 | UINT const message, 84 | WPARAM const wparam, 85 | LPARAM const lparam) noexcept; 86 | 87 | // Retrieves a class instance pointer for |window| 88 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 89 | 90 | // Update the window frame's theme to match the system theme. 91 | static void UpdateTheme(HWND const window); 92 | 93 | bool quit_on_close_ = false; 94 | 95 | // window handle for top level window. 96 | HWND window_handle_ = nullptr; 97 | 98 | // window handle for hosted content. 99 | HWND child_content_ = nullptr; 100 | }; 101 | 102 | #endif // RUNNER_WIN32_WINDOW_H_ 103 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 43 | 49 | 50 | 51 | 52 | 53 | 63 | 65 | 71 | 72 | 73 | 74 | 80 | 82 | 88 | 89 | 90 | 91 | 93 | 94 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # === Flutter Library === 14 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 15 | 16 | # Published to parent scope for install step. 17 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 18 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 19 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 20 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 21 | 22 | list(APPEND FLUTTER_LIBRARY_HEADERS 23 | "flutter_export.h" 24 | "flutter_windows.h" 25 | "flutter_messenger.h" 26 | "flutter_plugin_registrar.h" 27 | "flutter_texture_registrar.h" 28 | ) 29 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 30 | add_library(flutter INTERFACE) 31 | target_include_directories(flutter INTERFACE 32 | "${EPHEMERAL_DIR}" 33 | ) 34 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 35 | add_dependencies(flutter flutter_assemble) 36 | 37 | # === Wrapper === 38 | list(APPEND CPP_WRAPPER_SOURCES_CORE 39 | "core_implementations.cc" 40 | "standard_codec.cc" 41 | ) 42 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 43 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 44 | "plugin_registrar.cc" 45 | ) 46 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 47 | list(APPEND CPP_WRAPPER_SOURCES_APP 48 | "flutter_engine.cc" 49 | "flutter_view_controller.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 52 | 53 | # Wrapper sources needed for a plugin. 54 | add_library(flutter_wrapper_plugin STATIC 55 | ${CPP_WRAPPER_SOURCES_CORE} 56 | ${CPP_WRAPPER_SOURCES_PLUGIN} 57 | ) 58 | apply_standard_settings(flutter_wrapper_plugin) 59 | set_target_properties(flutter_wrapper_plugin PROPERTIES 60 | POSITION_INDEPENDENT_CODE ON) 61 | set_target_properties(flutter_wrapper_plugin PROPERTIES 62 | CXX_VISIBILITY_PRESET hidden) 63 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 64 | target_include_directories(flutter_wrapper_plugin PUBLIC 65 | "${WRAPPER_ROOT}/include" 66 | ) 67 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 68 | 69 | # Wrapper sources needed for the runner. 70 | add_library(flutter_wrapper_app STATIC 71 | ${CPP_WRAPPER_SOURCES_CORE} 72 | ${CPP_WRAPPER_SOURCES_APP} 73 | ) 74 | apply_standard_settings(flutter_wrapper_app) 75 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 76 | target_include_directories(flutter_wrapper_app PUBLIC 77 | "${WRAPPER_ROOT}/include" 78 | ) 79 | add_dependencies(flutter_wrapper_app flutter_assemble) 80 | 81 | # === Flutter tool backend === 82 | # _phony_ is a non-existent file to force this command to run every time, 83 | # since currently there's no way to get a full input/output list from the 84 | # flutter tool. 85 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 86 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 87 | add_custom_command( 88 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 89 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 90 | ${CPP_WRAPPER_SOURCES_APP} 91 | ${PHONY_OUTPUT} 92 | COMMAND ${CMAKE_COMMAND} -E env 93 | ${FLUTTER_TOOL_ENVIRONMENT} 94 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 95 | windows-x64 $ 96 | VERBATIM 97 | ) 98 | add_custom_target(flutter_assemble DEPENDS 99 | "${FLUTTER_LIBRARY}" 100 | ${FLUTTER_LIBRARY_HEADERS} 101 | ${CPP_WRAPPER_SOURCES_CORE} 102 | ${CPP_WRAPPER_SOURCES_PLUGIN} 103 | ${CPP_WRAPPER_SOURCES_APP} 104 | ) 105 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 43 | 49 | 50 | 51 | 52 | 53 | 63 | 65 | 71 | 72 | 73 | 74 | 80 | 82 | 88 | 89 | 90 | 91 | 93 | 94 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "run_tracker"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "run_tracker"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GObject::dispose. 85 | static void my_application_dispose(GObject* object) { 86 | MyApplication* self = MY_APPLICATION(object); 87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 | } 90 | 91 | static void my_application_class_init(MyApplicationClass* klass) { 92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 | } 96 | 97 | static void my_application_init(MyApplication* self) {} 98 | 99 | MyApplication* my_application_new() { 100 | return MY_APPLICATION(g_object_new(my_application_get_type(), 101 | "application-id", APPLICATION_ID, 102 | "flags", G_APPLICATION_NON_UNIQUE, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui' as ui; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter/services.dart'; 5 | import 'package:flutter_gen/gen_l10n/app_localizations.dart'; 6 | import 'package:flutter_localizations/flutter_localizations.dart'; 7 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 8 | import 'package:stack_trace/stack_trace.dart' as stack_trace; 9 | 10 | import 'core/utils/sharedPrefs_utils.dart'; 11 | import 'l10n/support_locale.dart'; 12 | import 'presentation/activity_list/screen/activity_list_screen.dart'; 13 | import 'presentation/common/core/services/text_to_speech_service.dart'; 14 | import 'presentation/common/core/utils/ui_utils.dart'; 15 | import 'presentation/home/screen/home_screen.dart'; 16 | import 'presentation/login/screen/login_screen.dart'; 17 | import 'presentation/registration/screen/registration_screen.dart'; 18 | import 'presentation/sum_up/screen/sum_up_screen.dart'; 19 | 20 | 21 | final GlobalKey navigatorKey = GlobalKey(); 22 | 23 | void main() async { 24 | WidgetsFlutterBinding.ensureInitialized(); 25 | await SystemChrome.setPreferredOrientations([ 26 | DeviceOrientation.portraitUp, 27 | DeviceOrientation.portraitDown 28 | ]); 29 | 30 | runApp( 31 | const ProviderScope(child: MyApp()), 32 | ); 33 | 34 | FlutterError.demangleStackTrace = (StackTrace stack) { 35 | if (stack is stack_trace.Trace) return stack.vmTrace; 36 | if (stack is stack_trace.Chain) return stack.toTrace().vmTrace; 37 | return stack; 38 | }; 39 | } 40 | 41 | final myAppProvider = Provider((ref) { 42 | return MyAppViewModel(ref); 43 | }); 44 | 45 | interface class MyAppViewModel { 46 | final Ref ref; 47 | 48 | MyAppViewModel(this.ref); 49 | 50 | void init() { 51 | ref.read(textToSpeechService).init(); 52 | } 53 | 54 | Future getJwt() async { 55 | return PrefsUtils.getJwt(); 56 | } 57 | 58 | Future getLocalizedConf() async { 59 | final lang = ui.window.locale.languageCode; 60 | final country = ui.window.locale.countryCode; 61 | return await AppLocalizations.delegate.load(Locale(lang, country)); 62 | } 63 | } 64 | 65 | class MyApp extends HookConsumerWidget { 66 | const MyApp({super.key}); 67 | 68 | MaterialApp buildMaterialApp(Widget home) { 69 | return MaterialApp( 70 | initialRoute: '/', 71 | routes: { 72 | '/register': (context) => RegistrationScreen(), 73 | '/login': (context) => LoginScreen(), 74 | '/sumup': (context) => const SumUpScreen(), 75 | '/activity_list': (context) => const ActivityListScreen() 76 | }, 77 | navigatorKey: navigatorKey, 78 | title: 'Run Tracker', 79 | debugShowCheckedModeBanner: false, 80 | theme: ThemeData( 81 | textSelectionTheme: TextSelectionThemeData( 82 | cursorColor: Colors.pink.shade800, 83 | selectionColor: Colors.pink.shade800, 84 | selectionHandleColor: Colors.pink.shade800, 85 | ), 86 | primaryColor: Colors.pink.shade800, 87 | bottomSheetTheme: 88 | const BottomSheetThemeData(backgroundColor: Colors.transparent), 89 | ), 90 | localizationsDelegates: const [ 91 | AppLocalizations.delegate, 92 | GlobalMaterialLocalizations.delegate, 93 | GlobalWidgetsLocalizations.delegate, 94 | GlobalCupertinoLocalizations.delegate, 95 | ], 96 | supportedLocales: L10n.support, 97 | home: home, 98 | ); 99 | } 100 | 101 | @override 102 | Widget build(BuildContext context, WidgetRef ref) { 103 | final provider = ref.read(myAppProvider); 104 | 105 | provider.init(); 106 | 107 | return FutureBuilder( 108 | future: provider.getJwt(), 109 | builder: (context, snapshot) { 110 | if (snapshot.connectionState == ConnectionState.waiting) { 111 | return UIUtils.loader; 112 | } else if (snapshot.hasData && snapshot.data != null) { 113 | return buildMaterialApp(const HomeScreen()); 114 | } else { 115 | return buildMaterialApp(LoginScreen()); 116 | } 117 | }, 118 | ); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(run_tracker LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "run_tracker") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(SET CMP0063 NEW) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | 56 | # Generated plugin build rules, which manage building the plugins and adding 57 | # them to the application. 58 | include(flutter/generated_plugins.cmake) 59 | 60 | 61 | # === Installation === 62 | # Support files are copied into place next to the executable, so that it can 63 | # run in place. This is done instead of making a separate bundle (as on Linux) 64 | # so that building and running from within Visual Studio will work. 65 | set(BUILD_BUNDLE_DIR "$") 66 | # Make the "install" step default, as it's required to run. 67 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 68 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 69 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 70 | endif() 71 | 72 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 73 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 74 | 75 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 76 | COMPONENT Runtime) 77 | 78 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 79 | COMPONENT Runtime) 80 | 81 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 82 | COMPONENT Runtime) 83 | 84 | if(PLUGIN_BUNDLED_LIBRARIES) 85 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 86 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 87 | COMPONENT Runtime) 88 | endif() 89 | 90 | # Fully re-copy the assets directory on each build to avoid having stale files 91 | # from a previous install. 92 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 93 | install(CODE " 94 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 95 | " COMPONENT Runtime) 96 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 97 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 98 | 99 | # Install the AOT library on non-Debug builds only. 100 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 101 | CONFIGURATIONS Profile;Release 102 | COMPONENT Runtime) 103 | -------------------------------------------------------------------------------- /lib/presentation/common/metrics/view_model/metrics_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 3 | import '../../../../../main.dart'; 4 | import '../../core/services/text_to_speech_service.dart'; 5 | import '../../location/view_model/location_view_model.dart'; 6 | import '../../timer/viewmodel/timer_view_model.dart'; 7 | import 'metrics_state.dart'; 8 | 9 | /// A provider for [MetricsViewModel] that creates an instance of [MetricsViewModel] automatically 10 | /// and disposes it when no longer needed. 11 | final metricsViewModelProvider = 12 | StateNotifierProvider.autoDispose( 13 | (ref) => MetricsViewModel(ref.container), 14 | ); 15 | 16 | /// The view model responsible for managing metrics state and calculations. 17 | class MetricsViewModel extends StateNotifier { 18 | final ProviderContainer _container; 19 | late final TextToSpeechService textToSpeech; 20 | 21 | /// Creates an instance of [MetricsViewModel] with the specified [ProviderContainer]. 22 | MetricsViewModel(this._container) : super(MetricsState.initial()) { 23 | textToSpeech = _container.read(textToSpeechService); 24 | } 25 | 26 | /// Updates the metrics based on the current location and timer. 27 | Future updateMetrics() async { 28 | final location = _container.read(locationViewModelProvider); 29 | final timer = _container.read(timerViewModelProvider.notifier); 30 | final timerState = _container.read(timerViewModelProvider); 31 | 32 | final lastDistanceInteger = state.distance.toInt(); 33 | 34 | final distance = state.distance + 35 | distanceInKmBetweenCoordinates( 36 | location.lastPosition?.latitude, 37 | location.lastPosition?.longitude, 38 | location.currentPosition?.latitude, 39 | location.currentPosition?.longitude, 40 | ); 41 | 42 | final globalSpeed = distance / (timer.getTimerInMs() / 3600000); 43 | 44 | state = state.copyWith(distance: distance, globalSpeed: globalSpeed); 45 | 46 | final newDistanceInteger = state.distance.toInt(); 47 | if (newDistanceInteger != lastDistanceInteger) { 48 | final l10nConf = await _container.read(myAppProvider).getLocalizedConf(); 49 | 50 | var textToSay = StringBuffer(); 51 | 52 | textToSay.write("$newDistanceInteger ${l10nConf.kilometers}."); 53 | 54 | var duration = StringBuffer(); 55 | if (timerState.hours != 0) { 56 | duration.write("${timerState.hours} ${l10nConf.hours}"); 57 | } 58 | if (timerState.minutes != 0) { 59 | duration.write("${timerState.minutes} ${l10nConf.minutes}"); 60 | } 61 | if (timerState.seconds != 0) { 62 | duration.write("${timerState.seconds} ${l10nConf.seconds}"); 63 | } 64 | 65 | textToSay.write('${l10nConf.duration}: $duration.'); 66 | 67 | String speedStr = state.globalSpeed.toStringAsFixed(2); 68 | String km = speedStr.split('.')[0]; 69 | String meters = speedStr.split('.')[1]; 70 | 71 | if (meters.startsWith('0')) { 72 | textToSay 73 | .write("${l10nConf.distance}: $speedStr ${l10nConf.kilometers}."); 74 | } else { 75 | textToSay 76 | .write("${l10nConf.distance}: $km,$meters ${l10nConf.kilometers}."); 77 | } 78 | 79 | textToSay.write( 80 | "${l10nConf.speed}: $km,$meters ${l10nConf.kilometers} ${l10nConf.per} ${l10nConf.hours}"); 81 | 82 | await textToSpeech.say(textToSay.toString()); 83 | } 84 | } 85 | 86 | /// Resets the metrics state to its initial values. 87 | void reset() { 88 | state = MetricsState.initial(); 89 | } 90 | 91 | /// Converts degrees to radians. 92 | double degreesToRadians(double degrees) { 93 | return degrees * pi / 180; 94 | } 95 | 96 | /// Calculates the distance in kilometers between two sets of coordinates. 97 | double distanceInKmBetweenCoordinates( 98 | double? lat1, 99 | double? lon1, 100 | double? lat2, 101 | double? lon2, 102 | ) { 103 | const earthRadiusKm = 6371.0; 104 | 105 | final dLat = degreesToRadians(lat2! - lat1!); 106 | final dLon = degreesToRadians(lon2! - lon1!); 107 | 108 | lat1 = degreesToRadians(lat1); 109 | lat2 = degreesToRadians(lat2); 110 | 111 | final a = sin(dLat / 2) * sin(dLat / 2) + 112 | sin(dLon / 2) * sin(dLon / 2) * cos(lat1) * cos(lat2); 113 | final c = 2 * atan2(sqrt(a), sqrt(1 - a)); 114 | return earthRadiusKm * c; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /lib/presentation/common/core/utils/image_utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:typed_data'; 2 | import 'dart:ui' as ui; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter/rendering.dart'; 5 | import 'package:image/image.dart' as img; 6 | 7 | 8 | interface class ImageUtils { 9 | static Future captureWidgetToImage(GlobalKey boundaryKey, 10 | {int size = 1500}) async { 11 | try { 12 | RenderRepaintBoundary boundary = boundaryKey.currentContext! 13 | .findRenderObject() as RenderRepaintBoundary; 14 | ui.Image image = await boundary.toImage(); 15 | ByteData? byteData = 16 | await image.toByteData(format: ui.ImageByteFormat.png); 17 | 18 | if (byteData == null) return null; 19 | 20 | Uint8List originalImageBytes = byteData.buffer.asUint8List(); 21 | Uint8List? croppedImageBytes = await cropImage(originalImageBytes, size); 22 | 23 | return croppedImageBytes; 24 | } catch (e) { 25 | return null; 26 | } 27 | } 28 | 29 | static Future cropImage(Uint8List imageBytes, int size) async { 30 | try { 31 | img.Image? originalImage = img.decodeImage(imageBytes); 32 | if (originalImage == null) return null; 33 | 34 | int cropSize; 35 | int offsetX = 0; 36 | int offsetY = 0; 37 | 38 | if (originalImage.width > originalImage.height) { 39 | // Crop vertically to get a square 40 | cropSize = originalImage.height; 41 | offsetX = (originalImage.width - cropSize) ~/ 2; 42 | } else { 43 | cropSize = originalImage.width; 44 | offsetY = (originalImage.height - cropSize) ~/ 2; 45 | } 46 | 47 | img.Image croppedImage = img.copyCrop(originalImage, 48 | x: offsetX, y: offsetY, width: cropSize, height: cropSize); 49 | img.Image resizedCroppedImage = 50 | img.copyResize(croppedImage, width: size, height: size); 51 | Uint8List croppedImageBytes = 52 | Uint8List.fromList(img.encodePng(resizedCroppedImage)); 53 | 54 | return croppedImageBytes; 55 | } catch (e) { 56 | return null; 57 | } 58 | } 59 | 60 | static Future addTextToImage( 61 | Uint8List imageBytes, String title, String text) async { 62 | try { 63 | img.Image? image = img.decodeImage(imageBytes); 64 | 65 | final recorder = ui.PictureRecorder(); 66 | final canvas = Canvas(recorder); 67 | 68 | final imgCodec = await ui.instantiateImageCodec(imageBytes); 69 | final frame = await imgCodec.getNextFrame(); 70 | 71 | canvas.drawImage( 72 | frame.image, 73 | const Offset(0, 0), 74 | Paint(), 75 | ); 76 | 77 | final titleStyle = ui.TextStyle( 78 | color: Colors.black, 79 | fontSize: 100, 80 | fontWeight: FontWeight.bold, 81 | shadows: [ 82 | const Shadow( 83 | blurRadius: 2, 84 | color: Colors.white, 85 | offset: Offset(1, 1), 86 | ), 87 | ], 88 | ); 89 | final titleParagraphBuilder = ui.ParagraphBuilder(ui.ParagraphStyle()) 90 | ..pushStyle(titleStyle) 91 | ..addText(title.toUpperCase()); 92 | final titleParagraph = titleParagraphBuilder.build(); 93 | titleParagraph 94 | .layout(ui.ParagraphConstraints(width: image!.width.toDouble())); 95 | 96 | canvas.drawParagraph(titleParagraph, const Offset(40, 40)); 97 | 98 | final textStyle = ui.TextStyle( 99 | color: Colors.black, 100 | fontSize: 50, 101 | fontWeight: FontWeight.bold, 102 | shadows: [ 103 | const Shadow( 104 | blurRadius: 2, 105 | color: Colors.white, 106 | offset: Offset(1, 1), 107 | ), 108 | ], 109 | ); 110 | final textParagraphBuilder = ui.ParagraphBuilder(ui.ParagraphStyle()) 111 | ..pushStyle(textStyle) 112 | ..addText(text); 113 | final textParagraph = textParagraphBuilder.build(); 114 | textParagraph 115 | .layout(ui.ParagraphConstraints(width: image.width.toDouble())); 116 | 117 | canvas.drawParagraph(textParagraph, const Offset(40, 160)); 118 | 119 | final imgData = await recorder.endRecording().toImage( 120 | image.width, 121 | image.height, 122 | ); 123 | final byteData = await imgData.toByteData(format: ui.ImageByteFormat.png); 124 | 125 | Uint8List imageWithTextBytes = byteData!.buffer.asUint8List(); 126 | return imageWithTextBytes; 127 | } catch (e) { 128 | return null; 129 | } 130 | } 131 | } 132 | --------------------------------------------------------------------------------