Skip to content

Commit

Permalink
Merge pull request #191 from QuantumPhysique/prepare_v0.9.0
Browse files Browse the repository at this point in the history
Prepare v0.9.0
  • Loading branch information
gwosd authored Jan 8, 2025
2 parents a33936b + 6ed4a5b commit 91c3e83
Show file tree
Hide file tree
Showing 12 changed files with 269 additions and 201 deletions.
27 changes: 20 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,22 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
[//]: # (### Bugfix 🐛:)
[//]: # (### Other changes:)


## [Unreleased]


## [0.9.0] - 2025-01-08
### Added Features and Improvements 🙌:
- Hello World! Thx to the community, the app is now available in Estonian and Slovenian 🎉
- Allow setting the first day of the week, thx to @olker159
- Using the latest flutter 3.27 with upgraded deps

### Other changes:
- Improved and restructured settings page

### Bugfix 🐛:
- Fixed the estimation of the current/max streak, see #183


## [0.8.1] - 2024-11-14
### Bugfix 🐛:
- Remove DependencyInfoBlock
Expand Down Expand Up @@ -86,7 +98,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Other changes:
- Disabling interpolation, will now use sigma=2days for extrapolation prediction
- Removed v0.6.0 due to critical bug when user targe weight was set.
- Removed v0.6.0 due to critical bug when user target weight was set.


## [0.5.0] - 2024-01-25
Expand All @@ -100,7 +112,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- Accelerated import

### Bugfix 🐛:
- Fix bug, that allowed target weights below 50kg
- Fix bug, that allowed target weights below 50 kg


## [0.4.6] - 2024-01-08
Expand Down Expand Up @@ -178,7 +190,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.3.0] - 2023-09-05
### Added Features and Improvements 🙌:
- Add support for themed app icon (android 13)
- Using latest flutter 3.13 version with improved Material You theme
- Using the latest flutter 3.13 version with improved Material You theme
- Update measurement list
- Add import and export feature

Expand All @@ -188,7 +200,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.2] - 2022-10-18
### Added Features and Improvements 🙌:
- All new measurment screen including now achievemts
- All new measurement screen including now achievements

### Bugfix 🐛:
- Show current slope on start screen widget instead of 30 days average
Expand Down Expand Up @@ -219,14 +231,15 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- Many new themes, improved zoom levels, many fixed bugs and so much more.

### Other changes:
- Added fastelone to publish app
- Added fastlane to publish app


## [0.1.0] - 2022-03-01
- initial release


[Unreleased]: https://github.com/quantumphysique/trale/compare/v0.8.1...main
[Unreleased]: https://github.com/quantumphysique/trale/compare/v0.9.0...main
[0.9.0]: https://github.com/quantumphysique/trale/compare/v0.8.1...v0.9.0
[0.8.1]: https://github.com/quantumphysique/trale/compare/v0.8.0...v0.8.1
[0.8.0]: https://github.com/quantumphysique/trale/compare/v0.7.2...v0.8.0
[0.7.2]: https://github.com/quantumphysique/trale/compare/v0.7.1...v0.7.2
Expand Down
21 changes: 11 additions & 10 deletions app/lib/core/firstDay.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import 'package:intl/date_symbols.dart';
import 'package:intl/intl.dart';

