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:ui';
import 'dart:async'; import 'dart:async';
import 'rpc.dart' as rpc; import 'rpc.dart' as rpc;
import '../config.dart';
typedef GetNotificationFunc = AppLifecycleState Function(); typedef GetNotificationFunc = AppLifecycleState Function();
Stream<int> targetHeight(GetNotificationFunc getNotification) async* { Stream<int> targetHeight(GetNotificationFunc getNotification) async* {
@ -42,7 +46,7 @@ Stream<int> targetHeight(GetNotificationFunc getNotification) async* {
Stream<Null> pull(GetNotificationFunc getNotification) async* { Stream<Null> pull(GetNotificationFunc getNotification) async* {
while (true) { while (true) {
final _appState = getNotification(); final _appState = getNotification();
// print('refresh targetHeight: app state: ${_appState}'); log.finer('refresh targetHeight: app state: ${_appState}');
if (_appState == AppLifecycleState.resumed) { if (_appState == AppLifecycleState.resumed) {
yield null; yield null;

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

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

@ -24,71 +24,86 @@ import 'package:flutter/material.dart';
import '../state.dart'; import '../state.dart';
import '../config.dart'; import '../config.dart';
Widget buildSynced(BuildContext context, SyncedState state) { Widget summary(BuildContext context, SyncedState state) {
return Scaffold( return Container
(
body: Container padding: EdgeInsets.only(bottom: 10.0),
color: config.backgroundColor,
child: Align
( (
padding: EdgeInsets.only(bottom: 10.0), alignment: Alignment.center,
color: config.backgroundColor, child: Column
child: Align
( (
alignment: Alignment.center, mainAxisAlignment: MainAxisAlignment.center,
child: Column children: <Widget>
( [
mainAxisAlignment: MainAxisAlignment.center, Spacer
children: <Widget> (
[ flex: 17,
Spacer ),
( Image.asset
flex: 17, ('assets/wownero_symbol.png',
), height: 220,
Image.asset ),
('assets/wownero_symbol.png', Spacer
height: 220, (
), flex: 7,
Spacer ),
Expanded
(
flex: 15,
child: AnimatedSwitcher
( (
flex: 7, duration: Duration(milliseconds: 500),
), child: Text
Expanded
(
flex: 15,
child: AnimatedSwitcher
( (
duration: Duration(milliseconds: 500), '${state.height}',
child: Text style: TextStyle
( (
'${state.height}', fontFamily: 'RobotoMono',
style: TextStyle fontSize: 35,
( fontWeight: FontWeight.bold,
fontFamily: 'RobotoMono', color: config.textColor,
fontSize: 35, ),
fontWeight: FontWeight.bold, key: ValueKey<int>(state.height),
color: config.textColor,
),
key: ValueKey<int>(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'),
),
],
),
);
}