Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cat-voices): Current campaign - Discovery Page #1614

Merged
merged 14 commits into from
Jan 23, 2025
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'package:catalyst_voices_brands/catalyst_voices_brands.dart';
import 'package:flutter/material.dart';

extension BuildContextThemeExt on BuildContext {
ThemeData get theme => Theme.of(this);
TextTheme get textTheme => theme.textTheme;
ColorScheme get colorScheme => theme.colorScheme;
VoicesColorScheme get colors => theme.colors;
}
1 change: 1 addition & 0 deletions catalyst_voices/apps/voices/lib/common/ext/ext.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export 'brand_ext.dart';
export 'build_context_ext.dart';
export 'space_ext.dart';
export 'string_ext.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'package:intl/intl.dart';

abstract class AmountFormatter {
static String decimalFormat(num value) {
return NumberFormat.decimalPattern().format(value);
}
}
LynxLynxx marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
import 'package:catalyst_voices_shared/catalyst_voices_shared.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';

/// A [DateTime] formatter.
Expand Down Expand Up @@ -95,4 +96,27 @@ abstract class DateFormatter {

return '${nf.format(hours)}:${nf.format(minutes)}';
}

static String formatDateRange(
MaterialLocalizations localizations,
VoicesLocalizations l10n,
DateRange range,
) {
final from = range.from;
final to = range.to;
if (from != null && to != null) {
if (range.areDatesInSameWeek(localizations.firstDayOfWeekIndex)) {
return '${l10n.weekOf} ${DateFormat.MMMd().format(from)}';
}

// ignore: lines_longer_than_80_chars
return '${DateFormat.MMMd().format(from)} - ${DateFormat.MMMd().format(to)}';
} else if (to == null && from != null) {
return '${l10n.from} ${DateFormat.MMMd().format(from)}';
} else if (to != null && from == null) {
return '${l10n.to} ${DateFormat.MMMd().format(to)}';
}

return '';
}
}
Loading
Loading