Skip to content

Commit

Permalink
fix: Profile view bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
TomBursch committed Nov 15, 2023
1 parent f011026 commit 84566b1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
6 changes: 3 additions & 3 deletions lib/pages/settings_user_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class _SettingsUserPageState extends State<SettingsUserPage> {
);
final user = widget.user ?? BlocProvider.of<AuthCubit>(context).getUser();
if (user != null) {
usernameController.text = user.username;
usernameController.text = "@${user.username}";
emailController.text = user.email ?? "";
nameController.text = user.name;
}
Expand All @@ -64,7 +64,7 @@ class _SettingsUserPageState extends State<SettingsUserPage> {
listenWhen: (previous, current) => previous.user != current.user,
listener: (context, state) {
if (state.user != null) {
usernameController.text = state.user?.username ?? '';
usernameController.text = "@${state.user?.username ?? ''}";
emailController.text = state.user?.email ?? '';
nameController.text = state.user?.name ?? '';
}
Expand Down Expand Up @@ -109,7 +109,7 @@ class _SettingsUserPageState extends State<SettingsUserPage> {
);
if (confirm) {
if (await cubit.deleteUser() && mounted) {
if (cubit.userId != null) {
if (cubit.userId == null) {
BlocProvider.of<AuthCubit>(context).logout();
}
Navigator.of(context).pop(UpdateEnum.deleted);
Expand Down
18 changes: 13 additions & 5 deletions lib/widgets/settings/token_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@ class TokenBottomSheet extends StatelessWidget {
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: TokenCard(token: token),
child: TokenCard(
token: token,
enableOnTap: false,
),
),
const Divider(),
ElevatedButton(
onPressed: onLogout,
child: Text(
AppLocalizations.of(context)!.logoutName(token.name),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: ElevatedButton(
onPressed: onLogout,
child: Text(
AppLocalizations.of(context)!.logoutName(token.name),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
),
const SizedBox(height: 16),
Expand Down
26 changes: 17 additions & 9 deletions lib/widgets/settings/token_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ import 'package:kitchenowl/widgets/settings/token_bottom_sheet.dart';
class TokenCard extends StatelessWidget {
final Token token;
final void Function()? onLogout;
final bool enableOnTap;

const TokenCard({super.key, required this.token, this.onLogout});
const TokenCard({
super.key,
required this.token,
this.onLogout,
this.enableOnTap = true,
});

@override
Widget build(BuildContext context) {
Expand All @@ -24,14 +30,16 @@ class TokenCard extends StatelessWidget {
)}",
)
: null,
onTap: () => showModalBottomSheet(
context: context,
showDragHandle: true,
builder: (context) => TokenBottomSheet(
token: token,
onLogout: onLogout,
),
),
onTap: enableOnTap
? () => showModalBottomSheet(
context: context,
showDragHandle: true,
builder: (context) => TokenBottomSheet(
token: token,
onLogout: onLogout,
),
)
: null,
),
);

Expand Down

0 comments on commit 84566b1

Please sign in to comment.