Skip to content

Commit

Permalink
Update design of dangerous buttons (#1758)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsreichardt authored Oct 10, 2024
1 parent 364a256 commit 2900e64
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 43 deletions.
48 changes: 43 additions & 5 deletions app/lib/groups/src/widgets/danger_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,17 @@ class _LeaveButton extends StatelessWidget {

@override
Widget build(BuildContext context) {
return _DangerButton(
return DangerButtonOutlined(
onPressed: onPressed,
label: label,
icon: const Icon(Icons.exit_to_app),
);
}
}

class _DangerButton extends StatelessWidget {
const _DangerButton({
class DangerButtonOutlined extends StatelessWidget {
const DangerButtonOutlined({
super.key,
this.onPressed,
required this.label,
required this.icon,
Expand All @@ -85,7 +86,44 @@ class _DangerButton extends StatelessWidget {
style: FilledButton.styleFrom(
shadowColor: Colors.transparent,
foregroundColor: Colors.red,
backgroundColor: Colors.red.withOpacity(0.2),
backgroundColor: Colors.transparent,
shape: RoundedRectangleBorder(
side: BorderSide(
color: Colors.red.withOpacity(0.5),
width: 2,
),
borderRadius: BorderRadius.circular(512),
),
),
onPressed: onPressed,
label: label,
),
);
}
}

class DangerButtonFilled extends StatelessWidget {
const DangerButtonFilled({
super.key,
this.onPressed,
required this.label,
required this.icon,
});

final VoidCallback? onPressed;
final Widget label;
final Widget icon;

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(bottom: 12),
child: FilledButton.icon(
icon: icon,
style: FilledButton.styleFrom(
shadowColor: Colors.transparent,
foregroundColor: Colors.white,
backgroundColor: Colors.red,
),
onPressed: onPressed,
label: label,
Expand All @@ -105,7 +143,7 @@ class _DeleteSchoolClassButton extends StatelessWidget {

@override
Widget build(BuildContext context) {
return _DangerButton(
return DangerButtonFilled(
icon: const Icon(Icons.delete),
onPressed: onPressed,
label: label,
Expand Down
44 changes: 6 additions & 38 deletions app/lib/settings/src/subpages/my_profile/my_profile_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import 'package:sharezone/account/account_page.dart';
import 'package:sharezone/account/change_data_bloc.dart';
import 'package:sharezone/account/profile/user_edit/user_edit_page.dart';
import 'package:sharezone/activation_code/activation_code_page.dart';
import 'package:sharezone/groups/src/widgets/danger_section.dart';
import 'package:sharezone/main/application_bloc.dart';
import 'package:sharezone/navigation/drawer/sign_out_dialogs/sign_out_dialogs.dart';
import 'package:sharezone/navigation/drawer/sign_out_dialogs/src/sign_out_and_delete_anonymous_user.dart';
Expand Down Expand Up @@ -70,9 +71,8 @@ class MyProfilePage extends StatelessWidget {
_UserId(user.id),
_EnterActivationTile(),
_PrivacyOptOut(),
const Divider(),
const Divider(height: 32),
SignOutButton(isAnonymous: user.isAnonymous),
const SizedBox(height: 8),
_DeleteAccountButton(),
],
);
Expand Down Expand Up @@ -325,14 +325,9 @@ class SignOutButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: ElevatedButton.icon(
child: DangerButtonOutlined(
key: const ValueKey('sign-out-button-E2E'),
icon: const Icon(Icons.exit_to_app),
style: ElevatedButton.styleFrom(
shadowColor: Colors.transparent,
backgroundColor: Colors.red.withOpacity(0.2),
foregroundColor: Colors.red,
),
onPressed: () => signOut(context, isAnonymous),
label: Text("Abmelden".toUpperCase()),
),
Expand All @@ -345,10 +340,10 @@ class _DeleteAccountButton extends StatelessWidget {
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(bottom: 12),
child: _DangerButton(
child: DangerButtonFilled(
icon: const Icon(Icons.delete),
title: "Konto löschen",
onTap: () => showDialog(
label: Text("Konto löschen".toUpperCase()),
onPressed: () => showDialog(
context: context,
builder: (context) => _DeleteAccountDialogContent(),
),
Expand All @@ -357,33 +352,6 @@ class _DeleteAccountButton extends StatelessWidget {
}
}

class _DangerButton extends StatelessWidget {
const _DangerButton({this.onTap, this.title, this.icon});

final VoidCallback? onTap;
final String? title;
final Icon? icon;

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.fromLTRB(12, 0, 12, 0),
child: ButtonTheme(
minWidth: getScreenSize(context).width,
child: ElevatedButton.icon(
icon: icon!,
label: Text(title!.toUpperCase()),
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor: Colors.redAccent,
),
onPressed: onTap,
),
),
);
}
}

class _DeleteAccountDialogContent extends StatefulWidget {
@override
_DeleteAccountDialogContentState createState() =>
Expand Down

0 comments on commit 2900e64

Please sign in to comment.