From 85cb1afcaed4440a3e668ed61150d635db01fcc2 Mon Sep 17 00:00:00 2001 From: Ajay Kumar Date: Sun, 2 May 2021 23:27:39 +0530 Subject: [PATCH] 1.0.6 - Added textAlign in ConnectivityScreenWrapper i.e #6 - Added import_sorter --- CHANGELOG.md | 4 +++ README.md | 21 ++++++++------ .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++ example/pubspec.lock | 2 +- git_add_and_format_code.sh | 10 +++++++ lib/connectivity_wrapper.dart | 2 ++ lib/src/providers/connectivity_provider.dart | 6 +++- lib/src/utils/constants.dart | 5 +++- .../connectivity_app_wrapper_widget.dart | 9 ++++-- .../widgets/connectivity_screen_wrapper.dart | 20 +++++++++---- .../widgets/connectivity_widget_wrapper.dart | 21 ++++++++------ lib/src/widgets/empty_container.dart | 1 + pubspec.lock | 28 +++++++++++++++++++ pubspec.yaml | 3 +- test/connectivity_wrapper_test.dart | 1 + 15 files changed, 113 insertions(+), 28 deletions(-) create mode 100644 example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100755 git_add_and_format_code.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index d2c9797..ae23114 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [1.0.6] - Maintenance issues and suggestions. + +- Resolved [#6](https://github.com/ajaynonstopio/connectivity_wrapper/issues/6) + ## [1.0.5] - Maintenance issues and suggestions. - Migrating to null safety and updated provider to: ^5.0.0 [#7](https://github.com/ajaynonstopio/connectivity_wrapper/issues/7) diff --git a/README.md b/README.md index df48574..a0c2ff7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -[![](https://img.shields.io/badge/build-1.0.5-brightgreen)](https://github.com/ajaynonstopio/connectivity_wrapper) +[![](https://img.shields.io/badge/build-1.0.6-brightgreen)](https://github.com/ajaynonstopio/connectivity_wrapper) +[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) # connectivity_wrapper @@ -258,13 +259,15 @@ class NetworkAwareWidgetScreen extends StatelessWidget { whether you can reliably make a network connection. Always guard your app code against timeouts and errors that might come from the network layer. -## Getting Started + -This project is a starting point for a Dart -[package](https://flutter.dev/developing-packages/), -a library module containing code that can be shared easily across -multiple Flutter or Dart projects. +## Contributing -For help getting started with Flutter, view our -[online documentation](https://flutter.dev/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. +There are couple of ways in which you can contribute. +- Propose any feature, enhancement +- Report a bug +- Fix a bug +- Participate in a discussion and help in decision making +- Write and improve some **documentation**. Documentation is super critical and its importance + cannot be overstated! +- Send in a Pull Request :-) \ No newline at end of file diff --git a/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/example/pubspec.lock b/example/pubspec.lock index 3b7e1ec..6cb396f 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -49,7 +49,7 @@ packages: path: ".." relative: true source: path - version: "1.0.5" + version: "1.0.6" cupertino_icons: dependency: "direct main" description: diff --git a/git_add_and_format_code.sh b/git_add_and_format_code.sh new file mode 100755 index 0000000..e4a6f92 --- /dev/null +++ b/git_add_and_format_code.sh @@ -0,0 +1,10 @@ +#!/bin/bash +clear +echo "Sort imports...." +flutter pub run import_sorter:main +echo "Formatting code with [flutter format]...." +flutter format lib +git add . +echo "Done" +git status + diff --git a/lib/connectivity_wrapper.dart b/lib/connectivity_wrapper.dart index 45b521d..adbbc68 100644 --- a/lib/connectivity_wrapper.dart +++ b/lib/connectivity_wrapper.dart @@ -10,9 +10,11 @@ /// library connectivity_wrapper; +// Dart imports: import 'dart:async'; import 'dart:io'; +// Project imports: import 'package:connectivity_wrapper/src/utils/constants.dart'; export 'package:connectivity_wrapper/src/widgets/connectivity_app_wrapper_widget.dart'; diff --git a/lib/src/providers/connectivity_provider.dart b/lib/src/providers/connectivity_provider.dart index a4c9599..c4b8cce 100644 --- a/lib/src/providers/connectivity_provider.dart +++ b/lib/src/providers/connectivity_provider.dart @@ -1,8 +1,12 @@ +// Dart imports: import 'dart:async'; -import 'package:connectivity_wrapper/connectivity_wrapper.dart'; +// Flutter imports: import 'package:flutter/material.dart'; +// Project imports: +import 'package:connectivity_wrapper/connectivity_wrapper.dart'; + /// [ConnectivityProvider] event ChangeNotifier class for ConnectivityStatus . /// which extends [ChangeNotifier]. diff --git a/lib/src/utils/constants.dart b/lib/src/utils/constants.dart index 921c34d..6cfddcd 100644 --- a/lib/src/utils/constants.dart +++ b/lib/src/utils/constants.dart @@ -1,7 +1,10 @@ -import 'package:connectivity_wrapper/src/widgets/connectivity_screen_wrapper.dart'; +// Flutter imports: import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +// Project imports: +import 'package:connectivity_wrapper/src/widgets/connectivity_screen_wrapper.dart'; + /// More info on why default port is 53 /// here: /// - https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers diff --git a/lib/src/widgets/connectivity_app_wrapper_widget.dart b/lib/src/widgets/connectivity_app_wrapper_widget.dart index 595fa28..b41aa07 100644 --- a/lib/src/widgets/connectivity_app_wrapper_widget.dart +++ b/lib/src/widgets/connectivity_app_wrapper_widget.dart @@ -1,8 +1,13 @@ -import 'package:connectivity_wrapper/connectivity_wrapper.dart'; -import 'package:connectivity_wrapper/src/providers/connectivity_provider.dart'; +// Flutter imports: import 'package:flutter/material.dart'; + +// Package imports: import 'package:provider/provider.dart'; +// Project imports: +import 'package:connectivity_wrapper/connectivity_wrapper.dart'; +import 'package:connectivity_wrapper/src/providers/connectivity_provider.dart'; + ///[ConnectivityAppWrapper] is a StatelessWidget. class ConnectivityAppWrapper extends StatelessWidget { diff --git a/lib/src/widgets/connectivity_screen_wrapper.dart b/lib/src/widgets/connectivity_screen_wrapper.dart index 959f9f4..6f5d350 100644 --- a/lib/src/widgets/connectivity_screen_wrapper.dart +++ b/lib/src/widgets/connectivity_screen_wrapper.dart @@ -1,8 +1,13 @@ -import 'package:connectivity_wrapper/connectivity_wrapper.dart'; -import 'package:connectivity_wrapper/src/utils/constants.dart'; +// Flutter imports: import 'package:flutter/material.dart'; + +// Package imports: import 'package:provider/provider.dart'; +// Project imports: +import 'package:connectivity_wrapper/connectivity_wrapper.dart'; +import 'package:connectivity_wrapper/src/utils/constants.dart'; + enum PositionOnScreen { TOP, BOTTOM, @@ -39,6 +44,9 @@ class ConnectivityScreenWrapper extends StatelessWidget { /// Disable the user interaction with child widget final Widget? disableWidget; + /// How the text should be aligned horizontally. + final TextAlign? textAlign; + const ConnectivityScreenWrapper({ Key? key, this.child, @@ -47,6 +55,7 @@ class ConnectivityScreenWrapper extends StatelessWidget { this.message, this.messageStyle, this.height, + this.textAlign, this.duration, this.positionOnScreen = PositionOnScreen.BOTTOM, this.disableInteraction = false, @@ -64,7 +73,7 @@ class ConnectivityScreenWrapper extends StatelessWidget { double _height = height ?? defaultHeight; - final Widget offlineWidget = AnimatedPositioned( + final Widget _offlineWidget = AnimatedPositioned( top: positionOnScreen.top(_height, isOffline), bottom: positionOnScreen.bottom(_height, isOffline), child: AnimatedContainer( @@ -76,6 +85,7 @@ class ConnectivityScreenWrapper extends StatelessWidget { child: Text( message ?? disconnectedMessage, style: messageStyle ?? defaultMessageStyle, + textAlign: textAlign, ), ), duration: duration ?? Duration(milliseconds: 300), @@ -87,10 +97,10 @@ class ConnectivityScreenWrapper extends StatelessWidget { absorbing: (disableInteraction && isOffline), child: Stack( children: ([ - child, + if (child != null) child, if (disableInteraction && isOffline) if (disableWidget != null) disableWidget, - offlineWidget, + _offlineWidget, ]) as List, ), ); diff --git a/lib/src/widgets/connectivity_widget_wrapper.dart b/lib/src/widgets/connectivity_widget_wrapper.dart index 00213bb..58ba5c1 100644 --- a/lib/src/widgets/connectivity_widget_wrapper.dart +++ b/lib/src/widgets/connectivity_widget_wrapper.dart @@ -1,8 +1,13 @@ +// Flutter imports: +import 'package:flutter/material.dart'; + +// Package imports: +import 'package:provider/provider.dart'; + +// Project imports: import 'package:connectivity_wrapper/connectivity_wrapper.dart'; import 'package:connectivity_wrapper/src/utils/constants.dart'; import 'package:connectivity_wrapper/src/widgets/empty_container.dart'; -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; class ConnectivityWidgetWrapper extends StatelessWidget { /// The [child] contained by the ConnectivityWidgetWrapper. @@ -71,9 +76,9 @@ class ConnectivityWidgetWrapper extends StatelessWidget { @override Widget build(BuildContext context) { - final bool isOffline = Provider.of(context) != + final bool _isOffline = Provider.of(context) != ConnectivityStatus.CONNECTED; - Widget finalOfflineWidget = Align( + Widget _finalOfflineWidget = Align( alignment: alignment ?? Alignment.bottomCenter, child: offlineWidget ?? Container( @@ -93,8 +98,8 @@ class ConnectivityWidgetWrapper extends StatelessWidget { if (stacked) return Stack( children: ([ - child, - disableInteraction && isOffline + if (child != null) child, + disableInteraction && _isOffline ? Column( children: [ Flexible( @@ -108,10 +113,10 @@ class ConnectivityWidgetWrapper extends StatelessWidget { ], ) : EmptyContainer(), - isOffline ? finalOfflineWidget : EmptyContainer(), + _isOffline ? _finalOfflineWidget : EmptyContainer(), ]) as List, ); - return isOffline ? finalOfflineWidget : child!; + return _isOffline ? _finalOfflineWidget : child!; } } diff --git a/lib/src/widgets/empty_container.dart b/lib/src/widgets/empty_container.dart index 2536eac..0538ec6 100644 --- a/lib/src/widgets/empty_container.dart +++ b/lib/src/widgets/empty_container.dart @@ -1,3 +1,4 @@ +// Flutter imports: import 'package:flutter/material.dart'; class EmptyContainer extends StatelessWidget { diff --git a/pubspec.lock b/pubspec.lock index 7f258cb..cb72621 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,13 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" async: dependency: transitive description: @@ -60,6 +67,13 @@ packages: description: flutter source: sdk version: "0.0.0" + import_sorter: + dependency: "direct dev" + description: + name: import_sorter + url: "https://pub.dartlang.org" + source: hosted + version: "4.5.0" matcher: dependency: transitive description: @@ -142,6 +156,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.2.19" + tint: + dependency: transitive + description: + name: tint + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" typed_data: dependency: transitive description: @@ -156,6 +177,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.0" + yaml: + dependency: transitive + description: + name: yaml + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" sdks: dart: ">=2.12.0 <3.0.0" flutter: ">=1.16.0" diff --git a/pubspec.yaml b/pubspec.yaml index 8bbd450..501d381 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: connectivity_wrapper description: A new Flutter package which provides network-aware widgets.It allows Flutter apps provide feedback on your app when it's not connected to it, or when there's no connection. -version: 1.0.5 +version: 1.0.6 documentation: https://github.com/ajaynonstopio/connectivity_wrapper homepage: https://github.com/ajaynonstopio/connectivity_wrapper @@ -15,5 +15,6 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + import_sorter: ^4.4.1 #run to sort import => flutter pub run import_sorter:main flutter: diff --git a/test/connectivity_wrapper_test.dart b/test/connectivity_wrapper_test.dart index c5ca345..11e7258 100644 --- a/test/connectivity_wrapper_test.dart +++ b/test/connectivity_wrapper_test.dart @@ -1,3 +1,4 @@ +// Package imports: import 'package:flutter_test/flutter_test.dart'; void main() {