mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Postmerge fixes
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -7,9 +7,7 @@ class $IngredientsTable extends Ingredients with TableInfo<$IngredientsTable, In
|
||||
@override
|
||||
final GeneratedDatabase attachedDatabase;
|
||||
final String? _alias;
|
||||
|
||||
$IngredientsTable(this.attachedDatabase, [this._alias]);
|
||||
|
||||
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
||||
@override
|
||||
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
||||
@@ -28,7 +26,9 @@ class $IngredientsTable extends Ingredients with TableInfo<$IngredientsTable, In
|
||||
type: DriftSqlType.string,
|
||||
requiredDuringInsert: true,
|
||||
);
|
||||
static const VerificationMeta _lastFetchedMeta = const VerificationMeta('lastFetched');
|
||||
static const VerificationMeta _lastFetchedMeta = const VerificationMeta(
|
||||
'lastFetched',
|
||||
);
|
||||
@override
|
||||
late final GeneratedColumn<DateTime> lastFetched = GeneratedColumn<DateTime>(
|
||||
'last_fetched',
|
||||
@@ -37,17 +37,13 @@ class $IngredientsTable extends Ingredients with TableInfo<$IngredientsTable, In
|
||||
type: DriftSqlType.dateTime,
|
||||
requiredDuringInsert: true,
|
||||
);
|
||||
|
||||
@override
|
||||
List<GeneratedColumn> get $columns => [id, data, lastFetched];
|
||||
|
||||
@override
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
|
||||
@override
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'ingredients';
|
||||
|
||||
@override
|
||||
VerificationContext validateIntegrity(
|
||||
Insertable<IngredientTable> instance, {
|
||||
@@ -61,14 +57,20 @@ class $IngredientsTable extends Ingredients with TableInfo<$IngredientsTable, In
|
||||
context.missing(_idMeta);
|
||||
}
|
||||
if (data.containsKey('data')) {
|
||||
context.handle(_dataMeta, this.data.isAcceptableOrUnknown(data['data']!, _dataMeta));
|
||||
context.handle(
|
||||
_dataMeta,
|
||||
this.data.isAcceptableOrUnknown(data['data']!, _dataMeta),
|
||||
);
|
||||
} else if (isInserting) {
|
||||
context.missing(_dataMeta);
|
||||
}
|
||||
if (data.containsKey('last_fetched')) {
|
||||
context.handle(
|
||||
_lastFetchedMeta,
|
||||
lastFetched.isAcceptableOrUnknown(data['last_fetched']!, _lastFetchedMeta),
|
||||
lastFetched.isAcceptableOrUnknown(
|
||||
data['last_fetched']!,
|
||||
_lastFetchedMeta,
|
||||
),
|
||||
);
|
||||
} else if (isInserting) {
|
||||
context.missing(_lastFetchedMeta);
|
||||
@@ -78,13 +80,18 @@ class $IngredientsTable extends Ingredients with TableInfo<$IngredientsTable, In
|
||||
|
||||
@override
|
||||
Set<GeneratedColumn> get $primaryKey => const {};
|
||||
|
||||
@override
|
||||
IngredientTable map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return IngredientTable(
|
||||
id: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
data: attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}data'])!,
|
||||
id: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.int,
|
||||
data['${effectivePrefix}id'],
|
||||
)!,
|
||||
data: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}data'],
|
||||
)!,
|
||||
lastFetched: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.dateTime,
|
||||
data['${effectivePrefix}last_fetched'],
|
||||
@@ -104,9 +111,11 @@ class IngredientTable extends DataClass implements Insertable<IngredientTable> {
|
||||
|
||||
/// The date when the ingredient was last fetched from the server
|
||||
final DateTime lastFetched;
|
||||
|
||||
const IngredientTable({required this.id, required this.data, required this.lastFetched});
|
||||
|
||||
const IngredientTable({
|
||||
required this.id,
|
||||
required this.data,
|
||||
required this.lastFetched,
|
||||
});
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, Expression>{};
|
||||
@@ -117,10 +126,17 @@ class IngredientTable extends DataClass implements Insertable<IngredientTable> {
|
||||
}
|
||||
|
||||
IngredientsCompanion toCompanion(bool nullToAbsent) {
|
||||
return IngredientsCompanion(id: Value(id), data: Value(data), lastFetched: Value(lastFetched));
|
||||
return IngredientsCompanion(
|
||||
id: Value(id),
|
||||
data: Value(data),
|
||||
lastFetched: Value(lastFetched),
|
||||
);
|
||||
}
|
||||
|
||||
factory IngredientTable.fromJson(Map<String, dynamic> json, {ValueSerializer? serializer}) {
|
||||
factory IngredientTable.fromJson(
|
||||
Map<String, dynamic> json, {
|
||||
ValueSerializer? serializer,
|
||||
}) {
|
||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||
return IngredientTable(
|
||||
id: serializer.fromJson<int>(json['id']),
|
||||
@@ -128,7 +144,6 @@ class IngredientTable extends DataClass implements Insertable<IngredientTable> {
|
||||
lastFetched: serializer.fromJson<DateTime>(json['lastFetched']),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||
@@ -144,7 +159,6 @@ class IngredientTable extends DataClass implements Insertable<IngredientTable> {
|
||||
data: data ?? this.data,
|
||||
lastFetched: lastFetched ?? this.lastFetched,
|
||||
);
|
||||
|
||||
IngredientTable copyWithCompanion(IngredientsCompanion data) {
|
||||
return IngredientTable(
|
||||
id: data.id.present ? data.id.value : this.id,
|
||||
@@ -165,7 +179,6 @@ class IngredientTable extends DataClass implements Insertable<IngredientTable> {
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(id, data, lastFetched);
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
@@ -180,14 +193,12 @@ class IngredientsCompanion extends UpdateCompanion<IngredientTable> {
|
||||
final Value<String> data;
|
||||
final Value<DateTime> lastFetched;
|
||||
final Value<int> rowid;
|
||||
|
||||
const IngredientsCompanion({
|
||||
this.id = const Value.absent(),
|
||||
this.data = const Value.absent(),
|
||||
this.lastFetched = const Value.absent(),
|
||||
this.rowid = const Value.absent(),
|
||||
});
|
||||
|
||||
IngredientsCompanion.insert({
|
||||
required int id,
|
||||
required String data,
|
||||
@@ -196,7 +207,6 @@ class IngredientsCompanion extends UpdateCompanion<IngredientTable> {
|
||||
}) : id = Value(id),
|
||||
data = Value(data),
|
||||
lastFetched = Value(lastFetched);
|
||||
|
||||
static Insertable<IngredientTable> custom({
|
||||
Expression<int>? id,
|
||||
Expression<String>? data,
|
||||
@@ -257,14 +267,11 @@ class IngredientsCompanion extends UpdateCompanion<IngredientTable> {
|
||||
|
||||
abstract class _$IngredientDatabase extends GeneratedDatabase {
|
||||
_$IngredientDatabase(QueryExecutor e) : super(e);
|
||||
|
||||
$IngredientDatabaseManager get managers => $IngredientDatabaseManager(this);
|
||||
late final $IngredientsTable ingredients = $IngredientsTable(this);
|
||||
|
||||
@override
|
||||
Iterable<TableInfo<Table, Object?>> get allTables =>
|
||||
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
||||
|
||||
@override
|
||||
List<DatabaseSchemaEntity> get allSchemaEntities => [ingredients];
|
||||
}
|
||||
@@ -292,15 +299,20 @@ class $$IngredientsTableFilterComposer extends Composer<_$IngredientDatabase, $I
|
||||
super.$addJoinBuilderToRootComposer,
|
||||
super.$removeJoinBuilderFromRootComposer,
|
||||
});
|
||||
ColumnFilters<int> get id => $composableBuilder(
|
||||
column: $table.id,
|
||||
builder: (column) => ColumnFilters(column),
|
||||
);
|
||||
|
||||
ColumnFilters<int> get id =>
|
||||
$composableBuilder(column: $table.id, builder: (column) => ColumnFilters(column));
|
||||
ColumnFilters<String> get data => $composableBuilder(
|
||||
column: $table.data,
|
||||
builder: (column) => ColumnFilters(column),
|
||||
);
|
||||
|
||||
ColumnFilters<String> get data =>
|
||||
$composableBuilder(column: $table.data, builder: (column) => ColumnFilters(column));
|
||||
|
||||
ColumnFilters<DateTime> get lastFetched =>
|
||||
$composableBuilder(column: $table.lastFetched, builder: (column) => ColumnFilters(column));
|
||||
ColumnFilters<DateTime> get lastFetched => $composableBuilder(
|
||||
column: $table.lastFetched,
|
||||
builder: (column) => ColumnFilters(column),
|
||||
);
|
||||
}
|
||||
|
||||
class $$IngredientsTableOrderingComposer extends Composer<_$IngredientDatabase, $IngredientsTable> {
|
||||
@@ -311,15 +323,20 @@ class $$IngredientsTableOrderingComposer extends Composer<_$IngredientDatabase,
|
||||
super.$addJoinBuilderToRootComposer,
|
||||
super.$removeJoinBuilderFromRootComposer,
|
||||
});
|
||||
ColumnOrderings<int> get id => $composableBuilder(
|
||||
column: $table.id,
|
||||
builder: (column) => ColumnOrderings(column),
|
||||
);
|
||||
|
||||
ColumnOrderings<int> get id =>
|
||||
$composableBuilder(column: $table.id, builder: (column) => ColumnOrderings(column));
|
||||
ColumnOrderings<String> get data => $composableBuilder(
|
||||
column: $table.data,
|
||||
builder: (column) => ColumnOrderings(column),
|
||||
);
|
||||
|
||||
ColumnOrderings<String> get data =>
|
||||
$composableBuilder(column: $table.data, builder: (column) => ColumnOrderings(column));
|
||||
|
||||
ColumnOrderings<DateTime> get lastFetched =>
|
||||
$composableBuilder(column: $table.lastFetched, builder: (column) => ColumnOrderings(column));
|
||||
ColumnOrderings<DateTime> get lastFetched => $composableBuilder(
|
||||
column: $table.lastFetched,
|
||||
builder: (column) => ColumnOrderings(column),
|
||||
);
|
||||
}
|
||||
|
||||
class $$IngredientsTableAnnotationComposer
|
||||
@@ -331,14 +348,15 @@ class $$IngredientsTableAnnotationComposer
|
||||
super.$addJoinBuilderToRootComposer,
|
||||
super.$removeJoinBuilderFromRootComposer,
|
||||
});
|
||||
|
||||
GeneratedColumn<int> get id => $composableBuilder(column: $table.id, builder: (column) => column);
|
||||
|
||||
GeneratedColumn<String> get data =>
|
||||
$composableBuilder(column: $table.data, builder: (column) => column);
|
||||
|
||||
GeneratedColumn<DateTime> get lastFetched =>
|
||||
$composableBuilder(column: $table.lastFetched, builder: (column) => column);
|
||||
GeneratedColumn<DateTime> get lastFetched => $composableBuilder(
|
||||
column: $table.lastFetched,
|
||||
builder: (column) => column,
|
||||
);
|
||||
}
|
||||
|
||||
class $$IngredientsTableTableManager
|
||||
@@ -359,8 +377,10 @@ class $$IngredientsTableTableManager
|
||||
IngredientTable,
|
||||
PrefetchHooks Function()
|
||||
> {
|
||||
$$IngredientsTableTableManager(_$IngredientDatabase db, $IngredientsTable table)
|
||||
: super(
|
||||
$$IngredientsTableTableManager(
|
||||
_$IngredientDatabase db,
|
||||
$IngredientsTable table,
|
||||
) : super(
|
||||
TableManagerState(
|
||||
db: db,
|
||||
table: table,
|
||||
@@ -374,8 +394,12 @@ class $$IngredientsTableTableManager
|
||||
Value<String> data = const Value.absent(),
|
||||
Value<DateTime> lastFetched = const Value.absent(),
|
||||
Value<int> rowid = const Value.absent(),
|
||||
}) =>
|
||||
IngredientsCompanion(id: id, data: data, lastFetched: lastFetched, rowid: rowid),
|
||||
}) => IngredientsCompanion(
|
||||
id: id,
|
||||
data: data,
|
||||
lastFetched: lastFetched,
|
||||
rowid: rowid,
|
||||
),
|
||||
createCompanionCallback:
|
||||
({
|
||||
required int id,
|
||||
@@ -412,9 +436,7 @@ typedef $$IngredientsTableProcessedTableManager =
|
||||
|
||||
class $IngredientDatabaseManager {
|
||||
final _$IngredientDatabase _db;
|
||||
|
||||
$IngredientDatabaseManager(this._db);
|
||||
|
||||
$$IngredientsTableTableManager get ingredients =>
|
||||
$$IngredientsTableTableManager(_db, _db.ingredients);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart' as riverpod;
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/core/locator.dart';
|
||||
import 'package:wger/powersync.dart';
|
||||
import 'package:wger/exceptions/http_exception.dart';
|
||||
import 'package:wger/helpers/errors.dart';
|
||||
import 'package:wger/helpers/shared_preferences.dart';
|
||||
|
||||
@@ -8,7 +8,10 @@ part of 'category.dart';
|
||||
|
||||
ExerciseCategory _$ExerciseCategoryFromJson(Map<String, dynamic> json) {
|
||||
$checkKeys(json, requiredKeys: const ['id', 'name']);
|
||||
return ExerciseCategory(id: (json['id'] as num).toInt(), name: json['name'] as String);
|
||||
return ExerciseCategory(
|
||||
id: (json['id'] as num).toInt(),
|
||||
name: json['name'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$ExerciseCategoryToJson(ExerciseCategory instance) => <String, dynamic>{
|
||||
|
||||
@@ -38,7 +38,9 @@ Exercise _$ExerciseFromJson(Map<String, dynamic> json) {
|
||||
.toList(),
|
||||
category: json['categories'] == null
|
||||
? null
|
||||
: ExerciseCategory.fromJson(json['categories'] as Map<String, dynamic>),
|
||||
: ExerciseCategory.fromJson(
|
||||
json['categories'] as Map<String, dynamic>,
|
||||
),
|
||||
)
|
||||
..categoryId = (json['category'] as num).toInt()
|
||||
..musclesIds = (json['muscles'] as List<dynamic>).map((e) => (e as num).toInt()).toList()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,9 @@ _ExerciseBaseData _$ExerciseBaseDataFromJson(Map<String, dynamic> json) => _Exer
|
||||
created: DateTime.parse(json['created'] as String),
|
||||
lastUpdate: DateTime.parse(json['last_update'] as String),
|
||||
lastUpdateGlobal: DateTime.parse(json['last_update_global'] as String),
|
||||
category: ExerciseCategory.fromJson(json['category'] as Map<String, dynamic>),
|
||||
category: ExerciseCategory.fromJson(
|
||||
json['category'] as Map<String, dynamic>,
|
||||
),
|
||||
muscles: (json['muscles'] as List<dynamic>)
|
||||
.map((e) => Muscle.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
@@ -56,34 +58,39 @@ Map<String, dynamic> _$ExerciseBaseDataToJson(_ExerciseBaseData instance) => <St
|
||||
'total_authors_history': instance.authorsGlobal,
|
||||
};
|
||||
|
||||
_ExerciseSearchDetails _$ExerciseSearchDetailsFromJson(Map<String, dynamic> json) =>
|
||||
_ExerciseSearchDetails(
|
||||
translationId: (json['id'] as num).toInt(),
|
||||
exerciseId: (json['base_id'] as num).toInt(),
|
||||
name: json['name'] as String,
|
||||
category: json['category'] as String,
|
||||
image: json['image'] as String?,
|
||||
imageThumbnail: json['image_thumbnail'] as String?,
|
||||
);
|
||||
_ExerciseSearchDetails _$ExerciseSearchDetailsFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _ExerciseSearchDetails(
|
||||
translationId: (json['id'] as num).toInt(),
|
||||
exerciseId: (json['base_id'] as num).toInt(),
|
||||
name: json['name'] as String,
|
||||
category: json['category'] as String,
|
||||
image: json['image'] as String?,
|
||||
imageThumbnail: json['image_thumbnail'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ExerciseSearchDetailsToJson(_ExerciseSearchDetails instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.translationId,
|
||||
'base_id': instance.exerciseId,
|
||||
'name': instance.name,
|
||||
'category': instance.category,
|
||||
'image': instance.image,
|
||||
'image_thumbnail': instance.imageThumbnail,
|
||||
};
|
||||
Map<String, dynamic> _$ExerciseSearchDetailsToJson(
|
||||
_ExerciseSearchDetails instance,
|
||||
) => <String, dynamic>{
|
||||
'id': instance.translationId,
|
||||
'base_id': instance.exerciseId,
|
||||
'name': instance.name,
|
||||
'category': instance.category,
|
||||
'image': instance.image,
|
||||
'image_thumbnail': instance.imageThumbnail,
|
||||
};
|
||||
|
||||
_ExerciseSearchEntry _$ExerciseSearchEntryFromJson(Map<String, dynamic> json) =>
|
||||
_ExerciseSearchEntry(
|
||||
value: json['value'] as String,
|
||||
data: ExerciseSearchDetails.fromJson(json['data'] as Map<String, dynamic>),
|
||||
data: ExerciseSearchDetails.fromJson(
|
||||
json['data'] as Map<String, dynamic>,
|
||||
),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ExerciseSearchEntryToJson(_ExerciseSearchEntry instance) =>
|
||||
<String, dynamic>{'value': instance.value, 'data': instance.data};
|
||||
Map<String, dynamic> _$ExerciseSearchEntryToJson(
|
||||
_ExerciseSearchEntry instance,
|
||||
) => <String, dynamic>{'value': instance.value, 'data': instance.data};
|
||||
|
||||
_ExerciseApiSearch _$ExerciseApiSearchFromJson(Map<String, dynamic> json) => _ExerciseApiSearch(
|
||||
suggestions: (json['suggestions'] as List<dynamic>)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,17 +6,21 @@ part of 'exercise_submission.dart';
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_ExerciseAliasSubmissionApi _$ExerciseAliasSubmissionApiFromJson(Map<String, dynamic> json) =>
|
||||
_ExerciseAliasSubmissionApi(alias: json['alias'] as String);
|
||||
_ExerciseAliasSubmissionApi _$ExerciseAliasSubmissionApiFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _ExerciseAliasSubmissionApi(alias: json['alias'] as String);
|
||||
|
||||
Map<String, dynamic> _$ExerciseAliasSubmissionApiToJson(_ExerciseAliasSubmissionApi instance) =>
|
||||
<String, dynamic>{'alias': instance.alias};
|
||||
Map<String, dynamic> _$ExerciseAliasSubmissionApiToJson(
|
||||
_ExerciseAliasSubmissionApi instance,
|
||||
) => <String, dynamic>{'alias': instance.alias};
|
||||
|
||||
_ExerciseCommentSubmissionApi _$ExerciseCommentSubmissionApiFromJson(Map<String, dynamic> json) =>
|
||||
_ExerciseCommentSubmissionApi(alias: json['alias'] as String);
|
||||
_ExerciseCommentSubmissionApi _$ExerciseCommentSubmissionApiFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _ExerciseCommentSubmissionApi(alias: json['alias'] as String);
|
||||
|
||||
Map<String, dynamic> _$ExerciseCommentSubmissionApiToJson(_ExerciseCommentSubmissionApi instance) =>
|
||||
<String, dynamic>{'alias': instance.alias};
|
||||
Map<String, dynamic> _$ExerciseCommentSubmissionApiToJson(
|
||||
_ExerciseCommentSubmissionApi instance,
|
||||
) => <String, dynamic>{'alias': instance.alias};
|
||||
|
||||
_ExerciseTranslationSubmissionApi _$ExerciseTranslationSubmissionApiFromJson(
|
||||
Map<String, dynamic> json,
|
||||
@@ -27,12 +31,18 @@ _ExerciseTranslationSubmissionApi _$ExerciseTranslationSubmissionApiFromJson(
|
||||
author: json['license_author'] as String,
|
||||
aliases:
|
||||
(json['aliases'] as List<dynamic>?)
|
||||
?.map((e) => ExerciseAliasSubmissionApi.fromJson(e as Map<String, dynamic>))
|
||||
?.map(
|
||||
(e) => ExerciseAliasSubmissionApi.fromJson(e as Map<String, dynamic>),
|
||||
)
|
||||
.toList() ??
|
||||
const [],
|
||||
comments:
|
||||
(json['comments'] as List<dynamic>?)
|
||||
?.map((e) => ExerciseCommentSubmissionApi.fromJson(e as Map<String, dynamic>))
|
||||
?.map(
|
||||
(e) => ExerciseCommentSubmissionApi.fromJson(
|
||||
e as Map<String, dynamic>,
|
||||
),
|
||||
)
|
||||
.toList() ??
|
||||
const [],
|
||||
);
|
||||
@@ -48,30 +58,36 @@ Map<String, dynamic> _$ExerciseTranslationSubmissionApiToJson(
|
||||
'comments': instance.comments,
|
||||
};
|
||||
|
||||
_ExerciseSubmissionApi _$ExerciseSubmissionApiFromJson(Map<String, dynamic> json) =>
|
||||
_ExerciseSubmissionApi(
|
||||
category: (json['category'] as num).toInt(),
|
||||
muscles: (json['muscles'] as List<dynamic>).map((e) => (e as num).toInt()).toList(),
|
||||
musclesSecondary: (json['muscles_secondary'] as List<dynamic>)
|
||||
.map((e) => (e as num).toInt())
|
||||
.toList(),
|
||||
equipment: (json['equipment'] as List<dynamic>).map((e) => (e as num).toInt()).toList(),
|
||||
author: json['license_author'] as String,
|
||||
variation: (json['variation'] as num?)?.toInt(),
|
||||
variationConnectTo: (json['variations_connect_to'] as num?)?.toInt(),
|
||||
translations: (json['translations'] as List<dynamic>)
|
||||
.map((e) => ExerciseTranslationSubmissionApi.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
_ExerciseSubmissionApi _$ExerciseSubmissionApiFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _ExerciseSubmissionApi(
|
||||
category: (json['category'] as num).toInt(),
|
||||
muscles: (json['muscles'] as List<dynamic>).map((e) => (e as num).toInt()).toList(),
|
||||
musclesSecondary: (json['muscles_secondary'] as List<dynamic>)
|
||||
.map((e) => (e as num).toInt())
|
||||
.toList(),
|
||||
equipment: (json['equipment'] as List<dynamic>).map((e) => (e as num).toInt()).toList(),
|
||||
author: json['license_author'] as String,
|
||||
variation: (json['variation'] as num?)?.toInt(),
|
||||
variationConnectTo: (json['variations_connect_to'] as num?)?.toInt(),
|
||||
translations: (json['translations'] as List<dynamic>)
|
||||
.map(
|
||||
(e) => ExerciseTranslationSubmissionApi.fromJson(
|
||||
e as Map<String, dynamic>,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ExerciseSubmissionApiToJson(_ExerciseSubmissionApi instance) =>
|
||||
<String, dynamic>{
|
||||
'category': instance.category,
|
||||
'muscles': instance.muscles,
|
||||
'muscles_secondary': instance.musclesSecondary,
|
||||
'equipment': instance.equipment,
|
||||
'license_author': instance.author,
|
||||
'variation': instance.variation,
|
||||
'variations_connect_to': instance.variationConnectTo,
|
||||
'translations': instance.translations,
|
||||
};
|
||||
Map<String, dynamic> _$ExerciseSubmissionApiToJson(
|
||||
_ExerciseSubmissionApi instance,
|
||||
) => <String, dynamic>{
|
||||
'category': instance.category,
|
||||
'muscles': instance.muscles,
|
||||
'muscles_secondary': instance.musclesSecondary,
|
||||
'equipment': instance.equipment,
|
||||
'license_author': instance.author,
|
||||
'variation': instance.variation,
|
||||
'variations_connect_to': instance.variationConnectTo,
|
||||
'translations': instance.translations,
|
||||
};
|
||||
|
||||
@@ -9,7 +9,15 @@ part of 'translation.dart';
|
||||
Translation _$TranslationFromJson(Map<String, dynamic> json) {
|
||||
$checkKeys(
|
||||
json,
|
||||
requiredKeys: const ['id', 'uuid', 'language', 'created', 'exercise', 'name', 'description'],
|
||||
requiredKeys: const [
|
||||
'id',
|
||||
'uuid',
|
||||
'language',
|
||||
'created',
|
||||
'exercise',
|
||||
'name',
|
||||
'description',
|
||||
],
|
||||
);
|
||||
return Translation(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
|
||||
@@ -20,7 +20,9 @@ MeasurementCategory _$MeasurementCategoryFromJson(Map<String, dynamic> json) {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$MeasurementCategoryToJson(MeasurementCategory instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$MeasurementCategoryToJson(
|
||||
MeasurementCategory instance,
|
||||
) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'unit': instance.unit,
|
||||
|
||||
@@ -50,7 +50,9 @@ Ingredient _$IngredientFromJson(Map<String, dynamic> json) {
|
||||
: IngredientImage.fromJson(json['image'] as Map<String, dynamic>),
|
||||
thumbnails: json['thumbnails'] == null
|
||||
? null
|
||||
: IngredientImageThumbnails.fromJson(json['thumbnails'] as Map<String, dynamic>),
|
||||
: IngredientImageThumbnails.fromJson(
|
||||
json['thumbnails'] as Map<String, dynamic>,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,9 @@ part of 'ingredient_image_thumbnails.dart';
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
IngredientImageThumbnails _$IngredientImageThumbnailsFromJson(Map<String, dynamic> json) {
|
||||
IngredientImageThumbnails _$IngredientImageThumbnailsFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) {
|
||||
$checkKeys(
|
||||
json,
|
||||
requiredKeys: const [
|
||||
@@ -28,12 +30,13 @@ IngredientImageThumbnails _$IngredientImageThumbnailsFromJson(Map<String, dynami
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$IngredientImageThumbnailsToJson(IngredientImageThumbnails instance) =>
|
||||
<String, dynamic>{
|
||||
'small': instance.small,
|
||||
'small_cropped': instance.smallCropped,
|
||||
'medium': instance.medium,
|
||||
'medium_cropped': instance.mediumCropped,
|
||||
'large': instance.large,
|
||||
'large_cropped': instance.largeCropped,
|
||||
};
|
||||
Map<String, dynamic> _$IngredientImageThumbnailsToJson(
|
||||
IngredientImageThumbnails instance,
|
||||
) => <String, dynamic>{
|
||||
'small': instance.small,
|
||||
'small_cropped': instance.smallCropped,
|
||||
'medium': instance.medium,
|
||||
'medium_cropped': instance.mediumCropped,
|
||||
'large': instance.large,
|
||||
'large_cropped': instance.largeCropped,
|
||||
};
|
||||
|
||||
@@ -7,21 +7,27 @@ part of 'ingredient_weight_unit.dart';
|
||||
// **************************************************************************
|
||||
|
||||
IngredientWeightUnit _$IngredientWeightUnitFromJson(Map<String, dynamic> json) {
|
||||
$checkKeys(json, requiredKeys: const ['id', 'weight_unit', 'ingredient', 'grams', 'amount']);
|
||||
$checkKeys(
|
||||
json,
|
||||
requiredKeys: const ['id', 'weight_unit', 'ingredient', 'grams', 'amount'],
|
||||
);
|
||||
return IngredientWeightUnit(
|
||||
id: (json['id'] as num).toInt(),
|
||||
weightUnit: WeightUnit.fromJson(json['weight_unit'] as Map<String, dynamic>),
|
||||
weightUnit: WeightUnit.fromJson(
|
||||
json['weight_unit'] as Map<String, dynamic>,
|
||||
),
|
||||
ingredient: Ingredient.fromJson(json['ingredient'] as Map<String, dynamic>),
|
||||
grams: (json['grams'] as num).toInt(),
|
||||
amount: (json['amount'] as num).toDouble(),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$IngredientWeightUnitToJson(IngredientWeightUnit instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'weight_unit': instance.weightUnit,
|
||||
'ingredient': instance.ingredient,
|
||||
'grams': instance.grams,
|
||||
'amount': instance.amount,
|
||||
};
|
||||
Map<String, dynamic> _$IngredientWeightUnitToJson(
|
||||
IngredientWeightUnit instance,
|
||||
) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'weight_unit': instance.weightUnit,
|
||||
'ingredient': instance.ingredient,
|
||||
'grams': instance.grams,
|
||||
'amount': instance.amount,
|
||||
};
|
||||
|
||||
@@ -118,7 +118,7 @@ class Log {
|
||||
return results.map((r) => Log.fromRow(r)).toList();
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
Future<void> delete() async {
|
||||
await db.execute('DELETE FROM $logItemsTable WHERE id = ?', [id]);
|
||||
}
|
||||
|
||||
@@ -7,10 +7,10 @@ part of 'meal.dart';
|
||||
// **************************************************************************
|
||||
|
||||
Meal _$MealFromJson(Map<String, dynamic> json) => Meal(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
id: json['id'] as String?,
|
||||
time: stringToTimeNull(json['time'] as String?),
|
||||
name: json['name'] as String?,
|
||||
)..planId = (json['plan'] as num).toInt();
|
||||
)..planId = json['plan'] as String;
|
||||
|
||||
Map<String, dynamic> _$MealToJson(Meal instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
|
||||
@@ -39,7 +39,7 @@ class NutritionalPlan {
|
||||
final _logger = Logger('NutritionalPlan Model');
|
||||
|
||||
@JsonKey(required: true)
|
||||
int? id;
|
||||
String? id;
|
||||
|
||||
@JsonKey(required: true)
|
||||
late String description;
|
||||
@@ -109,6 +109,8 @@ class NutritionalPlan {
|
||||
id: row['id'],
|
||||
description: row['description'],
|
||||
creationDate: DateTime.parse(row['creation_date']),
|
||||
startDate: row['start'] != null ? DateTime.parse(row['start']) : DateTime.now(),
|
||||
endDate: row['end'] != null ? DateTime.parse(row['end']) : null,
|
||||
onlyLogging: row['only_logging'] == 1,
|
||||
goalEnergy: row['goal_energy'],
|
||||
goalProtein: row['goal_protein'],
|
||||
@@ -135,6 +137,8 @@ class NutritionalPlan {
|
||||
id: id ?? this.id,
|
||||
description: description ?? this.description,
|
||||
creationDate: creationDate ?? this.creationDate,
|
||||
startDate: startDate ?? this.startDate,
|
||||
endDate: endDate ?? this.endDate,
|
||||
onlyLogging: onlyLogging ?? this.onlyLogging,
|
||||
goalEnergy: goalEnergy ?? this.goalEnergy,
|
||||
goalProtein: goalProtein ?? this.goalProtein,
|
||||
|
||||
@@ -10,6 +10,7 @@ NutritionalPlan _$NutritionalPlanFromJson(Map<String, dynamic> json) {
|
||||
$checkKeys(
|
||||
json,
|
||||
requiredKeys: const [
|
||||
'id',
|
||||
'description',
|
||||
'creation_date',
|
||||
'start',
|
||||
|
||||
@@ -9,7 +9,15 @@ part of 'routine.dart';
|
||||
Routine _$RoutineFromJson(Map<String, dynamic> json) {
|
||||
$checkKeys(
|
||||
json,
|
||||
requiredKeys: const ['id', 'created', 'name', 'description', 'fit_in_week', 'start', 'end'],
|
||||
requiredKeys: const [
|
||||
'id',
|
||||
'created',
|
||||
'name',
|
||||
'description',
|
||||
'fit_in_week',
|
||||
'start',
|
||||
'end',
|
||||
],
|
||||
);
|
||||
return Routine(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
|
||||
@@ -9,7 +9,15 @@ part of 'session.dart';
|
||||
WorkoutSession _$WorkoutSessionFromJson(Map<String, dynamic> json) {
|
||||
$checkKeys(
|
||||
json,
|
||||
requiredKeys: const ['id', 'routine', 'day', 'date', 'impression', 'time_start', 'time_end'],
|
||||
requiredKeys: const [
|
||||
'id',
|
||||
'routine',
|
||||
'day',
|
||||
'date',
|
||||
'impression',
|
||||
'time_start',
|
||||
'time_end',
|
||||
],
|
||||
);
|
||||
return WorkoutSession(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
|
||||
@@ -8,7 +8,10 @@ part of 'weight_unit.dart';
|
||||
|
||||
WeightUnit _$WeightUnitFromJson(Map<String, dynamic> json) {
|
||||
$checkKeys(json, requiredKeys: const ['id', 'name']);
|
||||
return WeightUnit(id: (json['id'] as num).toInt(), name: json['name'] as String);
|
||||
return WeightUnit(
|
||||
id: (json['id'] as num).toInt(),
|
||||
name: json['name'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$WeightUnitToJson(WeightUnit instance) => <String, dynamic>{
|
||||
|
||||
@@ -39,7 +39,7 @@ class DjangoConnector extends PowerSyncBackendConnector {
|
||||
// final wgerSession = await apiClient.getWgerJWTToken();
|
||||
final session = await apiClient.getPowersyncToken();
|
||||
// note: we don't set userId and expires property here. not sure if needed
|
||||
return PowerSyncCredentials(endpoint: this.powersyncUrl, token: session['token']);
|
||||
return PowerSyncCredentials(endpoint: powersyncUrl, token: session['token']);
|
||||
}
|
||||
|
||||
// Upload pending changes to Postgres via Django backend
|
||||
|
||||
@@ -24,11 +24,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:wger/core/locator.dart';
|
||||
import 'package:wger/database/ingredients/ingredients_database.dart';
|
||||
import 'package:wger/exceptions/http_exception.dart';
|
||||
import 'package:wger/exceptions/no_such_entry_exception.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/models/nutrition/ingredient.dart';
|
||||
import 'package:wger/models/nutrition/ingredient_image.dart';
|
||||
import 'package:wger/models/nutrition/log.dart';
|
||||
import 'package:wger/models/nutrition/meal.dart';
|
||||
import 'package:wger/models/nutrition/meal_item.dart';
|
||||
@@ -85,7 +82,7 @@ class NutritionPlansProvider with ChangeNotifier {
|
||||
.sorted((a, b) => b.creationDate.compareTo(a.creationDate))
|
||||
.firstOrNull;
|
||||
}
|
||||
/*
|
||||
/*
|
||||
NutritionalPlan findById(int id) {
|
||||
return _plans.firstWhere(
|
||||
(plan) => plan.id == id,
|
||||
@@ -168,7 +165,7 @@ class NutritionPlansProvider with ChangeNotifier {
|
||||
),
|
||||
);
|
||||
}
|
||||
/*
|
||||
/*
|
||||
TODO implement:
|
||||
ingredient.image = image;
|
||||
mealItem.ingredient = ingredient;
|
||||
@@ -188,11 +185,11 @@ TODO implement:
|
||||
}
|
||||
|
||||
Future<void> editPlan(NutritionalPlan plan) async {
|
||||
// TODO
|
||||
// TODO
|
||||
}
|
||||
|
||||
Future<void> deletePlan(String id) async {
|
||||
// TODO
|
||||
// TODO
|
||||
}
|
||||
|
||||
/// Adds a meal to a plan
|
||||
@@ -406,10 +403,11 @@ TODO implement:
|
||||
}
|
||||
|
||||
/// Log custom ingredient to nutrition diary
|
||||
Future<void> logIngredientToDiary(MealItem mealItem, int planId, [DateTime? dateTime]) async {
|
||||
Future<void> logIngredientToDiary(MealItem mealItem, String planId, [DateTime? dateTime]) async {
|
||||
print(
|
||||
'DIETER logIngredientToDiary called ingredient=${mealItem.ingredientId}, planId=$planId, dateTime=$dateTime'
|
||||
'DIETER logIngredientToDiary called ingredient=${mealItem.ingredientId}, planId=$planId, dateTime=$dateTime',
|
||||
);
|
||||
/*
|
||||
final plan = findById(planId);
|
||||
mealItem.ingredient = await fetchIngredient(mealItem.ingredientId);
|
||||
final log = Log.fromMealItem(mealItem, plan.id!, null, dateTime);
|
||||
@@ -417,6 +415,8 @@ TODO implement:
|
||||
final data = await baseProvider.post(log.toJson(), baseProvider.makeUrl(_nutritionDiaryPath));
|
||||
log.id = data['id'];
|
||||
plan.diaryEntries.add(log);
|
||||
|
||||
*/
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wger/models/muscle.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
import 'package:wger/models/muscle.dart';
|
||||
import 'package:wger/widgets/core/app_bar.dart';
|
||||
import 'package:wger/widgets/dashboard/calendar.dart';
|
||||
import 'package:wger/widgets/dashboard/widgets/measurements.dart';
|
||||
|
||||
@@ -136,7 +136,7 @@ class _HomeTabsScreenState extends State<HomeTabsScreen> with SingleTickerProvid
|
||||
widget._logger.info('Loading routines, weight, measurements and gallery');
|
||||
await Future.wait([
|
||||
galleryProvider.fetchAndSetGallery(),
|
||||
nutritionPlansProvider.fetchAndSetAllPlansSparse(),
|
||||
// nutritionPlansProvider.fetchAndSetAllPlansSparse(),
|
||||
routinesProvider.fetchAndSetAllRoutinesSparse(),
|
||||
// routinesProvider.fetchAndSetAllRoutinesFull(),
|
||||
weightProvider.fetchAndSetEntries(),
|
||||
@@ -145,11 +145,11 @@ class _HomeTabsScreenState extends State<HomeTabsScreen> with SingleTickerProvid
|
||||
|
||||
//
|
||||
// Current nutritional plan
|
||||
widget._logger.info('Loading current nutritional plan');
|
||||
if (nutritionPlansProvider.currentPlan != null) {
|
||||
final plan = nutritionPlansProvider.currentPlan!;
|
||||
await nutritionPlansProvider.fetchAndSetPlanFull(plan.id!);
|
||||
}
|
||||
// widget._logger.info('Loading current nutritional plan');
|
||||
// if (nutritionPlansProvider.currentPlan != null) {
|
||||
// final plan = nutritionPlansProvider.currentPlan!;
|
||||
// await nutritionPlansProvider.fetchAndSetPlanFull(plan.id!);
|
||||
// }
|
||||
|
||||
//
|
||||
// Current routine
|
||||
|
||||
@@ -28,12 +28,12 @@ import 'package:wger/widgets/nutrition/nutritional_diary_detail.dart';
|
||||
/// Arguments passed to the form screen
|
||||
class NutritionalDiaryArguments {
|
||||
/// Nutritional plan
|
||||
final String plan;
|
||||
final String planId;
|
||||
|
||||
/// Date to show data for
|
||||
final DateTime date;
|
||||
|
||||
const NutritionalDiaryArguments(this.plan, this.date);
|
||||
const NutritionalDiaryArguments(this.planId, this.date);
|
||||
}
|
||||
|
||||
class NutritionalDiaryScreen extends StatefulWidget {
|
||||
@@ -55,8 +55,10 @@ class _NutritionalDiaryScreenState extends State<NutritionalDiaryScreen> {
|
||||
final args = ModalRoute.of(context)!.settings.arguments as NutritionalDiaryArguments;
|
||||
date = args.date;
|
||||
|
||||
final stream =
|
||||
Provider.of<NutritionPlansProvider>(context, listen: false).watchNutritionPlan(args.plan);
|
||||
final stream = Provider.of<NutritionPlansProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).watchNutritionPlan(args.planId);
|
||||
_subscription = stream.listen((plan) {
|
||||
if (!context.mounted) {
|
||||
return;
|
||||
|
||||
@@ -79,141 +79,146 @@ class _NutritionalPlanScreenState extends State<NutritionalPlanScreen> {
|
||||
floatingActionButton: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
FloatingActionButton(
|
||||
heroTag: null,
|
||||
tooltip: AppLocalizations.of(context).logIngredient,
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).logIngredient,
|
||||
getIngredientLogForm(nutritionalPlan),
|
||||
hasListView: true,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: const SvgIcon(
|
||||
icon: SvgIconData('assets/icons/ingredient-diary.svg'),
|
||||
color: Colors.white,
|
||||
if (_plan != null)
|
||||
FloatingActionButton(
|
||||
heroTag: null,
|
||||
tooltip: AppLocalizations.of(context).logIngredient,
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).logIngredient,
|
||||
getIngredientLogForm(_plan!),
|
||||
hasListView: true,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: const SvgIcon(
|
||||
icon: SvgIconData('assets/icons/ingredient-diary.svg'),
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
FloatingActionButton(
|
||||
heroTag: null,
|
||||
tooltip: AppLocalizations.of(context).logMeal,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(
|
||||
LogMealsScreen.routeName,
|
||||
arguments: nutritionalPlan,
|
||||
);
|
||||
},
|
||||
child: const SvgIcon(
|
||||
icon: SvgIconData('assets/icons/meal-diary.svg'),
|
||||
color: Colors.white,
|
||||
if (_plan != null)
|
||||
FloatingActionButton(
|
||||
heroTag: null,
|
||||
tooltip: AppLocalizations.of(context).logMeal,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(
|
||||
LogMealsScreen.routeName,
|
||||
arguments: _plan,
|
||||
);
|
||||
},
|
||||
child: const SvgIcon(
|
||||
icon: SvgIconData('assets/icons/meal-diary.svg'),
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
SliverAppBar(
|
||||
foregroundColor: appBarForeground,
|
||||
pinned: true,
|
||||
iconTheme: const IconThemeData(color: appBarForeground),
|
||||
actions: [
|
||||
if (!nutritionalPlan.onlyLogging)
|
||||
IconButton(
|
||||
icon: const SvgIcon(
|
||||
icon: SvgIconData('assets/icons/meal-add.svg'),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).addMeal,
|
||||
MealForm(nutritionalPlan.id!),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
PopupMenuButton<NutritionalPlanOptions>(
|
||||
icon: const Icon(Icons.more_vert, color: appBarForeground),
|
||||
onSelected: (value) {
|
||||
switch (value) {
|
||||
case NutritionalPlanOptions.edit:
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).edit,
|
||||
PlanForm(nutritionalPlan),
|
||||
hasListView: true,
|
||||
body: _plan == null
|
||||
? const Text('plan not found')
|
||||
: CustomScrollView(
|
||||
slivers: [
|
||||
SliverAppBar(
|
||||
foregroundColor: appBarForeground,
|
||||
pinned: true,
|
||||
iconTheme: const IconThemeData(color: appBarForeground),
|
||||
actions: [
|
||||
if (!_plan!.onlyLogging)
|
||||
IconButton(
|
||||
icon: const SvgIcon(
|
||||
icon: SvgIconData('assets/icons/meal-add.svg'),
|
||||
),
|
||||
);
|
||||
break;
|
||||
case NutritionalPlanOptions.delete:
|
||||
Provider.of<NutritionPlansProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).deletePlan(nutritionalPlan.id!);
|
||||
Navigator.of(context).pop();
|
||||
break;
|
||||
}
|
||||
},
|
||||
itemBuilder: (BuildContext context) {
|
||||
return [
|
||||
PopupMenuItem<NutritionalPlanOptions>(
|
||||
value: NutritionalPlanOptions.edit,
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.edit),
|
||||
title: Text(AppLocalizations.of(context).edit),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).addMeal,
|
||||
MealForm(_plan!.id!),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const PopupMenuDivider(),
|
||||
PopupMenuItem<NutritionalPlanOptions>(
|
||||
value: NutritionalPlanOptions.delete,
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.delete),
|
||||
title: Text(AppLocalizations.of(context).delete),
|
||||
),
|
||||
),
|
||||
];
|
||||
},
|
||||
),
|
||||
],
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
titlePadding: const EdgeInsets.fromLTRB(56, 0, 56, 16),
|
||||
title: Text(
|
||||
nutritionalPlan.getLabel(context),
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(color: appBarForeground),
|
||||
),
|
||||
),
|
||||
),
|
||||
FutureBuilder(
|
||||
future: _loadFullPlan(context, nutritionalPlan.id!),
|
||||
builder: (context, AsyncSnapshot<NutritionalPlan> snapshot) =>
|
||||
snapshot.connectionState == ConnectionState.waiting
|
||||
? SliverList(
|
||||
delegate: SliverChildListDelegate(
|
||||
[
|
||||
const SizedBox(
|
||||
height: 200,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
PopupMenuButton<NutritionalPlanOptions>(
|
||||
icon: const Icon(Icons.more_vert, color: appBarForeground),
|
||||
onSelected: (value) {
|
||||
switch (value) {
|
||||
case NutritionalPlanOptions.edit:
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).edit,
|
||||
PlanForm(_plan),
|
||||
hasListView: true,
|
||||
),
|
||||
);
|
||||
break;
|
||||
case NutritionalPlanOptions.delete:
|
||||
Provider.of<NutritionPlansProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).deletePlan(_plan!.id!);
|
||||
Navigator.of(context).pop();
|
||||
break;
|
||||
}
|
||||
},
|
||||
itemBuilder: (BuildContext context) {
|
||||
return [
|
||||
PopupMenuItem<NutritionalPlanOptions>(
|
||||
value: NutritionalPlanOptions.edit,
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.edit),
|
||||
title: Text(AppLocalizations.of(context).edit),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
const PopupMenuDivider(),
|
||||
PopupMenuItem<NutritionalPlanOptions>(
|
||||
value: NutritionalPlanOptions.delete,
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.delete),
|
||||
title: Text(AppLocalizations.of(context).delete),
|
||||
),
|
||||
),
|
||||
];
|
||||
},
|
||||
),
|
||||
],
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
titlePadding: const EdgeInsets.fromLTRB(56, 0, 56, 16),
|
||||
title: Text(
|
||||
_plan!.getLabel(context),
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.titleLarge?.copyWith(color: appBarForeground),
|
||||
),
|
||||
)
|
||||
: Consumer<NutritionPlansProvider>(
|
||||
builder: (context, value, child) =>
|
||||
NutritionalPlanDetailWidget(nutritionalPlan),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
FutureBuilder(
|
||||
future: NutritionalPlan.read(_plan!.id!),
|
||||
builder: (context, AsyncSnapshot<NutritionalPlan> snapshot) =>
|
||||
snapshot.connectionState == ConnectionState.waiting
|
||||
? SliverList(
|
||||
delegate: SliverChildListDelegate(
|
||||
[
|
||||
const SizedBox(
|
||||
height: 200,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Consumer<NutritionPlansProvider>(
|
||||
builder: (context, value, child) => NutritionalPlanDetailWidget(_plan!),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ Widget getMealItemForm(
|
||||
]) {
|
||||
return IngredientForm(
|
||||
// TODO we use planId 0 here cause we don't have one and we don't need it I think?
|
||||
recent: recent.map((e) => Log.fromMealItem(e, "0", e.mealId)).toList(),
|
||||
recent: recent.map((e) => Log.fromMealItem(e, '0', e.mealId)).toList(),
|
||||
onSave: (BuildContext context, MealItem mealItem, DateTime? dt) {
|
||||
mealItem.mealId = meal.id!;
|
||||
Provider.of<NutritionPlansProvider>(context, listen: false).addMealItem(mealItem, meal);
|
||||
|
||||
@@ -113,7 +113,7 @@ class NutritionalDiaryTable extends StatelessWidget {
|
||||
return GestureDetector(
|
||||
onTap: () => Navigator.of(context).pushNamed(
|
||||
NutritionalDiaryScreen.routeName,
|
||||
arguments: NutritionalDiaryArguments(plan, date),
|
||||
arguments: NutritionalDiaryArguments(plan.id!, date),
|
||||
),
|
||||
child: element,
|
||||
);
|
||||
|
||||
@@ -138,8 +138,8 @@ class NutritionalPlanDetailWidget extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
]),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/helpers/measurements.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
import 'package:wger/models/nutrition/nutritional_plan.dart';
|
||||
import 'package:wger/providers/body_weight.dart';
|
||||
import 'package:wger/providers/nutrition.dart';
|
||||
import 'package:wger/providers/user.dart';
|
||||
@@ -117,99 +118,98 @@ class _NutritionalPlansListState extends State<NutritionalPlansList> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return RefreshIndicator(
|
||||
onRefresh: () => _nutritionProvider.fetchAndSetAllPlansSparse(),
|
||||
child: _nutritionProvider.items.isEmpty
|
||||
? const TextPrompt()
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
itemCount: _nutritionProvider.items.length,
|
||||
itemBuilder: (context, index) {
|
||||
final currentPlan = _nutritionProvider.items[index];
|
||||
return Card(
|
||||
child: ListTile(
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(
|
||||
NutritionalPlanScreen.routeName,
|
||||
arguments: currentPlan,
|
||||
);
|
||||
},
|
||||
title: Text(currentPlan.getLabel(context)),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
currentPlan.endDate != null
|
||||
? 'from ${DateFormat.yMd(
|
||||
Localizations.localeOf(context).languageCode,
|
||||
).format(currentPlan.startDate)} to ${DateFormat.yMd(
|
||||
Localizations.localeOf(context).languageCode,
|
||||
).format(currentPlan.endDate!)}'
|
||||
: 'from ${DateFormat.yMd(
|
||||
Localizations.localeOf(context).languageCode,
|
||||
).format(currentPlan.startDate)} (open ended)',
|
||||
),
|
||||
_buildWeightChangeInfo(context, currentPlan.startDate, currentPlan.endDate),
|
||||
],
|
||||
),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const VerticalDivider(),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.delete),
|
||||
tooltip: AppLocalizations.of(context).delete,
|
||||
onPressed: () async {
|
||||
// Delete the plan from DB
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext contextDialog) {
|
||||
return AlertDialog(
|
||||
content: Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).confirmDelete(currentPlan.description),
|
||||
final nutritionProvider = Provider.of<NutritionPlansProvider>(context);
|
||||
|
||||
return _plans.isEmpty
|
||||
? const TextPrompt()
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
itemCount: _plans.length,
|
||||
itemBuilder: (context, index) {
|
||||
final currentPlan = _plans[index];
|
||||
return Card(
|
||||
child: ListTile(
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(
|
||||
NutritionalPlanScreen.routeName,
|
||||
arguments: currentPlan,
|
||||
);
|
||||
},
|
||||
title: Text(currentPlan.getLabel(context)),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
currentPlan.endDate != null
|
||||
? 'from ${DateFormat.yMd(
|
||||
Localizations.localeOf(context).languageCode,
|
||||
).format(currentPlan.startDate)} to ${DateFormat.yMd(
|
||||
Localizations.localeOf(context).languageCode,
|
||||
).format(currentPlan.endDate!)}'
|
||||
: 'from ${DateFormat.yMd(
|
||||
Localizations.localeOf(context).languageCode,
|
||||
).format(currentPlan.startDate)} (open ended)',
|
||||
),
|
||||
_buildWeightChangeInfo(context, currentPlan.startDate, currentPlan.endDate),
|
||||
],
|
||||
),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const VerticalDivider(),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.delete),
|
||||
tooltip: AppLocalizations.of(context).delete,
|
||||
onPressed: () async {
|
||||
// Delete the plan from DB
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext contextDialog) {
|
||||
return AlertDialog(
|
||||
content: Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).confirmDelete(currentPlan.description),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
MaterialLocalizations.of(context).cancelButtonLabel,
|
||||
),
|
||||
onPressed: () => Navigator.of(contextDialog).pop(),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
MaterialLocalizations.of(context).cancelButtonLabel,
|
||||
TextButton(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).delete,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
onPressed: () => Navigator.of(contextDialog).pop(),
|
||||
),
|
||||
TextButton(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).delete,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
// Confirmed, delete the plan
|
||||
_nutritionProvider.deletePlan(currentPlan.id!);
|
||||
onPressed: () {
|
||||
// Confirmed, delete the plan
|
||||
nutritionProvider.deletePlan(currentPlan.id!);
|
||||
|
||||
// Close the popup
|
||||
Navigator.of(contextDialog).pop();
|
||||
// Close the popup
|
||||
Navigator.of(contextDialog).pop();
|
||||
|
||||
// and inform the user
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
AppLocalizations.of(context).successfullyDeleted,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
// and inform the user
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
AppLocalizations.of(context).successfullyDeleted,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -79,14 +79,14 @@ class NavigationHeader extends StatelessWidget {
|
||||
final PageController _controller;
|
||||
final String _title;
|
||||
final Map<Exercise, int> exercisePages;
|
||||
final int ?totalPages;
|
||||
final int? totalPages;
|
||||
|
||||
const NavigationHeader(
|
||||
this._title,
|
||||
this._controller, {
|
||||
this.totalPages,
|
||||
required this.exercisePages
|
||||
});
|
||||
this.totalPages,
|
||||
required this.exercisePages,
|
||||
});
|
||||
|
||||
Widget getDialog(BuildContext context) {
|
||||
final TextButton? endWorkoutButton = totalPages != null
|
||||
|
||||
Reference in New Issue
Block a user