diff --git a/assets/icon/gecko5b.png b/assets/icon/gecko5b.png new file mode 100644 index 0000000..bb08e85 Binary files /dev/null and b/assets/icon/gecko5b.png differ diff --git a/assets/icon/gecko5b36.png b/assets/icon/gecko5b36.png new file mode 100644 index 0000000..959ba78 Binary files /dev/null and b/assets/icon/gecko5b36.png differ diff --git a/assets/icon/gecko5b96.png b/assets/icon/gecko5b96.png new file mode 100644 index 0000000..3bf01d5 Binary files /dev/null and b/assets/icon/gecko5b96.png differ diff --git a/assets/icon/geckoicon36.png b/assets/icon/geckoicon36.png deleted file mode 100644 index 5142d61..0000000 Binary files a/assets/icon/geckoicon36.png and /dev/null differ diff --git a/assets/icon/geckoicon96.png b/assets/icon/geckoicon96.png deleted file mode 100644 index 9663e93..0000000 Binary files a/assets/icon/geckoicon96.png and /dev/null differ diff --git a/lib/functions.dart b/lib/functions.dart new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/lib/functions.dart @@ -0,0 +1 @@ + diff --git a/lib/main.dart b/lib/main.dart index 1c8186f..049b0c3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -11,6 +11,8 @@ import 'package:intl/intl.dart'; import 'api.dart'; import "package:dio/dio.dart"; +List litems = ["1", "2", "Third", "4"]; + void main() { runApp(MyApp()); } @@ -96,7 +98,9 @@ class _MyAppState extends State { ), style: TextStyle( fontSize: 30.0, color: Colors.black)), + TextField( + // Affichage history enabled: false, controller: this._outputHistory, @@ -137,6 +141,11 @@ class _MyAppState extends State { ], ), ), + // new ListView.builder( + // itemCount: litems.length, + // itemBuilder: (BuildContext ctxt, int index) { + // return new Text(litems[index]); + // }) ], ); }, @@ -270,4 +279,5 @@ class _MyAppState extends State { // print("Veuillez renseigner une clé publique"); // } // } + } diff --git a/lib/ui/exception_indicators/empty_list_indicator.dart b/lib/ui/exception_indicators/empty_list_indicator.dart new file mode 100644 index 0000000..ea14904 --- /dev/null +++ b/lib/ui/exception_indicators/empty_list_indicator.dart @@ -0,0 +1,12 @@ +import 'package:flutter/cupertino.dart'; +// import 'package:readwenderlich/ui/exception_indicators/exception_indicator.dart'; + +/// Indicates that no items were found. +class EmptyListIndicator extends StatelessWidget { + @override + Widget build(BuildContext context) => const ExceptionIndicator( + title: 'Too much filtering', + message: 'We couldn\'t find any results matching your applied filters.', + assetName: 'assets/empty-box.png', + ); +} diff --git a/lib/ui/exception_indicators/error_indicator.dart b/lib/ui/exception_indicators/error_indicator.dart new file mode 100644 index 0000000..83f364e --- /dev/null +++ b/lib/ui/exception_indicators/error_indicator.dart @@ -0,0 +1,28 @@ +import 'dart:io'; + +import 'package:flutter/material.dart'; +// import 'package:readwenderlich/ui/exception_indicators/generic_error_indicator.dart'; +// import 'package:readwenderlich/ui/exception_indicators/no_connection_indicator.dart'; + +/// Based on the received error, displays either a [NoConnectionIndicator] or +/// a [GenericErrorIndicator]. +class ErrorIndicator extends StatelessWidget { + const ErrorIndicator({ + @required this.error, + this.onTryAgain, + Key key, + }) : assert(error != null), + super(key: key); + + final dynamic error; + final VoidCallback onTryAgain; + + @override + Widget build(BuildContext context) => error is SocketException + ? NoConnectionIndicator( + onTryAgain: onTryAgain, + ) + : GenericErrorIndicator( + onTryAgain: onTryAgain, + ); +} diff --git a/lib/ui/exception_indicators/exception_indicator.dart b/lib/ui/exception_indicators/exception_indicator.dart new file mode 100644 index 0000000..89555fb --- /dev/null +++ b/lib/ui/exception_indicators/exception_indicator.dart @@ -0,0 +1,70 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +/// Basic layout for indicating that an exception occurred. +class ExceptionIndicator extends StatelessWidget { + const ExceptionIndicator({ + @required this.title, + @required this.assetName, + this.message, + this.onTryAgain, + Key key, + }) : assert(title != null), + assert(assetName != null), + super(key: key); + final String title; + final String message; + final String assetName; + final VoidCallback onTryAgain; + + @override + Widget build(BuildContext context) => Center( + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 32, horizontal: 16), + child: Column( + children: [ + Image.asset( + assetName, + ), + const SizedBox( + height: 32, + ), + Text( + title, + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.headline6, + ), + if (message != null) + const SizedBox( + height: 16, + ), + if (message != null) + Text( + message, + textAlign: TextAlign.center, + ), + if (onTryAgain != null) const Spacer(), + if (onTryAgain != null) + SizedBox( + height: 50, + width: double.infinity, + child: RaisedButton.icon( + onPressed: onTryAgain, + icon: const Icon( + Icons.refresh, + color: Colors.white, + ), + label: const Text( + 'Try Again', + style: TextStyle( + fontSize: 16, + color: Colors.white, + ), + ), + ), + ), + ], + ), + ), + ); +} diff --git a/lib/ui/exception_indicators/generic_error_indicator.dart b/lib/ui/exception_indicators/generic_error_indicator.dart new file mode 100644 index 0000000..85dc846 --- /dev/null +++ b/lib/ui/exception_indicators/generic_error_indicator.dart @@ -0,0 +1,21 @@ +import 'package:flutter/cupertino.dart'; +// import 'package:readwenderlich/ui/exception_indicators/exception_indicator.dart'; + +/// Indicates that an unknown error occurred. +class GenericErrorIndicator extends StatelessWidget { + const GenericErrorIndicator({ + Key key, + this.onTryAgain, + }) : super(key: key); + + final VoidCallback onTryAgain; + + @override + Widget build(BuildContext context) => ExceptionIndicator( + title: 'Something went wrong', + message: 'The application has encountered an unknown error.\n' + 'Please try again later.', + assetName: 'assets/confused-face.png', + onTryAgain: onTryAgain, + ); +} diff --git a/lib/ui/exception_indicators/no_connection_indicator.dart b/lib/ui/exception_indicators/no_connection_indicator.dart new file mode 100644 index 0000000..8a62dcd --- /dev/null +++ b/lib/ui/exception_indicators/no_connection_indicator.dart @@ -0,0 +1,20 @@ +import 'package:flutter/cupertino.dart'; +// import 'package:readwenderlich/ui/exception_indicators/exception_indicator.dart'; + +/// Indicates that a connection error occurred. +class NoConnectionIndicator extends StatelessWidget { + const NoConnectionIndicator({ + Key key, + this.onTryAgain, + }) : super(key: key); + + final VoidCallback onTryAgain; + + @override + Widget build(BuildContext context) => ExceptionIndicator( + title: 'No connection', + message: 'Please check internet connection and try again.', + assetName: 'assets/frustrated-face.png', + onTryAgain: onTryAgain, + ); +} diff --git a/lib/ui/history_list_item.dart b/lib/ui/history_list_item.dart new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/lib/ui/history_list_item.dart @@ -0,0 +1 @@ + diff --git a/lib/ui/history_list_screen.dart b/lib/ui/history_list_screen.dart new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/lib/ui/history_list_screen.dart @@ -0,0 +1 @@ + diff --git a/lib/ui/history_list_view.dart b/lib/ui/history_list_view.dart new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/lib/ui/history_list_view.dart @@ -0,0 +1 @@ + diff --git a/pubspec.lock b/pubspec.lock index 6fb8806..2093bdc 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -179,6 +179,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.1" + infinite_scroll_pagination: + dependency: "direct main" + description: + name: infinite_scroll_pagination + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.3" intl: dependency: "direct main" description: @@ -254,6 +261,13 @@ packages: description: flutter source: sdk version: "0.0.99" + sliver_tools: + dependency: transitive + description: + name: sliver_tools + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.10+1" source_span: dependency: transitive description: @@ -326,4 +340,4 @@ packages: version: "2.2.1" sdks: dart: ">=2.10.0-110 <2.11.0" - flutter: ">=1.12.13+hotfix.5 <2.0.0" + flutter: ">=1.22.0 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index a6fc6c1..fa07172 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -33,11 +33,13 @@ dependencies: gql_link: intl: flutter_launcher_icons: "^0.8.0" + infinite_scroll_pagination: ^2.2.3 + flutter_icons: android: "launcher_icon" ios: true - image_path: "assets/icon/gecko-bb-36.png" + image_path: "assets/icon/gecko5b96.png" # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons.