From f2f936e2adb69eee1e440fae72e6d4c5649d57b6 Mon Sep 17 00:00:00 2001 From: nilsreichardt Date: Sun, 7 Jan 2024 15:44:35 +0100 Subject: [PATCH] Reuse widgets from `sharezone_widgets` in `website` --- website/lib/home/src/all_in_one_platform.dart | 2 +- website/lib/home/src/traction.dart | 2 +- website/lib/legal/privacy_policy.dart | 2 +- website/lib/page.dart | 3 +- website/lib/support_page.dart | 5 +- website/lib/utils.dart | 2 +- website/lib/widgets/avatar_card.dart | 3 +- website/lib/widgets/divider_with_text.dart | 52 --------- .../lib/widgets/max_width_constraint_box.dart | 29 ----- website/lib/widgets/section.dart | 3 +- website/lib/widgets/shadow_card.dart | 107 ------------------ website/lib/widgets/snackbars.dart | 72 ------------ 12 files changed, 10 insertions(+), 272 deletions(-) delete mode 100644 website/lib/widgets/divider_with_text.dart delete mode 100644 website/lib/widgets/max_width_constraint_box.dart delete mode 100644 website/lib/widgets/shadow_card.dart delete mode 100644 website/lib/widgets/snackbars.dart diff --git a/website/lib/home/src/all_in_one_platform.dart b/website/lib/home/src/all_in_one_platform.dart index 404559807..2e07fac28 100644 --- a/website/lib/home/src/all_in_one_platform.dart +++ b/website/lib/home/src/all_in_one_platform.dart @@ -12,7 +12,7 @@ import 'package:sharezone_website/widgets/column_spacing.dart'; import 'package:sharezone_website/widgets/headline.dart'; import 'package:sharezone_website/widgets/row_spacing.dart'; import 'package:sharezone_website/widgets/section.dart'; -import 'package:sharezone_website/widgets/shadow_card.dart'; +import 'package:sharezone_widgets/sharezone_widgets.dart' hide Headline; import '../../main.dart'; import '../home_page.dart'; diff --git a/website/lib/home/src/traction.dart b/website/lib/home/src/traction.dart index 78ce677e5..0034bc6a4 100644 --- a/website/lib/home/src/traction.dart +++ b/website/lib/home/src/traction.dart @@ -12,8 +12,8 @@ import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:number_slide_animation/number_slide_animation.dart'; import 'package:sharezone_website/widgets/column_spacing.dart'; -import 'package:sharezone_website/widgets/max_width_constraint_box.dart'; import 'package:sharezone_website/widgets/transparent_button.dart'; +import 'package:sharezone_widgets/sharezone_widgets.dart'; import '../home_page.dart'; diff --git a/website/lib/legal/privacy_policy.dart b/website/lib/legal/privacy_policy.dart index 5924691e6..50e816e23 100644 --- a/website/lib/legal/privacy_policy.dart +++ b/website/lib/legal/privacy_policy.dart @@ -9,7 +9,7 @@ import 'package:flutter/material.dart'; import 'package:sharezone_website/page.dart'; import 'package:sharezone_website/widgets/headline.dart'; -import 'package:sharezone_website/widgets/max_width_constraint_box.dart'; +import 'package:sharezone_widgets/sharezone_widgets.dart' hide Headline; class PrivacyPolicyPage extends StatelessWidget { const PrivacyPolicyPage({super.key}); diff --git a/website/lib/page.dart b/website/lib/page.dart index 445dc4e0c..06c2ca592 100644 --- a/website/lib/page.dart +++ b/website/lib/page.dart @@ -12,10 +12,11 @@ import 'package:sharezone_website/sharezone_plus/sharezone_plus_page.dart'; import 'package:sharezone_website/support_page.dart'; import 'package:sharezone_website/utils.dart'; import 'package:sharezone_website/widgets/column_spacing.dart'; +import 'package:sharezone_widgets/sharezone_widgets.dart' + hide SharezoneLogo, LogoColor; import 'footer.dart'; import 'home/home_page.dart'; -import 'widgets/max_width_constraint_box.dart'; import 'widgets/sharezone_logo.dart'; import 'widgets/transparent_button.dart'; diff --git a/website/lib/support_page.dart b/website/lib/support_page.dart index 69ebb5992..22a388ec4 100644 --- a/website/lib/support_page.dart +++ b/website/lib/support_page.dart @@ -9,12 +9,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:sharezone_website/page.dart'; +import 'package:sharezone_website/widgets/avatar_card.dart'; +import 'package:sharezone_widgets/sharezone_widgets.dart'; import 'package:url_launcher/url_launcher.dart'; -import 'widgets/avatar_card.dart'; import 'widgets/section.dart'; -import 'widgets/shadow_card.dart'; -import 'widgets/snackbars.dart'; const phoneNumber = '+49 1516 7754541'; diff --git a/website/lib/utils.dart b/website/lib/utils.dart index 8e2ab3b04..968c6cbe0 100644 --- a/website/lib/utils.dart +++ b/website/lib/utils.dart @@ -7,7 +7,7 @@ // SPDX-License-Identifier: EUPL-1.2 import 'package:flutter/material.dart'; -import 'package:sharezone_website/widgets/snackbars.dart'; +import 'package:sharezone_widgets/sharezone_widgets.dart'; import 'package:url_launcher/url_launcher.dart' as url_launcher; /// Launches the given [url] in the browser. diff --git a/website/lib/widgets/avatar_card.dart b/website/lib/widgets/avatar_card.dart index 2190e19ae..30976bd5f 100644 --- a/website/lib/widgets/avatar_card.dart +++ b/website/lib/widgets/avatar_card.dart @@ -8,8 +8,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; - -import 'shadow_card.dart'; +import 'package:sharezone_widgets/sharezone_widgets.dart'; // Karte mit CircleAvatar und dahinter eine Karte // Wichtig: Es muss entweder ein SvgPath oder ein imagePath angeben werden! diff --git a/website/lib/widgets/divider_with_text.dart b/website/lib/widgets/divider_with_text.dart deleted file mode 100644 index 23c3dd54a..000000000 --- a/website/lib/widgets/divider_with_text.dart +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2023 Sharezone UG (haftungsbeschränkt) -// Licensed under the EUPL-1.2-or-later. -// -// You may obtain a copy of the Licence at: -// https://joinup.ec.europa.eu/software/page/eupl -// -// SPDX-License-Identifier: EUPL-1.2 - -import 'package:flutter/material.dart'; -import 'package:sharezone_website/main.dart'; - -class DividerWithText extends StatelessWidget { - const DividerWithText( - {super.key, required this.text, this.fontSize = 14, this.textStyle}); - - final Widget text; - final double fontSize; - final TextStyle? textStyle; - - @override - Widget build(BuildContext context) { - return Stack( - alignment: Alignment.center, - children: [ - Container(width: 200), - const Padding( - padding: EdgeInsets.only(top: 8), - child: Divider(height: 0), - ), - Align( - child: Padding( - padding: const EdgeInsets.only(left: 12), - child: Container( - color: Theme.of(context).scaffoldBackgroundColor, - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 24), - child: DefaultTextStyle( - style: TextStyle( - color: Colors.grey[600], - fontSize: fontSize, - fontFamily: SharezoneStyle.font, - ), - child: text, - ), - ), - ), - ), - ), - ], - ); - } -} diff --git a/website/lib/widgets/max_width_constraint_box.dart b/website/lib/widgets/max_width_constraint_box.dart deleted file mode 100644 index 284275ed1..000000000 --- a/website/lib/widgets/max_width_constraint_box.dart +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2023 Sharezone UG (haftungsbeschränkt) -// Licensed under the EUPL-1.2-or-later. -// -// You may obtain a copy of the Licence at: -// https://joinup.ec.europa.eu/software/page/eupl -// -// SPDX-License-Identifier: EUPL-1.2 - -import 'package:flutter/material.dart'; - -class MaxWidthConstraintBox extends StatelessWidget { - const MaxWidthConstraintBox( - {super.key, required this.child, this.maxWidth = 1000}); - - final Widget child; - - /// Default value is 1000. - final double maxWidth; - - @override - Widget build(BuildContext context) { - return Center( - child: ConstrainedBox( - constraints: BoxConstraints(maxWidth: maxWidth), - child: child, - ), - ); - } -} diff --git a/website/lib/widgets/section.dart b/website/lib/widgets/section.dart index e9e63bc56..0fef86bff 100644 --- a/website/lib/widgets/section.dart +++ b/website/lib/widgets/section.dart @@ -8,8 +8,7 @@ import 'package:flutter/material.dart'; import 'package:sharezone_website/home/home_page.dart'; - -import 'max_width_constraint_box.dart'; +import 'package:sharezone_widgets/sharezone_widgets.dart'; class Section extends StatelessWidget { const Section({super.key, this.child}); diff --git a/website/lib/widgets/shadow_card.dart b/website/lib/widgets/shadow_card.dart deleted file mode 100644 index c91da5df8..000000000 --- a/website/lib/widgets/shadow_card.dart +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (c) 2023 Sharezone UG (haftungsbeschränkt) -// Licensed under the EUPL-1.2-or-later. -// -// You may obtain a copy of the Licence at: -// https://joinup.ec.europa.eu/software/page/eupl -// -// SPDX-License-Identifier: EUPL-1.2 - -import 'package:flutter/material.dart'; - -class CustomCard extends StatelessWidget { - const CustomCard({ - super.key, - required this.child, - this.size, - this.onTap, - this.margin, - this.opacity, - this.padding = const EdgeInsets.all(0), - this.blurRadius = 5, - this.shadowColor = Colors.grey, - this.offset = const Offset(0.0, 0.0), - this.color, - this.borderRadius = const BorderRadius.all(Radius.circular(10)), - this.onLongPress, - this.withBorder = true, - this.borderWidth = 1, - }); - - const CustomCard.roundVertical({ - required this.child, - super.key, - this.onTap, - this.size, - this.margin, - this.opacity, - this.padding = const EdgeInsets.all(0), - this.blurRadius = 5, - this.borderRadius = const BorderRadius.vertical( - top: Radius.circular(500), bottom: Radius.circular(500)), - this.shadowColor = Colors.grey, - this.offset = const Offset(0.0, 0.0), - this.color, - this.onLongPress, - this.withBorder = false, - this.borderWidth = 1, - }); - - final Widget child; - final VoidCallback? onTap; - final VoidCallback? onLongPress; - final Size? size; - final Padding? margin; - final double? opacity; - final EdgeInsetsGeometry padding; - final double blurRadius; - final BorderRadius borderRadius; - final double borderWidth; - final Color shadowColor; - final Offset offset; - final Color? color; - final bool withBorder; - - @override - Widget build(BuildContext context) { - final color = this.color ?? Theme.of(context).cardColor; - return SafeArea( - left: true, - right: true, - bottom: false, - top: false, - child: ClipRRect( - borderRadius: borderRadius, - child: Padding( - padding: margin as EdgeInsetsGeometry? ?? const EdgeInsets.all(0.0), - child: Opacity( - opacity: opacity ?? 1, - child: Container( - width: size?.height, - height: size?.width, - decoration: BoxDecoration( - color: color, - borderRadius: borderRadius, - // border: Border.all(color: isDarkThemeEnabled(context) ? Colors.grey[800] : Colors.grey[300]), - border: withBorder - ? Border.all(color: Colors.grey[300]!, width: borderWidth) - : null, - ), - child: Material( - color: Colors.transparent, - child: InkWell( - borderRadius: borderRadius, - onTap: onTap, - onLongPress: onLongPress, - child: Padding( - padding: padding, - child: child, - ), - ), - ), - ), - ), - ), - ), - ); - } -} diff --git a/website/lib/widgets/snackbars.dart b/website/lib/widgets/snackbars.dart deleted file mode 100644 index 89b3bd61f..000000000 --- a/website/lib/widgets/snackbars.dart +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) 2023 Sharezone UG (haftungsbeschränkt) -// Licensed under the EUPL-1.2-or-later. -// -// You may obtain a copy of the Licence at: -// https://joinup.ec.europa.eu/software/page/eupl -// -// SPDX-License-Identifier: EUPL-1.2 - -import 'dart:developer'; - -import 'package:flutter/material.dart'; - -void showSnackSec({ - required BuildContext context, - String? text, - int seconds = 3, - bool withLoadingCircle = false, - SnackBarAction? action, - bool hideCurrentSnackBar = true, - SnackBarBehavior? behavior, -}) { - showSnack( - context: context, - duration: Duration(seconds: seconds), - text: text, - withLoadingCircle: withLoadingCircle, - action: action, - hideCurrentSnackBar: hideCurrentSnackBar, - behavior: behavior, - ); -} - -void showSnack({ - required BuildContext context, - String? text, - Duration duration = const Duration(seconds: 3), - bool withLoadingCircle = false, - SnackBarAction? action, - bool hideCurrentSnackBar = true, - SnackBarBehavior? behavior = SnackBarBehavior.floating, -}) { - final snackBar = SnackBar( - content: withLoadingCircle == false - ? Text(text!) - : Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const Padding( - padding: EdgeInsets.only(right: 20, left: 4), - child: SizedBox( - width: 25, - height: 25, - child: CircularProgressIndicator(), - ), - ), - Flexible(child: Text(text!)), - ], - ), - duration: duration, - action: action, - behavior: behavior, - ); - - try { - if (hideCurrentSnackBar) { - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - } - ScaffoldMessenger.of(context).showSnackBar(snackBar); - } catch (e) { - log("Fehler beim anzeigen der SnackBar über den Kontext: ${e.toString()}"); - } -}