Add unfocus for chat & tweak text fields
This commit is contained in:
parent
49b3385c12
commit
4f3e25148f
3 changed files with 79 additions and 73 deletions
|
|
@ -16,43 +16,46 @@ class _SearchState extends State<Search> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextField(
|
||||
controller: _textController,
|
||||
autocorrect: false,
|
||||
decoration: const InputDecoration(
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.all(8.0),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(5.0)),
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: TextField(
|
||||
controller: _textController,
|
||||
autocorrect: false,
|
||||
decoration: const InputDecoration(
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.all(8.0),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(15.0)),
|
||||
),
|
||||
hintText: 'Search for a channel',
|
||||
),
|
||||
hintText: 'Search',
|
||||
),
|
||||
onSubmitted: (string) async {
|
||||
final user = await Twitch.getUser(userLogin: string, headers: context.read<AuthStore>().headersTwitch);
|
||||
if (user != null) {
|
||||
final channelInfo = await Twitch.getChannel(userId: user.id, headers: context.read<AuthStore>().headersTwitch);
|
||||
if (channelInfo != null) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) {
|
||||
return VideoChat(
|
||||
userLogin: channelInfo.broadcasterLogin,
|
||||
userName: channelInfo.broadcasterName,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
onSubmitted: (string) async {
|
||||
final user = await Twitch.getUser(userLogin: string, headers: context.read<AuthStore>().headersTwitch);
|
||||
if (user != null) {
|
||||
final channelInfo = await Twitch.getChannel(userId: user.id, headers: context.read<AuthStore>().headersTwitch);
|
||||
if (channelInfo != null) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) {
|
||||
return VideoChat(
|
||||
userLogin: channelInfo.broadcasterLogin,
|
||||
userName: channelInfo.broadcasterName,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
} else {
|
||||
const snackBar = SnackBar(content: Text('Failed to get channel info :('));
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
}
|
||||
} else {
|
||||
const snackBar = SnackBar(content: Text('Failed to get channel info :('));
|
||||
const snackBar = SnackBar(content: Text('User does not exist :('));
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
}
|
||||
} else {
|
||||
const snackBar = SnackBar(content: Text('User does not exist :('));
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
}
|
||||
_textController.clear();
|
||||
},
|
||||
_textController.clear();
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,47 +20,50 @@ class VideoChat extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
Observer(
|
||||
builder: (_) {
|
||||
if (context.read<SettingsStore>().videoEnabled) {
|
||||
return AspectRatio(
|
||||
aspectRatio: 16 / 9,
|
||||
child: Video(
|
||||
channelName: userLogin,
|
||||
videoStore: VideoStore(),
|
||||
settingsStore: context.read<SettingsStore>(),
|
||||
),
|
||||
child: GestureDetector(
|
||||
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
|
||||
child: Column(
|
||||
children: [
|
||||
Observer(
|
||||
builder: (_) {
|
||||
if (context.read<SettingsStore>().videoEnabled) {
|
||||
return AspectRatio(
|
||||
aspectRatio: 16 / 9,
|
||||
child: Video(
|
||||
channelName: userLogin,
|
||||
videoStore: VideoStore(),
|
||||
settingsStore: context.read<SettingsStore>(),
|
||||
),
|
||||
);
|
||||
}
|
||||
return AppBar(
|
||||
title: Text(userName),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.settings),
|
||||
onPressed: () {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return Settings(settingsStore: context.read<SettingsStore>());
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return AppBar(
|
||||
title: Text(userName),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.settings),
|
||||
onPressed: () {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return Settings(settingsStore: context.read<SettingsStore>());
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: Chat(
|
||||
chatStore: ChatStore(
|
||||
auth: context.read<AuthStore>(),
|
||||
channelName: userLogin,
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: Chat(
|
||||
chatStore: ChatStore(
|
||||
auth: context.read<AuthStore>(),
|
||||
channelName: userLogin,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -77,13 +77,13 @@ class _ChatState extends State<Chat> {
|
|||
if (context.read<AuthStore>().isLoggedIn)
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: TextField(
|
||||
decoration: const InputDecoration(
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.all(8.0),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(5.0)),
|
||||
borderRadius: BorderRadius.all(Radius.circular(15.0)),
|
||||
),
|
||||
hintText: 'Send a message',
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue