diff --git a/CHANGELOG.md b/CHANGELOG.md index 731678f8..7c2eddb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.0.87 + +- [DSCircularProgress] Added widget to build circular progress indicator. +- [DSSearchInput] Added ```enabled``` property. + ## 0.0.86 - [DSMediaFormatService] Added service to format all kinds of media, like audios and videos. diff --git a/lib/blip_ds.dart b/lib/blip_ds.dart index 759dc59e..c6723372 100644 --- a/lib/blip_ds.dart +++ b/lib/blip_ds.dart @@ -151,6 +151,8 @@ export 'src/widgets/utils/ds_cached_network_image_view.widget.dart' show DSCachedNetworkImageView; export 'src/widgets/utils/ds_card.widget.dart' show DSCard; export 'src/widgets/utils/ds_chip.widget.dart' show DSChip; +export 'src/widgets/utils/ds_circular_progress.widget.dart' + show DSCircularProgress; export 'src/widgets/utils/ds_divider.widget.dart' show DSDivider; export 'src/widgets/utils/ds_expanded_image.widget.dart' show DSExpandedImage; export 'src/widgets/utils/ds_file_extension_icon.util.dart' diff --git a/lib/src/widgets/chat/ds_image_message_bubble.widget.dart b/lib/src/widgets/chat/ds_image_message_bubble.widget.dart index 92311f76..260c9ecd 100644 --- a/lib/src/widgets/chat/ds_image_message_bubble.widget.dart +++ b/lib/src/widgets/chat/ds_image_message_bubble.widget.dart @@ -8,6 +8,7 @@ import '../../models/ds_document_select.model.dart'; import '../../models/ds_message_bubble_style.model.dart'; import '../../themes/colors/ds_colors.theme.dart'; import '../texts/ds_caption_text.widget.dart'; +import '../utils/ds_circular_progress.widget.dart'; import '../utils/ds_expanded_image.widget.dart'; import 'ds_document_select.widget.dart'; import 'ds_message_bubble.widget.dart'; @@ -114,7 +115,11 @@ class _DSImageMessageBubbleState extends State isLoading: false, shouldAuthenticate: widget.shouldAuthenticate, ) - : _buildDownloadProgress(), + : DSCircularProgress( + currentProgress: _controller.downloadProgress, + maximumProgress: _controller.maximumProgress, + foregroundColor: foregroundColor, + ), ), if ((widget.title?.isNotEmpty ?? false) || (widget.text?.isNotEmpty ?? false)) @@ -161,27 +166,6 @@ class _DSImageMessageBubbleState extends State ); } - Widget _buildDownloadProgress() { - final foregroundColor = widget.style.isLightBubbleBackground(widget.align) - ? DSColors.neutralDarkCity - : DSColors.neutralLightSnow; - - final double percent = _controller.maximumProgress.value > 0 - ? _controller.downloadProgress.value / _controller.maximumProgress.value - : 0; - - return Center( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: CircularProgressIndicator( - color: foregroundColor, - backgroundColor: Colors.grey, - value: percent, - ), - ), - ); - } - @override bool get wantKeepAlive => true; } diff --git a/lib/src/widgets/chat/video/ds_video_message_bubble.widget.dart b/lib/src/widgets/chat/video/ds_video_message_bubble.widget.dart index f5eee8fc..204850c0 100644 --- a/lib/src/widgets/chat/video/ds_video_message_bubble.widget.dart +++ b/lib/src/widgets/chat/video/ds_video_message_bubble.widget.dart @@ -11,7 +11,7 @@ import '../../../services/ds_auth.service.dart'; import '../../../themes/colors/ds_colors.theme.dart'; import '../../../themes/icons/ds_icons.dart'; import '../../buttons/ds_button.widget.dart'; -import '../../texts/ds_caption_small_text.widget.dart'; +import '../../utils/ds_circular_progress.widget.dart'; import '../ds_message_bubble.widget.dart'; import '../ds_show_more_text.widget.dart'; import 'ds_video_body.widget.dart'; @@ -131,7 +131,11 @@ class _DSVideoMessageBubbleState extends State color: DSColors.neutralDarkRooftop, ) : _controller.isDownloading.value - ? _buildDownloadProgress(foregroundColor) + ? DSCircularProgress( + currentProgress: _controller.downloadProgress, + maximumProgress: _controller.maximumProgress, + foregroundColor: foregroundColor, + ) : _controller.thumbnail.isEmpty ? Center( child: SizedBox( @@ -186,32 +190,4 @@ class _DSVideoMessageBubbleState extends State ), ); } - - Widget _buildDownloadProgress(final Color foregroundColor) { - final double percent = _controller.maximumProgress.value > 0 - ? _controller.downloadProgress.value / _controller.maximumProgress.value - : 0; - - return AnimatedOpacity( - opacity: _controller.maximumProgress.value > 0 ? 1 : 0, - duration: const Duration(milliseconds: 250), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: CircularProgressIndicator( - color: foregroundColor, - backgroundColor: Colors.grey, - value: percent, - ), - ), - DSCaptionSmallText( - _controller.getDownloadProgress(), - color: foregroundColor, - ) - ], - ), - ); - } } diff --git a/lib/src/widgets/fields/ds_search_input.widget.dart b/lib/src/widgets/fields/ds_search_input.widget.dart index 962b2c39..2eb6f984 100644 --- a/lib/src/widgets/fields/ds_search_input.widget.dart +++ b/lib/src/widgets/fields/ds_search_input.widget.dart @@ -15,6 +15,7 @@ class DSSearchInput extends StatelessWidget { this.hintText, this.iconBackgroundColor = DSColors.disabledBg, this.iconForegroundColor = DSColors.primaryNight, + this.enabled, }); final void Function(String term) onSearch; @@ -25,6 +26,7 @@ class DSSearchInput extends StatelessWidget { final String? hintText; final Color iconBackgroundColor; final Color iconForegroundColor; + final bool? enabled; // TODO: check if can use DSTextField or DSInputContainer @override @@ -32,6 +34,7 @@ class DSSearchInput extends StatelessWidget { return SizedBox( height: 44.0, child: TextField( + enabled: enabled ?? true, focusNode: focusNode, controller: controller, onChanged: onSearch, @@ -81,13 +84,8 @@ class DSSearchInput extends StatelessWidget { width: 1.0, ), ), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(8.0), - borderSide: const BorderSide( - color: DSColors.neutralMediumWave, - width: 1.0, - ), - ), + disabledBorder: _getBorder(), + enabledBorder: _getBorder(), filled: true, hintText: hintText, hintStyle: const DSBodyTextStyle( @@ -97,4 +95,12 @@ class DSSearchInput extends StatelessWidget { ), ); } + + OutlineInputBorder _getBorder() => OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: const BorderSide( + color: DSColors.neutralMediumWave, + width: 1.0, + ), + ); } diff --git a/lib/src/widgets/radio/ds_radio_tile.widget.dart b/lib/src/widgets/radio/ds_radio_tile.widget.dart index 280d8ddf..154f95c9 100644 --- a/lib/src/widgets/radio/ds_radio_tile.widget.dart +++ b/lib/src/widgets/radio/ds_radio_tile.widget.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import '../../../blip_ds.dart'; +import 'ds_radio.widget.dart'; class DSRadioTile extends StatelessWidget { /// Create a Design System's tile widget with a radio button diff --git a/lib/src/widgets/utils/ds_circular_progress.widget.dart b/lib/src/widgets/utils/ds_circular_progress.widget.dart new file mode 100644 index 00000000..7166996f --- /dev/null +++ b/lib/src/widgets/utils/ds_circular_progress.widget.dart @@ -0,0 +1,64 @@ +import 'package:file_sizes/file_sizes.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../../themes/colors/ds_colors.theme.dart'; +import '../texts/ds_caption_small_text.widget.dart'; + +class DSCircularProgress extends StatelessWidget { + final RxInt maximumProgress; + final RxInt currentProgress; + final Color? foregroundColor; + + const DSCircularProgress({ + super.key, + required this.maximumProgress, + required this.currentProgress, + this.foregroundColor, + }); + + @override + Widget build(BuildContext context) { + return Obx( + () { + final double percent = maximumProgress.value > 0 + ? currentProgress.value / maximumProgress.value + : 0; + + return SizedBox( + width: double.infinity, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: CircularProgressIndicator( + color: DSColors.primary, + backgroundColor: Colors.grey, + value: currentProgress.value < maximumProgress.value + ? percent + : null, + ), + ), + DSCaptionSmallText( + _buildProgress(), + color: foregroundColor ?? DSColors.neutralDarkCity, + ) + ], + ), + ); + }, + ); + } + + String _buildProgress() { + String getSize(int value) => FileSize.getSize( + value, + precision: PrecisionValue.One, + ); + + return '${getSize(currentProgress.value)} / ${getSize(maximumProgress.value)}'; + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 70449d5d..718fc34f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: blip_ds description: Blip Design System for Flutter. -version: 0.0.86 +version: 0.0.87 homepage: https://github.com/takenet/blip-ds-flutter#readme repository: https://github.com/takenet/blip-ds-flutter @@ -33,7 +33,6 @@ dependencies: pointer_interceptor: ^0.9.1 debounce_throttle: ^2.0.0 file_sizes: ^1.0.6 - intl_phone_number_input: ^0.7.3+1 mask_text_input_formatter: ^2.4.0 dotted_border: ^2.0.0+3 map_launcher: ^2.5.0+1 diff --git a/sample/pubspec.lock b/sample/pubspec.lock index c879cfd7..6bc70e19 100644 --- a/sample/pubspec.lock +++ b/sample/pubspec.lock @@ -152,14 +152,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.0+3" - equatable: - dependency: transitive - description: - name: equatable - sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2 - url: "https://pub.dev" - source: hosted - version: "2.0.5" fake_async: dependency: transitive description: @@ -303,14 +295,6 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" - intl_phone_number_input: - dependency: transitive - description: - name: intl_phone_number_input - sha256: b812c6e3924e56e65b9684076ccd8eb24126abe0c84091d35d75a25e613a1793 - url: "https://pub.dev" - source: hosted - version: "0.7.3+1" js: dependency: transitive description: @@ -343,30 +327,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.4.8" - libphonenumber_platform_interface: - dependency: transitive - description: - name: libphonenumber_platform_interface - sha256: cdd1230aad1d8e12fb4d9752d67ed2361b1cbb26fc8d202a9990c218553b3963 - url: "https://pub.dev" - source: hosted - version: "0.4.0" - libphonenumber_plugin: - dependency: transitive - description: - name: libphonenumber_plugin - sha256: "1be7c9de4beaed6dffdaf4a3d87758ef9b259c1111283736faef2179919e3ca2" - url: "https://pub.dev" - source: hosted - version: "0.3.1" - libphonenumber_web: - dependency: transitive - description: - name: libphonenumber_web - sha256: "35a106149d2f7a05a670d02be2f4ea288258d7bca2f8bdda8a96617151dfa5b9" - url: "https://pub.dev" - source: hosted - version: "0.3.0" linkify: dependency: transitive description: