fix: Homeserver readonly if conifg wants it

This commit is contained in:
Christian Pauly 2021-01-23 12:11:02 +01:00
parent 3f14d5ed07
commit c81158a1c9
2 changed files with 8 additions and 3 deletions

View File

@ -8,6 +8,7 @@ class DefaultAppBarSearchField extends StatefulWidget {
final String prefixText;
final String hintText;
final EdgeInsets padding;
final bool readOnly;
const DefaultAppBarSearchField({
Key key,
@ -18,6 +19,7 @@ class DefaultAppBarSearchField extends StatefulWidget {
this.prefixText,
this.hintText,
this.padding,
this.readOnly = false,
}) : super(key: key);
@override
@ -71,6 +73,7 @@ class _DefaultAppBarSearchFieldState extends State<DefaultAppBarSearchField> {
controller: _searchController,
onChanged: widget.onChanged,
focusNode: _focusNode,
readOnly: widget.readOnly,
decoration: InputDecoration(
prefixText: widget.prefixText,
contentPadding: EdgeInsets.only(
@ -82,9 +85,10 @@ class _DefaultAppBarSearchFieldState extends State<DefaultAppBarSearchField> {
borderRadius: BorderRadius.circular(32),
),
hintText: widget.hintText,
suffixIcon: _focusNode.hasFocus ||
(widget.suffix == null &&
(_searchController.text?.isNotEmpty ?? false))
suffixIcon: !widget.readOnly &&
(_focusNode.hasFocus ||
(widget.suffix == null &&
(_searchController.text?.isNotEmpty ?? false)))
? IconButton(
icon: Icon(Icons.backspace_outlined),
onPressed: () {

View File

@ -71,6 +71,7 @@ class _HomeserverPickerState extends State<HomeserverPicker> {
suffix: Icon(Icons.edit_outlined),
padding: padding,
onChanged: (s) => _domain = s,
readOnly: !AppConfig.allowOtherHomeservers,
),
elevation: 0,
),