pull/2/head
fuwa 5 years ago
parent 3ffa4c25cb
commit 3cee0e35a7

@ -19,10 +19,14 @@ along with CyberWOW. If not, see <https://www.gnu.org/licenses/>.
*/
import 'package:logging/logging.dart';
import 'dart:ui';
import 'dart:async';
import 'rpc.dart' as rpc;
import '../config.dart';
typedef GetNotificationFunc = AppLifecycleState Function();
Stream<int> targetHeight(GetNotificationFunc getNotification) async* {
@ -42,7 +46,7 @@ Stream<int> targetHeight(GetNotificationFunc getNotification) async* {
Stream<Null> pull(GetNotificationFunc getNotification) async* {
while (true) {
final _appState = getNotification();
// print('refresh targetHeight: app state: ${_appState}');
log.finer('refresh targetHeight: app state: ${_appState}');
if (_appState == AppLifecycleState.resumed) {
yield null;

@ -75,6 +75,9 @@ class _CyberWOW_PageState extends State<CyberWOW_Page> with WidgetsBindingObserv
AppState _state;
AppLifecycleState _notification = AppLifecycleState.resumed;
final syncedPageController = PageController(
initialPage: 0,
);
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
@ -168,7 +171,7 @@ class _CyberWOW_PageState extends State<CyberWOW_Page> with WidgetsBindingObserv
(s) => buildBlank(context, s),
(s) => buildLoading(context, s),
(s) => buildSyncing(context, s),
(s) => buildSynced(context, s),
(s) => buildSynced(context, s, syncedPageController),
(s) => buildReSyncing(context, s),
),
);

@ -150,9 +150,7 @@ class SyncingState extends HookedState {
Future<void> printStdout() async {
await for (var line in processOutput) {
if (synced) break;
// print('syncing: print stdout loop');
log.finest('syncing: print stdout loop');
append(line);
log.info(line);
@ -161,8 +159,7 @@ class SyncingState extends HookedState {
Future<void> checkSync() async {
await for (var _null in refresh.pull(getNotification)) {
// print('syncing: target height ${_targetHeight}');
log.finer('syncing: checkSync loop');
// here doc is wrong, targetHeight could match height when synced
// potential bug, targetHeight could be smaller then height
@ -173,7 +170,6 @@ class SyncingState extends HookedState {
synced = true;
break;
}
// print('syncing: checkSync loop');
}
}

@ -24,10 +24,8 @@ import 'package:flutter/material.dart';
import '../state.dart';
import '../config.dart';
Widget buildSynced(BuildContext context, SyncedState state) {
return Scaffold(
body: Container
Widget summary(BuildContext context, SyncedState state) {
return Container
(
padding: EdgeInsets.only(bottom: 10.0),
color: config.backgroundColor,
@ -89,6 +87,23 @@ Widget buildSynced(BuildContext context, SyncedState state) {
],
),
),
);
}
Widget buildSynced(BuildContext context, SyncedState state, PageController controller) {
return Scaffold
(
body: PageView
(
controller: controller,
children:
[
summary(context, state),
Container
(
child: Text('Hello'),
),
],
),
);
}