diff --git a/lib/actions/actions.dart b/lib/actions/actions.dart index 39970cc..353ef8d 100644 --- a/lib/actions/actions.dart +++ b/lib/actions/actions.dart @@ -2,7 +2,7 @@ export 'app.dart'; export 'auth.dart'; export 'date.dart'; export 'deeplinks.dart'; -export 'default_rules.dart'; +export 'default_replies.dart'; export 'groups.dart'; export 'invites.dart'; export 'locale.dart'; diff --git a/lib/actions/default_rules.dart b/lib/actions/default_replies.dart similarity index 67% rename from lib/actions/default_rules.dart rename to lib/actions/default_replies.dart index b8eebe0..49bceb5 100644 --- a/lib/actions/default_rules.dart +++ b/lib/actions/default_replies.dart @@ -1,11 +1,11 @@ import 'package:flutter/foundation.dart'; @immutable -class RequestDeleteDefaultRuleAction { +class RequestDeleteDefaultReplyAction { final int memberId; final int scheduleId; - const RequestDeleteDefaultRuleAction({ + const RequestDeleteDefaultReplyAction({ required this.memberId, required this.scheduleId, }); diff --git a/lib/epics/default_replies.dart b/lib/epics/default_replies.dart new file mode 100644 index 0000000..6a6fdff --- /dev/null +++ b/lib/epics/default_replies.dart @@ -0,0 +1,59 @@ +import 'package:parousia/actions/actions.dart'; +import 'package:parousia/models/models.dart'; +import 'package:parousia/repositories/repositories.dart'; +import 'package:parousia/state/state.dart'; +import 'package:redux_entity/redux_entity.dart'; +import 'package:redux_epics/redux_epics.dart'; +import 'package:rxdart/rxdart.dart'; + +createDefaultRepliesEpics(DefaultRepliesRepository defaultReplies) => + combineEpics([ + _createRetrieveGroupDefaultRepliesEpic(defaultReplies), + _createRequestUpdateOneDefaultReplyEpic(defaultReplies), + _createRequestDeleteDefaultReplyEpic(defaultReplies), + ]); + +/// Fetch all default replies for a group +Epic _createRetrieveGroupDefaultRepliesEpic( + DefaultRepliesRepository defaultReplies) { + return (Stream actions, EpicStore store) => actions + .whereType() + .asyncMap( + (action) => defaultReplies + .getDefaultReplies(int.parse(action.groupId)) + .then((defaultReplies) => + SuccessRetrieveMany(defaultReplies.toList(growable: false))) + .catchError((error) => FailRetrieveMany([], error)), + ); +} + +/// Create a new default reply +Epic _createRequestUpdateOneDefaultReplyEpic( + DefaultRepliesRepository defaultReplies) { + return (Stream actions, EpicStore store) => + actions.whereType>().asyncMap( + (action) => defaultReplies + .createDefaultReply(action.entity) + .then((defaultReply) => SuccessUpdateOne(defaultReply)) + .catchError((error) => FailUpdateOne( + entity: action.entity, error: error)), + ); +} + +/// Delete a default reply +Epic _createRequestDeleteDefaultReplyEpic( + DefaultRepliesRepository defaultReplies) { + return (Stream actions, EpicStore store) => + actions.whereType().asyncMap( + (action) => defaultReplies + .deleteDefaultReply( + memberId: action.memberId, + scheduleId: action.scheduleId, + ) + .then((_) => SuccessDeleteOne( + "${action.memberId}-${action.scheduleId}")) + .catchError((error) => FailDeleteOne( + id: "${action.memberId}-${action.scheduleId}", + error: error)), + ); +} diff --git a/lib/epics/default_rules.dart b/lib/epics/default_rules.dart deleted file mode 100644 index 5b0fe75..0000000 --- a/lib/epics/default_rules.dart +++ /dev/null @@ -1,59 +0,0 @@ -import 'package:parousia/actions/actions.dart'; -import 'package:parousia/models/models.dart'; -import 'package:parousia/repositories/repositories.dart'; -import 'package:parousia/state/state.dart'; -import 'package:redux_entity/redux_entity.dart'; -import 'package:redux_epics/redux_epics.dart'; -import 'package:rxdart/rxdart.dart'; - -createDefaultRulesEpics(DefaultRulesRepository defaultRules) => - combineEpics([ - _createRetrieveGroupDefaultRulesEpic(defaultRules), - _createRequestUpdateOneDefaultRuleEpic(defaultRules), - _createRequestDeleteDefaultRuleEpic(defaultRules), - ]); - -/// Fetch all default replies for a group -Epic _createRetrieveGroupDefaultRulesEpic( - DefaultRulesRepository defaultRules) { - return (Stream actions, EpicStore store) => actions - .whereType() - .asyncMap( - (action) => defaultRules - .getDefaultRules(int.parse(action.groupId)) - .then((defaultRules) => - SuccessRetrieveMany(defaultRules.toList(growable: false))) - .catchError((error) => FailRetrieveMany([], error)), - ); -} - -/// Create a new default reply -Epic _createRequestUpdateOneDefaultRuleEpic( - DefaultRulesRepository defaultRules) { - return (Stream actions, EpicStore store) => - actions.whereType>().asyncMap( - (action) => defaultRules - .createDefaultRule(action.entity) - .then((defaultRule) => SuccessUpdateOne(defaultRule)) - .catchError((error) => FailUpdateOne( - entity: action.entity, error: error)), - ); -} - -/// Delete a default reply -Epic _createRequestDeleteDefaultRuleEpic( - DefaultRulesRepository defaultRules) { - return (Stream actions, EpicStore store) => - actions.whereType().asyncMap( - (action) => defaultRules - .deleteDefaultRule( - memberId: action.memberId, - scheduleId: action.scheduleId, - ) - .then((_) => SuccessDeleteOne( - "${action.memberId}-${action.scheduleId}")) - .catchError((error) => FailDeleteOne( - id: "${action.memberId}-${action.scheduleId}", - error: error)), - ); -} diff --git a/lib/epics/epics.dart b/lib/epics/epics.dart index 6cd2488..13c7d75 100644 --- a/lib/epics/epics.dart +++ b/lib/epics/epics.dart @@ -1,5 +1,5 @@ export 'auth.dart'; -export 'default_rules.dart'; +export 'default_replies.dart'; export 'groups.dart'; export 'invites.dart'; export 'members.dart'; diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index 395ca60..b4f699c 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -20,11 +20,12 @@ "createNewEvent": "Neues Event erstellen", "createNewGroup": "Neue Gruppe erstellen", "createOrJoinGroup": "Gruppe erstellen oder beitreten", - "defaultRules": "Standardantworten", - "defaultRulesDescription": "Wähle eine Standardantwort für dieses Event", - "defaultRulesDaily": "Täglich", - "defaultRulesWeekdays": "Wochentage", - "defaultRulesWeekends": "Wochenende", + "defaultReplies": "Standardantworten", + "defaultRepliesDescription": "Wähle eine Standardantwort für dieses Event", + "defaultRepliesDaily": "Täglich", + "defaultRepliesExplanation": "Standardantworten ermöglichen es dir, automatische Antworten für wiederkehrende Events festzulegen. Du kannst zwischen täglichen, wochentäglichen oder wochenendlichen Optionen wählen.", + "defaultRepliesWeekdays": "Wochentage", + "defaultRepliesWeekends": "Wochenende", "delete": "Löschen", "deleteGroup": "Gruppe löschen", "deleteGroupConfirmation": "Bist du sicher, dass du diese Gruppe löschen möchtest?", diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index f85157f..7ad8e48 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -20,11 +20,12 @@ "createNewEvent": "Create new event", "createNewGroup": "Create new group", "createOrJoinGroup": "Create or join group", - "defaultRules": "Default replies", - "defaultRulesDescription": "Choose a default reply to apply to this event", - "defaultRulesDaily": "Daily", - "defaultRulesWeekdays": "Weekdays", - "defaultRulesWeekends": "Weekends", + "defaultReplies": "Default replies", + "defaultRepliesDescription": "Choose a default reply to apply to this event", + "defaultRepliesDaily": "Daily", + "defaultRepliesExplanation": "Default replies allow you to set automatic responses for recurring events. You can choose from daily, weekdays, or weekends options.", + "defaultRepliesWeekdays": "Weekdays", + "defaultRepliesWeekends": "Weekends", "delete": "Delete", "deleteGroup": "Delete group", "deleteGroupConfirmation": "Are you sure you want to delete this group?", diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index 856bc5a..d9fcc07 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -20,11 +20,12 @@ "createNewEvent": "Crea un evento nuevo", "createNewGroup": "Crea un grupo nuevo", "createOrJoinGroup": "Crea o únete a un grupo", - "defaultRules": "Respuestas predeterminadas", - "defaultRulesDescription": "Elige una respuesta predeterminada para este evento", - "defaultRulesDaily": "Diario", - "defaultRulesWeekdays": "Días laborables", - "defaultRulesWeekends": "Fines de semana", + "defaultReplies": "Respuestas predeterminadas", + "defaultRepliesDescription": "Elige una respuesta predeterminada para este evento", + "defaultRepliesDaily": "Diario", + "defaultRepliesExplanation": "Las respuestas predeterminadas te permiten establecer respuestas automáticas para eventos recurrentes. Puedes elegir entre opciones diarias, de días laborables o de fines de semana.", + "defaultRepliesWeekdays": "Días laborables", + "defaultRepliesWeekends": "Fines de semana", "delete": "Eliminar", "deleteGroup": "Eliminar grupo", "deleteGroupConfirmation": "¿Estás seguro de que quieres eliminar este grupo?", diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index 4f4e59f..87f2393 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -20,11 +20,12 @@ "createNewEvent": "Crée un nouvel événement", "createNewGroup": "Crée un nouveau groupe", "createOrJoinGroup": "Crée ou rejoins un groupe", - "defaultRules": "Réponses par défaut", - "defaultRulesDescription": "Choisis une réponse par défaut pour cet événement", - "defaultRulesDaily": "Quotidien", - "defaultRulesWeekdays": "Jours de semaine", - "defaultRulesWeekends": "Week-ends", + "defaultReplies": "Réponses par défaut", + "defaultRepliesDescription": "Choisis une réponse par défaut pour cet événement", + "defaultRepliesDaily": "Quotidien", + "defaultRepliesExplanation": "Les réponses par défaut te permettent de définir des réponses automatiques pour les événements récurrents. Tu peux choisir entre des options quotidiennes, en semaine ou le week-end.", + "defaultRepliesWeekdays": "Jours de semaine", + "defaultRepliesWeekends": "Week-ends", "delete": "Supprime", "deleteGroup": "Supprime le groupe", "deleteGroupConfirmation": "Es-tu sûr de vouloir supprimer ce groupe?", diff --git a/lib/l10n/app_it.arb b/lib/l10n/app_it.arb index 578953a..932121a 100644 --- a/lib/l10n/app_it.arb +++ b/lib/l10n/app_it.arb @@ -20,11 +20,12 @@ "createNewEvent": "Crea un nuovo evento", "createNewGroup": "Crea un nuovo gruppo", "createOrJoinGroup": "Crea o unisciti a un gruppo", - "defaultRules": "Risposte predefinite", - "defaultRulesDescription": "Scegli una risposta predefinita per questo evento", - "defaultRulesDaily": "Giornaliero", - "defaultRulesWeekdays": "Giorni feriali", - "defaultRulesWeekends": "Fine settimana", + "defaultReplies": "Risposte predefinite", + "defaultRepliesDescription": "Scegli una risposta predefinita per questo evento", + "defaultRepliesExplanation": "Le risposte predefinite ti permettono di impostare risposte automatiche per eventi ricorrenti. Puoi scegliere tra opzioni giornaliere, nei giorni feriali o nei fine settimana.", + "defaultRepliesDaily": "Giornaliero", + "defaultRepliesWeekdays": "Giorni feriali", + "defaultRepliesWeekends": "Fine settimana", "delete": "Elimina", "deleteGroup": "Elimina gruppo", "deleteGroupConfirmation": "Sei sicuro di voler eliminare questo gruppo?", diff --git a/lib/main.dart b/lib/main.dart index 6ef5e21..da22746 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -54,7 +54,7 @@ Future main() async { } Future> _initStore(SupabaseClient supabase) async { - final defaultRulesRepository = DefaultRulesRepository(supabase: supabase); + final defaultRepliesRepository = DefaultRepliesRepository(supabase: supabase); final groupsRepository = GroupsRepository(supabase: supabase); final membersRepository = MembersRepository(supabase: supabase); final invitesRepository = InvitesRepository(supabase: supabase); @@ -66,7 +66,7 @@ Future> _initStore(SupabaseClient supabase) async { final epics = combineEpics([ createRouterEpics(router), createAuthEpics(), - createDefaultRulesEpics(defaultRulesRepository), + createDefaultRepliesEpics(defaultRepliesRepository), createGroupsEpics(groupsRepository), createMembersEpic(membersRepository), createInvitesEpics(invitesRepository), diff --git a/lib/models/default_rule.dart b/lib/models/default_reply.dart similarity index 62% rename from lib/models/default_rule.dart rename to lib/models/default_reply.dart index f381786..4610be1 100644 --- a/lib/models/default_rule.dart +++ b/lib/models/default_reply.dart @@ -4,22 +4,22 @@ import 'package:rrule/rrule.dart'; import 'enum.dart'; -part 'default_rule.freezed.dart'; +part 'default_reply.freezed.dart'; -part 'default_rule.g.dart'; +part 'default_reply.g.dart'; @freezed -sealed class DefaultRule with _$DefaultRule { +sealed class DefaultReply with _$DefaultReply { @JsonSerializable(fieldRename: FieldRename.snake) - const factory DefaultRule({ + const factory DefaultReply({ required int memberId, required int scheduleId, required ReplyOptions selectedOption, required RecurrenceRule recurrenceRule, DateTime? createdAt, DateTime? updatedAt, - }) = _DefaultRule; + }) = _DefaultReply; - factory DefaultRule.fromJson(Map json) => - _$DefaultRuleFromJson(json); + factory DefaultReply.fromJson(Map json) => + _$DefaultReplyFromJson(json); } diff --git a/lib/models/default_rule.freezed.dart b/lib/models/default_reply.freezed.dart similarity index 77% rename from lib/models/default_rule.freezed.dart rename to lib/models/default_reply.freezed.dart index 6eba860..a86be6d 100644 --- a/lib/models/default_rule.freezed.dart +++ b/lib/models/default_reply.freezed.dart @@ -3,7 +3,7 @@ // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark -part of 'default_rule.dart'; +part of 'default_reply.dart'; // ************************************************************************** // FreezedGenerator @@ -14,12 +14,12 @@ T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); -DefaultRule _$DefaultRuleFromJson(Map json) { - return _DefaultRule.fromJson(json); +DefaultReply _$DefaultReplyFromJson(Map json) { + return _DefaultReply.fromJson(json); } /// @nodoc -mixin _$DefaultRule { +mixin _$DefaultReply { int get memberId => throw _privateConstructorUsedError; int get scheduleId => throw _privateConstructorUsedError; ReplyOptions get selectedOption => throw _privateConstructorUsedError; @@ -27,21 +27,21 @@ mixin _$DefaultRule { DateTime? get createdAt => throw _privateConstructorUsedError; DateTime? get updatedAt => throw _privateConstructorUsedError; - /// Serializes this DefaultRule to a JSON map. + /// Serializes this DefaultReply to a JSON map. Map toJson() => throw _privateConstructorUsedError; - /// Create a copy of DefaultRule + /// Create a copy of DefaultReply /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) - $DefaultRuleCopyWith get copyWith => + $DefaultReplyCopyWith get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class $DefaultRuleCopyWith<$Res> { - factory $DefaultRuleCopyWith( - DefaultRule value, $Res Function(DefaultRule) then) = - _$DefaultRuleCopyWithImpl<$Res, DefaultRule>; +abstract class $DefaultReplyCopyWith<$Res> { + factory $DefaultReplyCopyWith( + DefaultReply value, $Res Function(DefaultReply) then) = + _$DefaultReplyCopyWithImpl<$Res, DefaultReply>; @useResult $Res call( {int memberId, @@ -53,16 +53,16 @@ abstract class $DefaultRuleCopyWith<$Res> { } /// @nodoc -class _$DefaultRuleCopyWithImpl<$Res, $Val extends DefaultRule> - implements $DefaultRuleCopyWith<$Res> { - _$DefaultRuleCopyWithImpl(this._value, this._then); +class _$DefaultReplyCopyWithImpl<$Res, $Val extends DefaultReply> + implements $DefaultReplyCopyWith<$Res> { + _$DefaultReplyCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of DefaultRule + /// Create a copy of DefaultReply /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override @@ -104,11 +104,11 @@ class _$DefaultRuleCopyWithImpl<$Res, $Val extends DefaultRule> } /// @nodoc -abstract class _$$DefaultRuleImplCopyWith<$Res> - implements $DefaultRuleCopyWith<$Res> { - factory _$$DefaultRuleImplCopyWith( - _$DefaultRuleImpl value, $Res Function(_$DefaultRuleImpl) then) = - __$$DefaultRuleImplCopyWithImpl<$Res>; +abstract class _$$DefaultReplyImplCopyWith<$Res> + implements $DefaultReplyCopyWith<$Res> { + factory _$$DefaultReplyImplCopyWith( + _$DefaultReplyImpl value, $Res Function(_$DefaultReplyImpl) then) = + __$$DefaultReplyImplCopyWithImpl<$Res>; @override @useResult $Res call( @@ -121,14 +121,14 @@ abstract class _$$DefaultRuleImplCopyWith<$Res> } /// @nodoc -class __$$DefaultRuleImplCopyWithImpl<$Res> - extends _$DefaultRuleCopyWithImpl<$Res, _$DefaultRuleImpl> - implements _$$DefaultRuleImplCopyWith<$Res> { - __$$DefaultRuleImplCopyWithImpl( - _$DefaultRuleImpl _value, $Res Function(_$DefaultRuleImpl) _then) +class __$$DefaultReplyImplCopyWithImpl<$Res> + extends _$DefaultReplyCopyWithImpl<$Res, _$DefaultReplyImpl> + implements _$$DefaultReplyImplCopyWith<$Res> { + __$$DefaultReplyImplCopyWithImpl( + _$DefaultReplyImpl _value, $Res Function(_$DefaultReplyImpl) _then) : super(_value, _then); - /// Create a copy of DefaultRule + /// Create a copy of DefaultReply /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override @@ -140,7 +140,7 @@ class __$$DefaultRuleImplCopyWithImpl<$Res> Object? createdAt = freezed, Object? updatedAt = freezed, }) { - return _then(_$DefaultRuleImpl( + return _then(_$DefaultReplyImpl( memberId: null == memberId ? _value.memberId : memberId // ignore: cast_nullable_to_non_nullable @@ -172,8 +172,8 @@ class __$$DefaultRuleImplCopyWithImpl<$Res> /// @nodoc @JsonSerializable(fieldRename: FieldRename.snake) -class _$DefaultRuleImpl with DiagnosticableTreeMixin implements _DefaultRule { - const _$DefaultRuleImpl( +class _$DefaultReplyImpl with DiagnosticableTreeMixin implements _DefaultReply { + const _$DefaultReplyImpl( {required this.memberId, required this.scheduleId, required this.selectedOption, @@ -181,8 +181,8 @@ class _$DefaultRuleImpl with DiagnosticableTreeMixin implements _DefaultRule { this.createdAt, this.updatedAt}); - factory _$DefaultRuleImpl.fromJson(Map json) => - _$$DefaultRuleImplFromJson(json); + factory _$DefaultReplyImpl.fromJson(Map json) => + _$$DefaultReplyImplFromJson(json); @override final int memberId; @@ -199,14 +199,14 @@ class _$DefaultRuleImpl with DiagnosticableTreeMixin implements _DefaultRule { @override String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { - return 'DefaultRule(memberId: $memberId, scheduleId: $scheduleId, selectedOption: $selectedOption, recurrenceRule: $recurrenceRule, createdAt: $createdAt, updatedAt: $updatedAt)'; + return 'DefaultReply(memberId: $memberId, scheduleId: $scheduleId, selectedOption: $selectedOption, recurrenceRule: $recurrenceRule, createdAt: $createdAt, updatedAt: $updatedAt)'; } @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); properties - ..add(DiagnosticsProperty('type', 'DefaultRule')) + ..add(DiagnosticsProperty('type', 'DefaultReply')) ..add(DiagnosticsProperty('memberId', memberId)) ..add(DiagnosticsProperty('scheduleId', scheduleId)) ..add(DiagnosticsProperty('selectedOption', selectedOption)) @@ -219,7 +219,7 @@ class _$DefaultRuleImpl with DiagnosticableTreeMixin implements _DefaultRule { bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$DefaultRuleImpl && + other is _$DefaultReplyImpl && (identical(other.memberId, memberId) || other.memberId == memberId) && (identical(other.scheduleId, scheduleId) || @@ -239,33 +239,33 @@ class _$DefaultRuleImpl with DiagnosticableTreeMixin implements _DefaultRule { int get hashCode => Object.hash(runtimeType, memberId, scheduleId, selectedOption, recurrenceRule, createdAt, updatedAt); - /// Create a copy of DefaultRule + /// Create a copy of DefaultReply /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') - _$$DefaultRuleImplCopyWith<_$DefaultRuleImpl> get copyWith => - __$$DefaultRuleImplCopyWithImpl<_$DefaultRuleImpl>(this, _$identity); + _$$DefaultReplyImplCopyWith<_$DefaultReplyImpl> get copyWith => + __$$DefaultReplyImplCopyWithImpl<_$DefaultReplyImpl>(this, _$identity); @override Map toJson() { - return _$$DefaultRuleImplToJson( + return _$$DefaultReplyImplToJson( this, ); } } -abstract class _DefaultRule implements DefaultRule { - const factory _DefaultRule( +abstract class _DefaultReply implements DefaultReply { + const factory _DefaultReply( {required final int memberId, required final int scheduleId, required final ReplyOptions selectedOption, required final RecurrenceRule recurrenceRule, final DateTime? createdAt, - final DateTime? updatedAt}) = _$DefaultRuleImpl; + final DateTime? updatedAt}) = _$DefaultReplyImpl; - factory _DefaultRule.fromJson(Map json) = - _$DefaultRuleImpl.fromJson; + factory _DefaultReply.fromJson(Map json) = + _$DefaultReplyImpl.fromJson; @override int get memberId; @@ -280,10 +280,10 @@ abstract class _DefaultRule implements DefaultRule { @override DateTime? get updatedAt; - /// Create a copy of DefaultRule + /// Create a copy of DefaultReply /// with the given fields replaced by the non-null parameter values. @override @JsonKey(includeFromJson: false, includeToJson: false) - _$$DefaultRuleImplCopyWith<_$DefaultRuleImpl> get copyWith => + _$$DefaultReplyImplCopyWith<_$DefaultReplyImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/models/default_rule.g.dart b/lib/models/default_reply.g.dart similarity index 85% rename from lib/models/default_rule.g.dart rename to lib/models/default_reply.g.dart index cadd9f6..ecc1d4c 100644 --- a/lib/models/default_rule.g.dart +++ b/lib/models/default_reply.g.dart @@ -1,13 +1,13 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'default_rule.dart'; +part of 'default_reply.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** -_$DefaultRuleImpl _$$DefaultRuleImplFromJson(Map json) => - _$DefaultRuleImpl( +_$DefaultReplyImpl _$$DefaultReplyImplFromJson(Map json) => + _$DefaultReplyImpl( memberId: (json['member_id'] as num).toInt(), scheduleId: (json['schedule_id'] as num).toInt(), selectedOption: @@ -22,7 +22,7 @@ _$DefaultRuleImpl _$$DefaultRuleImplFromJson(Map json) => : DateTime.parse(json['updated_at'] as String), ); -Map _$$DefaultRuleImplToJson(_$DefaultRuleImpl instance) => +Map _$$DefaultReplyImplToJson(_$DefaultReplyImpl instance) => { 'member_id': instance.memberId, 'schedule_id': instance.scheduleId, diff --git a/lib/models/models.dart b/lib/models/models.dart index 2f643a0..9956f9a 100644 --- a/lib/models/models.dart +++ b/lib/models/models.dart @@ -1,4 +1,4 @@ -export 'default_rule.dart'; +export 'default_reply.dart'; export 'enum.dart'; export 'group.dart'; export 'invite.dart'; diff --git a/lib/models/schedule_summary.dart b/lib/models/schedule_summary.dart index 98befee..3fde0d4 100644 --- a/lib/models/schedule_summary.dart +++ b/lib/models/schedule_summary.dart @@ -15,12 +15,12 @@ sealed class ScheduleInstanceSummary with _$ScheduleInstanceSummary { required String displayName, required DateTime instanceDate, required Map memberReplies, - required Map memberDefaultReplies, - required Map memberDefaultRules, + required Map memberDefaultReplyOptions, + required Map memberDefaultReplies, required int yesCount, ReplyOptions? myReply, - ReplyOptions? myDefaultReply, - DefaultRule? myDefaultRule, + ReplyOptions? myDefaultReplyOption, + DefaultReply? myDefaultReply, int? targetMemberId, }) = _ScheduleInstanceSummary; } @@ -36,12 +36,12 @@ sealed class ScheduleInstanceDetails with _$ScheduleInstanceDetails { required DateTime instanceDate, required List<(Member, Profile?)> members, required Map memberReplies, - required Map memberDefaultReplies, - required Map memberDefaultRules, + required Map memberDefaultReplyOptions, + required Map memberDefaultReplies, required int yesCount, ReplyOptions? myReply, - ReplyOptions? myDefaultReply, - DefaultRule? myDefaultRule, + ReplyOptions? myDefaultReplyOption, + DefaultReply? myDefaultReply, int? targetMemberId, bool? canEditOthers, }) = _ScheduleInstanceDetails; diff --git a/lib/models/schedule_summary.freezed.dart b/lib/models/schedule_summary.freezed.dart index 3c2b9ee..7031290 100644 --- a/lib/models/schedule_summary.freezed.dart +++ b/lib/models/schedule_summary.freezed.dart @@ -22,14 +22,14 @@ mixin _$ScheduleInstanceSummary { DateTime get instanceDate => throw _privateConstructorUsedError; Map get memberReplies => throw _privateConstructorUsedError; - Map get memberDefaultReplies => + Map get memberDefaultReplyOptions => throw _privateConstructorUsedError; - Map get memberDefaultRules => + Map get memberDefaultReplies => throw _privateConstructorUsedError; int get yesCount => throw _privateConstructorUsedError; ReplyOptions? get myReply => throw _privateConstructorUsedError; - ReplyOptions? get myDefaultReply => throw _privateConstructorUsedError; - DefaultRule? get myDefaultRule => throw _privateConstructorUsedError; + ReplyOptions? get myDefaultReplyOption => throw _privateConstructorUsedError; + DefaultReply? get myDefaultReply => throw _privateConstructorUsedError; int? get targetMemberId => throw _privateConstructorUsedError; /// Create a copy of ScheduleInstanceSummary @@ -51,15 +51,15 @@ abstract class $ScheduleInstanceSummaryCopyWith<$Res> { String displayName, DateTime instanceDate, Map memberReplies, - Map memberDefaultReplies, - Map memberDefaultRules, + Map memberDefaultReplyOptions, + Map memberDefaultReplies, int yesCount, ReplyOptions? myReply, - ReplyOptions? myDefaultReply, - DefaultRule? myDefaultRule, + ReplyOptions? myDefaultReplyOption, + DefaultReply? myDefaultReply, int? targetMemberId}); - $DefaultRuleCopyWith<$Res>? get myDefaultRule; + $DefaultReplyCopyWith<$Res>? get myDefaultReply; } /// @nodoc @@ -83,12 +83,12 @@ class _$ScheduleInstanceSummaryCopyWithImpl<$Res, Object? displayName = null, Object? instanceDate = null, Object? memberReplies = null, + Object? memberDefaultReplyOptions = null, Object? memberDefaultReplies = null, - Object? memberDefaultRules = null, Object? yesCount = null, Object? myReply = freezed, + Object? myDefaultReplyOption = freezed, Object? myDefaultReply = freezed, - Object? myDefaultRule = freezed, Object? targetMemberId = freezed, }) { return _then(_value.copyWith( @@ -112,14 +112,14 @@ class _$ScheduleInstanceSummaryCopyWithImpl<$Res, ? _value.memberReplies : memberReplies // ignore: cast_nullable_to_non_nullable as Map, + memberDefaultReplyOptions: null == memberDefaultReplyOptions + ? _value.memberDefaultReplyOptions + : memberDefaultReplyOptions // ignore: cast_nullable_to_non_nullable + as Map, memberDefaultReplies: null == memberDefaultReplies ? _value.memberDefaultReplies : memberDefaultReplies // ignore: cast_nullable_to_non_nullable - as Map, - memberDefaultRules: null == memberDefaultRules - ? _value.memberDefaultRules - : memberDefaultRules // ignore: cast_nullable_to_non_nullable - as Map, + as Map, yesCount: null == yesCount ? _value.yesCount : yesCount // ignore: cast_nullable_to_non_nullable @@ -128,14 +128,14 @@ class _$ScheduleInstanceSummaryCopyWithImpl<$Res, ? _value.myReply : myReply // ignore: cast_nullable_to_non_nullable as ReplyOptions?, + myDefaultReplyOption: freezed == myDefaultReplyOption + ? _value.myDefaultReplyOption + : myDefaultReplyOption // ignore: cast_nullable_to_non_nullable + as ReplyOptions?, myDefaultReply: freezed == myDefaultReply ? _value.myDefaultReply : myDefaultReply // ignore: cast_nullable_to_non_nullable - as ReplyOptions?, - myDefaultRule: freezed == myDefaultRule - ? _value.myDefaultRule - : myDefaultRule // ignore: cast_nullable_to_non_nullable - as DefaultRule?, + as DefaultReply?, targetMemberId: freezed == targetMemberId ? _value.targetMemberId : targetMemberId // ignore: cast_nullable_to_non_nullable @@ -147,13 +147,13 @@ class _$ScheduleInstanceSummaryCopyWithImpl<$Res, /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') - $DefaultRuleCopyWith<$Res>? get myDefaultRule { - if (_value.myDefaultRule == null) { + $DefaultReplyCopyWith<$Res>? get myDefaultReply { + if (_value.myDefaultReply == null) { return null; } - return $DefaultRuleCopyWith<$Res>(_value.myDefaultRule!, (value) { - return _then(_value.copyWith(myDefaultRule: value) as $Val); + return $DefaultReplyCopyWith<$Res>(_value.myDefaultReply!, (value) { + return _then(_value.copyWith(myDefaultReply: value) as $Val); }); } } @@ -173,16 +173,16 @@ abstract class _$$ScheduleInstanceSummaryImplCopyWith<$Res> String displayName, DateTime instanceDate, Map memberReplies, - Map memberDefaultReplies, - Map memberDefaultRules, + Map memberDefaultReplyOptions, + Map memberDefaultReplies, int yesCount, ReplyOptions? myReply, - ReplyOptions? myDefaultReply, - DefaultRule? myDefaultRule, + ReplyOptions? myDefaultReplyOption, + DefaultReply? myDefaultReply, int? targetMemberId}); @override - $DefaultRuleCopyWith<$Res>? get myDefaultRule; + $DefaultReplyCopyWith<$Res>? get myDefaultReply; } /// @nodoc @@ -205,12 +205,12 @@ class __$$ScheduleInstanceSummaryImplCopyWithImpl<$Res> Object? displayName = null, Object? instanceDate = null, Object? memberReplies = null, + Object? memberDefaultReplyOptions = null, Object? memberDefaultReplies = null, - Object? memberDefaultRules = null, Object? yesCount = null, Object? myReply = freezed, + Object? myDefaultReplyOption = freezed, Object? myDefaultReply = freezed, - Object? myDefaultRule = freezed, Object? targetMemberId = freezed, }) { return _then(_$ScheduleInstanceSummaryImpl( @@ -234,14 +234,14 @@ class __$$ScheduleInstanceSummaryImplCopyWithImpl<$Res> ? _value._memberReplies : memberReplies // ignore: cast_nullable_to_non_nullable as Map, + memberDefaultReplyOptions: null == memberDefaultReplyOptions + ? _value._memberDefaultReplyOptions + : memberDefaultReplyOptions // ignore: cast_nullable_to_non_nullable + as Map, memberDefaultReplies: null == memberDefaultReplies ? _value._memberDefaultReplies : memberDefaultReplies // ignore: cast_nullable_to_non_nullable - as Map, - memberDefaultRules: null == memberDefaultRules - ? _value._memberDefaultRules - : memberDefaultRules // ignore: cast_nullable_to_non_nullable - as Map, + as Map, yesCount: null == yesCount ? _value.yesCount : yesCount // ignore: cast_nullable_to_non_nullable @@ -250,14 +250,14 @@ class __$$ScheduleInstanceSummaryImplCopyWithImpl<$Res> ? _value.myReply : myReply // ignore: cast_nullable_to_non_nullable as ReplyOptions?, + myDefaultReplyOption: freezed == myDefaultReplyOption + ? _value.myDefaultReplyOption + : myDefaultReplyOption // ignore: cast_nullable_to_non_nullable + as ReplyOptions?, myDefaultReply: freezed == myDefaultReply ? _value.myDefaultReply : myDefaultReply // ignore: cast_nullable_to_non_nullable - as ReplyOptions?, - myDefaultRule: freezed == myDefaultRule - ? _value.myDefaultRule - : myDefaultRule // ignore: cast_nullable_to_non_nullable - as DefaultRule?, + as DefaultReply?, targetMemberId: freezed == targetMemberId ? _value.targetMemberId : targetMemberId // ignore: cast_nullable_to_non_nullable @@ -277,16 +277,16 @@ class _$ScheduleInstanceSummaryImpl required this.displayName, required this.instanceDate, required final Map memberReplies, - required final Map memberDefaultReplies, - required final Map memberDefaultRules, + required final Map memberDefaultReplyOptions, + required final Map memberDefaultReplies, required this.yesCount, this.myReply, + this.myDefaultReplyOption, this.myDefaultReply, - this.myDefaultRule, this.targetMemberId}) : _memberReplies = memberReplies, - _memberDefaultReplies = memberDefaultReplies, - _memberDefaultRules = memberDefaultRules; + _memberDefaultReplyOptions = memberDefaultReplyOptions, + _memberDefaultReplies = memberDefaultReplies; @override final int scheduleId; @@ -304,22 +304,22 @@ class _$ScheduleInstanceSummaryImpl return EqualUnmodifiableMapView(_memberReplies); } - final Map _memberDefaultReplies; + final Map _memberDefaultReplyOptions; @override - Map get memberDefaultReplies { - if (_memberDefaultReplies is EqualUnmodifiableMapView) - return _memberDefaultReplies; + Map get memberDefaultReplyOptions { + if (_memberDefaultReplyOptions is EqualUnmodifiableMapView) + return _memberDefaultReplyOptions; // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(_memberDefaultReplies); + return EqualUnmodifiableMapView(_memberDefaultReplyOptions); } - final Map _memberDefaultRules; + final Map _memberDefaultReplies; @override - Map get memberDefaultRules { - if (_memberDefaultRules is EqualUnmodifiableMapView) - return _memberDefaultRules; + Map get memberDefaultReplies { + if (_memberDefaultReplies is EqualUnmodifiableMapView) + return _memberDefaultReplies; // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(_memberDefaultRules); + return EqualUnmodifiableMapView(_memberDefaultReplies); } @override @@ -327,15 +327,15 @@ class _$ScheduleInstanceSummaryImpl @override final ReplyOptions? myReply; @override - final ReplyOptions? myDefaultReply; + final ReplyOptions? myDefaultReplyOption; @override - final DefaultRule? myDefaultRule; + final DefaultReply? myDefaultReply; @override final int? targetMemberId; @override String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { - return 'ScheduleInstanceSummary(scheduleId: $scheduleId, groupId: $groupId, displayName: $displayName, instanceDate: $instanceDate, memberReplies: $memberReplies, memberDefaultReplies: $memberDefaultReplies, memberDefaultRules: $memberDefaultRules, yesCount: $yesCount, myReply: $myReply, myDefaultReply: $myDefaultReply, myDefaultRule: $myDefaultRule, targetMemberId: $targetMemberId)'; + return 'ScheduleInstanceSummary(scheduleId: $scheduleId, groupId: $groupId, displayName: $displayName, instanceDate: $instanceDate, memberReplies: $memberReplies, memberDefaultReplyOptions: $memberDefaultReplyOptions, memberDefaultReplies: $memberDefaultReplies, yesCount: $yesCount, myReply: $myReply, myDefaultReplyOption: $myDefaultReplyOption, myDefaultReply: $myDefaultReply, targetMemberId: $targetMemberId)'; } @override @@ -348,12 +348,13 @@ class _$ScheduleInstanceSummaryImpl ..add(DiagnosticsProperty('displayName', displayName)) ..add(DiagnosticsProperty('instanceDate', instanceDate)) ..add(DiagnosticsProperty('memberReplies', memberReplies)) + ..add(DiagnosticsProperty( + 'memberDefaultReplyOptions', memberDefaultReplyOptions)) ..add(DiagnosticsProperty('memberDefaultReplies', memberDefaultReplies)) - ..add(DiagnosticsProperty('memberDefaultRules', memberDefaultRules)) ..add(DiagnosticsProperty('yesCount', yesCount)) ..add(DiagnosticsProperty('myReply', myReply)) + ..add(DiagnosticsProperty('myDefaultReplyOption', myDefaultReplyOption)) ..add(DiagnosticsProperty('myDefaultReply', myDefaultReply)) - ..add(DiagnosticsProperty('myDefaultRule', myDefaultRule)) ..add(DiagnosticsProperty('targetMemberId', targetMemberId)); } @@ -371,17 +372,17 @@ class _$ScheduleInstanceSummaryImpl other.instanceDate == instanceDate) && const DeepCollectionEquality() .equals(other._memberReplies, _memberReplies) && + const DeepCollectionEquality().equals( + other._memberDefaultReplyOptions, _memberDefaultReplyOptions) && const DeepCollectionEquality() .equals(other._memberDefaultReplies, _memberDefaultReplies) && - const DeepCollectionEquality() - .equals(other._memberDefaultRules, _memberDefaultRules) && (identical(other.yesCount, yesCount) || other.yesCount == yesCount) && (identical(other.myReply, myReply) || other.myReply == myReply) && + (identical(other.myDefaultReplyOption, myDefaultReplyOption) || + other.myDefaultReplyOption == myDefaultReplyOption) && (identical(other.myDefaultReply, myDefaultReply) || other.myDefaultReply == myDefaultReply) && - (identical(other.myDefaultRule, myDefaultRule) || - other.myDefaultRule == myDefaultRule) && (identical(other.targetMemberId, targetMemberId) || other.targetMemberId == targetMemberId)); } @@ -394,12 +395,12 @@ class _$ScheduleInstanceSummaryImpl displayName, instanceDate, const DeepCollectionEquality().hash(_memberReplies), + const DeepCollectionEquality().hash(_memberDefaultReplyOptions), const DeepCollectionEquality().hash(_memberDefaultReplies), - const DeepCollectionEquality().hash(_memberDefaultRules), yesCount, myReply, + myDefaultReplyOption, myDefaultReply, - myDefaultRule, targetMemberId); /// Create a copy of ScheduleInstanceSummary @@ -419,12 +420,12 @@ abstract class _ScheduleInstanceSummary implements ScheduleInstanceSummary { required final String displayName, required final DateTime instanceDate, required final Map memberReplies, - required final Map memberDefaultReplies, - required final Map memberDefaultRules, + required final Map memberDefaultReplyOptions, + required final Map memberDefaultReplies, required final int yesCount, final ReplyOptions? myReply, - final ReplyOptions? myDefaultReply, - final DefaultRule? myDefaultRule, + final ReplyOptions? myDefaultReplyOption, + final DefaultReply? myDefaultReply, final int? targetMemberId}) = _$ScheduleInstanceSummaryImpl; @override @@ -438,17 +439,17 @@ abstract class _ScheduleInstanceSummary implements ScheduleInstanceSummary { @override Map get memberReplies; @override - Map get memberDefaultReplies; + Map get memberDefaultReplyOptions; @override - Map get memberDefaultRules; + Map get memberDefaultReplies; @override int get yesCount; @override ReplyOptions? get myReply; @override - ReplyOptions? get myDefaultReply; + ReplyOptions? get myDefaultReplyOption; @override - DefaultRule? get myDefaultRule; + DefaultReply? get myDefaultReply; @override int? get targetMemberId; @@ -469,14 +470,14 @@ mixin _$ScheduleInstanceDetails { List<(Member, Profile?)> get members => throw _privateConstructorUsedError; Map get memberReplies => throw _privateConstructorUsedError; - Map get memberDefaultReplies => + Map get memberDefaultReplyOptions => throw _privateConstructorUsedError; - Map get memberDefaultRules => + Map get memberDefaultReplies => throw _privateConstructorUsedError; int get yesCount => throw _privateConstructorUsedError; ReplyOptions? get myReply => throw _privateConstructorUsedError; - ReplyOptions? get myDefaultReply => throw _privateConstructorUsedError; - DefaultRule? get myDefaultRule => throw _privateConstructorUsedError; + ReplyOptions? get myDefaultReplyOption => throw _privateConstructorUsedError; + DefaultReply? get myDefaultReply => throw _privateConstructorUsedError; int? get targetMemberId => throw _privateConstructorUsedError; bool? get canEditOthers => throw _privateConstructorUsedError; @@ -500,16 +501,16 @@ abstract class $ScheduleInstanceDetailsCopyWith<$Res> { DateTime instanceDate, List<(Member, Profile?)> members, Map memberReplies, - Map memberDefaultReplies, - Map memberDefaultRules, + Map memberDefaultReplyOptions, + Map memberDefaultReplies, int yesCount, ReplyOptions? myReply, - ReplyOptions? myDefaultReply, - DefaultRule? myDefaultRule, + ReplyOptions? myDefaultReplyOption, + DefaultReply? myDefaultReply, int? targetMemberId, bool? canEditOthers}); - $DefaultRuleCopyWith<$Res>? get myDefaultRule; + $DefaultReplyCopyWith<$Res>? get myDefaultReply; } /// @nodoc @@ -534,12 +535,12 @@ class _$ScheduleInstanceDetailsCopyWithImpl<$Res, Object? instanceDate = null, Object? members = null, Object? memberReplies = null, + Object? memberDefaultReplyOptions = null, Object? memberDefaultReplies = null, - Object? memberDefaultRules = null, Object? yesCount = null, Object? myReply = freezed, + Object? myDefaultReplyOption = freezed, Object? myDefaultReply = freezed, - Object? myDefaultRule = freezed, Object? targetMemberId = freezed, Object? canEditOthers = freezed, }) { @@ -568,14 +569,14 @@ class _$ScheduleInstanceDetailsCopyWithImpl<$Res, ? _value.memberReplies : memberReplies // ignore: cast_nullable_to_non_nullable as Map, + memberDefaultReplyOptions: null == memberDefaultReplyOptions + ? _value.memberDefaultReplyOptions + : memberDefaultReplyOptions // ignore: cast_nullable_to_non_nullable + as Map, memberDefaultReplies: null == memberDefaultReplies ? _value.memberDefaultReplies : memberDefaultReplies // ignore: cast_nullable_to_non_nullable - as Map, - memberDefaultRules: null == memberDefaultRules - ? _value.memberDefaultRules - : memberDefaultRules // ignore: cast_nullable_to_non_nullable - as Map, + as Map, yesCount: null == yesCount ? _value.yesCount : yesCount // ignore: cast_nullable_to_non_nullable @@ -584,14 +585,14 @@ class _$ScheduleInstanceDetailsCopyWithImpl<$Res, ? _value.myReply : myReply // ignore: cast_nullable_to_non_nullable as ReplyOptions?, + myDefaultReplyOption: freezed == myDefaultReplyOption + ? _value.myDefaultReplyOption + : myDefaultReplyOption // ignore: cast_nullable_to_non_nullable + as ReplyOptions?, myDefaultReply: freezed == myDefaultReply ? _value.myDefaultReply : myDefaultReply // ignore: cast_nullable_to_non_nullable - as ReplyOptions?, - myDefaultRule: freezed == myDefaultRule - ? _value.myDefaultRule - : myDefaultRule // ignore: cast_nullable_to_non_nullable - as DefaultRule?, + as DefaultReply?, targetMemberId: freezed == targetMemberId ? _value.targetMemberId : targetMemberId // ignore: cast_nullable_to_non_nullable @@ -607,13 +608,13 @@ class _$ScheduleInstanceDetailsCopyWithImpl<$Res, /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') - $DefaultRuleCopyWith<$Res>? get myDefaultRule { - if (_value.myDefaultRule == null) { + $DefaultReplyCopyWith<$Res>? get myDefaultReply { + if (_value.myDefaultReply == null) { return null; } - return $DefaultRuleCopyWith<$Res>(_value.myDefaultRule!, (value) { - return _then(_value.copyWith(myDefaultRule: value) as $Val); + return $DefaultReplyCopyWith<$Res>(_value.myDefaultReply!, (value) { + return _then(_value.copyWith(myDefaultReply: value) as $Val); }); } } @@ -634,17 +635,17 @@ abstract class _$$ScheduleInstanceDetailsImplCopyWith<$Res> DateTime instanceDate, List<(Member, Profile?)> members, Map memberReplies, - Map memberDefaultReplies, - Map memberDefaultRules, + Map memberDefaultReplyOptions, + Map memberDefaultReplies, int yesCount, ReplyOptions? myReply, - ReplyOptions? myDefaultReply, - DefaultRule? myDefaultRule, + ReplyOptions? myDefaultReplyOption, + DefaultReply? myDefaultReply, int? targetMemberId, bool? canEditOthers}); @override - $DefaultRuleCopyWith<$Res>? get myDefaultRule; + $DefaultReplyCopyWith<$Res>? get myDefaultReply; } /// @nodoc @@ -668,12 +669,12 @@ class __$$ScheduleInstanceDetailsImplCopyWithImpl<$Res> Object? instanceDate = null, Object? members = null, Object? memberReplies = null, + Object? memberDefaultReplyOptions = null, Object? memberDefaultReplies = null, - Object? memberDefaultRules = null, Object? yesCount = null, Object? myReply = freezed, + Object? myDefaultReplyOption = freezed, Object? myDefaultReply = freezed, - Object? myDefaultRule = freezed, Object? targetMemberId = freezed, Object? canEditOthers = freezed, }) { @@ -702,14 +703,14 @@ class __$$ScheduleInstanceDetailsImplCopyWithImpl<$Res> ? _value._memberReplies : memberReplies // ignore: cast_nullable_to_non_nullable as Map, + memberDefaultReplyOptions: null == memberDefaultReplyOptions + ? _value._memberDefaultReplyOptions + : memberDefaultReplyOptions // ignore: cast_nullable_to_non_nullable + as Map, memberDefaultReplies: null == memberDefaultReplies ? _value._memberDefaultReplies : memberDefaultReplies // ignore: cast_nullable_to_non_nullable - as Map, - memberDefaultRules: null == memberDefaultRules - ? _value._memberDefaultRules - : memberDefaultRules // ignore: cast_nullable_to_non_nullable - as Map, + as Map, yesCount: null == yesCount ? _value.yesCount : yesCount // ignore: cast_nullable_to_non_nullable @@ -718,14 +719,14 @@ class __$$ScheduleInstanceDetailsImplCopyWithImpl<$Res> ? _value.myReply : myReply // ignore: cast_nullable_to_non_nullable as ReplyOptions?, + myDefaultReplyOption: freezed == myDefaultReplyOption + ? _value.myDefaultReplyOption + : myDefaultReplyOption // ignore: cast_nullable_to_non_nullable + as ReplyOptions?, myDefaultReply: freezed == myDefaultReply ? _value.myDefaultReply : myDefaultReply // ignore: cast_nullable_to_non_nullable - as ReplyOptions?, - myDefaultRule: freezed == myDefaultRule - ? _value.myDefaultRule - : myDefaultRule // ignore: cast_nullable_to_non_nullable - as DefaultRule?, + as DefaultReply?, targetMemberId: freezed == targetMemberId ? _value.targetMemberId : targetMemberId // ignore: cast_nullable_to_non_nullable @@ -750,18 +751,18 @@ class _$ScheduleInstanceDetailsImpl required this.instanceDate, required final List<(Member, Profile?)> members, required final Map memberReplies, - required final Map memberDefaultReplies, - required final Map memberDefaultRules, + required final Map memberDefaultReplyOptions, + required final Map memberDefaultReplies, required this.yesCount, this.myReply, + this.myDefaultReplyOption, this.myDefaultReply, - this.myDefaultRule, this.targetMemberId, this.canEditOthers}) : _members = members, _memberReplies = memberReplies, - _memberDefaultReplies = memberDefaultReplies, - _memberDefaultRules = memberDefaultRules; + _memberDefaultReplyOptions = memberDefaultReplyOptions, + _memberDefaultReplies = memberDefaultReplies; @override final int scheduleId; @@ -787,22 +788,22 @@ class _$ScheduleInstanceDetailsImpl return EqualUnmodifiableMapView(_memberReplies); } - final Map _memberDefaultReplies; + final Map _memberDefaultReplyOptions; @override - Map get memberDefaultReplies { - if (_memberDefaultReplies is EqualUnmodifiableMapView) - return _memberDefaultReplies; + Map get memberDefaultReplyOptions { + if (_memberDefaultReplyOptions is EqualUnmodifiableMapView) + return _memberDefaultReplyOptions; // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(_memberDefaultReplies); + return EqualUnmodifiableMapView(_memberDefaultReplyOptions); } - final Map _memberDefaultRules; + final Map _memberDefaultReplies; @override - Map get memberDefaultRules { - if (_memberDefaultRules is EqualUnmodifiableMapView) - return _memberDefaultRules; + Map get memberDefaultReplies { + if (_memberDefaultReplies is EqualUnmodifiableMapView) + return _memberDefaultReplies; // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(_memberDefaultRules); + return EqualUnmodifiableMapView(_memberDefaultReplies); } @override @@ -810,9 +811,9 @@ class _$ScheduleInstanceDetailsImpl @override final ReplyOptions? myReply; @override - final ReplyOptions? myDefaultReply; + final ReplyOptions? myDefaultReplyOption; @override - final DefaultRule? myDefaultRule; + final DefaultReply? myDefaultReply; @override final int? targetMemberId; @override @@ -820,7 +821,7 @@ class _$ScheduleInstanceDetailsImpl @override String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { - return 'ScheduleInstanceDetails(scheduleId: $scheduleId, groupId: $groupId, displayName: $displayName, instanceDate: $instanceDate, members: $members, memberReplies: $memberReplies, memberDefaultReplies: $memberDefaultReplies, memberDefaultRules: $memberDefaultRules, yesCount: $yesCount, myReply: $myReply, myDefaultReply: $myDefaultReply, myDefaultRule: $myDefaultRule, targetMemberId: $targetMemberId, canEditOthers: $canEditOthers)'; + return 'ScheduleInstanceDetails(scheduleId: $scheduleId, groupId: $groupId, displayName: $displayName, instanceDate: $instanceDate, members: $members, memberReplies: $memberReplies, memberDefaultReplyOptions: $memberDefaultReplyOptions, memberDefaultReplies: $memberDefaultReplies, yesCount: $yesCount, myReply: $myReply, myDefaultReplyOption: $myDefaultReplyOption, myDefaultReply: $myDefaultReply, targetMemberId: $targetMemberId, canEditOthers: $canEditOthers)'; } @override @@ -834,12 +835,13 @@ class _$ScheduleInstanceDetailsImpl ..add(DiagnosticsProperty('instanceDate', instanceDate)) ..add(DiagnosticsProperty('members', members)) ..add(DiagnosticsProperty('memberReplies', memberReplies)) + ..add(DiagnosticsProperty( + 'memberDefaultReplyOptions', memberDefaultReplyOptions)) ..add(DiagnosticsProperty('memberDefaultReplies', memberDefaultReplies)) - ..add(DiagnosticsProperty('memberDefaultRules', memberDefaultRules)) ..add(DiagnosticsProperty('yesCount', yesCount)) ..add(DiagnosticsProperty('myReply', myReply)) + ..add(DiagnosticsProperty('myDefaultReplyOption', myDefaultReplyOption)) ..add(DiagnosticsProperty('myDefaultReply', myDefaultReply)) - ..add(DiagnosticsProperty('myDefaultRule', myDefaultRule)) ..add(DiagnosticsProperty('targetMemberId', targetMemberId)) ..add(DiagnosticsProperty('canEditOthers', canEditOthers)); } @@ -859,17 +861,17 @@ class _$ScheduleInstanceDetailsImpl const DeepCollectionEquality().equals(other._members, _members) && const DeepCollectionEquality() .equals(other._memberReplies, _memberReplies) && + const DeepCollectionEquality().equals( + other._memberDefaultReplyOptions, _memberDefaultReplyOptions) && const DeepCollectionEquality() .equals(other._memberDefaultReplies, _memberDefaultReplies) && - const DeepCollectionEquality() - .equals(other._memberDefaultRules, _memberDefaultRules) && (identical(other.yesCount, yesCount) || other.yesCount == yesCount) && (identical(other.myReply, myReply) || other.myReply == myReply) && + (identical(other.myDefaultReplyOption, myDefaultReplyOption) || + other.myDefaultReplyOption == myDefaultReplyOption) && (identical(other.myDefaultReply, myDefaultReply) || other.myDefaultReply == myDefaultReply) && - (identical(other.myDefaultRule, myDefaultRule) || - other.myDefaultRule == myDefaultRule) && (identical(other.targetMemberId, targetMemberId) || other.targetMemberId == targetMemberId) && (identical(other.canEditOthers, canEditOthers) || @@ -885,12 +887,12 @@ class _$ScheduleInstanceDetailsImpl instanceDate, const DeepCollectionEquality().hash(_members), const DeepCollectionEquality().hash(_memberReplies), + const DeepCollectionEquality().hash(_memberDefaultReplyOptions), const DeepCollectionEquality().hash(_memberDefaultReplies), - const DeepCollectionEquality().hash(_memberDefaultRules), yesCount, myReply, + myDefaultReplyOption, myDefaultReply, - myDefaultRule, targetMemberId, canEditOthers); @@ -912,12 +914,12 @@ abstract class _ScheduleInstanceDetails implements ScheduleInstanceDetails { required final DateTime instanceDate, required final List<(Member, Profile?)> members, required final Map memberReplies, - required final Map memberDefaultReplies, - required final Map memberDefaultRules, + required final Map memberDefaultReplyOptions, + required final Map memberDefaultReplies, required final int yesCount, final ReplyOptions? myReply, - final ReplyOptions? myDefaultReply, - final DefaultRule? myDefaultRule, + final ReplyOptions? myDefaultReplyOption, + final DefaultReply? myDefaultReply, final int? targetMemberId, final bool? canEditOthers}) = _$ScheduleInstanceDetailsImpl; @@ -934,17 +936,17 @@ abstract class _ScheduleInstanceDetails implements ScheduleInstanceDetails { @override Map get memberReplies; @override - Map get memberDefaultReplies; + Map get memberDefaultReplyOptions; @override - Map get memberDefaultRules; + Map get memberDefaultReplies; @override int get yesCount; @override ReplyOptions? get myReply; @override - ReplyOptions? get myDefaultReply; + ReplyOptions? get myDefaultReplyOption; @override - DefaultRule? get myDefaultRule; + DefaultReply? get myDefaultReply; @override int? get targetMemberId; @override diff --git a/lib/presentation/containers/group_schedule_details.dart b/lib/presentation/containers/group_schedule_details.dart index d905d7e..fe262d3 100644 --- a/lib/presentation/containers/group_schedule_details.dart +++ b/lib/presentation/containers/group_schedule_details.dart @@ -34,7 +34,7 @@ class GroupScheduleDetailsContainer extends StatelessWidget { group: vm.group, scheduleInstance: vm.scheduleInstance, onReplyChanged: vm.onReplyChanged, - onDefaultRuleChanged: vm.onDefaultRuleChanged, + onDefaultReplyChanged: vm.onDefaultReplyChanged, ), ); } @@ -47,7 +47,7 @@ sealed class _ViewModel with _$ViewModel { Group? group, ScheduleInstanceDetails? scheduleInstance, OnDetailsReplyChangedCallback? onReplyChanged, - OnDetailsDefaultRuleChangedCallback? onDefaultRuleChanged, + OnDetailsDefaultReplyChangedCallback? onDefaultReplyChanged, }) = __ViewModel; static _ViewModel fromStore(Store store, String groupId) { @@ -77,18 +77,18 @@ sealed class _ViewModel with _$ViewModel { selectedOption: reply))); } }, - onDefaultRuleChanged: (defaultOption, scheduleId, targetMemberId, reply) { - if (defaultOption == null) { - store.dispatch(RequestDeleteDefaultRuleAction( + onDefaultReplyChanged: (defaultReply, scheduleId, targetMemberId, reply) { + if (reply == null || defaultReply == null) { + store.dispatch(RequestDeleteDefaultReplyAction( memberId: targetMemberId, scheduleId: scheduleId, )); } else { - store.dispatch(RequestUpdateOne(DefaultRule( + store.dispatch(RequestUpdateOne(DefaultReply( memberId: targetMemberId, scheduleId: scheduleId, selectedOption: reply, - recurrenceRule: defaultOption))); + recurrenceRule: defaultReply))); } }, ); diff --git a/lib/presentation/containers/group_schedule_details.freezed.dart b/lib/presentation/containers/group_schedule_details.freezed.dart index 8eda428..a5c50d3 100644 --- a/lib/presentation/containers/group_schedule_details.freezed.dart +++ b/lib/presentation/containers/group_schedule_details.freezed.dart @@ -22,7 +22,7 @@ mixin _$ViewModel { throw _privateConstructorUsedError; OnDetailsReplyChangedCallback? get onReplyChanged => throw _privateConstructorUsedError; - OnDetailsDefaultRuleChangedCallback? get onDefaultRuleChanged => + OnDetailsDefaultReplyChangedCallback? get onDefaultReplyChanged => throw _privateConstructorUsedError; /// Create a copy of _ViewModel @@ -43,7 +43,7 @@ abstract class _$ViewModelCopyWith<$Res> { Group? group, ScheduleInstanceDetails? scheduleInstance, OnDetailsReplyChangedCallback? onReplyChanged, - OnDetailsDefaultRuleChangedCallback? onDefaultRuleChanged}); + OnDetailsDefaultReplyChangedCallback? onDefaultReplyChanged}); $GroupCopyWith<$Res>? get group; $ScheduleInstanceDetailsCopyWith<$Res>? get scheduleInstance; @@ -68,7 +68,7 @@ class __$ViewModelCopyWithImpl<$Res, $Val extends _ViewModel> Object? group = freezed, Object? scheduleInstance = freezed, Object? onReplyChanged = freezed, - Object? onDefaultRuleChanged = freezed, + Object? onDefaultReplyChanged = freezed, }) { return _then(_value.copyWith( loading: null == loading @@ -87,10 +87,10 @@ class __$ViewModelCopyWithImpl<$Res, $Val extends _ViewModel> ? _value.onReplyChanged : onReplyChanged // ignore: cast_nullable_to_non_nullable as OnDetailsReplyChangedCallback?, - onDefaultRuleChanged: freezed == onDefaultRuleChanged - ? _value.onDefaultRuleChanged - : onDefaultRuleChanged // ignore: cast_nullable_to_non_nullable - as OnDetailsDefaultRuleChangedCallback?, + onDefaultReplyChanged: freezed == onDefaultReplyChanged + ? _value.onDefaultReplyChanged + : onDefaultReplyChanged // ignore: cast_nullable_to_non_nullable + as OnDetailsDefaultReplyChangedCallback?, ) as $Val); } @@ -137,7 +137,7 @@ abstract class _$$_ViewModelImplCopyWith<$Res> Group? group, ScheduleInstanceDetails? scheduleInstance, OnDetailsReplyChangedCallback? onReplyChanged, - OnDetailsDefaultRuleChangedCallback? onDefaultRuleChanged}); + OnDetailsDefaultReplyChangedCallback? onDefaultReplyChanged}); @override $GroupCopyWith<$Res>? get group; @@ -162,7 +162,7 @@ class __$$_ViewModelImplCopyWithImpl<$Res> Object? group = freezed, Object? scheduleInstance = freezed, Object? onReplyChanged = freezed, - Object? onDefaultRuleChanged = freezed, + Object? onDefaultReplyChanged = freezed, }) { return _then(_$_ViewModelImpl( loading: null == loading @@ -181,10 +181,10 @@ class __$$_ViewModelImplCopyWithImpl<$Res> ? _value.onReplyChanged : onReplyChanged // ignore: cast_nullable_to_non_nullable as OnDetailsReplyChangedCallback?, - onDefaultRuleChanged: freezed == onDefaultRuleChanged - ? _value.onDefaultRuleChanged - : onDefaultRuleChanged // ignore: cast_nullable_to_non_nullable - as OnDetailsDefaultRuleChangedCallback?, + onDefaultReplyChanged: freezed == onDefaultReplyChanged + ? _value.onDefaultReplyChanged + : onDefaultReplyChanged // ignore: cast_nullable_to_non_nullable + as OnDetailsDefaultReplyChangedCallback?, )); } } @@ -197,7 +197,7 @@ class _$_ViewModelImpl with DiagnosticableTreeMixin implements __ViewModel { this.group, this.scheduleInstance, this.onReplyChanged, - this.onDefaultRuleChanged}); + this.onDefaultReplyChanged}); @override final bool loading; @@ -208,11 +208,11 @@ class _$_ViewModelImpl with DiagnosticableTreeMixin implements __ViewModel { @override final OnDetailsReplyChangedCallback? onReplyChanged; @override - final OnDetailsDefaultRuleChangedCallback? onDefaultRuleChanged; + final OnDetailsDefaultReplyChangedCallback? onDefaultReplyChanged; @override String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { - return '_ViewModel(loading: $loading, group: $group, scheduleInstance: $scheduleInstance, onReplyChanged: $onReplyChanged, onDefaultRuleChanged: $onDefaultRuleChanged)'; + return '_ViewModel(loading: $loading, group: $group, scheduleInstance: $scheduleInstance, onReplyChanged: $onReplyChanged, onDefaultReplyChanged: $onDefaultReplyChanged)'; } @override @@ -224,7 +224,8 @@ class _$_ViewModelImpl with DiagnosticableTreeMixin implements __ViewModel { ..add(DiagnosticsProperty('group', group)) ..add(DiagnosticsProperty('scheduleInstance', scheduleInstance)) ..add(DiagnosticsProperty('onReplyChanged', onReplyChanged)) - ..add(DiagnosticsProperty('onDefaultRuleChanged', onDefaultRuleChanged)); + ..add( + DiagnosticsProperty('onDefaultReplyChanged', onDefaultReplyChanged)); } @override @@ -238,13 +239,13 @@ class _$_ViewModelImpl with DiagnosticableTreeMixin implements __ViewModel { other.scheduleInstance == scheduleInstance) && (identical(other.onReplyChanged, onReplyChanged) || other.onReplyChanged == onReplyChanged) && - (identical(other.onDefaultRuleChanged, onDefaultRuleChanged) || - other.onDefaultRuleChanged == onDefaultRuleChanged)); + (identical(other.onDefaultReplyChanged, onDefaultReplyChanged) || + other.onDefaultReplyChanged == onDefaultReplyChanged)); } @override int get hashCode => Object.hash(runtimeType, loading, group, scheduleInstance, - onReplyChanged, onDefaultRuleChanged); + onReplyChanged, onDefaultReplyChanged); /// Create a copy of _ViewModel /// with the given fields replaced by the non-null parameter values. @@ -261,7 +262,7 @@ abstract class __ViewModel implements _ViewModel { final Group? group, final ScheduleInstanceDetails? scheduleInstance, final OnDetailsReplyChangedCallback? onReplyChanged, - final OnDetailsDefaultRuleChangedCallback? onDefaultRuleChanged}) = + final OnDetailsDefaultReplyChangedCallback? onDefaultReplyChanged}) = _$_ViewModelImpl; @override @@ -273,7 +274,7 @@ abstract class __ViewModel implements _ViewModel { @override OnDetailsReplyChangedCallback? get onReplyChanged; @override - OnDetailsDefaultRuleChangedCallback? get onDefaultRuleChanged; + OnDetailsDefaultReplyChangedCallback? get onDefaultReplyChanged; /// Create a copy of _ViewModel /// with the given fields replaced by the non-null parameter values. diff --git a/lib/presentation/screens/group_schedule_details.dart b/lib/presentation/screens/group_schedule_details.dart index fd138d1..caace83 100644 --- a/lib/presentation/screens/group_schedule_details.dart +++ b/lib/presentation/screens/group_schedule_details.dart @@ -14,8 +14,8 @@ typedef OnDetailsReplyChangedCallback = void Function( // ! order of the arguments. It's better to use a data class or a map instead. // TODO(giorgio): I actually just fixed a bug because of this! // I should refactor this to use either branded types or a map. -typedef OnDetailsDefaultRuleChangedCallback = void Function( - RecurrenceRule?, int, int, ReplyOptions); +typedef OnDetailsDefaultReplyChangedCallback = void Function( + RecurrenceRule?, int, int, ReplyOptions?); class GroupScheduleDetailsScreen extends StatelessWidget { final datetimeFormat = DateFormat.yMMMd()..add_jm(); @@ -24,7 +24,7 @@ class GroupScheduleDetailsScreen extends StatelessWidget { final Group? group; final ScheduleInstanceDetails? scheduleInstance; final OnDetailsReplyChangedCallback? onReplyChanged; - final OnDetailsDefaultRuleChangedCallback? onDefaultRuleChanged; + final OnDetailsDefaultReplyChangedCallback? onDefaultReplyChanged; GroupScheduleDetailsScreen({ super.key, @@ -32,7 +32,7 @@ class GroupScheduleDetailsScreen extends StatelessWidget { this.group, this.scheduleInstance, this.onReplyChanged, - this.onDefaultRuleChanged, + this.onDefaultReplyChanged, }); @override @@ -40,8 +40,9 @@ class GroupScheduleDetailsScreen extends StatelessWidget { final l10n = AppLocalizations.of(context)!; final members = scheduleInstance?.members ?? []; final replies = scheduleInstance?.memberReplies ?? {}; + final defaultReplyOptions = + scheduleInstance?.memberDefaultReplyOptions ?? {}; final defaultReplies = scheduleInstance?.memberDefaultReplies ?? {}; - final defaultRules = scheduleInstance?.memberDefaultRules ?? {}; return Scaffold( appBar: AppBar( @@ -58,13 +59,13 @@ class GroupScheduleDetailsScreen extends StatelessWidget { ScheduleMemberTile( name: l10n.you, reply: scheduleInstance?.myReply, + defaultReplyOption: scheduleInstance?.myDefaultReplyOption, defaultReply: scheduleInstance?.myDefaultReply, - defaultRule: scheduleInstance?.myDefaultRule, onReplyChanged: (reply) => onReplyChanged?.call( scheduleInstance!, scheduleInstance!.targetMemberId!, reply), - onDefaultRuleChanged: (defaultOption, reply) => - onDefaultRuleChanged?.call( - defaultOption, + onDefaultReplyChanged: (recurrenceRule, reply) => + onDefaultReplyChanged?.call( + recurrenceRule, scheduleInstance!.scheduleId, scheduleInstance!.targetMemberId!, reply), @@ -78,19 +79,19 @@ class GroupScheduleDetailsScreen extends StatelessWidget { memberProfile?.displayName ?? l10n.unknown; final reply = replies[member.id]; + final defaultReplyOption = defaultReplyOptions[member.id]; final defaultReply = defaultReplies[member.id]; - final defaultRule = defaultRules[member.id]; return ScheduleMemberTile( name: name, reply: reply, + defaultReplyOption: defaultReplyOption, defaultReply: defaultReply, - defaultRule: defaultRule, - onReplyChanged: (r) => - onReplyChanged?.call(scheduleInstance!, member.id, r), - onDefaultRuleChanged: (defaultOption, r) => - onDefaultRuleChanged?.call(defaultOption, - scheduleInstance!.scheduleId, member.id, r), + onReplyChanged: (reply) => + onReplyChanged?.call(scheduleInstance!, member.id, reply), + onDefaultReplyChanged: (recurrenceRule, reply) => + onDefaultReplyChanged?.call(recurrenceRule, + scheduleInstance!.scheduleId, member.id, reply), ); }, ), diff --git a/lib/presentation/widgets/default_rule_action_sheet.dart b/lib/presentation/widgets/default_reply_action_sheet.dart similarity index 51% rename from lib/presentation/widgets/default_rule_action_sheet.dart rename to lib/presentation/widgets/default_reply_action_sheet.dart index e15bc77..d1129bf 100644 --- a/lib/presentation/widgets/default_rule_action_sheet.dart +++ b/lib/presentation/widgets/default_reply_action_sheet.dart @@ -4,16 +4,16 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:parousia/presentation/presentation.dart'; import 'package:parousia/util/util.dart'; import 'package:rrule/rrule.dart'; +import 'package:parousia/models/models.dart'; -/// A widget to display the default reply options. -class DefaultRuleActionSheet extends StatelessWidget { - final RecurrenceRule? selectedDefaultOption; - final ValueSetter onOptionTap; +class DefaultReplyActionSheet extends StatelessWidget { + final RecurrenceRule? recurrenceRule; + final ReplyOptions? replyOption; - const DefaultRuleActionSheet({ + const DefaultReplyActionSheet({ super.key, - this.selectedDefaultOption, - required this.onOptionTap, + this.recurrenceRule, + this.replyOption, }); @override @@ -21,43 +21,29 @@ class DefaultRuleActionSheet extends StatelessWidget { final l10n = AppLocalizations.of(context)!; final options = [ - (CommonRecurrenceRules.daily, l10n.defaultRulesDaily), - (CommonRecurrenceRules.weekdays, l10n.defaultRulesWeekdays), - (CommonRecurrenceRules.weekends, l10n.defaultRulesWeekends), + (CommonRecurrenceRules.daily, l10n.defaultRepliesDaily), + (CommonRecurrenceRules.weekdays, l10n.defaultRepliesWeekdays), + (CommonRecurrenceRules.weekends, l10n.defaultRepliesWeekends), ]; final actions = [ - for (final (rrule, text) in options) + for (final (rule, text) in options) _buildActionSheetAction( context, - onTap: onOptionTap, text: text, - option: rrule, + option: rule, + isSelected: recurrenceRule == rule, + onTap: (replyOption) { + Navigator.pop(context, (rule, replyOption)); + }, ), ]; - if (_isIOS(context)) { - return CupertinoActionSheet( - title: Text(l10n.defaultRules), - message: Text(l10n.defaultRulesDescription), - actions: actions, - cancelButton: _buildActionSheetAction( - context, - onTap: onOptionTap, - text: l10n.cancel, - ), - ); - } - return Wrap( children: [ _buildActionSheetHeader(context), ...actions, - _buildActionSheetAction( - context, - onTap: onOptionTap, - text: l10n.cancel, - ), + _buildExplanationWidget(context), ], ); } @@ -79,7 +65,7 @@ class DefaultRuleActionSheet extends StatelessWidget { child: DefaultTextStyle( style: Theme.of(context).textTheme.titleLarge!, textAlign: textAlign, - child: Text(l10n.defaultRules), + child: Text(l10n.defaultReplies), ), ), Padding( @@ -91,44 +77,38 @@ class DefaultRuleActionSheet extends StatelessWidget { child: DefaultTextStyle( style: Theme.of(context).textTheme.titleMedium!, textAlign: textAlign, - child: Text(l10n.defaultRulesDescription), + child: Text(l10n.defaultRepliesDescription), ), - ) + ), ], ); } Widget _buildActionSheetAction( BuildContext context, { - required ValueSetter onTap, required String text, + required bool isSelected, + required void Function(ReplyOptions?) onTap, RecurrenceRule? option, }) { - final checked = - selectedDefaultOption != null && selectedDefaultOption == option; - - if (_isIOS(context)) { - return CupertinoActionSheetAction( - onPressed: () => onTap(option), - child: Row( - children: [ - if (checked) ...[ - Icon(CupertinoIcons.check_mark, size: 18), - SizedBox(width: 10), - ], - Text(text), - ], - ), - ); - } - return ListTile( - onTap: () => onTap(option), - leading: (checked) ? Icon(Icons.check) : null, title: Text(text), + trailing: ReplyButtons( + reply: isSelected ? replyOption : null, + onReplyChanged: (reply) => onTap(reply), + ), ); } - bool _isIOS(BuildContext context) => - Theme.of(context).platform == TargetPlatform.iOS; + Widget _buildExplanationWidget(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + return Padding( + padding: const EdgeInsets.all(16.0), + child: Text( + l10n.defaultRepliesExplanation, + style: Theme.of(context).textTheme.bodySmall, + textAlign: TextAlign.center, + ), + ); + } } diff --git a/lib/presentation/widgets/reply_button.dart b/lib/presentation/widgets/reply_button.dart index 300de75..bf8b84b 100644 --- a/lib/presentation/widgets/reply_button.dart +++ b/lib/presentation/widgets/reply_button.dart @@ -4,13 +4,13 @@ import 'package:parousia/models/models.dart'; class ReplyButtons extends StatelessWidget { final ReplyOptions? reply; - final ReplyOptions? defaultReply; + final ReplyOptions? defaultReplyOption; final ValueChanged? onReplyChanged; const ReplyButtons({ super.key, this.reply, - this.defaultReply, + this.defaultReplyOption, this.onReplyChanged, }); @@ -23,13 +23,13 @@ class ReplyButtons extends StatelessWidget { children: [ YesButton( reply: reply, - defaultReply: defaultReply, + defaultReplyOption: defaultReplyOption, onReplyChanged: onReplyChanged, ), SizedBox(width: 8), NoButton( reply: reply, - defaultReply: defaultReply, + defaultReplyOption: defaultReplyOption, onReplyChanged: onReplyChanged, ), ], @@ -40,7 +40,7 @@ class ReplyButtons extends StatelessWidget { class ReplyButton extends StatelessWidget { final ReplyOptions option; final ReplyOptions? reply; - final ReplyOptions? defaultReply; + final ReplyOptions? defaultReplyOption; final ValueChanged? onReplyChanged; final IconData activeIcon; final IconData inactiveIcon; @@ -51,7 +51,7 @@ class ReplyButton extends StatelessWidget { super.key, required this.option, this.reply, - this.defaultReply, + this.defaultReplyOption, this.onReplyChanged, required this.activeIcon, required this.inactiveIcon, @@ -67,7 +67,7 @@ class ReplyButton extends StatelessWidget { final focusColor = WidgetStatePropertyAll(activeColor); final isActive = reply == option; - final isDefault = defaultReply == option && reply == null; + final isDefault = defaultReplyOption == option && reply == null; if (isActive) { return IconButton.filled( @@ -101,13 +101,13 @@ class ReplyButton extends StatelessWidget { class YesButton extends StatelessWidget { final ReplyOptions? reply; - final ReplyOptions? defaultReply; + final ReplyOptions? defaultReplyOption; final ValueChanged? onReplyChanged; const YesButton({ super.key, this.reply, - this.defaultReply, + this.defaultReplyOption, this.onReplyChanged, }); @@ -118,7 +118,7 @@ class YesButton extends StatelessWidget { return ReplyButton( option: ReplyOptions.yes, reply: reply, - defaultReply: defaultReply, + defaultReplyOption: defaultReplyOption, onReplyChanged: onReplyChanged, activeIcon: Icons.event_available, inactiveIcon: Icons.event_available_outlined, @@ -130,13 +130,13 @@ class YesButton extends StatelessWidget { class NoButton extends StatelessWidget { final ReplyOptions? reply; - final ReplyOptions? defaultReply; + final ReplyOptions? defaultReplyOption; final ValueChanged? onReplyChanged; const NoButton({ super.key, this.reply, - this.defaultReply, + this.defaultReplyOption, this.onReplyChanged, }); @@ -147,7 +147,7 @@ class NoButton extends StatelessWidget { return ReplyButton( option: ReplyOptions.no, reply: reply, - defaultReply: defaultReply, + defaultReplyOption: defaultReplyOption, onReplyChanged: onReplyChanged, activeIcon: Icons.event_busy, inactiveIcon: Icons.event_busy_outlined, diff --git a/lib/presentation/widgets/schedule_member_tile.dart b/lib/presentation/widgets/schedule_member_tile.dart index 33dc2c0..4130b0c 100644 --- a/lib/presentation/widgets/schedule_member_tile.dart +++ b/lib/presentation/widgets/schedule_member_tile.dart @@ -1,99 +1,68 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:go_router/go_router.dart'; import 'package:parousia/models/models.dart'; import 'package:parousia/presentation/widgets/widgets.dart'; import 'package:rrule/rrule.dart'; -class ScheduleMemberTile extends StatefulWidget { +class ScheduleMemberTile extends StatelessWidget { final String name; final ReplyOptions? reply; - final ReplyOptions? defaultReply; - final DefaultRule? defaultRule; + final ReplyOptions? defaultReplyOption; + final DefaultReply? defaultReply; final Function(ReplyOptions?)? onReplyChanged; - final Function(RecurrenceRule?, ReplyOptions)? onDefaultRuleChanged; + final Function(RecurrenceRule?, ReplyOptions?)? onDefaultReplyChanged; const ScheduleMemberTile({ super.key, required this.name, this.reply, + this.defaultReplyOption, this.defaultReply, - this.defaultRule, this.onReplyChanged, - this.onDefaultRuleChanged, + this.onDefaultReplyChanged, }); - @override - State createState() => _ScheduleMemberTileState(); -} - -class _ScheduleMemberTileState extends State { - RecurrenceRule? selectedDefaultOption; - RecurrenceRule? previousDefaultOption; - - @override - void initState() { - super.initState(); - - selectedDefaultOption = widget.defaultRule?.recurrenceRule; - } - @override Widget build(BuildContext context) { return ListTile( - title: Text(widget.name), + title: Text(name), trailing: ReplyButtons( - reply: widget.reply, - defaultReply: widget.defaultReply, - onReplyChanged: (reply) => widget.onReplyChanged?.call(reply), + reply: reply, + defaultReplyOption: defaultReplyOption, + onReplyChanged: (reply) => onReplyChanged?.call(reply), ), - onLongPress: () => - _confirmDefaultRule(context, widget.reply ?? ReplyOptions.yes), + onTap: () => _confirmDefaultReply(context), ); } /// Shows a confirmation action sheet to define the default reply. - _confirmDefaultRule(BuildContext context, ReplyOptions reply) async { - setState(() { - previousDefaultOption = selectedDefaultOption; - }); - - final isConfirmed = await _confirmDefaultRuleActionSheet( + _confirmDefaultReply(BuildContext context) async { + RecurrenceRule? selectedRecurrenceRule = defaultReply?.recurrenceRule; + ReplyOptions? selectedOption = defaultReply?.selectedOption; + final response = await _confirmDefaultReplyActionSheet( context, - (BuildContext context) => DefaultRuleActionSheet( - selectedDefaultOption: selectedDefaultOption, - onOptionTap: (option) { - if (option == null) { - context.pop(false); - return; - } - - setState(() { - selectedDefaultOption = - (selectedDefaultOption != option) ? option : null; - }); - context.pop(true); - }, + (BuildContext context) => DefaultReplyActionSheet( + recurrenceRule: selectedRecurrenceRule, + replyOption: selectedOption, ), ); - if (isConfirmed == true) { - widget.onDefaultRuleChanged?.call(selectedDefaultOption, reply); + if (response != null) { + final (recurrenceRule, replyOption) = response; + if (recurrenceRule == null) return; - return; + onDefaultReplyChanged?.call(recurrenceRule, replyOption); } - - setState(() { - selectedDefaultOption = previousDefaultOption; - }); } - Future _confirmDefaultRuleActionSheet( + Future<(RecurrenceRule?, ReplyOptions?)?> _confirmDefaultReplyActionSheet( BuildContext context, WidgetBuilder builder) async { final isCupertino = Theme.of(context).platform == TargetPlatform.iOS; return await (isCupertino - ? showCupertinoModalPopup(context: context, builder: builder) - : showModalBottomSheet(context: context, builder: builder)); + ? showCupertinoModalPopup<(RecurrenceRule?, ReplyOptions?)>( + context: context, builder: builder) + : showModalBottomSheet<(RecurrenceRule?, ReplyOptions?)>( + context: context, builder: builder)); } } diff --git a/lib/presentation/widgets/schedule_tile.dart b/lib/presentation/widgets/schedule_tile.dart index 1758f6a..e31d2f0 100644 --- a/lib/presentation/widgets/schedule_tile.dart +++ b/lib/presentation/widgets/schedule_tile.dart @@ -27,7 +27,7 @@ class ScheduleTile extends StatelessWidget { alignment: Alignment.topLeft, child: ReplyButtons( reply: schedule.myReply, - defaultReply: schedule.myDefaultReply, + defaultReplyOption: schedule.myDefaultReplyOption, onReplyChanged: onReplyChanged, ), ), diff --git a/lib/presentation/widgets/widgets.dart b/lib/presentation/widgets/widgets.dart index 30cfae5..fd932cc 100644 --- a/lib/presentation/widgets/widgets.dart +++ b/lib/presentation/widgets/widgets.dart @@ -1,6 +1,6 @@ export 'date_dropdown.dart'; export 'date_fab.dart'; -export 'default_rule_action_sheet.dart'; +export 'default_reply_action_sheet.dart'; export 'delete_profile_tile.dart'; export 'empty_state.dart'; export 'form_builder_recurrence_rule.dart'; diff --git a/lib/reducers/remote_entities.dart b/lib/reducers/remote_entities.dart index fbbbd7b..287c2c1 100644 --- a/lib/reducers/remote_entities.dart +++ b/lib/reducers/remote_entities.dart @@ -21,10 +21,10 @@ final schedulesReducer = selectId: (schedule) => schedule.id.toString(), ); -final defaultRulesReducer = - RemoteEntityReducer, DefaultRule>( - selectId: (defaultRule) => - "${defaultRule.memberId}-${defaultRule.scheduleId}", +final defaultRepliesReducer = + RemoteEntityReducer, DefaultReply>( + selectId: (defaultReply) => + "${defaultReply.memberId}-${defaultReply.scheduleId}", ); final repliesReducer = RemoteEntityReducer, Reply>( diff --git a/lib/reducers/root_reducer.dart b/lib/reducers/root_reducer.dart index dd70913..2c06a2d 100644 --- a/lib/reducers/root_reducer.dart +++ b/lib/reducers/root_reducer.dart @@ -25,7 +25,7 @@ AppState rootReducer(AppState state, dynamic action) { members: membersReducer(state.members, action), invites: invitesReducer(state.invites, action), schedules: schedulesReducer(state.schedules, action), - defaultRules: defaultRulesReducer(state.defaultRules, action), + defaultReplies: defaultRepliesReducer(state.defaultReplies, action), replies: repliesReducer(state.replies, action), auth: authReducer(state.auth, action), themeMode: themeReducer(state.themeMode, action), diff --git a/lib/repositories/default_rules.dart b/lib/repositories/default_replies.dart similarity index 61% rename from lib/repositories/default_rules.dart rename to lib/repositories/default_replies.dart index d3eb819..221255b 100644 --- a/lib/repositories/default_rules.dart +++ b/lib/repositories/default_replies.dart @@ -3,18 +3,18 @@ import 'package:parousia/models/models.dart'; import 'const.dart'; import 'supabase.dart'; -class DefaultRulesRepository extends SupabaseRepository with Postgrest { - DefaultRulesRepository({required super.supabase}) +class DefaultRepliesRepository extends SupabaseRepository with Postgrest { + DefaultRepliesRepository({required super.supabase}) : super(tableName: Tables.default_replies); - Future> getDefaultRules(int groupId) async { + Future> getDefaultReplies(int groupId) async { return table() .select('*,members!inner(*)') .eq('members.group_id', groupId) - .withConverter((data) => data.map(DefaultRule.fromJson)); + .withConverter((data) => data.map(DefaultReply.fromJson)); } - Future createDefaultRule(DefaultRule reply) async { + Future createDefaultReply(DefaultReply reply) async { return table() .upsert({ 'schedule_id': reply.scheduleId, @@ -24,10 +24,10 @@ class DefaultRulesRepository extends SupabaseRepository with Postgrest { }) .select() .single() - .withConverter((data) => DefaultRule.fromJson(data)); + .withConverter((data) => DefaultReply.fromJson(data)); } - Future deleteDefaultRule( + Future deleteDefaultReply( {required int memberId, required int scheduleId}) async { return table() .delete() diff --git a/lib/repositories/repositories.dart b/lib/repositories/repositories.dart index 80ba372..467768f 100644 --- a/lib/repositories/repositories.dart +++ b/lib/repositories/repositories.dart @@ -1,4 +1,4 @@ -export 'default_rules.dart'; +export 'default_replies.dart'; export 'groups.dart'; export 'invites.dart'; export 'members.dart'; diff --git a/lib/selectors/schedules.dart b/lib/selectors/schedules.dart index 56516d4..f65c0f3 100644 --- a/lib/selectors/schedules.dart +++ b/lib/selectors/schedules.dart @@ -6,29 +6,29 @@ ScheduleInstanceSummary repliesForScheduleInstance({ required Schedule schedule, required DateTime startDate, required DateTime endDate, - Iterable? defaultRules, + Iterable? defaultReplies, Iterable? replies, int? targetMemberId, }) { final allReplies = {}; final memberReplies = {}; - final memberDefaultReplies = {}; - final memberDefaultRules = {}; + final memberDefaultReplyOptions = {}; + final memberDefaultReplies = {}; ReplyOptions? myReply; - ReplyOptions? myDefaultReply; - DefaultRule? myDefaultRule; + ReplyOptions? myDefaultReplyOption; + DefaultReply? myDefaultReply; - defaultRules?.forEach((defaultRule) { - if (defaultRule.scheduleId == schedule.id) { - if (defaultRule.memberId == targetMemberId) { - myDefaultRule = defaultRule; + defaultReplies?.forEach((defaultReply) { + if (defaultReply.scheduleId == schedule.id) { + if (defaultReply.memberId == targetMemberId) { + myDefaultReply = defaultReply; } else { - memberDefaultRules[defaultRule.memberId] = defaultRule; + memberDefaultReplies[defaultReply.memberId] = defaultReply; } } - defaultRule.recurrenceRule + defaultReply.recurrenceRule .getInstances( start: schedule.startDate, after: startDate, @@ -37,16 +37,16 @@ ScheduleInstanceSummary repliesForScheduleInstance({ ) .forEach((e) { final isSameDay = e.copyWith(isUtc: true).isAtSameMomentAs(instanceDate); - final isSameSchedule = defaultRule.scheduleId == schedule.id; + final isSameSchedule = defaultReply.scheduleId == schedule.id; if (isSameDay && isSameSchedule) { - if (defaultRule.memberId == targetMemberId) { - myDefaultReply = defaultRule.selectedOption; + if (defaultReply.memberId == targetMemberId) { + myDefaultReplyOption = defaultReply.selectedOption; } else { - memberDefaultReplies[defaultRule.memberId] = - defaultRule.selectedOption; + memberDefaultReplyOptions[defaultReply.memberId] = + defaultReply.selectedOption; } - allReplies[defaultRule.memberId] = defaultRule.selectedOption; + allReplies[defaultReply.memberId] = defaultReply.selectedOption; } }); }); @@ -77,12 +77,12 @@ ScheduleInstanceSummary repliesForScheduleInstance({ displayName: schedule.displayName, instanceDate: instanceDate, memberReplies: memberReplies, + memberDefaultReplyOptions: memberDefaultReplyOptions, memberDefaultReplies: memberDefaultReplies, - memberDefaultRules: memberDefaultRules, yesCount: yesCount, myReply: myReply, + myDefaultReplyOption: myDefaultReplyOption, myDefaultReply: myDefaultReply, - myDefaultRule: myDefaultRule, targetMemberId: targetMemberId, ); } @@ -91,7 +91,7 @@ Iterable getScheduleInstances({ required Schedule schedule, required DateTime startDate, required DateTime endDate, - Iterable? defaultRules, + Iterable? defaultReplies, Iterable? replies, int? targetMemberId, }) { @@ -108,7 +108,7 @@ Iterable getScheduleInstances({ (e) => repliesForScheduleInstance( instanceDate: e, schedule: schedule, - defaultRules: defaultRules, + defaultReplies: defaultReplies, replies: replies, startDate: after, endDate: endDate, diff --git a/lib/selectors/selectors.dart b/lib/selectors/selectors.dart index a8990d1..e11d5ca 100644 --- a/lib/selectors/selectors.dart +++ b/lib/selectors/selectors.dart @@ -55,8 +55,8 @@ final selectGroup = createSelector2( Iterable selectScheduleEntities(AppState state) => state.schedules.entities.values; -Iterable selectAllDefaultRules(AppState state) => - state.defaultRules.entities.values; +Iterable selectAllDefaultReplies(AppState state) => + state.defaultReplies.entities.values; Iterable selectAllReplies(AppState state) => state.replies.entities.values; @@ -74,8 +74,8 @@ final selectSchedules = createSelector3( final selectSchedulesIds = createSelector1(selectSchedules, (schedules) => schedules.map((s) => s.id)); -final selectDefaultRules = createSelector2( - selectAllDefaultRules, +final selectDefaultReplies = createSelector2( + selectAllDefaultReplies, selectSchedulesIds, (replies, scheduleIds) => replies.where((r) => scheduleIds.contains(r.scheduleId))); @@ -91,12 +91,12 @@ final selectScheduleInstancesForSelectedDate = createSelector5( selectedDateRangeSelector, selectMyMember, selectSchedules, - selectDefaultRules, + selectDefaultReplies, selectReplies, - (range, myMember, schedules, defaultRules, replies) => + (range, myMember, schedules, defaultReplies, replies) => schedules.expand((schedule) => getScheduleInstances( schedule: schedule, - defaultRules: defaultRules, + defaultReplies: defaultReplies, replies: replies, startDate: range.start, endDate: range.end, @@ -133,12 +133,13 @@ final selectScheduleInstanceForDate = createSelector3( displayName: instance.displayName, instanceDate: instance.instanceDate, memberReplies: instance.memberReplies, + memberDefaultReplyOptions: instance.memberDefaultReplyOptions, memberDefaultReplies: instance.memberDefaultReplies, - memberDefaultRules: instance.memberDefaultRules, members: members.whereNot((m) => m.$1.id == instance.targetMemberId).toList(), yesCount: instance.yesCount, myReply: instance.myReply, + myDefaultReplyOption: instance.myDefaultReplyOption, myDefaultReply: instance.myDefaultReply, targetMemberId: instance.targetMemberId, canEditOthers: canEditOthers, diff --git a/lib/state/app_state.dart b/lib/state/app_state.dart index 71ddf82..2a0ee22 100644 --- a/lib/state/app_state.dart +++ b/lib/state/app_state.dart @@ -20,8 +20,8 @@ sealed class AppState with _$AppState { @Default(RemoteEntityState()) RemoteEntityState invites, @Default(RemoteEntityState()) RemoteEntityState schedules, - @Default(RemoteEntityState()) - RemoteEntityState defaultRules, + @Default(RemoteEntityState()) + RemoteEntityState defaultReplies, @Default(RemoteEntityState()) RemoteEntityState replies, @Default(AuthState(status: AuthStatus.initial)) AuthState auth, @Default(ThemeMode.system) ThemeMode themeMode, diff --git a/lib/state/app_state.freezed.dart b/lib/state/app_state.freezed.dart index 99575c9..1975e05 100644 --- a/lib/state/app_state.freezed.dart +++ b/lib/state/app_state.freezed.dart @@ -26,7 +26,7 @@ mixin _$AppState { RemoteEntityState get invites => throw _privateConstructorUsedError; RemoteEntityState get schedules => throw _privateConstructorUsedError; - RemoteEntityState get defaultRules => + RemoteEntityState get defaultReplies => throw _privateConstructorUsedError; RemoteEntityState get replies => throw _privateConstructorUsedError; AuthState get auth => throw _privateConstructorUsedError; @@ -57,7 +57,7 @@ abstract class $AppStateCopyWith<$Res> { RemoteEntityState members, RemoteEntityState invites, RemoteEntityState schedules, - RemoteEntityState defaultRules, + RemoteEntityState defaultReplies, RemoteEntityState replies, AuthState auth, ThemeMode themeMode, @@ -90,7 +90,7 @@ class _$AppStateCopyWithImpl<$Res, $Val extends AppState> Object? members = null, Object? invites = null, Object? schedules = null, - Object? defaultRules = null, + Object? defaultReplies = null, Object? replies = null, Object? auth = null, Object? themeMode = null, @@ -120,10 +120,10 @@ class _$AppStateCopyWithImpl<$Res, $Val extends AppState> ? _value.schedules : schedules // ignore: cast_nullable_to_non_nullable as RemoteEntityState, - defaultRules: null == defaultRules - ? _value.defaultRules - : defaultRules // ignore: cast_nullable_to_non_nullable - as RemoteEntityState, + defaultReplies: null == defaultReplies + ? _value.defaultReplies + : defaultReplies // ignore: cast_nullable_to_non_nullable + as RemoteEntityState, replies: null == replies ? _value.replies : replies // ignore: cast_nullable_to_non_nullable @@ -194,7 +194,7 @@ abstract class _$$AppStateImplCopyWith<$Res> RemoteEntityState members, RemoteEntityState invites, RemoteEntityState schedules, - RemoteEntityState defaultRules, + RemoteEntityState defaultReplies, RemoteEntityState replies, AuthState auth, ThemeMode themeMode, @@ -227,7 +227,7 @@ class __$$AppStateImplCopyWithImpl<$Res> Object? members = null, Object? invites = null, Object? schedules = null, - Object? defaultRules = null, + Object? defaultReplies = null, Object? replies = null, Object? auth = null, Object? themeMode = null, @@ -257,10 +257,10 @@ class __$$AppStateImplCopyWithImpl<$Res> ? _value.schedules : schedules // ignore: cast_nullable_to_non_nullable as RemoteEntityState, - defaultRules: null == defaultRules - ? _value.defaultRules - : defaultRules // ignore: cast_nullable_to_non_nullable - as RemoteEntityState, + defaultReplies: null == defaultReplies + ? _value.defaultReplies + : defaultReplies // ignore: cast_nullable_to_non_nullable + as RemoteEntityState, replies: null == replies ? _value.replies : replies // ignore: cast_nullable_to_non_nullable @@ -302,7 +302,7 @@ class _$AppStateImpl with DiagnosticableTreeMixin implements _AppState { this.members = const RemoteEntityState(), this.invites = const RemoteEntityState(), this.schedules = const RemoteEntityState(), - this.defaultRules = const RemoteEntityState(), + this.defaultReplies = const RemoteEntityState(), this.replies = const RemoteEntityState(), this.auth = const AuthState(status: AuthStatus.initial), this.themeMode = ThemeMode.system, @@ -331,7 +331,7 @@ class _$AppStateImpl with DiagnosticableTreeMixin implements _AppState { final RemoteEntityState schedules; @override @JsonKey() - final RemoteEntityState defaultRules; + final RemoteEntityState defaultReplies; @override @JsonKey() final RemoteEntityState replies; @@ -352,7 +352,7 @@ class _$AppStateImpl with DiagnosticableTreeMixin implements _AppState { @override String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { - return 'AppState(profiles: $profiles, groups: $groups, members: $members, invites: $invites, schedules: $schedules, defaultRules: $defaultRules, replies: $replies, auth: $auth, themeMode: $themeMode, selectedDate: $selectedDate, selectedGroupId: $selectedGroupId, selectedScheduleId: $selectedScheduleId, locale: $locale)'; + return 'AppState(profiles: $profiles, groups: $groups, members: $members, invites: $invites, schedules: $schedules, defaultReplies: $defaultReplies, replies: $replies, auth: $auth, themeMode: $themeMode, selectedDate: $selectedDate, selectedGroupId: $selectedGroupId, selectedScheduleId: $selectedScheduleId, locale: $locale)'; } @override @@ -365,7 +365,7 @@ class _$AppStateImpl with DiagnosticableTreeMixin implements _AppState { ..add(DiagnosticsProperty('members', members)) ..add(DiagnosticsProperty('invites', invites)) ..add(DiagnosticsProperty('schedules', schedules)) - ..add(DiagnosticsProperty('defaultRules', defaultRules)) + ..add(DiagnosticsProperty('defaultReplies', defaultReplies)) ..add(DiagnosticsProperty('replies', replies)) ..add(DiagnosticsProperty('auth', auth)) ..add(DiagnosticsProperty('themeMode', themeMode)) @@ -387,8 +387,8 @@ class _$AppStateImpl with DiagnosticableTreeMixin implements _AppState { (identical(other.invites, invites) || other.invites == invites) && (identical(other.schedules, schedules) || other.schedules == schedules) && - (identical(other.defaultRules, defaultRules) || - other.defaultRules == defaultRules) && + (identical(other.defaultReplies, defaultReplies) || + other.defaultReplies == defaultReplies) && (identical(other.replies, replies) || other.replies == replies) && (identical(other.auth, auth) || other.auth == auth) && (identical(other.themeMode, themeMode) || @@ -411,7 +411,7 @@ class _$AppStateImpl with DiagnosticableTreeMixin implements _AppState { members, invites, schedules, - defaultRules, + defaultReplies, replies, auth, themeMode, @@ -443,7 +443,7 @@ abstract class _AppState implements AppState { final RemoteEntityState members, final RemoteEntityState invites, final RemoteEntityState schedules, - final RemoteEntityState defaultRules, + final RemoteEntityState defaultReplies, final RemoteEntityState replies, final AuthState auth, final ThemeMode themeMode, @@ -466,7 +466,7 @@ abstract class _AppState implements AppState { @override RemoteEntityState get schedules; @override - RemoteEntityState get defaultRules; + RemoteEntityState get defaultReplies; @override RemoteEntityState get replies; @override diff --git a/lib/state/app_state.g.dart b/lib/state/app_state.g.dart index 82b9698..538c356 100644 --- a/lib/state/app_state.g.dart +++ b/lib/state/app_state.g.dart @@ -33,11 +33,11 @@ _$AppStateImpl _$$AppStateImplFromJson(Map json) => : RemoteEntityState.fromJson( json['schedules'] as Map, (value) => Schedule.fromJson(value as Map)), - defaultRules: json['defaultRules'] == null - ? const RemoteEntityState() - : RemoteEntityState.fromJson( - json['defaultRules'] as Map, - (value) => DefaultRule.fromJson(value as Map)), + defaultReplies: json['defaultReplies'] == null + ? const RemoteEntityState() + : RemoteEntityState.fromJson( + json['defaultReplies'] as Map, + (value) => DefaultReply.fromJson(value as Map)), replies: json['replies'] == null ? const RemoteEntityState() : RemoteEntityState.fromJson( @@ -63,7 +63,7 @@ Map _$$AppStateImplToJson(_$AppStateImpl instance) => 'members': instance.members, 'invites': instance.invites, 'schedules': instance.schedules, - 'defaultRules': instance.defaultRules, + 'defaultReplies': instance.defaultReplies, 'replies': instance.replies, 'auth': instance.auth, 'themeMode': _$ThemeModeEnumMap[instance.themeMode]!, diff --git a/test/repositories_test.dart b/test/repositories_test.dart index b3085d3..5a2e287 100644 --- a/test/repositories_test.dart +++ b/test/repositories_test.dart @@ -538,8 +538,8 @@ void main() { runWithTemporaryGroup((supabase, group, groupsRepository) async { final membersRepository = MembersRepository(supabase: supabase); final schedulesRepository = SchedulesRepository(supabase: supabase); - final defaultRulesRepository = - DefaultRulesRepository(supabase: supabase); + final defaultRepliesRepository = + DefaultRepliesRepository(supabase: supabase); final member = await membersRepository.addMemberToGroup(group.id, displayName: 'Member invited with code'); @@ -560,8 +560,9 @@ void main() { ), ); - final defaultRule = await defaultRulesRepository.createDefaultRule( - DefaultRule( + final defaultReply = + await defaultRepliesRepository.createDefaultReply( + DefaultReply( scheduleId: schedule.id, memberId: member.id, selectedOption: ReplyOptions.yes, @@ -569,13 +570,14 @@ void main() { ), ); - final list = await defaultRulesRepository.getDefaultRules(group.id); + final list = + await defaultRepliesRepository.getDefaultReplies(group.id); expect(list, hasLength(1)); final schedules = await schedulesRepository.getGroupSchedules(group.id); // TODO - // expect(schedules.single.defaultRules?.single, equals(defaultRule)); + // expect(schedules.single.defaultReplies?.single, equals(defaultReply)); }), ), ); diff --git a/test/schedules_test.dart b/test/schedules_test.dart index 3b11f55..542c72b 100644 --- a/test/schedules_test.dart +++ b/test/schedules_test.dart @@ -29,18 +29,18 @@ void main() { startDate: startDate, recurrenceRule: weekendRecurrenceRule); - final defaultRules = [ - DefaultRule( + final defaultReplies = [ + DefaultReply( memberId: 32, scheduleId: dailySchedule.id, selectedOption: ReplyOptions.yes, recurrenceRule: dailyRecurrenceRule), - DefaultRule( + DefaultReply( memberId: 32, scheduleId: weekendSchedule.id, selectedOption: ReplyOptions.yes, recurrenceRule: weekendRecurrenceRule), - DefaultRule( + DefaultReply( memberId: 33, scheduleId: dailySchedule.id, selectedOption: ReplyOptions.yes, @@ -75,7 +75,7 @@ void main() { final result = getScheduleInstances( schedule: dailySchedule, - defaultRules: defaultRules, + defaultReplies: defaultReplies, replies: replies, startDate: startDate.subtract(const Duration(days: 10)), endDate: endDate,