|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'package:zup_app/core/cache.dart'; |
| 3 | +import 'package:zup_app/core/injections.dart'; |
| 4 | +import 'package:zup_app/core/zup_links.dart'; |
| 5 | +import 'package:zup_app/l10n/gen/app_localizations.dart'; |
| 6 | +import 'package:zup_ui_kit/zup_ui_kit.dart'; |
| 7 | + |
| 8 | +class AppCookieConsentWidget extends StatelessWidget { |
| 9 | + AppCookieConsentWidget({super.key, required this.onAccept}); |
| 10 | + |
| 11 | + final void Function() onAccept; |
| 12 | + |
| 13 | + final zupLinks = inject<ZupLinks>(); |
| 14 | + final cache = inject<Cache>(); |
| 15 | + |
| 16 | + @override |
| 17 | + Widget build(BuildContext context) { |
| 18 | + return Container( |
| 19 | + padding: const EdgeInsets.all(15), |
| 20 | + decoration: BoxDecoration( |
| 21 | + color: ZupColors.white, |
| 22 | + border: Border.all(color: ZupColors.gray5), |
| 23 | + borderRadius: BorderRadius.circular(12), |
| 24 | + ), |
| 25 | + width: 300, |
| 26 | + child: Material( |
| 27 | + color: Colors.transparent, |
| 28 | + child: Column( |
| 29 | + mainAxisSize: MainAxisSize.min, |
| 30 | + children: [ |
| 31 | + Text.rich( |
| 32 | + TextSpan(children: [ |
| 33 | + TextSpan( |
| 34 | + text: S.of(context).appCookiesConsentWidgetDescription, |
| 35 | + style: const TextStyle(color: ZupColors.gray, fontSize: 14), |
| 36 | + ), |
| 37 | + const TextSpan(text: " "), |
| 38 | + WidgetSpan( |
| 39 | + child: SizedBox( |
| 40 | + height: 17, |
| 41 | + child: TextButton( |
| 42 | + key: const Key("privacy-policy-button"), |
| 43 | + onPressed: () { |
| 44 | + zupLinks.launchPrivacyPolicy(); |
| 45 | + }, |
| 46 | + style: ButtonStyle( |
| 47 | + visualDensity: VisualDensity.compact, |
| 48 | + minimumSize: WidgetStateProperty.all(Size.zero), |
| 49 | + splashFactory: NoSplash.splashFactory, |
| 50 | + backgroundColor: WidgetStateProperty.all(Colors.transparent), |
| 51 | + overlayColor: WidgetStateProperty.all(Colors.transparent), |
| 52 | + padding: WidgetStateProperty.all(EdgeInsets.zero), |
| 53 | + ), |
| 54 | + child: Text( |
| 55 | + S.of(context).privacyPolicy, |
| 56 | + style: const TextStyle(decoration: TextDecoration.underline, fontSize: 14), |
| 57 | + ), |
| 58 | + ), |
| 59 | + ), |
| 60 | + style: const TextStyle(color: ZupColors.black, fontSize: 14), |
| 61 | + ), |
| 62 | + ]), |
| 63 | + ), |
| 64 | + const SizedBox(height: 20), |
| 65 | + ZupPrimaryButton( |
| 66 | + key: const Key("accept-cookies-button"), |
| 67 | + height: 40, |
| 68 | + title: S.of(context).understood, |
| 69 | + hoverElevation: 0, |
| 70 | + backgroundColor: ZupColors.brand6, |
| 71 | + foregroundColor: ZupColors.brand, |
| 72 | + onPressed: () { |
| 73 | + onAccept(); |
| 74 | + cache.saveCookiesConsentStatus(status: true); |
| 75 | + }, |
| 76 | + alignCenter: true, |
| 77 | + width: double.maxFinite, |
| 78 | + ), |
| 79 | + ], |
| 80 | + ), |
| 81 | + ), |
| 82 | + ); |
| 83 | + } |
| 84 | +} |
0 commit comments