Merge pull request #6195 from fufesou/fix/autocomplete
fix, autocomplete, fill id field
This commit is contained in:
commit
625f2d2410
@ -55,12 +55,12 @@ import 'package:flutter_hbb/common/widgets/peer_card.dart';
|
|||||||
}
|
}
|
||||||
|
|
||||||
class AutocompletePeerTile extends StatefulWidget {
|
class AutocompletePeerTile extends StatefulWidget {
|
||||||
final IDTextEditingController idController;
|
final VoidCallback onSelect;
|
||||||
final Peer peer;
|
final Peer peer;
|
||||||
|
|
||||||
const AutocompletePeerTile({
|
const AutocompletePeerTile({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.idController,
|
required this.onSelect,
|
||||||
required this.peer,
|
required this.peer,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@ -85,12 +85,7 @@ class _AutocompletePeerTileState extends State<AutocompletePeerTile>{
|
|||||||
fontSize: 11,
|
fontSize: 11,
|
||||||
color: Theme.of(context).textTheme.titleLarge?.color?.withOpacity(0.6));
|
color: Theme.of(context).textTheme.titleLarge?.color?.withOpacity(0.6));
|
||||||
final child = GestureDetector(
|
final child = GestureDetector(
|
||||||
onTap: () {
|
onTap: () => widget.onSelect(),
|
||||||
setState(() {
|
|
||||||
widget.idController.id = widget.peer.id;
|
|
||||||
FocusScope.of(context).unfocus();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child:
|
child:
|
||||||
Container(
|
Container(
|
||||||
height: 42,
|
height: 42,
|
||||||
|
@ -277,6 +277,12 @@ class _ConnectionPageState extends State<ConnectionPage>
|
|||||||
},
|
},
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
|
onSelected: (option) {
|
||||||
|
setState(() {
|
||||||
|
_idController.id = option.id;
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
});
|
||||||
|
},
|
||||||
optionsViewBuilder: (BuildContext context, AutocompleteOnSelected<Peer> onSelected, Iterable<Peer> options) {
|
optionsViewBuilder: (BuildContext context, AutocompleteOnSelected<Peer> onSelected, Iterable<Peer> options) {
|
||||||
double maxHeight = options.length * 50;
|
double maxHeight = options.length * 50;
|
||||||
maxHeight = maxHeight > 200 ? 200 : maxHeight;
|
maxHeight = maxHeight > 200 ? 200 : maxHeight;
|
||||||
@ -304,7 +310,7 @@ class _ConnectionPageState extends State<ConnectionPage>
|
|||||||
: Padding(
|
: Padding(
|
||||||
padding: const EdgeInsets.only(top: 5),
|
padding: const EdgeInsets.only(top: 5),
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: options.map((peer) => AutocompletePeerTile(idController: _idController, peer: peer)).toList(),
|
children: options.map((peer) => AutocompletePeerTile(onSelect: () => onSelected(peer), peer: peer)).toList(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -245,6 +245,12 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
|||||||
inputFormatters: [IDTextInputFormatter()],
|
inputFormatters: [IDTextInputFormatter()],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
onSelected: (option) {
|
||||||
|
setState(() {
|
||||||
|
_idController.id = option.id;
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
});
|
||||||
|
},
|
||||||
optionsViewBuilder: (BuildContext context, AutocompleteOnSelected<Peer> onSelected, Iterable<Peer> options) {
|
optionsViewBuilder: (BuildContext context, AutocompleteOnSelected<Peer> onSelected, Iterable<Peer> options) {
|
||||||
double maxHeight = options.length * 50;
|
double maxHeight = options.length * 50;
|
||||||
maxHeight = maxHeight > 200 ? 200 : maxHeight;
|
maxHeight = maxHeight > 200 ? 200 : maxHeight;
|
||||||
@ -268,7 +274,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
|||||||
)))
|
)))
|
||||||
: ListView(
|
: ListView(
|
||||||
padding: EdgeInsets.only(top: 5),
|
padding: EdgeInsets.only(top: 5),
|
||||||
children: options.map((peer) => AutocompletePeerTile(idController: _idController, peer: peer)).toList(),
|
children: options.map((peer) => AutocompletePeerTile(onSelect: () => onSelected(peer), peer: peer)).toList(),
|
||||||
))))
|
))))
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user