use flutter theme

This commit is contained in:
fuwa
2019-07-26 03:04:52 +08:00
parent 9dedc81012
commit a635f8e72b
11 changed files with 154 additions and 77 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ along with CyberWOW. If not, see <https://www.gnu.org/licenses/>.
import 'config/prototype.dart';
import 'config/cyberwow.dart' as cryptoConfig;
const c = cryptoConfig.config;
final c = cryptoConfig.config;
const arch = 'arm64';
// const arch = 'x86_64';
+48 -3
View File
@@ -23,14 +23,59 @@ import 'package:flutter/material.dart';
import 'prototype.dart';
const config = CryptoConfig
final _theme = ThemeData
(
brightness: Brightness.dark,
primaryColor: Colors.green,
hintColor: Colors.yellow,
primarySwatch: Colors.green,
accentColor: Colors.green,
scaffoldBackgroundColor: Colors.black,
fontFamily: 'RobotoMono',
textTheme: TextTheme
(
display1: TextStyle
(
fontSize: 35,
fontWeight: FontWeight.bold,
),
subhead: TextStyle
(
fontSize: 17,
fontWeight: FontWeight.bold,
),
body2: TextStyle
(
fontSize: 11,
),
).apply
(
bodyColor: Colors.green,
displayColor: Colors.green,
),
// cursorColor: config.c.textColor,
// inputDecorationTheme: InputDecorationTheme
// (
// focusedBorder: UnderlineInputBorder
// (
// borderSide: BorderSide(color: config.c.textColor)
// )
// )
);
final config = CryptoConfig
(
'wownerod',
'wownerod',
'Follow the white rabbit.',
70,
Colors.green,
Colors.black,
_theme,
34568,
[
'--prune-blockchain',
+2 -4
View File
@@ -26,8 +26,7 @@ class CryptoConfig {
final String appPath;
final String splash;
final int splashDelay;
final Color textColor;
final Color backgroundColor;
final ThemeData theme;
final int port;
final List<String> extraArgs;
const CryptoConfig
@@ -36,8 +35,7 @@ class CryptoConfig {
this.appPath,
this.splash,
this.splashDelay,
this.textColor,
this.backgroundColor,
this.theme,
this.port,
this.extraArgs,
);
+1 -4
View File
@@ -53,10 +53,7 @@ class CyberWOW_App extends StatelessWidget {
return MaterialApp
(
title: 'CyberWOW',
theme: ThemeData
(
primarySwatch: Colors.purple,
),
theme: config.c.theme,
home: CyberWOW_Page(title: 'CyberWOW'),
);
}
+2
View File
@@ -233,6 +233,8 @@ class SyncedState extends HookedState {
List<dynamic> getConnections = [];
List<dynamic> getTransactionPool = [];
final terminalController = TextEditingController();
SyncedState(f1, f2, f3, this.stdout, this.processInput, this.processOutput) : super (f1, f2, f3);
void appendInput(String line) {
-1
View File
@@ -28,7 +28,6 @@ Widget buildBlank(BuildContext context, BlankState state) {
return Scaffold(
body: Container
(
color: config.c.backgroundColor,
),
);
}
+1 -7
View File
@@ -35,7 +35,6 @@ Widget buildExiting(BuildContext context, ExitingState state) {
body: Container
(
// padding: const EdgeInsets.all(10.0),
color: config.c.backgroundColor,
child: Align
(
alignment: Alignment.topLeft,
@@ -54,12 +53,7 @@ Widget buildExiting(BuildContext context, ExitingState state) {
child: Text
(
state.stdout.join(),
style: TextStyle
(
fontFamily: 'RobotoMono',
fontSize: 11,
color: config.c.textColor,
),
style: Theme.of(context).textTheme.body2,
)
)
)
+1 -8
View File
@@ -33,7 +33,6 @@ Widget buildLoading(BuildContext context, LoadingState state) {
body: Container
(
padding: const EdgeInsets.all(10.0),
color: config.c.backgroundColor,
child: Align
(
alignment: Alignment.topLeft,
@@ -50,13 +49,7 @@ Widget buildLoading(BuildContext context, LoadingState state) {
child: Text
(
state.status,
style: TextStyle
(
fontFamily: 'RobotoMono',
fontSize: 17,
fontWeight: FontWeight.bold,
color: config.c.textColor,
),
style: Theme.of(context).textTheme.subhead,
)
)
)
+1 -7
View File
@@ -35,7 +35,6 @@ Widget buildReSyncing(BuildContext context, ReSyncingState state) {
body: Container
(
// padding: const EdgeInsets.all(10.0),
color: config.c.backgroundColor,
child: Align
(
alignment: Alignment.topLeft,
@@ -54,12 +53,7 @@ Widget buildReSyncing(BuildContext context, ReSyncingState state) {
child: Text
(
state.stdout.join(),
style: TextStyle
(
fontFamily: 'RobotoMono',
fontSize: 11,
color: config.c.textColor,
),
style: Theme.of(context).textTheme.body2,
)
)
)
+96 -35
View File
@@ -21,15 +21,16 @@ along with CyberWOW. If not, see <https://www.gnu.org/licenses/>.
import 'package:flutter/material.dart';
import 'dart:collection';
import '../state.dart';
import '../config.dart' as config;
import '../helper.dart';
Widget summary(SyncedState state) {
Widget summary(BuildContext context, SyncedState state) {
return Container
(
padding: EdgeInsets.only(bottom: 10.0),
color: config.c.backgroundColor,
child: Align
(
alignment: Alignment.center,
@@ -59,13 +60,7 @@ Widget summary(SyncedState state) {
child: Text
(
'${state.height}',
style: TextStyle
(
fontFamily: 'RobotoMono',
fontSize: 35,
fontWeight: FontWeight.bold,
color: config.c.textColor,
),
style: Theme.of(context).textTheme.display1,
key: ValueKey<int>(state.height),
)
)
@@ -91,11 +86,10 @@ Widget summary(SyncedState state) {
);
}
Widget rpcView(String title, dynamic body) {
Widget rpcView(BuildContext context, String title, dynamic body) {
return Container
(
padding: const EdgeInsets.all(10.0),
color: config.c.backgroundColor,
child: Align
(
alignment: Alignment.topLeft,
@@ -122,28 +116,17 @@ Widget rpcView(String title, dynamic body) {
Text
(
title,
style: TextStyle
(
fontFamily: 'RobotoMono',
fontSize: 35,
fontWeight: FontWeight.bold,
color: config.c.textColor,
),
style: Theme.of(context).textTheme.display1,
),
Container(
height: 1,
color: config.c.textColor,
color: Theme.of(context).primaryColor,
margin: const EdgeInsets.only(bottom: 20, top: 20),
),
Text
(
pretty(body),
style: TextStyle
(
fontFamily: 'RobotoMono',
fontSize: 11,
color: config.c.textColor,
),
style: Theme.of(context).textTheme.body2,
)
],
)
@@ -155,20 +138,98 @@ Widget rpcView(String title, dynamic body) {
);
}
Widget getInfo(SyncedState state) => rpcView('info', state.getInfo);
Widget getConnections(SyncedState state) => rpcView('connections', state.getConnections);
Widget syncInfo(SyncedState state) => rpcView('sync info', state.syncInfo);
Widget getTransactionPool(SyncedState state) => rpcView('tx pool', state.getTransactionPool);
Widget getInfo(BuildContext context, SyncedState state) => rpcView(context, 'info', state.getInfo);
Widget getConnections(BuildContext context, SyncedState state) => rpcView(context, 'connections', state.getConnections);
Widget syncInfo(BuildContext context, SyncedState state) => rpcView(context, 'sync info', state.syncInfo);
Widget getTransactionPool(BuildContext context, SyncedState state) => rpcView(context, 'tx pool', state.getTransactionPool);
Widget pageView (SyncedState state, PageController controller) {
Widget terminalView(BuildContext context, String title, SyncedState state) {
return Container
(
padding: const EdgeInsets.all(10.0),
child: Align
(
alignment: Alignment.topLeft,
child: Column
(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>
[
Expanded
(
flex: 1,
child: SingleChildScrollView
(
scrollDirection: Axis.vertical,
child: Column
(
children: <Widget>
[
Container(
height: 0,
margin: const EdgeInsets.only(bottom: 15),
),
Text
(
title,
style: Theme.of(context).textTheme.display1,
),
Container(
height: 1,
color: Theme.of(context).primaryColor,
margin: const EdgeInsets.only(bottom: 20, top: 20),
),
Text
(
state.stdout.join(),
style: Theme.of(context).textTheme.body2,
)
],
)
)
),
TextField
(
controller: state.terminalController,
decoration: InputDecoration
(
border: OutlineInputBorder
(
borderSide: BorderSide
(
),
),
enabledBorder: OutlineInputBorder
(
borderSide: BorderSide
(
color: Theme.of(context).primaryColor,
),
),
),
autofocus: true,
),
],
),
),
);
}
Widget terminal(BuildContext context, SyncedState state) => terminalView(context, 'terminal', state);
Widget pageView (BuildContext context, SyncedState state, PageController controller) {
return PageView (
controller: controller,
children:
[
summary(state),
getTransactionPool(state),
getInfo(state),
getConnections(state),
terminal(context, state),
summary(context, state),
getTransactionPool(context, state),
getInfo(context, state),
getConnections(context, state),
// syncInfo(state),
],
);
@@ -177,6 +238,6 @@ Widget pageView (SyncedState state, PageController controller) {
Widget buildSynced(BuildContext context, SyncedState state, PageController controller) {
return Scaffold
(
body: pageView(state, controller)
body: pageView(context, state, controller)
);
}
+1 -7
View File
@@ -35,7 +35,6 @@ Widget buildSyncing(BuildContext context, SyncingState state) {
body: Container
(
// padding: const EdgeInsets.all(10.0),
color: config.c.backgroundColor,
child: Align
(
alignment: Alignment.topLeft,
@@ -54,12 +53,7 @@ Widget buildSyncing(BuildContext context, SyncingState state) {
child: Text
(
state.stdout.join(),
style: TextStyle
(
fontFamily: 'RobotoMono',
fontSize: 11,
color: config.c.textColor,
),
style: Theme.of(context).textTheme.body2,
)
)
)