Skip to content

Commit

Permalink
Fix importing from Massive sets export - 1.0.63 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonp2412 committed Apr 25, 2024
1 parent cc7e99f commit 9b0ded1
Show file tree
Hide file tree
Showing 18 changed files with 38 additions and 14 deletions.
2 changes: 2 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/70.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix importing from Massive sets export
- Fix line graph crash for empty relative strengths
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/1_en-US.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/2_en-US.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 35 additions & 13 deletions lib/import_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flexify/database.dart';
import 'package:flexify/main.dart';
import 'package:flexify/utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class ImportData extends StatelessWidget {
final BuildContext pageContext;
Expand Down Expand Up @@ -32,19 +33,40 @@ class ImportData extends StatelessWidget {
const CsvToListConverter(eol: "\n").convert(csv);
if (rows.isEmpty) return;

final gymSets = rows.map(
(row) => GymSetsCompanion(
name: Value(row[1]),
reps: Value(row[2]),
weight: Value(row[3]),
created: Value(parseDate(row[4])),
unit: Value(row[5]),
bodyWeight: Value(row.elementAtOrNull(6) ?? 0),
),
);
await db.batch(
(batch) => batch.insertAll(db.gymSets, gymSets),
);
try {
final gymSets = rows.map(
(row) => GymSetsCompanion(
name: Value(row[1]),
reps: Value(row[2] is String
? double.parse(row[2])
: row[2]),
weight: Value(row[3] is String
? double.parse(row[3])
: row[3]),
created: Value(parseDate(row[4])),
unit: Value(row[5]),
bodyWeight: Value(row.elementAtOrNull(6) is String
? double.parse(row[6])
: row.elementAtOrNull(6) ?? 0),
),
);
await db.gymSets.deleteAll();
await db.gymSets.insertAll(gymSets);
} catch (error) {
if (!pageContext.mounted) return;
ScaffoldMessenger.of(pageContext).showSnackBar(
SnackBar(
content: const Text('Failed to import data'),
action: SnackBarAction(
label: "Copy",
onPressed: () {
Clipboard.setData(
ClipboardData(text: error.toString()));
}),
),
);
return;
}

final weightSet = await getBodyWeight();
if (weightSet != null)
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: flexify
description: Track gym progress, visualize graphs, enjoy offline support & timers
publish_to: none
version: 1.0.62+69
version: 1.0.63+70
environment:
sdk: '>=3.2.6 <4.0.0'
dependencies:
Expand Down

0 comments on commit 9b0ded1

Please sign in to comment.