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';
|
2020-02-27 17:05:23 +00:00
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:cake_wallet/src/stores/settings/settings_store.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
|
|
|
static final nowDate = DateTime.now();
|
|
|
|
final DateTime date;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
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-02-27 17:05:23 +00:00
|
|
|
final settingsStore = Provider.of<SettingsStore>(context);
|
|
|
|
final currentLanguage = settingsStore.languageCode;
|
2020-03-09 16:51:54 +00:00
|
|
|
final dateSectionDateFormat = settingsStore.getCurrentDateFormat(
|
2020-04-16 18:41:04 +00:00
|
|
|
formatUSA: "yyyy MMM d",
|
|
|
|
formatDefault: "d MMM yyyy");
|
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-02-27 17:05:23 +00:00
|
|
|
final dateFormat = DateFormat.EEEE(currentLanguage);
|
2020-01-04 19:31:52 +00:00
|
|
|
title = dateFormat.format(date);
|
|
|
|
} else {
|
|
|
|
title = dateSectionDateFormat.format(date);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 10, bottom: 10),
|
|
|
|
child: Center(
|
|
|
|
child: Text(title,
|
2020-04-16 18:41:04 +00:00
|
|
|
style: TextStyle(fontSize: 12, color: PaletteDark.historyPanelText))),
|
2020-01-04 19:31:52 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|