From e1b72975dd55b875c995279eabd6edb15355488f Mon Sep 17 00:00:00 2001 From: Sandip Kakadiya Date: Fri, 2 Oct 2020 11:44:32 +0530 Subject: [PATCH 01/25] local check --- example/pubspec.lock | 81 ++++++++++++++------------------------ pubspec.lock | 94 ++++++++++++-------------------------------- 2 files changed, 56 insertions(+), 119 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 079bd9a7..0df57074 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,48 +1,48 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - archive: + async: dependency: transitive description: - name: archive + name: async url: "https://pub.dartlang.org" source: hosted - version: "2.0.11" - args: + version: "2.4.2" + boolean_selector: dependency: transitive description: - name: args + name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "1.5.2" - async: + version: "2.0.0" + characters: dependency: transitive description: - name: async + name: characters url: "https://pub.dartlang.org" source: hosted - version: "2.4.0" - boolean_selector: + version: "1.0.0" + charcode: dependency: transitive description: - name: boolean_selector + name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" - charcode: + version: "1.1.3" + clock: dependency: transitive description: - name: charcode + name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.0.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" + version: "1.14.13" convert: dependency: transitive description: @@ -50,13 +50,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.1" - crypto: - dependency: transitive - description: - name: crypto - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.3" cupertino_icons: dependency: "direct main" description: @@ -64,6 +57,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.3" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" flutter: dependency: "direct main" description: flutter @@ -93,20 +93,13 @@ packages: relative: true source: path version: "1.1.1" - image: - dependency: transitive - description: - name: image - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.4" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.8" meta: dependency: transitive description: @@ -120,7 +113,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" + version: "1.7.0" path_drawing: dependency: transitive description: @@ -135,13 +128,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.4" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0+1" petitparser: dependency: transitive description: @@ -156,13 +142,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.1" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.5" sky_engine: dependency: transitive description: flutter @@ -174,14 +153,14 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.5.5" + version: "1.7.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.9.5" stream_channel: dependency: transitive description: @@ -209,14 +188,14 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.11" + version: "0.2.17" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.2.0" url_launcher: dependency: "direct main" description: @@ -260,5 +239,5 @@ packages: source: hosted version: "3.5.0" sdks: - dart: ">=2.4.0 <3.0.0" + dart: ">=2.9.0-14.0.dev <3.0.0" flutter: ">=1.12.8 <2.0.0" diff --git a/pubspec.lock b/pubspec.lock index 67a7df16..9477cdd7 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,62 +1,55 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - archive: - dependency: transitive - description: - name: archive - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.11" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.5.2" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.0" + version: "2.4.2" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "2.0.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" - collection: + version: "1.1.3" + clock: dependency: transitive description: - name: collection + name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" - convert: + version: "1.0.1" + collection: dependency: transitive description: - name: convert + name: collection url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" - crypto: + version: "1.14.13" + fake_async: dependency: transitive description: - name: crypto + name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "1.1.0" flutter: dependency: "direct main" description: flutter @@ -67,20 +60,13 @@ packages: description: flutter source: sdk version: "0.0.0" - image: - dependency: transitive - description: - name: image - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.4" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.8" meta: dependency: transitive description: @@ -94,28 +80,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0+1" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.0" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.5" + version: "1.7.0" sky_engine: dependency: transitive description: flutter @@ -127,14 +92,14 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.5.5" + version: "1.7.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.9.5" stream_channel: dependency: transitive description: @@ -162,14 +127,14 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.11" + version: "0.2.17" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.2.0" vector_math: dependency: transitive description: @@ -177,12 +142,5 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.8" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.dartlang.org" - source: hosted - version: "3.5.0" sdks: - dart: ">=2.4.0 <3.0.0" + dart: ">=2.9.0-14.0.dev <3.0.0" From b782f361763f1eb0f1a89a078fdb4598bdb454dc Mon Sep 17 00:00:00 2001 From: Sandip Kakadiya Date: Fri, 2 Oct 2020 15:15:16 +0530 Subject: [PATCH 02/25] gfcheckbox tiles change & few components missing comments added --- lib/components/accordian/gf_accordian.dart | 1 + lib/components/animation/gf_animation.dart | 1 + lib/components/badge/gf_button_badge.dart | 50 -- lib/components/badge/gf_icon_badge.dart | 3 - lib/components/border/gf_border.dart | 5 +- lib/components/border/gf_dashed_border.dart | 26 +- .../bottom_sheet/gf_bottom_sheet.dart | 4 +- lib/components/button/gf_button.dart | 743 ------------------ lib/components/carousel/gf_carousel.dart | 1 - lib/components/checkbox/gf_checkbox.dart | 1 + .../gf_checkbox_list_tile.dart | 91 ++- lib/components/drawer/gf_drawer.dart | 2 - lib/components/drawer/gf_drawer_header.dart | 2 - .../intro_screen/gf_intro_screen.dart | 4 +- ...gf_intro_screen_bottom_navigation_bar.dart | 4 +- lib/components/shimmer/gf_shimmer.dart | 4 +- lib/types/gf_alert_type.dart | 6 +- lib/types/gf_animation_type.dart | 2 +- lib/types/gf_border_type.dart | 2 +- lib/types/gf_button_type.dart | 2 +- lib/types/gf_checkbox_type.dart | 7 +- lib/types/gf_radio_type.dart | 7 +- lib/types/gf_toast_type.dart | 6 +- lib/types/gf_toggle_type.dart | 2 +- lib/types/gf_typography_type.dart | 2 +- pubspec.yaml | 2 +- 26 files changed, 102 insertions(+), 878 deletions(-) diff --git a/lib/components/accordian/gf_accordian.dart b/lib/components/accordian/gf_accordian.dart index d57cb475..7b331522 100644 --- a/lib/components/accordian/gf_accordian.dart +++ b/lib/components/accordian/gf_accordian.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:getwidget/getwidget.dart'; class GFAccordion extends StatefulWidget { + /// An accordion is used to show (and hide) content. Use [showAccordion] to hide & show the accordion content. const GFAccordion( {Key key, this.titleChild, diff --git a/lib/components/animation/gf_animation.dart b/lib/components/animation/gf_animation.dart index 900b13aa..f0849a86 100644 --- a/lib/components/animation/gf_animation.dart +++ b/lib/components/animation/gf_animation.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:getwidget/types/gf_animation_type.dart'; class GFAnimation extends StatefulWidget { + /// Wrap any widget with [GFAnimation] to animate your widget. see [GFAnimationType] for types of animations. const GFAnimation({ Key key, this.duration, diff --git a/lib/components/badge/gf_button_badge.dart b/lib/components/badge/gf_button_badge.dart index d198a622..ee3f08bc 100644 --- a/lib/components/badge/gf_button_badge.dart +++ b/lib/components/badge/gf_button_badge.dart @@ -272,53 +272,3 @@ class _GFButtonBadgeState extends State { ), ); } - -// -//class GFButtonBadge extends GFButton { -// -// -// Widget build(BuildContext context) => ConstrainedBox( -// constraints: const BoxConstraints( -// minHeight: 26, -// minWidth: 98, -// ), -// child: Container( -// height: size, -// child: GFButton( -// onPressed: onPressed, -// onHighlightChanged: onHighlightChanged, -// textStyle: textStyle, -// boxShadow: boxShadow, -// buttonBoxShadow: badgeBoxShadow, -// focusColor: focusColor, -// hoverColor: hoverColor, -// highlightColor: highlightColor, -// splashColor: splashColor, -// elevation: elevation, -// focusElevation: focusElevation, -// hoverElevation: hoverElevation, -// highlightElevation: highlightElevation, -// disabledElevation: disabledElevation, -// constraints: constraints, -// borderShape: borderShape, -// animationDuration: animationDuration, -// clipBehavior: clipBehavior, -// focusNode: focusNode, -// autofocus: autofocus, -// type: type, -// shape: shape, -// color: color, -// textColor: textColor, -// position: position, -// size: size, -// borderSide: borderSide, -// text: text, -// icon: icon, -// blockButton: blockButton, -// fullWidthButton: fullWidthButton, -// disabledColor: disabledTextColor, -// disabledTextColor: disabledColor, -// ), -// ), -// ); -//} diff --git a/lib/components/badge/gf_icon_badge.dart b/lib/components/badge/gf_icon_badge.dart index c0ec01d7..0045b2dc 100644 --- a/lib/components/badge/gf_icon_badge.dart +++ b/lib/components/badge/gf_icon_badge.dart @@ -34,9 +34,6 @@ class _GFIconBadgeState extends State { children: [ widget.child ?? Container(), Positioned( - // top: 2, - // left: 22, - right: 0, child: widget.counterChild ?? Container(), ), ], diff --git a/lib/components/border/gf_border.dart b/lib/components/border/gf_border.dart index bbec1e75..4057d5ed 100644 --- a/lib/components/border/gf_border.dart +++ b/lib/components/border/gf_border.dart @@ -5,11 +5,12 @@ import 'package:getwidget/components/border/gf_dashed_border.dart'; import 'package:getwidget/types/gf_border_type.dart'; class GFBorder extends StatelessWidget { + /// Create different types of borders around given child widget GFBorder({ @required this.child, this.color = Colors.black, this.strokeWidth = 1, - this.type = GFBorderType.Rect, + this.type = GFBorderType.rect, this.dashedLine = const [3, 1], this.padding = const EdgeInsets.all(10), this.radius = const Radius.circular(0), @@ -27,7 +28,7 @@ class GFBorder extends StatelessWidget { final double strokeWidth; /// color of type [Color] or GFColor which is used to change the color of the border type - final dynamic color; + final Color color; /// dashedLine of type [List] which is used for the linear and simple dashed line of border final List dashedLine; diff --git a/lib/components/border/gf_dashed_border.dart b/lib/components/border/gf_dashed_border.dart index a68d9d0a..ae321ead 100644 --- a/lib/components/border/gf_dashed_border.dart +++ b/lib/components/border/gf_dashed_border.dart @@ -9,7 +9,7 @@ class DashedType extends CustomPainter { this.strokeWidth = 2, this.dashedLine = const [3, 1], this.color = Colors.black, - this.type = GFBorderType.Rect, + this.type = GFBorderType.rect, this.radius = const Radius.circular(0), this.customPath, }) : assert(dashedLine.isNotEmpty, 'dash line cannot be empty'); @@ -21,7 +21,7 @@ class DashedType extends CustomPainter { final List dashedLine; /// color of type [Color] or GFColor which is used to change the color of the border type - final dynamic color; + final Color color; /// type of [GFBorderType] which is used to define the different types of borders ie, circle, Rect, RRect and oval final GFBorderType type; @@ -56,20 +56,19 @@ class DashedType extends CustomPainter { Path _getPath(Size size) { Path path; switch (type) { - case GFBorderType.Circle: + case GFBorderType.circle: path = _getCirclePath(size); break; - case GFBorderType.RRect: + case GFBorderType.rRect: path = _getRRectPath(size, radius); break; - case GFBorderType.Rect: + case GFBorderType.rect: path = _getRectPath(size); break; - case GFBorderType.Oval: + case GFBorderType.oval: path = _getOvalPath(size); break; } - return dashPath(path, dashedarray: CircularIntervalList(dashedLine)); } @@ -94,7 +93,6 @@ class DashedType extends CustomPainter { } /// gives a Rounded Rectangular Path with [radius] of [size] for borderType - Path _getRRectPath(Size size, Radius radius) => Path() ..addRRect( RRect.fromRectAndRadius( @@ -140,10 +138,8 @@ class DashedType extends CustomPainter { class CircularIntervalList { CircularIntervalList(this.values); - final List values; int index = 0; - T get next { if (index >= values.length) { index = 0; @@ -159,7 +155,6 @@ Path dashPath(Path source, if (source == null) { return null; } - final Path dest = Path(); for (final PathMetric metric in source.computeMetrics()) { double distance = dashOffset._calculate(metric.length); @@ -173,27 +168,26 @@ Path dashPath(Path source, draw = !draw; } } - return dest; } /// Specifies the starting position of a dashed array or line on a path, either as a percentage or absolute -enum _DashOffsetType { Absolute, Percentage } +enum _DashOffsetType { absolute, percentage } class DashOffset { ///gives offset of the dashed path that will be measured as a percentage which ranges from 0.0 to 1.0 DashOffset.percentage(double percentage) : _value = percentage.clamp(0.0, 1.0) ?? 0.0, - _dashOffsetType = _DashOffsetType.Percentage; + _dashOffsetType = _DashOffsetType.percentage; ///gives offset of the dashed path that will be measured as a absolute value const DashOffset.absolute(double start) : _value = start ?? 0.0, - _dashOffsetType = _DashOffsetType.Absolute; + _dashOffsetType = _DashOffsetType.absolute; final double _value; final _DashOffsetType _dashOffsetType; double _calculate(double length) => - _dashOffsetType == _DashOffsetType.Absolute ? _value : length * _value; + _dashOffsetType == _DashOffsetType.absolute ? _value : length * _value; } diff --git a/lib/components/bottom_sheet/gf_bottom_sheet.dart b/lib/components/bottom_sheet/gf_bottom_sheet.dart index e772ccf3..ad9ddf60 100644 --- a/lib/components/bottom_sheet/gf_bottom_sheet.dart +++ b/lib/components/bottom_sheet/gf_bottom_sheet.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; class GFBottomSheet extends StatefulWidget { + /// Opens sheet from bottom as a popup on current sheets it has different customization options. GFBottomSheet({ Key key, @required this.contentBody, @@ -122,7 +123,6 @@ class _GFBottomSheetState extends State Theme.of(context).bottomSheetTheme; final double elevation = widget.elevation ?? bottomSheetTheme.elevation ?? 0; - final Widget bottomSheet = Column( mainAxisSize: MainAxisSize.min, children: [ @@ -246,9 +246,7 @@ class GFBottomSheetController extends ValueNotifier { // ignore: unnecessary_getters_setters double get height => _height; - bool get isBottomSheetOpened => value; - void hideBottomSheet() => value = false; void showBottomSheet() => value = true; } diff --git a/lib/components/button/gf_button.dart b/lib/components/button/gf_button.dart index bd57593c..59ddf44b 100644 --- a/lib/components/button/gf_button.dart +++ b/lib/components/button/gf_button.dart @@ -1,746 +1,3 @@ -//import 'dart:math' as math; -//import 'package:flutter/foundation.dart'; -//import 'package:flutter/gestures.dart'; -//import 'package:flutter/rendering.dart'; -//import 'package:flutter/widgets.dart'; -//import 'package:flutter/material.dart'; -//import 'package:getwidget/getwidget.dart'; -// -//class GFButton extends StatefulWidget { -// /// Create buttons of all types. check out [GFIconButton] for icon buttons, and [GFBadge] for badges -// const GFButton({ -// Key key, -// @required this.onPressed, -// this.onHighlightChanged, -// this.textStyle, -// this.boxShadow, -// this.buttonBoxShadow, -// this.focusColor, -// this.hoverColor, -// this.highlightColor, -// this.splashColor, -// this.elevation = 0.0, -// this.focusElevation = 4.0, -// this.hoverElevation = 4.0, -// this.highlightElevation = 1.0, -// this.disabledElevation = 0.0, -// this.padding = const EdgeInsets.symmetric(horizontal: 8), -// this.constraints, -// this.borderShape, -// this.animationDuration = kThemeChangeDuration, -// this.clipBehavior = Clip.none, -// this.focusNode, -// this.autofocus = false, -// MaterialTapTargetSize materialTapTargetSize, -// this.child, -// this.type = GFButtonType.solid, -// this.shape = GFButtonShape.standard, -// this.color = GFColors.PRIMARY, -// this.textColor, -// this.position = GFPosition.start, -// this.size = GFSize.MEDIUM, -// this.borderSide, -// this.text, -// this.icon, -// this.blockButton, -// this.fullWidthButton, -// this.colorScheme, -// this.enableFeedback, -// this.onLongPress, -// this.disabledColor, -// this.disabledTextColor, -// }) : materialTapTargetSize = -// materialTapTargetSize ?? MaterialTapTargetSize.padded, -// assert(shape != null, 'Button shape can not be null'), -// // assert(elevation != null && elevation >= 0.0), -// assert(focusElevation != null && focusElevation >= 0.0), -// assert(hoverElevation != null && hoverElevation >= 0.0), -// assert(highlightElevation != null && highlightElevation >= 0.0), -// assert(disabledElevation != null && disabledElevation >= 0.0), -// assert(padding != null), -// assert(animationDuration != null), -// assert(clipBehavior != null), -// assert(autofocus != null), -// super(key: key); -// -// /// Called when the button is tapped or otherwise activated. -// final VoidCallback onPressed; -// -// /// Called by the underlying [InkWell] widget's InkWell.onHighlightChanged callback. -// final ValueChanged onHighlightChanged; -// -// /// Defines the default text style, with [Material.textStyle], for the button's [child]. -// final TextStyle textStyle; -// -// /// The border side for the button's [Material]. -// final BorderSide borderSide; -// -// /// The box shadow for the button's [Material], if GFButtonType is solid -// final BoxShadow boxShadow; -// -// /// Pass [GFColors] or [Color]. The color for the button's [Material] when it has the input focus. -// final Color focusColor; -// -// /// Pass [GFColors] or [Color]. The color for the button's [Material] when a pointer is hovering over it. -// final Color hoverColor; -// -// /// Pass [GFColors] or [Color]. The highlight color for the button's [InkWell]. -// final Color highlightColor; -// -// /// Pass [GFColors] or [Color]. The splash color for the button's [InkWell]. -// final Color splashColor; -// -// /// The elevation for the button's [Material] when the button is [enabled] but not pressed. -// final double elevation; -// -// /// The elevation for the button's [Material] when the button is [enabled] and a pointer is hovering over it. -// final double hoverElevation; -// -// /// The elevation for the button's [Material] when the button is [enabled] and has the input focus. -// final double focusElevation; -// -// /// The elevation for the button's [Material] when the button is [enabled] and pressed. -// final double highlightElevation; -// -// /// The elevation for the button's [Material] when the button is not [enabled]. -// final double disabledElevation; -// -// /// The internal padding for the button's [child]. -// final EdgeInsetsGeometry padding; -// -// /// Defines the button's size. -// final BoxConstraints constraints; -// -// /// The shape of the button's [Material]. -// final ShapeBorder borderShape; -// -// /// Defines the duration of animated changes for [shape] and [elevation]. -// final Duration animationDuration; -// -// /// Typically the button's label. -// final Widget child; -// -// /// Whether the button is enabled or disabled. -// bool get enabled => onPressed != null; -// -// /// Configures the minimum size of the tap target. -// final MaterialTapTargetSize materialTapTargetSize; -// -// /// {@macro flutter.widgets.Focus.focusNode} -// final FocusNode focusNode; -// -// /// {@macro flutter.widgets.Focus.autofocus} -// final bool autofocus; -// -// /// {@macro flutter.widgets.Clip} -// final Clip clipBehavior; -// -// /// Button type of [GFButtonType] i.e, solid, outline, outline2x, transparent -// final GFButtonType type; -// -// /// Button type of [GFButtonShape] i.e, standard, pills, square, shadow, icons -// final GFButtonShape shape; -// -// /// Pass [GFColors] or [Color] -// final Color color; -// -// /// The fill color of the button when the button is disabled. -// /// -// /// The default value of this color is the theme's disabled color, -// /// [ThemeData.disabledColor]. -// /// -// /// See also: -// /// -// /// * [color] - the fill color of the button when the button is [enabled]. -// final Color disabledColor; -// -// /// Pass [GFColors] or [Color] -// final Color textColor; -// -// /// The color to use for this button's text when the button is disabled. -// /// -// /// The button's [Material.textStyle] will be the current theme's button -// /// text style, [ThemeData.textTheme.button], configured with this color. -// /// -// /// The default value is the theme's disabled color, -// /// [ThemeData.disabledColor]. -// /// -// /// If [textColor] is a [MaterialStateProperty], [disabledTextColor] -// /// will be ignored. -// /// -// /// See also: -// /// -// /// * [textColor] - The color to use for this button's text when the button is [enabled]. -// final Color disabledTextColor; -// -// /// size of [double] or [GFSize] i.e, 1.2, small, medium, large etc. -// final double size; -// -// /// text of type [String] is alternative to child. text will get priority over child -// final String text; -// -// /// icon of type [Widget] -// final Widget icon; -// -// /// icon type of [GFPosition] i.e, start, end -// final GFPosition position; -// -// /// on true state blockButton gives block size button -// final bool blockButton; -// -// /// on true state full width Button gives full width button -// final bool fullWidthButton; -// -// /// on true state default box shadow appears around button, if GFButtonType is solid -// final bool buttonBoxShadow; -// -// /// A set of thirteen colors that can be used to derive the button theme's -// /// colors. -// /// -// /// This property was added much later than the theme's set of highly -// /// specific colors, like [ThemeData.buttonColor], [ThemeData.highlightColor], -// /// [ThemeData.splashColor] etc. -// /// -// /// The colors for new button classes can be defined exclusively in terms -// /// of [colorScheme]. When it's possible, the existing buttons will -// /// (continue to) gradually migrate to it. -// final ColorScheme colorScheme; -// -// /// Whether detected gestures should provide acoustic and/or haptic feedback. -// /// -// /// For example, on Android a tap will produce a clicking sound and a -// /// long-press will produce a short vibration, when feedback is enabled. -// /// -// /// See also: -// /// -// /// * [Feedback] for providing platform-specific feedback to certain actions. -// final bool enableFeedback; -// -// /// Called when the button is long-pressed. -// /// -// /// If this callback and [onPressed] are null, then the button will be disabled. -// /// -// /// See also: -// /// -// /// * [enabled], which is true if the button is enabled. -// final VoidCallback onLongPress; -// -// @override -// _GFButtonState createState() => _GFButtonState(); -//} -// -//class _GFButtonState extends State { -// Color color; -// Color disabledColor; -// Color textColor; -// Color disabledTextColor; -// Widget child; -// Widget icon; -// Function onPressed; -// GFButtonType type; -// GFButtonShape shape; -// double size; -// GFPosition position; -// BoxShadow boxShadow; -// -// final Set _states = {}; -// -// @override -// void initState() { -// color = widget.color; -// textColor = widget.textColor; -// child = widget.text != null ? Text(widget.text) : widget.child; -// icon = widget.icon; -// onPressed = widget.onPressed; -// type = widget.type; -// shape = widget.shape; -// size = widget.size; -// position = widget.position; -// disabledColor = widget.disabledColor; -// disabledTextColor = widget.disabledTextColor; -// _updateState( -// MaterialState.disabled, -// !widget.enabled, -// ); -// super.initState(); -// } -// -// bool get _hovered => _states.contains(MaterialState.hovered); -// bool get _focused => _states.contains(MaterialState.focused); -// bool get _pressed => _states.contains(MaterialState.pressed); -// bool get _disabled => _states.contains(MaterialState.disabled); -// -// double buttonWidth() { -// if (widget.blockButton == true) { -// return MediaQuery.of(context).size.width * 0.88; -// } else if (widget.fullWidthButton == true) { -// return MediaQuery.of(context).size.width; -// } else { -// return null; -// } -// } -// -// void _updateState(MaterialState state, bool value) { -// value ? _states.add(state) : _states.remove(state); -// } -// -// void _handleHighlightChanged(bool value) { -// if (_pressed != value) { -// setState(() { -// _updateState(MaterialState.pressed, value); -// if (widget.onHighlightChanged != null) { -// widget.onHighlightChanged(value); -// } -// }); -// } -// } -// -// void _handleHoveredChanged(bool value) { -// if (_hovered != value) { -// setState(() { -// _updateState(MaterialState.hovered, value); -// }); -// } -// } -// -// void _handleFocusedChanged(bool value) { -// if (_focused != value) { -// setState(() { -// _updateState(MaterialState.focused, value); -// }); -// } -// } -// -// @override -// void didUpdateWidget(GFButton oldWidget) { -// _updateState(MaterialState.disabled, !widget.enabled); -// // If the button is disabled while a press gesture is currently ongoing, -// // InkWell makes a call to handleHighlightChanged. This causes an exception -// // because it calls setState in the middle of a build. To preempt this, we -// // manually update pressed to false when this situation occurs. -// if (_disabled && _pressed) { -// _handleHighlightChanged(false); -// } -// super.didUpdateWidget(oldWidget); -// } -// -// double get _effectiveElevation { -// // These conditionals are in order of precedence, so be careful about -// // reorganizing them. -// if (_disabled) { -// return widget.disabledElevation; -// } -// if (_pressed) { -// return widget.highlightElevation; -// } -// if (_hovered) { -// return widget.hoverElevation; -// } -// if (_focused) { -// return widget.focusElevation; -// } -// return widget.elevation; -// } -// -// @override -// Widget build(BuildContext context) { -// ShapeBorder shapeBorderType; -// -// Color getBorderColor() { -// if (widget.enabled) { -// final Color fillColor = color ?? GFColors.PRIMARY; -// if (fillColor != null) { -// return fillColor; -// } -// } else { -// if (disabledColor != null) { -// return disabledColor; -// } else { -// return color.withOpacity(0.48); -// } -// } -// return color ?? GFColors.PRIMARY; -// } -// -// Color getDisabledFillColor() { -// if (widget.type == GFButtonType.transparent || -// widget.type == GFButtonType.outline || -// widget.type == GFButtonType.outline2x) { -// return Colors.transparent; -// } -// if (disabledColor != null) { -// return disabledColor; -// } else { -// return color.withOpacity(0.48); -// } -// } -// -// Color getColor() { -// if (widget.type == GFButtonType.transparent || -// widget.type == GFButtonType.outline || -// widget.type == GFButtonType.outline2x) { -// return Colors.transparent; -// } -// final Color fillColor = color ?? GFColors.PRIMARY; -// return fillColor; -// } -// -// Color getDisabledTextColor() { -// if (disabledTextColor != null) { -// return disabledTextColor; -// } else if (widget.type == GFButtonType.outline || -// widget.type == GFButtonType.outline2x || -// widget.type == GFButtonType.transparent) { -// return color; -// } else { -// return GFColors.DARK; -// } -// } -// -// Color getTextColor() { -// if (widget.type == GFButtonType.outline || -// widget.type == GFButtonType.outline2x || -// widget.type == GFButtonType.transparent) { -// return widget.enabled -// ? textColor == null -// ? color == GFColors.TRANSPARENT ? GFColors.DARK : color -// : textColor -// : getDisabledTextColor(); -// } -// if (textColor == null) { -// if (color == GFColors.TRANSPARENT) { -// return GFColors.DARK; -// } else { -// return GFColors.WHITE; -// } -// } else { -// return textColor; -// } -// } -// -// final Color effectiveTextColor = MaterialStateProperty.resolveAs( -// widget.textStyle?.color, _states); -// final Color themeColor = -// Theme.of(context).colorScheme.onSurface.withOpacity(0.12); -// final BorderSide outlineBorder = BorderSide( -// color: color == null -// ? themeColor -// : widget.borderSide == null -// ? getBorderColor() -// : widget.borderSide.color, -// width: widget.borderSide?.width == null -// ? widget.type == GFButtonType.outline2x ? 2.0 : 1.0 -// : widget.borderSide?.width, -// ); -// -// Size minSize; -// switch (widget.materialTapTargetSize) { -// case MaterialTapTargetSize.padded: -// minSize = const Size(48, 48); -// break; -// case MaterialTapTargetSize.shrinkWrap: -// minSize = Size.zero; -// break; -// default: -// minSize = Size.zero; -// break; -// } -// -// final BorderSide shapeBorder = widget.type == GFButtonType.outline || -// widget.type == GFButtonType.outline2x -// ? outlineBorder -// : widget.borderSide ?? -// BorderSide( -// color: color == null ? themeColor : getBorderColor(), -// width: 0, -// ); -// -// if (shape == GFButtonShape.pills) { -// shapeBorderType = RoundedRectangleBorder( -// borderRadius: BorderRadius.circular( -// 50, -// ), -// side: shapeBorder, -// ); -// } else if (shape == GFButtonShape.square) { -// shapeBorderType = RoundedRectangleBorder( -// borderRadius: BorderRadius.circular(0), -// side: shapeBorder, -// ); -// } else if (shape == GFButtonShape.standard) { -// shapeBorderType = RoundedRectangleBorder( -// borderRadius: BorderRadius.circular(3), -// side: shapeBorder, -// ); -// } else { -// shapeBorderType = RoundedRectangleBorder( -// borderRadius: BorderRadius.circular(50), -// side: shapeBorder, -// ); -// } -// -// BoxDecoration getBoxShadow() { -// if (widget.type != GFButtonType.transparent) { -// if (widget.boxShadow == null && widget.buttonBoxShadow != true) { -// return null; -// } else { -// return BoxDecoration( -// color: widget.type == GFButtonType.transparent || -// widget.type == GFButtonType.outline || -// widget.type == GFButtonType.outline2x -// ? Colors.transparent -// : color, -// borderRadius: widget.shape == GFButtonShape.pills -// ? BorderRadius.circular(50) -// : widget.shape == GFButtonShape.standard -// ? BorderRadius.circular(5) -// : BorderRadius.zero, -// boxShadow: [ -// widget.boxShadow == null && widget.buttonBoxShadow == true -// ? BoxShadow( -// color: themeColor, -// blurRadius: 1.5, -// spreadRadius: 2, -// offset: Offset.zero, -// ) -// : widget.boxShadow != null -// ? widget.boxShadow -// : BoxShadow( -// color: Theme.of(context).canvasColor, -// blurRadius: 0, -// spreadRadius: 0, -// offset: Offset.zero, -// ), -// ], -// ); -// } -// } -// return null; -// } -// -// TextStyle getTextStyle() { -// if (widget.size == GFSize.SMALL) { -// return TextStyle( -// color: widget.enabled ? getTextColor() : getDisabledTextColor(), -// fontSize: 12, -// ); -// } else if (widget.size == GFSize.MEDIUM) { -// return TextStyle( -// color: widget.enabled ? getTextColor() : getDisabledTextColor(), -// fontSize: 13, -// fontWeight: FontWeight.w400, -// ); -// } else if (widget.size == GFSize.LARGE) { -// return TextStyle( -// color: widget.enabled ? getTextColor() : getDisabledTextColor(), -// fontSize: 14, -// fontWeight: FontWeight.w500, -// ); -// } -// return TextStyle( -// color: widget.enabled ? getTextColor() : getDisabledTextColor(), -// fontSize: 13, -// fontWeight: FontWeight.w400, -// ); -// } -// -// -// final Widget result = Container( -// constraints: icon == null -// ? const BoxConstraints(minWidth: 80) -// : const BoxConstraints(minWidth: 90), -// decoration: widget.type == GFButtonType.solid ? getBoxShadow() : null, -// child: Material( -// elevation: _effectiveElevation, -// textStyle: widget.textStyle == null ? getTextStyle() : widget.textStyle, -// shape: widget.type == GFButtonType.transparent -// ? null -// : widget.borderShape ?? shapeBorderType, -// color: widget.enabled ? getColor() : getDisabledFillColor(), -// type: color == null ? MaterialType.transparency : MaterialType.button, -// animationDuration: widget.animationDuration, -// clipBehavior: widget.clipBehavior, -// child: InkWell( -// focusNode: widget.focusNode, -// canRequestFocus: widget.enabled, -// onFocusChange: _handleFocusedChanged, -// autofocus: widget.autofocus, -// onHighlightChanged: _handleHighlightChanged, -// onHover: _handleHoveredChanged, -// onTap: widget.onPressed, -// onLongPress: widget.onLongPress, -// enableFeedback: widget.enableFeedback, -// splashColor: widget.splashColor, -// highlightColor: widget.highlightColor, -// focusColor: widget.focusColor, -// hoverColor: widget.hoverColor, -// customBorder: widget.type == GFButtonType.transparent -// ? null -// : widget.borderShape ?? shapeBorderType, -// child: IconTheme.merge( -// data: IconThemeData(color: effectiveTextColor), -// child: Container( -// height: size, -// width: buttonWidth(), -// padding: widget.padding, -// child: Center( -// widthFactor: 1, -// heightFactor: 1, -//// child: widget.child !=null? widget.child:Row( -//// children: [ -//// widget.icon!=null?widget.icon:Icons.sentiment_very_satisfied, -//// widget.child !=null? widget.child:Text('k') -//// ], -////), -// child: icon != null && -// (position == GFPosition.start || position == null) -// ? Row( -// mainAxisSize: MainAxisSize.min, -// children: [ -// icon, -// const SizedBox(width: 8), -// child -// ], -// ) -// : icon != null && (position == GFPosition.end) -// ? Row( -// mainAxisSize: MainAxisSize.min, -// children: [ -// child, -// const SizedBox(width: 8), -// icon -// ], -// ) -// : widget.child, -// ), -// ), -// ), -// ), -// ), -// ); -// -// return Semantics( -// container: true, -// button: true, -// enabled: widget.enabled, -// child: _InputPadding( -// minSize: minSize, -// child: Focus( -// focusNode: widget.focusNode, -// onFocusChange: _handleFocusedChanged, -// autofocus: widget.autofocus, -// child: result, -// ), -// ), -// ); -// } -//} -// -///// A widget to pad the area around a [MaterialButton]'s inner [Material]. -///// -///// Redirect taps that occur in the padded area around the child to the center -///// of the child. This increases the size of the button and the button's -///// "tap target", but not its material or its ink splashes. -//class _InputPadding extends SingleChildRenderObjectWidget { -// const _InputPadding({ -// Key key, -// Widget child, -// this.minSize, -// }) : super( -// key: key, -// child: child, -// ); -// -// final Size minSize; -// -// @override -// RenderObject createRenderObject(BuildContext context) => -// _RenderInputPadding(minSize); -// -// @override -// void updateRenderObject( -// BuildContext context, covariant _RenderInputPadding renderObject) { -// renderObject.minSize = minSize; -// } -//} -// -//class _RenderInputPadding extends RenderShiftedBox { -// _RenderInputPadding(this._minSize, [RenderBox child]) : super(child); -// -// Size get minSize => _minSize; -// Size _minSize; -// -// set minSize(Size value) { -// _minSize = value; -// markNeedsLayout(); -// } -// -// @override -// double computeMinIntrinsicWidth(double height) { -// if (child != null) { -// return math.max(child.getMinIntrinsicWidth(height), minSize.width); -// } -// return 0; -// } -// -// @override -// double computeMinIntrinsicHeight(double width) { -// if (child != null) { -// return math.max(child.getMinIntrinsicHeight(width), minSize.height); -// } -// return 0; -// } -// -// @override -// double computeMaxIntrinsicWidth(double height) { -// if (child != null) { -// return math.max(child.getMaxIntrinsicWidth(height), minSize.width); -// } -// return 0; -// } -// -// @override -// double computeMaxIntrinsicHeight(double width) { -// if (child != null) { -// return math.max(child.getMaxIntrinsicHeight(width), minSize.height); -// } -// return 0; -// } -// -// @override -// void performLayout() { -// if (child != null) { -// child.layout(constraints, parentUsesSize: true); -// final BoxParentData childParentData = child.parentData; -// final double height = math.max(child.size.width, minSize.width); -// final double width = math.max(child.size.height, minSize.height); -// size = constraints.constrain(Size(height, width)); -// childParentData.offset = Alignment.center.alongOffset(size - child.size); -// } else { -// size = Size.zero; -// } -// } -// -// @override -// bool hitTest(BoxHitTestResult result, {Offset position}) { -// if (super.hitTest(result, position: position)) { -// return true; -// } -// final Offset center = child.size.center(Offset.zero); -// return result.addWithRawTransform( -// transform: MatrixUtils.forceToPoint(center), -// position: center, -// hitTest: (BoxHitTestResult result, Offset position) { -// assert(position == center); -// return child.hitTest( -// result, -// position: center, -// ); -// }, -// ); -// } -//} - import 'dart:math' as math; import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; diff --git a/lib/components/carousel/gf_carousel.dart b/lib/components/carousel/gf_carousel.dart index 65f80b24..3c8dbd46 100644 --- a/lib/components/carousel/gf_carousel.dart +++ b/lib/components/carousel/gf_carousel.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'package:flutter/material.dart'; -// ignore: must_be_immutable class GFCarousel extends StatefulWidget { /// Creates slide show of Images and [Widget] with animation for sliding. GFCarousel({ diff --git a/lib/components/checkbox/gf_checkbox.dart b/lib/components/checkbox/gf_checkbox.dart index 3a06baf8..faafbf5e 100644 --- a/lib/components/checkbox/gf_checkbox.dart +++ b/lib/components/checkbox/gf_checkbox.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:getwidget/getwidget.dart'; class GFCheckbox extends StatefulWidget { + /// [GFCheckbox] is a small box (as in a checklist) in which to place a check mark to make a selection with various customization options. const GFCheckbox( {Key key, this.size = GFSize.MEDIUM, diff --git a/lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart b/lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart index 8fbc0c17..58aff514 100644 --- a/lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart +++ b/lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:getwidget/getwidget.dart'; class GFCheckboxListTile extends StatelessWidget { + /// [GFCheckboxListTile] is a tile with small box at right (as in a checklist) in which to place a check mark to make a selection with various customization options. const GFCheckboxListTile({ Key key, @required this.value, @@ -12,6 +13,7 @@ class GFCheckboxListTile extends StatelessWidget { this.avatar, this.title, this.subTitle, + this.icon, this.description, this.padding = const EdgeInsets.all(8), this.margin = const EdgeInsets.all(16), @@ -29,6 +31,7 @@ class GFCheckboxListTile extends StatelessWidget { ), this.inactiveIcon = const Icon(Icons.close), this.custombgColor = GFColors.SUCCESS, + this.position = GFPosition.end, this.selected = false, this.autofocus = false, }) : assert(value != null), @@ -45,7 +48,7 @@ class GFCheckboxListTile extends StatelessWidget { /// The GFListTile's background color. Can be given [Color] or [GFColors] final Color color; - /// type of [Widget] or [GFAvatar] used to create rounded user profile + /// If position is start Checkbox will come instead of avatar, type of [Widget] or [GFAvatar] used to create rounded user profile final Widget avatar; /// The title to display inside the [GFListTile]. see [Text] @@ -87,13 +90,16 @@ class GFCheckboxListTile extends StatelessWidget { /// Called when the user checks or unchecks the checkbox. final ValueChanged onChanged; - ///Used to set the current state of the checkbox + /// Used to set the current state of the checkbox final bool value; - ///type of Widget used to change the checkbox's active icon + /// Position allows user to set position of [GFCheckbox] based on given [GFPosition] + final GFPosition position; + + /// type of Widget used to change the checkbox's active icon final Widget activeIcon; - ///type of [Widget] used to change the checkbox's inactive icon + /// type of [Widget] used to change the checkbox's inactive icon final Widget inactiveIcon; /// type of [Color] used to change the background color of the custom active checkbox only @@ -106,41 +112,46 @@ class GFCheckboxListTile extends StatelessWidget { /// {@macro flutter.widgets.Focus.autofocus} final bool autofocus; + /// If position is end Checkbox will come instead of icon, The icon to display inside the [GFListTile]. see [Icon] + final Widget icon; + @override - Widget build(BuildContext context) => MergeSemantics( - child: GFListTile( - autofocus: autofocus, - enabled: onChanged != null, - onTap: onChanged != null - ? () { - onChanged(!value); - } - : null, - selected: selected, - avatar: avatar, - titleText: titleText, - subTitle: subTitle, - subtitleText: subtitleText, - description: description, - color: color, - padding: padding, - margin: margin, - title: title, - icon: GFCheckbox( - autofocus: autofocus, - onChanged: onChanged, - value: value, - size: size, - activebgColor: activebgColor, - inactiveIcon: inactiveIcon, - activeBorderColor: activeBorderColor, - inactivebgColor: inactivebgColor, - activeIcon: activeIcon, - inactiveBorderColor: inactiveBorderColor, - custombgColor: custombgColor, - checkColor: checkColor, - type: type, - ), - ), - ); + Widget build(BuildContext context) { + final GFCheckbox checkbox = GFCheckbox( + autofocus: autofocus, + onChanged: onChanged, + value: value, + size: size, + activebgColor: activebgColor, + inactiveIcon: inactiveIcon, + activeBorderColor: activeBorderColor, + inactivebgColor: inactivebgColor, + activeIcon: activeIcon, + inactiveBorderColor: inactiveBorderColor, + custombgColor: custombgColor, + checkColor: checkColor, + type: type); + return MergeSemantics( + child: GFListTile( + autofocus: autofocus, + enabled: onChanged != null, + onTap: onChanged != null + ? () { + onChanged(!value); + } + : null, + selected: selected, + avatar: position == GFPosition.start ? checkbox : avatar, + titleText: titleText, + subTitle: subTitle, + subtitleText: subtitleText, + description: description, + color: color, + padding: padding, + margin: margin, + title: title, + icon: position == GFPosition.end ? checkbox : icon, + ), + ); + } } diff --git a/lib/components/drawer/gf_drawer.dart b/lib/components/drawer/gf_drawer.dart index 5dd595e7..76226e3f 100644 --- a/lib/components/drawer/gf_drawer.dart +++ b/lib/components/drawer/gf_drawer.dart @@ -53,9 +53,7 @@ const double _kWidth = 304; /// class GFDrawer extends StatelessWidget { /// Creates a material design drawer. - /// /// Typically used in the [Scaffold.drawer] property. - /// /// The [elevation] must be non-negative. const GFDrawer({ Key key, diff --git a/lib/components/drawer/gf_drawer_header.dart b/lib/components/drawer/gf_drawer_header.dart index f512c43d..3f8f3d39 100644 --- a/lib/components/drawer/gf_drawer_header.dart +++ b/lib/components/drawer/gf_drawer_header.dart @@ -75,9 +75,7 @@ class GFDrawerHeaderPictures extends StatelessWidget { } /// A material design [Drawer] header that identifies the app's user. -/// /// Requires one of its ancestors to be a [Material] widget. -/// class GFDrawerHeader extends StatefulWidget { /// Creates a material design drawer header. /// diff --git a/lib/components/intro_screen/gf_intro_screen.dart b/lib/components/intro_screen/gf_intro_screen.dart index fabda1b8..cef48793 100644 --- a/lib/components/intro_screen/gf_intro_screen.dart +++ b/lib/components/intro_screen/gf_intro_screen.dart @@ -114,7 +114,7 @@ class GFIntroScreen extends StatefulWidget { final EdgeInsets navigationBarMargin; /// defines [GFIntroScreenBottomNavigationBar] color - final dynamic navigationBarColor; + final Color navigationBarColor; /// defines the shape of [GFIntroScreenBottomNavigationBar] final ShapeBorder navigationBarShape; @@ -183,7 +183,7 @@ class GFIntroScreen extends StatefulWidget { final double dividerThickness; /// defines divider color - final dynamic dividerColor; + final Color dividerColor; /// defines pagination shape final ShapeBorder dotShape; diff --git a/lib/components/intro_screen/gf_intro_screen_bottom_navigation_bar.dart b/lib/components/intro_screen/gf_intro_screen_bottom_navigation_bar.dart index 79e0588f..5d8e5aa5 100644 --- a/lib/components/intro_screen/gf_intro_screen_bottom_navigation_bar.dart +++ b/lib/components/intro_screen/gf_intro_screen_bottom_navigation_bar.dart @@ -82,7 +82,7 @@ class GFIntroScreenBottomNavigationBar extends StatefulWidget { final EdgeInsets navigationBarMargin; /// defines [GFIntroScreenBottomNavigationBar] color - final dynamic navigationBarColor; + final Color navigationBarColor; /// defines the shape of [GFIntroScreenBottomNavigationBar] final ShapeBorder navigationBarShape; @@ -151,7 +151,7 @@ class GFIntroScreenBottomNavigationBar extends StatefulWidget { final double dividerThickness; /// defines divider color - final dynamic dividerColor; + final Color dividerColor; /// defines pagination shape final ShapeBorder dotShape; diff --git a/lib/components/shimmer/gf_shimmer.dart b/lib/components/shimmer/gf_shimmer.dart index 40acda88..0c707fe0 100644 --- a/lib/components/shimmer/gf_shimmer.dart +++ b/lib/components/shimmer/gf_shimmer.dart @@ -45,12 +45,12 @@ class GFShimmer extends StatefulWidget { /// Defines the main color of the [child]'s shimmer effect. /// Child [Widget] takes main color, only if [showGradient] is false. /// Default [showGradient] will be false. - final dynamic mainColor; + final Color mainColor; /// defines the secondary color of the [child]'s shimmer effect. /// Child [Widget] takes secondary color, only if [showGradient] is false. /// Default [showGradient] will be false. - final dynamic secondaryColor; + final Color secondaryColor; @override _GFShimmerState createState() => _GFShimmerState(); diff --git a/lib/types/gf_alert_type.dart b/lib/types/gf_alert_type.dart index 8c3480ab..391f5ae3 100644 --- a/lib/types/gf_alert_type.dart +++ b/lib/types/gf_alert_type.dart @@ -1 +1,5 @@ -enum GFAlertType { basic, rounded, fullWidth } +enum GFAlertType { + basic, + rounded, + fullWidth, +} diff --git a/lib/types/gf_animation_type.dart b/lib/types/gf_animation_type.dart index 7a97b55e..cb2d0302 100644 --- a/lib/types/gf_animation_type.dart +++ b/lib/types/gf_animation_type.dart @@ -5,5 +5,5 @@ enum GFAnimationType { rotateTransition, scaleTransition, slideTransition, - textStyle + textStyle, } diff --git a/lib/types/gf_border_type.dart b/lib/types/gf_border_type.dart index bea0b2a9..8eb24181 100644 --- a/lib/types/gf_border_type.dart +++ b/lib/types/gf_border_type.dart @@ -1 +1 @@ -enum GFBorderType { Circle, RRect, Rect, Oval } +enum GFBorderType { circle, rRect, rect, oval } diff --git a/lib/types/gf_button_type.dart b/lib/types/gf_button_type.dart index 1e363aa0..12a2f6a2 100644 --- a/lib/types/gf_button_type.dart +++ b/lib/types/gf_button_type.dart @@ -10,5 +10,5 @@ enum GFButtonType { outline2x, /// Type [GFButtonType.transparent], used for widget with fill color with Colors.transparent - transparent + transparent, } diff --git a/lib/types/gf_checkbox_type.dart b/lib/types/gf_checkbox_type.dart index 2f15b89d..39035e0f 100644 --- a/lib/types/gf_checkbox_type.dart +++ b/lib/types/gf_checkbox_type.dart @@ -1 +1,6 @@ -enum GFCheckboxType { basic, circle, square, custom } +enum GFCheckboxType { + basic, + circle, + square, + custom, +} diff --git a/lib/types/gf_radio_type.dart b/lib/types/gf_radio_type.dart index 61fab9b0..e1547b42 100644 --- a/lib/types/gf_radio_type.dart +++ b/lib/types/gf_radio_type.dart @@ -1 +1,6 @@ -enum GFRadioType { basic, square, custom, blunt } +enum GFRadioType { + basic, + square, + custom, + blunt, +} diff --git a/lib/types/gf_toast_type.dart b/lib/types/gf_toast_type.dart index 4dcad3df..7810c207 100644 --- a/lib/types/gf_toast_type.dart +++ b/lib/types/gf_toast_type.dart @@ -1 +1,5 @@ -enum GFToastType { basic, rounded, fullWidth } +enum GFToastType { + basic, + rounded, + fullWidth, +} diff --git a/lib/types/gf_toggle_type.dart b/lib/types/gf_toggle_type.dart index 01eb7d68..866ebb8f 100644 --- a/lib/types/gf_toggle_type.dart +++ b/lib/types/gf_toggle_type.dart @@ -10,5 +10,5 @@ enum GFToggleType { ios, /// [GFToggleType.square] is used for square shape of GFToggle - square + square, } diff --git a/lib/types/gf_typography_type.dart b/lib/types/gf_typography_type.dart index bd48332f..bf479f78 100644 --- a/lib/types/gf_typography_type.dart +++ b/lib/types/gf_typography_type.dart @@ -16,5 +16,5 @@ enum GFTypographyType { typo5, /// [GFTypographyType.typo6] type used for title widget with fontSize = 13.0 - typo6 + typo6, } diff --git a/pubspec.yaml b/pubspec.yaml index 41fbd5a0..a0a56314 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,4 +15,4 @@ dev_dependencies: sdk: flutter flutter: - uses-material-design: true \ No newline at end of file + uses-material-design: true From 1fba485add90244739dd54d517e7d13bf872e1b8 Mon Sep 17 00:00:00 2001 From: Sandip Kakadiya Date: Fri, 2 Oct 2020 15:26:38 +0530 Subject: [PATCH 03/25] floating widget changes & introscreen changes --- .../floating_widget/gf_floating_widget.dart | 35 +++++++++---------- .../intro_screen/gf_intro_screen.dart | 1 + ...gf_intro_screen_bottom_navigation_bar.dart | 8 +++++ 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/lib/components/floating_widget/gf_floating_widget.dart b/lib/components/floating_widget/gf_floating_widget.dart index c72368e4..9d0d55b6 100644 --- a/lib/components/floating_widget/gf_floating_widget.dart +++ b/lib/components/floating_widget/gf_floating_widget.dart @@ -61,26 +61,23 @@ class _GFFloatingWidgetState extends State { child: widget.body ?? Container(), ), Positioned( - child: Container( - height: MediaQuery.of(context).size.height, - width: MediaQuery.of(context).size.width, - color: widget.showblurness - ? widget.blurnessColor ?? Colors.black54 - : null, - child: Stack( - children: [ - Positioned( - top: widget.verticalPosition != null - ? widget.verticalPosition - : 0.0, - left: widget.horizontalPosition != null - ? widget.horizontalPosition - : 0.0, - child: widget.child ?? Container(), - ) - ], + child: Container( + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + color: widget.showblurness + ? widget.blurnessColor ?? Colors.black54 + : null, + child: Stack( + children: [ + Positioned( + top: widget.verticalPosition ?? 0.0, + left: widget.horizontalPosition ?? 0.0, + child: widget.child ?? Container(), + ) + ], + ), ), - )) + ) ], ); } diff --git a/lib/components/intro_screen/gf_intro_screen.dart b/lib/components/intro_screen/gf_intro_screen.dart index cef48793..1d3f8ba9 100644 --- a/lib/components/intro_screen/gf_intro_screen.dart +++ b/lib/components/intro_screen/gf_intro_screen.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:getwidget/getwidget.dart'; class GFIntroScreen extends StatefulWidget { + /// Presents informative screens to users with various posibilities in customization. const GFIntroScreen({ Key key, @required this.pageController, diff --git a/lib/components/intro_screen/gf_intro_screen_bottom_navigation_bar.dart b/lib/components/intro_screen/gf_intro_screen_bottom_navigation_bar.dart index 5d8e5aa5..6361c960 100644 --- a/lib/components/intro_screen/gf_intro_screen_bottom_navigation_bar.dart +++ b/lib/components/intro_screen/gf_intro_screen_bottom_navigation_bar.dart @@ -199,6 +199,14 @@ class _GFIntroScreenBottomNavigationBarState super.initState(); } + @override + void dispose() { + if (_pageController != null) { + _pageController.dispose(); + } + super.dispose(); + } + void onForwardButton() { widget.pageController.nextPage( duration: const Duration(milliseconds: 500), curve: Curves.linear); From 13cee3a1e0ed529a18bdcaaae20a928341ca12a4 Mon Sep 17 00:00:00 2001 From: Sandip Kakadiya Date: Fri, 2 Oct 2020 15:40:24 +0530 Subject: [PATCH 04/25] dropdown & multiselect changes --- example/pubspec.lock | 2 +- lib/components/dropdown/gf_dropdown.dart | 72 ++- lib/components/dropdown/gf_multiselect.dart | 234 +++++++++ lib/components/dropdown/multilevel.dart | 236 --------- lib/components/text_field/gf_text_field.dart | 491 +++++++++---------- pubspec.lock | 38 +- 6 files changed, 532 insertions(+), 541 deletions(-) create mode 100644 lib/components/dropdown/gf_multiselect.dart delete mode 100644 lib/components/dropdown/multilevel.dart diff --git a/example/pubspec.lock b/example/pubspec.lock index 86aef32e..975a5d1b 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -261,4 +261,4 @@ packages: version: "4.2.0" sdks: dart: ">=2.9.0-14.0.dev <3.0.0" - flutter: ">=1.18.0-6.0.pre <2.0.0" \ No newline at end of file + flutter: ">=1.18.0-6.0.pre <2.0.0" diff --git a/lib/components/dropdown/gf_dropdown.dart b/lib/components/dropdown/gf_dropdown.dart index 9fcf2a2c..a8b4f137 100644 --- a/lib/components/dropdown/gf_dropdown.dart +++ b/lib/components/dropdown/gf_dropdown.dart @@ -1,7 +1,8 @@ import 'package:flutter/material.dart'; class GFDropdown extends StatefulWidget { - GFDropdown( + /// + const GFDropdown( {Key key, @required this.items, this.icon, @@ -26,13 +27,13 @@ class GFDropdown extends StatefulWidget { this.dropdownColor, this.padding = const EdgeInsets.all(5), this.borderRadius = const BorderRadius.all(Radius.circular(4)), - this.borderColor}); + this.borderColor}) + : super(key: key); - DropdownButtonBuilder selectedItemBuilder; + final DropdownButtonBuilder selectedItemBuilder; final List> items; /// The widget to use for the drop-down button's icon. - /// /// Defaults to an [Icon] with the [Icons.arrow_drop_down] glyph. final Widget icon; @@ -55,7 +56,6 @@ class GFDropdown extends StatefulWidget { final Widget disabledHint; /// Called when the user selects an item. - /// /// If the [onChanged] callback is null or the list of [DropdownButton.items] /// is null then the dropdown button will be disabled, final ValueChanged onChanged; @@ -114,38 +114,34 @@ class GFDropdown extends StatefulWidget { class _GFDropdownState extends State { @override - Widget build(BuildContext context) { - return Card( + Widget build(BuildContext context) => Card( child: Container( - padding: widget.padding, - decoration: BoxDecoration( - borderRadius: widget.borderRadius, - border: Border.all( - color: widget.borderColor != null - ? widget.borderColor - : Colors.white)), - child: DropdownButton( - - items: widget.items, - selectedItemBuilder: widget.selectedItemBuilder, - value: widget.value, - hint: widget.hint, - disabledHint: widget.disabledHint, - onChanged: widget.onChanged == null ? null : widget.onChanged, - onTap: widget.onTap, - elevation: widget.elevation, - style: widget.style, - icon: widget.icon, - iconDisabledColor: widget.iconDisabledColor, - iconEnabledColor: widget.iconEnabledColor, - iconSize: widget.iconSize, - isDense: widget.isDense, - isExpanded: widget.isExpanded, - itemHeight: widget.itemHeight, - focusColor: widget.focusColor, - focusNode: widget.focusNode, - autofocus: widget.autofocus, - dropdownColor: widget.dropdownColor, - ))); - } + padding: widget.padding, + decoration: BoxDecoration( + borderRadius: widget.borderRadius, + border: Border.all(color: widget.borderColor ?? Colors.white)), + child: DropdownButton( + items: widget.items, + selectedItemBuilder: widget.selectedItemBuilder, + value: widget.value, + hint: widget.hint, + disabledHint: widget.disabledHint, + onChanged: widget.onChanged, + onTap: widget.onTap, + elevation: widget.elevation, + style: widget.style, + icon: widget.icon, + iconDisabledColor: widget.iconDisabledColor, + iconEnabledColor: widget.iconEnabledColor, + iconSize: widget.iconSize, + isDense: widget.isDense, + isExpanded: widget.isExpanded, + itemHeight: widget.itemHeight, + focusColor: widget.focusColor, + focusNode: widget.focusNode, + autofocus: widget.autofocus, + dropdownColor: widget.dropdownColor, + ), + ), + ); } diff --git a/lib/components/dropdown/gf_multiselect.dart b/lib/components/dropdown/gf_multiselect.dart new file mode 100644 index 00000000..57ee6b80 --- /dev/null +++ b/lib/components/dropdown/gf_multiselect.dart @@ -0,0 +1,234 @@ +import 'package:flutter/material.dart'; +import 'package:getwidget/getwidget.dart'; + +class GFMultiSelect extends StatefulWidget { + /// + const GFMultiSelect({ + this.titleText, + this.selectedTextStyle = + const TextStyle(fontSize: 16, fontWeight: FontWeight.w500), + this.color, + this.avatar, + this.padding = const EdgeInsets.all(0), + this.margin = const EdgeInsets.all(5), + this.size = GFSize.MEDIUM, + this.type = GFCheckboxType.basic, + this.checkColor = GFColors.WHITE, + this.activebgColor = GFColors.WHITE, + this.inactivebgColor = GFColors.WHITE, + this.activeBorderColor = GFColors.WHITE, + this.inactiveBorderColor = GFColors.WHITE, + this.items, + this.submitbutton, + this.expandedicon = Icons.keyboard_arrow_down, + this.collapsedicon = Icons.keyboard_arrow_up, + this.dropdownbgColor = Colors.white, + this.activeIcon = const Icon( + Icons.check, + size: 20, + color: GFColors.DARK, + ), + this.inactiveIcon, + this.custombgColor = GFColors.SUCCESS, + this.selected = false, + Key key, + }) : assert(selected != null), + super(key: key); + + ///type of [String] used to pass text, alternative to title property and gets higher priority than title + final String titleText; + + /// The GFListTile's background color. Can be given [Color] or [GFColors] + final Color color; + + /// type of [Widget] or [GFAvatar] used to create rounded user profile + final Widget avatar; + + /// defines the margin of GFListTile + final EdgeInsets margin; + + /// defines the padding of GFListTile + final EdgeInsets padding; + + /// type of [GFCheckboxType] which is of four type is basic, sqaure, circular and custom + final GFCheckboxType type; + + /// type of [double] which is GFSize ie, small, medium and large and can use any double value + final double size; + + /// type pf [Color] used to change the checkcolor when the checkbox is active + final Color checkColor; + + /// type of [Color] used to change the backgroundColor of the active checkbox + final Color activebgColor; + + /// type of [Color] used to change the backgroundColor of the inactive checkbox + final Color inactivebgColor; + + /// type of [Color] used to change the border color of the active checkbox + final Color activeBorderColor; + + /// type of [Color] used to change the border color of the inactive checkbox + final Color inactiveBorderColor; + + /// Called when the user checks or unchecks the checkbox. + // final ValueChanged onChanged; + + ///Used to set the current state of the checkbox + // final bool value; + + ///type of Widget used to change the checkbox's active icon + final Widget activeIcon; + + ///type of [Widget] used to change the checkbox's inactive icon + final Widget inactiveIcon; + + /// type of [Color] used to change the background color of the custom active checkbox only + final Color custombgColor; + + /// To have the list tile appear selected when the checkbox is checked, pass the same value to both. + /// Normally, this property is left to its default value, false. + final bool selected; + + final List items; + + final Widget submitbutton; + + final Color dropdownbgColor; + + final TextStyle selectedTextStyle; + + final IconData expandedicon; + + final IconData collapsedicon; + + @override + _GFMultiSelectState createState() => _GFMultiSelectState(); +} + +class _GFMultiSelectState extends State { + bool check = true; + bool isdrop = false; + bool check1 = false; + + final _controller = TextEditingController(); + + final List _selectedTitles = []; + + void _onItemSelect(bool selected, String title) { + if (selected == true) { + setState(() { + _selectedTitles.add(title); + }); + } else { + setState(() { + _selectedTitles.remove(title); + }); + } + } + + @override + void dispose() { + if (_controller != null) { + _controller.dispose(); + } + super.dispose(); + } + + @override + Widget build(BuildContext context) => Column( + children: [ + InkWell( + onTap: () { + setState(() { + isdrop = !isdrop; + }); + }, + child: Container( + + // height: 40, + width: MediaQuery.of(context).size.width, + decoration: const BoxDecoration( + border: + Border(bottom: BorderSide(color: Colors.black12))), + child: Container( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + child: Container( + padding: const EdgeInsets.only(bottom: 10), + child: Text(_selectedTitles.join(' , ').toString(), + style: widget.selectedTextStyle), + )), + Icon( + !isdrop ? widget.expandedicon : widget.collapsedicon, + color: Colors.black87, + size: 30, + ), + ], + ), + ))), + isdrop + ? Container( + decoration: BoxDecoration( + color: widget.dropdownbgColor, + boxShadow: const [ + BoxShadow( + color: Colors.black12, + blurRadius: 3, + ) + ], + ), + height: 300, + child: SingleChildScrollView( + child: Column( + children: [ + Column( + children: List.generate( + widget.items.length, + (index) => GFCheckboxListTile( + value: _selectedTitles + .contains(widget.items[index]), + onChanged: (bool selected) { + _controller.text; + print(selected); + _onItemSelect( + selected, widget.items[index]); + }, + selected: widget.selected, + avatar: widget.avatar, + titleText: widget.items[index], + color: widget.color, + padding: widget.padding, + margin: widget.margin, + size: widget.size, + activebgColor: widget.activebgColor, + inactiveIcon: widget.inactiveIcon, + activeBorderColor: + widget.activeBorderColor, + inactivebgColor: widget.inactivebgColor, + activeIcon: widget.activeIcon, + inactiveBorderColor: + widget.inactiveBorderColor, + custombgColor: widget.custombgColor, + checkColor: widget.checkColor, + type: widget.type, + ))), + GFButton( + onPressed: () { + setState(() { + isdrop = !isdrop; + }); + }, + child: widget.submitbutton, + ) + ], + ), + ), + ) + : Container(), + ], + ); +} diff --git a/lib/components/dropdown/multilevel.dart b/lib/components/dropdown/multilevel.dart deleted file mode 100644 index 1ab11566..00000000 --- a/lib/components/dropdown/multilevel.dart +++ /dev/null @@ -1,236 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:getwidget/getwidget.dart'; - -class GFMultilevelDropdown extends StatefulWidget { - const GFMultilevelDropdown({ - this.titleText, - this.selectedTextStyle = - const TextStyle(fontSize: 16, fontWeight: FontWeight.w500), - this.color, - this.avatar, - this.padding = const EdgeInsets.all(0), - this.margin = const EdgeInsets.all(5), - this.size = GFSize.MEDIUM, - this.type = GFCheckboxType.basic, - this.checkColor = GFColors.WHITE, - this.activebgColor = GFColors.WHITE, - this.inactivebgColor = GFColors.WHITE, - this.activeBorderColor = GFColors.WHITE, - this.inactiveBorderColor = GFColors.WHITE, - this.items, - this.submitbutton, - this.expandedicon = Icons.keyboard_arrow_down, - this.collapsedicon = Icons.keyboard_arrow_up, - this.dropdownbgColor = Colors.white, - this.activeIcon = const Icon( - Icons.check, - size: 20, - color: GFColors.DARK, - ), - this.inactiveIcon, - this.custombgColor = GFColors.SUCCESS, - this.selected = false, - Key key, - }) : assert(selected != null), - super(key: key); - - ///type of [String] used to pass text, alternative to title property and gets higher priority than title - final String titleText; - - /// The GFListTile's background color. Can be given [Color] or [GFColors] - final Color color; - - /// type of [Widget] or [GFAvatar] used to create rounded user profile - final Widget avatar; - - /// defines the margin of GFListTile - final EdgeInsets margin; - - /// defines the padding of GFListTile - final EdgeInsets padding; - - /// type of [GFCheckboxType] which is of four type is basic, sqaure, circular and custom - final GFCheckboxType type; - - /// type of [double] which is GFSize ie, small, medium and large and can use any double value - final double size; - - /// type pf [Color] used to change the checkcolor when the checkbox is active - final Color checkColor; - - /// type of [Color] used to change the backgroundColor of the active checkbox - final Color activebgColor; - - /// type of [Color] used to change the backgroundColor of the inactive checkbox - final Color inactivebgColor; - - /// type of [Color] used to change the border color of the active checkbox - final Color activeBorderColor; - - /// type of [Color] used to change the border color of the inactive checkbox - final Color inactiveBorderColor; - - /// Called when the user checks or unchecks the checkbox. - // final ValueChanged onChanged; - - ///Used to set the current state of the checkbox - // final bool value; - - ///type of Widget used to change the checkbox's active icon - final Widget activeIcon; - - ///type of [Widget] used to change the checkbox's inactive icon - final Widget inactiveIcon; - - /// type of [Color] used to change the background color of the custom active checkbox only - final Color custombgColor; - - /// To have the list tile appear selected when the checkbox is checked, pass the same value to both. - /// Normally, this property is left to its default value, false. - final bool selected; - - final List items; - - final Widget submitbutton; - - final Color dropdownbgColor; - - final TextStyle selectedTextStyle; - - final IconData expandedicon; - - final IconData collapsedicon; - - @override - _GFMultilevelDropdownState createState() => _GFMultilevelDropdownState(); -} - -class _GFMultilevelDropdownState extends State { - bool check = true; - bool isdrop = false; - bool check1 = false; - - final _controller = TextEditingController(); - - List _selecteCategorys = List(); - - void initState() { - super.initState(); - setState(() {}); - // if (widget.items != null) { - // _selecteCategorys.addAll(widget.items); - // } - } - - void _onCategorySelected(bool selected, category_id) { - if (selected == true) { - setState(() { - _selecteCategorys.add(category_id); - }); - } else { - setState(() { - _selecteCategorys.remove(category_id); - }); - } - } - - @override - void dispose() { - _controller.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return Column( - children: [ - InkWell( - onTap: () { - setState(() { - isdrop = !isdrop; - }); - }, - child: Container( - - // height: 40, - width: MediaQuery.of(context).size.width, - decoration: BoxDecoration( - border: Border(bottom: BorderSide(color: Colors.black12))), - child: Container( - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - child: Container( - padding: EdgeInsets.only(bottom: 10), - child: Text(_selecteCategorys.join(' , ').toString(), - style: widget.selectedTextStyle), - )), - Icon( - !isdrop ? widget.expandedicon : widget.collapsedicon, - color: Colors.black87, - size: 30.0, - ), - ], - ), - ))), - isdrop - ? Container( - decoration: BoxDecoration( - color: widget.dropdownbgColor, - boxShadow: [ - BoxShadow( - color: Colors.black12, - blurRadius: 3.0, - ) - ], - ), - height: 300, - - child: SingleChildScrollView( - child: Column(children: [ - Column( - children: List.generate(widget.items.length, (index) { - return GFCheckboxListTile( - value: _selecteCategorys.contains(widget.items[index]), - onChanged: (bool selected) { - _controller.text; - print(selected); - _onCategorySelected(selected, widget.items[index]); - }, - selected: widget.selected, - avatar: widget.avatar, - titleText: widget.items[index], - color: widget.color, - padding: widget.padding, - margin: widget.margin, - size: widget.size, - activebgColor: widget.activebgColor, - inactiveIcon: widget.inactiveIcon, - activeBorderColor: widget.activeBorderColor, - inactivebgColor: widget.inactivebgColor, - activeIcon: widget.activeIcon, - inactiveBorderColor: widget.inactiveBorderColor, - custombgColor: widget.custombgColor, - checkColor: widget.checkColor, - type: widget.type, - ); - })), - GFButton( - padding: EdgeInsets.all(0), - onPressed: () { - setState(() { - isdrop = !isdrop; - }); - - print(_selecteCategorys); - }, - child: widget.submitbutton, - ) - ]))) - : Container(), - ], - ); - } -} diff --git a/lib/components/text_field/gf_text_field.dart b/lib/components/text_field/gf_text_field.dart index df2876ad..3a99a4fe 100644 --- a/lib/components/text_field/gf_text_field.dart +++ b/lib/components/text_field/gf_text_field.dart @@ -1,247 +1,244 @@ - - -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter/material.dart'; - - -export 'package:flutter/services.dart' show SmartQuotesType, SmartDashesType; - -class GFTextField extends FormField { - GFTextField({ - Key key, - this.controller, - String initialValue, - FocusNode focusNode, - InputDecoration decoration = const InputDecoration(), - TextInputType keyboardType, - TextCapitalization textCapitalization = TextCapitalization.none, - TextInputAction textInputAction, - TextStyle style, - StrutStyle strutStyle, - TextDirection textDirection, - TextAlign textAlign = TextAlign.start, - TextAlignVertical textAlignVertical, - bool autofocus = false, - bool readOnly = false, - ToolbarOptions toolbarOptions, - bool showCursor, - String obscuringCharacter = '•', - bool obscureText = false, - bool autocorrect = true, - SmartDashesType smartDashesType, - SmartQuotesType smartQuotesType, - bool enableSuggestions = true, - bool autovalidate = false, - bool maxLengthEnforced = true, - int maxLines = 1, - int minLines, - bool expands = false, - int maxLength, - ValueChanged onChanged, - GestureTapCallback onTap, - VoidCallback onEditingComplete, - ValueChanged onFieldSubmitted, - FormFieldSetter onSaved, - FormFieldValidator validator, - List inputFormatters, - bool enabled, - double cursorWidth = 2.0, - double cursorHeight, - Radius cursorRadius, - Color cursorColor, - Color color, - Radius borderradius, - Brightness keyboardAppearance, - EdgeInsets scrollPadding = const EdgeInsets.all(20.0), - bool enableInteractiveSelection = true, - InputCounterWidgetBuilder buildCounter, - ScrollPhysics scrollPhysics, - Iterable autofillHints, - AutovalidateMode autovalidateMode, - }) : assert(initialValue == null || controller == null), - assert(textAlign != null), - assert(autofocus != null), - assert(readOnly != null), - assert(obscuringCharacter != null && obscuringCharacter.length == 1), - assert(obscureText != null), - assert(autocorrect != null), - assert(enableSuggestions != null), - assert(autovalidate != null), - assert( - autovalidate == false || - autovalidate == true && autovalidateMode == null, - 'autovalidate and autovalidateMode should not be used together.'), - assert(maxLengthEnforced != null), - assert(scrollPadding != null), - assert(maxLines == null || maxLines > 0), - assert(minLines == null || minLines > 0), - assert( - (maxLines == null) || (minLines == null) || (maxLines >= minLines), - "minLines can't be greater than maxLines", - ), - assert(expands != null), - assert( - !expands || (maxLines == null && minLines == null), - 'minLines and maxLines must be null when expands is true.', - ), - assert(!obscureText || maxLines == 1, - 'Obscured fields cannot be multiline.'), - assert(maxLength == null || maxLength > 0), - assert(enableInteractiveSelection != null), - super( - key: key, - initialValue: - controller != null ? controller.text : (initialValue ?? ''), - onSaved: onSaved, - validator: validator, - enabled: enabled ?? decoration?.enabled ?? true, - autovalidateMode: autovalidate - ? AutovalidateMode.always - : (autovalidateMode ?? AutovalidateMode.disabled), - builder: (FormFieldState field) { - final _GFTextFieldState state = field as _GFTextFieldState; - final InputDecoration effectiveDecoration = (decoration ?? - const InputDecoration()) - .applyDefaults(Theme.of(field.context).inputDecorationTheme); - void onChangedHandler(String value) { - if (onChanged != null) { - onChanged(value); - } - field.didChange(value); - } - - return Container( - decoration: BoxDecoration(border: Border.all(color: color)), - child: TextField( - controller: state._effectiveController, - focusNode: focusNode, - decoration: - effectiveDecoration.copyWith(errorText: field.errorText) != - null - ? decoration - : color, - keyboardType: keyboardType, - textInputAction: textInputAction, - style: style, - strutStyle: strutStyle, - textAlign: textAlign, - textAlignVertical: textAlignVertical, - textDirection: textDirection, - textCapitalization: textCapitalization, - autofocus: autofocus, - toolbarOptions: toolbarOptions, - readOnly: readOnly, - showCursor: showCursor, - obscuringCharacter: obscuringCharacter, - obscureText: obscureText, - autocorrect: autocorrect, - smartDashesType: smartDashesType ?? - (obscureText - ? SmartDashesType.disabled - : SmartDashesType.enabled), - smartQuotesType: smartQuotesType ?? - (obscureText - ? SmartQuotesType.disabled - : SmartQuotesType.enabled), - enableSuggestions: enableSuggestions, - maxLengthEnforced: maxLengthEnforced, - maxLines: maxLines, - minLines: minLines, - expands: expands, - maxLength: maxLength, - onChanged: onChangedHandler, - onTap: onTap, - onEditingComplete: onEditingComplete, - onSubmitted: onFieldSubmitted, - inputFormatters: inputFormatters, - enabled: enabled ?? decoration?.enabled ?? true, - cursorWidth: cursorWidth, - cursorHeight: cursorHeight, - cursorRadius: cursorRadius, - cursorColor: cursorColor, - scrollPadding: scrollPadding, - scrollPhysics: scrollPhysics, - keyboardAppearance: keyboardAppearance, - enableInteractiveSelection: enableInteractiveSelection, - buildCounter: buildCounter, - autofillHints: autofillHints, - ), - ); - }, - ); - final TextEditingController controller; - - @override - _GFTextFieldState createState() => _GFTextFieldState(); -} - -class _GFTextFieldState extends FormFieldState { - TextEditingController _controller; - - TextEditingController get _effectiveController => - widget.controller ?? _controller; - - @override - GFTextField get widget => super.widget as GFTextField; - - @override - void initState() { - super.initState(); - if (widget.controller == null) { - _controller = TextEditingController(text: widget.initialValue); - } else { - widget.controller.addListener(_handleControllerChanged); - } - } - - @override - void didUpdateWidget(GFTextField oldWidget) { - super.didUpdateWidget(oldWidget); - if (widget.controller != oldWidget.controller) { - oldWidget.controller?.removeListener(_handleControllerChanged); - widget.controller?.addListener(_handleControllerChanged); - - if (oldWidget.controller != null && widget.controller == null) - _controller = - TextEditingController.fromValue(oldWidget.controller.value); - if (widget.controller != null) { - setValue(widget.controller.text); - if (oldWidget.controller == null) _controller = null; - } - } - } - - @override - void dispose() { - widget.controller?.removeListener(_handleControllerChanged); - super.dispose(); - } - - @override - void didChange(String value) { - super.didChange(value); - - if (_effectiveController.text != value) _effectiveController.text = value; - } - - @override - void reset() { - super.reset(); - setState(() { - _effectiveController.text = widget.initialValue; - }); - } - - void _handleControllerChanged() { - // Suppress changes that originated from within this class. - // - // In the case where a controller has been passed in to this widget, we - // register this change listener. In these cases, we'll also receive change - // notifications for changes originating from within this class -- for - // example, the reset() method. In such cases, the FormField value will - // already have been set. - if (_effectiveController.text != value) - didChange(_effectiveController.text); - } -} +// import 'package:flutter/services.dart'; +// import 'package:flutter/widgets.dart'; +// import 'package:flutter/material.dart'; + +// export 'package:flutter/services.dart' show SmartQuotesType, SmartDashesType; + +// class GFTextField extends FormField { +// GFTextField({ +// Key key, +// this.controller, +// String initialValue, +// FocusNode focusNode, +// InputDecoration decoration = const InputDecoration(), +// TextInputType keyboardType, +// TextCapitalization textCapitalization = TextCapitalization.none, +// TextInputAction textInputAction, +// TextStyle style, +// StrutStyle strutStyle, +// TextDirection textDirection, +// TextAlign textAlign = TextAlign.start, +// TextAlignVertical textAlignVertical, +// bool autofocus = false, +// bool readOnly = false, +// ToolbarOptions toolbarOptions, +// bool showCursor, +// String obscuringCharacter = '•', +// bool obscureText = false, +// bool autocorrect = true, +// SmartDashesType smartDashesType, +// SmartQuotesType smartQuotesType, +// bool enableSuggestions = true, +// bool autovalidate = false, +// bool maxLengthEnforced = true, +// int maxLines = 1, +// int minLines, +// bool expands = false, +// int maxLength, +// ValueChanged onChanged, +// GestureTapCallback onTap, +// VoidCallback onEditingComplete, +// ValueChanged onFieldSubmitted, +// FormFieldSetter onSaved, +// FormFieldValidator validator, +// List inputFormatters, +// bool enabled, +// double cursorWidth = 2.0, +// double cursorHeight, +// Radius cursorRadius, +// Color cursorColor, +// Color color, +// Radius borderradius, +// Brightness keyboardAppearance, +// EdgeInsets scrollPadding = const EdgeInsets.all(20.0), +// bool enableInteractiveSelection = true, +// InputCounterWidgetBuilder buildCounter, +// ScrollPhysics scrollPhysics, +// Iterable autofillHints, +// AutovalidateMode autovalidateMode, +// }) : assert(initialValue == null || controller == null), +// assert(textAlign != null), +// assert(autofocus != null), +// assert(readOnly != null), +// assert(obscuringCharacter != null && obscuringCharacter.length == 1), +// assert(obscureText != null), +// assert(autocorrect != null), +// assert(enableSuggestions != null), +// assert(autovalidate != null), +// assert( +// autovalidate == false || +// autovalidate == true && autovalidateMode == null, +// 'autovalidate and autovalidateMode should not be used together.'), +// assert(maxLengthEnforced != null), +// assert(scrollPadding != null), +// assert(maxLines == null || maxLines > 0), +// assert(minLines == null || minLines > 0), +// assert( +// (maxLines == null) || (minLines == null) || (maxLines >= minLines), +// "minLines can't be greater than maxLines", +// ), +// assert(expands != null), +// assert( +// !expands || (maxLines == null && minLines == null), +// 'minLines and maxLines must be null when expands is true.', +// ), +// assert(!obscureText || maxLines == 1, +// 'Obscured fields cannot be multiline.'), +// assert(maxLength == null || maxLength > 0), +// assert(enableInteractiveSelection != null), +// super( +// key: key, +// initialValue: +// controller != null ? controller.text : (initialValue ?? ''), +// onSaved: onSaved, +// validator: validator, +// enabled: enabled ?? decoration?.enabled ?? true, +// autovalidateMode: autovalidate +// ? AutovalidateMode.always +// : (autovalidateMode ?? AutovalidateMode.disabled), +// builder: (FormFieldState field) { +// final _GFTextFieldState state = field as _GFTextFieldState; +// final InputDecoration effectiveDecoration = (decoration ?? +// const InputDecoration()) +// .applyDefaults(Theme.of(field.context).inputDecorationTheme); +// void onChangedHandler(String value) { +// if (onChanged != null) { +// onChanged(value); +// } +// field.didChange(value); +// } + +// return Container( +// decoration: BoxDecoration(border: Border.all(color: color)), +// child: TextField( +// controller: state._effectiveController, +// focusNode: focusNode, +// decoration: +// effectiveDecoration.copyWith(errorText: field.errorText) != +// null +// ? decoration +// : color, +// keyboardType: keyboardType, +// textInputAction: textInputAction, +// style: style, +// strutStyle: strutStyle, +// textAlign: textAlign, +// textAlignVertical: textAlignVertical, +// textDirection: textDirection, +// textCapitalization: textCapitalization, +// autofocus: autofocus, +// toolbarOptions: toolbarOptions, +// readOnly: readOnly, +// showCursor: showCursor, +// obscuringCharacter: obscuringCharacter, +// obscureText: obscureText, +// autocorrect: autocorrect, +// smartDashesType: smartDashesType ?? +// (obscureText +// ? SmartDashesType.disabled +// : SmartDashesType.enabled), +// smartQuotesType: smartQuotesType ?? +// (obscureText +// ? SmartQuotesType.disabled +// : SmartQuotesType.enabled), +// enableSuggestions: enableSuggestions, +// maxLengthEnforced: maxLengthEnforced, +// maxLines: maxLines, +// minLines: minLines, +// expands: expands, +// maxLength: maxLength, +// onChanged: onChangedHandler, +// onTap: onTap, +// onEditingComplete: onEditingComplete, +// onSubmitted: onFieldSubmitted, +// inputFormatters: inputFormatters, +// enabled: enabled ?? decoration?.enabled ?? true, +// cursorWidth: cursorWidth, +// cursorHeight: cursorHeight, +// cursorRadius: cursorRadius, +// cursorColor: cursorColor, +// scrollPadding: scrollPadding, +// scrollPhysics: scrollPhysics, +// keyboardAppearance: keyboardAppearance, +// enableInteractiveSelection: enableInteractiveSelection, +// buildCounter: buildCounter, +// autofillHints: autofillHints, +// ), +// ); +// }, +// ); +// final TextEditingController controller; + +// @override +// _GFTextFieldState createState() => _GFTextFieldState(); +// } + +// class _GFTextFieldState extends FormFieldState { +// TextEditingController _controller; + +// TextEditingController get _effectiveController => +// widget.controller ?? _controller; + +// @override +// GFTextField get widget => super.widget as GFTextField; + +// @override +// void initState() { +// super.initState(); +// if (widget.controller == null) { +// _controller = TextEditingController(text: widget.initialValue); +// } else { +// widget.controller.addListener(_handleControllerChanged); +// } +// } + +// @override +// void didUpdateWidget(GFTextField oldWidget) { +// super.didUpdateWidget(oldWidget); +// if (widget.controller != oldWidget.controller) { +// oldWidget.controller?.removeListener(_handleControllerChanged); +// widget.controller?.addListener(_handleControllerChanged); + +// if (oldWidget.controller != null && widget.controller == null) +// _controller = +// TextEditingController.fromValue(oldWidget.controller.value); +// if (widget.controller != null) { +// setValue(widget.controller.text); +// if (oldWidget.controller == null) _controller = null; +// } +// } +// } + +// @override +// void dispose() { +// widget.controller?.removeListener(_handleControllerChanged); +// super.dispose(); +// } + +// @override +// void didChange(String value) { +// super.didChange(value); + +// if (_effectiveController.text != value) _effectiveController.text = value; +// } + +// @override +// void reset() { +// super.reset(); +// setState(() { +// _effectiveController.text = widget.initialValue; +// }); +// } + +// void _handleControllerChanged() { +// // Suppress changes that originated from within this class. +// // +// // In the case where a controller has been passed in to this widget, we +// // register this change listener. In these cases, we'll also receive change +// // notifications for changes originating from within this class -- for +// // example, the reset() method. In such cases, the FormField value will +// // already have been set. +// if (_effectiveController.text != value) +// didChange(_effectiveController.text); +// } +// } diff --git a/pubspec.lock b/pubspec.lock index 3485d141..9477cdd7 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,49 +7,49 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety" + version: "2.4.2" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety" + version: "2.0.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.2" + version: "1.0.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety" + version: "1.1.3" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety" + version: "1.0.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.2" + version: "1.14.13" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety" + version: "1.1.0" flutter: dependency: "direct main" description: flutter @@ -66,21 +66,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety" + version: "0.12.8" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.2" + version: "1.1.8" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety" + version: "1.7.0" sky_engine: dependency: transitive description: flutter @@ -92,55 +92,55 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety" + version: "1.7.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety" + version: "1.9.5" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety" + version: "2.0.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety" + version: "1.0.5" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety" + version: "1.1.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety" + version: "0.2.17" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.2" + version: "1.2.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.2" + version: "2.0.8" sdks: - dart: ">=2.10.0-0.0.dev <2.10.0" + dart: ">=2.9.0-14.0.dev <3.0.0" From 154d789e57236fe60aa8502a7fb07b292ea36b7b Mon Sep 17 00:00:00 2001 From: Sandip Kakadiya Date: Fri, 2 Oct 2020 16:01:41 +0530 Subject: [PATCH 05/25] loader, listtile, progressbar, radiotile changes & comments changes --- lib/components/list_tile/gf_list_tile.dart | 2 +- lib/components/loader/gf_loader.dart | 69 +++++--------- .../progress_bar/gf_progress_bar.dart | 11 +-- lib/components/radio/gf_radio.dart | 5 +- .../radio_list_tile/gf_radio_list_tile.dart | 91 ++++++++++--------- 5 files changed, 74 insertions(+), 104 deletions(-) diff --git a/lib/components/list_tile/gf_list_tile.dart b/lib/components/list_tile/gf_list_tile.dart index 0c535fe3..5b08e13e 100644 --- a/lib/components/list_tile/gf_list_tile.dart +++ b/lib/components/list_tile/gf_list_tile.dart @@ -107,7 +107,7 @@ class GFListTile extends StatelessWidget { selected: selected, enabled: enabled, child: Container( -// constraints: const BoxConstraints(minHeight: 50), + // constraints: const BoxConstraints(minHeight: 50), padding: padding, margin: margin, decoration: BoxDecoration( diff --git a/lib/components/loader/gf_loader.dart b/lib/components/loader/gf_loader.dart index 769e6426..c47ba463 100644 --- a/lib/components/loader/gf_loader.dart +++ b/lib/components/loader/gf_loader.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:getwidget/getwidget.dart'; class GFLoader extends StatefulWidget { + /// [GFLoader] shows differnt type of loaders with different customization options. const GFLoader( {Key key, this.loaderColorOne = Colors.redAccent, @@ -66,51 +67,25 @@ class _GFLoaderState extends State Animation loaderanimation2; Animation loaderanimation3; AnimationController controller; + Interval interval = const Interval(0.1, 0.81, curve: Curves.linear); @override void initState() { - super.initState(); - controller = AnimationController(duration: widget.duration, vsync: this); - loaderanimation1 = Tween(begin: 0, end: 1).animate( - CurvedAnimation( - parent: controller, - curve: const Interval( - 0, - 0.71, - curve: Curves.linear, - ), - ), + CurvedAnimation(parent: controller, curve: interval), ); - loaderanimation2 = Tween(begin: 0, end: 1).animate( - CurvedAnimation( - parent: controller, - curve: const Interval( - 0.1, - 0.81, - curve: Curves.linear, - ), - ), + CurvedAnimation(parent: controller, curve: interval), ); - loaderanimation3 = Tween(begin: 0, end: 1).animate( - CurvedAnimation( - parent: controller, - curve: const Interval( - 0.2, - 0.91, - curve: Curves.linear, - ), - ), + CurvedAnimation(parent: controller, curve: interval), ); - controller.addListener(() { setState(() {}); }); - controller.repeat(); + super.initState(); } @override @@ -129,7 +104,7 @@ class _GFLoaderState extends State child: CircularProgressIndicator( valueColor: widget.androidLoaderColor, strokeWidth: widget.loaderstrokeWidth, -// value: 20, + // value: 20, ), )) : widget.type == GFLoaderType.ios @@ -172,7 +147,6 @@ class _GFLoaderState extends State color: widget.loaderColorTwo, type: widget.type, icon: widget.loaderIconTwo, -// ), ), ), @@ -190,7 +164,6 @@ class _GFLoaderState extends State color: widget.loaderColorThree, type: widget.type, icon: widget.loaderIconThree, -// ), ), ), @@ -200,7 +173,9 @@ class _GFLoaderState extends State @override void dispose() { - controller.dispose(); + if (controller != null) { + controller.dispose(); + } super.dispose(); } } @@ -215,7 +190,6 @@ class Loader extends StatelessWidget { this.size, this.child}) : super(key: key); - final double radius; final Color color; final GFLoaderType type; @@ -225,15 +199,16 @@ class Loader extends StatelessWidget { @override Widget build(BuildContext context) => Center( - child: type == GFLoaderType.custom - ? Container(child: child != null ? child : icon ?? Container()) - : Container( - width: radius, - height: radius, - decoration: BoxDecoration( - color: color, - shape: type == GFLoaderType.circle - ? BoxShape.circle - : BoxShape.rectangle), - )); + child: type == GFLoaderType.custom + ? Container(child: child != null ? child : icon ?? Container()) + : Container( + width: radius, + height: radius, + decoration: BoxDecoration( + color: color, + shape: type == GFLoaderType.circle + ? BoxShape.circle + : BoxShape.rectangle), + ), + ); } diff --git a/lib/components/progress_bar/gf_progress_bar.dart b/lib/components/progress_bar/gf_progress_bar.dart index dc6e55ad..3b2c09fd 100644 --- a/lib/components/progress_bar/gf_progress_bar.dart +++ b/lib/components/progress_bar/gf_progress_bar.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:getwidget/getwidget.dart'; class GFProgressBar extends StatefulWidget { + /// Shows progress as a completed and remaining percentage in bar of given state GFProgressBar({ Key key, this.percentage = 0.2, @@ -33,7 +34,6 @@ class GFProgressBar extends StatefulWidget { throw ArgumentError( ' linearGradient and progressBarColor cannot be given'); } - assert(circleStartAngle >= 0.0); if (percentage < 0.0 || percentage > 1.0) { throw Exception('Percentage value must be be tween 0.0 and 1.0'); @@ -276,7 +276,6 @@ class _GFProgressBarState extends State if (widget.trailing != null) { item.add(widget.trailing); } - return widget.type == GFProgressType.linear ? Material( color: Colors.transparent, @@ -334,7 +333,6 @@ class LinearPainter extends CustomPainter { _paintBackground.strokeCap = StrokeCap.round; } } - final Paint _paintBackground = Paint(); final Paint _paintLine = Paint(); final double circleWidth; @@ -353,11 +351,9 @@ class LinearPainter extends CustomPainter { final start = Offset(0, size.height / 2); final end = Offset(size.width, size.height / 2); canvas.drawLine(start, end, _paintBackground); - if (mask != null) { _paintLine.maskFilter = mask; } - if (fromRightToLeft) { final xProgress = size.width - size.width * progress; if (linearGradient != null) { @@ -416,7 +412,6 @@ class CirclePainter extends CustomPainter { _paintBackground.color = backgroundColor; _paintBackground.style = PaintingStyle.stroke; _paintBackground.strokeWidth = circleWidth; - _paintLine.color = progressBarColor; _paintLine.style = PaintingStyle.stroke; _paintLine.strokeWidth = circleWidth; @@ -444,7 +439,6 @@ class CirclePainter extends CustomPainter { void paint(Canvas canvas, Size size) { final child = Offset(size.width / 2, size.height / 2); canvas.drawCircle(child, radius, _paintBackground); - if (mask != null) { _paintLine.maskFilter = mask; } @@ -456,11 +450,8 @@ class CirclePainter extends CustomPainter { ), ); } - final double fixedStartAngle = circleStartAngle; - const double circleStartAngleFixedMargin = 1; - if (reverse) { final start = radians(360 * circleStartAngleFixedMargin - 90.0 + fixedStartAngle); diff --git a/lib/components/radio/gf_radio.dart b/lib/components/radio/gf_radio.dart index 5573c48d..13edac3c 100644 --- a/lib/components/radio/gf_radio.dart +++ b/lib/components/radio/gf_radio.dart @@ -5,6 +5,7 @@ import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; class GFRadio extends StatefulWidget { + /// [GFRadio] is one type of selection indicator in a list of options. const GFRadio( {Key key, @required this.value, @@ -95,7 +96,6 @@ class _GFRadioState extends State> with TickerProviderStateMixin { T groupValue; void onStatusChange() { - print('wer ${widget.value == widget.groupValue}'); groupValue = widget.value; _handleChanged(widget.value == groupValue); } @@ -112,10 +112,7 @@ class _GFRadioState extends State> with TickerProviderStateMixin { @override Widget build(BuildContext context) { -// print('gr ${widget.value} ${widget.groupValue}'); selected = widget.value == widget.groupValue; -// print('sel $selected'); - return InkWell( enableFeedback: enabled, onTap: onStatusChange, diff --git a/lib/components/radio_list_tile/gf_radio_list_tile.dart b/lib/components/radio_list_tile/gf_radio_list_tile.dart index c6464d78..e952e3c5 100644 --- a/lib/components/radio_list_tile/gf_radio_list_tile.dart +++ b/lib/components/radio_list_tile/gf_radio_list_tile.dart @@ -14,6 +14,7 @@ class GFRadioListTile extends StatelessWidget { this.inactivebgColor = GFColors.WHITE, this.activeBorderColor = GFColors.DARK, this.inactiveBorderColor = GFColors.DARK, + this.position = GFPosition.end, this.activeIcon = const Icon( Icons.check, size: 20, @@ -59,7 +60,7 @@ class GFRadioListTile extends StatelessWidget { /// The GFListTile's background color. Can be given [Color] or [GFColors] final Color color; - /// type of [Widget] or [GFAvatar] used to create rounded user profile + /// If position is start Checkbox will come instead of avatar, type of [Widget] or [GFAvatar] used to create rounded user profile final Widget avatar; /// The title to display inside the [GFListTile]. see [Text] @@ -71,7 +72,7 @@ class GFRadioListTile extends StatelessWidget { /// The description to display inside the [GFListTile]. see [Text] final Widget description; - /// The icon to display inside the [GFListTile]. see [Icon] + /// If position is end Checkbox will come instead of icon, The icon to display inside the [GFListTile]. see [Icon] final Widget icon; /// defines the margin of GFListTile @@ -92,6 +93,9 @@ class GFRadioListTile extends StatelessWidget { /// Inoperative if [enabled] is false. final GestureTapCallback onTap; + /// Position allows user to set position of [GFCheckbox] based on given [GFPosition] + final GFPosition position; + /// Called when the user long-presses on this list tile. /// /// Inoperative if [enabled] is false. @@ -163,45 +167,48 @@ class GFRadioListTile extends StatelessWidget { bool get checked => value == groupValue; @override - Widget build(BuildContext context) => MergeSemantics( - child: GFListTile( - autofocus: autofocus, - enabled: onChanged != null, - onTap: onChanged != null - ? () { - if (toggleable && checked) { - onChanged(null); - return; - } - if (!checked) { - onChanged(value); - } + Widget build(BuildContext context) { + GFRadio radio = GFRadio( + autofocus: autofocus, + onChanged: onChanged, + value: value, + groupValue: groupValue, + size: size, + activebgColor: activebgColor, + inactiveIcon: inactiveIcon, + activeBorderColor: activeBorderColor, + inactivebgColor: inactivebgColor, + activeIcon: activeIcon, + inactiveBorderColor: inactiveBorderColor, + custombgColor: custombgColor, + ); + return MergeSemantics( + child: GFListTile( + autofocus: autofocus, + enabled: onChanged != null, + onTap: onChanged != null + ? () { + if (toggleable && checked) { + onChanged(null); + return; + } + if (!checked) { + onChanged(value); } - : null, - selected: selected, - avatar: avatar, - titleText: titleText, - subTitle: subTitle, - subtitleText: subtitleText, - description: description, - color: color, - padding: padding, - margin: margin, - title: title, - icon: GFRadio( - autofocus: autofocus, - onChanged: onChanged, - value: value, - groupValue: groupValue, - size: size, - activebgColor: activebgColor, - inactiveIcon: inactiveIcon, - activeBorderColor: activeBorderColor, - inactivebgColor: inactivebgColor, - activeIcon: activeIcon, - inactiveBorderColor: inactiveBorderColor, - custombgColor: custombgColor, - ), - ), - ); + } + : null, + selected: selected, + avatar: position == GFPosition.start ? radio : avatar, + titleText: titleText, + subTitle: subTitle, + subtitleText: subtitleText, + description: description, + color: color, + padding: padding, + margin: margin, + title: title, + icon: position == GFPosition.end ? radio : icon, + ), + ); + } } From ee489ab6a1a3a349ede1ef19d6e391a5709f6b8f Mon Sep 17 00:00:00 2001 From: Sandip Kakadiya Date: Fri, 2 Oct 2020 17:20:33 +0530 Subject: [PATCH 06/25] radio, radiotile, rating, sticky header changes & review --- lib/components/checkbox/gf_checkbox.dart | 2 +- .../gf_checkbox_list_tile.dart | 2 +- lib/components/radio/gf_radio.dart | 6 +----- .../radio_list_tile/gf_radio_list_tile.dart | 17 ++++++++--------- lib/components/rating/gf_rating.dart | 1 + lib/components/shimmer/gf_shimmer.dart | 5 ++++- .../sticky_header/gf_sticky_header.dart | 3 +-- .../sticky_header/gf_sticky_header_builder.dart | 7 ++++--- .../sticky_header/render_gf_sticky_header.dart | 7 ------- lib/components/tabs/gf_segment_tabs.dart | 14 +++++++------- lib/components/tabs/gf_tabbar.dart | 14 ++++++-------- lib/components/tabs/gf_tabbar_view.dart | 12 +----------- lib/components/toast/gf_toast.dart | 4 ++-- lib/getwidget.dart | 2 +- 14 files changed, 38 insertions(+), 58 deletions(-) diff --git a/lib/components/checkbox/gf_checkbox.dart b/lib/components/checkbox/gf_checkbox.dart index faafbf5e..8fe7709c 100644 --- a/lib/components/checkbox/gf_checkbox.dart +++ b/lib/components/checkbox/gf_checkbox.dart @@ -19,7 +19,7 @@ class GFCheckbox extends StatefulWidget { size: 20, color: GFColors.WHITE, ), - this.inactiveIcon = const Icon(Icons.close), + this.inactiveIcon, this.custombgColor = GFColors.SUCCESS, this.autofocus = false, this.focusNode}) diff --git a/lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart b/lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart index 58aff514..fda47044 100644 --- a/lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart +++ b/lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart @@ -29,7 +29,7 @@ class GFCheckboxListTile extends StatelessWidget { size: 20, color: GFColors.WHITE, ), - this.inactiveIcon = const Icon(Icons.close), + this.inactiveIcon, this.custombgColor = GFColors.SUCCESS, this.position = GFPosition.end, this.selected = false, diff --git a/lib/components/radio/gf_radio.dart b/lib/components/radio/gf_radio.dart index 13edac3c..6bd558d5 100644 --- a/lib/components/radio/gf_radio.dart +++ b/lib/components/radio/gf_radio.dart @@ -23,11 +23,7 @@ class GFRadio extends StatefulWidget { size: 20, color: GFColors.DARK, ), - this.inactiveIcon = const Icon( - Icons.close, - size: 20, - color: GFColors.DARK, - ), + this.inactiveIcon, this.custombgColor = GFColors.SUCCESS, this.autofocus = false, this.focusNode, diff --git a/lib/components/radio_list_tile/gf_radio_list_tile.dart b/lib/components/radio_list_tile/gf_radio_list_tile.dart index e952e3c5..f4f09fb8 100644 --- a/lib/components/radio_list_tile/gf_radio_list_tile.dart +++ b/lib/components/radio_list_tile/gf_radio_list_tile.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:getwidget/getwidget.dart'; class GFRadioListTile extends StatelessWidget { + /// [GFRadioListTile] is a list title of with [GFRadio] in it. const GFRadioListTile({ Key key, @required this.value, @@ -20,11 +21,7 @@ class GFRadioListTile extends StatelessWidget { size: 20, color: GFColors.DARK, ), - this.inactiveIcon = const Icon( - Icons.close, - size: 20, - color: GFColors.DARK, - ), + this.inactiveIcon, this.custombgColor = GFColors.SUCCESS, this.autofocus = false, this.focusNode, @@ -156,8 +153,7 @@ class GFRadioListTile extends StatelessWidget { /// The value represented by this radio button. final T value; - /// The currently selected value for a group of radio buttons. Radio button is considered selected if its [value] matches the - /// [groupValue]. + /// The currently selected value for a group of radio buttons. Radio button is considered selected if its [value] matches the [groupValue]. final T groupValue; /// sets the radio value @@ -168,12 +164,13 @@ class GFRadioListTile extends StatelessWidget { @override Widget build(BuildContext context) { - GFRadio radio = GFRadio( - autofocus: autofocus, + final GFRadio radio = GFRadio( onChanged: onChanged, value: value, groupValue: groupValue, size: size, + type: type, + radioColor: radioColor, activebgColor: activebgColor, inactiveIcon: inactiveIcon, activeBorderColor: activeBorderColor, @@ -181,11 +178,13 @@ class GFRadioListTile extends StatelessWidget { activeIcon: activeIcon, inactiveBorderColor: inactiveBorderColor, custombgColor: custombgColor, + toggleable: toggleable, ); return MergeSemantics( child: GFListTile( autofocus: autofocus, enabled: onChanged != null, + focusNode: focusNode, onTap: onChanged != null ? () { if (toggleable && checked) { diff --git a/lib/components/rating/gf_rating.dart b/lib/components/rating/gf_rating.dart index d6de70cb..48f68962 100644 --- a/lib/components/rating/gf_rating.dart +++ b/lib/components/rating/gf_rating.dart @@ -4,6 +4,7 @@ import 'package:getwidget/getwidget.dart'; typedef RatingChangeCallback = void Function(double rating); class GFRating extends StatefulWidget { + /// [GFRating] to show ratings with many custimazation options. const GFRating({ this.itemCount = 5, this.spacing = 0.0, diff --git a/lib/components/shimmer/gf_shimmer.dart b/lib/components/shimmer/gf_shimmer.dart index 0c707fe0..8fb31cb5 100644 --- a/lib/components/shimmer/gf_shimmer.dart +++ b/lib/components/shimmer/gf_shimmer.dart @@ -3,6 +3,7 @@ import 'package:flutter/rendering.dart'; import 'package:getwidget/getwidget.dart'; class GFShimmer extends StatefulWidget { + /// [GFShimmer] shows shimmer effect. const GFShimmer({ Key key, @required this.child, @@ -125,7 +126,9 @@ class _GFShimmerState extends State @override void dispose() { - _controller.dispose(); + if (_controller != null) { + _controller.dispose(); + } super.dispose(); } } diff --git a/lib/components/sticky_header/gf_sticky_header.dart b/lib/components/sticky_header/gf_sticky_header.dart index a18e2008..1f037244 100644 --- a/lib/components/sticky_header/gf_sticky_header.dart +++ b/lib/components/sticky_header/gf_sticky_header.dart @@ -5,9 +5,8 @@ import 'package:flutter/widgets.dart'; import 'package:meta/meta.dart'; import 'package:getwidget/getwidget.dart'; -/// Place this widget inside a [ListView], [GridView], [CustomScrollView], [SingleChildScrollView] or similar. - class GFStickyHeader extends MultiChildRenderObjectWidget { + /// Place this widget inside a [ListView], [GridView], [CustomScrollView], [SingleChildScrollView] or similar. GFStickyHeader( {Key key, @required this.stickyContent, diff --git a/lib/components/sticky_header/gf_sticky_header_builder.dart b/lib/components/sticky_header/gf_sticky_header_builder.dart index 22c337cd..4ac3992d 100644 --- a/lib/components/sticky_header/gf_sticky_header_builder.dart +++ b/lib/components/sticky_header/gf_sticky_header_builder.dart @@ -2,11 +2,12 @@ import 'package:flutter/material.dart'; import 'package:getwidget/getwidget.dart'; typedef StickyHeaderWidgetBuilder = Widget Function( - BuildContext context, double stuckValue); - -/// Place this widget inside a [ListView], [GridView], [CustomScrollView], [SingleChildScrollView] or similar. + BuildContext context, + double stuckValue, +); class GFStickyHeaderBuilder extends StatefulWidget { + /// Place this widget inside a [ListView], [GridView], [CustomScrollView], [SingleChildScrollView] or similar. /// Constructs a new [GFStickyHeaderBuilder] widget. const GFStickyHeaderBuilder({ Key key, diff --git a/lib/components/sticky_header/render_gf_sticky_header.dart b/lib/components/sticky_header/render_gf_sticky_header.dart index 24d3d0d9..58b890ec 100644 --- a/lib/components/sticky_header/render_gf_sticky_header.dart +++ b/lib/components/sticky_header/render_gf_sticky_header.dart @@ -132,10 +132,8 @@ class RenderGFStickyHeader extends RenderBox assert(childCount == 2); _stickyContentBody.layout(constraints.loosen(), parentUsesSize: true); _contentBody.layout(constraints.loosen(), parentUsesSize: true); - final stickyContentBodyHeight = _stickyContentBody.size.height; final contentBodyHeight = _contentBody.size.height; - final height = max( constraints.minHeight, _enableHeaderOverlap @@ -145,20 +143,15 @@ class RenderGFStickyHeader extends RenderBox size = Size( constraints.constrainWidth(width), constraints.constrainHeight(height)); - final double stickyContentBodyOffset = getHeaderTileStuckOffset(); - assert(constraints != null); double crossSize = 0; double allottedSize = 0; RenderBox child = firstChild; - // ignore: unused_local_variable - int totalChildren = 0; while (child != null) { // ignore: avoid_as final FlexParentData childParentData = child.parentData as FlexParentData; - totalChildren++; final int flex = _getFlex(child); if (flex > 0) { } else { diff --git a/lib/components/tabs/gf_segment_tabs.dart b/lib/components/tabs/gf_segment_tabs.dart index 1f57d51b..e5adde9b 100644 --- a/lib/components/tabs/gf_segment_tabs.dart +++ b/lib/components/tabs/gf_segment_tabs.dart @@ -11,8 +11,8 @@ class GFSegmentTabs extends StatefulWidget { /// [GFSegmentTabs] are best used as an alternative for [GFTabBar]. const GFSegmentTabs( {Key key, -// this.initialIndex = 0, @required this.length, + // this.initialIndex = 0, this.height, this.width, this.border, @@ -31,13 +31,13 @@ class GFSegmentTabs extends StatefulWidget { this.tabs, this.tabController}) : assert(length != null && length >= 0), -// assert(initialIndex != null && -// initialIndex >= 0 && -// (length == 0 || initialIndex < length)), + // assert(initialIndex != null && + // initialIndex >= 0 && + // (length == 0 || initialIndex < length)), super(key: key); -// /// The initial index of the selected tab. Defaults to zero. -// final int initialIndex; + // /// The initial index of the selected tab. Defaults to zero. + // final int initialIndex; /// The total number of tabs. Typically greater than one. Must match [TabBar.tabs]'s and /// [TabBarView.children]'s length. @@ -178,7 +178,7 @@ class _GFSegmentTabsState extends State { borderRadius: widget.borderRadius ?? BorderRadius.circular(2), ), child: DefaultTabController( -// initialIndex: widget.initialIndex, + // initialIndex: widget.initialIndex, length: widget.length, child: Material( borderRadius: widget.borderRadius ?? BorderRadius.circular(2), diff --git a/lib/components/tabs/gf_tabbar.dart b/lib/components/tabs/gf_tabbar.dart index 24b22655..1e856bd0 100644 --- a/lib/components/tabs/gf_tabbar.dart +++ b/lib/components/tabs/gf_tabbar.dart @@ -9,15 +9,13 @@ import 'package:flutter/foundation.dart'; /// /// Typically created as the [AppBar.bottom] part of an [AppBar] and in /// conjunction with a [TabBarView]. - class GFTabBar extends StatefulWidget { /// Creates a material design tab bar. - /// /// The [tabs] argument must not be null and its length must match the [controller]'s /// [TabController.length]. const GFTabBar({ Key key, -// this.initialIndex = 0, + // this.initialIndex = 0, @required this.length, this.isScrollable = false, this.tabBarHeight, @@ -37,13 +35,13 @@ class GFTabBar extends StatefulWidget { this.shape, }) : assert(length != null && length >= 0), assert(isScrollable != null), -// assert(initialIndex != null && -// initialIndex >= 0 && -// (length == 0 || initialIndex < length)), + // assert(initialIndex != null && + // initialIndex >= 0 && + // (length == 0 || initialIndex < length)), super(key: key); -// /// The initial index of the selected tab. Defaults to zero. -// final int initialIndex; + // /// The initial index of the selected tab. Defaults to zero. + // final int initialIndex; /// The total number of tabs. Typically greater than one. Must match [TabBar.tabs]'s and /// [TabBarView.children]'s length. diff --git a/lib/components/tabs/gf_tabbar_view.dart b/lib/components/tabs/gf_tabbar_view.dart index b09ae692..a4e6959c 100644 --- a/lib/components/tabs/gf_tabbar_view.dart +++ b/lib/components/tabs/gf_tabbar_view.dart @@ -5,14 +5,10 @@ import 'package:flutter/widgets.dart'; import 'package:flutter/gestures.dart' show DragStartBehavior; import 'package:getwidget/getwidget.dart'; -/// A page view that displays the widget which corresponds to the currently -/// selected tab. -/// +/// A page view that displays the widget which corresponds to the currently selected tab. /// This widget is typically used in conjunction with a [GFTabBar] or [GFSegmentTabs]. -/// class GFTabBarView extends StatefulWidget { /// Creates a page view with one child per tab. - /// /// The length of [children] must be the same as the [controller]'s length. const GFTabBarView({ Key key, @@ -29,19 +25,15 @@ class GFTabBarView extends StatefulWidget { final TabController controller; /// One widget per tab. - /// /// Its length must match the length of the [GFTabBar.tabs] /// list, as well as the [controller]'s [TabController.length]. final List children; /// How the page view should respond to user input. - /// /// For example, determines how the page view continues to animate after the /// user stops dragging the page view. - /// /// The physics are modified to snap to page boundaries using /// [PageScrollPhysics] prior to being used. - /// /// Defaults to matching platform conventions. final ScrollPhysics physics; @@ -84,7 +76,6 @@ class _GFTabBarViewState extends State { } return true; }()); - if (newController == _controller) { return; } @@ -141,7 +132,6 @@ class _GFTabBarViewState extends State { if (_warpUnderwayCount > 0 || !_controller.indexIsChanging) { return; } // This widget is driving the controller's animation. - if (_controller.index != _currentIndex) { _currentIndex = _controller.index; _warpToCurrentIndex(); diff --git a/lib/components/toast/gf_toast.dart b/lib/components/toast/gf_toast.dart index cb53d23e..94a3db0c 100644 --- a/lib/components/toast/gf_toast.dart +++ b/lib/components/toast/gf_toast.dart @@ -110,7 +110,6 @@ class _GFToastState extends State with TickerProviderStateMixin { void dispose() { animationController.dispose(); fadeanimationController.dispose(); - super.dispose(); } @@ -171,5 +170,6 @@ class _GFToastState extends State with TickerProviderStateMixin { ), ), ], - )); + ), + ); } diff --git a/lib/getwidget.dart b/lib/getwidget.dart index 23926ca7..187db20c 100644 --- a/lib/getwidget.dart +++ b/lib/getwidget.dart @@ -46,7 +46,7 @@ export 'package:getwidget/components/toast/gf_toast.dart'; export 'package:getwidget/components/toggle/gf_toggle.dart'; export 'package:getwidget/components/typography/gf_typography.dart'; export 'package:getwidget/components/dropdown/gf_dropdown.dart'; -export 'package:getwidget/components/dropdown/multilevel.dart'; +export 'package:getwidget/components/dropdown/gf_multiselect.dart'; export 'colors/gf_color.dart'; export 'direction/gf_shimmer_direction.dart'; From 61d56ff7cd87252f05c2515fc2594e994a37a2b1 Mon Sep 17 00:00:00 2001 From: Sandip Kakadiya Date: Fri, 2 Oct 2020 17:40:49 +0530 Subject: [PATCH 07/25] changelog added --- CHANGELOG.md | 23 ++++++++++++++++++++++- lib/getwidget.dart | 4 ++-- lib/position/gf_position.dart | 2 +- lib/types/gf_border_type.dart | 7 ++++++- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f840b0c..7dbc7101 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,26 @@ # Changelog + +## 1.2.1 - 2020-10-02 + +### Fixed +* [GFButton] width related issue. +* [GFRadio] minor issue. +* [GFRadioListTile] selection issue +* [GFCheckbox] minor issue. +* [GFCheckboxListTile] selection issue +* Many more minor improvements. + +### Added +* few new compoenents added + - GFBottomSheet + - GFIntroScreen + - GFAnimation + - GFBorder + - GFStickyHeader + + + ## 1.1.3 - 2020-07-30 ### Fixed @@ -9,7 +30,7 @@ * [GFCarousel] active page indicator is not being updated without "onPageChanged" #139 * [GFTabBar] Docs say about isScrollable which is not supported #132 -### Update +### Added * couple of compoenents (WIP) - GFCheckboxTile - GFRadioTile diff --git a/lib/getwidget.dart b/lib/getwidget.dart index 187db20c..d83c29c3 100644 --- a/lib/getwidget.dart +++ b/lib/getwidget.dart @@ -45,8 +45,8 @@ export 'package:getwidget/components/tabs/gf_tabs.dart'; export 'package:getwidget/components/toast/gf_toast.dart'; export 'package:getwidget/components/toggle/gf_toggle.dart'; export 'package:getwidget/components/typography/gf_typography.dart'; -export 'package:getwidget/components/dropdown/gf_dropdown.dart'; -export 'package:getwidget/components/dropdown/gf_multiselect.dart'; +// export 'package:getwidget/components/dropdown/gf_dropdown.dart'; +// export 'package:getwidget/components/dropdown/gf_multiselect.dart'; export 'colors/gf_color.dart'; export 'direction/gf_shimmer_direction.dart'; diff --git a/lib/position/gf_position.dart b/lib/position/gf_position.dart index 43a249ce..c9f0857f 100644 --- a/lib/position/gf_position.dart +++ b/lib/position/gf_position.dart @@ -5,5 +5,5 @@ enum GFPosition { start, /// [GFPosition.end] is used to place icon, badges to end of the GFButton and GFButtonBadge - end + end, } diff --git a/lib/types/gf_border_type.dart b/lib/types/gf_border_type.dart index 8eb24181..42fb56cc 100644 --- a/lib/types/gf_border_type.dart +++ b/lib/types/gf_border_type.dart @@ -1 +1,6 @@ -enum GFBorderType { circle, rRect, rect, oval } +enum GFBorderType { + circle, + rRect, + rect, + oval, +} From 3196e0433651b51c9edf67663526a075e8714b7a Mon Sep 17 00:00:00 2001 From: Sandip Kakadiya Date: Fri, 2 Oct 2020 18:39:27 +0530 Subject: [PATCH 08/25] code formated , changelog added, version updated --- CHANGELOG.md | 2 +- example/pubspec.lock | 40 +++++++++---------- lib/components/button/gf_button.dart | 8 +++- lib/components/button/gf_icon_button.dart | 16 ++++++-- lib/components/card/gf_card.dart | 4 +- lib/components/carousel/gf_carousel.dart | 4 +- .../sticky_header/gf_sticky_header.dart | 1 - lib/getwidget.dart | 4 +- pubspec.lock | 38 +++++++++--------- pubspec.yaml | 2 +- 10 files changed, 67 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dbc7101..d7e1efb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog -## 1.2.1 - 2020-10-02 +## 1.2.2 - 2020-10-02 ### Fixed * [GFButton] width related issue. diff --git a/example/pubspec.lock b/example/pubspec.lock index 975a5d1b..10b10812 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,42 +7,42 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.2" + version: "2.5.0-nullsafety.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.0-nullsafety.3" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" + version: "1.2.0-nullsafety.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.1.0-nullsafety.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.13" + version: "1.15.0-nullsafety.3" convert: dependency: transitive description: @@ -63,7 +63,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0-nullsafety.1" flutter: dependency: "direct main" description: flutter @@ -92,28 +92,28 @@ packages: path: ".." relative: true source: path - version: "1.1.3" + version: "1.2.2" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.8" + version: "0.12.10-nullsafety.1" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0-nullsafety.3" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0-nullsafety.1" path_drawing: dependency: transitive description: @@ -167,49 +167,49 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0-nullsafety.2" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.5" + version: "1.10.0-nullsafety.1" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0-nullsafety.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0-nullsafety.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.17" + version: "0.2.19-nullsafety.2" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0-nullsafety.3" url_launcher: dependency: "direct main" description: @@ -251,7 +251,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0-nullsafety.3" xml: dependency: transitive description: @@ -260,5 +260,5 @@ packages: source: hosted version: "4.2.0" sdks: - dart: ">=2.9.0-14.0.dev <3.0.0" + dart: ">=2.10.0-110 <2.11.0" flutter: ">=1.18.0-6.0.pre <2.0.0" diff --git a/lib/components/button/gf_button.dart b/lib/components/button/gf_button.dart index 59ddf44b..df810c6d 100644 --- a/lib/components/button/gf_button.dart +++ b/lib/components/button/gf_button.dart @@ -420,7 +420,9 @@ class _GFButtonState extends State { widget.type == GFButtonType.transparent) { return widget.enabled ? textColor == null - ? color == GFColors.TRANSPARENT ? GFColors.DARK : color + ? color == GFColors.TRANSPARENT + ? GFColors.DARK + : color : textColor : getDisabledTextColor(); } @@ -446,7 +448,9 @@ class _GFButtonState extends State { ? getBorderColor() : widget.borderSide.color, width: widget.borderSide?.width == null - ? widget.type == GFButtonType.outline2x ? 2.0 : 1.0 + ? widget.type == GFButtonType.outline2x + ? 2.0 + : 1.0 : widget.borderSide?.width, ); diff --git a/lib/components/button/gf_icon_button.dart b/lib/components/button/gf_icon_button.dart index 356aabac..93acc6fa 100644 --- a/lib/components/button/gf_icon_button.dart +++ b/lib/components/button/gf_icon_button.dart @@ -162,7 +162,9 @@ class _GFIconButtonState extends State { widget.type == GFButtonType.outline || widget.type == GFButtonType.outline2x) { return widget.onPressed != null - ? color == GFColors.TRANSPARENT ? GFColors.DARK : color + ? color == GFColors.TRANSPARENT + ? GFColors.DARK + : color : color.withOpacity(0.48); } else if (color == GFColors.TRANSPARENT) { return widget.onPressed != null ? GFColors.DARK : GFColors.WHITE; @@ -182,7 +184,9 @@ class _GFIconButtonState extends State { ? getBorderColor() : widget.borderSide.color, width: widget.borderSide?.width == null - ? widget.type == GFButtonType.outline2x ? 2.0 : 1.0 + ? widget.type == GFButtonType.outline2x + ? 2.0 + : 1.0 : widget.borderSide?.width, ); @@ -241,7 +245,9 @@ class _GFIconButtonState extends State { height: widget.shape == GFIconButtonShape.circle ? height + 6.0 : height, width: widget.shape == GFIconButtonShape.pills ? width + 10 - : widget.shape == GFIconButtonShape.circle ? height + 6 : width, + : widget.shape == GFIconButtonShape.circle + ? height + 6 + : width, padding: widget.padding, child: IconTheme.merge( data: IconThemeData( @@ -309,7 +315,9 @@ class _GFIconButtonState extends State { widget.shape == GFIconButtonShape.circle ? height + 6 : height, width: widget.shape == GFIconButtonShape.pills ? width + 10 - : widget.shape == GFIconButtonShape.circle ? height + 6 : width, + : widget.shape == GFIconButtonShape.circle + ? height + 6 + : width, decoration: widget.type == GFButtonType.solid ? getBoxShadow() : null, child: Material( diff --git a/lib/components/card/gf_card.dart b/lib/components/card/gf_card.dart index 9c5959b9..dfadce1c 100644 --- a/lib/components/card/gf_card.dart +++ b/lib/components/card/gf_card.dart @@ -176,7 +176,9 @@ class GFCard extends StatelessWidget { _defaultClipBehavior, child: imageOverlay == null ? cardChild : overlayImage, ) - : imageOverlay == null ? cardChild : overlayImage, + : imageOverlay == null + ? cardChild + : overlayImage, ); } } diff --git a/lib/components/carousel/gf_carousel.dart b/lib/components/carousel/gf_carousel.dart index 3c8dbd46..4718e4ca 100644 --- a/lib/components/carousel/gf_carousel.dart +++ b/lib/components/carousel/gf_carousel.dart @@ -234,7 +234,9 @@ class _GFCarouselState extends State with TickerProviderStateMixin { reverse: widget.reverse, itemCount: widget.items.length == 1 ? widget.items.length - : widget.enableInfiniteScroll ? null : widget.items.length, + : widget.enableInfiniteScroll + ? null + : widget.items.length, onPageChanged: (int index) { int currentPage; currentPage = _getRealIndex(index + widget.initialPage, diff --git a/lib/components/sticky_header/gf_sticky_header.dart b/lib/components/sticky_header/gf_sticky_header.dart index 1f037244..e0bbb6ad 100644 --- a/lib/components/sticky_header/gf_sticky_header.dart +++ b/lib/components/sticky_header/gf_sticky_header.dart @@ -2,7 +2,6 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; -import 'package:meta/meta.dart'; import 'package:getwidget/getwidget.dart'; class GFStickyHeader extends MultiChildRenderObjectWidget { diff --git a/lib/getwidget.dart b/lib/getwidget.dart index d83c29c3..bd0a7242 100644 --- a/lib/getwidget.dart +++ b/lib/getwidget.dart @@ -22,6 +22,8 @@ export 'package:getwidget/components/checkbox/gf_checkbox.dart'; export 'package:getwidget/components/checkbox_list_tile/gf_checkbox_list_tile.dart'; export 'package:getwidget/components/drawer/gf_drawer.dart'; export 'package:getwidget/components/drawer/gf_drawer_header.dart'; +// export 'package:getwidget/components/dropdown/gf_dropdown.dart'; +// export 'package:getwidget/components/dropdown/gf_multiselect.dart'; export 'package:getwidget/components/floating_widget/gf_floating_widget.dart'; export 'package:getwidget/components/image/gf_image_overlay.dart'; export 'package:getwidget/components/intro_screen/gf_intro_screen_bottom_navigation_bar.dart'; @@ -45,8 +47,6 @@ export 'package:getwidget/components/tabs/gf_tabs.dart'; export 'package:getwidget/components/toast/gf_toast.dart'; export 'package:getwidget/components/toggle/gf_toggle.dart'; export 'package:getwidget/components/typography/gf_typography.dart'; -// export 'package:getwidget/components/dropdown/gf_dropdown.dart'; -// export 'package:getwidget/components/dropdown/gf_multiselect.dart'; export 'colors/gf_color.dart'; export 'direction/gf_shimmer_direction.dart'; diff --git a/pubspec.lock b/pubspec.lock index 9477cdd7..b308ac32 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,49 +7,49 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.2" + version: "2.5.0-nullsafety.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.0-nullsafety.3" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" + version: "1.2.0-nullsafety.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.1.0-nullsafety.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.13" + version: "1.15.0-nullsafety.3" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0-nullsafety.1" flutter: dependency: "direct main" description: flutter @@ -66,21 +66,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.8" + version: "0.12.10-nullsafety.1" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0-nullsafety.3" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0-nullsafety.1" sky_engine: dependency: transitive description: flutter @@ -92,55 +92,55 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0-nullsafety.2" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.5" + version: "1.10.0-nullsafety.1" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0-nullsafety.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0-nullsafety.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.17" + version: "0.2.19-nullsafety.2" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0-nullsafety.3" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0-nullsafety.3" sdks: - dart: ">=2.9.0-14.0.dev <3.0.0" + dart: ">=2.10.0-110 <2.11.0" diff --git a/pubspec.yaml b/pubspec.yaml index a0a56314..43a330e6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: getwidget description: GetWidget is open source libraries that come with pre-build 1000+ UI components. It makes development faster & more enjoyable. You can customize the component as per your need. -version: 1.1.3 +version: 1.2.2 homepage: https://github.com/ionicfirebaseapp/getwidget environment: From 45c6777e93163300f55aed7a27592b08a5cdcdcc Mon Sep 17 00:00:00 2001 From: deepikahr Date: Mon, 5 Oct 2020 21:09:56 +0530 Subject: [PATCH 09/25] GFProgressBar issue fixed --- example/lib/main_temp.dart | 211 ++++++++++++++++++ .../progress_bar/gf_progress_bar.dart | 7 +- 2 files changed, 215 insertions(+), 3 deletions(-) create mode 100644 example/lib/main_temp.dart diff --git a/example/lib/main_temp.dart b/example/lib/main_temp.dart new file mode 100644 index 00000000..058ea210 --- /dev/null +++ b/example/lib/main_temp.dart @@ -0,0 +1,211 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:getwidget/getwidget.dart'; + +final List imageList = [ + 'https://cdn.pixabay.com/photo/2017/12/03/18/04/christmas-balls-2995437_960_720.jpg', + 'https://cdn.pixabay.com/photo/2017/12/13/00/23/christmas-3015776_960_720.jpg', + 'https://cdn.pixabay.com/photo/2019/12/19/10/55/christmas-market-4705877_960_720.jpg', + 'https://cdn.pixabay.com/photo/2019/12/20/00/03/road-4707345_960_720.jpg', + 'https://cdn.pixabay.com/photo/2019/12/22/04/18/x-mas-4711785__340.jpg', + 'https://cdn.pixabay.com/photo/2016/11/22/07/09/spruce-1848543__340.jpg', + 'https://cdn.pixabay.com/photo/2017/12/03/18/04/christmas-balls-2995437_960_720.jpg', + 'https://cdn.pixabay.com/photo/2017/12/13/00/23/christmas-3015776_960_720.jpg', +]; + +void main() => runApp(MyApp()); + +class MyApp extends StatelessWidget { + @override + Widget build(BuildContext context) => MaterialApp( + title: 'GetWidget Example', + theme: ThemeData( + primarySwatch: Colors.blue, + ), + debugShowCheckedModeBanner: false, + home: BottomSheetPage(), + ); +} + +// Yashraj$07 + +class BottomSheetPage extends StatefulWidget { + @override + _BottomSheetPageState createState() => _BottomSheetPageState(); +} + +class _BottomSheetPageState extends State { + final GFBottomSheetController _controller = GFBottomSheetController(); + bool isSelected = false; + @override + Widget build(BuildContext context) => Scaffold( + body:GFTabs( + initialIndex: 4, + isScrollable: true, + length: 8, + tabs: [ + Tab( + icon: Icon(Icons.directions_bike), + child: Text( + "Tab1", + ), + ), + Tab( + icon: Icon(Icons.directions_bus), + child: Text( + "Tab2", + ), + ), + Tab( + icon: Icon(Icons.directions_railway), + child: Text( + "Tab3", + ), + ), + Tab( + icon: Icon(Icons.directions_bike), + child: Text( + "Tab4", + ), + ), + Tab( + icon: Icon(Icons.directions_bus), + child: Text( + "Tab5", + ), + ), + Tab( + icon: Icon(Icons.directions_railway), + child: Text( + "Tab6", + ), + ), + Tab( + icon: Icon(Icons.directions_bike), + child: Text( + "Tab66", + ), + ), + Tab( + icon: Icon(Icons.directions_bike), + child: Text( + "Tab666", + ), + ), + ], + tabBarView: GFTabBarView( + children: [ + Container(child: Icon(Icons.directions_bike), color: Colors.red,), + Container(child: Icon(Icons.directions_bus), color: Colors.blue,), + Container(child: Icon(Icons.directions_railway), color: Colors.orange,), + Container(child: Icon(Icons.directions_bike), color: Colors.red,), + Container(child: Icon(Icons.directions_bus), color: Colors.blue,), + Container(child: Icon(Icons.directions_railway), color: Colors.orange,), + Container(child: Icon(Icons.directions_bus), color: Colors.blue,), + Container(child: Icon(Icons.directions_railway), color: Colors.orange,), + ], + ), + ), + bottomSheet: GFBottomSheet( + controller: _controller, + maxContentHeight: 300, + // minContentHeight: 200, + enableExpandableContent: true, + stickyHeaderHeight: 70, + stickyHeader: const GFListTile( + padding: EdgeInsets.zero, + avatar: GFAvatar( + // backgroundImage: AssetImage('lib/assets/images/img.png'), + ), + titleText: 'Eva Mendez', + subtitleText: '11 minutes ago', + ), + contentBody: Container( + margin: EdgeInsets.symmetric(horizontal: 15, vertical: 10), + child: ListView( + shrinkWrap: true, + physics: const ScrollPhysics(), + children: [ + // Container( + // margin: EdgeInsets.symmetric(horizontal: 10), + // height: 60, + // padding: EdgeInsets.only(bottom: 15), + // child: TextFormField( + // + // initialValue: "Enter Message", + // keyboardType: TextInputType.emailAddress, + // decoration: InputDecoration( + // + // errorBorder: OutlineInputBorder( + // borderSide: BorderSide( + // width: 0, color: Color(0xFFF44242))), + // errorStyle: TextStyle(color: Color(0xFFF44242)), + // contentPadding: EdgeInsets.all(10), + // enabledBorder: const OutlineInputBorder( + // borderSide: const BorderSide(color: Colors.grey, width: 0.0), + // ), + // + // focusedBorder: OutlineInputBorder( + // borderSide: BorderSide(color: Colors.grey), + // ), + // fillColor: Colors.white, + // focusColor: Colors.white), + // ), + // ), + Container( + child: Row( + children: [ + Container( + width: 30, + height: 30, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(50), + image: DecorationImage( + image: AssetImage('assets/images/pixa.jpg'))), + ), + Container( + margin: EdgeInsets.only(left: 6), + child: Text( + 'Add to your story', + style: TextStyle(color: Colors.blue), + )) + ], + ), + ), + ListView.builder( + physics: ScrollPhysics(), + shrinkWrap: true, + scrollDirection: Axis.vertical, + itemCount: 3, + itemBuilder: (BuildContext context, int index) { + return SingleChildScrollView( + child: InkWell( + child: GFListTile( + avatar: GFAvatar( + backgroundImage: + AssetImage('assets/images/pixa.jpg'), + size: 20, + ), + subtitleText: 'John Mendez', + icon: Container( + width: 66, + height: 30, + child: GFButton( + onPressed: () {}, + color: GFColors.PRIMARY, + child: Center( + child: Text( + 'Send', + style: TextStyle(color: Colors.white), + )), + ), + ), + ), + )); + }), + ], + ), + ), + ), + ); +} diff --git a/lib/components/progress_bar/gf_progress_bar.dart b/lib/components/progress_bar/gf_progress_bar.dart index 3b2c09fd..a20f9106 100644 --- a/lib/components/progress_bar/gf_progress_bar.dart +++ b/lib/components/progress_bar/gf_progress_bar.dart @@ -125,6 +125,7 @@ class _GFProgressBarState extends State double _progressPercent = 0; double _percentage = 0; + @override void initState() { super.initState(); @@ -133,10 +134,10 @@ class _GFProgressBarState extends State duration: Duration(milliseconds: widget.animationDuration), vsync: this); _animation = - Tween(begin: 0, end: widget.percentage).animate(_animationController) + Tween(begin: _progressPercent, end: widget.percentage).animate(_animationController) ..addListener(() { setState(() { - _progressPercent = _animation.value; + _progressPercent = _animation.value; }); }); _animationController.forward(); @@ -148,7 +149,7 @@ class _GFProgressBarState extends State circularAnimationController = AnimationController( duration: Duration(milliseconds: widget.animationDuration), vsync: this); - circularAnimation = Tween(begin: 0, end: widget.percentage) + circularAnimation = Tween(begin: _percentage, end: widget.percentage) .animate(circularAnimationController) ..addListener(() { setState(() { From b3fb1831e01a7da35738c31e95890ff14c0ed811 Mon Sep 17 00:00:00 2001 From: deepikahr Date: Thu, 8 Oct 2020 15:12:20 +0530 Subject: [PATCH 10/25] state changes in gf bottomsheet --- example/lib/main_temp.dart | 317 ++++++++++++++---- .../bottom_sheet/gf_bottom_sheet.dart | 65 ++-- .../gf_checkbox_list_tile.dart | 2 +- .../floating_widget/gf_floating_widget.dart | 187 +++++++++-- lib/components/list_tile/gf_list_tile.dart | 2 +- .../radio_list_tile/gf_radio_list_tile.dart | 2 +- lib/components/toast/gf_toast.dart | 106 +++--- 7 files changed, 506 insertions(+), 175 deletions(-) diff --git a/example/lib/main_temp.dart b/example/lib/main_temp.dart index 058ea210..cc9ad214 100644 --- a/example/lib/main_temp.dart +++ b/example/lib/main_temp.dart @@ -1,6 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:getwidget/getwidget.dart'; +import 'dart:async'; final List imageList = [ 'https://cdn.pixabay.com/photo/2017/12/03/18/04/christmas-balls-2995437_960_720.jpg', @@ -37,72 +38,276 @@ class BottomSheetPage extends StatefulWidget { class _BottomSheetPageState extends State { final GFBottomSheetController _controller = GFBottomSheetController(); bool isSelected = false; + + bool showFloatingToast = false; + Timer autoTimer; + bool showBlurness = true; + Duration autoTimerDuration = Duration(milliseconds: 400); + + bool check = true; + int groupValue = 0; + + List list = [ + 'Flutter', + 'React', + 'Ionic', + 'Xamarin', + 'Flutter2', + 'React2', + 'Ionic2', + 'Xamarin2', + ]; + @override Widget build(BuildContext context) => Scaffold( - body:GFTabs( - initialIndex: 4, - isScrollable: true, - length: 8, - tabs: [ - Tab( - icon: Icon(Icons.directions_bike), - child: Text( - "Tab1", - ), + appBar: GFAppBar( + title: Text('GF Toasting'), + ), + body: GFFloatingWidget( + verticalPosition: MediaQuery.of(context).size.width * 0.5, + horizontalPosition: MediaQuery.of(context).size.height * 0.02, + showBlurness: showFloatingToast, + blurnessColor: Colors.black87, + child: showFloatingToast + ? GFToast( + backgroundColor: Colors.white, + text: + 'You have succesfully viewed how the floating toast works!!', + textStyle: const TextStyle(color: Colors.black87), + button: GFButton( + onPressed: () { + setState(() { + showFloatingToast = false; + }); + }, + text: 'OK', + type: GFButtonType.transparent, + color: GFColors.SUCCESS, ), - Tab( - icon: Icon(Icons.directions_bus), - child: Text( - "Tab2", + autoDismiss: false, + ) + : Container(), + body: ListView( + physics: const ScrollPhysics(), + children: [ + GFSearchBar( + searchList: list, + searchQueryBuilder: (query, list) => list + .where((item) => + item.toLowerCase().contains(query.toLowerCase())) + .toList(), + overlaySearchListItemBuilder: (item) => Container( + padding: const EdgeInsets.all(8), + child: Text( + item, + style: const TextStyle(fontSize: 18), + ), + ), + onItemSelected: (item) { + setState(() { + print('$item'); + }); + }), + const Padding( + padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), + child: GFTypography( + text: 'Customised SearchBar', + type: GFTypographyType.typo5, + dividerWidth: 25, + dividerColor: Color(0xFF19CA4B), + ), ), - ), - Tab( - icon: Icon(Icons.directions_railway), - child: Text( - "Tab3", + GFSearchBar( + searchBoxInputDecoration: InputDecoration( + labelText: 'Type Here', + labelStyle: const TextStyle(color: Colors.black26), + focusedBorder: OutlineInputBorder( + borderSide: const BorderSide(color: Colors.greenAccent), + borderRadius: BorderRadius.circular(25), + ), + prefixIcon: Icon( + Icons.search, + color: Colors.black26, + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.black12), + borderRadius: BorderRadius.circular(50)), + ), + searchList: list, + searchQueryBuilder: (query, list) => list + .where((item) => + item.toLowerCase().contains(query.toLowerCase())) + .toList(), + overlaySearchListItemBuilder: (item) => Container( + padding: const EdgeInsets.all(8), + child: Text( + item, + style: const TextStyle(fontSize: 18), + ), + ), + onItemSelected: (item) { + setState(() { + print('$item'); + }); + }), + const Padding( + padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), + child: GFTypography( + text: 'Animated Toasts (Auto Dismissable)', + type: GFTypographyType.typo5, + dividerWidth: 25, + dividerColor: Color(0xFF19CA4B), + ), ), - ), - Tab( - icon: Icon(Icons.directions_bike), - child: Text( - "Tab4", + GFToast( + text: 'Auto Dismissable after the given duration !', + button: GFButton( + onPressed: () {}, + text: 'OK', + type: GFButtonType.transparent, + color: GFColors.SUCCESS, + ), + autoDismiss: true, + duration: const Duration(seconds: 5), ), - ), - Tab( - icon: Icon(Icons.directions_bus), - child: Text( - "Tab5", + const SizedBox( + height: 15, ), - ), - Tab( - icon: Icon(Icons.directions_railway), - child: Text( - "Tab6", + const GFToast( + text: 'Pass true to autoDismiss property to use this effect!', + autoDismiss: true, + duration: Duration(seconds: 2), ), - ), - Tab( - icon: Icon(Icons.directions_bike), - child: Text( - "Tab66", + const Padding( + padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), + child: GFTypography( + text: 'Basic Toasts', + type: GFTypographyType.typo5, + dividerWidth: 25, + dividerColor: Color(0xFF19CA4B), + ), ), - ), - Tab( - icon: Icon(Icons.directions_bike), - child: Text( - "Tab666", + GFToast( + text: 'Paired Succesfully !', + button: GFButton( + onPressed: () {}, + text: 'OK', + type: GFButtonType.transparent, + color: GFColors.SUCCESS, + ), + autoDismiss: false, + duration: const Duration(milliseconds: 300), + alignment: Alignment.topLeft, + ), + const SizedBox( + height: 15, + ), + GFToast( + text: + 'This item already has the label “travel”. You can add new label. !', + button: GFButton( + onPressed: () {}, + text: 'OK', + type: GFButtonType.transparent, + color: GFColors.SUCCESS, + ), + autoDismiss: false, + ), + const Padding( + padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), + child: GFTypography( + text: 'Rounded Toasts', + type: GFTypographyType.typo5, + dividerWidth: 25, + dividerColor: Color(0xFF19CA4B), + ), + ), + GFToast( + text: 'Paired Succesfully !', + button: GFButton( + onPressed: () {}, + text: 'OK', + type: GFButtonType.transparent, + color: GFColors.SUCCESS, + ), + type: GFToastType.rounded, + autoDismiss: false, + alignment: Alignment.topLeft, + ), + const SizedBox( + height: 15, + ), + GFToast( + text: + 'This item already has the label “travel”. You can add a new label. !', + button: GFButton( + onPressed: () {}, + text: 'OK', + type: GFButtonType.transparent, + color: GFColors.SUCCESS, + ), + autoDismiss: false, + type: GFToastType.rounded, + alignment: Alignment.topLeft, + ), + const Padding( + padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), + child: GFTypography( + text: 'Full Width Toasts', + type: GFTypographyType.typo5, + dividerWidth: 25, + dividerColor: Color(0xFF19CA4B), + ), + ), + GFToast( + text: 'Paired Succesfully !', + button: GFButton( + onPressed: () {}, + text: 'OK', + type: GFButtonType.transparent, + color: GFColors.SUCCESS, + ), + type: GFToastType.fullWidth, + autoDismiss: false, + ), + const SizedBox( + height: 15, + ), + GFToast( + text: + 'This item already has the label “travel”. You can add a new label.!', + button: GFButton( + onPressed: () {}, + text: 'OK', + type: GFButtonType.transparent, + color: GFColors.SUCCESS, + ), + autoDismiss: false, + type: GFToastType.fullWidth, + ), + const Padding( + padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), + child: GFTypography( + text: 'Floating Toast', + type: GFTypographyType.typo5, + dividerWidth: 25, + dividerColor: Color(0xFF19CA4B), + ), + ), + Container( + margin: const EdgeInsets.only(left: 40, right: 40), + child: GFButton( + onPressed: () { + setState(() { + showFloatingToast = !showFloatingToast; + }); + }, + text: 'View Floating Toast', + ), + ), + const SizedBox( + height: 20, ), - ), - ], - tabBarView: GFTabBarView( - children: [ - Container(child: Icon(Icons.directions_bike), color: Colors.red,), - Container(child: Icon(Icons.directions_bus), color: Colors.blue,), - Container(child: Icon(Icons.directions_railway), color: Colors.orange,), - Container(child: Icon(Icons.directions_bike), color: Colors.red,), - Container(child: Icon(Icons.directions_bus), color: Colors.blue,), - Container(child: Icon(Icons.directions_railway), color: Colors.orange,), - Container(child: Icon(Icons.directions_bus), color: Colors.blue,), - Container(child: Icon(Icons.directions_railway), color: Colors.orange,), ], ), ), diff --git a/lib/components/bottom_sheet/gf_bottom_sheet.dart b/lib/components/bottom_sheet/gf_bottom_sheet.dart index ad9ddf60..0af334c1 100644 --- a/lib/components/bottom_sheet/gf_bottom_sheet.dart +++ b/lib/components/bottom_sheet/gf_bottom_sheet.dart @@ -14,7 +14,7 @@ class GFBottomSheet extends StatefulWidget { this.elevation = 0.0, this.stickyFooterHeight = 0.0, this.stickyHeaderHeight = 0.0, - this.animationDuration = 300, + this.animationDuration = 1200, this.enableExpandableContent = false, }) : assert(elevation >= 0.0), assert(minContentHeight >= 0.0), @@ -71,7 +71,8 @@ class GFBottomSheet extends StatefulWidget { class _GFBottomSheetState extends State with TickerProviderStateMixin { - final StreamController controller = StreamController.broadcast(); + final StreamController _streamController = + StreamController.broadcast(); bool isDragDirectionUp; bool showBottomSheet = false; Function _controllerListener; @@ -152,34 +153,38 @@ class _GFBottomSheetState extends State child: widget.contentBody), ), ) - : showContent - ? StreamBuilder( - stream: controller.stream, - initialData: widget.controller.height, - builder: (context, snapshot) => GestureDetector( - onVerticalDragUpdate: (DragUpdateDetails details) { - if (((widget.controller.height - details.delta.dy) > - widget.minContentHeight) && - ((widget.controller.height - details.delta.dy) < - (MediaQuery.of(context).size.height * 0.8 - - widget.stickyFooterHeight - - widget.stickyHeaderHeight))) { - isDragDirectionUp = details.delta.dy <= 0; - widget.controller.height -= details.delta.dy; - } - controller.add(widget.controller.height); - }, - onVerticalDragEnd: _onVerticalDragEnd, - onTap: _onTap, - behavior: HitTestBehavior.translucent, - child: Container( - height: snapshot.hasData == null - ? widget.minContentHeight - : snapshot.data, - child: widget.contentBody, - )), - ) - : Container(), + : widget.controller.height == widget.minContentHeight ? Container() + : StreamBuilder( + stream: _streamController.stream, + initialData: widget.controller.height, + builder: (BuildContext context, AsyncSnapshot snapshot) => + AnimatedContainer( + curve: Curves.easeOut, + duration: Duration( + milliseconds: widget.controller.animationDuration), + height: snapshot.hasData == null + ? widget.minContentHeight + : snapshot.data, + child: GestureDetector( + onVerticalDragUpdate: (DragUpdateDetails details) { + if (((widget.controller.height - details.delta.dy) > + widget.minContentHeight) && + ((widget.controller.height - details.delta.dy) < + (MediaQuery.of(context).size.height * 0.8 - + widget.stickyFooterHeight - + widget.stickyHeaderHeight))) { + isDragDirectionUp = details.delta.dy <= 0; + widget.controller.height -= details.delta.dy; + } + _streamController.add(widget.controller.height); + }, + onVerticalDragEnd: _onVerticalDragEnd, + onTap: _onTap, + behavior: HitTestBehavior.translucent, + child: widget.contentBody, + ), + ), + ), widget.stickyFooter == null ? Container() : AnimatedBuilder( diff --git a/lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart b/lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart index fda47044..35142631 100644 --- a/lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart +++ b/lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart @@ -16,7 +16,7 @@ class GFCheckboxListTile extends StatelessWidget { this.icon, this.description, this.padding = const EdgeInsets.all(8), - this.margin = const EdgeInsets.all(16), + this.margin = const EdgeInsets.symmetric(vertical: 8, horizontal: 16), this.size = GFSize.MEDIUM, this.type = GFCheckboxType.basic, this.checkColor = GFColors.WHITE, diff --git a/lib/components/floating_widget/gf_floating_widget.dart b/lib/components/floating_widget/gf_floating_widget.dart index 9d0d55b6..7ff6a0a3 100644 --- a/lib/components/floating_widget/gf_floating_widget.dart +++ b/lib/components/floating_widget/gf_floating_widget.dart @@ -6,12 +6,12 @@ class GFFloatingWidget extends StatefulWidget { /// Inside floating widget [GFToast] can be used as body. See [GFToast] const GFFloatingWidget( {Key key, - this.child, - this.horizontalPosition, - this.verticalPosition, - this.blurnessColor, - this.showblurness = false, - this.body}) + this.child, + this.horizontalPosition, + this.verticalPosition, + this.blurnessColor, + this.showBlurness = false, + this.body}) : super(key: key); ///child of type [Widget] which floats across the body based on horizontal and vertical position @@ -30,7 +30,7 @@ class GFFloatingWidget extends StatefulWidget { final Color blurnessColor; ///type of bool which allows to show or hide the blurness of the backgroundColor whenever the [child] is used in [GFFloatingWidget] - final bool showblurness; + final bool showBlurness; @override _GFFloatingWidgetState createState() => _GFFloatingWidgetState(); @@ -53,31 +53,152 @@ class _GFFloatingWidgetState extends State { @override Widget build(BuildContext context) => Stack( - alignment: Alignment.center, - fit: StackFit.loose, - children: [ - Container( - height: MediaQuery.of(context).size.height, - child: widget.body ?? Container(), + alignment: Alignment.center, + fit: StackFit.loose, + children: [ + Container( + height: MediaQuery.of(context).size.height, + child: widget.body ?? Container(), + ), + Positioned( + child: Container( + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + color: widget.showBlurness + ? widget.blurnessColor ?? Colors.black54 + : null, + child: Stack( + children: [ + Positioned( + top: widget.verticalPosition ?? 0.0, + left: widget.horizontalPosition ?? 0.0, + child: widget.child ?? Container(), + ) + ], ), - Positioned( - child: Container( - height: MediaQuery.of(context).size.height, - width: MediaQuery.of(context).size.width, - color: widget.showblurness - ? widget.blurnessColor ?? Colors.black54 - : null, - child: Stack( - children: [ - Positioned( - top: widget.verticalPosition ?? 0.0, - left: widget.horizontalPosition ?? 0.0, - child: widget.child ?? Container(), - ) - ], - ), - ), - ) - ], - ); + ), + ) + ], + ); } + +// import 'dart:async'; +// +// import 'package:flutter/material.dart'; +// import 'package:getwidget/getwidget.dart'; +// +// class GFFloatingWidget extends StatefulWidget { +// /// Creates a Floating body can be used to display the quick messages, warning and erros. +// /// Inside floating widget [GFToast] can be used as body. See [GFToast] +// const GFFloatingWidget( +// {Key key, +// this.child, +// this.horizontalPosition, +// this.verticalPosition, +// this.blurnessColor, +// this.showBlurness = false, +// this.body, +// this.autoDismiss = true, +// this.animationDuration = const Duration(milliseconds: 300), +// this.duration = const Duration(milliseconds: 300), +// }) +// : super(key: key); +// +// ///child of type [Widget] which floats across the body based on horizontal and vertical position +// final Widget child; +// +// ///body of type [Widget] which is same as Scaffold's body +// final Widget body; +// +// /// horizontalPosition of type [double] which aligns the child horizontally across the body +// final double horizontalPosition; +// +// /// verticalPosition of type [double] which aligns the child vertically across the body +// final double verticalPosition; +// +// ///blurnessColor of tye [Color] or [GFColors] which is used to blur the backgroundColor when ever the [child] is used in [GFFloatingWidget] +// final Color blurnessColor; +// +// ///type of bool which allows to show or hide the blurness of the backgroundColor whenever the [child] is used in [GFFloatingWidget] +// final bool showBlurness; +// +// ///type of [bool] which takes bool values ie, true or false to automatically hide the [GFToast] message +// final bool autoDismiss; +// +// ///type of [Duration] which takes the duration of the fade in animation +// final Duration animationDuration; +// +// ///type of [Duration] which takes the duration of the animation +// final Duration duration; +// +// @override +// _GFFloatingWidgetState createState() => _GFFloatingWidgetState(); +// } +// +// class _GFFloatingWidgetState extends State { +// Widget child; +// Color bgColor; +// bool showBackgroundOverlay = false; +// +// @override +// void initState() { +// child = widget.child; +// showBackgroundOverlay = widget.showBlurness; +// print('before $showBackgroundOverlay ${widget.showBlurness}'); +// if(widget.autoDismiss == true && widget.showBlurness == true) { +// print('first $showBackgroundOverlay ${widget.showBlurness}'); +// setState(() { +// showBackgroundOverlay = !showBackgroundOverlay; +// }); +// print('last $showBackgroundOverlay ${widget.showBlurness}'); +// } +// super.initState(); +// } +// +// @override +// void didUpdateWidget(GFFloatingWidget oldWidget) { +// child = widget.child; +// super.didUpdateWidget(oldWidget); +// } +// +// Color fadeBackgroundOverlay() { +// print('in $showBackgroundOverlay ${widget.showBlurness}'); +// Timer(widget.duration, () { +// if(mounted) { +// setState(() { +// bgColor = widget.blurnessColor != null ? widget.blurnessColor : Colors.black38; +// }); +// } +// +// }); +// return bgColor; +// } +// +// @override +// Widget build(BuildContext context) => Stack( +// alignment: Alignment.center, +// fit: StackFit.loose, +// children: [ +// Container( +// height: MediaQuery.of(context).size.height, +// child: widget.body ?? Container(), +// ), +// Positioned( +// child: Container( +// height: MediaQuery.of(context).size.height, +// width: MediaQuery.of(context).size.width, +// color: showBackgroundOverlay ? fadeBackgroundOverlay() : null, +// child: Stack( +// children: [ +// Positioned( +// top: widget.verticalPosition ?? 0.0, +// left: widget.horizontalPosition ?? 0.0, +// child: widget.child ?? Container(), +// ) +// ], +// ), +// ), +// ) +// ], +// ); +// } diff --git a/lib/components/list_tile/gf_list_tile.dart b/lib/components/list_tile/gf_list_tile.dart index 5b08e13e..68fdf7ad 100644 --- a/lib/components/list_tile/gf_list_tile.dart +++ b/lib/components/list_tile/gf_list_tile.dart @@ -15,7 +15,7 @@ class GFListTile extends StatelessWidget { this.description, this.icon, this.padding = const EdgeInsets.all(8), - this.margin = const EdgeInsets.all(16), + this.margin = const EdgeInsets.symmetric(vertical: 8, horizontal: 16), this.enabled = true, this.onTap, this.onLongPress, diff --git a/lib/components/radio_list_tile/gf_radio_list_tile.dart b/lib/components/radio_list_tile/gf_radio_list_tile.dart index f4f09fb8..4b712258 100644 --- a/lib/components/radio_list_tile/gf_radio_list_tile.dart +++ b/lib/components/radio_list_tile/gf_radio_list_tile.dart @@ -35,7 +35,7 @@ class GFRadioListTile extends StatelessWidget { this.description, this.icon, this.padding = const EdgeInsets.all(8), - this.margin = const EdgeInsets.all(16), + this.margin = const EdgeInsets.symmetric(vertical: 8, horizontal: 16), this.enabled = true, this.onTap, this.onLongPress, diff --git a/lib/components/toast/gf_toast.dart b/lib/components/toast/gf_toast.dart index 94a3db0c..f691d4b7 100644 --- a/lib/components/toast/gf_toast.dart +++ b/lib/components/toast/gf_toast.dart @@ -79,8 +79,8 @@ class _GFToastState extends State with TickerProviderStateMixin { if (mounted) { animationController.forward(); fadeanimationController = - AnimationController(duration: widget.animationDuration, vsync: this) - ..addListener(() => setState(() {})); + AnimationController(duration: widget.animationDuration, vsync: this) + ..addListener(() => setState(() {})); fadeanimation = Tween( begin: 0, end: 1, @@ -117,59 +117,59 @@ class _GFToastState extends State with TickerProviderStateMixin { Widget build(BuildContext context) => hideToast ? Container() : FadeTransition( - opacity: widget.autoDismiss ? fadeanimation : animation, - child: Column( + opacity: widget.autoDismiss ? fadeanimation : animation, + child: Column( + children: [ + Container( + width: widget.type == GFToastType.fullWidth + ? MediaQuery.of(context).size.width + : widget.width ?? MediaQuery.of(context).size.width * 0.885, + constraints: const BoxConstraints(minHeight: 50), + margin: widget.type == GFToastType.fullWidth + ? const EdgeInsets.only(left: 0, right: 0) + : const EdgeInsets.only(left: 10, right: 10), + padding: const EdgeInsets.all(10), + decoration: BoxDecoration( + borderRadius: widget.type == GFToastType.basic + ? BorderRadius.circular(0) + : widget.type == GFToastType.rounded + ? BorderRadius.circular(10) + : BorderRadius.zero, + color: widget.backgroundColor ?? const Color(0xff323232), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.40), + blurRadius: 6, + ) + ]), + child: Row( children: [ - Container( - width: widget.type == GFToastType.fullWidth - ? MediaQuery.of(context).size.width - : widget.width ?? MediaQuery.of(context).size.width * 0.885, - constraints: const BoxConstraints(minHeight: 50), - margin: widget.type == GFToastType.fullWidth - ? const EdgeInsets.only(left: 0, right: 0) - : const EdgeInsets.only(left: 10, right: 10), - padding: const EdgeInsets.all(10), - decoration: BoxDecoration( - borderRadius: widget.type == GFToastType.basic - ? BorderRadius.circular(0) - : widget.type == GFToastType.rounded - ? BorderRadius.circular(10) - : BorderRadius.zero, - color: widget.backgroundColor ?? const Color(0xff323232), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.40), - blurRadius: 6, - ) - ]), - child: Row( - children: [ - Flexible( - flex: 7, - fit: FlexFit.tight, - child: Align( - alignment: widget.alignment ?? Alignment.topLeft, - child: widget.text != null - ? Text(widget.text, style: widget.textStyle) - : (widget.child ?? Container()), - ), - ), - const SizedBox( - width: 10, - ), - widget.button != null - ? Flexible( - flex: 4, - fit: FlexFit.tight, - child: Align( - alignment: Alignment.topRight, - child: widget.button, - )) - : Container() - ], + Flexible( + flex: 7, + fit: FlexFit.tight, + child: Align( + alignment: widget.alignment ?? Alignment.topLeft, + child: widget.text != null + ? Text(widget.text, style: widget.textStyle) + : (widget.child ?? Container()), ), ), + const SizedBox( + width: 10, + ), + widget.button != null + ? Flexible( + flex: 4, + fit: FlexFit.tight, + child: Align( + alignment: Alignment.topRight, + child: widget.button, + )) + : Container() ], ), - ); -} + ), + ], + ), + ); +} \ No newline at end of file From 1fd77a62ca3e68ed73fb5d9e05a51da6eaf37f6d Mon Sep 17 00:00:00 2001 From: deepikahr Date: Thu, 8 Oct 2020 16:03:30 +0530 Subject: [PATCH 11/25] background blur changes in floating widget --- .../floating_widget/gf_floating_widget.dart | 306 +++++++++--------- lib/components/toast/gf_toast.dart | 24 +- 2 files changed, 165 insertions(+), 165 deletions(-) diff --git a/lib/components/floating_widget/gf_floating_widget.dart b/lib/components/floating_widget/gf_floating_widget.dart index 7ff6a0a3..3f1fa26e 100644 --- a/lib/components/floating_widget/gf_floating_widget.dart +++ b/lib/components/floating_widget/gf_floating_widget.dart @@ -1,89 +1,3 @@ -import 'package:flutter/material.dart'; -import 'package:getwidget/getwidget.dart'; - -class GFFloatingWidget extends StatefulWidget { - /// Creates a Floating body can be used to display the quick messages, warning and erros. - /// Inside floating widget [GFToast] can be used as body. See [GFToast] - const GFFloatingWidget( - {Key key, - this.child, - this.horizontalPosition, - this.verticalPosition, - this.blurnessColor, - this.showBlurness = false, - this.body}) - : super(key: key); - - ///child of type [Widget] which floats across the body based on horizontal and vertical position - final Widget child; - - ///body of type [Widget] which is same as Scaffold's body - final Widget body; - - /// horizontalPosition of type [double] which aligns the child horizontally across the body - final double horizontalPosition; - - /// verticalPosition of type [double] which aligns the child vertically across the body - final double verticalPosition; - - ///blurnessColor of tye [Color] or [GFColors] which is used to blur the backgroundColor when ever the [child] is used in [GFFloatingWidget] - final Color blurnessColor; - - ///type of bool which allows to show or hide the blurness of the backgroundColor whenever the [child] is used in [GFFloatingWidget] - final bool showBlurness; - - @override - _GFFloatingWidgetState createState() => _GFFloatingWidgetState(); -} - -class _GFFloatingWidgetState extends State { - Widget child; - - @override - void initState() { - child = widget.child; - super.initState(); - } - - @override - void didUpdateWidget(GFFloatingWidget oldWidget) { - child = widget.child; - super.didUpdateWidget(oldWidget); - } - - @override - Widget build(BuildContext context) => Stack( - alignment: Alignment.center, - fit: StackFit.loose, - children: [ - Container( - height: MediaQuery.of(context).size.height, - child: widget.body ?? Container(), - ), - Positioned( - child: Container( - height: MediaQuery.of(context).size.height, - width: MediaQuery.of(context).size.width, - color: widget.showBlurness - ? widget.blurnessColor ?? Colors.black54 - : null, - child: Stack( - children: [ - Positioned( - top: widget.verticalPosition ?? 0.0, - left: widget.horizontalPosition ?? 0.0, - child: widget.child ?? Container(), - ) - ], - ), - ), - ) - ], - ); -} - -// import 'dart:async'; -// // import 'package:flutter/material.dart'; // import 'package:getwidget/getwidget.dart'; // @@ -92,16 +6,12 @@ class _GFFloatingWidgetState extends State { // /// Inside floating widget [GFToast] can be used as body. See [GFToast] // const GFFloatingWidget( // {Key key, -// this.child, -// this.horizontalPosition, -// this.verticalPosition, -// this.blurnessColor, -// this.showBlurness = false, -// this.body, -// this.autoDismiss = true, -// this.animationDuration = const Duration(milliseconds: 300), -// this.duration = const Duration(milliseconds: 300), -// }) +// this.child, +// this.horizontalPosition, +// this.verticalPosition, +// this.blurnessColor, +// this.showBlurness = false, +// this.body}) // : super(key: key); // // ///child of type [Widget] which floats across the body based on horizontal and vertical position @@ -122,36 +32,16 @@ class _GFFloatingWidgetState extends State { // ///type of bool which allows to show or hide the blurness of the backgroundColor whenever the [child] is used in [GFFloatingWidget] // final bool showBlurness; // -// ///type of [bool] which takes bool values ie, true or false to automatically hide the [GFToast] message -// final bool autoDismiss; -// -// ///type of [Duration] which takes the duration of the fade in animation -// final Duration animationDuration; -// -// ///type of [Duration] which takes the duration of the animation -// final Duration duration; -// // @override // _GFFloatingWidgetState createState() => _GFFloatingWidgetState(); // } // // class _GFFloatingWidgetState extends State { // Widget child; -// Color bgColor; -// bool showBackgroundOverlay = false; // // @override // void initState() { // child = widget.child; -// showBackgroundOverlay = widget.showBlurness; -// print('before $showBackgroundOverlay ${widget.showBlurness}'); -// if(widget.autoDismiss == true && widget.showBlurness == true) { -// print('first $showBackgroundOverlay ${widget.showBlurness}'); -// setState(() { -// showBackgroundOverlay = !showBackgroundOverlay; -// }); -// print('last $showBackgroundOverlay ${widget.showBlurness}'); -// } // super.initState(); // } // @@ -161,44 +51,154 @@ class _GFFloatingWidgetState extends State { // super.didUpdateWidget(oldWidget); // } // -// Color fadeBackgroundOverlay() { -// print('in $showBackgroundOverlay ${widget.showBlurness}'); -// Timer(widget.duration, () { -// if(mounted) { -// setState(() { -// bgColor = widget.blurnessColor != null ? widget.blurnessColor : Colors.black38; -// }); -// } -// -// }); -// return bgColor; -// } -// // @override // Widget build(BuildContext context) => Stack( -// alignment: Alignment.center, -// fit: StackFit.loose, -// children: [ -// Container( -// height: MediaQuery.of(context).size.height, -// child: widget.body ?? Container(), +// alignment: Alignment.center, +// fit: StackFit.loose, +// children: [ +// Container( +// height: MediaQuery.of(context).size.height, +// child: widget.body ?? Container(), +// ), +// Positioned( +// child: Container( +// height: MediaQuery.of(context).size.height, +// width: MediaQuery.of(context).size.width, +// color: widget.showBlurness +// ? widget.blurnessColor ?? Colors.black54 +// : null, +// child: Stack( +// children: [ +// Positioned( +// top: widget.verticalPosition ?? 0.0, +// left: widget.horizontalPosition ?? 0.0, +// child: widget.child ?? Container(), +// ) +// ], // ), -// Positioned( -// child: Container( -// height: MediaQuery.of(context).size.height, -// width: MediaQuery.of(context).size.width, -// color: showBackgroundOverlay ? fadeBackgroundOverlay() : null, -// child: Stack( -// children: [ -// Positioned( -// top: widget.verticalPosition ?? 0.0, -// left: widget.horizontalPosition ?? 0.0, -// child: widget.child ?? Container(), -// ) -// ], -// ), -// ), -// ) -// ], -// ); +// ), +// ) +// ], +// ); // } + +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:getwidget/getwidget.dart'; + +class GFFloatingWidget extends StatefulWidget { + /// Creates a Floating body can be used to display the quick messages, warning and erros. + /// Inside floating widget [GFToast] can be used as body. See [GFToast] + const GFFloatingWidget( + {Key key, + this.child, + this.horizontalPosition, + this.verticalPosition, + this.blurnessColor, + this.showBlurness = false, + this.body, + this.autoDismiss = true, + this.animationDuration = const Duration(milliseconds: 300), + this.duration = const Duration(milliseconds: 300), + }) + : super(key: key); + + ///child of type [Widget] which floats across the body based on horizontal and vertical position + final Widget child; + + ///body of type [Widget] which is same as Scaffold's body + final Widget body; + + /// horizontalPosition of type [double] which aligns the child horizontally across the body + final double horizontalPosition; + + /// verticalPosition of type [double] which aligns the child vertically across the body + final double verticalPosition; + + ///blurnessColor of tye [Color] or [GFColors] which is used to blur the backgroundColor when ever the [child] is used in [GFFloatingWidget] + final Color blurnessColor; + + ///type of bool which allows to show or hide the blurness of the backgroundColor whenever the [child] is used in [GFFloatingWidget] + final bool showBlurness; + + ///type of [bool] which takes bool values ie, true or false to automatically hide the [GFToast] message + final bool autoDismiss; + + ///type of [Duration] which takes the duration of the fade in animation + final Duration animationDuration; + + ///type of [Duration] which takes the duration of the animation + final Duration duration; + + @override + _GFFloatingWidgetState createState() => _GFFloatingWidgetState(); +} + +class _GFFloatingWidgetState extends State { + Widget child; + Color bgColor; + bool showBackgroundOverlay = false; + + @override + void initState() { + child = widget.child; + showBackgroundOverlay = widget.showBlurness; + print('before $showBackgroundOverlay ${widget.showBlurness}'); + if(widget.autoDismiss == true && widget.showBlurness == true) { + print('first $showBackgroundOverlay ${widget.showBlurness}'); + setState(() { + showBackgroundOverlay = !showBackgroundOverlay; + }); + print('last $showBackgroundOverlay ${widget.showBlurness}'); + } + super.initState(); + } + + @override + void didUpdateWidget(GFFloatingWidget oldWidget) { + child = widget.child; + super.didUpdateWidget(oldWidget); + } + + Color fadeBackgroundOverlay() { + print('in $showBackgroundOverlay ${widget.showBlurness}'); + Timer(widget.duration, () { + if(mounted) { + setState(() { + bgColor = widget.blurnessColor != null ? widget.blurnessColor : Colors.black38; + }); + } + + }); + return bgColor; + } + + @override + Widget build(BuildContext context) => Stack( + alignment: Alignment.center, + fit: StackFit.loose, + children: [ + Container( + height: MediaQuery.of(context).size.height, + child: widget.body ?? Container(), + ), + Positioned( + child: Container( + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + color: showBackgroundOverlay ? fadeBackgroundOverlay() : null, + child: Stack( + children: [ + Positioned( + top: widget.verticalPosition ?? 0.0, + left: widget.horizontalPosition ?? 0.0, + child: widget.child ?? Container(), + ) + ], + ), + ), + ) + ], + ); +} diff --git a/lib/components/toast/gf_toast.dart b/lib/components/toast/gf_toast.dart index f691d4b7..dbcf734f 100644 --- a/lib/components/toast/gf_toast.dart +++ b/lib/components/toast/gf_toast.dart @@ -63,8 +63,8 @@ class GFToast extends StatefulWidget { } class _GFToastState extends State with TickerProviderStateMixin { - AnimationController animationController, fadeanimationController; - Animation animation, fadeanimation; + AnimationController animationController, fadeAnimationController; + Animation animation, fadeAnimation; bool hideToast = false; @override @@ -78,24 +78,24 @@ class _GFToastState extends State with TickerProviderStateMixin { if (mounted) { animationController.forward(); - fadeanimationController = + fadeAnimationController = AnimationController(duration: widget.animationDuration, vsync: this) ..addListener(() => setState(() {})); - fadeanimation = Tween( + fadeAnimation = Tween( begin: 0, end: 1, - ).animate(fadeanimationController); + ).animate(fadeAnimationController); Timer(widget.duration, () { if (mounted) { - fadeanimationController.forward(); + fadeAnimationController.forward(); } }); - fadeanimation = Tween( + fadeAnimation = Tween( begin: 1, end: 0, - ).animate(fadeanimationController); - fadeanimation.addStatusListener((AnimationStatus state) { - if (fadeanimation.isCompleted && widget.autoDismiss) { + ).animate(fadeAnimationController); + fadeAnimation.addStatusListener((AnimationStatus state) { + if (fadeAnimation.isCompleted && widget.autoDismiss) { setState(() { hideToast = true; }); @@ -109,7 +109,7 @@ class _GFToastState extends State with TickerProviderStateMixin { @override void dispose() { animationController.dispose(); - fadeanimationController.dispose(); + fadeAnimationController.dispose(); super.dispose(); } @@ -117,7 +117,7 @@ class _GFToastState extends State with TickerProviderStateMixin { Widget build(BuildContext context) => hideToast ? Container() : FadeTransition( - opacity: widget.autoDismiss ? fadeanimation : animation, + opacity: widget.autoDismiss ? fadeAnimation : animation, child: Column( children: [ Container( From 3d8eb5b2d5132691fb392757b1c877bec8d1d8a1 Mon Sep 17 00:00:00 2001 From: deepikahr Date: Mon, 12 Oct 2020 21:10:05 +0530 Subject: [PATCH 12/25] icon button issue fixed --- example/lib/main_temp.dart | 665 ++++++++++++------ lib/components/button/gf_icon_button.dart | 116 +-- .../floating_widget/gf_floating_widget.dart | 185 +---- 3 files changed, 545 insertions(+), 421 deletions(-) diff --git a/example/lib/main_temp.dart b/example/lib/main_temp.dart index cc9ad214..0de1c6bc 100644 --- a/example/lib/main_temp.dart +++ b/example/lib/main_temp.dart @@ -58,6 +58,8 @@ class _BottomSheetPageState extends State { 'Xamarin2', ]; + String selected; + @override Widget build(BuildContext context) => Scaffold( appBar: GFAppBar( @@ -87,229 +89,472 @@ class _BottomSheetPageState extends State { autoDismiss: false, ) : Container(), - body: ListView( - physics: const ScrollPhysics(), - children: [ - GFSearchBar( - searchList: list, - searchQueryBuilder: (query, list) => list - .where((item) => - item.toLowerCase().contains(query.toLowerCase())) - .toList(), - overlaySearchListItemBuilder: (item) => Container( - padding: const EdgeInsets.all(8), - child: Text( - item, - style: const TextStyle(fontSize: 18), - ), - ), - onItemSelected: (item) { - setState(() { - print('$item'); - }); - }), - const Padding( - padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), - child: GFTypography( - text: 'Customised SearchBar', - type: GFTypographyType.typo5, - dividerWidth: 25, - dividerColor: Color(0xFF19CA4B), - ), - ), - GFSearchBar( - searchBoxInputDecoration: InputDecoration( - labelText: 'Type Here', - labelStyle: const TextStyle(color: Colors.black26), - focusedBorder: OutlineInputBorder( - borderSide: const BorderSide(color: Colors.greenAccent), - borderRadius: BorderRadius.circular(25), - ), - prefixIcon: Icon( - Icons.search, - color: Colors.black26, - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Colors.black12), - borderRadius: BorderRadius.circular(50)), - ), - searchList: list, - searchQueryBuilder: (query, list) => list - .where((item) => - item.toLowerCase().contains(query.toLowerCase())) - .toList(), - overlaySearchListItemBuilder: (item) => Container( - padding: const EdgeInsets.all(8), - child: Text( - item, - style: const TextStyle(fontSize: 18), - ), + body: Column( + children: [ + + + + GFTypography( + child: Text( + selected ?? 'nothing selected yet', + style: TextStyle( + fontSize: 20.0, + color: Colors.black, + fontWeight: FontWeight.w600, ), - onItemSelected: (item) { - setState(() { - print('$item'); - }); - }), - const Padding( - padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), - child: GFTypography( - text: 'Animated Toasts (Auto Dismissable)', - type: GFTypographyType.typo5, - dividerWidth: 25, - dividerColor: Color(0xFF19CA4B), - ), - ), - GFToast( - text: 'Auto Dismissable after the given duration !', - button: GFButton( - onPressed: () {}, - text: 'OK', - type: GFButtonType.transparent, - color: GFColors.SUCCESS, - ), - autoDismiss: true, - duration: const Duration(seconds: 5), - ), - const SizedBox( - height: 15, - ), - const GFToast( - text: 'Pass true to autoDismiss property to use this effect!', - autoDismiss: true, - duration: Duration(seconds: 2), - ), - const Padding( - padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), - child: GFTypography( - text: 'Basic Toasts', - type: GFTypographyType.typo5, - dividerWidth: 25, - dividerColor: Color(0xFF19CA4B), - ), - ), - GFToast( - text: 'Paired Succesfully !', - button: GFButton( - onPressed: () {}, - text: 'OK', - type: GFButtonType.transparent, - color: GFColors.SUCCESS, - ), - autoDismiss: false, - duration: const Duration(milliseconds: 300), - alignment: Alignment.topLeft, - ), - const SizedBox( - height: 15, - ), - GFToast( - text: - 'This item already has the label “travel”. You can add new label. !', - button: GFButton( - onPressed: () {}, - text: 'OK', - type: GFButtonType.transparent, - color: GFColors.SUCCESS, - ), - autoDismiss: false, - ), - const Padding( - padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), - child: GFTypography( - text: 'Rounded Toasts', - type: GFTypographyType.typo5, - dividerWidth: 25, - dividerColor: Color(0xFF19CA4B), - ), - ), - GFToast( - text: 'Paired Succesfully !', - button: GFButton( - onPressed: () {}, - text: 'OK', - type: GFButtonType.transparent, - color: GFColors.SUCCESS, - ), - type: GFToastType.rounded, - autoDismiss: false, - alignment: Alignment.topLeft, - ), - const SizedBox( - height: 15, - ), - GFToast( - text: - 'This item already has the label “travel”. You can add a new label. !', - button: GFButton( - onPressed: () {}, - text: 'OK', - type: GFButtonType.transparent, - color: GFColors.SUCCESS, ), - autoDismiss: false, - type: GFToastType.rounded, - alignment: Alignment.topLeft, + type: GFTypographyType.typo5, + dividerWidth: 45, + dividerColor: Color(0xFF19CA4B), ), - const Padding( - padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), - child: GFTypography( - text: 'Full Width Toasts', - type: GFTypographyType.typo5, - dividerWidth: 25, - dividerColor: Color(0xFF19CA4B), - ), + + + GFIconButton( + onPressed: () { + print('ffffffffff'); + }, + icon: Icon(Icons.ac_unit), + // iconSize: 42.0, + type: GFButtonType.solid, + // shape: GFIconButtonShape.circle, + size: GFSize.SMALL, + // buttonBoxShadow: true, + color: GFColors.WARNING, + // boxShadow: BoxShadow( + // color: Colors.pink, + // blurRadius: 2.0, + // spreadRadius: 1.0, + // offset: Offset.zero, + // ), + // borderSide: BorderSide(color: Colors.pink, width: 1.0, style: BorderStyle.solid), + // borderShape: RoundedRectangleBorder(side: BorderSide(color: Colors.pink, width: 2.0, style: BorderStyle.solid), borderRadius: BorderRadius.zero), ), - GFToast( - text: 'Paired Succesfully !', - button: GFButton( - onPressed: () {}, - text: 'OK', - type: GFButtonType.transparent, - color: GFColors.SUCCESS, - ), - type: GFToastType.fullWidth, - autoDismiss: false, + + SizedBox( + height: 22, ), - const SizedBox( - height: 15, + + GFIconButton( + onPressed: () { + print('ffffffffff'); + }, + icon: Icon(Icons.ac_unit), + // iconSize: 62.0, + type: GFButtonType.solid, + // shape: GFIconButtonShape.circle, + size: GFSize.MEDIUM, + // buttonBoxShadow: true, + color: GFColors.WARNING, + // boxShadow: BoxShadow( + // color: Colors.pink, + // blurRadius: 2.0, + // spreadRadius: 1.0, + // offset: Offset.zero, + // ), + // borderSide: BorderSide(color: Colors.pink, width: 1.0, style: BorderStyle.solid), + // borderShape: RoundedRectangleBorder(side: BorderSide(color: Colors.pink, width: 2.0, style: BorderStyle.solid), borderRadius: BorderRadius.zero), ), - GFToast( - text: - 'This item already has the label “travel”. You can add a new label.!', - button: GFButton( - onPressed: () {}, - text: 'OK', - type: GFButtonType.transparent, - color: GFColors.SUCCESS, - ), - autoDismiss: false, - type: GFToastType.fullWidth, + + SizedBox( + height: 22, ), - const Padding( - padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), - child: GFTypography( - text: 'Floating Toast', - type: GFTypographyType.typo5, - dividerWidth: 25, - dividerColor: Color(0xFF19CA4B), - ), + + GFIconButton( + onPressed: () { + print('ffffffffff'); + }, + icon: Icon(Icons.ac_unit), + // iconSize: 62.0, + type: GFButtonType.transparent, + // shape: GFIconButtonShape.pills, + size: GFSize.LARGE, + // buttonBoxShadow: true, + color: GFColors.WARNING, + // boxShadow: BoxShadow( + // color: Colors.pink, + // blurRadius: 2.0, + // spreadRadius: 1.0, + // offset: Offset.zero, + // ), + // borderSide: BorderSide(color: Colors.pink, width: 1.0, style: BorderStyle.solid), + // borderShape: RoundedRectangleBorder(side: BorderSide(color: Colors.pink, width: 2.0, style: BorderStyle.solid), borderRadius: BorderRadius.circular(22)), ), - Container( - margin: const EdgeInsets.only(left: 40, right: 40), - child: GFButton( - onPressed: () { - setState(() { - showFloatingToast = !showFloatingToast; - }); - }, - text: 'View Floating Toast', + + + GFTypography( + child: Text( + selected ?? 'nothing selected yet', + style: TextStyle( + fontSize: 20.0, + color: Colors.black, + fontWeight: FontWeight.w600, + ), ), + type: GFTypographyType.typo5, + dividerWidth: 45, + dividerColor: Color(0xFF19CA4B), ), - const SizedBox( - height: 20, + + IconButton( + onPressed: () { + print('kkkkkkkkkk'); + }, + icon: Icon(Icons.ac_unit), + iconSize: 42.0, ), ], ), + +// ListView( +// physics: const ScrollPhysics(), +// children: [ +// GFSearchBar( +// // searchBoxInputDecoration: InputDecoration( +// // enabledBorder: OutlineInputBorder( +// // borderSide: BorderSide( +// // color: Colors.teal, +// // ), +// // borderRadius: BorderRadius.circular(50)), +// // ), +// searchList: list, +// // hideSearchBoxWhenItemSelected: false, +// // overlaySearchListHeight: 100.0, +// searchQueryBuilder: (query, list) => +// list.where((item) => item.toLowerCase().contains(query.toLowerCase())).toList(), +// overlaySearchListItemBuilder: (item) => Container( +// padding: const EdgeInsets.all(8), +// child: Text( +// item, +// style: const TextStyle(fontSize: 18), +// ), +// ), +// // noItemsFoundWidget: Container( +// // color: Colors.green, +// // child: Text("no items found..."), +// // ), +// onItemSelected: (item) { +// setState(() { +// selected = item; +// print('$item'); +// }); +// }), +// SizedBox( +// height: 10, +// ), +// GFSearchBar( +// searchBoxInputDecoration: InputDecoration( +// labelText: 'Type Here', +// labelStyle: TextStyle(color: Colors.black26), +// focusedBorder: OutlineInputBorder( +// borderSide: const BorderSide(color: Colors.greenAccent), +// borderRadius: BorderRadius.circular(25), +// ), +// prefixIcon: Icon( +// Icons.search, +// color: Colors.black26, +// ), +// enabledBorder: OutlineInputBorder( +// borderSide: BorderSide(color: Colors.black12), borderRadius: BorderRadius.circular(50)), +// ), +// searchList: list, +// // hideSearchBoxWhenItemSelected: false, +// // overlaySearchListHeight: 100.0, +// searchQueryBuilder: (query, list) => +// list.where((item) => item.toLowerCase().contains(query.toLowerCase())).toList(), +// overlaySearchListItemBuilder: (item) => Container( +// padding: const EdgeInsets.all(8), +// child: Text( +// item, +// style: const TextStyle(fontSize: 18), +// ), +// ), +// // noItemsFoundWidget: Container( +// // color: Colors.green, +// // child: Text("no items found..."), +// // ), +// onItemSelected: (item) { +// setState(() { +// selected = item; +// print('$item'); +// }); +// }), +// SizedBox( +// height: 10, +// ), +// GFTypography( +// child: Text( +// selected ?? 'nothing selected yet', +// style: TextStyle( +// fontSize: 20.0, +// color: Colors.black, +// fontWeight: FontWeight.w600, +// ), +// ), +// type: GFTypographyType.typo5, +// dividerWidth: 45, +// dividerColor: Color(0xFF19CA4B), +// ), +// +// GFSearchBar( +// searchBoxInputDecoration: InputDecoration( +// labelText: 'Type Here', +// labelStyle: TextStyle(color: Colors.black26), +// focusedBorder: OutlineInputBorder( +// borderSide: const BorderSide(color: Colors.greenAccent), +// borderRadius: BorderRadius.circular(25), +// ), +// prefixIcon: Icon( +// Icons.search, +// color: Colors.black26, +// ), +// enabledBorder: OutlineInputBorder( +// borderSide: BorderSide(color: Colors.black12), borderRadius: BorderRadius.circular(50)), +// ), +// searchList: list, +// // hideSearchBoxWhenItemSelected: false, +// // overlaySearchListHeight: 100.0, +// searchQueryBuilder: (query, list) => +// list.where((item) => item.toLowerCase().contains(query.toLowerCase())).toList(), +// overlaySearchListItemBuilder: (item) => Container( +// padding: const EdgeInsets.all(8), +// child: Text( +// item, +// style: const TextStyle(fontSize: 18), +// ), +// ), +// // noItemsFoundWidget: Container( +// // color: Colors.green, +// // child: Text("no items found..."), +// // ), +// onItemSelected: (item) { +// setState(() { +// selected = item; +// print('$item'); +// }); +// }), +// SizedBox( +// height: 10, +// ), +// GFSearchBar( +// searchList: list, +// searchQueryBuilder: (query, list) => list +// .where((item) => +// item.toLowerCase().contains(query.toLowerCase())) +// .toList(), +// overlaySearchListItemBuilder: (item) => Container( +// padding: const EdgeInsets.all(8), +// child: Text( +// item, +// style: const TextStyle(fontSize: 18), +// ), +// ), +// onItemSelected: (item) { +// setState(() { +// print('$item'); +// }); +// }), +// const Padding( +// padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), +// child: GFTypography( +// text: 'Customised SearchBar', +// type: GFTypographyType.typo5, +// dividerWidth: 25, +// dividerColor: Color(0xFF19CA4B), +// ), +// ), +// GFSearchBar( +// searchBoxInputDecoration: InputDecoration( +// labelText: 'Type Here', +// labelStyle: const TextStyle(color: Colors.black26), +// focusedBorder: OutlineInputBorder( +// borderSide: const BorderSide(color: Colors.greenAccent), +// borderRadius: BorderRadius.circular(25), +// ), +// prefixIcon: Icon( +// Icons.search, +// color: Colors.black26, +// ), +// enabledBorder: OutlineInputBorder( +// borderSide: BorderSide(color: Colors.black12), +// borderRadius: BorderRadius.circular(50)), +// ), +// searchList: list, +// searchQueryBuilder: (query, list) => list +// .where((item) => +// item.toLowerCase().contains(query.toLowerCase())) +// .toList(), +// overlaySearchListItemBuilder: (item) => Container( +// padding: const EdgeInsets.all(8), +// child: Text( +// item, +// style: const TextStyle(fontSize: 18), +// ), +// ), +// onItemSelected: (item) { +// setState(() { +// print('$item'); +// }); +// }), +// const Padding( +// padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), +// child: GFTypography( +// text: 'Animated Toasts (Auto Dismissable)', +// type: GFTypographyType.typo5, +// dividerWidth: 25, +// dividerColor: Color(0xFF19CA4B), +// ), +// ), +// GFToast( +// text: 'Auto Dismissable after the given duration !', +// button: GFButton( +// onPressed: () {}, +// text: 'OK', +// type: GFButtonType.transparent, +// color: GFColors.SUCCESS, +// ), +// autoDismiss: true, +// duration: const Duration(seconds: 5), +// ), +// const SizedBox( +// height: 15, +// ), +// const GFToast( +// text: 'Pass true to autoDismiss property to use this effect!', +// autoDismiss: true, +// duration: Duration(seconds: 2), +// ), +// const Padding( +// padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), +// child: GFTypography( +// text: 'Basic Toasts', +// type: GFTypographyType.typo5, +// dividerWidth: 25, +// dividerColor: Color(0xFF19CA4B), +// ), +// ), +// GFToast( +// text: 'Paired Succesfully !', +// button: GFButton( +// onPressed: () {}, +// text: 'OK', +// type: GFButtonType.transparent, +// color: GFColors.SUCCESS, +// ), +// autoDismiss: false, +// duration: const Duration(milliseconds: 300), +// alignment: Alignment.topLeft, +// ), +// const SizedBox( +// height: 15, +// ), +// GFToast( +// text: +// 'This item already has the label “travel”. You can add new label. !', +// button: GFButton( +// onPressed: () {}, +// text: 'OK', +// type: GFButtonType.transparent, +// color: GFColors.SUCCESS, +// ), +// autoDismiss: false, +// ), +// const Padding( +// padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), +// child: GFTypography( +// text: 'Rounded Toasts', +// type: GFTypographyType.typo5, +// dividerWidth: 25, +// dividerColor: Color(0xFF19CA4B), +// ), +// ), +// GFToast( +// text: 'Paired Succesfully !', +// button: GFButton( +// onPressed: () {}, +// text: 'OK', +// type: GFButtonType.transparent, +// color: GFColors.SUCCESS, +// ), +// type: GFToastType.rounded, +// autoDismiss: false, +// alignment: Alignment.topLeft, +// ), +// const SizedBox( +// height: 15, +// ), +// GFToast( +// text: +// 'This item already has the label “travel”. You can add a new label. !', +// button: GFButton( +// onPressed: () {}, +// text: 'OK', +// type: GFButtonType.transparent, +// color: GFColors.SUCCESS, +// ), +// autoDismiss: false, +// type: GFToastType.rounded, +// alignment: Alignment.topLeft, +// ), +// const Padding( +// padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), +// child: GFTypography( +// text: 'Full Width Toasts', +// type: GFTypographyType.typo5, +// dividerWidth: 25, +// dividerColor: Color(0xFF19CA4B), +// ), +// ), +// GFToast( +// text: 'Paired Succesfully !', +// button: GFButton( +// onPressed: () {}, +// text: 'OK', +// type: GFButtonType.transparent, +// color: GFColors.SUCCESS, +// ), +// type: GFToastType.fullWidth, +// autoDismiss: false, +// ), +// const SizedBox( +// height: 15, +// ), +// GFToast( +// text: +// 'This item already has the label “travel”. You can add a new label.!', +// button: GFButton( +// onPressed: () {}, +// text: 'OK', +// type: GFButtonType.transparent, +// color: GFColors.SUCCESS, +// ), +// autoDismiss: false, +// type: GFToastType.fullWidth, +// ), +// const Padding( +// padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), +// child: GFTypography( +// text: 'Floating Toast', +// type: GFTypographyType.typo5, +// dividerWidth: 25, +// dividerColor: Color(0xFF19CA4B), +// ), +// ), +// Container( +// margin: const EdgeInsets.only(left: 40, right: 40), +// child: GFButton( +// onPressed: () { +// setState(() { +// showFloatingToast = !showFloatingToast; +// }); +// }, +// text: 'View Floating Toast', +// ), +// ), +// const SizedBox( +// height: 20, +// ), +// ], +// ), ), bottomSheet: GFBottomSheet( controller: _controller, diff --git a/lib/components/button/gf_icon_button.dart b/lib/components/button/gf_icon_button.dart index 93acc6fa..227407e5 100644 --- a/lib/components/button/gf_icon_button.dart +++ b/lib/components/button/gf_icon_button.dart @@ -111,7 +111,7 @@ class _GFIconButtonState extends State { BoxShadow boxShadow; double height; double width; - double iconPixel; + double iconPixel = 18.0; @override void initState() { @@ -230,31 +230,34 @@ class _GFIconButtonState extends State { } else if (widget.size == GFSize.MEDIUM) { height = 35.0; width = 35.0; - iconPixel = 18.0; + iconPixel = 28.0; } else if (widget.size == GFSize.LARGE) { height = 40.0; width = 40.0; - iconPixel = 18.0; - } else { - height = 35.0; - width = 35.0; - iconPixel = 18.0; + iconPixel = 38.0; } Widget result = Container( - height: widget.shape == GFIconButtonShape.circle ? height + 6.0 : height, - width: widget.shape == GFIconButtonShape.pills - ? width + 10 - : widget.shape == GFIconButtonShape.circle - ? height + 6 - : width, + // height: widget.shape == GFIconButtonShape.circle ? height + 6.0 : height, + // width: widget.shape == GFIconButtonShape.pills + // ? width + 10 + // : widget.shape == GFIconButtonShape.circle + // ? height + 6 + // : width, padding: widget.padding, - child: IconTheme.merge( - data: IconThemeData( - size: widget.iconSize > 0.0 ? widget.iconSize : iconPixel, - color: getIconColor(), + child: SizedBox( + height: widget.iconSize != 0 ? widget.iconSize : iconPixel, + width: widget.iconSize != 0 ? widget.iconSize : iconPixel, + child: Align( + alignment: Alignment.center, + child: IconTheme.merge( + data: IconThemeData( + size: widget.iconSize > 0.0 ? widget.iconSize : iconPixel, + color: getIconColor(), + ), + child: widget.icon, + ), ), - child: widget.icon, ), ); @@ -308,46 +311,43 @@ class _GFIconButtonState extends State { child: Focus( focusNode: widget.focusNode, autofocus: widget.autofocus, - child: ConstrainedBox( - constraints: const BoxConstraints(maxWidth: 60, maxHeight: 60), - child: Container( - height: - widget.shape == GFIconButtonShape.circle ? height + 6 : height, - width: widget.shape == GFIconButtonShape.pills - ? width + 10 - : widget.shape == GFIconButtonShape.circle - ? height + 6 - : width, - decoration: - widget.type == GFButtonType.solid ? getBoxShadow() : null, - child: Material( - shape: widget.type == GFButtonType.transparent - ? null - : widget.borderShape ?? shapeBorderType, - color: widget.onPressed != null - ? getColor() - : getDisabledFillColor(), - type: widget.type == GFButtonType.transparent - ? MaterialType.transparency - : MaterialType.button, - child: InkResponse( - onTap: widget.onPressed, - child: result, - focusColor: widget.focusColor ?? Theme.of(context).focusColor, - hoverColor: widget.hoverColor ?? Theme.of(context).hoverColor, - highlightColor: - widget.highlightColor ?? Theme.of(context).highlightColor, - splashColor: - widget.splashColor ?? Theme.of(context).splashColor, - radius: math.max( - Material.defaultSplashRadius, - (widget.iconSize + - math.min( - widget.padding.horizontal, - widget.padding.vertical, - )) * - 0.7), - ), + child: Container( + // height: + // widget.shape == GFIconButtonShape.circle ? height + 6 : height, + // width: widget.shape == GFIconButtonShape.pills + // ? width + 10 + // : widget.shape == GFIconButtonShape.circle + // ? height + 6 + // : width, + decoration: + widget.type == GFButtonType.solid ? getBoxShadow() : null, + child: Material( + shape: widget.type == GFButtonType.transparent + ? null + : widget.borderShape ?? shapeBorderType, + color: widget.onPressed != null + ? getColor() + : getDisabledFillColor(), + type: widget.type == GFButtonType.transparent + ? MaterialType.transparency + : MaterialType.button, + child: InkResponse( + onTap: widget.onPressed, + child: result, + focusColor: widget.focusColor ?? Theme.of(context).focusColor, + hoverColor: widget.hoverColor ?? Theme.of(context).hoverColor, + highlightColor: + widget.highlightColor ?? Theme.of(context).highlightColor, + splashColor: + widget.splashColor ?? Theme.of(context).splashColor, + radius: math.max( + Material.defaultSplashRadius, + (widget.iconSize > 0.0 ? widget.iconSize : iconPixel + + math.min( + widget.padding.horizontal, + widget.padding.vertical, + )) * + 0.7), ), ), ), diff --git a/lib/components/floating_widget/gf_floating_widget.dart b/lib/components/floating_widget/gf_floating_widget.dart index 3f1fa26e..3c32a0cf 100644 --- a/lib/components/floating_widget/gf_floating_widget.dart +++ b/lib/components/floating_widget/gf_floating_widget.dart @@ -1,89 +1,3 @@ -// import 'package:flutter/material.dart'; -// import 'package:getwidget/getwidget.dart'; -// -// class GFFloatingWidget extends StatefulWidget { -// /// Creates a Floating body can be used to display the quick messages, warning and erros. -// /// Inside floating widget [GFToast] can be used as body. See [GFToast] -// const GFFloatingWidget( -// {Key key, -// this.child, -// this.horizontalPosition, -// this.verticalPosition, -// this.blurnessColor, -// this.showBlurness = false, -// this.body}) -// : super(key: key); -// -// ///child of type [Widget] which floats across the body based on horizontal and vertical position -// final Widget child; -// -// ///body of type [Widget] which is same as Scaffold's body -// final Widget body; -// -// /// horizontalPosition of type [double] which aligns the child horizontally across the body -// final double horizontalPosition; -// -// /// verticalPosition of type [double] which aligns the child vertically across the body -// final double verticalPosition; -// -// ///blurnessColor of tye [Color] or [GFColors] which is used to blur the backgroundColor when ever the [child] is used in [GFFloatingWidget] -// final Color blurnessColor; -// -// ///type of bool which allows to show or hide the blurness of the backgroundColor whenever the [child] is used in [GFFloatingWidget] -// final bool showBlurness; -// -// @override -// _GFFloatingWidgetState createState() => _GFFloatingWidgetState(); -// } -// -// class _GFFloatingWidgetState extends State { -// Widget child; -// -// @override -// void initState() { -// child = widget.child; -// super.initState(); -// } -// -// @override -// void didUpdateWidget(GFFloatingWidget oldWidget) { -// child = widget.child; -// super.didUpdateWidget(oldWidget); -// } -// -// @override -// Widget build(BuildContext context) => Stack( -// alignment: Alignment.center, -// fit: StackFit.loose, -// children: [ -// Container( -// height: MediaQuery.of(context).size.height, -// child: widget.body ?? Container(), -// ), -// Positioned( -// child: Container( -// height: MediaQuery.of(context).size.height, -// width: MediaQuery.of(context).size.width, -// color: widget.showBlurness -// ? widget.blurnessColor ?? Colors.black54 -// : null, -// child: Stack( -// children: [ -// Positioned( -// top: widget.verticalPosition ?? 0.0, -// left: widget.horizontalPosition ?? 0.0, -// child: widget.child ?? Container(), -// ) -// ], -// ), -// ), -// ) -// ], -// ); -// } - -import 'dart:async'; - import 'package:flutter/material.dart'; import 'package:getwidget/getwidget.dart'; @@ -92,16 +6,12 @@ class GFFloatingWidget extends StatefulWidget { /// Inside floating widget [GFToast] can be used as body. See [GFToast] const GFFloatingWidget( {Key key, - this.child, - this.horizontalPosition, - this.verticalPosition, - this.blurnessColor, - this.showBlurness = false, - this.body, - this.autoDismiss = true, - this.animationDuration = const Duration(milliseconds: 300), - this.duration = const Duration(milliseconds: 300), - }) + this.child, + this.horizontalPosition, + this.verticalPosition, + this.blurnessColor, + this.showBlurness = false, + this.body}) : super(key: key); ///child of type [Widget] which floats across the body based on horizontal and vertical position @@ -122,36 +32,16 @@ class GFFloatingWidget extends StatefulWidget { ///type of bool which allows to show or hide the blurness of the backgroundColor whenever the [child] is used in [GFFloatingWidget] final bool showBlurness; - ///type of [bool] which takes bool values ie, true or false to automatically hide the [GFToast] message - final bool autoDismiss; - - ///type of [Duration] which takes the duration of the fade in animation - final Duration animationDuration; - - ///type of [Duration] which takes the duration of the animation - final Duration duration; - @override _GFFloatingWidgetState createState() => _GFFloatingWidgetState(); } class _GFFloatingWidgetState extends State { Widget child; - Color bgColor; - bool showBackgroundOverlay = false; @override void initState() { child = widget.child; - showBackgroundOverlay = widget.showBlurness; - print('before $showBackgroundOverlay ${widget.showBlurness}'); - if(widget.autoDismiss == true && widget.showBlurness == true) { - print('first $showBackgroundOverlay ${widget.showBlurness}'); - setState(() { - showBackgroundOverlay = !showBackgroundOverlay; - }); - print('last $showBackgroundOverlay ${widget.showBlurness}'); - } super.initState(); } @@ -161,44 +51,33 @@ class _GFFloatingWidgetState extends State { super.didUpdateWidget(oldWidget); } - Color fadeBackgroundOverlay() { - print('in $showBackgroundOverlay ${widget.showBlurness}'); - Timer(widget.duration, () { - if(mounted) { - setState(() { - bgColor = widget.blurnessColor != null ? widget.blurnessColor : Colors.black38; - }); - } - - }); - return bgColor; - } - @override Widget build(BuildContext context) => Stack( - alignment: Alignment.center, - fit: StackFit.loose, - children: [ - Container( - height: MediaQuery.of(context).size.height, - child: widget.body ?? Container(), + alignment: Alignment.center, + fit: StackFit.loose, + children: [ + Container( + height: MediaQuery.of(context).size.height, + child: widget.body ?? Container(), + ), + Positioned( + child: Container( + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + color: widget.showBlurness + ? widget.blurnessColor ?? Colors.black54 + : null, + child: Stack( + children: [ + Positioned( + top: widget.verticalPosition ?? 0.0, + left: widget.horizontalPosition ?? 0.0, + child: widget.child ?? Container(), + ) + ], ), - Positioned( - child: Container( - height: MediaQuery.of(context).size.height, - width: MediaQuery.of(context).size.width, - color: showBackgroundOverlay ? fadeBackgroundOverlay() : null, - child: Stack( - children: [ - Positioned( - top: widget.verticalPosition ?? 0.0, - left: widget.horizontalPosition ?? 0.0, - child: widget.child ?? Container(), - ) - ], - ), - ), - ) - ], - ); + ), + ) + ], + ); } From e9938514d4cc5f9889458de2e266068580c45ebd Mon Sep 17 00:00:00 2001 From: deepikahr Date: Mon, 12 Oct 2020 21:16:14 +0530 Subject: [PATCH 13/25] gfsearchbar tested --- example/lib/main_temp.dart | 661 ------------------ .../bottom_sheet/gf_bottom_sheet.dart | 63 +- lib/components/button/gf_icon_button.dart | 29 +- .../floating_widget/gf_floating_widget.dart | 64 +- .../progress_bar/gf_progress_bar.dart | 7 +- lib/components/toast/gf_toast.dart | 106 +-- 6 files changed, 134 insertions(+), 796 deletions(-) delete mode 100644 example/lib/main_temp.dart diff --git a/example/lib/main_temp.dart b/example/lib/main_temp.dart deleted file mode 100644 index 0de1c6bc..00000000 --- a/example/lib/main_temp.dart +++ /dev/null @@ -1,661 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:getwidget/getwidget.dart'; -import 'dart:async'; - -final List imageList = [ - 'https://cdn.pixabay.com/photo/2017/12/03/18/04/christmas-balls-2995437_960_720.jpg', - 'https://cdn.pixabay.com/photo/2017/12/13/00/23/christmas-3015776_960_720.jpg', - 'https://cdn.pixabay.com/photo/2019/12/19/10/55/christmas-market-4705877_960_720.jpg', - 'https://cdn.pixabay.com/photo/2019/12/20/00/03/road-4707345_960_720.jpg', - 'https://cdn.pixabay.com/photo/2019/12/22/04/18/x-mas-4711785__340.jpg', - 'https://cdn.pixabay.com/photo/2016/11/22/07/09/spruce-1848543__340.jpg', - 'https://cdn.pixabay.com/photo/2017/12/03/18/04/christmas-balls-2995437_960_720.jpg', - 'https://cdn.pixabay.com/photo/2017/12/13/00/23/christmas-3015776_960_720.jpg', -]; - -void main() => runApp(MyApp()); - -class MyApp extends StatelessWidget { - @override - Widget build(BuildContext context) => MaterialApp( - title: 'GetWidget Example', - theme: ThemeData( - primarySwatch: Colors.blue, - ), - debugShowCheckedModeBanner: false, - home: BottomSheetPage(), - ); -} - -// Yashraj$07 - -class BottomSheetPage extends StatefulWidget { - @override - _BottomSheetPageState createState() => _BottomSheetPageState(); -} - -class _BottomSheetPageState extends State { - final GFBottomSheetController _controller = GFBottomSheetController(); - bool isSelected = false; - - bool showFloatingToast = false; - Timer autoTimer; - bool showBlurness = true; - Duration autoTimerDuration = Duration(milliseconds: 400); - - bool check = true; - int groupValue = 0; - - List list = [ - 'Flutter', - 'React', - 'Ionic', - 'Xamarin', - 'Flutter2', - 'React2', - 'Ionic2', - 'Xamarin2', - ]; - - String selected; - - @override - Widget build(BuildContext context) => Scaffold( - appBar: GFAppBar( - title: Text('GF Toasting'), - ), - body: GFFloatingWidget( - verticalPosition: MediaQuery.of(context).size.width * 0.5, - horizontalPosition: MediaQuery.of(context).size.height * 0.02, - showBlurness: showFloatingToast, - blurnessColor: Colors.black87, - child: showFloatingToast - ? GFToast( - backgroundColor: Colors.white, - text: - 'You have succesfully viewed how the floating toast works!!', - textStyle: const TextStyle(color: Colors.black87), - button: GFButton( - onPressed: () { - setState(() { - showFloatingToast = false; - }); - }, - text: 'OK', - type: GFButtonType.transparent, - color: GFColors.SUCCESS, - ), - autoDismiss: false, - ) - : Container(), - body: Column( - children: [ - - - - GFTypography( - child: Text( - selected ?? 'nothing selected yet', - style: TextStyle( - fontSize: 20.0, - color: Colors.black, - fontWeight: FontWeight.w600, - ), - ), - type: GFTypographyType.typo5, - dividerWidth: 45, - dividerColor: Color(0xFF19CA4B), - ), - - - GFIconButton( - onPressed: () { - print('ffffffffff'); - }, - icon: Icon(Icons.ac_unit), - // iconSize: 42.0, - type: GFButtonType.solid, - // shape: GFIconButtonShape.circle, - size: GFSize.SMALL, - // buttonBoxShadow: true, - color: GFColors.WARNING, - // boxShadow: BoxShadow( - // color: Colors.pink, - // blurRadius: 2.0, - // spreadRadius: 1.0, - // offset: Offset.zero, - // ), - // borderSide: BorderSide(color: Colors.pink, width: 1.0, style: BorderStyle.solid), - // borderShape: RoundedRectangleBorder(side: BorderSide(color: Colors.pink, width: 2.0, style: BorderStyle.solid), borderRadius: BorderRadius.zero), - ), - - SizedBox( - height: 22, - ), - - GFIconButton( - onPressed: () { - print('ffffffffff'); - }, - icon: Icon(Icons.ac_unit), - // iconSize: 62.0, - type: GFButtonType.solid, - // shape: GFIconButtonShape.circle, - size: GFSize.MEDIUM, - // buttonBoxShadow: true, - color: GFColors.WARNING, - // boxShadow: BoxShadow( - // color: Colors.pink, - // blurRadius: 2.0, - // spreadRadius: 1.0, - // offset: Offset.zero, - // ), - // borderSide: BorderSide(color: Colors.pink, width: 1.0, style: BorderStyle.solid), - // borderShape: RoundedRectangleBorder(side: BorderSide(color: Colors.pink, width: 2.0, style: BorderStyle.solid), borderRadius: BorderRadius.zero), - ), - - SizedBox( - height: 22, - ), - - GFIconButton( - onPressed: () { - print('ffffffffff'); - }, - icon: Icon(Icons.ac_unit), - // iconSize: 62.0, - type: GFButtonType.transparent, - // shape: GFIconButtonShape.pills, - size: GFSize.LARGE, - // buttonBoxShadow: true, - color: GFColors.WARNING, - // boxShadow: BoxShadow( - // color: Colors.pink, - // blurRadius: 2.0, - // spreadRadius: 1.0, - // offset: Offset.zero, - // ), - // borderSide: BorderSide(color: Colors.pink, width: 1.0, style: BorderStyle.solid), - // borderShape: RoundedRectangleBorder(side: BorderSide(color: Colors.pink, width: 2.0, style: BorderStyle.solid), borderRadius: BorderRadius.circular(22)), - ), - - - GFTypography( - child: Text( - selected ?? 'nothing selected yet', - style: TextStyle( - fontSize: 20.0, - color: Colors.black, - fontWeight: FontWeight.w600, - ), - ), - type: GFTypographyType.typo5, - dividerWidth: 45, - dividerColor: Color(0xFF19CA4B), - ), - - IconButton( - onPressed: () { - print('kkkkkkkkkk'); - }, - icon: Icon(Icons.ac_unit), - iconSize: 42.0, - ), - ], - ), - -// ListView( -// physics: const ScrollPhysics(), -// children: [ -// GFSearchBar( -// // searchBoxInputDecoration: InputDecoration( -// // enabledBorder: OutlineInputBorder( -// // borderSide: BorderSide( -// // color: Colors.teal, -// // ), -// // borderRadius: BorderRadius.circular(50)), -// // ), -// searchList: list, -// // hideSearchBoxWhenItemSelected: false, -// // overlaySearchListHeight: 100.0, -// searchQueryBuilder: (query, list) => -// list.where((item) => item.toLowerCase().contains(query.toLowerCase())).toList(), -// overlaySearchListItemBuilder: (item) => Container( -// padding: const EdgeInsets.all(8), -// child: Text( -// item, -// style: const TextStyle(fontSize: 18), -// ), -// ), -// // noItemsFoundWidget: Container( -// // color: Colors.green, -// // child: Text("no items found..."), -// // ), -// onItemSelected: (item) { -// setState(() { -// selected = item; -// print('$item'); -// }); -// }), -// SizedBox( -// height: 10, -// ), -// GFSearchBar( -// searchBoxInputDecoration: InputDecoration( -// labelText: 'Type Here', -// labelStyle: TextStyle(color: Colors.black26), -// focusedBorder: OutlineInputBorder( -// borderSide: const BorderSide(color: Colors.greenAccent), -// borderRadius: BorderRadius.circular(25), -// ), -// prefixIcon: Icon( -// Icons.search, -// color: Colors.black26, -// ), -// enabledBorder: OutlineInputBorder( -// borderSide: BorderSide(color: Colors.black12), borderRadius: BorderRadius.circular(50)), -// ), -// searchList: list, -// // hideSearchBoxWhenItemSelected: false, -// // overlaySearchListHeight: 100.0, -// searchQueryBuilder: (query, list) => -// list.where((item) => item.toLowerCase().contains(query.toLowerCase())).toList(), -// overlaySearchListItemBuilder: (item) => Container( -// padding: const EdgeInsets.all(8), -// child: Text( -// item, -// style: const TextStyle(fontSize: 18), -// ), -// ), -// // noItemsFoundWidget: Container( -// // color: Colors.green, -// // child: Text("no items found..."), -// // ), -// onItemSelected: (item) { -// setState(() { -// selected = item; -// print('$item'); -// }); -// }), -// SizedBox( -// height: 10, -// ), -// GFTypography( -// child: Text( -// selected ?? 'nothing selected yet', -// style: TextStyle( -// fontSize: 20.0, -// color: Colors.black, -// fontWeight: FontWeight.w600, -// ), -// ), -// type: GFTypographyType.typo5, -// dividerWidth: 45, -// dividerColor: Color(0xFF19CA4B), -// ), -// -// GFSearchBar( -// searchBoxInputDecoration: InputDecoration( -// labelText: 'Type Here', -// labelStyle: TextStyle(color: Colors.black26), -// focusedBorder: OutlineInputBorder( -// borderSide: const BorderSide(color: Colors.greenAccent), -// borderRadius: BorderRadius.circular(25), -// ), -// prefixIcon: Icon( -// Icons.search, -// color: Colors.black26, -// ), -// enabledBorder: OutlineInputBorder( -// borderSide: BorderSide(color: Colors.black12), borderRadius: BorderRadius.circular(50)), -// ), -// searchList: list, -// // hideSearchBoxWhenItemSelected: false, -// // overlaySearchListHeight: 100.0, -// searchQueryBuilder: (query, list) => -// list.where((item) => item.toLowerCase().contains(query.toLowerCase())).toList(), -// overlaySearchListItemBuilder: (item) => Container( -// padding: const EdgeInsets.all(8), -// child: Text( -// item, -// style: const TextStyle(fontSize: 18), -// ), -// ), -// // noItemsFoundWidget: Container( -// // color: Colors.green, -// // child: Text("no items found..."), -// // ), -// onItemSelected: (item) { -// setState(() { -// selected = item; -// print('$item'); -// }); -// }), -// SizedBox( -// height: 10, -// ), -// GFSearchBar( -// searchList: list, -// searchQueryBuilder: (query, list) => list -// .where((item) => -// item.toLowerCase().contains(query.toLowerCase())) -// .toList(), -// overlaySearchListItemBuilder: (item) => Container( -// padding: const EdgeInsets.all(8), -// child: Text( -// item, -// style: const TextStyle(fontSize: 18), -// ), -// ), -// onItemSelected: (item) { -// setState(() { -// print('$item'); -// }); -// }), -// const Padding( -// padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), -// child: GFTypography( -// text: 'Customised SearchBar', -// type: GFTypographyType.typo5, -// dividerWidth: 25, -// dividerColor: Color(0xFF19CA4B), -// ), -// ), -// GFSearchBar( -// searchBoxInputDecoration: InputDecoration( -// labelText: 'Type Here', -// labelStyle: const TextStyle(color: Colors.black26), -// focusedBorder: OutlineInputBorder( -// borderSide: const BorderSide(color: Colors.greenAccent), -// borderRadius: BorderRadius.circular(25), -// ), -// prefixIcon: Icon( -// Icons.search, -// color: Colors.black26, -// ), -// enabledBorder: OutlineInputBorder( -// borderSide: BorderSide(color: Colors.black12), -// borderRadius: BorderRadius.circular(50)), -// ), -// searchList: list, -// searchQueryBuilder: (query, list) => list -// .where((item) => -// item.toLowerCase().contains(query.toLowerCase())) -// .toList(), -// overlaySearchListItemBuilder: (item) => Container( -// padding: const EdgeInsets.all(8), -// child: Text( -// item, -// style: const TextStyle(fontSize: 18), -// ), -// ), -// onItemSelected: (item) { -// setState(() { -// print('$item'); -// }); -// }), -// const Padding( -// padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), -// child: GFTypography( -// text: 'Animated Toasts (Auto Dismissable)', -// type: GFTypographyType.typo5, -// dividerWidth: 25, -// dividerColor: Color(0xFF19CA4B), -// ), -// ), -// GFToast( -// text: 'Auto Dismissable after the given duration !', -// button: GFButton( -// onPressed: () {}, -// text: 'OK', -// type: GFButtonType.transparent, -// color: GFColors.SUCCESS, -// ), -// autoDismiss: true, -// duration: const Duration(seconds: 5), -// ), -// const SizedBox( -// height: 15, -// ), -// const GFToast( -// text: 'Pass true to autoDismiss property to use this effect!', -// autoDismiss: true, -// duration: Duration(seconds: 2), -// ), -// const Padding( -// padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), -// child: GFTypography( -// text: 'Basic Toasts', -// type: GFTypographyType.typo5, -// dividerWidth: 25, -// dividerColor: Color(0xFF19CA4B), -// ), -// ), -// GFToast( -// text: 'Paired Succesfully !', -// button: GFButton( -// onPressed: () {}, -// text: 'OK', -// type: GFButtonType.transparent, -// color: GFColors.SUCCESS, -// ), -// autoDismiss: false, -// duration: const Duration(milliseconds: 300), -// alignment: Alignment.topLeft, -// ), -// const SizedBox( -// height: 15, -// ), -// GFToast( -// text: -// 'This item already has the label “travel”. You can add new label. !', -// button: GFButton( -// onPressed: () {}, -// text: 'OK', -// type: GFButtonType.transparent, -// color: GFColors.SUCCESS, -// ), -// autoDismiss: false, -// ), -// const Padding( -// padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), -// child: GFTypography( -// text: 'Rounded Toasts', -// type: GFTypographyType.typo5, -// dividerWidth: 25, -// dividerColor: Color(0xFF19CA4B), -// ), -// ), -// GFToast( -// text: 'Paired Succesfully !', -// button: GFButton( -// onPressed: () {}, -// text: 'OK', -// type: GFButtonType.transparent, -// color: GFColors.SUCCESS, -// ), -// type: GFToastType.rounded, -// autoDismiss: false, -// alignment: Alignment.topLeft, -// ), -// const SizedBox( -// height: 15, -// ), -// GFToast( -// text: -// 'This item already has the label “travel”. You can add a new label. !', -// button: GFButton( -// onPressed: () {}, -// text: 'OK', -// type: GFButtonType.transparent, -// color: GFColors.SUCCESS, -// ), -// autoDismiss: false, -// type: GFToastType.rounded, -// alignment: Alignment.topLeft, -// ), -// const Padding( -// padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), -// child: GFTypography( -// text: 'Full Width Toasts', -// type: GFTypographyType.typo5, -// dividerWidth: 25, -// dividerColor: Color(0xFF19CA4B), -// ), -// ), -// GFToast( -// text: 'Paired Succesfully !', -// button: GFButton( -// onPressed: () {}, -// text: 'OK', -// type: GFButtonType.transparent, -// color: GFColors.SUCCESS, -// ), -// type: GFToastType.fullWidth, -// autoDismiss: false, -// ), -// const SizedBox( -// height: 15, -// ), -// GFToast( -// text: -// 'This item already has the label “travel”. You can add a new label.!', -// button: GFButton( -// onPressed: () {}, -// text: 'OK', -// type: GFButtonType.transparent, -// color: GFColors.SUCCESS, -// ), -// autoDismiss: false, -// type: GFToastType.fullWidth, -// ), -// const Padding( -// padding: EdgeInsets.only(left: 15, top: 30, bottom: 10), -// child: GFTypography( -// text: 'Floating Toast', -// type: GFTypographyType.typo5, -// dividerWidth: 25, -// dividerColor: Color(0xFF19CA4B), -// ), -// ), -// Container( -// margin: const EdgeInsets.only(left: 40, right: 40), -// child: GFButton( -// onPressed: () { -// setState(() { -// showFloatingToast = !showFloatingToast; -// }); -// }, -// text: 'View Floating Toast', -// ), -// ), -// const SizedBox( -// height: 20, -// ), -// ], -// ), - ), - bottomSheet: GFBottomSheet( - controller: _controller, - maxContentHeight: 300, - // minContentHeight: 200, - enableExpandableContent: true, - stickyHeaderHeight: 70, - stickyHeader: const GFListTile( - padding: EdgeInsets.zero, - avatar: GFAvatar( - // backgroundImage: AssetImage('lib/assets/images/img.png'), - ), - titleText: 'Eva Mendez', - subtitleText: '11 minutes ago', - ), - contentBody: Container( - margin: EdgeInsets.symmetric(horizontal: 15, vertical: 10), - child: ListView( - shrinkWrap: true, - physics: const ScrollPhysics(), - children: [ - // Container( - // margin: EdgeInsets.symmetric(horizontal: 10), - // height: 60, - // padding: EdgeInsets.only(bottom: 15), - // child: TextFormField( - // - // initialValue: "Enter Message", - // keyboardType: TextInputType.emailAddress, - // decoration: InputDecoration( - // - // errorBorder: OutlineInputBorder( - // borderSide: BorderSide( - // width: 0, color: Color(0xFFF44242))), - // errorStyle: TextStyle(color: Color(0xFFF44242)), - // contentPadding: EdgeInsets.all(10), - // enabledBorder: const OutlineInputBorder( - // borderSide: const BorderSide(color: Colors.grey, width: 0.0), - // ), - // - // focusedBorder: OutlineInputBorder( - // borderSide: BorderSide(color: Colors.grey), - // ), - // fillColor: Colors.white, - // focusColor: Colors.white), - // ), - // ), - Container( - child: Row( - children: [ - Container( - width: 30, - height: 30, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(50), - image: DecorationImage( - image: AssetImage('assets/images/pixa.jpg'))), - ), - Container( - margin: EdgeInsets.only(left: 6), - child: Text( - 'Add to your story', - style: TextStyle(color: Colors.blue), - )) - ], - ), - ), - ListView.builder( - physics: ScrollPhysics(), - shrinkWrap: true, - scrollDirection: Axis.vertical, - itemCount: 3, - itemBuilder: (BuildContext context, int index) { - return SingleChildScrollView( - child: InkWell( - child: GFListTile( - avatar: GFAvatar( - backgroundImage: - AssetImage('assets/images/pixa.jpg'), - size: 20, - ), - subtitleText: 'John Mendez', - icon: Container( - width: 66, - height: 30, - child: GFButton( - onPressed: () {}, - color: GFColors.PRIMARY, - child: Center( - child: Text( - 'Send', - style: TextStyle(color: Colors.white), - )), - ), - ), - ), - )); - }), - ], - ), - ), - ), - ); -} diff --git a/lib/components/bottom_sheet/gf_bottom_sheet.dart b/lib/components/bottom_sheet/gf_bottom_sheet.dart index 0af334c1..0772f64d 100644 --- a/lib/components/bottom_sheet/gf_bottom_sheet.dart +++ b/lib/components/bottom_sheet/gf_bottom_sheet.dart @@ -153,38 +153,39 @@ class _GFBottomSheetState extends State child: widget.contentBody), ), ) - : widget.controller.height == widget.minContentHeight ? Container() - : StreamBuilder( - stream: _streamController.stream, - initialData: widget.controller.height, - builder: (BuildContext context, AsyncSnapshot snapshot) => - AnimatedContainer( - curve: Curves.easeOut, - duration: Duration( - milliseconds: widget.controller.animationDuration), - height: snapshot.hasData == null - ? widget.minContentHeight - : snapshot.data, - child: GestureDetector( - onVerticalDragUpdate: (DragUpdateDetails details) { - if (((widget.controller.height - details.delta.dy) > - widget.minContentHeight) && - ((widget.controller.height - details.delta.dy) < - (MediaQuery.of(context).size.height * 0.8 - - widget.stickyFooterHeight - - widget.stickyHeaderHeight))) { - isDragDirectionUp = details.delta.dy <= 0; - widget.controller.height -= details.delta.dy; - } - _streamController.add(widget.controller.height); - }, - onVerticalDragEnd: _onVerticalDragEnd, - onTap: _onTap, - behavior: HitTestBehavior.translucent, - child: widget.contentBody, + : widget.controller.height == widget.minContentHeight + ? Container() + : StreamBuilder( + stream: _streamController.stream, + initialData: widget.controller.height, + builder: (BuildContext context, AsyncSnapshot snapshot) => + AnimatedContainer( + curve: Curves.easeOut, + duration: Duration( + milliseconds: widget.controller.animationDuration), + height: snapshot.hasData == null + ? widget.minContentHeight + : snapshot.data, + child: GestureDetector( + onVerticalDragUpdate: (DragUpdateDetails details) { + if (((widget.controller.height - details.delta.dy) > + widget.minContentHeight) && + ((widget.controller.height - details.delta.dy) < + (MediaQuery.of(context).size.height * 0.8 - + widget.stickyFooterHeight - + widget.stickyHeaderHeight))) { + isDragDirectionUp = details.delta.dy <= 0; + widget.controller.height -= details.delta.dy; + } + _streamController.add(widget.controller.height); + }, + onVerticalDragEnd: _onVerticalDragEnd, + onTap: _onTap, + behavior: HitTestBehavior.translucent, + child: widget.contentBody, + ), + ), ), - ), - ), widget.stickyFooter == null ? Container() : AnimatedBuilder( diff --git a/lib/components/button/gf_icon_button.dart b/lib/components/button/gf_icon_button.dart index 227407e5..a228c390 100644 --- a/lib/components/button/gf_icon_button.dart +++ b/lib/components/button/gf_icon_button.dart @@ -111,7 +111,7 @@ class _GFIconButtonState extends State { BoxShadow boxShadow; double height; double width; - double iconPixel = 18.0; + double iconPixel = 18; @override void initState() { @@ -230,7 +230,7 @@ class _GFIconButtonState extends State { } else if (widget.size == GFSize.MEDIUM) { height = 35.0; width = 35.0; - iconPixel = 28.0; + iconPixel = 28.0; } else if (widget.size == GFSize.LARGE) { height = 40.0; width = 40.0; @@ -246,7 +246,7 @@ class _GFIconButtonState extends State { // : width, padding: widget.padding, child: SizedBox( - height: widget.iconSize != 0 ? widget.iconSize : iconPixel, + height: widget.iconSize != 0 ? widget.iconSize : iconPixel, width: widget.iconSize != 0 ? widget.iconSize : iconPixel, child: Align( alignment: Alignment.center, @@ -319,15 +319,13 @@ class _GFIconButtonState extends State { // : widget.shape == GFIconButtonShape.circle // ? height + 6 // : width, - decoration: - widget.type == GFButtonType.solid ? getBoxShadow() : null, + decoration: widget.type == GFButtonType.solid ? getBoxShadow() : null, child: Material( shape: widget.type == GFButtonType.transparent ? null : widget.borderShape ?? shapeBorderType, - color: widget.onPressed != null - ? getColor() - : getDisabledFillColor(), + color: + widget.onPressed != null ? getColor() : getDisabledFillColor(), type: widget.type == GFButtonType.transparent ? MaterialType.transparency : MaterialType.button, @@ -338,15 +336,16 @@ class _GFIconButtonState extends State { hoverColor: widget.hoverColor ?? Theme.of(context).hoverColor, highlightColor: widget.highlightColor ?? Theme.of(context).highlightColor, - splashColor: - widget.splashColor ?? Theme.of(context).splashColor, + splashColor: widget.splashColor ?? Theme.of(context).splashColor, radius: math.max( Material.defaultSplashRadius, - (widget.iconSize > 0.0 ? widget.iconSize : iconPixel + - math.min( - widget.padding.horizontal, - widget.padding.vertical, - )) * + (widget.iconSize > 0.0 + ? widget.iconSize + : iconPixel + + math.min( + widget.padding.horizontal, + widget.padding.vertical, + )) * 0.7), ), ), diff --git a/lib/components/floating_widget/gf_floating_widget.dart b/lib/components/floating_widget/gf_floating_widget.dart index 3c32a0cf..1be9abc8 100644 --- a/lib/components/floating_widget/gf_floating_widget.dart +++ b/lib/components/floating_widget/gf_floating_widget.dart @@ -6,12 +6,12 @@ class GFFloatingWidget extends StatefulWidget { /// Inside floating widget [GFToast] can be used as body. See [GFToast] const GFFloatingWidget( {Key key, - this.child, - this.horizontalPosition, - this.verticalPosition, - this.blurnessColor, - this.showBlurness = false, - this.body}) + this.child, + this.horizontalPosition, + this.verticalPosition, + this.blurnessColor, + this.showBlurness = false, + this.body}) : super(key: key); ///child of type [Widget] which floats across the body based on horizontal and vertical position @@ -53,31 +53,31 @@ class _GFFloatingWidgetState extends State { @override Widget build(BuildContext context) => Stack( - alignment: Alignment.center, - fit: StackFit.loose, - children: [ - Container( - height: MediaQuery.of(context).size.height, - child: widget.body ?? Container(), - ), - Positioned( - child: Container( - height: MediaQuery.of(context).size.height, - width: MediaQuery.of(context).size.width, - color: widget.showBlurness - ? widget.blurnessColor ?? Colors.black54 - : null, - child: Stack( - children: [ - Positioned( - top: widget.verticalPosition ?? 0.0, - left: widget.horizontalPosition ?? 0.0, - child: widget.child ?? Container(), - ) - ], + alignment: Alignment.center, + fit: StackFit.loose, + children: [ + Container( + height: MediaQuery.of(context).size.height, + child: widget.body ?? Container(), ), - ), - ) - ], - ); + Positioned( + child: Container( + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + color: widget.showBlurness + ? widget.blurnessColor ?? Colors.black54 + : null, + child: Stack( + children: [ + Positioned( + top: widget.verticalPosition ?? 0.0, + left: widget.horizontalPosition ?? 0.0, + child: widget.child ?? Container(), + ) + ], + ), + ), + ) + ], + ); } diff --git a/lib/components/progress_bar/gf_progress_bar.dart b/lib/components/progress_bar/gf_progress_bar.dart index a20f9106..2b4e2456 100644 --- a/lib/components/progress_bar/gf_progress_bar.dart +++ b/lib/components/progress_bar/gf_progress_bar.dart @@ -125,7 +125,6 @@ class _GFProgressBarState extends State double _progressPercent = 0; double _percentage = 0; - @override void initState() { super.initState(); @@ -133,11 +132,11 @@ class _GFProgressBarState extends State _animationController = AnimationController( duration: Duration(milliseconds: widget.animationDuration), vsync: this); - _animation = - Tween(begin: _progressPercent, end: widget.percentage).animate(_animationController) + _animation = Tween(begin: _progressPercent, end: widget.percentage) + .animate(_animationController) ..addListener(() { setState(() { - _progressPercent = _animation.value; + _progressPercent = _animation.value; }); }); _animationController.forward(); diff --git a/lib/components/toast/gf_toast.dart b/lib/components/toast/gf_toast.dart index dbcf734f..030444b5 100644 --- a/lib/components/toast/gf_toast.dart +++ b/lib/components/toast/gf_toast.dart @@ -79,8 +79,8 @@ class _GFToastState extends State with TickerProviderStateMixin { if (mounted) { animationController.forward(); fadeAnimationController = - AnimationController(duration: widget.animationDuration, vsync: this) - ..addListener(() => setState(() {})); + AnimationController(duration: widget.animationDuration, vsync: this) + ..addListener(() => setState(() {})); fadeAnimation = Tween( begin: 0, end: 1, @@ -117,59 +117,59 @@ class _GFToastState extends State with TickerProviderStateMixin { Widget build(BuildContext context) => hideToast ? Container() : FadeTransition( - opacity: widget.autoDismiss ? fadeAnimation : animation, - child: Column( - children: [ - Container( - width: widget.type == GFToastType.fullWidth - ? MediaQuery.of(context).size.width - : widget.width ?? MediaQuery.of(context).size.width * 0.885, - constraints: const BoxConstraints(minHeight: 50), - margin: widget.type == GFToastType.fullWidth - ? const EdgeInsets.only(left: 0, right: 0) - : const EdgeInsets.only(left: 10, right: 10), - padding: const EdgeInsets.all(10), - decoration: BoxDecoration( - borderRadius: widget.type == GFToastType.basic - ? BorderRadius.circular(0) - : widget.type == GFToastType.rounded - ? BorderRadius.circular(10) - : BorderRadius.zero, - color: widget.backgroundColor ?? const Color(0xff323232), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.40), - blurRadius: 6, - ) - ]), - child: Row( + opacity: widget.autoDismiss ? fadeAnimation : animation, + child: Column( children: [ - Flexible( - flex: 7, - fit: FlexFit.tight, - child: Align( - alignment: widget.alignment ?? Alignment.topLeft, - child: widget.text != null - ? Text(widget.text, style: widget.textStyle) - : (widget.child ?? Container()), + Container( + width: widget.type == GFToastType.fullWidth + ? MediaQuery.of(context).size.width + : widget.width ?? MediaQuery.of(context).size.width * 0.885, + constraints: const BoxConstraints(minHeight: 50), + margin: widget.type == GFToastType.fullWidth + ? const EdgeInsets.only(left: 0, right: 0) + : const EdgeInsets.only(left: 10, right: 10), + padding: const EdgeInsets.all(10), + decoration: BoxDecoration( + borderRadius: widget.type == GFToastType.basic + ? BorderRadius.circular(0) + : widget.type == GFToastType.rounded + ? BorderRadius.circular(10) + : BorderRadius.zero, + color: widget.backgroundColor ?? const Color(0xff323232), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.40), + blurRadius: 6, + ) + ]), + child: Row( + children: [ + Flexible( + flex: 7, + fit: FlexFit.tight, + child: Align( + alignment: widget.alignment ?? Alignment.topLeft, + child: widget.text != null + ? Text(widget.text, style: widget.textStyle) + : (widget.child ?? Container()), + ), + ), + const SizedBox( + width: 10, + ), + widget.button != null + ? Flexible( + flex: 4, + fit: FlexFit.tight, + child: Align( + alignment: Alignment.topRight, + child: widget.button, + )) + : Container() + ], ), ), - const SizedBox( - width: 10, - ), - widget.button != null - ? Flexible( - flex: 4, - fit: FlexFit.tight, - child: Align( - alignment: Alignment.topRight, - child: widget.button, - )) - : Container() ], ), - ), - ], - ), - ); -} \ No newline at end of file + ); +} From 9578e71609ec2cdceea8b9dca0a34852db33fb08 Mon Sep 17 00:00:00 2001 From: deepikahr Date: Tue, 13 Oct 2020 22:31:49 +0530 Subject: [PATCH 14/25] changes in gfdropdown and gfmultiselect --- example/lib/main_temp.dart | 103 ++++++++++++++++++++ lib/components/dropdown/gf_dropdown.dart | 17 ++-- lib/components/dropdown/gf_multiselect.dart | 102 ++++++++++++------- lib/getwidget.dart | 4 +- 4 files changed, 182 insertions(+), 44 deletions(-) create mode 100644 example/lib/main_temp.dart diff --git a/example/lib/main_temp.dart b/example/lib/main_temp.dart new file mode 100644 index 00000000..59c15e7b --- /dev/null +++ b/example/lib/main_temp.dart @@ -0,0 +1,103 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:getwidget/getwidget.dart'; + +void main() => runApp(MyApp()); + +class MyApp extends StatelessWidget { + @override + Widget build(BuildContext context) => MaterialApp( + title: 'GetWidget Example', + theme: ThemeData( + primarySwatch: Colors.blue, + ), + debugShowCheckedModeBanner: false, + home: Example(), + ); +} + +class Example extends StatefulWidget { + @override + _ExampleState createState() => _ExampleState(); +} + +class _ExampleState extends State { + String dropdownValue = 'One'; + + @override + Widget build(BuildContext context) => Scaffold( + appBar: GFAppBar( + title: const Text('drop down'), + ), + backgroundColor: Colors.teal, + body: Column( + children: [ + const GFMultiSelect( + items: ['Running', 'Walking', 'Eating', 'Sleeping', 'Playing', 'Drinking', 'Jogging'], + titleText: 'Select options : ', + // onSelect: (){ + // + // }, + // dropdownTitleTileMargin: EdgeInsets.all(2), + // dropdownTitleTilePadding: EdgeInsets.all(4), + // hideDropdownUnderline: true, + // dropdownUnderlineColor: GFColors.DANGER, + // expandedicon: Icon(Icons.edit, color: Colors.tealAccent,), + // collapsedicon: Text('close'), + // submitbutton: Text('OK'), + + // selectedTextStyle : TextStyle(fontSize: 16, fontWeight: FontWeight.w500, color: Colors.pink), + // color : Colors.blueGrey, + // avatar : GFAvatar(backgroundColor: Colors.red,), + // padding : EdgeInsets.all(6), + // margin : EdgeInsets.all(6), + // size : GFSize.LARGE, + // type : GFCheckboxType.basic, + // checkColor : GFColors.ALT, + // activebgColor : GFColors.DARK, + // inactivebgColor : GFColors.SECONDARY, + // activeBorderColor : GFColors.SUCCESS, + // inactiveBorderColor : GFColors.LIGHT, + // expandedicon : Icons.keyboard_arrow_down, + // collapsedicon : Icons.keyboard_arrow_up, + // dropdownbgColor : Colors.white, + // activeIcon : Icon( + // Icons.check, + // size: 20, + // color: GFColors.DARK, + // ), + // inactiveIcon : Icon( + // Icons.check_box_outline_blank, + // size: 20, + // color: GFColors.DARK, + // ), + // custombgColor : GFColors.SUCCESS, + // selected : false, + ), + const SizedBox(height: 22,), + GFDropdown( + // isExpanded: true, + isDense: true, + // padding: const EdgeInsets.all(12), + // borderRadius: BorderRadius.circular(12), + // border: const BorderSide(color: Colors.pink, width: 2, style: BorderStyle.solid), + // dropdownColor: Colors.tealAccent, + value: dropdownValue, + onChanged: (newValue) { + print('val $newValue'); + setState(() { + dropdownValue = newValue; + }); + }, + items: ['One', 'Two', 'Free', 'Four'] + .map((value) => + DropdownMenuItem( + value: value, + child: Text(value), + ) + ).toList(), + ), + ], + ), + ); +} diff --git a/lib/components/dropdown/gf_dropdown.dart b/lib/components/dropdown/gf_dropdown.dart index a8b4f137..5ca281ef 100644 --- a/lib/components/dropdown/gf_dropdown.dart +++ b/lib/components/dropdown/gf_dropdown.dart @@ -27,7 +27,7 @@ class GFDropdown extends StatefulWidget { this.dropdownColor, this.padding = const EdgeInsets.all(5), this.borderRadius = const BorderRadius.all(Radius.circular(4)), - this.borderColor}) + this.border}) : super(key: key); final DropdownButtonBuilder selectedItemBuilder; @@ -44,7 +44,7 @@ class GFDropdown extends StatefulWidget { final T value; /// the color of the border of the dropdown button - final Color borderColor; + final BorderSide border; ///The padding given inside the dropdown final EdgeInsets padding; @@ -114,12 +114,15 @@ class GFDropdown extends StatefulWidget { class _GFDropdownState extends State { @override - Widget build(BuildContext context) => Card( - child: Container( + Widget build(BuildContext context) => Material( + shape: RoundedRectangleBorder( + side: widget.border ?? + const BorderSide( + color: Colors.white, width: 1, style: BorderStyle.solid), + borderRadius: widget.borderRadius, + ), + child: Padding( padding: widget.padding, - decoration: BoxDecoration( - borderRadius: widget.borderRadius, - border: Border.all(color: widget.borderColor ?? Colors.white)), child: DropdownButton( items: widget.items, selectedItemBuilder: widget.selectedItemBuilder, diff --git a/lib/components/dropdown/gf_multiselect.dart b/lib/components/dropdown/gf_multiselect.dart index 57ee6b80..4cd6c7fe 100644 --- a/lib/components/dropdown/gf_multiselect.dart +++ b/lib/components/dropdown/gf_multiselect.dart @@ -1,27 +1,34 @@ import 'package:flutter/material.dart'; import 'package:getwidget/getwidget.dart'; -class GFMultiSelect extends StatefulWidget { +class GFMultiSelect extends StatefulWidget { /// const GFMultiSelect({ - this.titleText, - this.selectedTextStyle = - const TextStyle(fontSize: 16, fontWeight: FontWeight.w500), + @required this.items, + @required this.titleText, + this.selectedTextStyle = const TextStyle(fontSize: 16, fontWeight: FontWeight.w500), this.color, this.avatar, - this.padding = const EdgeInsets.all(0), + this.padding = const EdgeInsets.all(5), this.margin = const EdgeInsets.all(5), - this.size = GFSize.MEDIUM, + this.size = GFSize.SMALL, this.type = GFCheckboxType.basic, this.checkColor = GFColors.WHITE, this.activebgColor = GFColors.WHITE, this.inactivebgColor = GFColors.WHITE, this.activeBorderColor = GFColors.WHITE, this.inactiveBorderColor = GFColors.WHITE, - this.items, this.submitbutton, - this.expandedicon = Icons.keyboard_arrow_down, - this.collapsedicon = Icons.keyboard_arrow_up, + this.expandedicon = const Icon( + Icons.keyboard_arrow_down, + color: Colors.black87, + size: 30, + ), + this.collapsedicon = const Icon( + Icons.keyboard_arrow_up, + color: Colors.black87, + size: 30, + ), this.dropdownbgColor = Colors.white, this.activeIcon = const Icon( Icons.check, @@ -31,6 +38,14 @@ class GFMultiSelect extends StatefulWidget { this.inactiveIcon, this.custombgColor = GFColors.SUCCESS, this.selected = false, + this.dropdownTitleTileBorder, + this.dropdownTitleTileBorderRadius = const BorderRadius.all(Radius.circular(4)), + this.dropdownTitleTileColor = GFColors.WHITE, + this.hideDropdownUnderline = false, + this.dropdownUnderlineColor = Colors.black12, + this.dropdownTitleTileMargin = const EdgeInsets.all(16), + this.dropdownTitleTilePadding = const EdgeInsets.all(12), + this.onSelect, Key key, }) : assert(selected != null), super(key: key); @@ -98,15 +113,34 @@ class GFMultiSelect extends StatefulWidget { final TextStyle selectedTextStyle; - final IconData expandedicon; + final Widget expandedicon; + + final Widget collapsedicon; + + /// The border radius of the dropdown. + final BorderRadius dropdownTitleTileBorderRadius; + + /// The border radius of the dropdown. + final Border dropdownTitleTileBorder; + + /// The border radius of the dropdown. + final dynamic dropdownTitleTileColor; + + final bool hideDropdownUnderline; - final IconData collapsedicon; + final dynamic dropdownUnderlineColor; + + final EdgeInsets dropdownTitleTileMargin; + + final EdgeInsets dropdownTitleTilePadding; + + final ValueChanged onSelect; @override _GFMultiSelectState createState() => _GFMultiSelectState(); } -class _GFMultiSelectState extends State { +class _GFMultiSelectState extends State> { bool check = true; bool isdrop = false; bool check1 = false; @@ -145,33 +179,32 @@ class _GFMultiSelectState extends State { }); }, child: Container( - - // height: 40, - width: MediaQuery.of(context).size.width, - decoration: const BoxDecoration( - border: - Border(bottom: BorderSide(color: Colors.black12))), + margin: widget.dropdownTitleTileMargin, + padding: widget.dropdownTitleTilePadding, + decoration: BoxDecoration( + color: widget.dropdownTitleTileColor, + border: widget.dropdownTitleTileBorder, + borderRadius: widget.dropdownTitleTileBorderRadius + ), child: Container( + decoration: BoxDecoration( + border: widget.hideDropdownUnderline ? const Border(bottom: BorderSide(color: Colors.white)) + : Border(bottom: BorderSide(color: widget.dropdownUnderlineColor)), + ), child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Expanded( - child: Container( - padding: const EdgeInsets.only(bottom: 10), - child: Text(_selectedTitles.join(' , ').toString(), - style: widget.selectedTextStyle), - )), - Icon( - !isdrop ? widget.expandedicon : widget.collapsedicon, - color: Colors.black87, - size: 30, - ), + _selectedTitles.isEmpty ? + Expanded(child: Text(widget.titleText, style: widget.selectedTextStyle)) : + Expanded(child: Text(_selectedTitles.join(', ').toString(), style: widget.selectedTextStyle)), + !isdrop ? widget.expandedicon : widget.collapsedicon, ], ), ))), isdrop ? Container( + padding: const EdgeInsets.symmetric(vertical: 6), decoration: BoxDecoration( color: widget.dropdownbgColor, boxShadow: const [ @@ -181,7 +214,6 @@ class _GFMultiSelectState extends State { ) ], ), - height: 300, child: SingleChildScrollView( child: Column( children: [ @@ -191,9 +223,9 @@ class _GFMultiSelectState extends State { (index) => GFCheckboxListTile( value: _selectedTitles .contains(widget.items[index]), - onChanged: (bool selected) { + onChanged: widget.onSelect != null ? widget.onSelect : (bool selected) { _controller.text; - print(selected); + print('index $index'); _onItemSelect( selected, widget.items[index]); }, @@ -222,7 +254,7 @@ class _GFMultiSelectState extends State { isdrop = !isdrop; }); }, - child: widget.submitbutton, + child: widget.submitbutton ?? const Text('OK'), ) ], ), diff --git a/lib/getwidget.dart b/lib/getwidget.dart index bd0a7242..c6c38e86 100644 --- a/lib/getwidget.dart +++ b/lib/getwidget.dart @@ -22,8 +22,8 @@ export 'package:getwidget/components/checkbox/gf_checkbox.dart'; export 'package:getwidget/components/checkbox_list_tile/gf_checkbox_list_tile.dart'; export 'package:getwidget/components/drawer/gf_drawer.dart'; export 'package:getwidget/components/drawer/gf_drawer_header.dart'; -// export 'package:getwidget/components/dropdown/gf_dropdown.dart'; -// export 'package:getwidget/components/dropdown/gf_multiselect.dart'; +export 'package:getwidget/components/dropdown/gf_dropdown.dart'; +export 'package:getwidget/components/dropdown/gf_multiselect.dart'; export 'package:getwidget/components/floating_widget/gf_floating_widget.dart'; export 'package:getwidget/components/image/gf_image_overlay.dart'; export 'package:getwidget/components/intro_screen/gf_intro_screen_bottom_navigation_bar.dart'; From 21db984e7bb9e92cea98fcc9912c354f65dd8abc Mon Sep 17 00:00:00 2001 From: deepikahr Date: Wed, 14 Oct 2020 17:28:29 +0530 Subject: [PATCH 15/25] onchangd added --- example/lib/main_temp.dart | 27 +++++++++-------- lib/components/dropdown/gf_multiselect.dart | 32 +++++++++++++-------- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/example/lib/main_temp.dart b/example/lib/main_temp.dart index 59c15e7b..718cce3e 100644 --- a/example/lib/main_temp.dart +++ b/example/lib/main_temp.dart @@ -22,22 +22,24 @@ class Example extends StatefulWidget { } class _ExampleState extends State { - String dropdownValue = 'One'; + String dropdownValue; + List dropList = ['Running', 'Walking', 'Eating', 'Sleeping', 'Playing', 'Drinking', 'Jogging']; + String selected; @override Widget build(BuildContext context) => Scaffold( appBar: GFAppBar( - title: const Text('drop down'), + title: const Text('drop down '), ), backgroundColor: Colors.teal, body: Column( children: [ - const GFMultiSelect( - items: ['Running', 'Walking', 'Eating', 'Sleeping', 'Playing', 'Drinking', 'Jogging'], - titleText: 'Select options : ', - // onSelect: (){ - // - // }, + GFMultiSelect( + items: dropList, + dropDownTitleTileText: 'Select options : ', + onSelect: (value){ + print('sel $value '); + }, // dropdownTitleTileMargin: EdgeInsets.all(2), // dropdownTitleTilePadding: EdgeInsets.all(4), // hideDropdownUnderline: true, @@ -72,12 +74,13 @@ class _ExampleState extends State { // color: GFColors.DARK, // ), // custombgColor : GFColors.SUCCESS, - // selected : false, + selected : false, ), const SizedBox(height: 22,), GFDropdown( // isExpanded: true, isDense: true, + hint: Text('sele $selected'), // padding: const EdgeInsets.all(12), // borderRadius: BorderRadius.circular(12), // border: const BorderSide(color: Colors.pink, width: 2, style: BorderStyle.solid), @@ -86,14 +89,14 @@ class _ExampleState extends State { onChanged: (newValue) { print('val $newValue'); setState(() { - dropdownValue = newValue; + selected = newValue.value; }); }, - items: ['One', 'Two', 'Free', 'Four'] + items: ['One', 'Two', 'Free', 'Four'].asMap().entries .map((value) => DropdownMenuItem( value: value, - child: Text(value), + child: Text('${value.value}'), ) ).toList(), ), diff --git a/lib/components/dropdown/gf_multiselect.dart b/lib/components/dropdown/gf_multiselect.dart index 4cd6c7fe..c1dcec41 100644 --- a/lib/components/dropdown/gf_multiselect.dart +++ b/lib/components/dropdown/gf_multiselect.dart @@ -5,7 +5,8 @@ class GFMultiSelect extends StatefulWidget { /// const GFMultiSelect({ @required this.items, - @required this.titleText, + @required this.onSelect, + this.dropDownTitleTileText = 'Select : ', this.selectedTextStyle = const TextStyle(fontSize: 16, fontWeight: FontWeight.w500), this.color, this.avatar, @@ -45,13 +46,12 @@ class GFMultiSelect extends StatefulWidget { this.dropdownUnderlineColor = Colors.black12, this.dropdownTitleTileMargin = const EdgeInsets.all(16), this.dropdownTitleTilePadding = const EdgeInsets.all(12), - this.onSelect, Key key, }) : assert(selected != null), super(key: key); ///type of [String] used to pass text, alternative to title property and gets higher priority than title - final String titleText; + final String dropDownTitleTileText; /// The GFListTile's background color. Can be given [Color] or [GFColors] final Color color; @@ -105,7 +105,7 @@ class GFMultiSelect extends StatefulWidget { /// Normally, this property is left to its default value, false. final bool selected; - final List items; + final List items; final Widget submitbutton; @@ -134,7 +134,7 @@ class GFMultiSelect extends StatefulWidget { final EdgeInsets dropdownTitleTilePadding; - final ValueChanged onSelect; + final ValueChanged> onSelect; @override _GFMultiSelectState createState() => _GFMultiSelectState(); @@ -144,19 +144,23 @@ class _GFMultiSelectState extends State> { bool check = true; bool isdrop = false; bool check1 = false; + bool isItemSelected = false; final _controller = TextEditingController(); final List _selectedTitles = []; + final List _selectedTitlesIndex = []; - void _onItemSelect(bool selected, String title) { + void _onItemSelect(bool selected, int index) { if (selected == true) { setState(() { - _selectedTitles.add(title); + _selectedTitles.add(widget.items[index]); + _selectedTitlesIndex.add(index); }); } else { setState(() { - _selectedTitles.remove(title); + _selectedTitles.remove(widget.items[index]); + _selectedTitlesIndex.remove(index); }); } } @@ -196,7 +200,7 @@ class _GFMultiSelectState extends State> { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ _selectedTitles.isEmpty ? - Expanded(child: Text(widget.titleText, style: widget.selectedTextStyle)) : + Expanded(child: Text(widget.dropDownTitleTileText, style: widget.selectedTextStyle)) : Expanded(child: Text(_selectedTitles.join(', ').toString(), style: widget.selectedTextStyle)), !isdrop ? widget.expandedicon : widget.collapsedicon, ], @@ -223,11 +227,15 @@ class _GFMultiSelectState extends State> { (index) => GFCheckboxListTile( value: _selectedTitles .contains(widget.items[index]), - onChanged: widget.onSelect != null ? widget.onSelect : (bool selected) { + onChanged: (bool selected) { _controller.text; - print('index $index'); _onItemSelect( - selected, widget.items[index]); + selected, index); + if (selected == null) { + widget.onSelect(null); + return; + } + widget.onSelect(_selectedTitlesIndex); }, selected: widget.selected, avatar: widget.avatar, From 4a5cb48f9e77dca345c075886b360f723b6ebaeb Mon Sep 17 00:00:00 2001 From: deepikahr Date: Wed, 14 Oct 2020 18:36:21 +0530 Subject: [PATCH 16/25] extra features added --- example/lib/main_temp.dart | 71 ++++--- lib/components/dropdown/gf_multiselect.dart | 212 +++++++++++--------- 2 files changed, 155 insertions(+), 128 deletions(-) diff --git a/example/lib/main_temp.dart b/example/lib/main_temp.dart index 718cce3e..f95e3607 100644 --- a/example/lib/main_temp.dart +++ b/example/lib/main_temp.dart @@ -32,55 +32,59 @@ class _ExampleState extends State { title: const Text('drop down '), ), backgroundColor: Colors.teal, - body: Column( + body: SingleChildScrollView( + child: Column( children: [ GFMultiSelect( items: dropList, - dropDownTitleTileText: 'Select options : ', onSelect: (value){ print('sel $value '); }, + // dropDownTitleTileText: 'Select options : ', + // dropDownTitleTileHintText: 'select', + // dropDownTitleTileHintTextStyle: const TextStyle(fontSize: 12, fontWeight: FontWeight.w500, color: Colors.pink), // dropdownTitleTileMargin: EdgeInsets.all(2), // dropdownTitleTilePadding: EdgeInsets.all(4), // hideDropdownUnderline: true, - // dropdownUnderlineColor: GFColors.DANGER, - // expandedicon: Icon(Icons.edit, color: Colors.tealAccent,), - // collapsedicon: Text('close'), - // submitbutton: Text('OK'), + // dropdownUnderlineBorder: const BorderSide(color: Colors.pink, width: 2), + // dropdownTitleTileBorder: Border.all(color: Colors.pink, width: 2), + // dropdownTitleTileBorderRadius: BorderRadius.circular(55), + // expandedicon: const Icon(Icons.edit, color: Colors.tealAccent,), + // collapsedicon: const Text('close'), + // submitbutton: const Text('OK'), - // selectedTextStyle : TextStyle(fontSize: 16, fontWeight: FontWeight.w500, color: Colors.pink), - // color : Colors.blueGrey, - // avatar : GFAvatar(backgroundColor: Colors.red,), - // padding : EdgeInsets.all(6), - // margin : EdgeInsets.all(6), - // size : GFSize.LARGE, - // type : GFCheckboxType.basic, - // checkColor : GFColors.ALT, - // activebgColor : GFColors.DARK, - // inactivebgColor : GFColors.SECONDARY, - // activeBorderColor : GFColors.SUCCESS, - // inactiveBorderColor : GFColors.LIGHT, - // expandedicon : Icons.keyboard_arrow_down, - // collapsedicon : Icons.keyboard_arrow_up, - // dropdownbgColor : Colors.white, - // activeIcon : Icon( - // Icons.check, - // size: 20, - // color: GFColors.DARK, - // ), - // inactiveIcon : Icon( - // Icons.check_box_outline_blank, - // size: 20, - // color: GFColors.DARK, - // ), - // custombgColor : GFColors.SUCCESS, + + dropDownTitleTileTextStyle : const TextStyle(fontSize: 16, fontWeight: FontWeight.w500, color: Colors.pink), + color : Colors.blueGrey, + avatar : const GFAvatar(backgroundColor: Colors.red,), + padding : const EdgeInsets.all(6), + margin : const EdgeInsets.all(6), + size : GFSize.LARGE, + type : GFCheckboxType.basic, + checkColor : GFColors.ALT, + activebgColor : GFColors.LIGHT, + inactivebgColor : GFColors.SECONDARY, + activeBorderColor : GFColors.SUCCESS, + inactiveBorderColor : GFColors.PRIMARY, + dropdownbgColor : Colors.white, + activeIcon : const Icon( + Icons.check, + size: 20, + color: GFColors.DARK, + ), + inactiveIcon : const Icon( + Icons.check_box_outline_blank, + size: 20, + color: GFColors.DARK, + ), + custombgColor : GFColors.SUCCESS, selected : false, ), const SizedBox(height: 22,), GFDropdown( // isExpanded: true, isDense: true, - hint: Text('sele $selected'), + hint: Text('select'), // padding: const EdgeInsets.all(12), // borderRadius: BorderRadius.circular(12), // border: const BorderSide(color: Colors.pink, width: 2, style: BorderStyle.solid), @@ -102,5 +106,6 @@ class _ExampleState extends State { ), ], ), + ), ); } diff --git a/lib/components/dropdown/gf_multiselect.dart b/lib/components/dropdown/gf_multiselect.dart index c1dcec41..4daae3c4 100644 --- a/lib/components/dropdown/gf_multiselect.dart +++ b/lib/components/dropdown/gf_multiselect.dart @@ -7,7 +7,7 @@ class GFMultiSelect extends StatefulWidget { @required this.items, @required this.onSelect, this.dropDownTitleTileText = 'Select : ', - this.selectedTextStyle = const TextStyle(fontSize: 16, fontWeight: FontWeight.w500), + this.dropDownTitleTileTextStyle = const TextStyle(fontSize: 16, fontWeight: FontWeight.w500), this.color, this.avatar, this.padding = const EdgeInsets.all(5), @@ -43,9 +43,11 @@ class GFMultiSelect extends StatefulWidget { this.dropdownTitleTileBorderRadius = const BorderRadius.all(Radius.circular(4)), this.dropdownTitleTileColor = GFColors.WHITE, this.hideDropdownUnderline = false, - this.dropdownUnderlineColor = Colors.black12, + this.dropdownUnderlineBorder = const BorderSide(color: Colors.black12, width: 1), this.dropdownTitleTileMargin = const EdgeInsets.all(16), this.dropdownTitleTilePadding = const EdgeInsets.all(12), + this.dropDownTitleTileHintText, + this.dropDownTitleTileHintTextStyle = const TextStyle(fontSize: 12, fontWeight: FontWeight.w400), Key key, }) : assert(selected != null), super(key: key); @@ -53,6 +55,10 @@ class GFMultiSelect extends StatefulWidget { ///type of [String] used to pass text, alternative to title property and gets higher priority than title final String dropDownTitleTileText; + final String dropDownTitleTileHintText; + + final TextStyle dropDownTitleTileHintTextStyle; + /// The GFListTile's background color. Can be given [Color] or [GFColors] final Color color; @@ -111,7 +117,7 @@ class GFMultiSelect extends StatefulWidget { final Color dropdownbgColor; - final TextStyle selectedTextStyle; + final TextStyle dropDownTitleTileTextStyle; final Widget expandedicon; @@ -128,7 +134,7 @@ class GFMultiSelect extends StatefulWidget { final bool hideDropdownUnderline; - final dynamic dropdownUnderlineColor; + final BorderSide dropdownUnderlineBorder; final EdgeInsets dropdownTitleTileMargin; @@ -136,6 +142,8 @@ class GFMultiSelect extends StatefulWidget { final ValueChanged> onSelect; + + @override _GFMultiSelectState createState() => _GFMultiSelectState(); } @@ -174,101 +182,115 @@ class _GFMultiSelectState extends State> { } @override - Widget build(BuildContext context) => Column( - children: [ - InkWell( - onTap: () { - setState(() { - isdrop = !isdrop; - }); - }, - child: Container( - margin: widget.dropdownTitleTileMargin, - padding: widget.dropdownTitleTilePadding, - decoration: BoxDecoration( - color: widget.dropdownTitleTileColor, + Widget build(BuildContext context) { + + Widget dropdownTile() => Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + _selectedTitles.isEmpty ? + Expanded(child: Text(widget.dropDownTitleTileText, style: widget.dropDownTitleTileTextStyle)) : + Expanded(child: Text(_selectedTitles.join(', ').toString(), style: widget.dropDownTitleTileTextStyle)), + !isdrop ? widget.expandedicon : widget.collapsedicon, + ], + ); + + return Column( + children: [ + InkWell( + onTap: () { + setState(() { + isdrop = !isdrop; + }); + }, + child: Container( + margin: widget.dropdownTitleTileMargin, + padding: widget.dropdownTitleTilePadding, + decoration: BoxDecoration( + color: widget.dropdownTitleTileColor, border: widget.dropdownTitleTileBorder, borderRadius: widget.dropdownTitleTileBorderRadius - ), - child: Container( - decoration: BoxDecoration( - border: widget.hideDropdownUnderline ? const Border(bottom: BorderSide(color: Colors.white)) - : Border(bottom: BorderSide(color: widget.dropdownUnderlineColor)), - ), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - _selectedTitles.isEmpty ? - Expanded(child: Text(widget.dropDownTitleTileText, style: widget.selectedTextStyle)) : - Expanded(child: Text(_selectedTitles.join(', ').toString(), style: widget.selectedTextStyle)), - !isdrop ? widget.expandedicon : widget.collapsedicon, - ], - ), - ))), - isdrop - ? Container( - padding: const EdgeInsets.symmetric(vertical: 6), + ), + child: Container( decoration: BoxDecoration( - color: widget.dropdownbgColor, - boxShadow: const [ - BoxShadow( - color: Colors.black12, - blurRadius: 3, - ) - ], + border: widget.hideDropdownUnderline ? const Border( + bottom: BorderSide(color: Colors.white)) + : Border(bottom: widget.dropdownUnderlineBorder), ), - child: SingleChildScrollView( - child: Column( - children: [ - Column( - children: List.generate( - widget.items.length, - (index) => GFCheckboxListTile( - value: _selectedTitles - .contains(widget.items[index]), - onChanged: (bool selected) { - _controller.text; - _onItemSelect( - selected, index); - if (selected == null) { - widget.onSelect(null); - return; - } - widget.onSelect(_selectedTitlesIndex); - }, - selected: widget.selected, - avatar: widget.avatar, - titleText: widget.items[index], - color: widget.color, - padding: widget.padding, - margin: widget.margin, - size: widget.size, - activebgColor: widget.activebgColor, - inactiveIcon: widget.inactiveIcon, - activeBorderColor: - widget.activeBorderColor, - inactivebgColor: widget.inactivebgColor, - activeIcon: widget.activeIcon, - inactiveBorderColor: - widget.inactiveBorderColor, - custombgColor: widget.custombgColor, - checkColor: widget.checkColor, - type: widget.type, - ))), - GFButton( - onPressed: () { - setState(() { - isdrop = !isdrop; - }); - }, - child: widget.submitbutton ?? const Text('OK'), - ) - ], - ), + child: widget.dropDownTitleTileHintText == null ? dropdownTile() : Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('${widget.dropDownTitleTileHintText}', style: widget.dropDownTitleTileHintTextStyle,), + dropdownTile(), + const SizedBox(height: 2,) + ], ), + ))), + isdrop + ? Container( + padding: const EdgeInsets.symmetric(vertical: 6), + decoration: BoxDecoration( + color: widget.dropdownbgColor, + boxShadow: const [ + BoxShadow( + color: Colors.black12, + blurRadius: 3, + ) + ], + ), + child: SingleChildScrollView( + child: Column( + children: [ + Column( + children: List.generate( + widget.items.length, + (index) => + GFCheckboxListTile( + value: _selectedTitles + .contains(widget.items[index]), + onChanged: (bool selected) { + _controller.text; + _onItemSelect( + selected, index); + if (selected == null) { + widget.onSelect(null); + return; + } + widget.onSelect(_selectedTitlesIndex); + }, + selected: widget.selected, + avatar: widget.avatar, + titleText: widget.items[index], + color: widget.color, + padding: widget.padding, + margin: widget.margin, + size: widget.size, + activebgColor: widget.activebgColor, + inactiveIcon: widget.inactiveIcon, + activeBorderColor: + widget.activeBorderColor, + inactivebgColor: widget.inactivebgColor, + activeIcon: widget.activeIcon, + inactiveBorderColor: + widget.inactiveBorderColor, + custombgColor: widget.custombgColor, + checkColor: widget.checkColor, + type: widget.type, + ))), + GFButton( + onPressed: () { + setState(() { + isdrop = !isdrop; + }); + }, + child: widget.submitbutton ?? const Text('OK'), ) - : Container(), - ], - ); + ], + ), + ), + ) + : Container(), + ], + ); + } } From 1ac4267bb226cbe581dcff895016316b000a2740 Mon Sep 17 00:00:00 2001 From: deepikahr Date: Wed, 14 Oct 2020 19:59:50 +0530 Subject: [PATCH 17/25] description added --- example/lib/main_temp.dart | 160 ++++++----- lib/components/dropdown/gf_dropdown.dart | 15 +- lib/components/dropdown/gf_multiselect.dart | 302 +++++++++++--------- 3 files changed, 260 insertions(+), 217 deletions(-) diff --git a/example/lib/main_temp.dart b/example/lib/main_temp.dart index f95e3607..88b65d62 100644 --- a/example/lib/main_temp.dart +++ b/example/lib/main_temp.dart @@ -23,7 +23,15 @@ class Example extends StatefulWidget { class _ExampleState extends State { String dropdownValue; - List dropList = ['Running', 'Walking', 'Eating', 'Sleeping', 'Playing', 'Drinking', 'Jogging']; + List dropList = [ + 'Running', + 'Walking', + 'Eating', + 'Sleeping', + 'Playing', + 'Drinking', + 'Jogging' + ]; String selected; @override @@ -33,79 +41,87 @@ class _ExampleState extends State { ), backgroundColor: Colors.teal, body: SingleChildScrollView( - child: Column( - children: [ - GFMultiSelect( - items: dropList, - onSelect: (value){ - print('sel $value '); - }, - // dropDownTitleTileText: 'Select options : ', - // dropDownTitleTileHintText: 'select', - // dropDownTitleTileHintTextStyle: const TextStyle(fontSize: 12, fontWeight: FontWeight.w500, color: Colors.pink), - // dropdownTitleTileMargin: EdgeInsets.all(2), - // dropdownTitleTilePadding: EdgeInsets.all(4), - // hideDropdownUnderline: true, - // dropdownUnderlineBorder: const BorderSide(color: Colors.pink, width: 2), - // dropdownTitleTileBorder: Border.all(color: Colors.pink, width: 2), - // dropdownTitleTileBorderRadius: BorderRadius.circular(55), - // expandedicon: const Icon(Icons.edit, color: Colors.tealAccent,), - // collapsedicon: const Text('close'), - // submitbutton: const Text('OK'), - - - dropDownTitleTileTextStyle : const TextStyle(fontSize: 16, fontWeight: FontWeight.w500, color: Colors.pink), - color : Colors.blueGrey, - avatar : const GFAvatar(backgroundColor: Colors.red,), - padding : const EdgeInsets.all(6), - margin : const EdgeInsets.all(6), - size : GFSize.LARGE, - type : GFCheckboxType.basic, - checkColor : GFColors.ALT, - activebgColor : GFColors.LIGHT, - inactivebgColor : GFColors.SECONDARY, - activeBorderColor : GFColors.SUCCESS, - inactiveBorderColor : GFColors.PRIMARY, - dropdownbgColor : Colors.white, - activeIcon : const Icon( - Icons.check, - size: 20, - color: GFColors.DARK, + child: Column( + children: [ + GFMultiSelect( + items: dropList, + onSelect: (value) { + print('sel $value '); + }, + // dropDownTitleTileText: 'Select options : ', + // dropDownTitleTileHintText: 'select', + // dropDownTitleTileHintTextStyle: const TextStyle(fontSize: 12, fontWeight: FontWeight.w500, color: Colors.pink), + // dropdownTitleTileMargin: EdgeInsets.all(2), + // dropdownTitleTilePadding: EdgeInsets.all(4), + // hideDropdownUnderline: true, + // dropdownUnderlineBorder: const BorderSide(color: Colors.pink, width: 2), + // dropdownTitleTileBorder: Border.all(color: Colors.pink, width: 2), + // dropdownTitleTileBorderRadius: BorderRadius.circular(55), + // expandedIcon: const Icon(Icons.edit, color: Colors.tealAccent,), + // collapsedIcon: const Text('close'), + // submitButton: const Text('OK'), + // dropDownTitleTileTextStyle: const TextStyle( + // fontSize: 16, + // fontWeight: FontWeight.w500, + // color: Colors.pink), + // + // color: Colors.blueGrey, + // avatar: const GFAvatar( + // backgroundColor: Colors.red, + // ), + // padding: const EdgeInsets.all(6), + // margin: const EdgeInsets.all(6), + // size: GFSize.LARGE, + // type: GFCheckboxType.basic, + // checkColor: GFColors.ALT, + // activebgColor: GFColors.LIGHT, + // inactivebgColor: GFColors.SECONDARY, + // activeBorderColor: GFColors.SUCCESS, + // inactiveBorderColor: GFColors.PRIMARY, + // dropdownbgColor: Colors.pink, + // activeIcon: const Icon( + // Icons.check, + // size: 20, + // color: GFColors.DARK, + // ), + // inactiveIcon: const Icon( + // Icons.check_box_outline_blank, + // size: 20, + // color: GFColors.DARK, + // ), + // custombgColor: GFColors.DANGER, + // selected: true, ), - inactiveIcon : const Icon( - Icons.check_box_outline_blank, - size: 20, - color: GFColors.DARK, + const SizedBox( + height: 22, ), - custombgColor : GFColors.SUCCESS, - selected : false, - ), - const SizedBox(height: 22,), - GFDropdown( - // isExpanded: true, - isDense: true, - hint: Text('select'), - // padding: const EdgeInsets.all(12), - // borderRadius: BorderRadius.circular(12), - // border: const BorderSide(color: Colors.pink, width: 2, style: BorderStyle.solid), - // dropdownColor: Colors.tealAccent, - value: dropdownValue, - onChanged: (newValue) { - print('val $newValue'); - setState(() { - selected = newValue.value; - }); - }, - items: ['One', 'Two', 'Free', 'Four'].asMap().entries - .map((value) => - DropdownMenuItem( - value: value, - child: Text('${value.value}'), - ) - ).toList(), - ), - ], - ), + GFDropdown( + // isExpanded: true, + // isDense: true, + // hint: const Text('select'), + // padding: const EdgeInsets.all(12), + // borderRadius: BorderRadius.circular(12), + // border: const BorderSide(color: Colors.pink, width: 2, style: BorderStyle.solid), + // dropdownColor: Colors.tealAccent, + // dropdownButtonColor: Colors.amber, + value: dropdownValue, + onChanged: (newValue) { + print('val $newValue'); + setState(() { + selected = newValue.value; + }); + }, + items: ['One', 'Two', 'Free', 'Four'] + .asMap() + .entries + .map((value) => DropdownMenuItem( + value: value, + child: Text('${value.value}'), + )) + .toList(), + ), + ], + ), ), ); } diff --git a/lib/components/dropdown/gf_dropdown.dart b/lib/components/dropdown/gf_dropdown.dart index 5ca281ef..ba3d4405 100644 --- a/lib/components/dropdown/gf_dropdown.dart +++ b/lib/components/dropdown/gf_dropdown.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:getwidget/getwidget.dart'; class GFDropdown extends StatefulWidget { /// @@ -18,7 +19,7 @@ class GFDropdown extends StatefulWidget { this.iconDisabledColor, this.iconEnabledColor, this.iconSize = 24.0, - this.isDense = false, + this.isDense = true, this.isExpanded = false, this.itemHeight = kMinInteractiveDimension, this.focusColor, @@ -27,7 +28,9 @@ class GFDropdown extends StatefulWidget { this.dropdownColor, this.padding = const EdgeInsets.all(5), this.borderRadius = const BorderRadius.all(Radius.circular(4)), - this.border}) + this.border = const BorderSide(color: Colors.white, width: 1, style: BorderStyle.solid), + this.dropdownButtonColor = GFColors.WHITE + }) : super(key: key); final DropdownButtonBuilder selectedItemBuilder; @@ -108,6 +111,9 @@ class GFDropdown extends StatefulWidget { /// The border radius of the dropdown. final BorderRadius borderRadius; + /// The background color of the dropdownButton. + final dynamic dropdownButtonColor; + @override _GFDropdownState createState() => _GFDropdownState(); } @@ -115,10 +121,9 @@ class GFDropdown extends StatefulWidget { class _GFDropdownState extends State { @override Widget build(BuildContext context) => Material( + color: widget.dropdownButtonColor, shape: RoundedRectangleBorder( - side: widget.border ?? - const BorderSide( - color: Colors.white, width: 1, style: BorderStyle.solid), + side: widget.border, borderRadius: widget.borderRadius, ), child: Padding( diff --git a/lib/components/dropdown/gf_multiselect.dart b/lib/components/dropdown/gf_multiselect.dart index 4daae3c4..a4841f16 100644 --- a/lib/components/dropdown/gf_multiselect.dart +++ b/lib/components/dropdown/gf_multiselect.dart @@ -7,7 +7,8 @@ class GFMultiSelect extends StatefulWidget { @required this.items, @required this.onSelect, this.dropDownTitleTileText = 'Select : ', - this.dropDownTitleTileTextStyle = const TextStyle(fontSize: 16, fontWeight: FontWeight.w500), + this.dropDownTitleTileTextStyle = + const TextStyle(fontSize: 16, fontWeight: FontWeight.w500), this.color, this.avatar, this.padding = const EdgeInsets.all(5), @@ -19,13 +20,13 @@ class GFMultiSelect extends StatefulWidget { this.inactivebgColor = GFColors.WHITE, this.activeBorderColor = GFColors.WHITE, this.inactiveBorderColor = GFColors.WHITE, - this.submitbutton, - this.expandedicon = const Icon( + this.submitButton, + this.expandedIcon = const Icon( Icons.keyboard_arrow_down, color: Colors.black87, size: 30, ), - this.collapsedicon = const Icon( + this.collapsedIcon = const Icon( Icons.keyboard_arrow_up, color: Colors.black87, size: 30, @@ -40,67 +41,116 @@ class GFMultiSelect extends StatefulWidget { this.custombgColor = GFColors.SUCCESS, this.selected = false, this.dropdownTitleTileBorder, - this.dropdownTitleTileBorderRadius = const BorderRadius.all(Radius.circular(4)), + this.dropdownTitleTileBorderRadius = + const BorderRadius.all(Radius.circular(4)), this.dropdownTitleTileColor = GFColors.WHITE, this.hideDropdownUnderline = false, - this.dropdownUnderlineBorder = const BorderSide(color: Colors.black12, width: 1), + this.dropdownUnderlineBorder = + const BorderSide(color: Colors.black12, width: 1), this.dropdownTitleTileMargin = const EdgeInsets.all(16), this.dropdownTitleTilePadding = const EdgeInsets.all(12), this.dropDownTitleTileHintText, - this.dropDownTitleTileHintTextStyle = const TextStyle(fontSize: 12, fontWeight: FontWeight.w400), + this.dropDownTitleTileHintTextStyle = + const TextStyle(fontSize: 12, fontWeight: FontWeight.w400), Key key, }) : assert(selected != null), super(key: key); - ///type of [String] used to pass text, alternative to title property and gets higher priority than title + /// defines the list of items the user can select + final List items; + + /// callback when user select item from the dropdown, + /// in callback we get list of selected items index + final ValueChanged> onSelect; + + /// type of [String] to define the dropdownTitleTile title final String dropDownTitleTileText; + /// type of [TextStyle] to define the textStyle of [dropDownTitleTileText] + final TextStyle dropDownTitleTileTextStyle; + + /// type of [String] to define the dropdownTitleTile hint text final String dropDownTitleTileHintText; + /// type of [TextStyle] to define the textStyle of [dropDownTitleTileHintTextStyle] final TextStyle dropDownTitleTileHintTextStyle; - /// The GFListTile's background color. Can be given [Color] or [GFColors] - final Color color; + /// defines the border radius of the dropdownTitleTile + final BorderRadius dropdownTitleTileBorderRadius; + + /// defines the border of the dropdownTitleTile. + final Border dropdownTitleTileBorder; + + /// defines the background color of dropdownButton + final dynamic dropdownTitleTileColor; + + /// on true state, it hides the Dropdown Underline border + /// defaults value is false + final bool hideDropdownUnderline; + + /// defines the border of the Dropdown Underline border + final BorderSide dropdownUnderlineBorder; + + /// defines the dropdownTitleTile margin + final EdgeInsets dropdownTitleTileMargin; + + /// defines the dropdownTitleTile padding + final EdgeInsets dropdownTitleTilePadding; + + /// defines the dropdownTitleTile's trailing icon when dropdown is visible + final Widget expandedIcon; + + /// defines the dropdownTitleTile's trailing icon when dropdown is not visible + final Widget collapsedIcon; + + /// defines the button in the dropdown + final Widget submitButton; + + /// defines dropdown checkbox ListTile's background color. Can be given [Color] or [GFColors] + final dynamic color; - /// type of [Widget] or [GFAvatar] used to create rounded user profile + /// type of [Widget] or [GFAvatar] used to defines dropdown checkbox ListTile's leading final Widget avatar; - /// defines the margin of GFListTile + /// defines the margin of dropdown checkbox ListTile final EdgeInsets margin; - /// defines the padding of GFListTile + /// defines the padding of dropdown checkbox ListTile final EdgeInsets padding; + /// defines dropdown ListTile's checkbox type /// type of [GFCheckboxType] which is of four type is basic, sqaure, circular and custom final GFCheckboxType type; + /// defines dropdown ListTile's checkbox size /// type of [double] which is GFSize ie, small, medium and large and can use any double value final double size; - /// type pf [Color] used to change the checkcolor when the checkbox is active + /// defines dropdown ListTile's checkbox color when its active + /// type of [Color] used to change the checkcolor when the checkbox is active final Color checkColor; + /// defines dropdown ListTile's checkbox background color when its active /// type of [Color] used to change the backgroundColor of the active checkbox final Color activebgColor; + /// defines dropdown ListTile's checkbox background color when its inactive /// type of [Color] used to change the backgroundColor of the inactive checkbox final Color inactivebgColor; + /// defines dropdown ListTile's checkbox border color when its active /// type of [Color] used to change the border color of the active checkbox final Color activeBorderColor; + /// defines dropdown ListTile's checkbox border color when its inactive /// type of [Color] used to change the border color of the inactive checkbox final Color inactiveBorderColor; - /// Called when the user checks or unchecks the checkbox. - // final ValueChanged onChanged; - - ///Used to set the current state of the checkbox - // final bool value; - - ///type of Widget used to change the checkbox's active icon + /// defines dropdown ListTile's checkbox's active icon + /// type of [Widget] used to change the checkbox's active icon final Widget activeIcon; + /// defines dropdown ListTile's checkbox's inactive icon ///type of [Widget] used to change the checkbox's inactive icon final Widget inactiveIcon; @@ -111,51 +161,17 @@ class GFMultiSelect extends StatefulWidget { /// Normally, this property is left to its default value, false. final bool selected; - final List items; - - final Widget submitbutton; - + /// defines the background color of the dropdown. Can be given [Color] or [GFColors] final Color dropdownbgColor; - final TextStyle dropDownTitleTileTextStyle; - - final Widget expandedicon; - - final Widget collapsedicon; - - /// The border radius of the dropdown. - final BorderRadius dropdownTitleTileBorderRadius; - - /// The border radius of the dropdown. - final Border dropdownTitleTileBorder; - - /// The border radius of the dropdown. - final dynamic dropdownTitleTileColor; - - final bool hideDropdownUnderline; - - final BorderSide dropdownUnderlineBorder; - - final EdgeInsets dropdownTitleTileMargin; - - final EdgeInsets dropdownTitleTilePadding; - - final ValueChanged> onSelect; - - @override _GFMultiSelectState createState() => _GFMultiSelectState(); } class _GFMultiSelectState extends State> { - bool check = true; - bool isdrop = false; - bool check1 = false; - bool isItemSelected = false; - + bool showDropdown = false; final _controller = TextEditingController(); - final List _selectedTitles = []; final List _selectedTitlesIndex = []; @@ -183,24 +199,27 @@ class _GFMultiSelectState extends State> { @override Widget build(BuildContext context) { - Widget dropdownTile() => Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - _selectedTitles.isEmpty ? - Expanded(child: Text(widget.dropDownTitleTileText, style: widget.dropDownTitleTileTextStyle)) : - Expanded(child: Text(_selectedTitles.join(', ').toString(), style: widget.dropDownTitleTileTextStyle)), - !isdrop ? widget.expandedicon : widget.collapsedicon, - ], - ); + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + _selectedTitles.isEmpty + ? Expanded( + child: Text(widget.dropDownTitleTileText, + style: widget.dropDownTitleTileTextStyle)) + : Expanded( + child: Text(_selectedTitles.join(', ').toString(), + style: widget.dropDownTitleTileTextStyle)), + !showDropdown ? widget.expandedIcon : widget.collapsedIcon, + ], + ); return Column( children: [ InkWell( onTap: () { setState(() { - isdrop = !isdrop; + showDropdown = !showDropdown; }); }, child: Container( @@ -209,86 +228,89 @@ class _GFMultiSelectState extends State> { decoration: BoxDecoration( color: widget.dropdownTitleTileColor, border: widget.dropdownTitleTileBorder, - borderRadius: widget.dropdownTitleTileBorderRadius - ), + borderRadius: widget.dropdownTitleTileBorderRadius), child: Container( decoration: BoxDecoration( - border: widget.hideDropdownUnderline ? const Border( - bottom: BorderSide(color: Colors.white)) + border: widget.hideDropdownUnderline + ? const Border(bottom: BorderSide(color: Colors.white)) : Border(bottom: widget.dropdownUnderlineBorder), ), - child: widget.dropDownTitleTileHintText == null ? dropdownTile() : Column( - crossAxisAlignment: CrossAxisAlignment.start, + child: widget.dropDownTitleTileHintText == null + ? dropdownTile() + : Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '${widget.dropDownTitleTileHintText}', + style: widget.dropDownTitleTileHintTextStyle, + ), + dropdownTile(), + const SizedBox( + height: 2, + ) + ], + ), + ))), + showDropdown + ? Container( + padding: const EdgeInsets.symmetric(vertical: 6), + decoration: BoxDecoration( + color: widget.dropdownbgColor, + boxShadow: const [ + BoxShadow( + color: Colors.black12, + blurRadius: 3, + ) + ], + ), + child: SingleChildScrollView( + child: Column( children: [ - Text('${widget.dropDownTitleTileHintText}', style: widget.dropDownTitleTileHintTextStyle,), - dropdownTile(), - const SizedBox(height: 2,) + Column( + children: List.generate( + widget.items.length, + (index) => GFCheckboxListTile( + value: _selectedTitles + .contains(widget.items[index]), + onChanged: (bool selected) { + _controller.text; + _onItemSelect(selected, index); + if (selected == null) { + widget.onSelect(null); + return; + } + widget.onSelect(_selectedTitlesIndex); + }, + selected: widget.selected, + avatar: widget.avatar, + titleText: widget.items[index], + color: widget.color, + padding: widget.padding, + margin: widget.margin, + size: widget.size, + activebgColor: widget.activebgColor, + inactiveIcon: widget.inactiveIcon, + activeBorderColor: widget.activeBorderColor, + inactivebgColor: widget.inactivebgColor, + activeIcon: widget.activeIcon, + inactiveBorderColor: + widget.inactiveBorderColor, + custombgColor: widget.custombgColor, + checkColor: widget.checkColor, + type: widget.type, + ))), + GFButton( + onPressed: () { + setState(() { + showDropdown = !showDropdown; + }); + }, + child: widget.submitButton ?? const Text('OK'), + ) ], ), - ))), - isdrop - ? Container( - padding: const EdgeInsets.symmetric(vertical: 6), - decoration: BoxDecoration( - color: widget.dropdownbgColor, - boxShadow: const [ - BoxShadow( - color: Colors.black12, - blurRadius: 3, + ), ) - ], - ), - child: SingleChildScrollView( - child: Column( - children: [ - Column( - children: List.generate( - widget.items.length, - (index) => - GFCheckboxListTile( - value: _selectedTitles - .contains(widget.items[index]), - onChanged: (bool selected) { - _controller.text; - _onItemSelect( - selected, index); - if (selected == null) { - widget.onSelect(null); - return; - } - widget.onSelect(_selectedTitlesIndex); - }, - selected: widget.selected, - avatar: widget.avatar, - titleText: widget.items[index], - color: widget.color, - padding: widget.padding, - margin: widget.margin, - size: widget.size, - activebgColor: widget.activebgColor, - inactiveIcon: widget.inactiveIcon, - activeBorderColor: - widget.activeBorderColor, - inactivebgColor: widget.inactivebgColor, - activeIcon: widget.activeIcon, - inactiveBorderColor: - widget.inactiveBorderColor, - custombgColor: widget.custombgColor, - checkColor: widget.checkColor, - type: widget.type, - ))), - GFButton( - onPressed: () { - setState(() { - isdrop = !isdrop; - }); - }, - child: widget.submitbutton ?? const Text('OK'), - ) - ], - ), - ), - ) : Container(), ], ); From b322fb90fd9bc636b6b5641c39c7b6f797a6a805 Mon Sep 17 00:00:00 2001 From: deepikahr Date: Wed, 14 Oct 2020 20:11:30 +0530 Subject: [PATCH 18/25] completed GFDropdown and GFMultiselect --- example/lib/main_temp.dart | 127 -------------------- lib/components/dropdown/gf_dropdown.dart | 6 +- lib/components/dropdown/gf_multiselect.dart | 1 - 3 files changed, 3 insertions(+), 131 deletions(-) delete mode 100644 example/lib/main_temp.dart diff --git a/example/lib/main_temp.dart b/example/lib/main_temp.dart deleted file mode 100644 index 88b65d62..00000000 --- a/example/lib/main_temp.dart +++ /dev/null @@ -1,127 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:getwidget/getwidget.dart'; - -void main() => runApp(MyApp()); - -class MyApp extends StatelessWidget { - @override - Widget build(BuildContext context) => MaterialApp( - title: 'GetWidget Example', - theme: ThemeData( - primarySwatch: Colors.blue, - ), - debugShowCheckedModeBanner: false, - home: Example(), - ); -} - -class Example extends StatefulWidget { - @override - _ExampleState createState() => _ExampleState(); -} - -class _ExampleState extends State { - String dropdownValue; - List dropList = [ - 'Running', - 'Walking', - 'Eating', - 'Sleeping', - 'Playing', - 'Drinking', - 'Jogging' - ]; - String selected; - - @override - Widget build(BuildContext context) => Scaffold( - appBar: GFAppBar( - title: const Text('drop down '), - ), - backgroundColor: Colors.teal, - body: SingleChildScrollView( - child: Column( - children: [ - GFMultiSelect( - items: dropList, - onSelect: (value) { - print('sel $value '); - }, - // dropDownTitleTileText: 'Select options : ', - // dropDownTitleTileHintText: 'select', - // dropDownTitleTileHintTextStyle: const TextStyle(fontSize: 12, fontWeight: FontWeight.w500, color: Colors.pink), - // dropdownTitleTileMargin: EdgeInsets.all(2), - // dropdownTitleTilePadding: EdgeInsets.all(4), - // hideDropdownUnderline: true, - // dropdownUnderlineBorder: const BorderSide(color: Colors.pink, width: 2), - // dropdownTitleTileBorder: Border.all(color: Colors.pink, width: 2), - // dropdownTitleTileBorderRadius: BorderRadius.circular(55), - // expandedIcon: const Icon(Icons.edit, color: Colors.tealAccent,), - // collapsedIcon: const Text('close'), - // submitButton: const Text('OK'), - // dropDownTitleTileTextStyle: const TextStyle( - // fontSize: 16, - // fontWeight: FontWeight.w500, - // color: Colors.pink), - // - // color: Colors.blueGrey, - // avatar: const GFAvatar( - // backgroundColor: Colors.red, - // ), - // padding: const EdgeInsets.all(6), - // margin: const EdgeInsets.all(6), - // size: GFSize.LARGE, - // type: GFCheckboxType.basic, - // checkColor: GFColors.ALT, - // activebgColor: GFColors.LIGHT, - // inactivebgColor: GFColors.SECONDARY, - // activeBorderColor: GFColors.SUCCESS, - // inactiveBorderColor: GFColors.PRIMARY, - // dropdownbgColor: Colors.pink, - // activeIcon: const Icon( - // Icons.check, - // size: 20, - // color: GFColors.DARK, - // ), - // inactiveIcon: const Icon( - // Icons.check_box_outline_blank, - // size: 20, - // color: GFColors.DARK, - // ), - // custombgColor: GFColors.DANGER, - // selected: true, - ), - const SizedBox( - height: 22, - ), - GFDropdown( - // isExpanded: true, - // isDense: true, - // hint: const Text('select'), - // padding: const EdgeInsets.all(12), - // borderRadius: BorderRadius.circular(12), - // border: const BorderSide(color: Colors.pink, width: 2, style: BorderStyle.solid), - // dropdownColor: Colors.tealAccent, - // dropdownButtonColor: Colors.amber, - value: dropdownValue, - onChanged: (newValue) { - print('val $newValue'); - setState(() { - selected = newValue.value; - }); - }, - items: ['One', 'Two', 'Free', 'Four'] - .asMap() - .entries - .map((value) => DropdownMenuItem( - value: value, - child: Text('${value.value}'), - )) - .toList(), - ), - ], - ), - ), - ); -} diff --git a/lib/components/dropdown/gf_dropdown.dart b/lib/components/dropdown/gf_dropdown.dart index ba3d4405..670bf39e 100644 --- a/lib/components/dropdown/gf_dropdown.dart +++ b/lib/components/dropdown/gf_dropdown.dart @@ -28,9 +28,9 @@ class GFDropdown extends StatefulWidget { this.dropdownColor, this.padding = const EdgeInsets.all(5), this.borderRadius = const BorderRadius.all(Radius.circular(4)), - this.border = const BorderSide(color: Colors.white, width: 1, style: BorderStyle.solid), - this.dropdownButtonColor = GFColors.WHITE - }) + this.border = const BorderSide( + color: Colors.white, width: 1, style: BorderStyle.solid), + this.dropdownButtonColor = GFColors.WHITE}) : super(key: key); final DropdownButtonBuilder selectedItemBuilder; diff --git a/lib/components/dropdown/gf_multiselect.dart b/lib/components/dropdown/gf_multiselect.dart index a4841f16..6b1499e0 100644 --- a/lib/components/dropdown/gf_multiselect.dart +++ b/lib/components/dropdown/gf_multiselect.dart @@ -164,7 +164,6 @@ class GFMultiSelect extends StatefulWidget { /// defines the background color of the dropdown. Can be given [Color] or [GFColors] final Color dropdownbgColor; - @override _GFMultiSelectState createState() => _GFMultiSelectState(); } From e0a9c72f04d0d9a0afd351c6515e2ad74ce232f9 Mon Sep 17 00:00:00 2001 From: deepikahr Date: Wed, 14 Oct 2020 20:12:55 +0530 Subject: [PATCH 19/25] completed GFDropdown and GFMultiselect --- lib/components/dropdown/gf_multiselect.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/components/dropdown/gf_multiselect.dart b/lib/components/dropdown/gf_multiselect.dart index 6b1499e0..d60edab3 100644 --- a/lib/components/dropdown/gf_multiselect.dart +++ b/lib/components/dropdown/gf_multiselect.dart @@ -63,7 +63,7 @@ class GFMultiSelect extends StatefulWidget { /// in callback we get list of selected items index final ValueChanged> onSelect; - /// type of [String] to define the dropdownTitleTile title + /// type of [String] to define the dropdownTitleTile title final String dropDownTitleTileText; /// type of [TextStyle] to define the textStyle of [dropDownTitleTileText] From 0a1497b18cb8372b466e41df532762b55007d13e Mon Sep 17 00:00:00 2001 From: deepikahr Date: Thu, 15 Oct 2020 23:34:16 +0530 Subject: [PATCH 20/25] description changed --- lib/components/animation/gf_animation.dart | 39 +++++++++++----------- lib/components/dropdown/gf_dropdown.dart | 20 +++++------ 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/lib/components/animation/gf_animation.dart b/lib/components/animation/gf_animation.dart index f0849a86..9c6c07ab 100644 --- a/lib/components/animation/gf_animation.dart +++ b/lib/components/animation/gf_animation.dart @@ -38,13 +38,13 @@ class GFAnimation extends StatefulWidget { /// The duration for animation to perform final Duration duration; - /// The duration for animation to perform + /// The duration for reverse animation to perform final Duration reverseDuration; - /// Defines how the animated widget is aligned within the Animation. + /// Defines how the animated widget is aligned during Animation. final Alignment alignment; - /// Defines how the animated widget is aligned(after the onTap) within the Animation. + /// Defines how the animated widget is aligned(after the onTap) during Animation. final Alignment activeAlignment; /// The child of type [Widget] to display animation effect. @@ -53,19 +53,20 @@ class GFAnimation extends StatefulWidget { /// Determines the animation curve. Defaults to [Curves.linear]. final Curve curve; - ///type of [GFAnimation] which takes the type ie, align, size, container, rotateTransition, scaleTransition, slideTransition, and textStyle for the [GFAnimation] + ///type of [GFAnimation] which takes the type ie, align, size, container, + /// rotateTransition, scaleTransition, slideTransition, and textStyle for the [GFAnimation] final GFAnimationType type; /// defines [AnimatedContainer] initial width final double width; - /// defines the width of [AnimatedContainer] upto which it can extend during animation + /// defines the width of [AnimatedContainer] upto which it can expand during animation final double changedWidth; /// defines [AnimatedContainer] initial height final double height; - /// defines the height of [AnimatedContainer] upto which it can extend during animation + /// defines the height of [AnimatedContainer] upto which it can expand during animation final double changedHeight; /// defines the color of [AnimatedContainer] when onTap triggers @@ -83,42 +84,40 @@ class GFAnimation extends StatefulWidget { /// Called when the user taps the [child] final Function onTap; - /// Here's an illustration of the [RotationTransition] widget, with it's [turnsAnimation] - /// animated by a stuckValue set to animate + /// For GFAnimationType.rotateTransition, customized turns animation can be added to [RotationTransition] widget final Animation turnsAnimation; - /// Here's an illustration of the [ScaleTransition] widget, with it's [scaleAnimation] - /// animated by a [CurvedAnimation] set to [Curves.linear] + /// For GFAnimationType.scaleTransition, customized scale animation can be added to [ScaleTransition] widget final Animation scaleAnimation; - /// controls animation + /// Type of [AnimationController], its a controller of an animation. final AnimationController controller; - ///direction of the [AnimatedDefaultTextStyle] TextDirection for [ltr,rtl] + /// Defines direction of the [AnimatedDefaultTextStyle] TextDirection i.e [ltr,rtl] final TextDirection textDirection; - /// [ScaleTransition], which animates the scale of a widget. + /// For GFAnimationType.slideTransition, which animates the position of a widget. final Animation slidePosition; - /// defines the [TextStyle] of [AnimatedDefaultTextStyle] + /// Defines the [TextStyle] of [AnimatedDefaultTextStyle] final TextStyle style; - /// defines the [TextAlign] of [AnimatedDefaultTextStyle] + /// Defines the [TextAlign] of [AnimatedDefaultTextStyle] final TextAlign textAlign; - /// defines the [TextOverflow] of [AnimatedDefaultTextStyle] + /// Defines the [TextOverflow] of [AnimatedDefaultTextStyle] final TextOverflow textOverflow; - /// defines the [maxLines] of [AnimatedDefaultTextStyle] + /// Defines the [maxLines] of [AnimatedDefaultTextStyle] final int maxLines; - /// defines the [TextWidthBasis] of [AnimatedDefaultTextStyle] + /// Defines the [TextWidthBasis] of [AnimatedDefaultTextStyle] final TextWidthBasis textWidthBasis; - /// defines the [fontSize] of [AnimatedDefaultTextStyle] + /// Defines the [fontSize] of [AnimatedDefaultTextStyle] final double fontSize; - /// defines the [fontWeight] of [AnimatedDefaultTextStyle] + /// Defines the [fontWeight] of [AnimatedDefaultTextStyle] final FontWeight fontWeight; @override diff --git a/lib/components/dropdown/gf_dropdown.dart b/lib/components/dropdown/gf_dropdown.dart index 670bf39e..bc56ff3f 100644 --- a/lib/components/dropdown/gf_dropdown.dart +++ b/lib/components/dropdown/gf_dropdown.dart @@ -46,10 +46,10 @@ class GFDropdown extends StatefulWidget { /// The value of the currently selected [DropdownMenuItem]. final T value; - /// the color of the border of the dropdown button + /// Defines the border of dropdown button final BorderSide border; - ///The padding given inside the dropdown + /// Defines the padding given inside the dropdown final EdgeInsets padding; /// A placeholder widget that is displayed by the dropdown button. @@ -90,28 +90,26 @@ class GFDropdown extends StatefulWidget { /// Set the dropdown's inner contents to horizontally fill its parent. final bool isExpanded; - /// The default value is [kMinInteractiveDimension], which is also the minimum - /// height for menu items. - /// - /// If this value is null and there isn't enough vertical room for the menu, + /// Defines the height of the menu items final double itemHeight; /// The color for the button's [Material] when it has the input focus. final Color focusColor; - /// {@macro flutter.widgets.Focus.focusNode} + /// Defines the keyboard focus for this widget. final FocusNode focusNode; - /// {@macro flutter.widgets.Focus.autofocus} + /// On true state it should focus itself if nothing else is already focused. + /// Defaults to false final bool autofocus; - /// The background color of the dropdown. + /// Defines the background color of the dropdown. final Color dropdownColor; - /// The border radius of the dropdown. + /// Defines the border radius of the dropdown. final BorderRadius borderRadius; - /// The background color of the dropdownButton. + /// Defines the background color of the dropdownButton. final dynamic dropdownButtonColor; @override From 3755c9ffc47f36fc660a7f5db6ef52538f7006f4 Mon Sep 17 00:00:00 2001 From: deepikahr Date: Fri, 16 Oct 2020 11:14:47 +0530 Subject: [PATCH 21/25] changes in description --- lib/components/dropdown/gf_multiselect.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/components/dropdown/gf_multiselect.dart b/lib/components/dropdown/gf_multiselect.dart index d60edab3..9ebcf00d 100644 --- a/lib/components/dropdown/gf_multiselect.dart +++ b/lib/components/dropdown/gf_multiselect.dart @@ -164,6 +164,7 @@ class GFMultiSelect extends StatefulWidget { /// defines the background color of the dropdown. Can be given [Color] or [GFColors] final Color dropdownbgColor; + @override _GFMultiSelectState createState() => _GFMultiSelectState(); } From 9d1cb12acfc754a2ae10b12ce65382e02316109e Mon Sep 17 00:00:00 2001 From: deepikahr Date: Fri, 16 Oct 2020 20:02:34 +0530 Subject: [PATCH 22/25] changes in description and properties key names in few components --- lib/components/checkbox/gf_checkbox.dart | 21 ++++--- .../gf_checkbox_list_tile.dart | 35 ++++++----- lib/components/dropdown/gf_dropdown.dart | 3 +- lib/components/dropdown/gf_multiselect.dart | 61 ++++++++++--------- .../intro_screen/gf_intro_screen.dart | 10 +-- ...gf_intro_screen_bottom_navigation_bar.dart | 6 +- lib/components/list_tile/gf_list_tile.dart | 17 +++--- lib/components/radio/gf_radio.dart | 16 ++--- .../radio_list_tile/gf_radio_list_tile.dart | 26 ++++---- .../sticky_header/gf_sticky_header.dart | 1 + 10 files changed, 103 insertions(+), 93 deletions(-) diff --git a/lib/components/checkbox/gf_checkbox.dart b/lib/components/checkbox/gf_checkbox.dart index 8fe7709c..e59c6d5e 100644 --- a/lib/components/checkbox/gf_checkbox.dart +++ b/lib/components/checkbox/gf_checkbox.dart @@ -8,8 +8,8 @@ class GFCheckbox extends StatefulWidget { this.size = GFSize.MEDIUM, this.type = GFCheckboxType.basic, this.checkColor = GFColors.WHITE, - this.activebgColor = GFColors.PRIMARY, - this.inactivebgColor = GFColors.WHITE, + this.activeBgColor = GFColors.PRIMARY, + this.inactiveBgColor = GFColors.WHITE, this.activeBorderColor = GFColors.WHITE, this.inactiveBorderColor = GFColors.DARK, this.onChanged, @@ -20,7 +20,7 @@ class GFCheckbox extends StatefulWidget { color: GFColors.WHITE, ), this.inactiveIcon, - this.custombgColor = GFColors.SUCCESS, + this.customBgColor = GFColors.SUCCESS, this.autofocus = false, this.focusNode}) : assert(autofocus != null), @@ -32,14 +32,14 @@ class GFCheckbox extends StatefulWidget { /// type of [double] which is GFSize ie, small, medium and large and can use any double value final double size; - /// type of [Color] used to change the checkcolor when the checkbox is active + /// type of [Color] used to change the checkColor when the checkbox is active final Color checkColor; /// type of [Color] used to change the backgroundColor of the active checkbox - final Color activebgColor; + final Color activeBgColor; /// type of [Color] used to change the backgroundColor of the inactive checkbox - final Color inactivebgColor; + final Color inactiveBgColor; /// type of [Color] used to change the border color of the active checkbox final Color activeBorderColor; @@ -60,7 +60,7 @@ class GFCheckbox extends StatefulWidget { final Widget inactiveIcon; /// type of [Color] used to change the background color of the custom active checkbox only - final Color custombgColor; + final Color customBgColor; /// on true state this widget will be selected as the initial focus /// when no other node in its scope is currently focused @@ -69,6 +69,7 @@ class GFCheckbox extends StatefulWidget { /// an optional focus node to use as the focus node for this widget. final FocusNode focusNode; + @override _GFCheckboxState createState() => _GFCheckboxState(); } @@ -101,8 +102,8 @@ class _GFCheckboxState extends State { ? widget.value ? widget.type == GFCheckboxType.custom ? Colors.white - : widget.activebgColor - : widget.inactivebgColor + : widget.activeBgColor + : widget.inactiveBgColor : Colors.grey, borderRadius: widget.type == GFCheckboxType.basic ? BorderRadius.circular(3) @@ -129,7 +130,7 @@ class _GFCheckboxState extends State { height: widget.size * 0.8, decoration: BoxDecoration( shape: BoxShape.rectangle, - color: widget.custombgColor), + color: widget.customBgColor), ) ], ) diff --git a/lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart b/lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart index 35142631..0b8c9810 100644 --- a/lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart +++ b/lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart @@ -2,7 +2,8 @@ import 'package:flutter/material.dart'; import 'package:getwidget/getwidget.dart'; class GFCheckboxListTile extends StatelessWidget { - /// [GFCheckboxListTile] is a tile with small box at right (as in a checklist) in which to place a check mark to make a selection with various customization options. + /// [GFCheckboxListTile] is a tile with small box at right (as in a checklist) + /// in which to place a check mark to make a selection with various customization options. const GFCheckboxListTile({ Key key, @required this.value, @@ -12,7 +13,7 @@ class GFCheckboxListTile extends StatelessWidget { this.color, this.avatar, this.title, - this.subTitle, + this.subtitle, this.icon, this.description, this.padding = const EdgeInsets.all(8), @@ -20,8 +21,8 @@ class GFCheckboxListTile extends StatelessWidget { this.size = GFSize.MEDIUM, this.type = GFCheckboxType.basic, this.checkColor = GFColors.WHITE, - this.activebgColor = GFColors.PRIMARY, - this.inactivebgColor = GFColors.WHITE, + this.activeBgColor = GFColors.PRIMARY, + this.inactiveBgColor = GFColors.WHITE, this.activeBorderColor = GFColors.WHITE, this.inactiveBorderColor = GFColors.DARK, this.activeIcon = const Icon( @@ -30,7 +31,7 @@ class GFCheckboxListTile extends StatelessWidget { color: GFColors.WHITE, ), this.inactiveIcon, - this.custombgColor = GFColors.SUCCESS, + this.customBgColor = GFColors.SUCCESS, this.position = GFPosition.end, this.selected = false, this.autofocus = false, @@ -48,14 +49,15 @@ class GFCheckboxListTile extends StatelessWidget { /// The GFListTile's background color. Can be given [Color] or [GFColors] final Color color; - /// If position is start Checkbox will come instead of avatar, type of [Widget] or [GFAvatar] used to create rounded user profile + /// If position is start Checkbox will come instead of avatar, + /// type of [Widget] or [GFAvatar] used to create rounded user profile final Widget avatar; /// The title to display inside the [GFListTile]. see [Text] final Widget title; - /// The subTitle to display inside the [GFListTile]. see [Text] - final Widget subTitle; + /// The subtitle to display inside the [GFListTile]. see [Text] + final Widget subtitle; /// The description to display inside the [GFListTile]. see [Text] final Widget description; @@ -76,10 +78,10 @@ class GFCheckboxListTile extends StatelessWidget { final Color checkColor; /// type of [Color] used to change the backgroundColor of the active checkbox - final Color activebgColor; + final Color activeBgColor; /// type of [Color] used to change the backgroundColor of the inactive checkbox - final Color inactivebgColor; + final Color inactiveBgColor; /// type of [Color] used to change the border color of the active checkbox final Color activeBorderColor; @@ -103,13 +105,14 @@ class GFCheckboxListTile extends StatelessWidget { final Widget inactiveIcon; /// type of [Color] used to change the background color of the custom active checkbox only - final Color custombgColor; + final Color customBgColor; /// To have the list tile appear selected when the checkbox is checked, pass the same value to both. /// Normally, this property is left to its default value, false. final bool selected; - /// {@macro flutter.widgets.Focus.autofocus} + /// On true state it should focus itself if nothing else is already focused. + /// Defaults to false final bool autofocus; /// If position is end Checkbox will come instead of icon, The icon to display inside the [GFListTile]. see [Icon] @@ -122,13 +125,13 @@ class GFCheckboxListTile extends StatelessWidget { onChanged: onChanged, value: value, size: size, - activebgColor: activebgColor, + activeBgColor: activeBgColor, inactiveIcon: inactiveIcon, activeBorderColor: activeBorderColor, - inactivebgColor: inactivebgColor, + inactiveBgColor: inactiveBgColor, activeIcon: activeIcon, inactiveBorderColor: inactiveBorderColor, - custombgColor: custombgColor, + customBgColor: customBgColor, checkColor: checkColor, type: type); return MergeSemantics( @@ -143,7 +146,7 @@ class GFCheckboxListTile extends StatelessWidget { selected: selected, avatar: position == GFPosition.start ? checkbox : avatar, titleText: titleText, - subTitle: subTitle, + subtitle: subtitle, subtitleText: subtitleText, description: description, color: color, diff --git a/lib/components/dropdown/gf_dropdown.dart b/lib/components/dropdown/gf_dropdown.dart index bc56ff3f..7d987ec5 100644 --- a/lib/components/dropdown/gf_dropdown.dart +++ b/lib/components/dropdown/gf_dropdown.dart @@ -2,7 +2,8 @@ import 'package:flutter/material.dart'; import 'package:getwidget/getwidget.dart'; class GFDropdown extends StatefulWidget { - /// + /// GF Dropdown let user to select from the number of items and display selected + /// item in the button. It displays list of items in the overlay dropdown fashion. const GFDropdown( {Key key, @required this.items, diff --git a/lib/components/dropdown/gf_multiselect.dart b/lib/components/dropdown/gf_multiselect.dart index 9ebcf00d..d5ededa7 100644 --- a/lib/components/dropdown/gf_multiselect.dart +++ b/lib/components/dropdown/gf_multiselect.dart @@ -2,12 +2,14 @@ import 'package:flutter/material.dart'; import 'package:getwidget/getwidget.dart'; class GFMultiSelect extends StatefulWidget { - /// + /// GF Multiselect let user to select multiple items from the number of + /// Checkbox ListTile items and display selected items in the TitleTile box. + /// It displays list of items in the overlay dropdown fashion. const GFMultiSelect({ @required this.items, @required this.onSelect, - this.dropDownTitleTileText = 'Select : ', - this.dropDownTitleTileTextStyle = + this.dropdownTitleTileText = 'Select : ', + this.dropdownTitleTileTextStyle = const TextStyle(fontSize: 16, fontWeight: FontWeight.w500), this.color, this.avatar, @@ -16,8 +18,8 @@ class GFMultiSelect extends StatefulWidget { this.size = GFSize.SMALL, this.type = GFCheckboxType.basic, this.checkColor = GFColors.WHITE, - this.activebgColor = GFColors.WHITE, - this.inactivebgColor = GFColors.WHITE, + this.activeBgColor = GFColors.WHITE, + this.inactiveBgColor = GFColors.WHITE, this.activeBorderColor = GFColors.WHITE, this.inactiveBorderColor = GFColors.WHITE, this.submitButton, @@ -31,14 +33,14 @@ class GFMultiSelect extends StatefulWidget { color: Colors.black87, size: 30, ), - this.dropdownbgColor = Colors.white, + this.dropdownBgColor = Colors.white, this.activeIcon = const Icon( Icons.check, size: 20, color: GFColors.DARK, ), this.inactiveIcon, - this.custombgColor = GFColors.SUCCESS, + this.customBgColor = GFColors.SUCCESS, this.selected = false, this.dropdownTitleTileBorder, this.dropdownTitleTileBorderRadius = @@ -49,8 +51,8 @@ class GFMultiSelect extends StatefulWidget { const BorderSide(color: Colors.black12, width: 1), this.dropdownTitleTileMargin = const EdgeInsets.all(16), this.dropdownTitleTilePadding = const EdgeInsets.all(12), - this.dropDownTitleTileHintText, - this.dropDownTitleTileHintTextStyle = + this.dropdownTitleTileHintText, + this.dropdownTitleTileHintTextStyle = const TextStyle(fontSize: 12, fontWeight: FontWeight.w400), Key key, }) : assert(selected != null), @@ -64,16 +66,16 @@ class GFMultiSelect extends StatefulWidget { final ValueChanged> onSelect; /// type of [String] to define the dropdownTitleTile title - final String dropDownTitleTileText; + final String dropdownTitleTileText; - /// type of [TextStyle] to define the textStyle of [dropDownTitleTileText] - final TextStyle dropDownTitleTileTextStyle; + /// type of [TextStyle] to define the textStyle of [dropdownTitleTileText] + final TextStyle dropdownTitleTileTextStyle; /// type of [String] to define the dropdownTitleTile hint text - final String dropDownTitleTileHintText; + final String dropdownTitleTileHintText; - /// type of [TextStyle] to define the textStyle of [dropDownTitleTileHintTextStyle] - final TextStyle dropDownTitleTileHintTextStyle; + /// type of [TextStyle] to define the textStyle of [dropdownTitleTileHintTextStyle] + final TextStyle dropdownTitleTileHintTextStyle; /// defines the border radius of the dropdownTitleTile final BorderRadius dropdownTitleTileBorderRadius; @@ -132,11 +134,11 @@ class GFMultiSelect extends StatefulWidget { /// defines dropdown ListTile's checkbox background color when its active /// type of [Color] used to change the backgroundColor of the active checkbox - final Color activebgColor; + final Color activeBgColor; /// defines dropdown ListTile's checkbox background color when its inactive /// type of [Color] used to change the backgroundColor of the inactive checkbox - final Color inactivebgColor; + final Color inactiveBgColor; /// defines dropdown ListTile's checkbox border color when its active /// type of [Color] used to change the border color of the active checkbox @@ -155,15 +157,14 @@ class GFMultiSelect extends StatefulWidget { final Widget inactiveIcon; /// type of [Color] used to change the background color of the custom active checkbox only - final Color custombgColor; + final Color customBgColor; /// To have the list tile appear selected when the checkbox is checked, pass the same value to both. /// Normally, this property is left to its default value, false. final bool selected; /// defines the background color of the dropdown. Can be given [Color] or [GFColors] - final Color dropdownbgColor; - + final Color dropdownBgColor; @override _GFMultiSelectState createState() => _GFMultiSelectState(); @@ -205,11 +206,11 @@ class _GFMultiSelectState extends State> { children: [ _selectedTitles.isEmpty ? Expanded( - child: Text(widget.dropDownTitleTileText, - style: widget.dropDownTitleTileTextStyle)) + child: Text(widget.dropdownTitleTileText, + style: widget.dropdownTitleTileTextStyle)) : Expanded( child: Text(_selectedTitles.join(', ').toString(), - style: widget.dropDownTitleTileTextStyle)), + style: widget.dropdownTitleTileTextStyle)), !showDropdown ? widget.expandedIcon : widget.collapsedIcon, ], ); @@ -235,14 +236,14 @@ class _GFMultiSelectState extends State> { ? const Border(bottom: BorderSide(color: Colors.white)) : Border(bottom: widget.dropdownUnderlineBorder), ), - child: widget.dropDownTitleTileHintText == null + child: widget.dropdownTitleTileHintText == null ? dropdownTile() : Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - '${widget.dropDownTitleTileHintText}', - style: widget.dropDownTitleTileHintTextStyle, + '${widget.dropdownTitleTileHintText}', + style: widget.dropdownTitleTileHintTextStyle, ), dropdownTile(), const SizedBox( @@ -255,7 +256,7 @@ class _GFMultiSelectState extends State> { ? Container( padding: const EdgeInsets.symmetric(vertical: 6), decoration: BoxDecoration( - color: widget.dropdownbgColor, + color: widget.dropdownBgColor, boxShadow: const [ BoxShadow( color: Colors.black12, @@ -288,14 +289,14 @@ class _GFMultiSelectState extends State> { padding: widget.padding, margin: widget.margin, size: widget.size, - activebgColor: widget.activebgColor, + activeBgColor: widget.activeBgColor, inactiveIcon: widget.inactiveIcon, activeBorderColor: widget.activeBorderColor, - inactivebgColor: widget.inactivebgColor, + inactiveBgColor: widget.inactiveBgColor, activeIcon: widget.activeIcon, inactiveBorderColor: widget.inactiveBorderColor, - custombgColor: widget.custombgColor, + customBgColor: widget.customBgColor, checkColor: widget.checkColor, type: widget.type, ))), diff --git a/lib/components/intro_screen/gf_intro_screen.dart b/lib/components/intro_screen/gf_intro_screen.dart index 1d3f8ba9..b80606eb 100644 --- a/lib/components/intro_screen/gf_intro_screen.dart +++ b/lib/components/intro_screen/gf_intro_screen.dart @@ -3,7 +3,9 @@ import 'package:flutter/material.dart'; import 'package:getwidget/getwidget.dart'; class GFIntroScreen extends StatefulWidget { - /// Presents informative screens to users with various posibilities in customization. + /// GF Intro Screen is virtual unique interactive Slider that helps users get started with an app. + /// It has many features that helps to build custom-made introduction screen sliders. + /// Presents informative screens to users with various possibilities in customization. const GFIntroScreen({ Key key, @required this.pageController, @@ -29,7 +31,7 @@ class GFIntroScreen extends StatefulWidget { this.dividerHeight = 1, this.dividerThickness = 2, this.dotShape, - this.inActiveColor = GFColors.LIGHT, + this.inactiveColor = GFColors.LIGHT, this.activeColor = GFColors.PRIMARY, this.dotHeight = 12, this.dotWidth = 12, @@ -190,7 +192,7 @@ class GFIntroScreen extends StatefulWidget { final ShapeBorder dotShape; /// defines pagination inactive color - final Color inActiveColor; + final Color inactiveColor; /// defines pagination active color final Color activeColor; @@ -247,7 +249,7 @@ class _GFIntroScreenState extends State { dividerHeight: widget.dividerHeight, dividerThickness: widget.dividerThickness, dotShape: widget.dotShape, - inActiveColor: widget.inActiveColor, + inactiveColor: widget.inactiveColor, activeColor: widget.activeColor, dotHeight: widget.dotHeight, dotWidth: widget.dotWidth, diff --git a/lib/components/intro_screen/gf_intro_screen_bottom_navigation_bar.dart b/lib/components/intro_screen/gf_intro_screen_bottom_navigation_bar.dart index 6361c960..4f2a23e2 100644 --- a/lib/components/intro_screen/gf_intro_screen_bottom_navigation_bar.dart +++ b/lib/components/intro_screen/gf_intro_screen_bottom_navigation_bar.dart @@ -20,7 +20,7 @@ class GFIntroScreenBottomNavigationBar extends StatefulWidget { this.dividerHeight = 1, this.dividerThickness = 2, this.dotShape, - this.inActiveColor = GFColors.DANGER, + this.inactiveColor = GFColors.DANGER, this.activeColor = GFColors.PRIMARY, this.dotHeight = 12, this.dotWidth = 12, @@ -157,7 +157,7 @@ class GFIntroScreenBottomNavigationBar extends StatefulWidget { final ShapeBorder dotShape; /// defines pagination inactive color - final Color inActiveColor; + final Color inactiveColor; /// defines pagination active color final Color activeColor; @@ -297,7 +297,7 @@ class _GFIntroScreenBottomNavigationBarState child: Material( shape: widget.dotShape ?? RoundedRectangleBorder(borderRadius: BorderRadius.circular(50)), - color: currentIndex == i ? widget.activeColor : widget.inActiveColor, + color: currentIndex == i ? widget.activeColor : widget.inactiveColor, child: Container( width: widget.dotWidth, height: widget.dotHeight, diff --git a/lib/components/list_tile/gf_list_tile.dart b/lib/components/list_tile/gf_list_tile.dart index 68fdf7ad..eed7744d 100644 --- a/lib/components/list_tile/gf_list_tile.dart +++ b/lib/components/list_tile/gf_list_tile.dart @@ -11,7 +11,7 @@ class GFListTile extends StatelessWidget { this.color, this.avatar, this.title, - this.subTitle, + this.subtitle, this.description, this.icon, this.padding = const EdgeInsets.all(8), @@ -29,10 +29,10 @@ class GFListTile extends StatelessWidget { assert(autofocus != null), super(key: key); - ///type of [String] used to pass text, alternative to title property and gets higher priority than title + /// type of [String] used to pass text, alternative to title property and gets higher priority than title final String titleText; - ///type of [String] used to pass text, alternative to subtitle property and gets higher priority than subtitle + /// type of [String] used to pass text, alternative to subtitle property and gets higher priority than subtitle final String subtitleText; /// The GFListTile's background color. Can be given [Color] or [GFColors] @@ -44,8 +44,8 @@ class GFListTile extends StatelessWidget { /// The title to display inside the [GFListTile]. see [Text] final Widget title; - /// The subTitle to display inside the [GFListTile]. see [Text] - final Widget subTitle; + /// The subtitle to display inside the [GFListTile]. see [Text] + final Widget subtitle; /// The description to display inside the [GFListTile]. see [Text] final Widget description; @@ -88,10 +88,11 @@ class GFListTile extends StatelessWidget { /// The color for the tile's [Material] when a pointer is hovering over it. final Color hoverColor; - /// {@macro flutter.widgets.Focus.focusNode} + /// Defines the keyboard focus for this widget. final FocusNode focusNode; - /// {@macro flutter.widgets.Focus.autofocus} + /// On true state it should focus itself if nothing else is already focused. + /// Defaults to false final bool autofocus; @override @@ -141,7 +142,7 @@ class GFListTile extends StatelessWidget { color: Colors.black54, ), ) - : subTitle ?? Container(), + : subtitle ?? Container(), description ?? Container() ], ), diff --git a/lib/components/radio/gf_radio.dart b/lib/components/radio/gf_radio.dart index 6bd558d5..4ff86546 100644 --- a/lib/components/radio/gf_radio.dart +++ b/lib/components/radio/gf_radio.dart @@ -14,8 +14,8 @@ class GFRadio extends StatefulWidget { this.size = GFSize.SMALL, this.type = GFRadioType.basic, this.radioColor = GFColors.SUCCESS, - this.activebgColor = GFColors.WHITE, - this.inactivebgColor = GFColors.WHITE, + this.activeBgColor = GFColors.WHITE, + this.inactiveBgColor = GFColors.WHITE, this.activeBorderColor = GFColors.DARK, this.inactiveBorderColor = GFColors.DARK, this.activeIcon = const Icon( @@ -24,7 +24,7 @@ class GFRadio extends StatefulWidget { color: GFColors.DARK, ), this.inactiveIcon, - this.custombgColor = GFColors.SUCCESS, + this.customBgColor = GFColors.SUCCESS, this.autofocus = false, this.focusNode, this.toggleable = false}) @@ -42,10 +42,10 @@ class GFRadio extends StatefulWidget { final Color radioColor; /// type of [Color] used to change the backgroundColor of the active radio button - final Color activebgColor; + final Color activeBgColor; /// type of [Color] used to change the backgroundColor of the inactive radio button - final Color inactivebgColor; + final Color inactiveBgColor; /// type of [Color] used to change the border color of the active radio button final Color activeBorderColor; @@ -63,7 +63,7 @@ class GFRadio extends StatefulWidget { final Widget inactiveIcon; /// type of [Color] used to change the background color of the custom active radio button only - final Color custombgColor; + final Color customBgColor; /// on true state this widget will be selected as the initial focus /// when no other node in its scope is currently focused @@ -116,7 +116,7 @@ class _GFRadioState extends State> with TickerProviderStateMixin { height: widget.size, width: widget.size, decoration: BoxDecoration( - color: selected ? widget.activebgColor : widget.inactivebgColor, + color: selected ? widget.activeBgColor : widget.inactiveBgColor, borderRadius: widget.type == GFRadioType.basic ? BorderRadius.circular(50) : widget.type == GFRadioType.square @@ -159,7 +159,7 @@ class _GFRadioState extends State> with TickerProviderStateMixin { decoration: BoxDecoration( borderRadius: const BorderRadius.all( Radius.circular(50)), - color: widget.custombgColor), + color: widget.customBgColor), ) ], ) diff --git a/lib/components/radio_list_tile/gf_radio_list_tile.dart b/lib/components/radio_list_tile/gf_radio_list_tile.dart index 4b712258..86c738d0 100644 --- a/lib/components/radio_list_tile/gf_radio_list_tile.dart +++ b/lib/components/radio_list_tile/gf_radio_list_tile.dart @@ -11,8 +11,8 @@ class GFRadioListTile extends StatelessWidget { this.size = GFSize.SMALL, this.type = GFRadioType.basic, this.radioColor = GFColors.SUCCESS, - this.activebgColor = GFColors.WHITE, - this.inactivebgColor = GFColors.WHITE, + this.activeBgColor = GFColors.WHITE, + this.inactiveBgColor = GFColors.WHITE, this.activeBorderColor = GFColors.DARK, this.inactiveBorderColor = GFColors.DARK, this.position = GFPosition.end, @@ -22,7 +22,7 @@ class GFRadioListTile extends StatelessWidget { color: GFColors.DARK, ), this.inactiveIcon, - this.custombgColor = GFColors.SUCCESS, + this.customBgColor = GFColors.SUCCESS, this.autofocus = false, this.focusNode, this.toggleable = false, @@ -31,7 +31,7 @@ class GFRadioListTile extends StatelessWidget { this.color, this.avatar, this.title, - this.subTitle, + this.subtitle, this.description, this.icon, this.padding = const EdgeInsets.all(8), @@ -63,8 +63,8 @@ class GFRadioListTile extends StatelessWidget { /// The title to display inside the [GFListTile]. see [Text] final Widget title; - /// The subTitle to display inside the [GFListTile]. see [Text] - final Widget subTitle; + /// The subtitle to display inside the [GFListTile]. see [Text] + final Widget subtitle; /// The description to display inside the [GFListTile]. see [Text] final Widget description; @@ -127,10 +127,10 @@ class GFRadioListTile extends StatelessWidget { final Color radioColor; /// type of [Color] used to change the backgroundColor of the active checkbox - final Color activebgColor; + final Color activeBgColor; /// type of [Color] used to change the backgroundColor of the inactive checkbox - final Color inactivebgColor; + final Color inactiveBgColor; /// type of [Color] used to change the border color of the active checkbox final Color activeBorderColor; @@ -148,7 +148,7 @@ class GFRadioListTile extends StatelessWidget { final Widget inactiveIcon; /// type of [Color] used to change the background color of the custom active checkbox only - final Color custombgColor; + final Color customBgColor; /// The value represented by this radio button. final T value; @@ -171,13 +171,13 @@ class GFRadioListTile extends StatelessWidget { size: size, type: type, radioColor: radioColor, - activebgColor: activebgColor, + activeBgColor: activeBgColor, inactiveIcon: inactiveIcon, activeBorderColor: activeBorderColor, - inactivebgColor: inactivebgColor, + inactiveBgColor: inactiveBgColor, activeIcon: activeIcon, inactiveBorderColor: inactiveBorderColor, - custombgColor: custombgColor, + customBgColor: customBgColor, toggleable: toggleable, ); return MergeSemantics( @@ -199,7 +199,7 @@ class GFRadioListTile extends StatelessWidget { selected: selected, avatar: position == GFPosition.start ? radio : avatar, titleText: titleText, - subTitle: subTitle, + subtitle: subtitle, subtitleText: subtitleText, description: description, color: color, diff --git a/lib/components/sticky_header/gf_sticky_header.dart b/lib/components/sticky_header/gf_sticky_header.dart index e0bbb6ad..c28a3b59 100644 --- a/lib/components/sticky_header/gf_sticky_header.dart +++ b/lib/components/sticky_header/gf_sticky_header.dart @@ -5,6 +5,7 @@ import 'package:flutter/widgets.dart'; import 'package:getwidget/getwidget.dart'; class GFStickyHeader extends MultiChildRenderObjectWidget { + /// GF Sticky Header will the stick header at top when content is being scrolled. /// Place this widget inside a [ListView], [GridView], [CustomScrollView], [SingleChildScrollView] or similar. GFStickyHeader( {Key key, From 434ba0e854d306aefdbef5208658b4de062890a8 Mon Sep 17 00:00:00 2001 From: deepikahr Date: Fri, 16 Oct 2020 20:07:57 +0530 Subject: [PATCH 23/25] changes in description and keynames --- lib/components/checkbox/gf_checkbox.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/components/checkbox/gf_checkbox.dart b/lib/components/checkbox/gf_checkbox.dart index e59c6d5e..c53fe2ed 100644 --- a/lib/components/checkbox/gf_checkbox.dart +++ b/lib/components/checkbox/gf_checkbox.dart @@ -69,7 +69,6 @@ class GFCheckbox extends StatefulWidget { /// an optional focus node to use as the focus node for this widget. final FocusNode focusNode; - @override _GFCheckboxState createState() => _GFCheckboxState(); } From 729993c4087ed2b282d84375e57fa6e9996ec645 Mon Sep 17 00:00:00 2001 From: deepikahr Date: Thu, 22 Oct 2020 19:22:26 +0530 Subject: [PATCH 24/25] getWidget issues fixed --- lib/components/carousel/gf_carousel.dart | 145 ++++++++++-------- lib/components/checkbox/gf_checkbox.dart | 4 - .../gf_checkbox_list_tile.dart | 6 +- lib/components/dropdown/gf_dropdown.dart | 9 +- lib/components/dropdown/gf_multiselect.dart | 54 +++++-- pubspec.lock | 6 +- 6 files changed, 129 insertions(+), 95 deletions(-) diff --git a/lib/components/carousel/gf_carousel.dart b/lib/components/carousel/gf_carousel.dart index 4718e4ca..e30e31c8 100644 --- a/lib/components/carousel/gf_carousel.dart +++ b/lib/components/carousel/gf_carousel.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; class GFCarousel extends StatefulWidget { /// Creates slide show of Images and [Widget] with animation for sliding. - GFCarousel({ + const GFCarousel({ @required this.items, this.pagerSize, this.passiveIndicator, @@ -13,7 +13,6 @@ class GFCarousel extends StatefulWidget { this.aspectRatio = 16 / 9, this.viewportFraction = 0.8, this.initialPage = 0, - int realPage = 10000, this.enableInfiniteScroll = true, this.reverse = false, this.autoPlay = false, @@ -25,12 +24,7 @@ class GFCarousel extends StatefulWidget { this.onPageChanged, this.scrollPhysics, this.scrollDirection = Axis.horizontal, - }) : realPage = enableInfiniteScroll ? realPage + initialPage : initialPage, - pageController = PageController( - viewportFraction: viewportFraction, - initialPage: - enableInfiniteScroll ? realPage + initialPage : initialPage, - ); + }); /// The pagination dots size can be defined using [double]. final double pagerSize; @@ -59,9 +53,6 @@ class GFCarousel extends StatefulWidget { /// The initial page to show when first creating the [GFCarousel]. Defaults to 0. final num initialPage; - /// The actual index of the [PageView]. - final num realPage; - /// Determines if slides should loop infinitely or be limited to item length. Defaults to true, i.e. infinite loop. final bool enableInfiniteScroll; @@ -107,48 +98,44 @@ class GFCarousel extends StatefulWidget { /// Defaults to matching platform conventions. final ScrollPhysics scrollPhysics; - /// [pageController] is created using the properties passed to the constructor - /// and can be used to control the [PageView] it is passed to. - final PageController pageController; - /// Animates the controlled [GFCarousel] to the next page. /// /// The animation lasts for the given duration and follows the given curve. /// The returned [Future] resolves when the animation completes. - Future nextPage({Duration duration, Curve curve}) => - pageController.nextPage(duration: duration, curve: curve); - - /// Animates the controlled [GFCarousel] to the previous page. - /// - /// The animation lasts for the given duration and follows the given curve. - /// The returned [Future] resolves when the animation completes. - Future previousPage({Duration duration, Curve curve}) => - pageController.previousPage(duration: duration, curve: curve); - - /// Changes which page is displayed in the controlled [GFCarousel]. - /// - /// Jumps the page position from its current value to the given value, - /// without animation, and without checking if the new value is in range. - void jumpToPage(int page) { - final index = - _getRealIndex(pageController.page.toInt(), realPage, items.length); - return pageController - .jumpToPage(pageController.page.toInt() + page - index); - } - - /// Animates the controlled [GFCarousel] from the current page to the given page. - /// - /// The animation lasts for the given duration and follows the given curve. - /// The returned [Future] resolves when the animation completes. - Future animateToPage(int page, {Duration duration, Curve curve}) { - final index = - _getRealIndex(pageController.page.toInt(), realPage, items.length); - return pageController.animateToPage( - pageController.page.toInt() + page - index, - duration: duration, - curve: curve, - ); - } + // Future nextPage({Duration duration, Curve curve}) => + // pageController.nextPage(duration: duration, curve: curve); + // + // /// Animates the controlled [GFCarousel] to the previous page. + // /// + // /// The animation lasts for the given duration and follows the given curve. + // /// The returned [Future] resolves when the animation completes. + // Future previousPage({Duration duration, Curve curve}) => + // pageController.previousPage(duration: duration, curve: curve); + // + // /// Changes which page is displayed in the controlled [GFCarousel]. + // /// + // /// Jumps the page position from its current value to the given value, + // /// without animation, and without checking if the new value is in range. + // void jumpToPage(int page) { + // final index = + // _getRealIndex(pageController.page.toInt(), realPage, items.length); + // return pageController + // .jumpToPage(pageController.page.toInt() + page - index); + // } + // + // /// Animates the controlled [GFCarousel] from the current page to the given page. + // /// + // /// The animation lasts for the given duration and follows the given curve. + // /// The returned [Future] resolves when the animation completes. + // Future animateToPage(int page, {Duration duration, Curve curve}) { + // final index = + // _getRealIndex(pageController.page.toInt(), realPage, items.length); + // return pageController.animateToPage( + // pageController.page.toInt() + page - index, + // duration: duration, + // curve: curve, + // ); + // } List map(List list, Function handler) { List result; @@ -173,15 +160,31 @@ class _GFCarouselState extends State with TickerProviderStateMixin { /// Width of cells container double width = 0; + /// [pageController] is created using the properties passed to the constructor + /// and can be used to control the [PageView] it is passed to. + PageController pageController; + + /// The actual index of the [PageView]. + int realPage = 10000; + @override void initState() { super.initState(); + realPage = widget.enableInfiniteScroll + ? realPage + widget.initialPage + : widget.initialPage; + pageController = PageController( + viewportFraction: widget.viewportFraction, + initialPage: widget.enableInfiniteScroll + ? realPage + widget.initialPage + : widget.initialPage, + ); timer = getPlayTimer(); } Timer getPlayTimer() => Timer.periodic(widget.autoPlayInterval, (_) { if (widget.autoPlay && widget.items.length > 1) { - widget.pageController.nextPage( + pageController.nextPage( duration: widget.autoPlayAnimationDuration, curve: widget.autoPlayCurve); } @@ -230,7 +233,7 @@ class _GFCarouselState extends State with TickerProviderStateMixin { getPageWrapper(PageView.builder( physics: widget.scrollPhysics, scrollDirection: widget.scrollDirection, - controller: widget.pageController, + controller: pageController, reverse: widget.reverse, itemCount: widget.items.length == 1 ? widget.items.length @@ -239,8 +242,8 @@ class _GFCarouselState extends State with TickerProviderStateMixin { : widget.items.length, onPageChanged: (int index) { int currentPage; - currentPage = _getRealIndex(index + widget.initialPage, - widget.realPage, widget.items.length); + currentPage = _getRealIndex( + index + widget.initialPage, realPage, widget.items.length); if (widget.onPageChanged != null) { widget.onPageChanged(currentPage); } @@ -253,29 +256,47 @@ class _GFCarouselState extends State with TickerProviderStateMixin { itemBuilder: (BuildContext context, int i) { final int index = _getRealIndex( i + widget.initialPage, - widget.realPage, + realPage, widget.items.length, ); + currentSlide = index; return AnimatedBuilder( - animation: widget.pageController, + animation: pageController, child: widget.items[index], builder: (BuildContext context, child) { // on the first render, the pageController.page is null, // this is a dirty hack - if (widget.pageController.position.minScrollExtent == null || - widget.pageController.position.maxScrollExtent == null) { - Future.delayed(const Duration(microseconds: 1), () { - setState(() {}); - }); - return Container(); + + // if (pageController.position.minScrollExtent == null || + // pageController.position.maxScrollExtent == null) { + // Future.delayed(const Duration(microseconds: 1), () {}); + // return Container(); + // } + + double value; + try { + value = pageController.page - i; + // ignore: avoid_catches_without_on_clauses + } catch (e) { + // value = 1; + final BuildContext storageContext = + pageController.position.context.storageContext; + final double previousSavedPosition = + PageStorage.of(storageContext) + ?.readState(storageContext); + if (previousSavedPosition != null) { + value = previousSavedPosition - i.toDouble(); + } else { + value = realPage.toDouble() - i.toDouble(); + } } - double value = widget.pageController.page - i; value = (1 - (value.abs() * 0.3)).clamp(0.0, 1.0); final double height = widget.height ?? MediaQuery.of(context).size.width * (1 / widget.aspectRatio); + final double distortionValue = widget.enlargeMainPage ? Curves.easeOut.transform(value) : 1.0; diff --git a/lib/components/checkbox/gf_checkbox.dart b/lib/components/checkbox/gf_checkbox.dart index c53fe2ed..e1188619 100644 --- a/lib/components/checkbox/gf_checkbox.dart +++ b/lib/components/checkbox/gf_checkbox.dart @@ -7,7 +7,6 @@ class GFCheckbox extends StatefulWidget { {Key key, this.size = GFSize.MEDIUM, this.type = GFCheckboxType.basic, - this.checkColor = GFColors.WHITE, this.activeBgColor = GFColors.PRIMARY, this.inactiveBgColor = GFColors.WHITE, this.activeBorderColor = GFColors.WHITE, @@ -32,9 +31,6 @@ class GFCheckbox extends StatefulWidget { /// type of [double] which is GFSize ie, small, medium and large and can use any double value final double size; - /// type of [Color] used to change the checkColor when the checkbox is active - final Color checkColor; - /// type of [Color] used to change the backgroundColor of the active checkbox final Color activeBgColor; diff --git a/lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart b/lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart index 0b8c9810..ba31a401 100644 --- a/lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart +++ b/lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart @@ -20,7 +20,6 @@ class GFCheckboxListTile extends StatelessWidget { this.margin = const EdgeInsets.symmetric(vertical: 8, horizontal: 16), this.size = GFSize.MEDIUM, this.type = GFCheckboxType.basic, - this.checkColor = GFColors.WHITE, this.activeBgColor = GFColors.PRIMARY, this.inactiveBgColor = GFColors.WHITE, this.activeBorderColor = GFColors.WHITE, @@ -74,9 +73,6 @@ class GFCheckboxListTile extends StatelessWidget { /// type of [double] which is GFSize ie, small, medium and large and can use any double value final double size; - /// type pf [Color] used to change the checkcolor when the checkbox is active - final Color checkColor; - /// type of [Color] used to change the backgroundColor of the active checkbox final Color activeBgColor; @@ -132,7 +128,7 @@ class GFCheckboxListTile extends StatelessWidget { activeIcon: activeIcon, inactiveBorderColor: inactiveBorderColor, customBgColor: customBgColor, - checkColor: checkColor, + // checkColor: checkColor, type: type); return MergeSemantics( child: GFListTile( diff --git a/lib/components/dropdown/gf_dropdown.dart b/lib/components/dropdown/gf_dropdown.dart index 7d987ec5..8d8caa90 100644 --- a/lib/components/dropdown/gf_dropdown.dart +++ b/lib/components/dropdown/gf_dropdown.dart @@ -22,7 +22,7 @@ class GFDropdown extends StatefulWidget { this.iconSize = 24.0, this.isDense = true, this.isExpanded = false, - this.itemHeight = kMinInteractiveDimension, + this.itemHeight = 40, this.focusColor, this.focusNode, this.autofocus = false, @@ -30,7 +30,7 @@ class GFDropdown extends StatefulWidget { this.padding = const EdgeInsets.all(5), this.borderRadius = const BorderRadius.all(Radius.circular(4)), this.border = const BorderSide( - color: Colors.white, width: 1, style: BorderStyle.solid), + color: Colors.transparent, width: 1, style: BorderStyle.solid), this.dropdownButtonColor = GFColors.WHITE}) : super(key: key); @@ -125,7 +125,8 @@ class _GFDropdownState extends State { side: widget.border, borderRadius: widget.borderRadius, ), - child: Padding( + child: Container( + height: widget.itemHeight, padding: widget.padding, child: DropdownButton( items: widget.items, @@ -143,7 +144,7 @@ class _GFDropdownState extends State { iconSize: widget.iconSize, isDense: widget.isDense, isExpanded: widget.isExpanded, - itemHeight: widget.itemHeight, + // itemHeight: widget.itemHeight, focusColor: widget.focusColor, focusNode: widget.focusNode, autofocus: widget.autofocus, diff --git a/lib/components/dropdown/gf_multiselect.dart b/lib/components/dropdown/gf_multiselect.dart index d5ededa7..be98ec28 100644 --- a/lib/components/dropdown/gf_multiselect.dart +++ b/lib/components/dropdown/gf_multiselect.dart @@ -17,12 +17,12 @@ class GFMultiSelect extends StatefulWidget { this.margin = const EdgeInsets.all(5), this.size = GFSize.SMALL, this.type = GFCheckboxType.basic, - this.checkColor = GFColors.WHITE, this.activeBgColor = GFColors.WHITE, this.inactiveBgColor = GFColors.WHITE, this.activeBorderColor = GFColors.WHITE, this.inactiveBorderColor = GFColors.WHITE, this.submitButton, + this.cancelButton, this.expandedIcon = const Icon( Icons.keyboard_arrow_down, color: Colors.black87, @@ -48,12 +48,13 @@ class GFMultiSelect extends StatefulWidget { this.dropdownTitleTileColor = GFColors.WHITE, this.hideDropdownUnderline = false, this.dropdownUnderlineBorder = - const BorderSide(color: Colors.black12, width: 1), + const BorderSide(color: Colors.black45, width: 1), this.dropdownTitleTileMargin = const EdgeInsets.all(16), this.dropdownTitleTilePadding = const EdgeInsets.all(12), this.dropdownTitleTileHintText, this.dropdownTitleTileHintTextStyle = const TextStyle(fontSize: 12, fontWeight: FontWeight.w400), + this.dropdownButton, Key key, }) : assert(selected != null), super(key: key); @@ -105,9 +106,12 @@ class GFMultiSelect extends StatefulWidget { /// defines the dropdownTitleTile's trailing icon when dropdown is not visible final Widget collapsedIcon; - /// defines the button in the dropdown + /// defines the submit button in the dropdown final Widget submitButton; + /// defines the cancel button in the dropdown + final Widget cancelButton; + /// defines dropdown checkbox ListTile's background color. Can be given [Color] or [GFColors] final dynamic color; @@ -128,10 +132,6 @@ class GFMultiSelect extends StatefulWidget { /// type of [double] which is GFSize ie, small, medium and large and can use any double value final double size; - /// defines dropdown ListTile's checkbox color when its active - /// type of [Color] used to change the checkcolor when the checkbox is active - final Color checkColor; - /// defines dropdown ListTile's checkbox background color when its active /// type of [Color] used to change the backgroundColor of the active checkbox final Color activeBgColor; @@ -166,6 +166,8 @@ class GFMultiSelect extends StatefulWidget { /// defines the background color of the dropdown. Can be given [Color] or [GFColors] final Color dropdownBgColor; + final Widget dropdownButton; + @override _GFMultiSelectState createState() => _GFMultiSelectState(); } @@ -233,7 +235,8 @@ class _GFMultiSelectState extends State> { child: Container( decoration: BoxDecoration( border: widget.hideDropdownUnderline - ? const Border(bottom: BorderSide(color: Colors.white)) + ? const Border( + bottom: BorderSide(color: Colors.transparent)) : Border(bottom: widget.dropdownUnderlineBorder), ), child: widget.dropdownTitleTileHintText == null @@ -297,17 +300,34 @@ class _GFMultiSelectState extends State> { inactiveBorderColor: widget.inactiveBorderColor, customBgColor: widget.customBgColor, - checkColor: widget.checkColor, + // checkColor: widget.checkColor, type: widget.type, ))), - GFButton( - onPressed: () { - setState(() { - showDropdown = !showDropdown; - }); - }, - child: widget.submitButton ?? const Text('OK'), - ) + widget.dropdownButton ?? + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + GFButton( + onPressed: () { + setState(() { + showDropdown = !showDropdown; + _selectedTitles.clear(); + _selectedTitlesIndex.clear(); + }); + }, + child: + widget.cancelButton ?? const Text('CANCEL'), + ), + GFButton( + onPressed: () { + setState(() { + showDropdown = !showDropdown; + }); + }, + child: widget.submitButton ?? const Text('OK'), + ) + ], + ) ], ), ), diff --git a/pubspec.lock b/pubspec.lock index b308ac32..65991e82 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -73,7 +73,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0-nullsafety.4" path: dependency: transitive description: @@ -99,7 +99,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0-nullsafety.2" stream_channel: dependency: transitive description: @@ -143,4 +143,4 @@ packages: source: hosted version: "2.1.0-nullsafety.3" sdks: - dart: ">=2.10.0-110 <2.11.0" + dart: ">=2.10.0-110 <=2.11.0-213.1.beta" From ffac50802b85521609b6c21ae1049acaa1ab6ce7 Mon Sep 17 00:00:00 2001 From: deepikahr Date: Tue, 27 Oct 2020 10:38:59 +0530 Subject: [PATCH 25/25] GFCarousel issues fixed --- lib/components/carousel/gf_carousel.dart | 54 ------------------------ 1 file changed, 54 deletions(-) diff --git a/lib/components/carousel/gf_carousel.dart b/lib/components/carousel/gf_carousel.dart index e30e31c8..fcf8173a 100644 --- a/lib/components/carousel/gf_carousel.dart +++ b/lib/components/carousel/gf_carousel.dart @@ -85,8 +85,6 @@ class GFCarousel extends StatefulWidget { /// Called whenever the page in the center of the viewport changes. final Function(int index) onPageChanged; -// int onPageIndex; - /// How the carousel should respond to user input. /// /// For example, determines how the items continues to animate after the @@ -98,45 +96,6 @@ class GFCarousel extends StatefulWidget { /// Defaults to matching platform conventions. final ScrollPhysics scrollPhysics; - /// Animates the controlled [GFCarousel] to the next page. - /// - /// The animation lasts for the given duration and follows the given curve. - /// The returned [Future] resolves when the animation completes. - // Future nextPage({Duration duration, Curve curve}) => - // pageController.nextPage(duration: duration, curve: curve); - // - // /// Animates the controlled [GFCarousel] to the previous page. - // /// - // /// The animation lasts for the given duration and follows the given curve. - // /// The returned [Future] resolves when the animation completes. - // Future previousPage({Duration duration, Curve curve}) => - // pageController.previousPage(duration: duration, curve: curve); - // - // /// Changes which page is displayed in the controlled [GFCarousel]. - // /// - // /// Jumps the page position from its current value to the given value, - // /// without animation, and without checking if the new value is in range. - // void jumpToPage(int page) { - // final index = - // _getRealIndex(pageController.page.toInt(), realPage, items.length); - // return pageController - // .jumpToPage(pageController.page.toInt() + page - index); - // } - // - // /// Animates the controlled [GFCarousel] from the current page to the given page. - // /// - // /// The animation lasts for the given duration and follows the given curve. - // /// The returned [Future] resolves when the animation completes. - // Future animateToPage(int page, {Duration duration, Curve curve}) { - // final index = - // _getRealIndex(pageController.page.toInt(), realPage, items.length); - // return pageController.animateToPage( - // pageController.page.toInt() + page - index, - // duration: duration, - // curve: curve, - // ); - // } - List map(List list, Function handler) { List result; result = []; @@ -152,7 +111,6 @@ class GFCarousel extends StatefulWidget { class _GFCarouselState extends State with TickerProviderStateMixin { Timer timer; -// int _current = 0; /// Size of cell double size = 0; @@ -249,9 +207,7 @@ class _GFCarouselState extends State with TickerProviderStateMixin { } if (widget.pagination == true && widget.onPageChanged == null) { onPageSlide(currentPage); -// _current = currentPage; } -// _current = currentPage; }, itemBuilder: (BuildContext context, int i) { final int index = _getRealIndex( @@ -265,21 +221,11 @@ class _GFCarouselState extends State with TickerProviderStateMixin { animation: pageController, child: widget.items[index], builder: (BuildContext context, child) { - // on the first render, the pageController.page is null, - // this is a dirty hack - - // if (pageController.position.minScrollExtent == null || - // pageController.position.maxScrollExtent == null) { - // Future.delayed(const Duration(microseconds: 1), () {}); - // return Container(); - // } - double value; try { value = pageController.page - i; // ignore: avoid_catches_without_on_clauses } catch (e) { - // value = 1; final BuildContext storageContext = pageController.position.context.storageContext; final double previousSavedPosition =