Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
MacaronFR committed Jul 14, 2024
2 parents 224e8f7 + 9108f3e commit f1e8ae8
Show file tree
Hide file tree
Showing 9 changed files with 289 additions and 112 deletions.
112 changes: 62 additions & 50 deletions packages/app/lib/auth/screens/signup_screen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hollybike/app/app_router.gr.dart';
import 'package:hollybike/auth/bloc/auth_bloc.dart';
import 'package:hollybike/auth/types/form_texts.dart';
import 'package:hollybike/auth/types/signup_dto.dart';
Expand All @@ -17,63 +18,74 @@ class SignupScreen extends StatelessWidget {

@override
Widget build(BuildContext context) {
final canPop = context.routeData.queryParams.getBool("canPop", false);
final popContext = context.routeData.queryParams.getString(
"popContext", "");

return Scaffold(
floatingActionButton: canPop
floatingActionButton: popContext == "connected"
? FloatingActionButton.small(
onPressed: () => context.router.maybePop(),
child: const Icon(Icons.arrow_back),
)
onPressed: () => context.router.maybePop(),
child: const Icon(Icons.arrow_back),
)
: null,
floatingActionButtonLocation: FloatingActionButtonLocation.miniStartTop,
body: BlocBuilder<AuthBloc, AuthState>(
builder: (context, state) {
final error = state is AuthFailure ? state.message : null;

return BannerDialog(
body: FormBuilder(
title: "Inscrivez-vous!",
description: "Saisissez les informations de votre nouveau compte.",
errorText: error,
formTexts: const FormTexts(
submit: "S'inscrire",
),
onFormSubmit: (formValue) {
final values = Map.from(context.routeData.queryParams.rawMap);
values.addAll(formValue);
body: BlocListener<AuthBloc, AuthState>(
listener: (context, state) {
if (state is! AuthFailure) {
if (popContext == "connected") {
context.router.maybePop();
} else if (popContext.isEmpty) {
context.router.replaceAll([const EventsRoute()]);
}
}
},
child: BlocBuilder<AuthBloc, AuthState>(
builder: (context, state) {
final error = state is AuthFailure ? state.message : null;

BlocProvider.of<AuthBloc>(context).add(AuthSignup(
host: context.routeData.queryParams.getString("host"),
signupDto: SignupDto.fromMap(values),
));
if (canPop) context.router.maybePop();
},
formFields: {
"username": FormFieldConfig(
label: "Nom utilisateur",
validator: _inputValidator,
autofocus: true,
autofillHints: [AutofillHints.newUsername],
textInputType: TextInputType.name,
),
"email": FormFieldConfig(
label: "Adresse mail",
validator: _inputValidator,
autofillHints: [AutofillHints.email],
textInputType: TextInputType.emailAddress,
return BannerDialog(
body: FormBuilder(
title: "Inscrivez-vous!",
description: "Saisissez les informations de votre nouveau compte.",
errorText: error,
formTexts: const FormTexts(
submit: "S'inscrire",
),
"password": FormFieldConfig(
label: "Mot de passe",
validator: _passwordInputValidator,
isSecured: true,
hasControlField: true,
autofillHints: [AutofillHints.newPassword],
),
},
),
);
},
onFormSubmit: (formValue) {
final values = Map.from(context.routeData.queryParams.rawMap);
values.addAll(formValue);

BlocProvider.of<AuthBloc>(context).add(AuthSignup(
host: context.routeData.queryParams.getString("host"),
signupDto: SignupDto.fromMap(values),
));
},
formFields: {
"username": FormFieldConfig(
label: "Nom utilisateur",
validator: _inputValidator,
autofocus: true,
autofillHints: [AutofillHints.newUsername],
textInputType: TextInputType.name,
),
"email": FormFieldConfig(
label: "Adresse mail",
validator: _inputValidator,
autofillHints: [AutofillHints.email],
textInputType: TextInputType.emailAddress,
),
"password": FormFieldConfig(
label: "Mot de passe",
validator: _passwordInputValidator,
isSecured: true,
hasControlField: true,
autofillHints: [AutofillHints.newPassword],
),
},
),
);
},
),
),
);
}
Expand Down
6 changes: 3 additions & 3 deletions packages/app/lib/auth/widgets/signup_link_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class _SignupLinkDialogState extends State<SignupLinkDialog> {
),
),
ElevatedButton(
onPressed: isValid ? _handleSubmit : null,
onPressed: _handleSubmit,
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.all(18),
shape: const RoundedRectangleBorder(
Expand Down Expand Up @@ -114,8 +114,8 @@ class _SignupLinkDialogState extends State<SignupLinkDialog> {
void _handleSubmit() {
if (isValid) {
widget.canPop
? context.router.replaceNamed("${_linkController.text}&canPop=true")
: context.router.pushNamed("${_linkController.text}&canPop=false");
? context.router.replaceNamed("${_linkController.text}&popContext=connected")
: context.router.pushNamed("${_linkController.text}&popContext=guard");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hollybike/event/types/event_status_state.dart';
import 'package:hollybike/positions/bloc/my_position/my_position_bloc.dart';
import 'package:hollybike/positions/bloc/my_position/my_position_event.dart';

import '../../bloc/event_details_bloc/event_details_bloc.dart';
import '../../bloc/event_details_bloc/event_details_event.dart';
Expand Down Expand Up @@ -172,5 +174,9 @@ class EventDetailsActionsMenu extends StatelessWidget {
context.read<EventDetailsBloc>().add(
LeaveEvent(),
);

context.read<MyPositionBloc>().add(
DisableSendPositions(),
);
}
}
4 changes: 3 additions & 1 deletion packages/app/lib/event/widgets/event_status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ class _EventStatusIndicatorState extends State<EventStatusIndicator> {
size: 13,
),
SizedBox(width: widget.separatorWidth),
_statusText,
Flexible(
child: _statusText,
),
],
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class EditProfileBloc extends Bloc<EditProfileEvent, EditProfileState> {
);
} catch (e) {
if (e is DioException) {
if (e.response?.statusCode == 403) {
if (e.response?.statusCode == 401) {
emit(EditProfileLoadFailure(
state,
errorMessage: 'Mot de passe incorrect.',
Expand Down
70 changes: 47 additions & 23 deletions packages/app/lib/profile/widgets/profile_bottom_bar_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@ import '../../event/widgets/event_loading_profile_picture.dart';
import '../bloc/profile_bloc/profile_bloc.dart';

class ProfileBottomBarButton extends StatelessWidget {
const ProfileBottomBarButton({super.key});
final bool isSelected;
final Color color;
final double size;

const ProfileBottomBarButton({
super.key,
this.isSelected = false,
required this.color,
required this.size,
});

@override
Widget build(BuildContext context) {
return NavigationDestination(
selectedIcon: Container(
padding: const EdgeInsets.all(2),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.onPrimary,
shape: BoxShape.circle,
),
child: _renderProfilePicture(context),
),
icon: _renderProfilePicture(context),
label: 'Profile',
);
return _renderProfilePicture(context);
}

void _handleLongPress(context) {
Expand All @@ -42,22 +40,48 @@ class ProfileBottomBarButton extends StatelessWidget {
final currentProfile = bloc.currentProfile;

if (currentProfile is ProfileLoadSuccessEvent) {
return UserProfilePicture(
url: currentProfile.profile.profilePicture,
profilePictureKey: currentProfile.profile.profilePictureKey,
radius: 12,
isLoading: false,
return _profilePictureContainer(
context,
UserProfilePicture(
url: currentProfile.profile.profilePicture,
profilePictureKey: currentProfile.profile.profilePictureKey,
radius: size * 0.5,
isLoading: false,
),
);
}

return const UserProfilePicture(
url: null,
profilePictureKey: null,
radius: 12,
isLoading: true,
return _profilePictureContainer(
context,
UserProfilePicture(
url: null,
profilePictureKey: null,
radius: size * 0.5,
isLoading: true,
),
);
},
),
);
}

Widget _profilePictureContainer(
BuildContext context,
Widget child,
) {
return Center(
child: Container(
height: size,
width: size,
decoration: BoxDecoration(
border: Border.all(
color: isSelected ? color : Colors.transparent,
width: 2,
),
shape: BoxShape.circle,
),
child: child,
),
);
}
}
Loading

0 comments on commit f1e8ae8

Please sign in to comment.