/// Enum representing the first day of the week
enum TraleFirstDay {
/// Default: locale-based
Default,

/// Sunday as the first day of the week
sunday,

/// Monday as the first day of the week
monday,

Expand All @@ -16,15 +14,18 @@ enum TraleFirstDay {

/// Saturday as the first day of the week
saturday,

/// Sunday as the first day of the week
sunday,
}

extension TraleFirstDayExtension on TraleFirstDay {
// Caching the localized names
static final Map<String, Map<TraleFirstDay, String>> _localizedNamesCache =
{};
<String, Map<TraleFirstDay, String>>{};

/// Mapping of TraleFirstDay values to DateTime weekday values (Monday = 1, Sunday = 7)
static const Map<TraleFirstDay, int?> _weekdayMapping = {
static const Map<TraleFirstDay, int?> _weekdayMapping = <TraleFirstDay, int?>{
TraleFirstDay.Default: null, // No specific weekday for Default
TraleFirstDay.sunday: DateTime.sunday,
TraleFirstDay.monday: DateTime.monday,
Expand All @@ -41,10 +42,10 @@ extension TraleFirstDayExtension on TraleFirstDay {
static Future<void> loadLocalizedNames(String locale) async {
if (_localizedNamesCache.containsKey(locale)) return;

final dateSymbols = await DateFormat('EEEE', locale).dateSymbols;
final standaloneWeekdays = dateSymbols.STANDALONEWEEKDAYS;
final DateSymbols dateSymbols = DateFormat('EEEE', locale).dateSymbols;
final List<String> standaloneWeekdays = dateSymbols.STANDALONEWEEKDAYS;

_localizedNamesCache[locale] = {
_localizedNamesCache[locale] = <TraleFirstDay, String>{
TraleFirstDay.sunday: standaloneWeekdays[0],
TraleFirstDay.monday: standaloneWeekdays[1],
TraleFirstDay.tuesday: standaloneWeekdays[2],
Expand All @@ -61,8 +62,8 @@ extension TraleFirstDayExtension on TraleFirstDay {
static TraleFirstDay fromDateTimeWeekday(int weekday) =>
_weekdayMapping.entries
.firstWhere(
(entry) => entry.value == weekday,
orElse: () => MapEntry(TraleFirstDay.sunday, DateTime.sunday),
(MapEntry<TraleFirstDay, int?> entry) => entry.value == weekday,
orElse: () => const MapEntry(TraleFirstDay.sunday, DateTime.sunday),
)
.key;
}
Expand Down
9 changes: 4 additions & 5 deletions app/lib/core/interpolationPreview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:trale/core/measurementDatabase.dart';
import 'package:trale/core/measurementInterpolation.dart';


Map<int, double> _ms_map = {
Map<int, double> _ms_map = <int, double>{
0: 78.1,
1: 78.4,
2: 78.3,
Expand All @@ -29,12 +29,11 @@ List<Measurement> _ms = <Measurement>[
class PreviewDatabase extends MeasurementDatabaseBaseclass {
PreviewDatabase();

List<Measurement>? _measurements = _ms;
final List<Measurement> _measurements = _ms;

/// get sorted measurements
List<Measurement> get measurements => _measurements == null
? <Measurement>[]
: _measurements!..sort(
@override
List<Measurement> get measurements => _measurements ?? <Measurement>[]..sort(
(Measurement a, Measurement b) => b.compareTo(a)
);
}
Expand Down
6 changes: 4 additions & 2 deletions app/lib/core/language.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ class Language {
'de': 'Deutsch',
'en': 'English',
'es': 'Español',
'et': 'Eesti keel',
'fi': 'Suomi',
'fr': 'Français',
'hr': 'hrvatski',
'hr': 'Hrvatski',
'it': 'Italiano',
'ko': '조선말',
'lt': 'Lietuvių',
'nb': 'Bokmål',
'pl': 'język polski',
'pl': 'Język polski',
'pt': 'Português',
'sl': 'Slovenščina',
'tr': 'Türkçe',
'uk': 'Українська мова',
'zh': '汉语',
Expand Down
34 changes: 17 additions & 17 deletions app/lib/core/printFormat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,34 @@ enum TraleDatePrintFormat {
/// Extension to add functionality to TraleDatePrintFormat
extension TraleDateFormatExtension on TraleDatePrintFormat {
/// Mapping of date formats to their patterns
static const _patternMapping = <TraleDatePrintFormat, String?>{
static const Map<TraleDatePrintFormat, String?> _patternMapping = <TraleDatePrintFormat, String?>{
TraleDatePrintFormat.systemDefault: null,
TraleDatePrintFormat.yyyyMMdd: 'yyyy/MM/dd',
TraleDatePrintFormat.ddMMyyyy: 'dd/MM/yyyy',
TraleDatePrintFormat.MMddyyyy: 'MM/dd/yyyy',
TraleDatePrintFormat.ddMMyyyyDot: 'dd.MM.yyyy',
};

/// Mapping of date formats to their patterns
static const Map<TraleDatePrintFormat, String?> _patternMappingShort = <TraleDatePrintFormat, String?>{
TraleDatePrintFormat.systemDefault: null,
TraleDatePrintFormat.yyyyMMdd: 'MM/dd',
TraleDatePrintFormat.ddMMyyyy: 'dd/MM',
TraleDatePrintFormat.MMddyyyy: 'MM/dd',
TraleDatePrintFormat.ddMMyyyyDot: 'dd.MM',
};

/// Get the pattern associated with each format option, using a custom format if provided
String? getPattern([String? customPattern]) {
return _patternMapping[this];
}
String? get pattern => _patternMapping[this];

/// Get the pattern associated with each format option, using a custom format if provided
String? get patternShort => _patternMappingShort[this];

/// Format a DateTime object according to the selected format
String formatDate(DateTime date, {String? customPattern}) {
final pattern = getPattern(customPattern);
return DateFormat(pattern).format(date);
}
DateFormat get dateFormat => DateFormat(pattern);

/// Parse a date string into DateTime based on the selected format
DateTime? parseDate(String dateString, {String? customPattern}) {
try {
final pattern = getPattern(customPattern);
return DateFormat(pattern).parse(dateString);
} catch (e) {
return null;
}
}
/// Format a DateTime object according to the selected format without year
DateFormat get dayFormat => DateFormat(patternShort);

/// Get the string name for each date format
String get name => toString().split('.').last;
Expand Down
40 changes: 24 additions & 16 deletions app/lib/core/traleNotifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,30 +138,38 @@ class TraleNotifier with ChangeNotifier {

/// getter
DateFormat dateFormat(BuildContext context) {
final Locale activeLocale = Localizations.localeOf(context);
if (dateTimePatternMap().containsKey(activeLocale.languageCode)) {
final Map<String, String> dateTimeLocaleMap =
dateTimePatternMap()[activeLocale.languageCode]!;
if (dateTimeLocaleMap.containsKey('yMd')) {
return DateFormat(dateTimeLocaleMap['yMd']!
.replaceFirst('d', 'dd')
.replaceFirst('M', 'MM'));
if (datePrintFormat == TraleDatePrintFormat.systemDefault) {
final Locale activeLocale = Localizations.localeOf(context);
if (dateTimePatternMap().containsKey(activeLocale.languageCode)) {
final Map<String, String> dateTimeLocaleMap =
dateTimePatternMap()[activeLocale.languageCode]!;
if (dateTimeLocaleMap.containsKey('yMd')) {
return DateFormat(dateTimeLocaleMap['yMd']!
.replaceFirst('d', 'dd')
.replaceFirst('M', 'MM'));
}
}
} else {
return datePrintFormat.dateFormat;
}
return DateFormat('dd/MM/yyyy');
}

/// getter
DateFormat dayFormat(BuildContext context) {
final Locale activeLocale = Localizations.localeOf(context);
if (dateTimePatternMap().containsKey(activeLocale.languageCode)) {
final Map<String, String> dateTimeLocaleMap =
dateTimePatternMap()[activeLocale.languageCode]!;
if (dateTimeLocaleMap.containsKey('Md')) {
return DateFormat(dateTimeLocaleMap['Md']!
.replaceFirst('d', 'dd')
.replaceFirst('M', 'MM'));
if (datePrintFormat == TraleDatePrintFormat.systemDefault) {
final Locale activeLocale = Localizations.localeOf(context);
if (dateTimePatternMap().containsKey(activeLocale.languageCode)) {
final Map<String, String> dateTimeLocaleMap =
dateTimePatternMap()[activeLocale.languageCode]!;
if (dateTimeLocaleMap.containsKey('Md')) {
return DateFormat(dateTimeLocaleMap['Md']!
.replaceFirst('d', 'dd')
.replaceFirst('M', 'MM'));
}
}
} else {
return datePrintFormat.dayFormat;
}
return DateFormat('dd/MM');
}
Expand Down
10 changes: 5 additions & 5 deletions app/lib/pages/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ class InterpolationSetting extends StatelessWidget {

child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
children: <Widget>[
AutoSizeText(
AppLocalizations.of(context)!.strength.inCaps,
style: Theme.of(context).textTheme.bodyLarge,
Expand All @@ -526,7 +526,7 @@ class InterpolationSetting extends StatelessWidget {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
children: <Widget>[
Container(
padding: EdgeInsets.symmetric(
horizontal: TraleTheme.of(context)!.padding,
Expand Down Expand Up @@ -690,8 +690,8 @@ class FirstDayListTile extends StatelessWidget {

@override
Widget build(BuildContext context) {
final locale = Localizations.localeOf(context).toString();
final traleNotifier = Provider.of<TraleNotifier>(context);
final String locale = Localizations.localeOf(context).toString();
final TraleNotifier traleNotifier = Provider.of<TraleNotifier>(context);
return FutureBuilder<void>(
future: TraleFirstDayExtension.loadLocalizedNames(locale),
builder: (BuildContext context, AsyncSnapshot<void> snapshot) {
Expand Down Expand Up @@ -763,7 +763,7 @@ class DatePrintListTile extends StatelessWidget {
in TraleDatePrintFormat.values)
DropdownMenuEntry<TraleDatePrintFormat>(
value: datePrintFormat,
label: datePrintFormat.getPattern() ?? 'Default',
label: datePrintFormat.pattern ?? 'Default',
)
],
onSelected: (TraleDatePrintFormat? newDatePrintFormat) async {
Expand Down
Loading

0 comments on commit 91c3e83

Please sign in to comment.