Fix account settings not updating on log in or out

This commit is contained in:
Tommy Chow 2022-01-26 16:41:02 -05:00
parent 476410da8f
commit 60de657a96
2 changed files with 89 additions and 88 deletions

View file

@ -11,62 +11,60 @@ class ChatBottomBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Observer(
builder: (context) {
return Row(
children: [
IconButton(
icon: Icon(Icons.adaptive.more),
tooltip: 'Chat Details',
onPressed: () => showModalBottomSheet(
isScrollControlled: true,
context: context,
builder: (_) => SizedBox(
height: MediaQuery.of(context).size.height * 0.8,
child: ChatDetails(
chatDetails: chatStore.chatDetailsStore,
userLogin: chatStore.channelName,
),
builder: (context) => Row(
children: [
IconButton(
icon: Icon(Icons.adaptive.more),
tooltip: 'Chat Details',
onPressed: () => showModalBottomSheet(
isScrollControlled: true,
context: context,
builder: (_) => SizedBox(
height: MediaQuery.of(context).size.height * 0.8,
child: ChatDetails(
chatDetails: chatStore.chatDetailsStore,
userLogin: chatStore.channelName,
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 5.0, horizontal: 10.0),
child: TextField(
focusNode: chatStore.textFieldFocusNode,
minLines: 1,
maxLines: 5,
enabled: chatStore.auth.isLoggedIn ? true : false,
decoration: InputDecoration(
suffixIcon: IconButton(
tooltip: 'Emote Menu',
icon: const Icon(Icons.emoji_emotions_outlined),
onPressed: () {
FocusScope.of(context).unfocus();
chatStore.assetsStore.showEmoteMenu = !chatStore.assetsStore.showEmoteMenu;
},
),
isDense: true,
hintMaxLines: 1,
contentPadding: const EdgeInsets.all(10.0),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(15.0)),
),
hintText: chatStore.auth.isLoggedIn ? 'Send a message' : "Log in to chat",
),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 5.0, horizontal: 10.0),
child: TextField(
focusNode: chatStore.textFieldFocusNode,
minLines: 1,
maxLines: 5,
enabled: chatStore.auth.isLoggedIn ? true : false,
decoration: InputDecoration(
suffixIcon: IconButton(
tooltip: 'Emote Menu',
icon: const Icon(Icons.emoji_emotions_outlined),
onPressed: () {
FocusScope.of(context).unfocus();
chatStore.assetsStore.showEmoteMenu = !chatStore.assetsStore.showEmoteMenu;
},
),
controller: chatStore.textController,
onSubmitted: chatStore.sendMessage,
isDense: true,
hintMaxLines: 1,
contentPadding: const EdgeInsets.all(10.0),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(15.0)),
),
hintText: chatStore.auth.isLoggedIn ? 'Send a message' : "Log in to chat",
),
controller: chatStore.textController,
onSubmitted: chatStore.sendMessage,
),
),
IconButton(
tooltip: 'Send',
icon: const Icon(Icons.send),
onPressed: chatStore.auth.isLoggedIn ? () => chatStore.sendMessage(chatStore.textController.text) : null,
)
],
);
},
),
IconButton(
tooltip: 'Send',
icon: const Icon(Icons.send),
onPressed: chatStore.auth.isLoggedIn ? () => chatStore.sendMessage(chatStore.textController.text) : null,
)
],
),
);
}
}

View file

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:frosty/core/auth/auth_store.dart';
import 'package:frosty/screens/settings/stores/settings_store.dart';
import 'package:frosty/screens/settings/widgets/blocked_users.dart';
@ -18,51 +19,53 @@ class AccountSettings extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SectionHeader(
'Account',
padding: EdgeInsets.all(10.0),
),
ProfileCard(authStore: authStore),
if (authStore.isLoggedIn) ...[
ListTile(
title: const Text('Blocked Users'),
trailing: Icon(Icons.adaptive.arrow_forward),
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => BlockedUsers(
authStore: authStore,
return Observer(
builder: (context) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SectionHeader(
'Account',
padding: EdgeInsets.all(10.0),
),
ProfileCard(authStore: authStore),
if (authStore.isLoggedIn) ...[
ListTile(
title: const Text('Blocked Users'),
trailing: Icon(Icons.adaptive.arrow_forward),
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => BlockedUsers(
authStore: authStore,
),
),
),
),
),
ListTile(
isThreeLine: true,
title: const Text('Log in to WebView'),
subtitle: const Text('Lets you avoid ads on your subscribed streamers or if you have Turbo.'),
trailing: Icon(Icons.adaptive.arrow_forward),
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return Scaffold(
appBar: AppBar(
title: const Text('Log In to WebView'),
),
body: const WebView(
initialUrl: 'https://www.twitch.tv/login',
javascriptMode: JavascriptMode.unrestricted,
),
);
},
ListTile(
isThreeLine: true,
title: const Text('Log in to WebView'),
subtitle: const Text('Lets you avoid ads on your subscribed streamers or if you have Turbo.'),
trailing: Icon(Icons.adaptive.arrow_forward),
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return Scaffold(
appBar: AppBar(
title: const Text('Log In to WebView'),
),
body: const WebView(
initialUrl: 'https://www.twitch.tv/login',
javascriptMode: JavascriptMode.unrestricted,
),
);
},
),
),
),
),
],
],
],
),
);
}
}