CWA-180 | fixed local date format in dashboard_page, date_section_raw, trade_details_page, transaction_details_page, added currentLocale parameter to settings store

This commit is contained in:
Oleksandr Sobol 2020-03-06 20:38:13 +02:00
parent 00307cb55c
commit 75c33370f1
5 changed files with 24 additions and 7 deletions

View file

@ -125,7 +125,9 @@ class DashboardPageBodyState extends State<DashboardPageBody> {
final actionListStore = Provider.of<ActionListStore>(context); final actionListStore = Provider.of<ActionListStore>(context);
final syncStore = Provider.of<SyncStore>(context); final syncStore = Provider.of<SyncStore>(context);
final settingsStore = Provider.of<SettingsStore>(context); final settingsStore = Provider.of<SettingsStore>(context);
final transactionDateFormat = DateFormat("MMMM d, yyyy HH:mm", settingsStore.languageCode); final transactionDateFormat = settingsStore.currentLocale == 'en_US'
? DateFormat("MMMM d, yyyy, HH:mm", settingsStore.languageCode)
: DateFormat("d MMMM yyyy, HH:mm", settingsStore.languageCode);
return Observer( return Observer(
key: _listObserverKey, key: _listObserverKey,

View file

@ -19,7 +19,9 @@ class DateSectionRaw extends StatelessWidget {
nowDate.year == date.year; nowDate.year == date.year;
final settingsStore = Provider.of<SettingsStore>(context); final settingsStore = Provider.of<SettingsStore>(context);
final currentLanguage = settingsStore.languageCode; final currentLanguage = settingsStore.languageCode;
final dateSectionDateFormat = DateFormat("d MMM", currentLanguage); final dateSectionDateFormat = settingsStore.currentLocale == 'en_US'
? DateFormat("MMM d", settingsStore.languageCode)
: DateFormat("d MMM", settingsStore.languageCode);
var title = ""; var title = "";
if (isToday) { if (isToday) {

View file

@ -5,6 +5,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/stores/exchange_trade/exchange_trade_store.dart'; import 'package:cake_wallet/src/stores/exchange_trade/exchange_trade_store.dart';
import 'package:cake_wallet/src/stores/settings/settings_store.dart';
import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart'; import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart';
import 'package:cake_wallet/src/screens/transaction_details/standart_list_row.dart'; import 'package:cake_wallet/src/screens/transaction_details/standart_list_row.dart';
@ -17,11 +18,13 @@ class TradeDetailsPage extends BasePage {
@override @override
bool get isModalBackButton => true; bool get isModalBackButton => true;
final createdAtFormat = DateFormat('yyyy-MM-dd HH:mm:ss');
@override @override
Widget body(BuildContext context) { Widget body(BuildContext context) {
final exchangeStore = Provider.of<ExchangeTradeStore>(context); final exchangeStore = Provider.of<ExchangeTradeStore>(context);
final settingsStore = Provider.of<SettingsStore>(context);
final createdAtFormat = settingsStore.currentLocale == 'en_US'
? DateFormat('yyyy.MM.dd, HH:mm')
: DateFormat('dd.MM.yyyy, HH:mm');
return Container( return Container(
padding: EdgeInsets.only(top: 10.0, bottom: 10.0, left: 20, right: 15), padding: EdgeInsets.only(top: 10.0, bottom: 10.0, left: 20, right: 15),

View file

@ -42,11 +42,13 @@ class TransactionDetailsForm extends StatefulWidget {
} }
class TransactionDetailsFormState extends State<TransactionDetailsForm> { class TransactionDetailsFormState extends State<TransactionDetailsForm> {
final DateFormat _dateFormat = DateFormat('dd.MM.yyyy, HH:mm');
final _items = List<StandartListItem>(); final _items = List<StandartListItem>();
@override @override
void initState() { void initState() {
final _dateFormat = widget.settingsStore.currentLocale == 'en_US'
? DateFormat('yyyy.MM.dd, HH:mm')
: DateFormat('dd.MM.yyyy, HH:mm');
final items = [ final items = [
StandartListItem( StandartListItem(
title: S.current.transaction_details_transaction_id, title: S.current.transaction_details_transaction_id,

View file

@ -14,6 +14,7 @@ import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/domain/common/default_settings_migration.dart'; import 'package:cake_wallet/src/domain/common/default_settings_migration.dart';
import 'package:package_info/package_info.dart'; import 'package:package_info/package_info.dart';
import 'package:cake_wallet/src/domain/common/language.dart'; import 'package:cake_wallet/src/domain/common/language.dart';
import 'package:devicelocale/devicelocale.dart';
part 'settings_store.g.dart'; part 'settings_store.g.dart';
@ -31,7 +32,8 @@ abstract class SettingsStoreBase with Store {
@required bool initialDarkTheme, @required bool initialDarkTheme,
this.actionlistDisplayMode, this.actionlistDisplayMode,
@required int initialPinLength, @required int initialPinLength,
@required String initialLanguageCode}) { @required String initialLanguageCode,
@required String initialCurrentLocale}) {
fiatCurrency = initialFiatCurrency; fiatCurrency = initialFiatCurrency;
transactionPriority = initialTransactionPriority; transactionPriority = initialTransactionPriority;
balanceDisplayMode = initialBalanceDisplayMode; balanceDisplayMode = initialBalanceDisplayMode;
@ -42,6 +44,7 @@ abstract class SettingsStoreBase with Store {
isDarkTheme = initialDarkTheme; isDarkTheme = initialDarkTheme;
defaultPinLength = initialPinLength; defaultPinLength = initialPinLength;
languageCode = initialLanguageCode; languageCode = initialLanguageCode;
currentLocale = initialCurrentLocale;
itemHeaders = Map(); itemHeaders = Map();
actionlistDisplayMode.observe( actionlistDisplayMode.observe(
@ -96,6 +99,7 @@ abstract class SettingsStoreBase with Store {
sharedPreferences.getString(currentLanguageCode) == null sharedPreferences.getString(currentLanguageCode) == null
? await Language.localeDetection() ? await Language.localeDetection()
: sharedPreferences.getString(currentLanguageCode); : sharedPreferences.getString(currentLanguageCode);
final initialCurrentLocale = await Devicelocale.currentLocale;
final store = SettingsStore( final store = SettingsStore(
sharedPreferences: sharedPreferences, sharedPreferences: sharedPreferences,
@ -108,7 +112,8 @@ abstract class SettingsStoreBase with Store {
initialDarkTheme: savedDarkTheme, initialDarkTheme: savedDarkTheme,
actionlistDisplayMode: actionlistDisplayMode, actionlistDisplayMode: actionlistDisplayMode,
initialPinLength: defaultPinLength, initialPinLength: defaultPinLength,
initialLanguageCode: savedLanguageCode); initialLanguageCode: savedLanguageCode,
initialCurrentLocale: initialCurrentLocale);
await store.loadSettings(); await store.loadSettings();
@ -141,8 +146,11 @@ abstract class SettingsStoreBase with Store {
@observable @observable
int defaultPinLength; int defaultPinLength;
String languageCode; String languageCode;
String currentLocale;
@observable @observable
Map<String, String> itemHeaders; Map<String, String> itemHeaders;