From 198a1854a9dd25a0343121519ac42e974d786df3 Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Tue, 14 Jul 2020 11:46:06 +0300 Subject: [PATCH] add documentation Mohammad Aljammal and Elham Rababah --- lib/uitl/cupertino_picker.dart | 57 ++++++--- lib/widgets/avatar/large_avatar.dart | 29 +++-- lib/widgets/buttons/button.dart | 21 ++-- lib/widgets/buttons/mini_button.dart | 22 ++-- lib/widgets/buttons/secondary_button.dart | 115 ++++++++++-------- lib/widgets/charts/app_time_series_chart.dart | 4 +- lib/widgets/data_display/list/ListItem.dart | 73 ----------- .../data_display/list/custom_Item.dart | 93 ++++++++++++++ ...Container.dart => flexible_container.dart} | 15 ++- lib/widgets/data_display/text.dart | 2 +- lib/widgets/drawer/app_drawer_widget.dart | 4 +- lib/widgets/input/custom_switch.dart | 5 + lib/widgets/transitions/fade_page.dart | 2 + lib/widgets/transitions/slide_up_page.dart | 61 +++++----- 14 files changed, 299 insertions(+), 204 deletions(-) delete mode 100644 lib/widgets/data_display/list/ListItem.dart create mode 100644 lib/widgets/data_display/list/custom_Item.dart rename lib/widgets/data_display/list/{ListContainer.dart => flexible_container.dart} (55%) diff --git a/lib/uitl/cupertino_picker.dart b/lib/uitl/cupertino_picker.dart index 34da2f66..d40d4b39 100644 --- a/lib/uitl/cupertino_picker.dart +++ b/lib/uitl/cupertino_picker.dart @@ -3,37 +3,52 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - -class CupertinoPickerUtils{ - +class CupertinoPickerUtils { int cupertinoPickerIndex = 0; /// show Cupertino Picker for any list [context] the page BuildContext /// [items] the list of items we need to show /// [onSelectFun] the call function on select event - ///The [isDismissible] parameter specifies whether the bottom sheet will be + /// [isDismissible] parameter specifies whether the bottom sheet will be /// dismissed when user taps on the scrim. + + /// [itemExtent] All children will be given the [BoxConstraints] to match this exact + /// height. Must not be null and must be positive. + + /// The [looping] argument decides whether the child list loops and can be + /// scrolled infinitely. If set to true, scrolling past the end of the list + /// will loop the list back to the beginning. If set to false, the list will + /// stop scrolling when you reach the end or the beginning. + + /// [backgroundColor] background color showCupertinoPicker( - {context, items, decKey, onSelectFun, bool isDismissible = false}) { + {BuildContext context, + List items, + String decKey, + Function onSelectFun, + bool isDismissible = false, + double itemExtent = 25, + bool looping = true, + Color backgroundColor = const Color(0xfff7f7f7)}) { showModalBottomSheet( isDismissible: isDismissible, context: context, builder: (BuildContext builder) { return Container( height: SizeConfig.realScreenHeight * 0.4, - color: Color(0xfff7f7f7), + color: backgroundColor, child: Column( mainAxisAlignment: MainAxisAlignment.end, children: [ Container( - color: Color(0xfff7f7f7), + color: backgroundColor, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ CupertinoButton( child: Text(TranslationBase.of(context).cancel, style: - TextStyle(color: Theme.of(context).primaryColor)), + TextStyle(color: Theme.of(context).primaryColor)), onPressed: () { Navigator.pop(context); }, @@ -53,8 +68,14 @@ class CupertinoPickerUtils{ ), Container( height: SizeConfig.realScreenHeight * 0.3, - color: Color(0xfff7f7f7), - child: buildPickerItems(context, items, decKey, onSelectFun)) + color: backgroundColor, + child: buildPickerItems( + context: context, + decKey: decKey, + itemExtent: itemExtent, + items: items, + looping: looping, + onSelectFun: onSelectFun)) ], ), ); @@ -67,22 +88,28 @@ class CupertinoPickerUtils{ /// [items] the list of items we need to show /// [onSelectFun] the call function on select event /// [decKey] the key we show for user - buildPickerItems(context, List items, decKey, onSelectFun) { + buildPickerItems( + {BuildContext context, + List items, + String decKey, + Function onSelectFun, + double itemExtent, + bool looping}) { return CupertinoPicker( magnification: 1.5, scrollController: - FixedExtentScrollController(initialItem: cupertinoPickerIndex), + FixedExtentScrollController(initialItem: cupertinoPickerIndex), children: items.map((item) { return Text( '${item["$decKey"]}', style: TextStyle(fontSize: SizeConfig.textMultiplier * 2), ); }).toList(), - itemExtent: 25, - looping: true, + itemExtent: itemExtent, + looping: looping, onSelectedItemChanged: (int index) { cupertinoPickerIndex = index; }, ); } -} \ No newline at end of file +} diff --git a/lib/widgets/avatar/large_avatar.dart b/lib/widgets/avatar/large_avatar.dart index ad3cd277..cd6ee539 100644 --- a/lib/widgets/avatar/large_avatar.dart +++ b/lib/widgets/avatar/large_avatar.dart @@ -2,15 +2,24 @@ import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +/// LargeAvatar +/// [name] the user name +/// [url] the image url +/// [disableProfileView] disable user profile view +/// [radius] the avatar radius +/// [width] the avatar width +/// [height] the avatar height +/// [onTap] on tap function class LargeAvatar extends StatelessWidget { LargeAvatar( {Key key, - this.name, + @required this.name, this.url, this.disableProfileView: false, this.radius = 60.0, this.width = 90, - this.height = 90}) + this.height = 90, + this.onTap}) : super(key: key); final String name; @@ -19,6 +28,7 @@ class LargeAvatar extends StatelessWidget { final double radius; final double width; final double height; + final GestureTapCallback onTap; Widget _getAvatar() { if (url != null && url.isNotEmpty && Uri.parse(url).isAbsolute) { @@ -33,30 +43,19 @@ class LargeAvatar extends StatelessWidget { ), ), ); - } else if (name == null || name.isEmpty) { - return Center( - child: Texts( - 'DR', - color: Colors.white, - )); - } else { + } else return Center( child: Texts( name[0].toUpperCase(), color: Colors.white, fontSize: 18, )); - } } @override Widget build(BuildContext context) { return InkWell( - onTap: disableProfileView - ? null - : () { - //TODO when we need that - }, + onTap: disableProfileView ? null : onTap, child: Container( decoration: BoxDecoration( gradient: LinearGradient( diff --git a/lib/widgets/buttons/button.dart b/lib/widgets/buttons/button.dart index 0c71f25a..d5d8f34e 100644 --- a/lib/widgets/buttons/button.dart +++ b/lib/widgets/buttons/button.dart @@ -1,16 +1,21 @@ import 'package:flutter/material.dart'; - +/// Button widget +/// [label] button label +/// [icon] button icon its optional +/// [onTap] button function +/// [loading] show the progress indicator +/// [elevation] color elevation value class Button extends StatefulWidget { Button( {Key key, - this.title: "", + this.label: "", this.icon, this.onTap, this.loading: false, this.elevation: true}) : super(key: key); - final String title; + final String label; final Widget icon; final VoidCallback onTap; final bool loading; @@ -51,7 +56,7 @@ class _ButtonState extends State