Browse Source

Added refresh button on error

tmp v2.2.0
Dan Cojocaru 3 years ago
parent
commit
be48e955c7
Signed by: kbruen
GPG Key ID: 818A889458EDC937
  1. 23
      .gitignore
  2. 3
      CHANGELOG.TXT
  3. 14
      ios/Flutter/flutter_export_environment.sh
  4. 2
      lib/components/refresh_future_builder.dart
  5. 78
      lib/components/select_train_suggestions/select_train_suggestions_cupertino.dart
  6. 7
      lib/pages/train_info_page/view_train/train_info.dart
  7. 21
      lib/pages/train_info_page/view_train/train_info_cupertino.dart
  8. 21
      lib/pages/train_info_page/view_train/train_info_material.dart
  9. 2
      pubspec.yaml

23
.gitignore vendored

@ -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

3
CHANGELOG.TXT

@ -1,3 +1,6 @@
v2.2.0
Added refresh button on error
v2.1.1
Fixed Android build
Switched versioning format

14
ios/Flutter/flutter_export_environment.sh

@ -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"

2
lib/components/refresh_future_builder.dart

@ -46,7 +46,7 @@ class _RefreshFutureBuilderState<T> extends State<RefreshFutureBuilder<T>> {
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);

78
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: <Widget>[
GestureDetector(
onTap: () {
onTrainSelected(currentInput);
},
child: Padding(
padding: const EdgeInsets.all(8),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(getUseCurrentInputWidgetText(currentInput)),
],
)
),
Padding(
padding: const EdgeInsets.all(0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
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: <Widget>[
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: <Widget>[
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(),
],
);
}
}

7
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});
}

21
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!(),
),
),
],
),
),
);
}

21
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!(),
),
),
],
),
),
);
}

2
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"

Loading…
Cancel
Save