Add disabled chat bar when logged out

This commit is contained in:
Tommy Chow 2022-01-09 14:56:40 -05:00
parent 91e07ef2e8
commit 0ea0ca09d5
2 changed files with 17 additions and 14 deletions

View file

@ -80,24 +80,26 @@ class _ChatState extends State<Chat> {
),
),
Observer(
builder: (_) => Visibility(
visible: !chatStore.autoScroll,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
width: double.infinity,
child: ElevatedButton.icon(
onPressed: chatStore.resumeScroll,
label: const Text('Resume Scroll'),
icon: const Icon(Icons.arrow_circle_down),
),
),
builder: (_) => AnimatedSwitcher(
duration: const Duration(milliseconds: 200),
child: chatStore.autoScroll
? const SizedBox()
: Container(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
width: double.infinity,
child: ElevatedButton.icon(
onPressed: chatStore.resumeScroll,
label: const Text('Resume Scroll'),
icon: const Icon(Icons.arrow_circle_down),
),
),
),
),
],
),
),
const SizedBox(height: 5.0),
if (chatStore.auth.isLoggedIn) ChatBottomBar(chatStore: chatStore),
ChatBottomBar(chatStore: chatStore),
if (chatStore.assetsStore.showEmoteMenu)
Flexible(
flex: 2,

View file

@ -32,6 +32,7 @@ class ChatBottomBar extends StatelessWidget {
child: TextField(
minLines: 1,
maxLines: 5,
enabled: chatStore.auth.isLoggedIn ? true : false,
onTap: () {
chatStore.assetsStore.showEmoteMenu = false;
Future.delayed(
@ -53,7 +54,7 @@ class ChatBottomBar extends StatelessWidget {
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
),
hintText: 'Send a message',
hintText: chatStore.auth.isLoggedIn ? 'Send a message' : "Log in to chat",
),
controller: chatStore.textController,
onSubmitted: chatStore.sendMessage,
@ -63,7 +64,7 @@ class ChatBottomBar extends StatelessWidget {
IconButton(
tooltip: 'Send',
icon: const Icon(Icons.send),
onPressed: () => chatStore.sendMessage(chatStore.textController.text),
onPressed: chatStore.auth.isLoggedIn ? () => chatStore.sendMessage(chatStore.textController.text) : null,
)
],
);