Resolves #290 Hide pin inputs if code_format is null

This commit is contained in:
Yegor Vialov
2019-02-16 20:33:56 +02:00
parent 62b1af30e0
commit 3dea844e1e

View File

@ -123,99 +123,109 @@ class _AlarmControlPanelControlsWidgetWidgetState extends State<AlarmControlPane
) )
); );
} }
Widget pinPad = Padding( Widget pinPad;
padding: EdgeInsets.only(bottom: Sizes.rowPadding), if (entity.attributes["code_format"] == null) {
child: Column( pinPad = Container(width: 0.0, height: 0.0,);
mainAxisSize: MainAxisSize.min, } else {
children: <Widget>[ pinPad = Padding(
Wrap( padding: EdgeInsets.only(bottom: Sizes.rowPadding),
spacing: 5.0, child: Column(
children: <Widget>[ mainAxisSize: MainAxisSize.min,
RaisedButton( children: <Widget>[
onPressed: () => _pinPadHandler("1"), Wrap(
child: Text("1"), spacing: 5.0,
), children: <Widget>[
RaisedButton( RaisedButton(
onPressed: () => _pinPadHandler("2"), onPressed: () => _pinPadHandler("1"),
child: Text("2"), child: Text("1"),
), ),
RaisedButton( RaisedButton(
onPressed: () => _pinPadHandler("3"), onPressed: () => _pinPadHandler("2"),
child: Text("3"), child: Text("2"),
) ),
], RaisedButton(
), onPressed: () => _pinPadHandler("3"),
Wrap( child: Text("3"),
spacing: 5.0, )
children: <Widget>[ ],
RaisedButton( ),
onPressed: () => _pinPadHandler("4"), Wrap(
child: Text("4"), spacing: 5.0,
), children: <Widget>[
RaisedButton( RaisedButton(
onPressed: () => _pinPadHandler("5"), onPressed: () => _pinPadHandler("4"),
child: Text("5"), child: Text("4"),
), ),
RaisedButton( RaisedButton(
onPressed: () => _pinPadHandler("6"), onPressed: () => _pinPadHandler("5"),
child: Text("6"), child: Text("5"),
) ),
], RaisedButton(
), onPressed: () => _pinPadHandler("6"),
Wrap( child: Text("6"),
spacing: 5.0, )
children: <Widget>[ ],
RaisedButton( ),
onPressed: () => _pinPadHandler("7"), Wrap(
child: Text("7"), spacing: 5.0,
), children: <Widget>[
RaisedButton( RaisedButton(
onPressed: () => _pinPadHandler("8"), onPressed: () => _pinPadHandler("7"),
child: Text("8"), child: Text("7"),
), ),
RaisedButton( RaisedButton(
onPressed: () => _pinPadHandler("9"), onPressed: () => _pinPadHandler("8"),
child: Text("9"), child: Text("8"),
) ),
], RaisedButton(
), onPressed: () => _pinPadHandler("9"),
Wrap( child: Text("9"),
spacing: 5.0, )
alignment: WrapAlignment.end, ],
children: <Widget>[ ),
RaisedButton( Wrap(
onPressed: () => _pinPadHandler("0"), spacing: 5.0,
child: Text("0"), alignment: WrapAlignment.end,
), children: <Widget>[
RaisedButton( RaisedButton(
onPressed: () => _pinPadClear(), onPressed: () => _pinPadHandler("0"),
child: Text("CLEAR"), child: Text("0"),
) ),
], RaisedButton(
) onPressed: () => _pinPadClear(),
], child: Text("CLEAR"),
) )
); ],
Widget inputWrapper = Container( )
width: 150.0, ],
child: TextField( )
decoration: InputDecoration( );
labelText: "Alarm Code" }
), Widget inputWrapper;
//focusNode: _focusNode, if (entity.attributes["code_format"] == null) {
obscureText: true, inputWrapper = Container(width: 0.0, height: 0.0,);
controller: new TextEditingController.fromValue( } else {
new TextEditingValue( inputWrapper = Container(
text: code, width: 150.0,
selection: child: TextField(
new TextSelection.collapsed(offset: code.length) decoration: InputDecoration(
) labelText: "Alarm Code"
), ),
onChanged: (value) { //focusNode: _focusNode,
code = value; obscureText: true,
} controller: new TextEditingController.fromValue(
) new TextEditingValue(
); text: code,
selection:
new TextSelection.collapsed(offset: code.length)
)
),
onChanged: (value) {
code = value;
}
)
);
}
Widget buttonsWrapper = Padding( Widget buttonsWrapper = Padding(
padding: EdgeInsets.symmetric(vertical: Sizes.rowPadding), padding: EdgeInsets.symmetric(vertical: Sizes.rowPadding),
child: Wrap( child: Wrap(