Skip to content

Commit

Permalink
chore: generate format fix
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesvedder committed Jun 16, 2024
1 parent 1643dc3 commit 161b8c9
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 56 deletions.
2 changes: 1 addition & 1 deletion designer_v2/lib/features/app_controller.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion designer_v2/lib/features/auth/auth_form_controller.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 15 additions & 12 deletions designer_v2/lib/features/dashboard/dashboard_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,21 @@ class DashboardController extends _$DashboardController
final SearchController searchController = SearchController();

void _subscribeStudies() {
_studiesSubscription = studyRepository.watchAll().listen((wrappedModels) {
print("studyRepository.update");
// Update the controller's state when new studies are available in the repository
final studies = wrappedModels.map((study) => study.model).toList();
state = state.copyWith(
studies: () => AsyncValue.data(studies),
);
}, onError: (Object error) {
state = state.copyWith(
studies: () => AsyncValue.error(error, StackTrace.current),
);
},);
_studiesSubscription = studyRepository.watchAll().listen(
(wrappedModels) {
print("studyRepository.update");
// Update the controller's state when new studies are available in the repository
final studies = wrappedModels.map((study) => study.model).toList();
state = state.copyWith(
studies: () => AsyncValue.data(studies),
);
},
onError: (Object error) {
state = state.copyWith(
studies: () => AsyncValue.error(error, StackTrace.current),
);
},
);
}

void setSearchText(String? text) {
Expand Down
4 changes: 3 additions & 1 deletion designer_v2/lib/features/design/study_form_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ class StudyFormViewModel extends FormViewModel<Study>
/// before the [StudyController]'s [Study] is available (see also: [AsyncValue])
@riverpod
StudyFormViewModel studyFormViewModel(
StudyFormViewModelRef ref, StudyID studyId,) {
StudyFormViewModelRef ref,
StudyID studyId,
) {
print("studyFormViewModel");
final state = ref.watch(studyControllerProvider(studyId));
return StudyFormViewModel(
Expand Down
96 changes: 76 additions & 20 deletions designer_v2/lib/features/design/study_form_providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,79 +25,132 @@ part 'study_form_providers.g.dart';
// - Study Info

@riverpod
StudyInfoFormViewModel studyInfoFormViewModel(StudyInfoFormViewModelRef ref, StudyID studyId) {
StudyInfoFormViewModel studyInfoFormViewModel(
StudyInfoFormViewModelRef ref,
StudyID studyId,
) {
return ref.watch(studyFormViewModelProvider(studyId)).studyInfoFormViewModel;
}

// - Enrollment

@riverpod
EnrollmentFormViewModel enrollmentFormViewModel(EnrollmentFormViewModelRef ref, StudyID studyId) {
EnrollmentFormViewModel enrollmentFormViewModel(
EnrollmentFormViewModelRef ref,
StudyID studyId,
) {
return ref.watch(studyFormViewModelProvider(studyId)).enrollmentFormViewModel;
}

@riverpod
ScreenerQuestionFormViewModel screenerQuestionFormViewModel(ScreenerQuestionFormViewModelRef ref, ScreenerQuestionFormRouteArgs args) {
ScreenerQuestionFormViewModel screenerQuestionFormViewModel(
ScreenerQuestionFormViewModelRef ref,
ScreenerQuestionFormRouteArgs args,
) {
return ref.watch(enrollmentFormViewModelProvider(args.studyId)).provide(args);
}

@riverpod
ConsentItemFormViewModel consentItemFormViewModel(ConsentItemFormViewModelRef ref, ConsentItemFormRouteArgs args) {
return ref.watch(enrollmentFormViewModelProvider(args.studyId)).consentItemDelegate.provide(args);
ConsentItemFormViewModel consentItemFormViewModel(
ConsentItemFormViewModelRef ref,
ConsentItemFormRouteArgs args,
) {
return ref
.watch(enrollmentFormViewModelProvider(args.studyId))
.consentItemDelegate
.provide(args);
}

// - Interventions

@riverpod
InterventionsFormViewModel interventionsFormViewModel(InterventionsFormViewModelRef ref, StudyID studyId) {
return ref.watch(studyFormViewModelProvider(studyId)).interventionsFormViewModel;
InterventionsFormViewModel interventionsFormViewModel(
InterventionsFormViewModelRef ref,
StudyID studyId,
) {
return ref
.watch(studyFormViewModelProvider(studyId))
.interventionsFormViewModel;
}

@riverpod
InterventionFormViewModel interventionFormViewModel(InterventionFormViewModelRef ref, InterventionFormRouteArgs args) {
return ref.watch(interventionsFormViewModelProvider(args.studyId)).provide(args);
InterventionFormViewModel interventionFormViewModel(
InterventionFormViewModelRef ref,
InterventionFormRouteArgs args,
) {
return ref
.watch(interventionsFormViewModelProvider(args.studyId))
.provide(args);
}

@riverpod
InterventionTaskFormViewModel interventionTaskFormViewModel(InterventionTaskFormViewModelRef ref, InterventionTaskFormRouteArgs args) {
InterventionTaskFormViewModel interventionTaskFormViewModel(
InterventionTaskFormViewModelRef ref,
InterventionTaskFormRouteArgs args,
) {
return ref.watch(interventionFormViewModelProvider(args)).provide(args);
}

// - Measurements

@riverpod
MeasurementsFormViewModel measurementsFormViewModel(MeasurementsFormViewModelRef ref, StudyID studyId) {
return ref.watch(studyFormViewModelProvider(studyId)).measurementsFormViewModel;
MeasurementsFormViewModel measurementsFormViewModel(
MeasurementsFormViewModelRef ref,
StudyID studyId,
) {
return ref
.watch(studyFormViewModelProvider(studyId))
.measurementsFormViewModel;
}

@riverpod
MeasurementSurveyFormViewModel surveyFormViewModel(SurveyFormViewModelRef ref, MeasurementFormRouteArgs args) {
return ref.watch(measurementsFormViewModelProvider(args.studyId)).provide(args);
MeasurementSurveyFormViewModel surveyFormViewModel(
SurveyFormViewModelRef ref,
MeasurementFormRouteArgs args,
) {
return ref
.watch(measurementsFormViewModelProvider(args.studyId))
.provide(args);
}

@riverpod
QuestionFormViewModel surveyQuestionFormViewModel(SurveyQuestionFormViewModelRef ref, SurveyQuestionFormRouteArgs args) {
QuestionFormViewModel surveyQuestionFormViewModel(
SurveyQuestionFormViewModelRef ref,
SurveyQuestionFormRouteArgs args,
) {
return ref.watch(surveyFormViewModelProvider(args)).provide(args);
}

// - Reports

@riverpod
ReportsFormViewModel reportsFormViewModel(ReportsFormViewModelRef ref, StudyID studyId) {
ReportsFormViewModel reportsFormViewModel(
ReportsFormViewModelRef ref,
StudyID studyId,
) {
return ref.watch(studyFormViewModelProvider(studyId)).reportsFormViewModel;
}

@riverpod
ReportItemFormViewModel reportItemFormViewModel(ReportItemFormViewModelRef ref, ReportItemFormRouteArgs args) {
return ref.watch(reportsFormViewModelProvider(args.studyId)).reportItemDelegate.provide(args);
ReportItemFormViewModel reportItemFormViewModel(
ReportItemFormViewModelRef ref,
ReportItemFormRouteArgs args,
) {
return ref
.watch(reportsFormViewModelProvider(args.studyId))
.reportItemDelegate
.provide(args);
}

// - Validators

/// Provides the [StudyFormViewModel] for validation purposes with
/// a [StudyFormValidationSet.publish]
@riverpod
StudyFormViewModel studyPublishValidator(StudyPublishValidatorRef ref, StudyID studyId) {
StudyFormViewModel studyPublishValidator(
StudyPublishValidatorRef ref,
StudyID studyId,
) {
final state = ref.watch(studyControllerProvider(studyId));
return StudyFormViewModel(
router: ref.watch(routerProvider),
Expand All @@ -111,7 +164,10 @@ StudyFormViewModel studyPublishValidator(StudyPublishValidatorRef ref, StudyID s
/// Provides the [StudyFormViewModel] for validation purposes with
/// a [StudyFormValidationSet.test]
@riverpod
StudyFormViewModel studyTestValidator(StudyTestValidatorRef ref, StudyID studyId) {
StudyFormViewModel studyTestValidator(
StudyTestValidatorRef ref,
StudyID studyId,
) {
final state = ref.watch(studyControllerProvider(studyId));
return StudyFormViewModel(
router: ref.watch(routerProvider),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ class InviteCodeFormViewModel extends FormViewModel<StudyInvite> {
/// before the [StudyController]'s [Study] is available (see also: [AsyncValue])
@riverpod
InviteCodeFormViewModel inviteCodeFormViewModel(
InviteCodeFormViewModelRef ref, StudyID studyId,) {
InviteCodeFormViewModelRef ref,
StudyID studyId,
) {
print("inviteCodeFormViewModelProvider($studyId");
// Reactively bind to and obtain [StudyController]'s current study
final study = ref
Expand Down
30 changes: 16 additions & 14 deletions designer_v2/lib/features/study/study_controller_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ import 'package:studyu_designer_v2/utils/model_action.dart';

class StudyControllerState extends StudyControllerBaseState
implements IStudyAppBarViewModel, ISyncIndicatorViewModel {
const StudyControllerState(
{required super.studyId,
required super.studyRepository,
required super.router,
required super.currentUser,
super.studyWithMetadata,
this.isDirty = false,
this.syncState = const AsyncValue<void>.data(null),
this.lastSynced,});
const StudyControllerState({
required super.studyId,
required super.studyRepository,
required super.router,
required super.currentUser,
super.studyWithMetadata,
this.isDirty = false,
this.syncState = const AsyncValue<void>.data(null),
this.lastSynced,
});

bool get isPublished => study.value != null && study.value!.published;

Expand All @@ -30,11 +31,12 @@ class StudyControllerState extends StudyControllerBaseState
}
// filter out edit action since we are already editing the study
return withIcons(
studyRepository
.availableActions(studyVal)
.where((action) => action.type != StudyActionType.edit)
.toList(),
studyActionIcons,);
studyRepository
.availableActions(studyVal)
.where((action) => action.type != StudyActionType.edit)
.toList(),
studyActionIcons,
);
}

// - ISyncIndicatorViewModel
Expand Down
4 changes: 3 additions & 1 deletion designer_v2/lib/features/study/study_test_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class StudyTestController extends _$StudyTestController {
@riverpod
PlatformController studyTestPlatformController(
StudyTestPlatformControllerRef ref, StudyID studyId,) {
StudyTestPlatformControllerRef ref,
StudyID studyId,
) {
final state = ref.watch(studyTestControllerProvider(studyId));
PlatformController platformController;
if (!kIsWeb) {
Expand Down
4 changes: 3 additions & 1 deletion designer_v2/lib/repositories/invite_code_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ class InviteCodeRepositoryDelegate

@riverpod
InviteCodeRepository inviteCodeRepository(
InviteCodeRepositoryRef ref, StudyID studyId,) {
InviteCodeRepositoryRef ref,
StudyID studyId,
) {
print("inviteCodeRepositoryProvider($studyId");
// Initialize repository for a given study
final repository = InviteCodeRepository(
Expand Down
8 changes: 4 additions & 4 deletions designer_v2/lib/repositories/study_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class StudyRepositoryDelegate extends IModelRepositoryDelegate<Study> {

@riverpod
StudyRepository studyRepository(StudyRepositoryRef ref) => StudyRepository(
apiClient: ref.watch(apiClientProvider),
authRepository: ref.watch(authRepositoryProvider),
ref: ref,
);
apiClient: ref.watch(apiClientProvider),
authRepository: ref.watch(authRepositoryProvider),
ref: ref,
);

0 comments on commit 161b8c9

Please sign in to comment.