Resolves #401 Fix login restart and several login views opened

This commit is contained in:
estevez-dev 2019-09-01 22:27:56 +03:00
parent e8efefe25d
commit de762a4878
4 changed files with 56 additions and 8 deletions

41
flutter_03.log Normal file
View File

@ -0,0 +1,41 @@
Flutter crash report; please file at https://github.com/flutter/flutter/issues.
## command
flutter --no-color run --machine --track-widget-creation --device-id=89AY052S4 lib/main.dart
## exception
_InternalLinkedHashMap<String, dynamic>: {code: 105, message: Isolate must be runnable, data: {request: {method: _reloadSources, params: {pause: true, rootLibUri: file:///data/user/0/com.keyboardcrumbs.haclient/code_cache/ha_clientLNSJAH/ha_client/lib/main.dart.incremental.dill, packagesUri: file:///data/user/0/com.keyboardcrumbs.haclient/code_cache/ha_clientLNSJAH/ha_client/.packages, isolateId: isolates/866521062}}, details: Isolate must be runnable before this request is made.}}
```
null```
## flutter doctor
```
[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Linux, locale en_US.UTF-8)
• Flutter version 1.7.8+hotfix.4 at /home/estevez/sdk/flutter
• Framework revision 20e59316b8 (6 weeks ago), 2019-07-18 20:04:33 -0700
• Engine revision fee001c93f
• Dart version 2.4.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /home/estevez/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /home/estevez/bin/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✓] Android Studio (version 3.5)
• Android Studio at /home/estevez/bin/android-studio
• Flutter plugin version 38.2.3
• Dart plugin version 191.8423
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] Connected device (1 available)
• Pixel 3 XL • 89AY052S4 • android-arm64 • Android 9 (API 28)
• No issues found!
```

View File

@ -176,8 +176,7 @@ class HAClientApp extends StatelessWidget {
FlatButton(
child: Text("Manual", style: TextStyle(color: Colors.white)),
onPressed: () {
Navigator.of(context).pop();
Navigator.of(context).pushNamed("/connection-settings");
eventBus.fire(ShowPageEvent(path: "/connection-settings", goBackFirst: true));
},
)
],
@ -212,6 +211,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
StreamSubscription _showPageSubscription;
int _previousViewCount;
bool _showLoginButton = false;
bool _preventAppRefresh = false;
@override
void initState() {
@ -255,6 +255,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
_settingsSubscription = eventBus.on<SettingsChangedEvent>().listen((event) {
Logger.d("Settings change event: reconnect=${event.reconnect}");
if (event.reconnect) {
_preventAppRefresh = false;
_fullLoad();
}
});
@ -332,7 +333,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
Logger.d("$state");
if (state == AppLifecycleState.resumed && ConnectionManager().settingsLoaded) {
if (state == AppLifecycleState.resumed && ConnectionManager().settingsLoaded && !_preventAppRefresh) {
_quickLoad();
}
}
@ -411,7 +412,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
if (_showPageSubscription == null) {
_showPageSubscription =
eventBus.on<ShowPageEvent>().listen((event) {
_showPage(event.path);
_showPage(event.path, event.goBackFirst);
});
}
@ -429,6 +430,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
if (event.showButton) {
_showOAuth();
} else {
_preventAppRefresh = false;
Navigator.of(context).pop();
}
});
@ -442,6 +444,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
}
void _showOAuth() {
_preventAppRefresh = true;
Navigator.of(context).pushNamed('/login');
}
@ -509,7 +512,10 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
);
}
void _showPage(String path) {
void _showPage(String path, bool goBackFirst) {
if (goBackFirst) {
Navigator.pop(context);
}
Navigator.pushNamed(
context,
path

View File

@ -59,7 +59,7 @@ class StartupUserMessagesManager {
onPositive: () {
SharedPreferences.getInstance().then((prefs) {
prefs.setBool(_supportAppDevelopmentMessageKey, true);
eventBus.fire(ShowPageEvent("/configuration"));
eventBus.fire(ShowPageEvent(path: "/configuration"));
});
},
onNegative: () {

View File

@ -200,9 +200,10 @@ class ShowEntityPageEvent {
}
class ShowPageEvent {
String path;
final String path;
final bool goBackFirst;
ShowPageEvent(this.path);
ShowPageEvent({@required this.path, this.goBackFirst: false});
}
class ShowErrorEvent {