Skip to content

Commit

Permalink
feat: some new stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardo.gabriel committed Apr 9, 2024
1 parent 8405071 commit ad9564b
Show file tree
Hide file tree
Showing 46 changed files with 1,507 additions and 645 deletions.
32 changes: 32 additions & 0 deletions lib/controllers/grx_animated_loading_button.controller.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:rounded_loading_button_plus/rounded_loading_button.dart';

class GrxAnimatedLoadingButtonController
extends RoundedLoadingButtonController {
GrxAnimatedLoadingButtonController({
this.resetStateDuration = const Duration(seconds: 3),
});

final Duration? resetStateDuration;

@override
void success() {
super.success();

_resetButtonState();
}

@override
void error() {
super.error();

_resetButtonState();
}

void _resetButtonState() {
if (resetStateDuration != null && resetStateDuration!.inMilliseconds > 0) {
Future.delayed(resetStateDuration!, () {
reset();
});
}
}
}
67 changes: 67 additions & 0 deletions lib/delegates/grx_animated_sliver_header.delegate.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import 'dart:math' as math;
import 'dart:ui';

import 'package:flutter/material.dart';

import '../animations/grx_fade_transition.animation.dart';

const double _kToolbarExtent = 60.0;

class GrxAnimatedSliverHeaderDelegate extends SliverPersistentHeaderDelegate {
GrxAnimatedSliverHeaderDelegate({
required this.animationController,
required this.builder,
this.topSafePadding = 0.0,
this.toolbarExtent,
});

final AnimationController animationController;
final Widget Function(double progress) builder;
final double topSafePadding;
final double? toolbarExtent;

late final Animation<double> topBarAnimation =
Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(0, 0.6, curve: Curves.fastOutSlowIn),
),
);

@override
Widget build(
BuildContext context,
double shrinkOffset,
bool overlapsContent,
) {
final progress = clampDouble(shrinkOffset / maxExtent, 0.0, 1.0);

return FlexibleSpaceBar.createSettings(
minExtent: minExtent,
maxExtent: maxExtent,
currentExtent: math.max(minExtent, maxExtent - shrinkOffset),
toolbarOpacity: progress,
isScrolledUnder: shrinkOffset > maxExtent - minExtent,
child: AnimatedBuilder(
animation: animationController,
child: builder(progress),
builder: (context, child) {
return GrxFadeTransition(
animation: topBarAnimation,
child: child!,
);
},
),
);
}

@override
double get maxExtent => (toolbarExtent ?? _kToolbarExtent) + topSafePadding;

@override
double get minExtent => (toolbarExtent ?? _kToolbarExtent) + topSafePadding;

@override
bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) =>
true;
}
10 changes: 8 additions & 2 deletions lib/delegates/grx_searchable_sliver_header.delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import '../widgets/headers/grx_searchable_header.widget.dart';

const double _kToolbarExtent = 60.0;
const double _kFilterFieldExtent = 70.0;
const double _kTotalWidgetExtent = 35.0;

class GrxSearchableSliverHeaderDelegate extends SliverPersistentHeaderDelegate {
const GrxSearchableSliverHeaderDelegate({
Expand All @@ -20,6 +21,7 @@ class GrxSearchableSliverHeaderDelegate extends SliverPersistentHeaderDelegate {
this.onFilter,
this.onAdd,
this.onQuickSearchHandler,
this.onTotalWidgetBuilder,
this.hintText,
this.canPop = false,
});
Expand All @@ -31,6 +33,7 @@ class GrxSearchableSliverHeaderDelegate extends SliverPersistentHeaderDelegate {
final void Function()? onFilter;
final void Function()? onAdd;
final void Function(String)? onQuickSearchHandler;
final Widget Function(double progress)? onTotalWidgetBuilder;
final String? hintText;
final bool canPop;

Expand Down Expand Up @@ -69,6 +72,7 @@ class GrxSearchableSliverHeaderDelegate extends SliverPersistentHeaderDelegate {
),
],
onQuickSearchHandler: onQuickSearchHandler,
extraWidget: onTotalWidgetBuilder?.call(progress),
),
);
}
Expand All @@ -77,13 +81,15 @@ class GrxSearchableSliverHeaderDelegate extends SliverPersistentHeaderDelegate {
double get maxExtent =>
_kToolbarExtent +
topSafePadding +
(onQuickSearchHandler != null ? _kFilterFieldExtent : 0);
(onQuickSearchHandler != null ? _kFilterFieldExtent : 0) +
(onTotalWidgetBuilder != null ? _kTotalWidgetExtent : 0);

@override
double get minExtent =>
_kToolbarExtent +
topSafePadding +
(onQuickSearchHandler != null ? _kFilterFieldExtent : 0);
(onQuickSearchHandler != null ? _kFilterFieldExtent : 0) +
(onTotalWidgetBuilder != null ? _kTotalWidgetExtent : 0);

@override
bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) =>
Expand Down
14 changes: 11 additions & 3 deletions lib/grex_ds.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
library grex_ds;

export 'package:rounded_loading_button_plus/rounded_loading_button.dart'
show RoundedLoadingButtonController;
export 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';

/// Animations
export 'animations/grx_fade_transition.animation.dart' show GrxFadeTransition;
/// Controllers
export 'controllers/grx_animated_loading_button.controller.dart'
show GrxAnimatedLoadingButtonController;
/// Enums
export 'enums/grx_align.enum.dart' show GrxAlign;
export 'enums/grx_country_id.enum.dart' show GrxCountryId;
Expand Down Expand Up @@ -99,10 +101,10 @@ export 'widgets/fields/grx_date_time_picker_form_field.widget.dart'
show GrxDateTimePickerFormField;
export 'widgets/fields/grx_dropdown_form_field.widget.dart'
show GrxDropdownFormField;
export 'widgets/fields/grx_filter_field.widget.dart' show GrxFilterField;
export 'widgets/fields/grx_multi_select_form_field.widget.dart'
show GrxMultiSelectFormField;
export 'widgets/fields/grx_phone_form_field.widget.dart' show GrxPhoneFormField;
export 'widgets/fields/grx_search_field.widget.dart' show GrxSearchField;
export 'widgets/fields/grx_switch_form_field.widget.dart'
show GrxSwitchFormField;
export 'widgets/fields/grx_text_field.widget.dart' show GrxTextField;
Expand All @@ -123,8 +125,12 @@ export 'widgets/grx_help.widget.dart' show GrxHelpWidget;
/// Widgets/Lists
export 'widgets/grx_sliver_animated_list.widget.dart'
show GrxSliverAnimatedList;
/// Widget/Loading
export 'widgets/grx_spinner_loading.widget.dart' show GrxSpinnerLoading;
/// Widget/Avatar
export 'widgets/grx_user_avatar.widget.dart' show GrxUserAvatar;
export 'widgets/headers/grx_animated_sliver_header.widget.dart'
show GrxAnimatedSliverHeader;
/// Widget/Headers
export 'widgets/headers/grx_header.widget.dart' show GrxHeader;
export 'widgets/headers/grx_searchable_header.widget.dart'
Expand All @@ -134,6 +140,8 @@ export 'widgets/headers/grx_searchable_sliver_header.widget.dart'
/// Widgets/Layout
export 'widgets/layout/grx_responsive_layout.widget.dart'
show GrxResponsiveLayout;
export 'widgets/list/grx_list_empty.widget.dart' show GrxListEmpty;
export 'widgets/list/grx_list_error.widget.dart' show GrxListError;
/// Widgets/Media
export 'widgets/media/grx_svg.widget.dart' show GrxSvg;
/// Widgets/Typography
Expand Down
19 changes: 19 additions & 0 deletions lib/models/grx_button_options.model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:flutter/widgets.dart';

import '../themes/colors/grx_colors.dart';

