Compare commits
	
		
			No commits in common. "ea1cb1da7642d944534db12d5affb8e2f250cad1" and "3ff136f758e4059ce662ae5f3cb50b84c1208c73" have entirely different histories.
		
	
	
		
			ea1cb1da76
			...
			3ff136f758
		
	
		
|  | @ -33,10 +33,10 @@ class AlarmService : Service(), OnPreparedListener { | |||
|         val pendingStop = | ||||
|             PendingIntent.getBroadcast(context, 0, stopBroadcast, PendingIntent.FLAG_IMMUTABLE) | ||||
|         return NotificationCompat.Builder(context, MainActivity.CHANNEL_ID_PENDING) | ||||
|             .setSmallIcon(R.drawable.baseline_hourglass_bottom_24).setContentTitle("Resting") | ||||
|             .setSmallIcon(R.drawable.ic_baseline_hourglass_bottom_24).setContentTitle("Resting") | ||||
|             .setContentIntent(pendingContent) | ||||
|             .addAction(R.drawable.launch_background, "Stop", pendingStop) | ||||
|             .addAction(R.drawable.launch_background, "Add 1 min", pendingAdd) | ||||
|             .addAction(R.drawable.ic_baseline_stop_24, "Stop", pendingStop) | ||||
|             .addAction(R.drawable.ic_baseline_stop_24, "Add 1 min", pendingAdd) | ||||
|             .setDeleteIntent(pendingStop) | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -18,8 +18,8 @@ import io.flutter.embedding.engine.FlutterEngine | |||
| import io.flutter.plugin.common.MethodChannel | ||||
| import kotlin.math.floor | ||||
| 
 | ||||
| @RequiresApi(Build.VERSION_CODES.O) | ||||
| class MainActivity : FlutterActivity() { | ||||
|     @RequiresApi(Build.VERSION_CODES.O) | ||||
|     override fun configureFlutterEngine(flutterEngine: FlutterEngine) { | ||||
|         super.configureFlutterEngine(flutterEngine) | ||||
|         MethodChannel(flutterEngine.dartExecutor.binaryMessenger, FLUTTER_CHANNEL).setMethodCallHandler { | ||||
|  | @ -38,6 +38,7 @@ class MainActivity : FlutterActivity() { | |||
|     private var running = false | ||||
| 
 | ||||
|     private val stopReceiver = object : BroadcastReceiver() { | ||||
|         @RequiresApi(Build.VERSION_CODES.O) | ||||
|         override fun onReceive(context: Context?, intent: Intent?) { | ||||
|             Log.d("MainActivity", "Received stop broadcast intent") | ||||
|             stop() | ||||
|  | @ -45,6 +46,7 @@ class MainActivity : FlutterActivity() { | |||
|     } | ||||
| 
 | ||||
|     private val addReceiver = object : BroadcastReceiver() { | ||||
|         @RequiresApi(Build.VERSION_CODES.O) | ||||
|         override fun onReceive(context: Context?, intent: Intent?) { | ||||
|             add() | ||||
|         } | ||||
|  | @ -53,6 +55,7 @@ class MainActivity : FlutterActivity() { | |||
|     init { | ||||
|     } | ||||
| 
 | ||||
|     @RequiresApi(api = Build.VERSION_CODES.O) | ||||
|     fun add() { | ||||
|         Log.d("MainActivity", "Add 1 min to alarm.") | ||||
|         countdownTimer?.cancel() | ||||
|  | @ -66,6 +69,7 @@ class MainActivity : FlutterActivity() { | |||
|         context.stopService(intent) | ||||
|     } | ||||
| 
 | ||||
|     @RequiresApi(api = Build.VERSION_CODES.O) | ||||
|     fun stop() { | ||||
|         Log.d("MainActivity", "Stop alarm.") | ||||
|         countdownTimer?.cancel() | ||||
|  | @ -77,6 +81,7 @@ class MainActivity : FlutterActivity() { | |||
|         manager.cancel(NOTIFICATION_ID_PENDING) | ||||
|     } | ||||
| 
 | ||||
|     @RequiresApi(api = Build.VERSION_CODES.O) | ||||
|     fun timer(milliseconds: Int) { | ||||
|         context.registerReceiver(stopReceiver, IntentFilter(STOP_BROADCAST)) | ||||
|         context.registerReceiver(addReceiver, IntentFilter(ADD_BROADCAST)) | ||||
|  | @ -91,6 +96,7 @@ class MainActivity : FlutterActivity() { | |||
|         running = true | ||||
|     } | ||||
| 
 | ||||
|     @RequiresApi(Build.VERSION_CODES.O) | ||||
|     private fun getTimer( | ||||
|         endMs: Int, | ||||
|     ): CountDownTimer { | ||||
|  | @ -119,6 +125,7 @@ class MainActivity : FlutterActivity() { | |||
|     } | ||||
| 
 | ||||
|     @SuppressLint("UnspecifiedImmutableFlag") | ||||
|     @RequiresApi(Build.VERSION_CODES.M) | ||||
|     private fun getBuilder(): NotificationCompat.Builder { | ||||
|         val contentIntent = Intent(context, MainActivity::class.java) | ||||
|         val pendingContent = | ||||
|  | @ -133,13 +140,14 @@ class MainActivity : FlutterActivity() { | |||
|         val pendingStop = | ||||
|             PendingIntent.getBroadcast(context, 0, stopBroadcast, PendingIntent.FLAG_IMMUTABLE) | ||||
|         return NotificationCompat.Builder(context, CHANNEL_ID_PENDING) | ||||
|             .setSmallIcon(R.drawable.baseline_hourglass_bottom_24).setContentTitle("Resting") | ||||
|             .setSmallIcon(R.drawable.ic_baseline_hourglass_bottom_24).setContentTitle("Resting") | ||||
|             .setContentIntent(pendingContent) | ||||
|             .addAction(R.drawable.baseline_hourglass_bottom_24, "Stop", pendingStop) | ||||
|             .addAction(R.drawable.baseline_hourglass_bottom_24, "Add 1 min", pendingAdd) | ||||
|             .addAction(R.drawable.ic_baseline_stop_24, "Stop", pendingStop) | ||||
|             .addAction(R.drawable.ic_baseline_stop_24, "Add 1 min", pendingAdd) | ||||
|             .setDeleteIntent(pendingStop) | ||||
|     } | ||||
| 
 | ||||
|     @RequiresApi(Build.VERSION_CODES.O) | ||||
|     private fun getManager(): NotificationManager { | ||||
|         val notificationManager = context.getSystemService( | ||||
|             NotificationManager::class.java | ||||
|  |  | |||
|  | @ -1,5 +0,0 @@ | |||
| <vector android:height="24dp" android:tint="#000000" | ||||
|     android:viewportHeight="24" android:viewportWidth="24" | ||||
|     android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||||
|     <path android:fillColor="@android:color/white" android:pathData="M18,22l-0.01,-6L14,12l3.99,-4.01L18,2H6v6l4,4l-4,3.99V22H18zM8,7.5V4h8v3.5l-4,4L8,7.5z"/> | ||||
| </vector> | ||||
|  | @ -1,53 +0,0 @@ | |||
| import 'package:flutter/material.dart'; | ||||
| 
 | ||||
| class DynamicColorScheme extends StatefulWidget { | ||||
|   final Color Function(Brightness brightness) data; | ||||
|   final Widget Function(BuildContext context, ColorScheme colorScheme) builder; | ||||
| 
 | ||||
|   const DynamicColorScheme({ | ||||
|     required this.data, | ||||
|     required this.builder, | ||||
|     Key? key, | ||||
|   }) : super(key: key); | ||||
| 
 | ||||
|   @override | ||||
|   createState() => _DynamicColorSchemeState(); | ||||
| } | ||||
| 
 | ||||
| class _DynamicColorSchemeState extends State<DynamicColorScheme> { | ||||
|   late final ValueNotifier<Brightness> brightness; | ||||
| 
 | ||||
|   @override | ||||
|   void initState() { | ||||
|     super.initState(); | ||||
|     brightness = ValueNotifier(MediaQuery.of(context).platformBrightness); | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   void didChangeDependencies() { | ||||
|     super.didChangeDependencies(); | ||||
|     brightness.value = MediaQuery.of(context).platformBrightness; | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return ValueListenableBuilder<Brightness>( | ||||
|       valueListenable: brightness, | ||||
|       builder: (context, platformBrightness, child) { | ||||
|         final colorScheme = ColorScheme.fromSwatch( | ||||
|           brightness: platformBrightness, | ||||
|           primarySwatch: Colors.blue, | ||||
|           accentColor: Colors.blueAccent, | ||||
|         ).copyWith( | ||||
|           secondary: Colors.red, | ||||
|         ); | ||||
|         final color = widget.data(platformBrightness); | ||||
|         return widget.builder( | ||||
|             context, | ||||
|             colorScheme.copyWith( | ||||
|               primary: color, | ||||
|             )); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| } | ||||
|  | @ -25,9 +25,10 @@ class MyApp extends StatelessWidget { | |||
| 
 | ||||
|     return MaterialApp( | ||||
|       title: 'Gym App', | ||||
|       themeMode: ThemeMode.system, | ||||
|       darkTheme: ThemeData.dark(), | ||||
|       theme: ThemeData.light(), | ||||
|       theme: ThemeData( | ||||
|         primarySwatch: Colors.blue, | ||||
|         visualDensity: VisualDensity.adaptivePlatformDensity, | ||||
|       ), | ||||
|       initialRoute: '/home', | ||||
|       routes: routes, | ||||
|       navigatorKey: navigatorKey, | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ import 'package:flutter/material.dart'; | |||
| import 'package:flutter/material.dart' as material; | ||||
| import 'package:fmassive/database.dart'; | ||||
| import 'package:fmassive/main.dart'; | ||||
| import 'package:fmassive/sound_picker.dart'; | ||||
| import 'package:moor/moor.dart'; | ||||
| 
 | ||||
| class SettingsPage extends StatelessWidget { | ||||
|  | @ -48,6 +47,7 @@ class _SettingsPageState extends State<_SettingsPage> { | |||
|               return const Center(child: CircularProgressIndicator()); | ||||
| 
 | ||||
|             return SingleChildScrollView( | ||||
|               padding: const EdgeInsets.all(8.0), | ||||
|               child: material.Column( | ||||
|                 crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                 children: [ | ||||
|  | @ -105,14 +105,46 @@ class _SettingsPageState extends State<_SettingsPage> { | |||
|                           .write(SettingsCompanion(steps: Value(value))); | ||||
|                     }, | ||||
|                   ), | ||||
|                   Center( | ||||
|                       child: SoundPicker( | ||||
|                           path: settings.sound, | ||||
|                           onSelect: (path) { | ||||
|                             db | ||||
|                                 .update(db.settings) | ||||
|                                 .write(SettingsCompanion(sound: Value(path))); | ||||
|                           })), | ||||
|                   TextField( | ||||
|                     decoration: const InputDecoration( | ||||
|                       labelText: 'Sound', | ||||
|                     ), | ||||
|                     onChanged: (value) { | ||||
|                       db | ||||
|                           .update(db.settings) | ||||
|                           .write(SettingsCompanion(sound: Value(value))); | ||||
|                     }, | ||||
|                   ), | ||||
|                   TextField( | ||||
|                     decoration: const InputDecoration( | ||||
|                       labelText: 'Light Color', | ||||
|                     ), | ||||
|                     onChanged: (value) { | ||||
|                       db | ||||
|                           .update(db.settings) | ||||
|                           .write(SettingsCompanion(lightColor: Value(value))); | ||||
|                     }, | ||||
|                   ), | ||||
|                   TextField( | ||||
|                     decoration: const InputDecoration( | ||||
|                       labelText: 'Dark Color', | ||||
|                     ), | ||||
|                     onChanged: (value) { | ||||
|                       db | ||||
|                           .update(db.settings) | ||||
|                           .write(SettingsCompanion(darkColor: Value(value))); | ||||
|                     }, | ||||
|                   ), | ||||
|                   TextField( | ||||
|                     decoration: const InputDecoration( | ||||
|                       labelText: 'Date', | ||||
|                     ), | ||||
|                     onChanged: (value) { | ||||
|                       db | ||||
|                           .update(db.settings) | ||||
|                           .write(SettingsCompanion(date: Value(value))); | ||||
|                     }, | ||||
|                   ), | ||||
|                 ], | ||||
|               ), | ||||
|             ); | ||||
|  |  | |||
|  | @ -1,43 +0,0 @@ | |||
| import 'package:audioplayers/audioplayers.dart'; | ||||
| import 'package:file_picker/file_picker.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:path/path.dart'; | ||||
| 
 | ||||
| class SoundPicker extends StatefulWidget { | ||||
|   const SoundPicker({super.key, required this.onSelect, required this.path}); | ||||
| 
 | ||||
|   final Function(String path) onSelect; | ||||
|   final String? path; | ||||
| 
 | ||||
|   @override | ||||
|   createState() => _SoundPickerState(); | ||||
| } | ||||
| 
 | ||||
| class _SoundPickerState extends State<SoundPicker> { | ||||
|   final audioPlayer = AudioPlayer(); | ||||
| 
 | ||||
|   @override | ||||
|   void dispose() { | ||||
|     audioPlayer.dispose(); | ||||
|     super.dispose(); | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return ElevatedButton( | ||||
|       onPressed: () async { | ||||
|         FilePickerResult? result = await FilePicker.platform.pickFiles( | ||||
|           type: FileType.audio, | ||||
|         ); | ||||
|         if (result == null) return; | ||||
|         final path = result.files.first.path; | ||||
|         if (path == null) return; | ||||
|         await audioPlayer.play(DeviceFileSource(path)); | ||||
|         widget.onSelect(path); | ||||
|       }, | ||||
|       child: Text(widget.path != null | ||||
|           ? "Sound: ${basename(widget.path!)}" | ||||
|           : 'Alarm sound'), | ||||
|     ); | ||||
|   } | ||||
| } | ||||
|  | @ -6,13 +6,9 @@ | |||
| 
 | ||||
| #include "generated_plugin_registrant.h" | ||||
| 
 | ||||
| #include <audioplayers_linux/audioplayers_linux_plugin.h> | ||||
| #include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h> | ||||
| 
 | ||||
| void fl_register_plugins(FlPluginRegistry* registry) { | ||||
|   g_autoptr(FlPluginRegistrar) audioplayers_linux_registrar = | ||||
|       fl_plugin_registry_get_registrar_for_plugin(registry, "AudioplayersLinuxPlugin"); | ||||
|   audioplayers_linux_plugin_register_with_registrar(audioplayers_linux_registrar); | ||||
|   g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar = | ||||
|       fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin"); | ||||
|   sqlite3_flutter_libs_plugin_register_with_registrar(sqlite3_flutter_libs_registrar); | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| # | ||||
| 
 | ||||
| list(APPEND FLUTTER_PLUGIN_LIST | ||||
|   audioplayers_linux | ||||
|   sqlite3_flutter_libs | ||||
| ) | ||||
| 
 | ||||
|  |  | |||
|  | @ -5,13 +5,11 @@ | |||
| import FlutterMacOS | ||||
| import Foundation | ||||
| 
 | ||||
| import audioplayers_darwin | ||||
| import path_provider_foundation | ||||
| import sqflite | ||||
| import sqlite3_flutter_libs | ||||
| 
 | ||||
| func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { | ||||
|   AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin")) | ||||
|   PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) | ||||
|   SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) | ||||
|   Sqlite3FlutterLibsPlugin.register(with: registry.registrar(forPlugin: "Sqlite3FlutterLibsPlugin")) | ||||
|  |  | |||
							
								
								
									
										93
									
								
								pubspec.lock
									
									
									
									
									
								
							
							
						
						
									
										93
									
								
								pubspec.lock
									
									
									
									
									
								
							|  | @ -41,62 +41,6 @@ packages: | |||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "2.10.0" | ||||
|   audioplayers: | ||||
|     dependency: "direct main" | ||||
|     description: | ||||
|       name: audioplayers | ||||
|       sha256: "6063c05f987596ba7a3dad9bb9a5d8adfa5e7c07b9bae5301b27c11d0b3a239f" | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "4.0.1" | ||||
|   audioplayers_android: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: audioplayers_android | ||||
|       sha256: fb6bca878ad175d8f6ddc0e0a2d4226d81fa7c10747c12db420e96c7a096b2cc | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "3.0.1" | ||||
|   audioplayers_darwin: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: audioplayers_darwin | ||||
|       sha256: c4a56c49347b2e85ac4e1efea218948ca0fba87f04d2a3d3de07ce2410037038 | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "4.0.1" | ||||
|   audioplayers_linux: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: audioplayers_linux | ||||
|       sha256: "897e24f190232a3fbb88134b062aa83a9240f55789b5e8d17c114283284ef56b" | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "2.0.1" | ||||
|   audioplayers_platform_interface: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: audioplayers_platform_interface | ||||
|       sha256: "3a90a46198d375fc7d47bc1d3070c8fd8863b6469b7d87ca80f953efb090f976" | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "5.0.0" | ||||
|   audioplayers_web: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: audioplayers_web | ||||
|       sha256: "4f5dcbfec0bf98ea09e243d5f5b64ea43a4e6710a2f292724bed16cdba3c691e" | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "3.0.1" | ||||
|   audioplayers_windows: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: audioplayers_windows | ||||
|       sha256: "010f575653c01ccbe9756050b18df83d89426740e04b684f6438aa26c775a965" | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "2.0.1" | ||||
|   boolean_selector: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|  | @ -297,14 +241,6 @@ packages: | |||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "6.1.4" | ||||
|   file_picker: | ||||
|     dependency: "direct main" | ||||
|     description: | ||||
|       name: file_picker | ||||
|       sha256: dcde5ad1a0cebcf3715ea3f24d0db1888bf77027a26c77d7779e8ef63b8ade62 | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "5.2.9" | ||||
|   fixnum: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|  | @ -326,24 +262,11 @@ packages: | |||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "2.0.1" | ||||
|   flutter_plugin_android_lifecycle: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: flutter_plugin_android_lifecycle | ||||
|       sha256: c224ac897bed083dabf11f238dd11a239809b446740be0c2044608c50029ffdf | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "2.0.9" | ||||
|   flutter_test: | ||||
|     dependency: "direct dev" | ||||
|     description: flutter | ||||
|     source: sdk | ||||
|     version: "0.0.0" | ||||
|   flutter_web_plugins: | ||||
|     dependency: transitive | ||||
|     description: flutter | ||||
|     source: sdk | ||||
|     version: "0.0.0" | ||||
|   frontend_server_client: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|  | @ -368,14 +291,6 @@ packages: | |||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "2.2.0" | ||||
|   http: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: http | ||||
|       sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482" | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "0.13.5" | ||||
|   http_multi_server: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|  | @ -757,14 +672,6 @@ packages: | |||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "1.3.1" | ||||
|   uuid: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: uuid | ||||
|       sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313" | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "3.0.7" | ||||
|   vector_math: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|  |  | |||
|  | @ -42,8 +42,6 @@ dependencies: | |||
|   path_provider: ^2.0.14 | ||||
|   sqlite3_flutter_libs: ^0.5.13 | ||||
|   moor: ^4.6.1+1 | ||||
|   file_picker: ^5.2.9 | ||||
|   audioplayers: ^4.0.1 | ||||
| 
 | ||||
| dev_dependencies: | ||||
|   flutter_test: | ||||
|  |  | |||
|  | @ -6,12 +6,9 @@ | |||
| 
 | ||||
| #include "generated_plugin_registrant.h" | ||||
| 
 | ||||
| #include <audioplayers_windows/audioplayers_windows_plugin.h> | ||||
| #include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h> | ||||
| 
 | ||||
| void RegisterPlugins(flutter::PluginRegistry* registry) { | ||||
|   AudioplayersWindowsPluginRegisterWithRegistrar( | ||||
|       registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin")); | ||||
|   Sqlite3FlutterLibsPluginRegisterWithRegistrar( | ||||
|       registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin")); | ||||
| } | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| # | ||||
| 
 | ||||
| list(APPEND FLUTTER_PLUGIN_LIST | ||||
|   audioplayers_windows | ||||
|   sqlite3_flutter_libs | ||||
| ) | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user