mirror of
https://github.com/wownero/cyberwow.git
synced 2026-10-19 00:08:43 +02:00
add pager
This commit is contained in:
@@ -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,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: <Widget>
|
||||
[
|
||||
Spacer
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>
|
||||
[
|
||||
Spacer
|
||||
(
|
||||
flex: 17,
|
||||
),
|
||||
Image.asset
|
||||
('assets/wownero_symbol.png',
|
||||
height: 220,
|
||||
),
|
||||
Spacer
|
||||
(
|
||||
flex: 7,
|
||||
),
|
||||
Expanded
|
||||
(
|
||||
flex: 15,
|
||||
child: AnimatedSwitcher
|
||||
(
|
||||
flex: 17,
|
||||
),
|
||||
Image.asset
|
||||
('assets/wownero_symbol.png',
|
||||
height: 220,
|
||||
),
|
||||
Spacer
|
||||
(
|
||||
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<int>(state.height),
|
||||
)
|
||||
fontFamily: 'RobotoMono',
|
||||
fontSize: 35,
|
||||
fontWeight: FontWeight.bold,
|
||||
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'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user