|
| 1 | +import 'package:flutter_bloc/flutter_bloc.dart'; |
| 2 | +import 'package:go_router/go_router.dart'; |
| 3 | +import 'package:shadcn_flutter/shadcn_flutter.dart'; |
| 4 | + |
| 5 | +import '../../../extensions/text_extensions.dart'; |
| 6 | +import '../../../settings/error_settings.dart'; |
| 7 | +import '../../../theme/cubit/theme_cubit.dart'; |
| 8 | +import '../icon_container.dart'; |
| 9 | + |
| 10 | +class NotAuthorizedCard extends StatelessWidget { |
| 11 | + const NotAuthorizedCard({ |
| 12 | + super.key, |
| 13 | + this.accessInformations, |
| 14 | + this.color, |
| 15 | + this.darkColor, |
| 16 | + this.withShadow = false, |
| 17 | + }); |
| 18 | + |
| 19 | + final List<String>? accessInformations; |
| 20 | + |
| 21 | + final bool withShadow; |
| 22 | + |
| 23 | + final Color? color; |
| 24 | + |
| 25 | + final Color? darkColor; |
| 26 | + |
| 27 | + @override |
| 28 | + Widget build(BuildContext context) { |
| 29 | + final isDarkMode = context.watch<ThemeCubit>().state.isDarkMode; |
| 30 | + return ConstrainedBox( |
| 31 | + constraints: BoxConstraints(maxWidth: 720), |
| 32 | + child: Card( |
| 33 | + boxShadow: withShadow |
| 34 | + ? [ |
| 35 | + isDarkMode |
| 36 | + ? BoxShadow( |
| 37 | + color: Color.fromRGBO(255, 255, 255, 0.25), |
| 38 | + offset: Offset(0, 0), |
| 39 | + blurRadius: 50, |
| 40 | + spreadRadius: -12, |
| 41 | + ) |
| 42 | + : BoxShadow( |
| 43 | + color: Color.fromRGBO(0, 0, 0, 0.25), |
| 44 | + offset: Offset(0, 0), |
| 45 | + blurRadius: 50, |
| 46 | + spreadRadius: -12, |
| 47 | + ), |
| 48 | + ] |
| 49 | + : null, |
| 50 | + borderColor: isDarkMode ? darkColor : color, |
| 51 | + borderWidth: 2, |
| 52 | + child: Column( |
| 53 | + children: [ |
| 54 | + IconContainer( |
| 55 | + color: Colors.orange[100], |
| 56 | + darkColor: Colors.orange[900].withAlpha(100), |
| 57 | + icon: LucideIcons.shieldAlert, |
| 58 | + iconColor: Colors.orange[600], |
| 59 | + iconDarkColor: Colors.orange[400], |
| 60 | + ), |
| 61 | + Gap(24), |
| 62 | + Text('403').bold.x8Large.setColors( |
| 63 | + lightColor: Colors.orange[600], |
| 64 | + darkColor: Colors.orange[400], |
| 65 | + ), |
| 66 | + Gap(8), |
| 67 | + Text('Zugriff verweigert').bold.x3Large.setColors( |
| 68 | + lightColor: Colors.gray[900], |
| 69 | + darkColor: Colors.white, |
| 70 | + ), |
| 71 | + Gap(16), |
| 72 | + ConstrainedBox( |
| 73 | + constraints: BoxConstraints(maxWidth: 440), |
| 74 | + child: |
| 75 | + Text( |
| 76 | + 'Sie haben keine Berechtigung, auf diese Seite oder Ressource zuzugreifen.', |
| 77 | + textAlign: TextAlign.center, |
| 78 | + ).large.setColors( |
| 79 | + lightColor: Colors.gray[600], |
| 80 | + darkColor: Colors.gray[400], |
| 81 | + ), |
| 82 | + ), |
| 83 | + Gap(24), |
| 84 | + SizedBox( |
| 85 | + width: double.infinity, |
| 86 | + child: Card( |
| 87 | + padding: EdgeInsets.all(24), |
| 88 | + filled: true, |
| 89 | + fillColor: isDarkMode |
| 90 | + ? Colors.orange[900].withAlpha(25) |
| 91 | + : Colors.orange[50], |
| 92 | + child: Column( |
| 93 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 94 | + children: [ |
| 95 | + Row( |
| 96 | + mainAxisAlignment: MainAxisAlignment.center, |
| 97 | + children: [ |
| 98 | + Icon( |
| 99 | + LucideIcons.lock, |
| 100 | + color: isDarkMode |
| 101 | + ? Colors.orange[400] |
| 102 | + : Colors.orange[600], |
| 103 | + ), |
| 104 | + Gap(10), |
| 105 | + Text('Zugriffsinformationen').h4.setColors( |
| 106 | + lightColor: Colors.gray[900], |
| 107 | + darkColor: Colors.white, |
| 108 | + ), |
| 109 | + ], |
| 110 | + ), |
| 111 | + Gap(12), |
| 112 | + Column( |
| 113 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 114 | + children: |
| 115 | + (accessInformations ?? |
| 116 | + ErrorSettings.accessInformations) |
| 117 | + .map( |
| 118 | + (reason) => Text(reason).li.setColors( |
| 119 | + lightColor: Colors.gray[600], |
| 120 | + darkColor: Colors.gray[400], |
| 121 | + ), |
| 122 | + ) |
| 123 | + .toList(), |
| 124 | + ).gap(5), |
| 125 | + ], |
| 126 | + ), |
| 127 | + ), |
| 128 | + ).withPadding(horizontal: 30), |
| 129 | + Gap(32), |
| 130 | + Row( |
| 131 | + mainAxisAlignment: MainAxisAlignment.center, |
| 132 | + children: [ |
| 133 | + OutlineButton( |
| 134 | + onPressed: () => context.pop(), |
| 135 | + enabled: context.canPop(), |
| 136 | + leading: const Icon(LucideIcons.arrowLeft), |
| 137 | + child: Text('Zurück'), |
| 138 | + ), |
| 139 | + PrimaryButton( |
| 140 | + onPressed: () => |
| 141 | + context.goNamed(ErrorSettings.accessInformationHomeLink), |
| 142 | + leading: const Icon(LucideIcons.house), |
| 143 | + child: Text('Zur Startseite'), |
| 144 | + ), |
| 145 | + ], |
| 146 | + ).gap(10), |
| 147 | + Divider().withPadding(all: 32), |
| 148 | + Text('Benötigen Sie Hilfe? Kontaktieren Sie uns.').muted.small, |
| 149 | + ], |
| 150 | + ).withPadding(vertical: 48), |
| 151 | + ), |
| 152 | + ); |
| 153 | + } |
| 154 | +} |
0 commit comments