Skip to content

Commit

Permalink
Merge pull request #1636 from matthiasn/refactor/const_factories
Browse files Browse the repository at this point in the history
refactor: const factories
  • Loading branch information
matthiasn authored Aug 2, 2023
2 parents 24e71ae + 2ec71be commit d4aa66f
Show file tree
Hide file tree
Showing 42 changed files with 522 additions and 370 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ local.properties
classes.viz.png
classes.viz.puml

lib/routes/router.gr.dart

missing_translations.txt

nohup.out
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
### Changed:
- const factories

## [0.8.393] - 2023-06-29
### Changed:
- Consistent microphone icon across app
- Upgraded dependencies

Expand Down
2 changes: 1 addition & 1 deletion lib/classes/audio_note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ part 'audio_note.g.dart';

@freezed
class AudioNote with _$AudioNote {
factory AudioNote({
const factory AudioNote({
required DateTime createdAt,
required String audioFile,
required String audioDirectory,
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/audio_note.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class __$$_AudioNoteCopyWithImpl<$Res>
/// @nodoc
@JsonSerializable()
class _$_AudioNote implements _AudioNote {
_$_AudioNote(
const _$_AudioNote(
{required this.createdAt,
required this.audioFile,
required this.audioDirectory,
Expand Down Expand Up @@ -194,7 +194,7 @@ class _$_AudioNote implements _AudioNote {
}

abstract class _AudioNote implements AudioNote {
factory _AudioNote(
const factory _AudioNote(
{required final DateTime createdAt,
required final String audioFile,
required final String audioDirectory,
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/check_list_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ part 'check_list_item.g.dart';

@freezed
class CheckListItem with _$CheckListItem {
factory CheckListItem({
const factory CheckListItem({
required String id,
required DateTime createdAt,
required int utcOffset,
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/check_list_item.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class __$$_CheckListItemCopyWithImpl<$Res>
/// @nodoc
@JsonSerializable()
class _$_CheckListItem implements _CheckListItem {
_$_CheckListItem(
const _$_CheckListItem(
{required this.id,
required this.createdAt,
required this.utcOffset,
Expand Down Expand Up @@ -266,7 +266,7 @@ class _$_CheckListItem implements _CheckListItem {
}

abstract class _CheckListItem implements CheckListItem {
factory _CheckListItem(
const factory _CheckListItem(
{required final String id,
required final DateTime createdAt,
required final int utcOffset,
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ part 'config.g.dart';

@freezed
class ImapConfig with _$ImapConfig {
factory ImapConfig({
const factory ImapConfig({
required String host,
required String folder,
required String userName,
Expand All @@ -19,7 +19,7 @@ class ImapConfig with _$ImapConfig {

@freezed
class SyncConfig with _$SyncConfig {
factory SyncConfig({
const factory SyncConfig({
required ImapConfig imapConfig,
required String sharedSecret,
}) = _SyncConfig;
Expand Down
8 changes: 4 additions & 4 deletions lib/classes/config.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class __$$_ImapConfigCopyWithImpl<$Res>
/// @nodoc
@JsonSerializable()
class _$_ImapConfig implements _ImapConfig {
_$_ImapConfig(
const _$_ImapConfig(
{required this.host,
required this.folder,
required this.userName,
Expand Down Expand Up @@ -203,7 +203,7 @@ class _$_ImapConfig implements _ImapConfig {
}

abstract class _ImapConfig implements ImapConfig {
factory _ImapConfig(
const factory _ImapConfig(
{required final String host,
required final String folder,
required final String userName,
Expand Down Expand Up @@ -336,7 +336,7 @@ class __$$_SyncConfigCopyWithImpl<$Res>
/// @nodoc
@JsonSerializable()
class _$_SyncConfig implements _SyncConfig {
_$_SyncConfig({required this.imapConfig, required this.sharedSecret});
const _$_SyncConfig({required this.imapConfig, required this.sharedSecret});

factory _$_SyncConfig.fromJson(Map<String, dynamic> json) =>
_$$_SyncConfigFromJson(json);
Expand Down Expand Up @@ -381,7 +381,7 @@ class _$_SyncConfig implements _SyncConfig {
}

abstract class _SyncConfig implements SyncConfig {
factory _SyncConfig(
const factory _SyncConfig(
{required final ImapConfig imapConfig,
required final String sharedSecret}) = _$_SyncConfig;

Expand Down
48 changes: 24 additions & 24 deletions lib/classes/entity_definitions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ enum HabitCompletionType { success, skip, fail, open }

@freezed
class HabitSchedule with _$HabitSchedule {
factory HabitSchedule.daily({
const factory HabitSchedule.daily({
required int requiredCompletions,
DateTime? showFrom,
}) = DailyHabitSchedule;

factory HabitSchedule.weekly({
const factory HabitSchedule.weekly({
required int requiredCompletions,
}) = WeeklyHabitSchedule;

factory HabitSchedule.monthly({
const factory HabitSchedule.monthly({
required int requiredCompletions,
}) = MonthlyHabitSchedule;

Expand All @@ -29,43 +29,43 @@ class HabitSchedule with _$HabitSchedule {

@freezed
class AutoCompleteRule with _$AutoCompleteRule {
factory AutoCompleteRule.health({
const factory AutoCompleteRule.health({
required String dataType,
num? minimum,
num? maximum,
String? title,
}) = AutoCompleteRuleHealth;

factory AutoCompleteRule.workout({
const factory AutoCompleteRule.workout({
required String dataType,
num? minimum,
num? maximum,
String? title,
}) = AutoCompleteRuleWorkout;

factory AutoCompleteRule.measurable({
const factory AutoCompleteRule.measurable({
required String dataTypeId,
num? minimum,
num? maximum,
String? title,
}) = AutoCompleteRuleMeasurable;

factory AutoCompleteRule.habit({
const factory AutoCompleteRule.habit({
required String habitId,
String? title,
}) = AutoCompleteRuleHabit;

factory AutoCompleteRule.and({
const factory AutoCompleteRule.and({
required List<AutoCompleteRule> rules,
String? title,
}) = AutoCompleteRuleAnd;

factory AutoCompleteRule.or({
const factory AutoCompleteRule.or({
required List<AutoCompleteRule> rules,
String? title,
}) = AutoCompleteRuleOr;

factory AutoCompleteRule.multiple({
const factory AutoCompleteRule.multiple({
required List<AutoCompleteRule> rules,
required int successes,
String? title,
Expand All @@ -77,7 +77,7 @@ class AutoCompleteRule with _$AutoCompleteRule {

@freezed
class EntityDefinition with _$EntityDefinition {
factory EntityDefinition.measurableDataType({
const factory EntityDefinition.measurableDataType({
required String id,
required DateTime createdAt,
required DateTime updatedAt,
Expand All @@ -93,7 +93,7 @@ class EntityDefinition with _$EntityDefinition {
AggregationType? aggregationType,
}) = MeasurableDataType;

factory EntityDefinition.categoryDefinition({
const factory EntityDefinition.categoryDefinition({
required String id,
required DateTime createdAt,
required DateTime updatedAt,
Expand All @@ -106,7 +106,7 @@ class EntityDefinition with _$EntityDefinition {
DateTime? deletedAt,
}) = CategoryDefinition;

factory EntityDefinition.habit({
const factory EntityDefinition.habit({
required String id,
required DateTime createdAt,
required DateTime updatedAt,
Expand All @@ -127,7 +127,7 @@ class EntityDefinition with _$EntityDefinition {
bool? priority,
}) = HabitDefinition;

factory EntityDefinition.dashboard({
const factory EntityDefinition.dashboard({
required String id,
required DateTime createdAt,
required DateTime updatedAt,
Expand All @@ -151,7 +151,7 @@ class EntityDefinition with _$EntityDefinition {

@freezed
class MeasurementData with _$MeasurementData {
factory MeasurementData({
const factory MeasurementData({
required DateTime dateFrom,
required DateTime dateTo,
required num value,
Expand All @@ -164,7 +164,7 @@ class MeasurementData with _$MeasurementData {

@freezed
class WorkoutData with _$WorkoutData {
factory WorkoutData({
const factory WorkoutData({
required DateTime dateFrom,
required DateTime dateTo,
required String id,
Expand All @@ -180,7 +180,7 @@ class WorkoutData with _$WorkoutData {

@freezed
class HabitCompletionData with _$HabitCompletionData {
factory HabitCompletionData({
const factory HabitCompletionData({
required DateTime dateFrom,
required DateTime dateTo,
required String habitId,
Expand All @@ -199,39 +199,39 @@ enum WorkoutValueType {

@freezed
class DashboardItem with _$DashboardItem {
factory DashboardItem.measurement({
const factory DashboardItem.measurement({
required String id,
AggregationType? aggregationType,
}) = DashboardMeasurementItem;

factory DashboardItem.healthChart({
const factory DashboardItem.healthChart({
required String color,
required String healthType,
}) = DashboardHealthItem;

factory DashboardItem.workoutChart({
const factory DashboardItem.workoutChart({
required String workoutType,
required String displayName,
required String color,
required WorkoutValueType valueType,
}) = DashboardWorkoutItem;

factory DashboardItem.habitChart({
const factory DashboardItem.habitChart({
required String habitId,
}) = DashboardHabitItem;

factory DashboardItem.surveyChart({
const factory DashboardItem.surveyChart({
required Map<String, String> colorsByScoreKey,
required String surveyType,
required String surveyName,
}) = DashboardSurveyItem;

factory DashboardItem.storyTimeChart({
const factory DashboardItem.storyTimeChart({
required String storyTagId,
required String color,
}) = DashboardStoryTimeItem;

factory DashboardItem.wildcardStoryTimeChart({
const factory DashboardItem.wildcardStoryTimeChart({
required String storySubstring,
required String color,
}) = WildcardStoryTimeItem;
Expand Down
Loading

0 comments on commit d4aa66f

Please sign in to comment.