| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- import 'package:flutter/material.dart';
- import 'package:flutter_riverpod/flutter_riverpod.dart';
- import 'package:go_router/go_router.dart';
- import '../../../../services/analysis_providers.dart';
- import '../../../shared/presentation/widgets/async_value_view.dart';
- import '../../../shared/presentation/widgets/lab_section_scaffold.dart';
- class HistoryPage extends ConsumerWidget {
- const HistoryPage({super.key});
- @override
- Widget build(BuildContext context, WidgetRef ref) {
- final theme = Theme.of(context);
- final observations = ref.watch(observationListProvider);
- final sessions = ref.watch(sessionListProvider);
- return LabSectionScaffold(
- eyebrow: 'History',
- title: 'Browse prior observations and experiment sessions.',
- description:
- 'This page keeps the mobile lab stateful by showing the observation archive and the experiment session archive side by side.',
- children: [
- AsyncValueView(
- value: observations,
- loadingMessage: 'Loading observations...',
- data: (items) => Card(
- child: Padding(
- padding: const EdgeInsets.all(20),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- 'Observation Archive',
- style: theme.textTheme.titleLarge,
- ),
- const SizedBox(height: 8),
- if (items.isEmpty)
- Text(
- 'No observations stored yet.',
- style: theme.textTheme.bodyMedium,
- )
- else
- ...items.map(
- (item) => ListTile(
- contentPadding: EdgeInsets.zero,
- title: Text(item.id),
- subtitle: Text(
- '${item.durationMs} ms | ${item.sampleRate} Hz | ${item.tags.join(', ')}',
- ),
- trailing: const Icon(Icons.chevron_right),
- onTap: () {
- ref
- .read(sessionActionsProvider)
- .selectObservation(item.id);
- context.goNamed('observation');
- },
- ),
- ),
- ],
- ),
- ),
- ),
- ),
- const SizedBox(height: 16),
- AsyncValueView(
- value: sessions,
- loadingMessage: 'Loading session archive...',
- data: (items) => Card(
- child: Padding(
- padding: const EdgeInsets.all(20),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text('Session Archive', style: theme.textTheme.titleLarge),
- const SizedBox(height: 8),
- if (items.isEmpty)
- Text(
- 'No backend sessions found yet.',
- style: theme.textTheme.bodyMedium,
- )
- else
- ...items.map(
- (item) => ListTile(
- contentPadding: EdgeInsets.zero,
- title: Text(item.observationId),
- subtitle: Text('${item.status} | ${item.message}'),
- trailing: const Icon(Icons.chevron_right),
- onTap: () {
- ref
- .read(sessionActionsProvider)
- .selectSession(item.sessionId);
- context.goNamed('observation');
- },
- ),
- ),
- ],
- ),
- ),
- ),
- ),
- ],
- );
- }
- }
|