/*class EntryPage extends StatelessWidget { final DateTime date; EntryPage({Key? key, required this.date}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Date Display'), leading: IconButton( icon: Icon(Icons.arrow_back, color: Colors.white), onPressed: () => context.go("/statistic"), ), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Selected Date:", style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), ), SizedBox(height: 10), Text( DateFormat('yyyy-MM-dd').format(date), style: TextStyle(fontSize: 20, color: Colors.blue), ), ], ), ), ); } } */ import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:intl/intl.dart'; import '../../utils/logic/PreferencesService.dart'; class EntryPage extends StatelessWidget { final DateTime date; final PreferencesService prefsService = PreferencesService(); EntryPage({Key? key, required this.date}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Date Display'), leading: IconButton( icon: Icon(Icons.arrow_back, color: Colors.white), onPressed: () => context.go("/statistic"), ), ), body: FutureBuilder( future: prefsService.getDiaryEntryByDate(date), // Fetch the diary entry builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.done) { // Check if the diary entry exists if (snapshot.data != null) { DiaryEntry entry = snapshot.data!; return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Selected Date:", style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), ), SizedBox(height: 10), Text( DateFormat('yyyy-MM-dd').format(date), style: TextStyle(fontSize: 20, color: Colors.blue), ), SizedBox(height: 20), Text( "Percent Value: ${entry.percentValue}", style: TextStyle(fontSize: 18), ), ...entry.texts.map((text) => Padding( padding: const EdgeInsets.all(8.0), child: Text(text), )), ], ), ); } else { // Handle the case when there is no entry for the given date return Center( child: Text("No entry found for this date."), ); } } else { // Show loading indicator while waiting for data return Center(child: CircularProgressIndicator()); } }, ), ); } }