Add ability to unfocus keyboard on search (#49)
This commit is contained in:
parent
824732fe38
commit
19d36f6a2b
1 changed files with 53 additions and 50 deletions
|
|
@ -44,57 +44,60 @@ class _SearchState extends State<Search> {
|
|||
Expanded(
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () => searchStore.handleQuery(searchStore.textController.text),
|
||||
child: Observer(
|
||||
builder: (_) {
|
||||
return ListView.builder(
|
||||
itemCount: searchStore.searchResults.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == searchStore.searchResults.length) {
|
||||
if (searchStore.textController.text.isEmpty) {
|
||||
return const SizedBox();
|
||||
}
|
||||
return ListTile(
|
||||
title: Text('Go to ${searchStore.textController.text}'),
|
||||
onTap: () => searchStore.handleSearch(searchStore.textController.text, context),
|
||||
);
|
||||
}
|
||||
|
||||
final channel = searchStore.searchResults[index];
|
||||
return ListTile(
|
||||
title: Text(channel.displayName),
|
||||
trailing: channel.isLive
|
||||
? ClipRRect(
|
||||
borderRadius: BorderRadius.circular(5.0),
|
||||
child: Container(
|
||||
color: const Color(0xFFF44336),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: const Text(
|
||||
'LIVE',
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
)
|
||||
: null,
|
||||
subtitle:
|
||||
channel.isLive ? Text('Uptime: ${DateTime.now().difference(DateTime.parse(channel.startedAt)).toString().split('.')[0]}') : null,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) {
|
||||
return VideoChat(
|
||||
title: channel.title,
|
||||
userName: channel.displayName,
|
||||
userLogin: channel.broadcasterLogin,
|
||||
);
|
||||
},
|
||||
),
|
||||
child: GestureDetector(
|
||||
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
|
||||
child: Observer(
|
||||
builder: (_) {
|
||||
return ListView.builder(
|
||||
itemCount: searchStore.searchResults.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == searchStore.searchResults.length) {
|
||||
if (searchStore.textController.text.isEmpty) {
|
||||
return const SizedBox();
|
||||
}
|
||||
return ListTile(
|
||||
title: Text('Go to ${searchStore.textController.text}'),
|
||||
onTap: () => searchStore.handleSearch(searchStore.textController.text, context),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
final channel = searchStore.searchResults[index];
|
||||
return ListTile(
|
||||
title: Text(channel.displayName),
|
||||
trailing: channel.isLive
|
||||
? ClipRRect(
|
||||
borderRadius: BorderRadius.circular(5.0),
|
||||
child: Container(
|
||||
color: const Color(0xFFF44336),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: const Text(
|
||||
'LIVE',
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
)
|
||||
: null,
|
||||
subtitle:
|
||||
channel.isLive ? Text('Uptime: ${DateTime.now().difference(DateTime.parse(channel.startedAt)).toString().split('.')[0]}') : null,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) {
|
||||
return VideoChat(
|
||||
title: channel.title,
|
||||
userName: channel.displayName,
|
||||
userLogin: channel.broadcasterLogin,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue