diff --git a/lib/core/database.dart b/lib/core/database.dart index aaee96d..67c4889 100644 --- a/lib/core/database.dart +++ b/lib/core/database.dart @@ -604,7 +604,7 @@ class DatabaseHelper { file_path = '${directory.path}/backup_database.db'; } else if (Platform.isAndroid) { file_path = '/storage/emulated/0/Download/backup_database.db'; - + // Use file picker to select the backup file FilePickerResult? result = await FilePicker.platform.pickFiles( type: FileType.any, @@ -620,7 +620,7 @@ class DatabaseHelper { } else { throw Exception('Unsupported platform'); } - + // Check if the backup file exists File selectedFile = File(file_path); if (!await selectedFile.exists()) { diff --git a/lib/tabs/visualization_tab.dart b/lib/tabs/visualization_tab.dart index f21fb21..fc75441 100644 --- a/lib/tabs/visualization_tab.dart +++ b/lib/tabs/visualization_tab.dart @@ -229,9 +229,7 @@ class VisualizationTabState extends State { if (_selectedTable == 'Fitness') { switch (_dataType) { case 'Weight': - return widget.isKg - ? value - : value * 2.20462; + return widget.isKg ? value : value * 2.20462; case 'Height': return value; // Assuming height is already in the desired unit case 'Age': diff --git a/lib/widgets/charts/chart_widget.dart b/lib/widgets/charts/chart_widget.dart index 6df4200..baca88d 100644 --- a/lib/widgets/charts/chart_widget.dart +++ b/lib/widgets/charts/chart_widget.dart @@ -119,9 +119,21 @@ class ChartWidget extends StatelessWidget { ); }, ), - lineTouchData: const LineTouchData( + lineTouchData: LineTouchData( enabled: true, handleBuiltInTouches: true, + touchTooltipData: LineTouchTooltipData( + tooltipMargin: 8, + tooltipHorizontalAlignment: FLHorizontalAlignment.left, + getTooltipItems: (List touchedSpots) { + return touchedSpots.map((touchedSpot) { + return LineTooltipItem( + _formatTooltip(touchedSpot.x, touchedSpot.y), + TextStyle(color: Colors.white), + ); + }).toList(); + }, + ), ), ), ); @@ -217,6 +229,16 @@ class ChartWidget extends StatelessWidget { scatterTouchData: ScatterTouchData( enabled: true, handleBuiltInTouches: true, + touchTooltipData: ScatterTouchTooltipData( + getTooltipColor: (ScatterSpot spot) => Colors.blueGrey, + tooltipHorizontalAlignment: FLHorizontalAlignment.left, + getTooltipItems: (ScatterSpot touchedSpot) { + return ScatterTooltipItem( + _formatTooltip(touchedSpot.x, touchedSpot.y), + textStyle: TextStyle(color: Colors.white), + ); + }, + ), ), ), ); @@ -238,4 +260,10 @@ class ChartWidget extends StatelessWidget { ), ); } + + String _formatTooltip(double x, double y) { + final date = DateTime.now().add(Duration(days: x.toInt())); + final formattedDate = DateFormat('dd/MM').format(date); + return 'x=$formattedDate\ny=${y.toStringAsFixed(2)}'; + } } diff --git a/lib/widgets/settings/settings.dart b/lib/widgets/settings/settings.dart index 476a0d7..525fb81 100644 --- a/lib/widgets/settings/settings.dart +++ b/lib/widgets/settings/settings.dart @@ -234,9 +234,7 @@ class SettingsModalState extends State { value: _appTheme, style: TextStyle( fontSize: 14, - color: isDarkMode - ? Colors.purple - : Colors.black, + color: isDarkMode ? Colors.purple : Colors.black, ), items: const [ DropdownMenuItem( @@ -287,9 +285,7 @@ class SettingsModalState extends State { child: Text( _isKg ? 'kg' : 'lbs', style: TextStyle( - color: Theme.of(context) - .colorScheme - .primary, + color: Theme.of(context).colorScheme.primary, fontSize: 16, ), ), @@ -324,9 +320,7 @@ class SettingsModalState extends State { value: _aggregationMethod, style: TextStyle( fontSize: 14, - color: isDarkMode - ? Colors.purple - : Colors.black, + color: isDarkMode ? Colors.purple : Colors.black, ), items: const [ DropdownMenuItem( @@ -366,9 +360,7 @@ class SettingsModalState extends State { value: _plotType, style: TextStyle( fontSize: 14, - color: isDarkMode - ? Colors.purple - : Colors.black, + color: isDarkMode ? Colors.purple : Colors.black, ), items: const [ DropdownMenuItem( diff --git a/pubspec.yaml b/pubspec.yaml index 965ae91..4e4b2e5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: IronFlow description: "Strength training and fitness app for mobile devices." publish_to: 'none' # Remove this line if you wish to publish to pub.dev -version: 0.12.1+61 +version: 0.12.2+62 environment: sdk: '>=3.4.3 <4.0.0' @@ -30,7 +30,7 @@ dependencies: permission_handler: ^11.3.1 # visualization - fl_chart: ^0.68.0 + fl_chart: ^0.70.0 # settings (to remember user settings) shared_preferences: ^2.0.6