chore: fix all problems

This commit is contained in:
Hugo Pointcheval 2023-02-24 10:12:04 +01:00
parent 31f43c73db
commit 833c4c85b6
Signed by: hugo
GPG Key ID: 3AAC487E131E00BC
11 changed files with 113 additions and 39 deletions

View File

@ -35,7 +35,7 @@ class AlbumsScreen extends BlocScreen<AlbumBloc, AlbumEvent, AlbumState> {
bloc..add(AlbumFetched());
@override
Widget onWrap(BuildContext context, Widget child) => AlbumsWrapperWidget(
Widget parent(BuildContext context, Widget child) => AlbumsWrapperWidget(
child: child,
);

View File

@ -43,7 +43,7 @@ class PhotoDetailsScreen
bloc..load(photoId);
@override
Widget onWrap(BuildContext context, Widget child) =>
Widget parent(BuildContext context, Widget child) =>
PhotoDetailsWrapperWidget(child: child);
@override

View File

@ -37,7 +37,7 @@ class PhotosScreen extends BlocScreen<PhotoBloc, PhotoEvent, PhotoState> {
bloc..add(PhotoFetched(albumId));
@override
Widget onWrap(BuildContext context, Widget child) => PhotosWrapperWidget(
Widget parent(BuildContext context, Widget child) => PhotosWrapperWidget(
child: child,
);

View File

@ -0,0 +1,74 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:example_router/core/constants/form_field.dart';
import 'package:wyatt_authentication_bloc/wyatt_authentication_bloc.dart';
import 'package:wyatt_form_bloc/wyatt_form_bloc.dart';
import 'package:wyatt_type_utils/wyatt_type_utils.dart';
class EditProfileCubit extends FormDataCubitImpl {
final AuthenticationRepository<int> authenticationRepository;
EditProfileCubit(
super._formRepository,
super._formName, {
required this.authenticationRepository,
}) : super();
@override
Future<void> submit() async {
emit(
state.copyWith(
status: FormStatus.submissionInProgress,
),
);
// final user = (await authenticationRepository.getAccount()).ok;
final form = state.form;
final email = form.valueOf<String?>(AuthFormField.email);
final oldPassword = form.valueOf<String?>(AppFormField.oldPassword);
final newPassword = form.valueOf<String?>(AuthFormField.password);
if (email.isNullOrEmpty ||
oldPassword.isNullOrEmpty ||
newPassword.isNullOrEmpty) {
emit(
state.copyWith(
errorMessage: 'An error occured while retrieving data from the form.',
status: FormStatus.submissionFailure,
),
);
}
try {
// await authenticationRepository.signInWithEmailAndPassword(
// email: user?.email ?? '',
// password: oldPassword ?? '',
// );
// await authenticationRepository.reauthenticateWithCredential();
await authenticationRepository.updateEmail(email: email!);
await authenticationRepository.updatePassword(password: newPassword!);
} on Exception catch (e) {
emit(
state.copyWith(
status: FormStatus.submissionFailure,
errorMessage: e.toString(),
),
);
}
emit(state.copyWith(status: FormStatus.submissionSuccess));
}
}

View File

@ -20,6 +20,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
void main() {
BlocOverrides.runZoned(() => runApp(const CounterRepositoryProviderPage()),
blocObserver: CounterObserver());
Bloc.observer = CounterObserver();
runApp(const CounterRepositoryProviderPage());
}

View File

@ -7,24 +7,24 @@ class ExampleCubit extends Cubit<CrudState> {
FutureOr<void> run() async {
while (true) {
await Future.delayed(const Duration(seconds: 1));
await Future<void>.delayed(const Duration(seconds: 1));
emit(CrudLoading());
await Future.delayed(const Duration(seconds: 1));
await Future<void>.delayed(const Duration(seconds: 1));
emit(const CrudError('Cubit Error'));
await Future.delayed(const Duration(seconds: 1));
await Future<void>.delayed(const Duration(seconds: 1));
emit(const CrudLoaded<String>('DATA LOADED'));
await Future.delayed(const Duration(seconds: 1));
await Future<void>.delayed(const Duration(seconds: 1));
emit(CrudInitial());
}
}
FutureOr<void> runList() async {
while (true) {
await Future.delayed(const Duration(seconds: 1));
await Future<void>.delayed(const Duration(seconds: 1));
emit(CrudLoading());
await Future.delayed(const Duration(seconds: 1));
await Future<void>.delayed(const Duration(seconds: 1));
emit(const CrudError('Cubit Error'));
await Future.delayed(const Duration(seconds: 1));
await Future<void>.delayed(const Duration(seconds: 1));
emit(
const CrudListLoaded<String>([
'DATA LOADED 1',
@ -33,7 +33,7 @@ class ExampleCubit extends Cubit<CrudState> {
'DATA LOADED 4'
]),
);
await Future.delayed(const Duration(seconds: 1));
await Future<void>.delayed(const Duration(seconds: 1));
emit(CrudInitial());
}
}

View File

@ -21,10 +21,6 @@ import 'package:form_bloc_example/app/bloc_observer.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
BlocOverrides.runZoned(
() => runApp(
const App(),
),
blocObserver: AppBlocObserver(),
);
Bloc.observer = AppBlocObserver();
runApp(const App());
}

View File

@ -66,7 +66,7 @@ Future<void> handleDigest(HttpRequest req) async {
Future<void> handleUnsafe(HttpRequest req) async {
print(
'Query parameters => '
'${req.uri.queryParameters.toString()}',
'${req.uri.queryParameters}',
);
}

View File

@ -82,8 +82,8 @@ class VerifyCode {
VerifyCode.fromMap(json.decode(source) as Map<String, dynamic>);
@override
String toString() =>
'VerifyCode(email: $email, verificationCode: $verificationCode, action: $action)';
String toString() => 'VerifyCode(email: $email, verificationCode: '
'$verificationCode, action: $action)';
}
class Account {
@ -198,8 +198,8 @@ class TokenSuccess {
TokenSuccess.fromMap(json.decode(source) as Map<String, dynamic>);
@override
String toString() =>
'TokenSuccess(accessToken: $accessToken, refreshToken: $refreshToken, account: $account)';
String toString() => 'TokenSuccess(accessToken: $accessToken, refreshToken: '
'$refreshToken, account: $account)';
}
class Login {
@ -353,19 +353,19 @@ void main(List<String> args) async {
);
await api.sendSignUpCode('git@pcl.ovh');
final verifiedAccount = await api.verifyCode(
VerifyCode(
email: 'git@pcl.ovh',
verificationCode: '000000000',
action: EmailVerificationAction.signUp,
),
);
final registeredAccount = await api.signUp(
SignUp(sessionId: verifiedAccount.sessionId ?? '', password: 'password'),
);
final signedInAccount = await api.signInWithPassword(
Login(email: 'git@pcl.ovh', password: 'password'),
);
// final verifiedAccount = await api.verifyCode(
// VerifyCode(
// email: 'git@pcl.ovh',
// verificationCode: '000000000',
// action: EmailVerificationAction.signUp,
// ),
// );
// final registeredAccount = await api.signUp(
// SignUp(sessionId: verifiedAccount.sessionId ?? '', password: 'password'),
// );
// final signedInAccount = await api.signInWithPassword(
// Login(email: 'git@pcl.ovh', password: 'password'),
// );
final accountList = await api.getAccountList();
print(accountList);
}

View File

@ -45,7 +45,8 @@ import 'package:wyatt_http_client/src/utils/protocols.dart';
// BaseResponse onResponse(BaseResponse response) {
// final res = child?.onResponse(response) ?? response;
// print(
// 'RequestMutator::OnResponse: ${res.statusCode} -> ${res.contentLength} bytes',
// 'RequestMutator::OnResponse: ${res.statusCode} -> ${res.contentLength}
// bytes',
// );
// return res;
// }
@ -75,7 +76,8 @@ import 'package:wyatt_http_client/src/utils/protocols.dart';
// if (response != null) return response;
// return Future.sync(() => innerHandler(request))
// .then((response) => responseHandler!(response), onError: onError);
// .then((response) => responseHandler!(response), onError:
// onError);
// });
// };
// };

View File

@ -30,6 +30,8 @@ class Pipeline {
/// Add a [Middleware] to this [Pipeline]
Pipeline addMiddleware(Middleware middleware) {
_middlewares.add(middleware);
// TODO(hpcl): use Dart cascades instead of returning this
// ignore: avoid_returning_this
return this;
}