class GrxButtonOptions {
const GrxButtonOptions({
required this.title,
this.onPressed,
this.icon,
this.backgroundColor,
this.foregroundColor = GrxColors.cffffffff,
});

final String title;
final Color foregroundColor;
final VoidCallback? onPressed;
final IconData? icon;
final Color? backgroundColor;
}
1 change: 1 addition & 0 deletions lib/themes/colors/grx_colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ abstract class GrxColors {
static const Color cffd2dfe6 = Color(0xffd2dfe6);
static const Color cffd6dfea = Color(0xffd6dfea);
static const Color cffdce2e8 = Color(0xffdce2e8);
static const Color cffdeeaf3 = Color(0xffdeeaf3);
static const Color cffe0efff = Color(0xffe0efff);
static const Color cffe8f2ff = Color(0xffe8f2ff);
static const Color cfff2f7fd = Color(0xfff2f7fd);
Expand Down
4 changes: 2 additions & 2 deletions lib/themes/fields/grx_field_styles.theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ abstract class GrxFieldStyles {
GrxCaptionTextStyle(color: GrxColors.cfffc5858);

static const underlineInputBorder = UnderlineInputBorder(
borderSide: BorderSide(color: GrxColors.cff75f3ab),
borderSide: BorderSide(color: GrxColors.primarySwatch),
);

static const underlineInputFocusedBorder = UnderlineInputBorder(
borderSide: BorderSide(color: GrxColors.cff75f3ab, width: 2),
borderSide: BorderSide(color: GrxColors.primarySwatch, width: 2),
);

static const underlineInputErrorBorder = UnderlineInputBorder(
Expand Down
3 changes: 3 additions & 0 deletions lib/themes/grx_theme_data.theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ abstract class GrxThemeData {
splashColor: GrxColors.cff7593b5.withOpacity(.3),
highlightColor: GrxColors.cff7593b5.withOpacity(.2),
textTheme: const GrxTextTheme(),
progressIndicatorTheme: const ProgressIndicatorThemeData(
color: GrxColors.primarySwatch,
),
);
}
2 changes: 1 addition & 1 deletion lib/utils/grx_utils.util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
/// All utility constants that are used by this Design System.
abstract class GrxUtils {
static const packageName = 'grex_ds';
static const defaultAnimationDuration = Duration(milliseconds: 300);
static const defaultAnimationDuration = Duration(milliseconds: 400);
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:super_sliver_list/super_sliver_list.dart';

import '../../extensions/list.extension.dart';
import '../../models/grx_country.model.dart';
import '../../themes/colors/grx_colors.dart';
import '../../utils/grx_country.util.dart';
import '../../utils/grx_utils.util.dart';
import '../checkbox/grx_rounded_checkbox.widget.dart';
import '../fields/grx_filter_field.widget.dart';
import '../fields/grx_search_field.widget.dart';
import '../grx_card.widget.dart';
import '../typography/grx_body_text.widget.dart';
import '../typography/grx_headline_small_text.widget.dart';
Expand Down Expand Up @@ -62,7 +63,7 @@ class _GrxBottomSheetCountriesState extends State<GrxBottomSheetCountries> {
vertical: 10.0,
horizontal: 8.0,
),
child: GrxFilterField(
child: GrxSearchField(
// searchFieldController: widget.quickSearchFieldController!,
searchFieldController: searchFieldController,
onChanged: _onSearch,
Expand All @@ -77,7 +78,7 @@ class _GrxBottomSheetCountriesState extends State<GrxBottomSheetCountries> {
right: 8.0,
bottom: viewInsets.bottom + padding.bottom + 8.0,
),
sliver: SliverList(
sliver: SuperSliverList(
delegate: SliverChildBuilderDelegate(
childCount: _filteredCountries.length,
(context, index) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'package:flutter/material.dart';
import 'package:super_sliver_list/super_sliver_list.dart';

import '../../themes/colors/grx_colors.dart';
import '../buttons/grx_primary_button.widget.dart';
import '../buttons/grx_secondary_button.widget.dart';
import '../fields/grx_filter_field.widget.dart';
import '../fields/grx_search_field.widget.dart';
import '../typography/grx_caption_large_text.widget.dart';

class GrxBottomSheetFormFieldBody<T> extends StatefulWidget {
Expand Down Expand Up @@ -135,7 +136,7 @@ class _GrxBottomSheetFormFieldBodyState<T>
vertical: 10,
horizontal: 8,
),
child: GrxFilterField(
child: GrxSearchField(
searchFieldController:
widget.quickSearchFieldController!,
onChanged: _filterData,
Expand Down Expand Up @@ -167,7 +168,7 @@ class _GrxBottomSheetFormFieldBodyState<T>
8
: 0,
),
sliver: SliverList(
sliver: SuperSliverList(
delegate: SliverChildBuilderDelegate(
childCount: _list.length,
(context, index) {
Expand Down
12 changes: 6 additions & 6 deletions lib/widgets/buttons/grx_animated_loading_button.widget.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/widgets.dart';
// import 'package:rounded_loading_button/rounded_loading_button.dart';
import 'package:rounded_loading_button_plus/rounded_loading_button.dart';

import '../../controllers/grx_animated_loading_button.controller.dart';
import '../../enums/grx_text_transform.enum.dart';
import '../../themes/colors/grx_colors.dart';
import '../typography/grx_headline_small_text.widget.dart';
Expand All @@ -19,12 +19,12 @@ class GrxAnimatedLoadingButton extends StatelessWidget {
this.width,
this.margin,
this.animateOnTap = false,
final RoundedLoadingButtonController? controller,
}) : controller = controller ?? RoundedLoadingButtonController(),
final GrxAnimatedLoadingButtonController? controller,
}) : controller = controller ?? GrxAnimatedLoadingButtonController(),
assert(text != null || textSpan != null);

final RoundedLoadingButtonController controller;
final void Function(RoundedLoadingButtonController controller) onPressed;
final GrxAnimatedLoadingButtonController controller;
final void Function(GrxAnimatedLoadingButtonController controller) onPressed;
final String? text;
final InlineSpan? textSpan;
final GrxTextTransform transform;
Expand All @@ -47,7 +47,7 @@ class GrxAnimatedLoadingButton extends StatelessWidget {
borderRadius: height / 2,
color: backgroundColor,
errorColor: GrxColors.cfffc5858,
successColor: GrxColors.cff75f3ab,
successColor: GrxColors.primarySwatch,
animateOnTap: animateOnTap,
width: this.width ?? width,
child: Padding(
Expand Down
11 changes: 9 additions & 2 deletions lib/widgets/buttons/grx_bottom_button.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class GrxBottomButton extends StatelessWidget {
this.iconSize = 23,
this.iconColor,
this.iconPadding = 5,
this.isLoading = false,
});

final String text;
Expand All @@ -27,6 +28,7 @@ class GrxBottomButton extends StatelessWidget {
final double iconSize;
final Color? iconColor;
final double iconPadding;
final bool isLoading;

@override
Widget build(BuildContext context) {
Expand All @@ -39,9 +41,13 @@ class GrxBottomButton extends StatelessWidget {
left: 25,
top: 22,
right: 25,
bottom: 22 + MediaQuery.of(context).viewPadding.bottom,
bottom: 22 + MediaQuery.viewPaddingOf(context).bottom,
),
backgroundColor: GrxColors.cff69efa3,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
side: BorderSide.none,
),
backgroundColor: GrxColors.primarySwatch,
foregroundColor: GrxColors.cffffffff,
style: const GrxHeadlineMediumTextStyle(),
icon: icon,
Expand All @@ -50,6 +56,7 @@ class GrxBottomButton extends StatelessWidget {
iconColor: iconColor,
iconPadding: iconPadding,
onPressed: onPressed,
isLoading: isLoading,
);
}
}
Loading

0 comments on commit ad9564b

Please sign in to comment.