Przebudowanie aplikacji, usprawnione AI, dodanie combo buildera
Some checks failed
Build Linux App / build (push) Failing after 1m18s

This commit is contained in:
Kazimierz Ciołek
2026-07-06 23:44:17 +02:00
parent 9dcc4b87de
commit 6dd7213eb0
48 changed files with 3229 additions and 669 deletions

View File

@@ -5,18 +5,28 @@ import 'package:google_fonts/google_fonts.dart';
import 'package:trainhub_flutter/core/constants/ui_constants.dart';
import 'package:trainhub_flutter/core/theme/app_colors.dart';
import 'package:trainhub_flutter/presentation/plan_editor/plan_editor_controller.dart';
import 'package:trainhub_flutter/presentation/plan_editor/widgets/plan_flow_graph.dart';
import 'package:trainhub_flutter/presentation/plan_editor/widgets/plan_section_card.dart';
@RoutePage()
class PlanEditorPage extends ConsumerWidget {
class PlanEditorPage extends ConsumerStatefulWidget {
final String planId;
const PlanEditorPage({super.key, @PathParam('planId') required this.planId});
@override
Widget build(BuildContext context, WidgetRef ref) {
final state = ref.watch(planEditorControllerProvider(planId));
final controller = ref.read(planEditorControllerProvider(planId).notifier);
ConsumerState<PlanEditorPage> createState() => _PlanEditorPageState();
}
class _PlanEditorPageState extends ConsumerState<PlanEditorPage> {
bool _graphView = false;
@override
Widget build(BuildContext context) {
final state = ref.watch(planEditorControllerProvider(widget.planId));
final controller = ref.read(
planEditorControllerProvider(widget.planId).notifier,
);
return Scaffold(
backgroundColor: AppColors.surface,
@@ -104,6 +114,13 @@ class PlanEditorPage extends ConsumerWidget {
),
),
// List / graph view toggle
_ViewToggle(
graphView: _graphView,
onChanged: (v) => setState(() => _graphView = v),
),
const SizedBox(width: UIConstants.spacing16),
// Unsaved changes badge + save button
state.maybeWhen(
data: (data) => data.isDirty
@@ -115,7 +132,9 @@ class PlanEditorPage extends ConsumerWidget {
vertical: 4,
),
decoration: BoxDecoration(
color: AppColors.warning.withValues(alpha: 0.12),
color: AppColors.warning.withValues(
alpha: 0.12,
),
borderRadius: BorderRadius.circular(20),
border: Border.all(
color: AppColors.warning.withValues(
@@ -150,41 +169,50 @@ class PlanEditorPage extends ConsumerWidget {
// --- Body ---
Expanded(
child: state.when(
data: (data) => ReorderableListView.builder(
padding: const EdgeInsets.all(UIConstants.spacing24),
onReorder: controller.reorderSection,
footer: Center(
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: UIConstants.spacing16,
),
child: OutlinedButton.icon(
onPressed: controller.addSection,
icon: const Icon(Icons.add, size: 16),
label: const Text('Add Section'),
style: OutlinedButton.styleFrom(
foregroundColor: AppColors.textSecondary,
side: const BorderSide(color: AppColors.border),
padding: const EdgeInsets.symmetric(
horizontal: UIConstants.spacing24,
vertical: UIConstants.spacing12,
data: (data) => _graphView
? PlanFlowGraph(
// Rebuild the graph when the plan structure changes.
key: ValueKey(
'${data.plan.id}-${data.plan.totalExercises}-'
'${data.plan.sections.length}',
),
plan: data.plan,
)
: ReorderableListView.builder(
padding: const EdgeInsets.all(UIConstants.spacing24),
onReorder: controller.reorderSection,
footer: Center(
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: UIConstants.spacing16,
),
child: OutlinedButton.icon(
onPressed: controller.addSection,
icon: const Icon(Icons.add, size: 16),
label: const Text('Add Section'),
style: OutlinedButton.styleFrom(
foregroundColor: AppColors.textSecondary,
side: const BorderSide(color: AppColors.border),
padding: const EdgeInsets.symmetric(
horizontal: UIConstants.spacing24,
vertical: UIConstants.spacing12,
),
),
),
),
),
itemCount: data.plan.sections.length,
itemBuilder: (context, index) {
final section = data.plan.sections[index];
return PlanSectionCard(
key: ValueKey(section.id),
section: section,
sectionIndex: index,
plan: data.plan,
availableExercises: data.availableExercises,
);
},
),
),
),
itemCount: data.plan.sections.length,
itemBuilder: (context, index) {
final section = data.plan.sections[index];
return PlanSectionCard(
key: ValueKey(section.id),
section: section,
sectionIndex: index,
plan: data.plan,
availableExercises: data.availableExercises,
);
},
),
error: (e, s) => Center(
child: Text(
'Error: $e',
@@ -199,3 +227,77 @@ class PlanEditorPage extends ConsumerWidget {
);
}
}
// ---------------------------------------------------------------------------
// List / graph segmented toggle
// ---------------------------------------------------------------------------
class _ViewToggle extends StatelessWidget {
const _ViewToggle({required this.graphView, required this.onChanged});
final bool graphView;
final ValueChanged<bool> onChanged;
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: AppColors.surfaceContainerHigh,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColors.border),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
_ToggleButton(
icon: Icons.view_list_rounded,
tooltip: 'List view',
selected: !graphView,
onTap: () => onChanged(false),
),
_ToggleButton(
icon: Icons.account_tree_outlined,
tooltip: 'Graph view',
selected: graphView,
onTap: () => onChanged(true),
),
],
),
);
}
}
class _ToggleButton extends StatelessWidget {
const _ToggleButton({
required this.icon,
required this.tooltip,
required this.selected,
required this.onTap,
});
final IconData icon;
final String tooltip;
final bool selected;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
return Tooltip(
message: tooltip,
child: GestureDetector(
onTap: onTap,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7),
decoration: BoxDecoration(
color: selected ? AppColors.accentMuted : Colors.transparent,
borderRadius: BorderRadius.circular(7),
),
child: Icon(
icon,
size: 16,
color: selected ? AppColors.accent : AppColors.textMuted,
),
),
),
);
}
}