From 1a17f73df464ea95c9bb818bcce0018621c7da28 Mon Sep 17 00:00:00 2001 From: Inex Code Date: Wed, 14 Sep 2022 18:14:55 +0300 Subject: [PATCH] Delete unused UI components. --- .../brand_modal_sheet/brand_modal_sheet.dart | 63 -------------- .../components/brand_radio/brand_radio.dart | 2 + .../brand_radio_tile/brand_radio_tile.dart | 2 + .../brand_span_button/brand_span_button.dart | 35 -------- lib/ui/components/brand_text/brand_text.dart | 2 + .../dots_indicator/dots_indicator.dart | 33 ------- .../components/pre_styled_buttons/close.dart | 19 ---- .../components/pre_styled_buttons/flash.dart | 87 ------------------- .../pre_styled_buttons/flash_fab.dart | 1 + .../pre_styled_buttons.dart | 22 ----- lib/utils/extensions/elevation_extension.dart | 32 ------- lib/utils/route_transitions/slide_bottom.dart | 49 ----------- lib/utils/route_transitions/slide_right.dart | 48 ---------- 13 files changed, 7 insertions(+), 388 deletions(-) delete mode 100644 lib/ui/components/brand_modal_sheet/brand_modal_sheet.dart delete mode 100644 lib/ui/components/brand_span_button/brand_span_button.dart delete mode 100644 lib/ui/components/dots_indicator/dots_indicator.dart delete mode 100644 lib/ui/components/pre_styled_buttons/close.dart delete mode 100644 lib/ui/components/pre_styled_buttons/flash.dart delete mode 100644 lib/ui/components/pre_styled_buttons/pre_styled_buttons.dart delete mode 100644 lib/utils/extensions/elevation_extension.dart delete mode 100644 lib/utils/route_transitions/slide_bottom.dart delete mode 100644 lib/utils/route_transitions/slide_right.dart diff --git a/lib/ui/components/brand_modal_sheet/brand_modal_sheet.dart b/lib/ui/components/brand_modal_sheet/brand_modal_sheet.dart deleted file mode 100644 index 6435f7bc..00000000 --- a/lib/ui/components/brand_modal_sheet/brand_modal_sheet.dart +++ /dev/null @@ -1,63 +0,0 @@ -// import 'package:flutter/material.dart'; - -// var navigatorKey = GlobalKey(); - -// class BrandModalSheet extends StatelessWidget { -// const BrandModalSheet({ -// Key? key, -// this.child, -// }) : super(key: key); - -// final Widget? child; -// @override -// Widget build(BuildContext context) { -// return DraggableScrollableSheet( -// minChildSize: 1, -// initialChildSize: 1, -// maxChildSize: 1, -// builder: (context, scrollController) { -// return SingleChildScrollView( -// controller: scrollController, -// physics: ClampingScrollPhysics(), -// child: Container( -// child: Column( -// children: [ -// GestureDetector( -// onTap: () => Navigator.of(context).pop(), -// behavior: HitTestBehavior.opaque, -// child: Container( -// width: double.infinity, -// child: Center( -// child: Padding( -// padding: EdgeInsets.only(top: 132, bottom: 6), -// child: Container( -// height: 4, -// width: 30, -// decoration: BoxDecoration( -// borderRadius: BorderRadius.circular(2), -// color: Color(0xFFE3E3E3).withOpacity(0.65), -// ), -// ), -// ), -// ), -// ), -// ), -// Container( -// constraints: BoxConstraints( -// minHeight: MediaQuery.of(context).size.height - 132, -// maxHeight: MediaQuery.of(context).size.height - 132, -// ), -// decoration: BoxDecoration( -// borderRadius: -// BorderRadius.vertical(top: Radius.circular(20)), -// color: Theme.of(context).scaffoldBackgroundColor, -// ), -// width: double.infinity, -// child: child), -// ], -// ), -// ), -// ); -// }); -// } -// } diff --git a/lib/ui/components/brand_radio/brand_radio.dart b/lib/ui/components/brand_radio/brand_radio.dart index 60f41fb5..2dc8fc00 100644 --- a/lib/ui/components/brand_radio/brand_radio.dart +++ b/lib/ui/components/brand_radio/brand_radio.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:selfprivacy/config/brand_colors.dart'; +// TODO: Delete this file. + class BrandRadio extends StatelessWidget { const BrandRadio({ required this.isChecked, diff --git a/lib/ui/components/brand_radio_tile/brand_radio_tile.dart b/lib/ui/components/brand_radio_tile/brand_radio_tile.dart index 5b18247d..3226c97b 100644 --- a/lib/ui/components/brand_radio_tile/brand_radio_tile.dart +++ b/lib/ui/components/brand_radio_tile/brand_radio_tile.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:selfprivacy/ui/components/brand_radio/brand_radio.dart'; import 'package:selfprivacy/ui/components/brand_text/brand_text.dart'; +// TODO: Delete this file + class BrandRadioTile extends StatelessWidget { const BrandRadioTile({ required this.isChecked, diff --git a/lib/ui/components/brand_span_button/brand_span_button.dart b/lib/ui/components/brand_span_button/brand_span_button.dart deleted file mode 100644 index de19730e..00000000 --- a/lib/ui/components/brand_span_button/brand_span_button.dart +++ /dev/null @@ -1,35 +0,0 @@ -import 'package:flutter/gestures.dart'; -import 'package:flutter/material.dart'; -import 'package:selfprivacy/config/brand_colors.dart'; -import 'package:url_launcher/url_launcher.dart'; - -class BrandSpanButton extends TextSpan { - BrandSpanButton({ - required final String text, - required final VoidCallback onTap, - final TextStyle? style, - }) : super( - recognizer: TapGestureRecognizer()..onTap = onTap, - text: text, - style: (style ?? const TextStyle()).copyWith(color: BrandColors.blue), - ); - - BrandSpanButton.link({ - required final String text, - final String? urlString, - final TextStyle? style, - }) : super( - recognizer: TapGestureRecognizer() - ..onTap = () => _launchURL(urlString ?? text), - text: text, - style: (style ?? const TextStyle()).copyWith(color: BrandColors.blue), - ); - - static Future _launchURL(final String link) async { - if (await canLaunchUrl(Uri.parse(link))) { - await launchUrl(Uri.parse(link)); - } else { - throw 'Could not launch $link'; - } - } -} diff --git a/lib/ui/components/brand_text/brand_text.dart b/lib/ui/components/brand_text/brand_text.dart index 544ffcec..00e9d736 100644 --- a/lib/ui/components/brand_text/brand_text.dart +++ b/lib/ui/components/brand_text/brand_text.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:selfprivacy/config/text_themes.dart'; export 'package:selfprivacy/utils/extensions/text_extensions.dart'; +// TODO: Delete this file + enum TextType { h1, // right now only at onboarding and opened providers h2, // cards titles diff --git a/lib/ui/components/dots_indicator/dots_indicator.dart b/lib/ui/components/dots_indicator/dots_indicator.dart deleted file mode 100644 index fff647b7..00000000 --- a/lib/ui/components/dots_indicator/dots_indicator.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:selfprivacy/config/brand_colors.dart'; - -class DotsIndicator extends StatelessWidget { - const DotsIndicator({ - required this.activeIndex, - required this.count, - final super.key, - }); - - final int activeIndex; - final int count; - - @override - Widget build(final BuildContext context) { - final List dots = List.generate( - count, - (final index) => Container( - margin: const EdgeInsets.symmetric(horizontal: 5, vertical: 10), - height: 10, - width: 10, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: index == activeIndex ? BrandColors.blue : BrandColors.gray2, - ), - ), - ); - return Row( - mainAxisAlignment: MainAxisAlignment.center, - children: dots, - ); - } -} diff --git a/lib/ui/components/pre_styled_buttons/close.dart b/lib/ui/components/pre_styled_buttons/close.dart deleted file mode 100644 index 48a1bddb..00000000 --- a/lib/ui/components/pre_styled_buttons/close.dart +++ /dev/null @@ -1,19 +0,0 @@ -part of 'pre_styled_buttons.dart'; - -class _CloseButton extends StatelessWidget { - const _CloseButton({required this.onPress}); - - final VoidCallback onPress; - - @override - Widget build(final BuildContext context) => OutlinedButton( - onPressed: () => Navigator.of(context).pop(), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - BrandText.h4('basis.close'.tr()), - const Icon(Icons.close), - ], - ), - ); -} diff --git a/lib/ui/components/pre_styled_buttons/flash.dart b/lib/ui/components/pre_styled_buttons/flash.dart deleted file mode 100644 index 3e780fd7..00000000 --- a/lib/ui/components/pre_styled_buttons/flash.dart +++ /dev/null @@ -1,87 +0,0 @@ -part of 'pre_styled_buttons.dart'; - -class _BrandFlashButton extends StatefulWidget { - @override - _BrandFlashButtonState createState() => _BrandFlashButtonState(); -} - -class _BrandFlashButtonState extends State<_BrandFlashButton> - with SingleTickerProviderStateMixin { - late AnimationController _animationController; - late Animation _colorTween; - - @override - void initState() { - _animationController = AnimationController( - vsync: this, - duration: const Duration(milliseconds: 800), - ); - _colorTween = ColorTween( - begin: BrandColors.black, - end: BrandColors.primary, - ).animate(_animationController); - - super.initState(); - WidgetsBinding.instance.addPostFrameCallback(_afterLayout); - } - - void _afterLayout(final _) { - if (Theme.of(context).brightness == Brightness.dark) { - setState(() { - _colorTween = ColorTween( - begin: BrandColors.white, - end: BrandColors.primary, - ).animate(_animationController); - }); - } - } - - @override - void dispose() { - _animationController.dispose(); - super.dispose(); - } - - bool wasPrevStateIsEmpty = true; - - @override - Widget build(final BuildContext context) => - BlocListener( - listener: (final context, final state) { - if (wasPrevStateIsEmpty && state is! JobsStateEmpty) { - wasPrevStateIsEmpty = false; - _animationController.forward(); - } else if (!wasPrevStateIsEmpty && state is JobsStateEmpty) { - wasPrevStateIsEmpty = true; - - _animationController.reverse(); - } - }, - child: IconButton( - onPressed: () { - showBrandBottomSheet( - context: context, - builder: (final context) => const BrandBottomSheet( - isExpended: true, - child: JobsContent(), - ), - ); - }, - icon: AnimatedBuilder( - animation: _colorTween, - builder: (final context, final child) { - final double v = _animationController.value; - final IconData icon = - v > 0.5 ? Ionicons.flash : Ionicons.flash_outline; - return Transform.scale( - scale: 1 + (v < 0.5 ? v : 1 - v) * 2, - child: Icon( - icon, - color: _colorTween.value, - ), - ); - }, - ), - ), - ); -} diff --git a/lib/ui/components/pre_styled_buttons/flash_fab.dart b/lib/ui/components/pre_styled_buttons/flash_fab.dart index c9fb754f..b97f3bd6 100644 --- a/lib/ui/components/pre_styled_buttons/flash_fab.dart +++ b/lib/ui/components/pre_styled_buttons/flash_fab.dart @@ -55,6 +55,7 @@ class _BrandFabState extends State }, child: FloatingActionButton( onPressed: () { + // TODO: Make a hero animation to the screen showBrandBottomSheet( context: context, builder: (final BuildContext context) => const BrandBottomSheet( diff --git a/lib/ui/components/pre_styled_buttons/pre_styled_buttons.dart b/lib/ui/components/pre_styled_buttons/pre_styled_buttons.dart deleted file mode 100644 index 5649236c..00000000 --- a/lib/ui/components/pre_styled_buttons/pre_styled_buttons.dart +++ /dev/null @@ -1,22 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:ionicons/ionicons.dart'; -import 'package:selfprivacy/config/brand_colors.dart'; -import 'package:selfprivacy/logic/cubit/client_jobs/client_jobs_cubit.dart'; -import 'package:selfprivacy/ui/components/brand_bottom_sheet/brand_bottom_sheet.dart'; -import 'package:selfprivacy/ui/components/brand_text/brand_text.dart'; -import 'package:easy_localization/easy_localization.dart'; -import 'package:selfprivacy/ui/components/jobs_content/jobs_content.dart'; -import 'package:selfprivacy/ui/helpers/modals.dart'; - -part 'close.dart'; -part 'flash.dart'; - -class PreStyledButtons { - static Widget close({ - required final VoidCallback onPress, - }) => - _CloseButton(onPress: onPress); - - static Widget flash() => _BrandFlashButton(); -} diff --git a/lib/utils/extensions/elevation_extension.dart b/lib/utils/extensions/elevation_extension.dart deleted file mode 100644 index 9c6bbc14..00000000 --- a/lib/utils/extensions/elevation_extension.dart +++ /dev/null @@ -1,32 +0,0 @@ -library elevation_extension; - -import 'package:flutter/material.dart'; -import 'package:flutter/cupertino.dart'; - -extension ElevationExtension on BoxDecoration { - BoxDecoration copyWith({ - final Color? color, - final DecorationImage? image, - final BoxBorder? border, - final BorderRadiusGeometry? borderRadius, - final List? boxShadow, - final Gradient? gradient, - final BlendMode? backgroundBlendMode, - final BoxShape? shape, - }) => - BoxDecoration( - color: color ?? this.color, - image: image ?? this.image, - border: border ?? this.border, - borderRadius: borderRadius ?? this.borderRadius, - boxShadow: this.boxShadow != null || boxShadow != null - ? [ - ...this.boxShadow ?? [], - ...boxShadow ?? [] - ] - : null, - gradient: gradient ?? this.gradient, - backgroundBlendMode: backgroundBlendMode ?? this.backgroundBlendMode, - shape: shape ?? this.shape, - ); -} diff --git a/lib/utils/route_transitions/slide_bottom.dart b/lib/utils/route_transitions/slide_bottom.dart deleted file mode 100644 index e187b4d7..00000000 --- a/lib/utils/route_transitions/slide_bottom.dart +++ /dev/null @@ -1,49 +0,0 @@ -import 'package:flutter/material.dart'; - -Function pageBuilder = (final Widget widget) => ( - final BuildContext context, - final Animation animation, - final Animation secondaryAnimation, - ) => - widget; - -Function transitionsBuilder = ( - final BuildContext context, - final Animation animation, - final Animation secondaryAnimation, - final Widget child, -) => - SlideTransition( - position: Tween( - begin: const Offset(0, 1), - end: Offset.zero, - ).animate(animation), - child: Container( - decoration: animation.isCompleted - ? null - : const BoxDecoration( - border: Border( - bottom: BorderSide( - color: Colors.black, - ), - ), - ), - child: child, - ), - ); - -class SlideBottomRoute extends PageRouteBuilder { - SlideBottomRoute(this.widget) - : super( - transitionDuration: const Duration(milliseconds: 150), - pageBuilder: pageBuilder(widget), - transitionsBuilder: transitionsBuilder as Widget Function( - BuildContext, - Animation, - Animation, - Widget, - ), - ); - - final Widget widget; -} diff --git a/lib/utils/route_transitions/slide_right.dart b/lib/utils/route_transitions/slide_right.dart deleted file mode 100644 index eae4414d..00000000 --- a/lib/utils/route_transitions/slide_right.dart +++ /dev/null @@ -1,48 +0,0 @@ -import 'package:flutter/material.dart'; - -Function pageBuilder = (final Widget widget) => ( - final BuildContext context, - final Animation animation, - final Animation secondaryAnimation, - ) => - widget; - -Function transitionsBuilder = ( - final BuildContext context, - final Animation animation, - final Animation secondaryAnimation, - final Widget child, -) => - SlideTransition( - position: Tween( - begin: const Offset(-1, 0), - end: Offset.zero, - ).animate(animation), - child: Container( - decoration: animation.isCompleted - ? null - : const BoxDecoration( - border: Border( - right: BorderSide( - color: Colors.black, - ), - ), - ), - child: child, - ), - ); - -class SlideRightRoute extends PageRouteBuilder { - SlideRightRoute(this.widget) - : super( - pageBuilder: pageBuilder(widget), - transitionsBuilder: transitionsBuilder as Widget Function( - BuildContext, - Animation, - Animation, - Widget, - ), - ); - - final Widget widget; -}