diff --git a/cyberwow/lib/controller/refresh.dart b/cyberwow/lib/controller/refresh.dart index 643ed42..fbc0cd3 100644 --- a/cyberwow/lib/controller/refresh.dart +++ b/cyberwow/lib/controller/refresh.dart @@ -19,10 +19,14 @@ along with CyberWOW. If not, see . */ +import 'package:logging/logging.dart'; + import 'dart:ui'; import 'dart:async'; import 'rpc.dart' as rpc; +import '../config.dart'; + typedef GetNotificationFunc = AppLifecycleState Function(); Stream targetHeight(GetNotificationFunc getNotification) async* { @@ -42,7 +46,7 @@ Stream targetHeight(GetNotificationFunc getNotification) async* { Stream 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; diff --git a/cyberwow/lib/main.dart b/cyberwow/lib/main.dart index 8caf158..3ee9a49 100644 --- a/cyberwow/lib/main.dart +++ b/cyberwow/lib/main.dart @@ -75,6 +75,9 @@ class _CyberWOW_PageState extends State 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 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), ), ); diff --git a/cyberwow/lib/state.dart b/cyberwow/lib/state.dart index f6f63b7..f91f088 100644 --- a/cyberwow/lib/state.dart +++ b/cyberwow/lib/state.dart @@ -150,9 +150,7 @@ class SyncingState extends HookedState { Future 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 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'); } } diff --git a/cyberwow/lib/widget/synced.dart b/cyberwow/lib/widget/synced.dart index ecce72f..5a816cc 100644 --- a/cyberwow/lib/widget/synced.dart +++ b/cyberwow/lib/widget/synced.dart @@ -24,71 +24,86 @@ 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, + child: Align ( - padding: EdgeInsets.only(bottom: 10.0), - color: config.backgroundColor, - child: Align + alignment: Alignment.center, + child: Column ( - alignment: Alignment.center, - child: Column - ( - mainAxisAlignment: MainAxisAlignment.center, - children: - [ - Spacer - ( - flex: 17, - ), - Image.asset - ('assets/wownero_symbol.png', - height: 220, - ), - Spacer + mainAxisAlignment: MainAxisAlignment.center, + children: + [ + Spacer + ( + flex: 17, + ), + Image.asset + ('assets/wownero_symbol.png', + height: 220, + ), + Spacer + ( + flex: 7, + ), + Expanded + ( + flex: 15, + child: AnimatedSwitcher ( - flex: 7, - ), - Expanded - ( - flex: 15, - child: AnimatedSwitcher + duration: Duration(milliseconds: 500), + child: Text ( - duration: Duration(milliseconds: 500), - child: Text + '${state.height}', + style: TextStyle ( - '${state.height}', - style: TextStyle - ( - fontFamily: 'RobotoMono', - fontSize: 35, - fontWeight: FontWeight.bold, - color: config.textColor, - ), - key: ValueKey(state.height), - ) + fontFamily: 'RobotoMono', + fontSize: 35, + fontWeight: FontWeight.bold, + color: config.textColor, + ), + key: ValueKey(state.height), ) - ), - Spacer + ) + ), + Spacer + ( + flex: 1, + ), + SizedBox + ( + height: 20.0, + width: 20.0, + child: (state.connected) ? + Container() : + CircularProgressIndicator ( - flex: 1, + strokeWidth: 2, ), - SizedBox - ( - height: 20.0, - width: 20.0, - child: (state.connected) ? - Container() : - CircularProgressIndicator - ( - strokeWidth: 2, - ), - ), - ], - ), + ), + ], ), ), ); } + +Widget buildSynced(BuildContext context, SyncedState state, PageController controller) { + return Scaffold + ( + body: PageView + ( + controller: controller, + children: + [ + summary(context, state), + Container + ( + child: Text('Hello'), + ), + ], + ), + ); +}