Skip to content

Commit

Permalink
v0.2.0 (#4)
Browse files Browse the repository at this point in the history
* Changes we made together during HumpdayQandA (#2)

* HumpdayQandA changes.

* Removed android unrequired sub-directory.

* chore(example): code clean up

* chore: code clean up

* test: improve cases

* chore: code clean up

* chore: bump to v0.2.0

* chore: update README

* test: improve cases

* refactor: accomodate new test case
  • Loading branch information
jogboms authored Sep 6, 2018
1 parent 5ee4b95 commit 1c6df0c
Show file tree
Hide file tree
Showing 18 changed files with 536 additions and 257 deletions.
85 changes: 48 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

[![pub package](https://img.shields.io/pub/v/flutter_offline.svg)](https://pub.dartlang.org/packages/flutter_offline)

Handle offline/online connectivity in Flutter like a Boss. Ample support for both iOS and Android platforms.
A tidy utility to handle offline/online connectivity like a Boss. It provides support for both iOS and Android platforms (offcourse).

## 🎖 Installing

```yaml
dependencies:
flutter_offline: "^0.1.0"
flutter_offline: "^0.2.0"
```
### ⚡️ Import
Expand All @@ -23,46 +23,53 @@ import 'package:flutter_offline/flutter_offline.dart';
import 'package:flutter/material.dart';
import 'package:flutter_offline/flutter_offline.dart';
class OfflineDelegate extends OfflineBuilderDelegate {
@override
Widget builder(BuildContext context, bool state) {
return new Stack(
fit: StackFit.expand,
children: [
Positioned(
height: 24.0,
left: 0.0,
right: 0.0,
child: Container(
color: state ? Color(0xFF00EE44) : Color(0xFFEE4400),
child: Center(
child: Text("${state ? 'ONLINE' : 'OFFLINE'}"),
),
),
),
Center(
child: new Text(
'Yay!',
),
),
],
);
}
}
class DemoPage extends StatelessWidget {
const DemoPage({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("Offline Demo"),
),
body: OfflineBuilder(
delegate: new OfflineDelegate(),
connectivityBuilder: (
BuildContext context,
ConnectivityResult connectivity,
Widget child,
) {
final bool connected = connectivity != ConnectivityResult.none;
return new Stack(
fit: StackFit.expand,
children: [
Positioned(
height: 24.0,
left: 0.0,
right: 0.0,
child: Container(
color: connected ? Color(0xFF00EE44) : Color(0xFFEE4400),
child: Center(
child: Text("${connected ? 'ONLINE' : 'OFFLINE'}"),
),
),
),
Center(
child: new Text(
'Yay!',
),
),
],
);
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(
'There are no bottons to push :)',
),
new Text(
'Just turn off your internet.',
),
],
),
),
);
}
Expand All @@ -76,13 +83,13 @@ For more info, please, refer to the `main.dart` in the example.
<table>
<tr>
<td align="center">
<img src="./screenshots/demo_1.gif" width="200px">
<img src="./screenshots/demo_1.gif" width="250px">
</td>
<td align="center">
<img src="./screenshots/demo_2.gif" width="200px">
<img src="./screenshots/demo_2.gif" width="250px">
</td>
<td align="center">
<img src="./screenshots/demo_3.gif" width="200px">
<img src="./screenshots/demo_3.gif" width="250px">
</td>
</tr>
</table>
Expand All @@ -100,6 +107,10 @@ For help getting started with Flutter, view our online

For help on editing plugin code, view the [documentation](https://flutter.io/platform-plugins/#edit-code).

### 🤓 Mentions

Simon Lightfoot ([@slightfoot](https://github.com/slightfoot)) is just awesome 👍.

## ⭐️ License

MIT License
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ analyzer:
implicit-dynamic: false
errors:
# treat missing required parameters as a warning (not a hint)
missing_required_param: warning
# missing_required_param: warning
# treat missing returns as a warning (not a hint)
missing_return: warning
# allow having TODOs in the code
Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions android/local.properties

This file was deleted.

35 changes: 0 additions & 35 deletions example/lib/delegates/demo_1.dart

This file was deleted.

34 changes: 0 additions & 34 deletions example/lib/delegates/demo_2.dart

This file was deleted.

40 changes: 0 additions & 40 deletions example/lib/delegates/demo_3.dart

This file was deleted.

9 changes: 3 additions & 6 deletions example/lib/demo_page.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
import 'package:flutter/material.dart';
import 'package:flutter_offline/flutter_offline.dart';

class DemoPage extends StatelessWidget {
const DemoPage({
Key key,
@required this.delegate,
@required this.child,
}) : super(key: key);

final OfflineBuilderDelegate delegate;
final Widget child;

@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("Offline Demo"),
),
body: OfflineBuilder(
delegate: delegate,
),
body: child,
);
}
}
36 changes: 16 additions & 20 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
import 'package:example/delegates/demo_1.dart';
import 'package:example/delegates/demo_2.dart';
import 'package:example/delegates/demo_3.dart';
import 'package:example/demo_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_offline/flutter_offline.dart';

void main() => runApp(new MyApp());
import './demo_page.dart';
import './widgets/demo_1.dart';
import './widgets/demo_2.dart';
import './widgets/demo_3.dart';

void navigate(BuildContext context, OfflineBuilderDelegate delegate) {
Navigator.of(context).push<void>(
MaterialPageRoute<void>(
builder: (BuildContext context) {
return new DemoPage(
delegate: delegate,
);
},
),
);
}
void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
@override
Expand All @@ -33,19 +21,19 @@ class MyApp extends StatelessWidget {
RaisedButton(
child: Text("Demo 1"),
onPressed: () {
navigate(context, Demo1OfflineDelegate());
navigate(context, Demo1());
},
),
RaisedButton(
child: Text("Demo 2"),
onPressed: () {
navigate(context, Demo2OfflineDelegate());
navigate(context, Demo2());
},
),
RaisedButton(
child: Text("Demo 3"),
onPressed: () {
navigate(context, Demo3OfflineDelegate());
navigate(context, Demo3());
},
),
],
Expand All @@ -54,4 +42,12 @@ class MyApp extends StatelessWidget {
),
);
}

void navigate(BuildContext context, Widget widget) {
Navigator.of(context).push<void>(
MaterialPageRoute<void>(
builder: (BuildContext context) => DemoPage(child: widget),
),
);
}
}
Loading

0 comments on commit 1c6df0c

Please sign in to comment.