Added Expansiontile for comments
parent
ad6e890f57
commit
5177d38b36
|
@ -0,0 +1,29 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
|
class EntryDetailTitle extends StatelessWidget {
|
||||||
|
final DateTime date;
|
||||||
|
final String entryData;
|
||||||
|
|
||||||
|
const EntryDetailTitle(
|
||||||
|
{super.key, required this.date, required this.entryData});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
DateFormat.MMMd('de').format(date),
|
||||||
|
style:
|
||||||
|
const TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
entryData,
|
||||||
|
style:
|
||||||
|
const TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,41 +1,53 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:smoke_cess_app/widgets/entry_detail_title.dart';
|
||||||
|
|
||||||
class EntryDetail extends StatelessWidget {
|
class EntryDetail extends StatelessWidget {
|
||||||
final DateTime date;
|
final DateTime date;
|
||||||
final String entryData;
|
final String entryData;
|
||||||
final IconData icon;
|
final String? entryComment;
|
||||||
|
final IconData iconData;
|
||||||
|
|
||||||
const EntryDetail(
|
const EntryDetail(
|
||||||
{super.key,
|
{super.key,
|
||||||
required this.date,
|
required this.date,
|
||||||
required this.entryData,
|
required this.entryData,
|
||||||
required this.icon});
|
required this.iconData,
|
||||||
|
required this.entryComment});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final Icon icon = Icon(iconData, color: Colors.white);
|
||||||
|
final ShapeBorder shape = RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
|
);
|
||||||
|
final Color color = Theme.of(context).colorScheme.primary.withOpacity(0.8);
|
||||||
|
final Widget title = EntryDetailTitle(date: date, entryData: entryData);
|
||||||
return Card(
|
return Card(
|
||||||
child: ListTile(
|
child: entryComment != null
|
||||||
shape: RoundedRectangleBorder(
|
? ExpansionTile(
|
||||||
borderRadius: BorderRadius.circular(10.0),
|
iconColor: color,
|
||||||
),
|
collapsedShape: shape,
|
||||||
leading: Icon(icon, color: Colors.white),
|
shape: shape,
|
||||||
title: Row(
|
leading: icon,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
title: title,
|
||||||
children: [
|
collapsedBackgroundColor: color,
|
||||||
Text(
|
backgroundColor:
|
||||||
DateFormat.MMMd('de').format(date),
|
Theme.of(context).colorScheme.secondary.withOpacity(0.8),
|
||||||
style: const TextStyle(
|
children: entryComment != null
|
||||||
color: Colors.white, fontWeight: FontWeight.bold),
|
? [
|
||||||
),
|
Text(
|
||||||
Text(
|
entryComment ?? '',
|
||||||
entryData,
|
style: const TextStyle(
|
||||||
style: const TextStyle(
|
color: Colors.white, fontWeight: FontWeight.bold),
|
||||||
color: Colors.white, fontWeight: FontWeight.bold),
|
)
|
||||||
)
|
]
|
||||||
],
|
: [],
|
||||||
),
|
)
|
||||||
tileColor: Theme.of(context).colorScheme.primary.withOpacity(0.8),
|
: ListTile(
|
||||||
));
|
shape: shape,
|
||||||
|
leading: icon,
|
||||||
|
title: title,
|
||||||
|
tileColor: color,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ class HistoryList<T> extends StatelessWidget {
|
||||||
final DateTime Function(T) dateSelector;
|
final DateTime Function(T) dateSelector;
|
||||||
final String Function(T) entryDataSelector;
|
final String Function(T) entryDataSelector;
|
||||||
final IconData Function(T)? iconDataSelector;
|
final IconData Function(T)? iconDataSelector;
|
||||||
|
final String Function(T)? entryCommentSelector;
|
||||||
final IconData? icon;
|
final IconData? icon;
|
||||||
|
|
||||||
const HistoryList(
|
const HistoryList(
|
||||||
|
@ -14,7 +15,8 @@ class HistoryList<T> extends StatelessWidget {
|
||||||
required this.dateSelector,
|
required this.dateSelector,
|
||||||
required this.entryDataSelector,
|
required this.entryDataSelector,
|
||||||
this.iconDataSelector,
|
this.iconDataSelector,
|
||||||
this.icon});
|
this.icon,
|
||||||
|
this.entryCommentSelector});
|
||||||
|
|
||||||
IconData _getIcon(T entry) {
|
IconData _getIcon(T entry) {
|
||||||
if (icon != null) {
|
if (icon != null) {
|
||||||
|
@ -25,6 +27,13 @@ class HistoryList<T> extends StatelessWidget {
|
||||||
return Icons.circle;
|
return Icons.circle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String? _getComment(T entry) {
|
||||||
|
if (entryCommentSelector != null) {
|
||||||
|
return entryCommentSelector!(entry);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
|
@ -33,7 +42,8 @@ class HistoryList<T> extends StatelessWidget {
|
||||||
return EntryDetail(
|
return EntryDetail(
|
||||||
date: dateSelector(entry),
|
date: dateSelector(entry),
|
||||||
entryData: entryDataSelector(entry),
|
entryData: entryDataSelector(entry),
|
||||||
icon: _getIcon(entry));
|
entryComment: _getComment(entry),
|
||||||
|
iconData: _getIcon(entry));
|
||||||
}).toList()));
|
}).toList()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ class MoodView extends StatelessWidget {
|
||||||
history: tasksModel.moodHistory,
|
history: tasksModel.moodHistory,
|
||||||
dateSelector: (Mood mood) => mood.date,
|
dateSelector: (Mood mood) => mood.date,
|
||||||
entryDataSelector: (Mood mood) => 'Stimmung: ${mood.moodValue}',
|
entryDataSelector: (Mood mood) => 'Stimmung: ${mood.moodValue}',
|
||||||
|
entryCommentSelector: (Mood mood) => 'Kommentar: ${mood.comment}',
|
||||||
iconDataSelector: (Mood mood) => mood.moodValue >= 50
|
iconDataSelector: (Mood mood) => mood.moodValue >= 50
|
||||||
? Icons.mood_outlined
|
? Icons.mood_outlined
|
||||||
: Icons.mood_bad_outlined,
|
: Icons.mood_bad_outlined,
|
||||||
|
|
|
@ -10,11 +10,15 @@ class RelapseView extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
TasksProvider tasksModel = context.watch<TasksProvider>();
|
TasksProvider tasksModel = context.watch<TasksProvider>();
|
||||||
return HistoryList<Relapse>(
|
return Column(children: [
|
||||||
history: tasksModel.relapseHistory,
|
HistoryList<Relapse>(
|
||||||
dateSelector: (Relapse relapse) => relapse.date,
|
history: tasksModel.relapseHistory,
|
||||||
entryDataSelector: (Relapse relapse) => 'Grund: ${relapse.category}',
|
dateSelector: (Relapse relapse) => relapse.date,
|
||||||
icon: Icons.smoke_free_outlined,
|
entryDataSelector: (Relapse relapse) => 'Grund: ${relapse.category}',
|
||||||
);
|
entryCommentSelector: (Relapse relapse) =>
|
||||||
|
'Kommentar: ${relapse.comment}',
|
||||||
|
icon: Icons.smoke_free_outlined,
|
||||||
|
)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ class SleepView extends StatelessWidget {
|
||||||
dateSelector: (Sleep sleep) => sleep.date,
|
dateSelector: (Sleep sleep) => sleep.date,
|
||||||
entryDataSelector: (Sleep sleep) =>
|
entryDataSelector: (Sleep sleep) =>
|
||||||
'${sleep.sleepDuration.hour}:${sleep.sleepDuration.minute}',
|
'${sleep.sleepDuration.hour}:${sleep.sleepDuration.minute}',
|
||||||
|
entryCommentSelector: (Sleep sleep) => 'Kommentar: ${sleep.comment}',
|
||||||
icon: Icons.bedtime_outlined,
|
icon: Icons.bedtime_outlined,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue