mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
This puts this code in sync with the backend and is logically better, since the translations can be displayed when needed and are not hard coded
107 lines
4.4 KiB
Dart
107 lines
4.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:wger/providers/add_exercise_provider.dart';
|
|
import 'package:wger/providers/exercises.dart';
|
|
|
|
class DuplicatesAndVariationsStepContent extends StatelessWidget {
|
|
final GlobalKey<FormState> formkey;
|
|
|
|
const DuplicatesAndVariationsStepContent({required this.formkey});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final addExerciseProvider = context.read<AddExerciseProvider>();
|
|
final exerciseProvider = context.read<ExercisesProvider>();
|
|
|
|
return Form(
|
|
key: formkey,
|
|
child: Column(
|
|
children: [
|
|
Text(
|
|
AppLocalizations.of(context).whatVariationsExist,
|
|
style: Theme.of(context).textTheme.caption,
|
|
),
|
|
const SizedBox(height: 10),
|
|
SizedBox(
|
|
height: 400,
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
// Exercise bases with variations
|
|
...exerciseProvider.exerciseBasesByVariation.keys
|
|
.map(
|
|
(key) => Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Flexible(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
//mainAxisSize: MainAxisSize.max,
|
|
children: [
|
|
...exerciseProvider.exerciseBasesByVariation[key]!
|
|
.map(
|
|
(base) => Text(
|
|
base
|
|
.getExercise(
|
|
Localizations.localeOf(context).languageCode)
|
|
.name,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
)
|
|
.toList(),
|
|
const SizedBox(height: 20),
|
|
],
|
|
),
|
|
),
|
|
Consumer<AddExerciseProvider>(
|
|
builder: (ctx, provider, __) => Switch(
|
|
value: provider.variationId == key,
|
|
onChanged: (state) => provider.variationId = key),
|
|
),
|
|
],
|
|
),
|
|
)
|
|
.toList(),
|
|
// Exercise bases without variations
|
|
...exerciseProvider.bases
|
|
.where((b) => b.variationId == null)
|
|
.map(
|
|
(base) => Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Flexible(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.max,
|
|
children: [
|
|
Text(
|
|
base
|
|
.getExercise(Localizations.localeOf(context).languageCode)
|
|
.name,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
const SizedBox(height: 20),
|
|
],
|
|
),
|
|
),
|
|
Consumer<AddExerciseProvider>(
|
|
builder: (ctx, provider, __) => Switch(
|
|
value: provider.newVariationForExercise == base.id,
|
|
onChanged: (state) => provider.newVariationForExercise = base.id,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)
|
|
.toList(),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|