141 lines
4.8 KiB
Dart
141 lines
4.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
import '../../../core/theme/kittie_colors.dart';
|
|
import '../../../core/theme/kittie_typography.dart';
|
|
import '../../../shared/widgets/energy_badge.dart';
|
|
import '../../../domain/entities/task_entity.dart';
|
|
import '../../tasks/providers/task_providers.dart';
|
|
import '../../tasks/providers/pet_providers.dart';
|
|
|
|
/// Distraction-free single-task view.
|
|
///
|
|
/// Shows next pending task (lowest energy first).
|
|
/// No bottom nav — full screen with back button.
|
|
class ZenScreen extends ConsumerWidget {
|
|
const ZenScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final task = ref.watch(nextZenTaskProvider);
|
|
|
|
return Scaffold(
|
|
backgroundColor: KittieColors.creamDark,
|
|
body: SafeArea(
|
|
child: Column(
|
|
children: [
|
|
// Back button
|
|
Align(
|
|
alignment: Alignment.centerLeft,
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(left: 8, top: 8),
|
|
child: IconButton(
|
|
icon: const Icon(Icons.arrow_back_rounded),
|
|
color: KittieColors.brown,
|
|
onPressed: () => context.pop(),
|
|
),
|
|
),
|
|
),
|
|
|
|
// Main content
|
|
Expanded(
|
|
child: Center(
|
|
child: task == null
|
|
? _buildEmpty()
|
|
: _buildTask(context, ref, task),
|
|
),
|
|
),
|
|
|
|
// Action buttons
|
|
if (task != null)
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(24, 0, 24, 32),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: ElevatedButton(
|
|
onPressed: () {
|
|
ref.read(taskRepositoryProvider).completeTask(task.id);
|
|
ref.read(petStateProvider.notifier).incrementTasksDone();
|
|
},
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: KittieColors.sageGreen,
|
|
foregroundColor: Colors.white,
|
|
minimumSize: const Size(0, 52),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(16),
|
|
),
|
|
),
|
|
child: Text('Hotovo',
|
|
style: KittieTypography.labelLarge
|
|
.copyWith(color: Colors.white)),
|
|
),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: TextButton(
|
|
onPressed: () {
|
|
ref.read(taskRepositoryProvider).updateTask(
|
|
task.copyWith(
|
|
sortOrder: task.sortOrder + 100),
|
|
);
|
|
},
|
|
style: TextButton.styleFrom(
|
|
foregroundColor: KittieColors.brownLight,
|
|
minimumSize: const Size(0, 52),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(16),
|
|
side: const BorderSide(
|
|
color: KittieColors.creamBorder,
|
|
),
|
|
),
|
|
),
|
|
child: Text('Přeskočit',
|
|
style: KittieTypography.labelLarge
|
|
.copyWith(color: KittieColors.brownLight)),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildEmpty() {
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const Text('\u{2728}', style: TextStyle(fontSize: 48)),
|
|
const SizedBox(height: 16),
|
|
Text(
|
|
'Vše hotovo.\nOdpočívej.',
|
|
textAlign: TextAlign.center,
|
|
style: KittieTypography.h2.copyWith(color: KittieColors.brown),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildTask(BuildContext context, WidgetRef ref, TaskEntity task) {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 32),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
task.title,
|
|
textAlign: TextAlign.center,
|
|
style: KittieTypography.h1.copyWith(fontSize: 28),
|
|
),
|
|
const SizedBox(height: 16),
|
|
EnergyBadge(energyLevel: task.energyLevel),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|