diff --git a/cyberwow/lib/config/cyberwow.dart b/cyberwow/lib/config/cyberwow.dart index 1f0b3ec..f3444e8 100644 --- a/cyberwow/lib/config/cyberwow.dart +++ b/cyberwow/lib/config/cyberwow.dart @@ -31,6 +31,7 @@ final _theme = ThemeData hintColor: Colors.yellow, primarySwatch: Colors.green, accentColor: Colors.green, + cursorColor: Colors.green, scaffoldBackgroundColor: Colors.black, diff --git a/cyberwow/lib/main.dart b/cyberwow/lib/main.dart index e018878..4e3f29f 100644 --- a/cyberwow/lib/main.dart +++ b/cyberwow/lib/main.dart @@ -74,7 +74,7 @@ class _CyberWOW_PageState extends State with WidgetsBindingObserv AppState _state; AppLifecycleState _notification = AppLifecycleState.resumed; final syncedPageController = PageController( - initialPage: 0, + initialPage: 1, ); bool _exiting = false; diff --git a/cyberwow/lib/state.dart b/cyberwow/lib/state.dart index 0826a26..1bf5078 100644 --- a/cyberwow/lib/state.dart +++ b/cyberwow/lib/state.dart @@ -233,7 +233,8 @@ class SyncedState extends HookedState { List getConnections = []; List getTransactionPool = []; - final terminalController = TextEditingController(); + FocusNode focusNode = FocusNode(); + TextEditingController textController = TextEditingController(); SyncedState(f1, f2, f3, this.stdout, this.processInput, this.processOutput) : super (f1, f2, f3); diff --git a/cyberwow/lib/widget/synced.dart b/cyberwow/lib/widget/synced.dart index a329824..24a9e04 100644 --- a/cyberwow/lib/widget/synced.dart +++ b/cyberwow/lib/widget/synced.dart @@ -26,6 +26,7 @@ import 'dart:collection'; import '../state.dart'; import '../config.dart' as config; import '../helper.dart'; +import '../logging.dart'; Widget summary(BuildContext context, SyncedState state) { return Container @@ -145,9 +146,42 @@ Widget getTransactionPool(BuildContext context, SyncedState state) => rpcView(co Widget terminalView(BuildContext context, String title, SyncedState state) { + final input = TextFormField + ( + controller: state.textController, + textInputAction: TextInputAction.done, + autofocus: true, + autocorrect: false, + focusNode: state.focusNode, + decoration: + InputDecoration + ( + // border: UnderlineInputBorder // OutlineInputBorder + // ( + // ), + // hintText: 'WOW', + enabledBorder: UnderlineInputBorder + ( + borderSide: BorderSide + ( + color: Theme.of(context).primaryColor, + ), + ), + border: InputBorder.none, + ), + onFieldSubmitted: (v) { + if (state.textController.text != '') { + FocusScope.of(context).requestFocus(state.focusNode); + log.finer('terminal input: ${state.textController.text}'); + state.appendInput(state.textController.text); + state.textController.clear(); + } + }, + ); + return Container ( - padding: const EdgeInsets.all(10.0), + // padding: const EdgeInsets.all(10.0), child: Align ( alignment: Alignment.topLeft, @@ -162,25 +196,12 @@ Widget terminalView(BuildContext context, String title, SyncedState state) { child: SingleChildScrollView ( scrollDirection: Axis.vertical, + reverse: true, child: Column ( children: [ - 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(), @@ -190,26 +211,10 @@ Widget terminalView(BuildContext context, String title, SyncedState state) { ) ) ), - TextField + Container ( - controller: state.terminalController, - decoration: InputDecoration - ( - border: OutlineInputBorder - ( - borderSide: BorderSide - ( - ), - ), - enabledBorder: OutlineInputBorder - ( - borderSide: BorderSide - ( - color: Theme.of(context).primaryColor, - ), - ), - ), - autofocus: true, + margin: const EdgeInsets.all(10.0), + child: input, ), ], ),