Skip to content

Commit

Permalink
#4 #3 add alert to landing page, adjust keyboard focus in serial term…
Browse files Browse the repository at this point in the history
…inal
  • Loading branch information
PatHock committed Jun 22, 2018
1 parent 3475438 commit 47dc4d0
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 26 deletions.
30 changes: 24 additions & 6 deletions lib/view/landing_view.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'serial_terminal_view.dart'; //FIXME: fix this
import 'serial_terminal_view.dart'; //FIXME: fix this

class LandingView extends StatelessWidget {
@override
Expand Down Expand Up @@ -63,20 +63,38 @@ class LandingView extends StatelessWidget {
elevation: 4.0,
splashColor: Colors.deepOrange,
onPressed: () {
print("You pressed the button. Good job!");
var alert = new AlertDialog(
title: new Text("ALERT"),
content: new Text("You pressed the button, kiddo. Good job!"),
actions: <Widget>[
new FlatButton(
child: new Text('K'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
showDialog(
context: context,
child: alert,
barrierDismissible: false,
);
}),
new Divider(),
new Divider(),
new RaisedButton(
child: const Text('Go to Serial Terminal Page'),
color: Theme.of(context).accentColor,
elevation: 4.0,
splashColor: Colors.deepOrange,
onPressed: () {
print("You pressed the serial terminal button."); //TODO: navigate to new page
print(
"You pressed the serial terminal button."); //TODO: navigate to new page
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SerialTerminalView()),
);
MaterialPageRoute(
builder: (context) => SerialTerminalView()),
);
})
], // Children
),
Expand Down
56 changes: 36 additions & 20 deletions lib/view/serial_terminal_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class _SerialTerminalViewState extends State<SerialTerminalView> {
// of the TextField!
final textController = TextEditingController();

// Create the focus node. We will pass it to the TextField below.
final focusNode = FocusNode();

@override
void initState() {
// TODO: implement initState
Expand All @@ -24,6 +27,7 @@ class _SerialTerminalViewState extends State<SerialTerminalView> {
void dispose() {
// Clean up the controller when the Widget is removed from the Widget tree
textController.dispose();
focusNode.dispose();
super.dispose();
}

Expand All @@ -33,27 +37,39 @@ class _SerialTerminalViewState extends State<SerialTerminalView> {
appBar: new AppBar(
title: new Text("Serial Terminal"),
),
body: new SizedBox(
// height: 500.0,

child: new Card(
child: new Column(
children: [
TextField(
controller: textController,
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration(
// fillColor: Colors.black,
// filled: true,
border: InputBorder.none,
hintText: "Type something here.",
body:
// height: 500.0,
new GestureDetector(
onTap: () {
print("Text field was tapped.");
focusNode.unfocus();
// focusNode.consumeKeyboardToken();
FocusScope.of(context).requestFocus(focusNode);
},
child: new SizedBox(
child: new Card(
child: new Column(
children: [
TextField(
focusNode: focusNode,
controller: textController,
autofocus: true,
autocorrect: false,
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration(
// fillColor: Colors.black,
// filled: true,
border: InputBorder.none,
hintText: "Type something here.",
),
)
], // Children
),
),
)
], // Children
),
),
),
)),
);
}
}


0 comments on commit 47dc4d0

Please sign in to comment.