Skip to content

Commit

Permalink
Change filter by date button design on dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikpre authored and Gabriel Sailer committed Mar 13, 2021
1 parent dca3c29 commit 55583e7
Showing 1 changed file with 37 additions and 5 deletions.
42 changes: 37 additions & 5 deletions lib/views/insights_cards/overview_insights_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,49 @@ class OverviewInsightCard extends InsightsCard {
// physics: const AlwaysScrollableScrollPhysics(),
// shrinkWrap: true,
children: <Widget>[
GestureDetector(
onTap: () => _activateFilter(context),
child: Center(
child: Text(
'${Provider.of<FilterState>(context).startTime.toString()} - ${Provider.of<FilterState>(context).endTime.toString()}'))),
TextButton.icon(
icon: Icon(Icons.calendar_today),
style: TextButton.styleFrom(
backgroundColor: Color(0xFFECB02D),
primary: Colors.white,
),
onPressed: () => _activateFilter(context),
label: Text(" " + _removeTimeFromDate(context, true) + " - " + _removeTimeFromDate(context, false)),
),
_detailElements(apps, context, "Apps"),
_detailElements(websites, context, "Websites"),
],
);
}

String _removeTimeFromDate(BuildContext context, bool isStartTime) {
FilterState dateAndTime = Provider.of<FilterState>(context);
var date;
List<String> monthsShort = [
'',
'Jan.',
'Feb.',
'Mar.',
'Apr.',
'May',
'Jun.',
'Jul.',
'Aug.',
'Sep.',
'Oct.',
'Nov.',
'Dec.'
];
if (isStartTime == true) {
date =
"${monthsShort[dateAndTime.startTime.month]} ${dateAndTime.startTime.day}, ${dateAndTime.startTime.year}";
} else {
date =
"${monthsShort[dateAndTime.endTime.month]} ${dateAndTime.endTime.day}, ${dateAndTime.endTime.year}";
}
return date.toString();
}

void _activateFilter(BuildContext context) async {
DateTime startTime =
Provider.of<FilterState>(context, listen: false).startTime;
Expand Down

0 comments on commit 55583e7

Please sign in to comment.