Add settings and stats button to chat

- Added ability to toggle video directly in chat
- Added hint to text field when searching
- Tweaked chat text field padding
This commit is contained in:
tommyxchow 2021-10-23 00:31:27 -04:00
parent 012accd918
commit 4af72b8da0
3 changed files with 61 additions and 21 deletions

View file

@ -41,6 +41,9 @@ class _HomeState extends State<Home> {
controller: _textController,
autocorrect: false,
autofocus: true,
decoration: const InputDecoration(
hintText: 'Search for a channel',
),
onSubmitted: (string) async {
if (await Twitch.getUser(userLogin: string, headers: context.read<AuthStore>().headersTwitch) != null) {
Navigator.push(

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:frosty/stores/auth_store.dart';
import 'package:frosty/stores/chat_store.dart';
import 'package:frosty/stores/settings_store.dart';
@ -18,12 +19,16 @@ class VideoChat extends StatelessWidget {
body: SafeArea(
child: Column(
children: [
Visibility(
visible: context.read<SettingsStore>().videoEnabled,
child: AspectRatio(
aspectRatio: 16 / 9,
child: Video(channelName: userLogin),
),
Observer(
builder: (_) {
return Visibility(
visible: context.read<SettingsStore>().videoEnabled,
child: AspectRatio(
aspectRatio: 16 / 9,
child: Video(channelName: userLogin),
),
);
},
),
Expanded(
child: Chat(chatStore: ChatStore(auth: context.read<AuthStore>(), channelName: userLogin)),

View file

@ -1,7 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:frosty/screens/settings.dart';
import 'package:frosty/stores/auth_store.dart';
import 'package:frosty/stores/chat_store.dart';
import 'package:frosty/widgets/chat_stats.dart';
import 'package:provider/provider.dart';
class Chat extends StatefulWidget {
@ -56,22 +58,52 @@ class _ChatState extends State<Chat> {
],
),
),
if (context.read<AuthStore>().isLoggedIn)
Padding(
padding: const EdgeInsets.all(5.0),
child: TextField(
decoration: const InputDecoration(
isDense: true,
contentPadding: EdgeInsets.all(8.0),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(5.0)),
),
hintText: 'Send a message',
),
controller: widget.chatStore.textController,
onSubmitted: (string) => widget.chatStore.sendMessage(string),
Row(
children: [
IconButton(
icon: const Icon(Icons.settings),
onPressed: () {
showModalBottomSheet(
context: context,
builder: (context) {
return const Settings();
},
);
},
),
),
IconButton(
icon: const Icon(Icons.stacked_bar_chart),
onPressed: () {
showModalBottomSheet(
context: context,
builder: (context) {
return ChatStats(
chatStore: widget.chatStore,
);
},
);
},
),
if (context.read<AuthStore>().isLoggedIn)
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
decoration: const InputDecoration(
isDense: true,
contentPadding: EdgeInsets.all(8.0),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(5.0)),
),
hintText: 'Send a message',
),
controller: widget.chatStore.textController,
onSubmitted: (string) => widget.chatStore.sendMessage(string),
),
),
),
],
)
],
);
}