From be48e955c7d16001d5fa617035980e232c3af2d8 Mon Sep 17 00:00:00 2001 From: Dan Cojocaru Date: Mon, 23 Aug 2021 15:32:33 +0300 Subject: [PATCH] Added refresh button on error --- .gitignore | 23 +++++- CHANGELOG.TXT | 3 + ios/Flutter/flutter_export_environment.sh | 14 ---- lib/components/refresh_future_builder.dart | 2 +- .../select_train_suggestions_cupertino.dart | 78 ++++++++++--------- .../view_train/train_info.dart | 7 +- .../view_train/train_info_cupertino.dart | 21 ++++- .../view_train/train_info_material.dart | 21 ++++- pubspec.yaml | 2 +- 9 files changed, 110 insertions(+), 61 deletions(-) delete mode 100755 ios/Flutter/flutter_export_environment.sh diff --git a/.gitignore b/.gitignore index 570b0d0..6f3c2aa 100644 --- a/.gitignore +++ b/.gitignore @@ -25,10 +25,15 @@ .dart_tool/ .flutter-plugins .flutter-plugins-dependencies +**/generated_plugin_registrant.dart .packages .pub-cache/ .pub/ -/build/ +build/ +flutter_*.png +linked_*.ds +unlinked.ds +unlinked_spec.ds # Android related **/android/**/gradle-wrapper.jar @@ -38,6 +43,8 @@ **/android/gradlew.bat **/android/local.properties **/android/**/GeneratedPluginRegistrant.java +**/android/key.properties +*.jks # iOS/XCode related **/ios/**/*.mode1v3 @@ -56,18 +63,32 @@ **/ios/**/profile **/ios/**/xcuserdata **/ios/.generated/ +**/ios/Flutter/.last_build_id **/ios/Flutter/App.framework **/ios/Flutter/Flutter.framework +**/ios/Flutter/Flutter.podspec **/ios/Flutter/Generated.xcconfig +**/ios/Flutter/ephemeral **/ios/Flutter/app.flx **/ios/Flutter/app.zip **/ios/Flutter/flutter_assets/ +**/ios/Flutter/flutter_export_environment.sh **/ios/ServiceDefinitions.json **/ios/Runner/GeneratedPluginRegistrant.* +# macOS +**/macos/Flutter/GeneratedPluginRegistrant.swift + +# Coverage +coverage/ + +# Symbols +app.*.symbols + # Exceptions to above rules. !**/ios/**/default.mode1v3 !**/ios/**/default.mode2v3 !**/ios/**/default.pbxuser !**/ios/**/default.perspectivev3 !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages +!/dev/ci/**/Gemfile.lock diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index c0fa5ee..4bf880a 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -1,3 +1,6 @@ +v2.2.0 +Added refresh button on error + v2.1.1 Fixed Android build Switched versioning format diff --git a/ios/Flutter/flutter_export_environment.sh b/ios/Flutter/flutter_export_environment.sh deleted file mode 100755 index 2d03b62..0000000 --- a/ios/Flutter/flutter_export_environment.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/usr/local/Caskroom/flutter/2.2.3/flutter" -export "FLUTTER_APPLICATION_PATH=/Users/dan.cojocaru/info_tren" -export "COCOAPODS_PARALLEL_CODE_SIGN=true" -export "FLUTTER_TARGET=/Users/dan.cojocaru/info_tren/lib/main.dart" -export "FLUTTER_BUILD_DIR=build" -export "FLUTTER_BUILD_NAME=2.0.6" -export "FLUTTER_BUILD_NUMBER=2.0.6" -export "DART_DEFINES=Zmx1dHRlci5pbnNwZWN0b3Iuc3RydWN0dXJlZEVycm9ycz10cnVl,RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==" -export "DART_OBFUSCATION=false" -export "TRACK_WIDGET_CREATION=true" -export "TREE_SHAKE_ICONS=false" -export "PACKAGE_CONFIG=/Users/dan.cojocaru/info_tren/.dart_tool/package_config.json" diff --git a/lib/components/refresh_future_builder.dart b/lib/components/refresh_future_builder.dart index f107ea0..78a53e9 100644 --- a/lib/components/refresh_future_builder.dart +++ b/lib/components/refresh_future_builder.dart @@ -46,7 +46,7 @@ class _RefreshFutureBuilderState extends State> { case RefreshFutureBuilderState.waiting: return; case RefreshFutureBuilderState.error: - snapshot = RefreshFutureBuilderSnapshot.refresh(null, snapshot.error, snapshot.stackTrace); + snapshot = RefreshFutureBuilderSnapshot.waiting(); break; case RefreshFutureBuilderState.done: snapshot = RefreshFutureBuilderSnapshot.refresh(snapshot.data); diff --git a/lib/components/select_train_suggestions/select_train_suggestions_cupertino.dart b/lib/components/select_train_suggestions/select_train_suggestions_cupertino.dart index d35d8b4..7283e0b 100644 --- a/lib/components/select_train_suggestions/select_train_suggestions_cupertino.dart +++ b/lib/components/select_train_suggestions/select_train_suggestions_cupertino.dart @@ -1,5 +1,5 @@ import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; +import 'package:info_tren/components/cupertino_divider.dart'; import 'package:info_tren/components/select_train_suggestions/select_train_suggestions.dart'; import 'package:info_tren/models/train_operator_lines.dart'; @@ -9,21 +9,19 @@ class SelectTrainSuggestionsStateCupertino extends SelectTrainSuggestionsState { return Column( mainAxisSize: MainAxisSize.min, children: [ - GestureDetector( - onTap: () { - onTrainSelected(currentInput); - }, - child: Padding( - padding: const EdgeInsets.all(8), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text(getUseCurrentInputWidgetText(currentInput)), - ], - ) - ), + Padding( + padding: const EdgeInsets.all(0), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + CupertinoButton( + child: Text(getUseCurrentInputWidgetText(currentInput)), + onPressed: () => onTrainSelected(currentInput), + ), + ], + ) ), - Divider(), + CupertinoDivider(), ], ); } @@ -44,31 +42,37 @@ class OperatorAutocompleteTileCupertino extends OperatorAutocompleteTile { @override Widget build(BuildContext context) { - return GestureDetector( - onTap: () { - onTrainSelected(train.internalNumber); - }, - child: Padding( - padding: const EdgeInsets.fromLTRB(16, 2, 16, 2), - child: SizedBox( - width: double.infinity, - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Text( - operatorName, - style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(fontSize: 10, fontWeight: FontWeight.w200), - textAlign: TextAlign.left, - ), - Text( - "${train.rang} ${train.number}", - textAlign: TextAlign.left, + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + GestureDetector( + onTap: () { + onTrainSelected(train.internalNumber); + }, + child: Padding( + padding: const EdgeInsets.fromLTRB(16, 4, 16, 4), + child: SizedBox( + width: double.infinity, + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text( + operatorName, + style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(fontSize: 10, fontWeight: FontWeight.w200), + textAlign: TextAlign.left, + ), + Text( + "${train.rang} ${train.number}", + textAlign: TextAlign.left, + ), + ], ), - ], + ), ), ), - ), + CupertinoDivider(), + ], ); } } diff --git a/lib/pages/train_info_page/view_train/train_info.dart b/lib/pages/train_info_page/view_train/train_info.dart index 0ad578f..d7d2aa4 100644 --- a/lib/pages/train_info_page/view_train/train_info.dart +++ b/lib/pages/train_info_page/view_train/train_info.dart @@ -33,7 +33,7 @@ class TrainInfo extends StatelessWidget { return TrainInfoLoadingMaterial(title: trainNumber.toString(),); } else if (snapshot.state == RefreshFutureBuilderState.error) { - return TrainInfoErrorMaterial(title: '$trainNumber - Error', error: snapshot.error!,); + return TrainInfoErrorMaterial(title: '$trainNumber - Error', error: snapshot.error!, refresh: refresh,); } return TrainInfoMaterial(trainData: snapshot.data!,); @@ -42,7 +42,7 @@ class TrainInfo extends StatelessWidget { return TrainInfoLoadingCupertino(title: trainNumber.toString(),); } else if (snapshot.state == RefreshFutureBuilderState.error) { - return TrainInfoErrorCupertino(title: '$trainNumber - Error', error: snapshot.error!,); + return TrainInfoErrorCupertino(title: '$trainNumber - Error', error: snapshot.error!, refresh: refresh,); } return TrainInfoCupertino(trainData: snapshot.data!,); @@ -64,6 +64,7 @@ abstract class TrainInfoLoading extends StatelessWidget { abstract class TrainInfoError extends StatelessWidget { final String title; final Object error; + final Future Function()? refresh; - TrainInfoError({required this.title, required this.error}); + TrainInfoError({required this.title, required this.error, this.refresh}); } diff --git a/lib/pages/train_info_page/view_train/train_info_cupertino.dart b/lib/pages/train_info_page/view_train/train_info_cupertino.dart index 4961637..0a0465c 100644 --- a/lib/pages/train_info_page/view_train/train_info_cupertino.dart +++ b/lib/pages/train_info_page/view_train/train_info_cupertino.dart @@ -24,7 +24,11 @@ class TrainInfoLoadingCupertino extends TrainInfoLoading { } class TrainInfoErrorCupertino extends TrainInfoError { - TrainInfoErrorCupertino({required Object error, required String title,}) : super(error: error, title: title,); + TrainInfoErrorCupertino({ + required Object error, + required String title, + Future Function()? refresh, + }) : super(error: error, title: title, refresh: refresh,); @override Widget build(BuildContext context) { @@ -33,7 +37,20 @@ class TrainInfoErrorCupertino extends TrainInfoError { middle: Text(title), ), child: Center( - child: Text(error.toString()), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text(error.toString()), + if (refresh != null) + Padding( + padding: const EdgeInsets.all(8), + child: CupertinoButton( + child: Text('Retry'), + onPressed: () => refresh!(), + ), + ), + ], + ), ), ); } diff --git a/lib/pages/train_info_page/view_train/train_info_material.dart b/lib/pages/train_info_page/view_train/train_info_material.dart index 8b2060d..08c11d4 100644 --- a/lib/pages/train_info_page/view_train/train_info_material.dart +++ b/lib/pages/train_info_page/view_train/train_info_material.dart @@ -23,7 +23,11 @@ class TrainInfoLoadingMaterial extends TrainInfoLoading { } class TrainInfoErrorMaterial extends TrainInfoError { - TrainInfoErrorMaterial({required Object error, required String title,}) : super(error: error, title: title,); + TrainInfoErrorMaterial({ + required Object error, + required String title, + Future Function()? refresh, + }) : super(error: error, title: title, refresh: refresh,); @override Widget build(BuildContext context) { @@ -32,7 +36,20 @@ class TrainInfoErrorMaterial extends TrainInfoError { title: Text(title), ), body: Center( - child: Text(error.toString()), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text(error.toString()), + if (refresh != null) + Padding( + padding: const EdgeInsets.all(8), + child: ElevatedButton( + child: Text('Retry'), + onPressed: () => refresh!(), + ), + ), + ], + ), ), ); } diff --git a/pubspec.yaml b/pubspec.yaml index 736f26a..6153ebd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: O aplicație de vizualizare a datelor puse la dispoziție de Inform # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 2.1.1 +version: 2.2.0 environment: sdk: ">=2.12.0 <3.0.0"