refactor: Remove BackblazeFormCubit dependency on BackupsCubit

This commit is contained in:
NaiJi 2023-10-04 04:06:08 -03:00
parent 13fae7c19e
commit d6871e448e

View file

@ -2,12 +2,11 @@ import 'dart:async';
import 'package:cubit_form/cubit_form.dart'; import 'package:cubit_form/cubit_form.dart';
import 'package:selfprivacy/config/get_it_config.dart'; import 'package:selfprivacy/config/get_it_config.dart';
import 'package:selfprivacy/logic/api_maps/rest_maps/backblaze.dart'; import 'package:selfprivacy/logic/api_maps/rest_maps/backblaze.dart';
import 'package:selfprivacy/logic/cubit/backups/backups_cubit.dart';
import 'package:selfprivacy/logic/models/hive/backups_credential.dart'; import 'package:selfprivacy/logic/models/hive/backups_credential.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
class BackblazeFormCubit extends FormCubit { class BackblazeFormCubit extends FormCubit {
BackblazeFormCubit(this.backupsCubit) { BackblazeFormCubit(this.onSubmitCallback) {
keyId = FieldCubit( keyId = FieldCubit(
initalValue: '', initalValue: '',
validations: [ validations: [
@ -27,17 +26,17 @@ class BackblazeFormCubit extends FormCubit {
@override @override
FutureOr<void> onSubmit() async { FutureOr<void> onSubmit() async {
await backupsCubit.setBackupsKey( await onSubmitCallback(
keyId.state.value, keyId.state.value,
applicationKey.state.value, applicationKey.state.value,
); );
} }
final BackupsCubit backupsCubit;
late final FieldCubit<String> keyId; late final FieldCubit<String> keyId;
late final FieldCubit<String> applicationKey; late final FieldCubit<String> applicationKey;
final Function(String keyId, String applicationKey) onSubmitCallback;
@override @override
FutureOr<bool> asyncValidation() async { FutureOr<bool> asyncValidation() async {
late GenericResult<bool> backblazeResponse; late GenericResult<bool> backblazeResponse;