cake_wallet/lib/src/screens/dashboard/date_section_raw.dart

39 lines
1.1 KiB
Dart
Raw Normal View History

2020-01-04 19:31:52 +00:00
import 'package:flutter/material.dart';
import 'package:cake_wallet/palette.dart';
import 'package:intl/intl.dart';
import 'package:cake_wallet/generated/i18n.dart';
class DateSectionRaw extends StatelessWidget {
static final dateSectionDateFormat = DateFormat("d MMM");
static final nowDate = DateTime.now();
final DateTime date;
DateSectionRaw({this.date});
@override
Widget build(BuildContext context) {
final diffDays = date.difference(nowDate).inDays;
final isToday = nowDate.day == date.day && nowDate.month == date.month && nowDate.year == date.year;
var title = "";
if (isToday) {
title = S.of(context).today;
} else if (diffDays == 0) {
title = S.of(context).yesterday;
} else if (diffDays > -7 && diffDays < 0) {
final dateFormat = DateFormat("EEEE");
title = dateFormat.format(date);
} else {
title = dateSectionDateFormat.format(date);
}
return Padding(
padding: const EdgeInsets.only(top: 10, bottom: 10),
child: Center(
child: Text(title,
style: TextStyle(fontSize: 16, color: Palette.wildDarkBlue))),
);
}
}