2020-01-04 19:31:52 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/utils/date_formatter.dart';
|
2020-01-04 19:31:52 +00:00
|
|
|
|
|
|
|
class DateSectionRaw extends StatelessWidget {
|
2020-01-08 12:26:34 +00:00
|
|
|
DateSectionRaw({this.date});
|
|
|
|
|
2020-01-04 19:31:52 +00:00
|
|
|
final DateTime date;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-09-21 11:50:26 +00:00
|
|
|
final nowDate = DateTime.now();
|
2020-01-04 19:31:52 +00:00
|
|
|
final diffDays = date.difference(nowDate).inDays;
|
2020-01-08 12:26:34 +00:00
|
|
|
final isToday = nowDate.day == date.day &&
|
|
|
|
nowDate.month == date.month &&
|
|
|
|
nowDate.year == date.year;
|
2020-10-22 15:11:52 +00:00
|
|
|
final dateSectionDateFormat = DateFormatter.withCurrentLocal(hasTime: false);
|
2020-01-04 19:31:52 +00:00
|
|
|
var title = "";
|
2020-01-08 12:26:34 +00:00
|
|
|
|
2020-01-04 19:31:52 +00:00
|
|
|
if (isToday) {
|
|
|
|
title = S.of(context).today;
|
|
|
|
} else if (diffDays == 0) {
|
|
|
|
title = S.of(context).yesterday;
|
|
|
|
} else if (diffDays > -7 && diffDays < 0) {
|
2020-09-21 11:50:26 +00:00
|
|
|
final dateFormat = DateFormat.EEEE();
|
2020-01-04 19:31:52 +00:00
|
|
|
title = dateFormat.format(date);
|
|
|
|
} else {
|
|
|
|
title = dateSectionDateFormat.format(date);
|
|
|
|
}
|
|
|
|
|
2020-04-17 19:40:11 +00:00
|
|
|
return Container(
|
2020-09-21 11:50:26 +00:00
|
|
|
height: 35,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: Text(title,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
color: Theme.of(context).textTheme.overline.backgroundColor)));
|
2020-01-04 19:31:52 +00:00
|
|
|
}
|
|
|
|
}
|