Skip to content
This repository has been archived by the owner on Jan 28, 2025. It is now read-only.

Commit

Permalink
1.0.6
Browse files Browse the repository at this point in the history
- Added textAlign in ConnectivityScreenWrapper i.e #6
- Added import_sorter
  • Loading branch information
ProjectAJ14 committed May 2, 2021
1 parent 35008f3 commit 85cb1af
Show file tree
Hide file tree
Showing 15 changed files with 113 additions and 28 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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 :-)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.5"
version: "1.0.6"
cupertino_icons:
dependency: "direct main"
description:
Expand Down
10 changes: 10 additions & 0 deletions git_add_and_format_code.sh
Original file line number Diff line number Diff line change
@@ -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

2 changes: 2 additions & 0 deletions lib/connectivity_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
6 changes: 5 additions & 1 deletion lib/src/providers/connectivity_provider.dart
Original file line number Diff line number Diff line change
@@ -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].
Expand Down
5 changes: 4 additions & 1 deletion lib/src/utils/constants.dart
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 7 additions & 2 deletions lib/src/widgets/connectivity_app_wrapper_widget.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
20 changes: 15 additions & 5 deletions lib/src/widgets/connectivity_screen_wrapper.dart
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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(
Expand All @@ -76,6 +85,7 @@ class ConnectivityScreenWrapper extends StatelessWidget {
child: Text(
message ?? disconnectedMessage,
style: messageStyle ?? defaultMessageStyle,
textAlign: textAlign,
),
),
duration: duration ?? Duration(milliseconds: 300),
Expand All @@ -87,10 +97,10 @@ class ConnectivityScreenWrapper extends StatelessWidget {
absorbing: (disableInteraction && isOffline),
child: Stack(
children: (<Widget?>[
child,
if (child != null) child,
if (disableInteraction && isOffline)
if (disableWidget != null) disableWidget,
offlineWidget,
_offlineWidget,
]) as List<Widget>,
),
);
Expand Down
21 changes: 13 additions & 8 deletions lib/src/widgets/connectivity_widget_wrapper.dart
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -71,9 +76,9 @@ class ConnectivityWidgetWrapper extends StatelessWidget {

@override
Widget build(BuildContext context) {
final bool isOffline = Provider.of<ConnectivityStatus>(context) !=
final bool _isOffline = Provider.of<ConnectivityStatus>(context) !=
ConnectivityStatus.CONNECTED;
Widget finalOfflineWidget = Align(
Widget _finalOfflineWidget = Align(
alignment: alignment ?? Alignment.bottomCenter,
child: offlineWidget ??
Container(
Expand All @@ -93,8 +98,8 @@ class ConnectivityWidgetWrapper extends StatelessWidget {
if (stacked)
return Stack(
children: (<Widget?>[
child,
disableInteraction && isOffline
if (child != null) child,
disableInteraction && _isOffline
? Column(
children: <Widget>[
Flexible(
Expand All @@ -108,10 +113,10 @@ class ConnectivityWidgetWrapper extends StatelessWidget {
],
)
: EmptyContainer(),
isOffline ? finalOfflineWidget : EmptyContainer(),
_isOffline ? _finalOfflineWidget : EmptyContainer(),
]) as List<Widget>,
);

return isOffline ? finalOfflineWidget : child!;
return _isOffline ? _finalOfflineWidget : child!;
}
}
1 change: 1 addition & 0 deletions lib/src/widgets/empty_container.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Flutter imports:
import 'package:flutter/material.dart';

class EmptyContainer extends StatelessWidget {
Expand Down
28 changes: 28 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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"
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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:
1 change: 1 addition & 0 deletions test/connectivity_wrapper_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package imports:
import 'package:flutter_test/flutter_test.dart';

void main() {
Expand Down

0 comments on commit 85cb1af

Please sign in to comment.