Merge NDM-App-197: Pet Stats Screen + Zen Mode + Profile scaffolding
This commit is contained in:
@@ -1,35 +1,66 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../features/tasks/screens/tasks_screen.dart';
|
||||
import 'routes.dart';
|
||||
import '../../features/tasks/screens/pet_screen.dart';
|
||||
import '../../features/zen_mode/screens/zen_screen.dart';
|
||||
import '../../shared/widgets/profile_screen.dart';
|
||||
import '../../shared/widgets/app_shell.dart';
|
||||
|
||||
/// GoRouter configuration provider.
|
||||
final routerProvider = Provider<GoRouter>((ref) {
|
||||
/// Route name constants.
|
||||
abstract final class Routes {
|
||||
static const String tasks = '/tasks';
|
||||
static const String pet = '/pet';
|
||||
static const String zen = '/zen';
|
||||
static const String profile = '/profile';
|
||||
}
|
||||
|
||||
final appRouterProvider = Provider<GoRouter>((ref) {
|
||||
return GoRouter(
|
||||
initialLocation: Routes.home,
|
||||
initialLocation: Routes.tasks,
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: Routes.home,
|
||||
builder: (context, state) => const TasksScreen(),
|
||||
StatefulShellRoute.indexedStack(
|
||||
builder: (context, state, navigationShell) {
|
||||
return AppShell(navigationShell: navigationShell);
|
||||
},
|
||||
branches: [
|
||||
StatefulShellBranch(
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: Routes.tasks,
|
||||
pageBuilder: (context, state) => const NoTransitionPage(
|
||||
child: TasksScreen(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
StatefulShellBranch(
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: Routes.pet,
|
||||
pageBuilder: (context, state) => const NoTransitionPage(
|
||||
child: PetScreen(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
StatefulShellBranch(
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: Routes.profile,
|
||||
pageBuilder: (context, state) => const NoTransitionPage(
|
||||
child: ProfileScreen(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
// Zen mode — outside shell, no bottom nav
|
||||
GoRoute(
|
||||
path: Routes.addTask,
|
||||
builder: (context, state) => const _AddTaskPlaceholder(),
|
||||
path: Routes.zen,
|
||||
builder: (context, state) => const ZenScreen(),
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
class _AddTaskPlaceholder extends StatelessWidget {
|
||||
const _AddTaskPlaceholder();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Novy ukol')),
|
||||
body: const Center(child: Text('Formulář pro nový úkol')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,28 @@
|
||||
/// Available pet companions.
|
||||
/// Pet types available in KittieMobile.
|
||||
enum PetType {
|
||||
dog,
|
||||
cat,
|
||||
capybara;
|
||||
|
||||
/// Parse from database string value.
|
||||
static PetType fromString(String value) =>
|
||||
PetType.values.firstWhere((e) => e.name == value);
|
||||
/// Parses a string to [PetType], defaults to [cat].
|
||||
static PetType fromString(String value) {
|
||||
return PetType.values.firstWhere(
|
||||
(type) => type.name == value,
|
||||
orElse: () => PetType.cat,
|
||||
);
|
||||
}
|
||||
|
||||
/// Display emoji for each pet type.
|
||||
String get emoji => switch (this) {
|
||||
PetType.dog => '\u{1F436}',
|
||||
PetType.cat => '\u{1F431}',
|
||||
PetType.capybara => '\u{1F9AB}',
|
||||
};
|
||||
|
||||
/// Czech label for each pet type.
|
||||
String get label => switch (this) {
|
||||
PetType.dog => 'Pejsek',
|
||||
PetType.cat => 'Kocicka',
|
||||
PetType.capybara => 'Kapybara',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,25 +1,18 @@
|
||||
import 'task_status.dart';
|
||||
|
||||
// Sentinel distinguishes "not provided" from "explicitly null" in copyWith.
|
||||
const _unset = Object();
|
||||
|
||||
/// Pure domain entity for a task.
|
||||
class TaskEntity {
|
||||
final String id;
|
||||
final String userId;
|
||||
final int id;
|
||||
final int userId;
|
||||
final String title;
|
||||
final String? description;
|
||||
final int energyLevel;
|
||||
final TaskStatus status;
|
||||
final bool isSelfCare;
|
||||
final DateTime? deadline;
|
||||
final String? photoPath;
|
||||
final DateTime? snoozeUntil;
|
||||
final int sortOrder;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
final DateTime? syncedAt;
|
||||
final String? localId;
|
||||
|
||||
const TaskEntity({
|
||||
required this.id,
|
||||
@@ -30,53 +23,36 @@ class TaskEntity {
|
||||
this.status = TaskStatus.pending,
|
||||
this.isSelfCare = false,
|
||||
this.deadline,
|
||||
this.photoPath,
|
||||
this.snoozeUntil,
|
||||
this.sortOrder = 0,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
this.syncedAt,
|
||||
this.localId,
|
||||
});
|
||||
|
||||
TaskEntity copyWith({
|
||||
String? id,
|
||||
String? userId,
|
||||
int? id,
|
||||
int? userId,
|
||||
String? title,
|
||||
Object? description = _unset,
|
||||
String? description,
|
||||
int? energyLevel,
|
||||
TaskStatus? status,
|
||||
bool? isSelfCare,
|
||||
Object? deadline = _unset,
|
||||
Object? photoPath = _unset,
|
||||
Object? snoozeUntil = _unset,
|
||||
DateTime? deadline,
|
||||
int? sortOrder,
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt,
|
||||
Object? syncedAt = _unset,
|
||||
Object? localId = _unset,
|
||||
}) {
|
||||
return TaskEntity(
|
||||
id: id ?? this.id,
|
||||
userId: userId ?? this.userId,
|
||||
title: title ?? this.title,
|
||||
description:
|
||||
identical(description, _unset) ? this.description : description as String?,
|
||||
description: description ?? this.description,
|
||||
energyLevel: energyLevel ?? this.energyLevel,
|
||||
status: status ?? this.status,
|
||||
isSelfCare: isSelfCare ?? this.isSelfCare,
|
||||
deadline: identical(deadline, _unset) ? this.deadline : deadline as DateTime?,
|
||||
photoPath:
|
||||
identical(photoPath, _unset) ? this.photoPath : photoPath as String?,
|
||||
snoozeUntil: identical(snoozeUntil, _unset)
|
||||
? this.snoozeUntil
|
||||
: snoozeUntil as DateTime?,
|
||||
deadline: deadline ?? this.deadline,
|
||||
sortOrder: sortOrder ?? this.sortOrder,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
updatedAt: updatedAt ?? this.updatedAt,
|
||||
syncedAt:
|
||||
identical(syncedAt, _unset) ? this.syncedAt : syncedAt as DateTime?,
|
||||
localId: identical(localId, _unset) ? this.localId : localId as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +1,30 @@
|
||||
import 'pet_type.dart';
|
||||
|
||||
/// Pure domain entity for a user profile.
|
||||
/// Pure domain entity for a user.
|
||||
class UserEntity {
|
||||
final String id;
|
||||
final String deviceId;
|
||||
final int id;
|
||||
final String name;
|
||||
final PetType petType;
|
||||
final String petName;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
|
||||
const UserEntity({
|
||||
required this.id,
|
||||
required this.deviceId,
|
||||
required this.name,
|
||||
required this.petType,
|
||||
required this.petName,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
this.name = 'Friend',
|
||||
this.petType = PetType.cat,
|
||||
this.petName = 'Yoshi',
|
||||
});
|
||||
|
||||
UserEntity copyWith({
|
||||
String? id,
|
||||
String? deviceId,
|
||||
int? id,
|
||||
String? name,
|
||||
PetType? petType,
|
||||
String? petName,
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt,
|
||||
}) {
|
||||
return UserEntity(
|
||||
id: id ?? this.id,
|
||||
deviceId: deviceId ?? this.deviceId,
|
||||
name: name ?? this.name,
|
||||
petType: petType ?? this.petType,
|
||||
petName: petName ?? this.petName,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
updatedAt: updatedAt ?? this.updatedAt,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,75 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../../domain/entities/pet_state.dart';
|
||||
import '../../../domain/entities/pet_state_entity.dart';
|
||||
import '../../../domain/entities/pet_type.dart';
|
||||
import '../../../domain/entities/user_entity.dart';
|
||||
|
||||
/// Provider for pet companion state.
|
||||
final petStateProvider =
|
||||
NotifierProvider<PetStateNotifier, PetState>(PetStateNotifier.new);
|
||||
/// Pet mood states.
|
||||
enum PetMood {
|
||||
happy,
|
||||
neutral,
|
||||
sad;
|
||||
|
||||
class PetStateNotifier extends Notifier<PetState> {
|
||||
String get emoji => switch (this) {
|
||||
PetMood.happy => '\u{1F60A}',
|
||||
PetMood.neutral => '\u{1F610}',
|
||||
PetMood.sad => '\u{1F622}',
|
||||
};
|
||||
}
|
||||
|
||||
// ── User ──
|
||||
|
||||
class UserNotifier extends Notifier<UserEntity> {
|
||||
@override
|
||||
PetState build() => const PetState();
|
||||
UserEntity build() => const UserEntity(
|
||||
id: 1,
|
||||
name: 'Friend',
|
||||
petType: PetType.cat,
|
||||
petName: 'Yoshi',
|
||||
);
|
||||
|
||||
void onTaskCompleted() {
|
||||
state = state.copyWith(
|
||||
totalTasksDone: state.totalTasksDone + 1,
|
||||
mood: 'happy',
|
||||
);
|
||||
}
|
||||
void updateName(String name) => state = state.copyWith(name: name);
|
||||
void updatePetName(String petName) =>
|
||||
state = state.copyWith(petName: petName);
|
||||
}
|
||||
|
||||
void setEnergy(int energy) {
|
||||
state = state.copyWith(energyToday: energy);
|
||||
}
|
||||
final userProvider =
|
||||
NotifierProvider<UserNotifier, UserEntity>(UserNotifier.new);
|
||||
|
||||
void incrementStreak() {
|
||||
state = state.copyWith(streakDays: state.streakDays + 1);
|
||||
// ── Pet state ──
|
||||
|
||||
class PetStateNotifier extends Notifier<PetStateEntity> {
|
||||
@override
|
||||
PetStateEntity build() => const PetStateEntity(
|
||||
id: 1,
|
||||
userId: 1,
|
||||
energyToday: 2,
|
||||
streakDays: 3,
|
||||
totalTasksDone: 12,
|
||||
unlockedItems: 'masle,pelisek',
|
||||
);
|
||||
|
||||
void incrementTasksDone() {
|
||||
state = state.copyWith(totalTasksDone: state.totalTasksDone + 1);
|
||||
}
|
||||
}
|
||||
|
||||
final petStateProvider =
|
||||
NotifierProvider<PetStateNotifier, PetStateEntity>(PetStateNotifier.new);
|
||||
|
||||
// ── Derived providers ──
|
||||
|
||||
/// Pet mood derived from pet state.
|
||||
final petMoodProvider = Provider<PetMood>((ref) {
|
||||
final pet = ref.watch(petStateProvider);
|
||||
if (pet.streakDays >= 3 || pet.totalTasksDone >= 5) return PetMood.happy;
|
||||
if (pet.totalTasksDone == 0) return PetMood.sad;
|
||||
return PetMood.neutral;
|
||||
});
|
||||
|
||||
/// Pet level = totalTasksDone / 15 + 1, max 10.
|
||||
final petLevelProvider = Provider<int>((ref) {
|
||||
final pet = ref.watch(petStateProvider);
|
||||
final level = pet.totalTasksDone ~/ 15 + 1;
|
||||
return level.clamp(1, 10);
|
||||
});
|
||||
|
||||
@@ -1,73 +1,116 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../../domain/entities/task.dart';
|
||||
import '../../../domain/entities/task_entity.dart';
|
||||
import '../../../domain/entities/task_status.dart';
|
||||
|
||||
/// Provider for today's task list.
|
||||
final todayTasksProvider =
|
||||
NotifierProvider<TodayTasksNotifier, List<Task>>(TodayTasksNotifier.new);
|
||||
|
||||
class TodayTasksNotifier extends Notifier<List<Task>> {
|
||||
/// Notifier managing the task list.
|
||||
class TasksNotifier extends Notifier<List<TaskEntity>> {
|
||||
@override
|
||||
List<Task> build() => _seedTasks();
|
||||
List<TaskEntity> build() => _sampleTasks;
|
||||
|
||||
void addTask(Task task) {
|
||||
state = [...state, task];
|
||||
}
|
||||
|
||||
void completeTask(String id) {
|
||||
void completeTask(int id) {
|
||||
state = [
|
||||
for (final task in state)
|
||||
if (task.id == id)
|
||||
task.copyWith(status: TaskStatus.done, updatedAt: DateTime.now())
|
||||
task.copyWith(
|
||||
status: TaskStatus.done,
|
||||
updatedAt: DateTime.now(),
|
||||
)
|
||||
else
|
||||
task,
|
||||
];
|
||||
}
|
||||
|
||||
void uncompleteTask(String id) {
|
||||
void skipTask(int id) {
|
||||
final skipped = state.firstWhere((t) => t.id == id);
|
||||
state = [
|
||||
for (final task in state)
|
||||
if (task.id == id)
|
||||
task.copyWith(status: TaskStatus.pending, updatedAt: DateTime.now())
|
||||
else
|
||||
task,
|
||||
];
|
||||
}
|
||||
|
||||
/// Seed tasks for demo/development.
|
||||
static List<Task> _seedTasks() {
|
||||
final now = DateTime.now();
|
||||
return [
|
||||
Task(
|
||||
id: '1',
|
||||
title: 'Odpovedet na emaily',
|
||||
energyLevel: 1,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
),
|
||||
Task(
|
||||
id: '2',
|
||||
title: 'Pripravit prezentaci',
|
||||
description: 'Pro pondelni meeting',
|
||||
energyLevel: 3,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
),
|
||||
Task(
|
||||
id: '3',
|
||||
title: 'Uklid pokoje',
|
||||
energyLevel: 2,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
),
|
||||
Task(
|
||||
id: '4',
|
||||
title: 'Nakoupit veceri',
|
||||
energyLevel: 1,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
),
|
||||
...state.where((t) => t.id != id),
|
||||
skipped.copyWith(sortOrder: skipped.sortOrder + 100),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/// All tasks.
|
||||
final tasksProvider =
|
||||
NotifierProvider<TasksNotifier, List<TaskEntity>>(TasksNotifier.new);
|
||||
|
||||
/// Pending tasks only, ordered by sort order.
|
||||
final pendingTasksProvider = Provider<List<TaskEntity>>((ref) {
|
||||
final tasks = ref.watch(tasksProvider);
|
||||
return tasks
|
||||
.where((t) => t.status == TaskStatus.pending)
|
||||
.toList()
|
||||
..sort((a, b) => a.sortOrder.compareTo(b.sortOrder));
|
||||
});
|
||||
|
||||
/// Next zen task: first pending task sorted by energy level (lowest first).
|
||||
final nextZenTaskProvider = Provider<TaskEntity?>((ref) {
|
||||
final pending = ref.watch(pendingTasksProvider);
|
||||
if (pending.isEmpty) return null;
|
||||
final sorted = [...pending]
|
||||
..sort((a, b) => a.energyLevel.compareTo(b.energyLevel));
|
||||
return sorted.first;
|
||||
});
|
||||
|
||||
/// Count of completed self-care tasks.
|
||||
final selfCareCountProvider = Provider<int>((ref) {
|
||||
final tasks = ref.watch(tasksProvider);
|
||||
return tasks
|
||||
.where((t) => t.isSelfCare && t.status == TaskStatus.done)
|
||||
.length;
|
||||
});
|
||||
|
||||
// — Sample data for development —
|
||||
|
||||
final _now = DateTime.now();
|
||||
|
||||
final _sampleTasks = <TaskEntity>[
|
||||
TaskEntity(
|
||||
id: 1,
|
||||
userId: 1,
|
||||
title: 'Nakoupit potraviny',
|
||||
energyLevel: 1,
|
||||
sortOrder: 0,
|
||||
createdAt: _now,
|
||||
updatedAt: _now,
|
||||
),
|
||||
TaskEntity(
|
||||
id: 2,
|
||||
userId: 1,
|
||||
title: 'Udelat prezentaci',
|
||||
energyLevel: 3,
|
||||
sortOrder: 1,
|
||||
createdAt: _now,
|
||||
updatedAt: _now,
|
||||
),
|
||||
TaskEntity(
|
||||
id: 3,
|
||||
userId: 1,
|
||||
title: 'Protahnout se',
|
||||
energyLevel: 1,
|
||||
isSelfCare: true,
|
||||
sortOrder: 2,
|
||||
createdAt: _now,
|
||||
updatedAt: _now,
|
||||
),
|
||||
TaskEntity(
|
||||
id: 4,
|
||||
userId: 1,
|
||||
title: 'Napsat email klientovi',
|
||||
energyLevel: 2,
|
||||
sortOrder: 3,
|
||||
createdAt: _now,
|
||||
updatedAt: _now,
|
||||
),
|
||||
TaskEntity(
|
||||
id: 5,
|
||||
userId: 1,
|
||||
title: 'Meditace',
|
||||
energyLevel: 1,
|
||||
isSelfCare: true,
|
||||
status: TaskStatus.done,
|
||||
sortOrder: 4,
|
||||
createdAt: _now,
|
||||
updatedAt: _now,
|
||||
),
|
||||
];
|
||||
|
||||
@@ -0,0 +1,274 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../../core/theme/kittie_colors.dart';
|
||||
import '../../../core/theme/kittie_typography.dart';
|
||||
import '../providers/pet_providers.dart';
|
||||
import '../providers/task_providers.dart';
|
||||
|
||||
/// Pet companion screen — stats, avatar, unlocked items.
|
||||
class PetScreen extends ConsumerWidget {
|
||||
const PetScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final user = ref.watch(userProvider);
|
||||
final petState = ref.watch(petStateProvider);
|
||||
final mood = ref.watch(petMoodProvider);
|
||||
final level = ref.watch(petLevelProvider);
|
||||
final selfCareCount = ref.watch(selfCareCountProvider);
|
||||
final unlocked = petState.unlockedItems.isEmpty
|
||||
? <String>[]
|
||||
: petState.unlockedItems.split(',');
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: KittieColors.cream,
|
||||
body: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
|
||||
child: Column(
|
||||
children: [
|
||||
// Pet name header
|
||||
Text(
|
||||
user.petName,
|
||||
style: KittieTypography.h1.copyWith(fontSize: 24),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'Tvuj spolecnik — ${user.petType.label}',
|
||||
style: KittieTypography.bodyMedium.copyWith(
|
||||
color: KittieColors.brownLight,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Large circular avatar with mood badge
|
||||
Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Container(
|
||||
width: 130,
|
||||
height: 130,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: KittieColors.creamDark,
|
||||
border: Border.all(
|
||||
color: KittieColors.creamBorder,
|
||||
width: 3,
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
user.petType.emoji,
|
||||
style: const TextStyle(fontSize: 64),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
child: Container(
|
||||
width: 36,
|
||||
height: 36,
|
||||
decoration: BoxDecoration(
|
||||
color: _moodColor(mood),
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: KittieColors.cream,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
mood.emoji,
|
||||
style: const TextStyle(fontSize: 18),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
|
||||
// Stats grid 2×2
|
||||
GridView.count(
|
||||
crossAxisCount: 2,
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
mainAxisSpacing: 12,
|
||||
crossAxisSpacing: 12,
|
||||
childAspectRatio: 1.4,
|
||||
children: [
|
||||
_StatTile(
|
||||
icon: Icons.local_fire_department_rounded,
|
||||
label: 'Streak',
|
||||
value: '${petState.streakDays} dni',
|
||||
color: KittieColors.orange,
|
||||
),
|
||||
_StatTile(
|
||||
icon: Icons.check_circle_rounded,
|
||||
label: 'Hotove ukoly',
|
||||
value: '${petState.totalTasksDone}',
|
||||
color: KittieColors.sageGreen,
|
||||
),
|
||||
_StatTile(
|
||||
icon: Icons.favorite_rounded,
|
||||
label: 'Pece o sebe',
|
||||
value: '$selfCareCount',
|
||||
color: KittieColors.purple,
|
||||
),
|
||||
_StatTile(
|
||||
icon: Icons.star_rounded,
|
||||
label: 'Uroven',
|
||||
value: '$level',
|
||||
color: KittieColors.amber,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
|
||||
// Unlocked items header
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text('Odemcene predmety',
|
||||
style: KittieTypography.h3),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Horizontal scroll of items
|
||||
SizedBox(
|
||||
height: 100,
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
children: [
|
||||
_ItemCard(
|
||||
name: 'Masle',
|
||||
icon: Icons.catching_pokemon_rounded,
|
||||
unlocked: unlocked.contains('masle'),
|
||||
),
|
||||
_ItemCard(
|
||||
name: 'Pelisek',
|
||||
icon: Icons.bed_rounded,
|
||||
unlocked: unlocked.contains('pelisek'),
|
||||
),
|
||||
_ItemCard(
|
||||
name: 'Koruna',
|
||||
icon: Icons.auto_awesome_rounded,
|
||||
unlocked: unlocked.contains('koruna'),
|
||||
),
|
||||
_ItemCard(
|
||||
name: 'Kridla',
|
||||
icon: Icons.flight_rounded,
|
||||
unlocked: unlocked.contains('kridla'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Color _moodColor(PetMood mood) => switch (mood) {
|
||||
PetMood.happy => KittieColors.sageGreen,
|
||||
PetMood.neutral => KittieColors.amber,
|
||||
PetMood.sad => KittieColors.red,
|
||||
};
|
||||
}
|
||||
|
||||
// ── Private widgets ──
|
||||
|
||||
class _StatTile extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final String value;
|
||||
final Color color;
|
||||
|
||||
const _StatTile({
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.value,
|
||||
required this.color,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(icon, color: color, size: 24),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
value,
|
||||
style: KittieTypography.h2.copyWith(color: color),
|
||||
),
|
||||
Text(
|
||||
label,
|
||||
style: KittieTypography.bodySmall.copyWith(color: color),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ItemCard extends StatelessWidget {
|
||||
final String name;
|
||||
final IconData icon;
|
||||
final bool unlocked;
|
||||
|
||||
const _ItemCard({
|
||||
required this.name,
|
||||
required this.icon,
|
||||
required this.unlocked,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Opacity(
|
||||
opacity: unlocked ? 1.0 : 0.35,
|
||||
child: Container(
|
||||
width: 80,
|
||||
margin: const EdgeInsets.only(right: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: KittieColors.creamDark,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: KittieColors.creamBorder),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
size: 32,
|
||||
color: unlocked ? KittieColors.amber : KittieColors.brownLight,
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
name,
|
||||
style: KittieTypography.labelSmall,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
if (!unlocked)
|
||||
Icon(
|
||||
Icons.lock_rounded,
|
||||
size: 12,
|
||||
color: KittieColors.brownLight,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
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(tasksProvider.notifier).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(tasksProvider.notifier).skipTask(task.id);
|
||||
},
|
||||
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('Preskocit',
|
||||
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(
|
||||
'Vse hotovo.\nOdpocivej.',
|
||||
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),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -13,7 +13,7 @@ class KittieApp extends ConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final router = ref.watch(routerProvider);
|
||||
final router = ref.watch(appRouterProvider);
|
||||
|
||||
return MaterialApp.router(
|
||||
title: 'KittieMobile',
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../core/theme/kittie_colors.dart';
|
||||
import '../../core/theme/kittie_typography.dart';
|
||||
import '../../core/constants/app_constants.dart';
|
||||
|
||||
/// Bottom navigation shell wrapping the main tabs.
|
||||
class AppShell extends StatelessWidget {
|
||||
final StatefulNavigationShell navigationShell;
|
||||
|
||||
const AppShell({super.key, required this.navigationShell});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: navigationShell,
|
||||
bottomNavigationBar: Container(
|
||||
height: AppConstants.bottomNavHeight,
|
||||
decoration: const BoxDecoration(
|
||||
color: KittieColors.cream,
|
||||
border: Border(
|
||||
top: BorderSide(color: KittieColors.creamBorder, width: 0.5),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_NavItem(
|
||||
icon: Icons.grid_view_rounded,
|
||||
label: 'ukoly',
|
||||
isActive: navigationShell.currentIndex == 0,
|
||||
onTap: () => navigationShell.goBranch(0),
|
||||
),
|
||||
_NavItem(
|
||||
icon: Icons.pets_rounded,
|
||||
label: 'mazlicek',
|
||||
isActive: navigationShell.currentIndex == 1,
|
||||
onTap: () => navigationShell.goBranch(1),
|
||||
),
|
||||
_NavItem(
|
||||
icon: Icons.person_rounded,
|
||||
label: 'profil',
|
||||
isActive: navigationShell.currentIndex == 2,
|
||||
onTap: () => navigationShell.goBranch(2),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _NavItem extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final bool isActive;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const _NavItem({
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.isActive,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final color = isActive ? KittieColors.brown : KittieColors.brownLight;
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: SizedBox(
|
||||
width: 64,
|
||||
height: AppConstants.bottomNavHeight,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(icon, color: color, size: 24),
|
||||
const SizedBox(height: 2),
|
||||
Text(label, style: KittieTypography.labelSmall.copyWith(color: color)),
|
||||
const SizedBox(height: 4),
|
||||
if (isActive)
|
||||
Container(
|
||||
width: 4,
|
||||
height: 4,
|
||||
decoration: const BoxDecoration(
|
||||
color: KittieColors.amber,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../core/theme/kittie_colors.dart';
|
||||
import '../../core/theme/kittie_typography.dart';
|
||||
import '../../features/tasks/providers/pet_providers.dart';
|
||||
|
||||
/// User profile screen — name, pet info, stats, export.
|
||||
class ProfileScreen extends ConsumerWidget {
|
||||
const ProfileScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final user = ref.watch(userProvider);
|
||||
final petState = ref.watch(petStateProvider);
|
||||
final level = ref.watch(petLevelProvider);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: KittieColors.cream,
|
||||
body: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('Profil', style: KittieTypography.h2),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// User name
|
||||
_EditableRow(
|
||||
label: 'Jmeno',
|
||||
value: user.name,
|
||||
onEdit: () => _showEditDialog(
|
||||
context,
|
||||
title: 'Upravit jmeno',
|
||||
initialValue: user.name,
|
||||
onSave: (v) => ref.read(userProvider.notifier).updateName(v),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Pet name
|
||||
_EditableRow(
|
||||
label: 'Jmeno mazlicka',
|
||||
value: user.petName,
|
||||
onEdit: () => _showEditDialog(
|
||||
context,
|
||||
title: 'Upravit jmeno mazlicka',
|
||||
initialValue: user.petName,
|
||||
onSave: (v) =>
|
||||
ref.read(userProvider.notifier).updatePetName(v),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Pet type
|
||||
_InfoRow(label: 'Typ mazlicka', value: user.petType.label),
|
||||
const SizedBox(height: 32),
|
||||
|
||||
// Stats summary
|
||||
Text('Statistiky', style: KittieTypography.h3),
|
||||
const SizedBox(height: 12),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: KittieColors.creamDark,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: KittieColors.creamBorder),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
_StatRow(
|
||||
icon: Icons.local_fire_department_rounded,
|
||||
label: 'Streak',
|
||||
value: '${petState.streakDays} dni',
|
||||
color: KittieColors.orange,
|
||||
),
|
||||
const Divider(color: KittieColors.creamBorder, height: 24),
|
||||
_StatRow(
|
||||
icon: Icons.check_circle_rounded,
|
||||
label: 'Hotove ukoly',
|
||||
value: '${petState.totalTasksDone}',
|
||||
color: KittieColors.sageGreen,
|
||||
),
|
||||
const Divider(color: KittieColors.creamBorder, height: 24),
|
||||
_StatRow(
|
||||
icon: Icons.star_rounded,
|
||||
label: 'Uroven mazlicka',
|
||||
value: '$level',
|
||||
color: KittieColors.amber,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
|
||||
// Export button
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Pripravujeme')),
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.download_rounded),
|
||||
label: Text('Exportovat data',
|
||||
style: KittieTypography.labelLarge),
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: KittieColors.brown,
|
||||
side: const BorderSide(color: KittieColors.creamBorder),
|
||||
minimumSize: const Size(0, 48),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 48),
|
||||
|
||||
// Version
|
||||
Center(
|
||||
child: Text(
|
||||
'KittieMobile v1.0.0',
|
||||
style: KittieTypography.bodySmall.copyWith(
|
||||
color: KittieColors.brownLight,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showEditDialog(
|
||||
BuildContext context, {
|
||||
required String title,
|
||||
required String initialValue,
|
||||
required ValueChanged<String> onSave,
|
||||
}) {
|
||||
final controller = TextEditingController(text: initialValue);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
backgroundColor: KittieColors.cream,
|
||||
title: Text(title, style: KittieTypography.h3),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
autofocus: true,
|
||||
style: KittieTypography.bodyLarge,
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx),
|
||||
child: const Text('Zrusit'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
final text = controller.text.trim();
|
||||
if (text.isNotEmpty) onSave(text);
|
||||
Navigator.pop(ctx);
|
||||
},
|
||||
child: const Text('Ulozit'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Private helper widgets ──
|
||||
|
||||
class _EditableRow extends StatelessWidget {
|
||||
final String label;
|
||||
final String value;
|
||||
final VoidCallback onEdit;
|
||||
|
||||
const _EditableRow({
|
||||
required this.label,
|
||||
required this.value,
|
||||
required this.onEdit,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(label,
|
||||
style: KittieTypography.labelMedium
|
||||
.copyWith(color: KittieColors.brownLight)),
|
||||
const SizedBox(height: 4),
|
||||
Text(value, style: KittieTypography.bodyLarge),
|
||||
],
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.edit_rounded, size: 20),
|
||||
color: KittieColors.brownLight,
|
||||
onPressed: onEdit,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _InfoRow extends StatelessWidget {
|
||||
final String label;
|
||||
final String value;
|
||||
|
||||
const _InfoRow({required this.label, required this.value});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(label,
|
||||
style: KittieTypography.labelMedium
|
||||
.copyWith(color: KittieColors.brownLight)),
|
||||
const SizedBox(height: 4),
|
||||
Text(value, style: KittieTypography.bodyLarge),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _StatRow extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final String value;
|
||||
final Color color;
|
||||
|
||||
const _StatRow({
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.value,
|
||||
required this.color,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Icon(icon, color: color, size: 20),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: Text(label, style: KittieTypography.bodyMedium)),
|
||||
Text(value,
|
||||
style: KittieTypography.labelLarge.copyWith(color: color)),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:kittie_mobile/main.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('KittieApp renders', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const ProviderScope(child: KittieApp()));
|
||||
testWidgets('KittieApp smoke test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const ProviderScope(child: KittieApp()),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('DNESNI UKOLY'), findsOneWidget);
|
||||
|
||||
// App renders without crashing
|
||||
expect(find.byType(MaterialApp), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user