feat: Removed mute delay (#11)
Co-authored-by: Salvatore Giordano <[email protected]>
This commit is contained in:
co-authored by
Salvatore Giordano
parent
4667e7da98
commit
9082e50532
@@ -18,6 +18,14 @@ class ChatInfoScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ChatInfoScreenState extends State<ChatInfoScreen> {
|
class _ChatInfoScreenState extends State<ChatInfoScreen> {
|
||||||
|
ValueNotifier<bool> mutedBool = ValueNotifier(false);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
mutedBool = ValueNotifier(StreamChannel.of(context).channel.isMuted);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final channel = StreamChannel.of(context).channel;
|
final channel = StreamChannel.of(context).channel;
|
||||||
@@ -134,6 +142,8 @@ class _ChatInfoScreenState extends State<ChatInfoScreen> {
|
|||||||
StreamBuilder<bool>(
|
StreamBuilder<bool>(
|
||||||
stream: StreamChannel.of(context).channel.isMutedStream,
|
stream: StreamChannel.of(context).channel.isMutedStream,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
|
mutedBool.value = snapshot.data;
|
||||||
|
|
||||||
return OptionListTile(
|
return OptionListTile(
|
||||||
tileColor: StreamChatTheme.of(context).colorTheme.whiteSnow,
|
tileColor: StreamChatTheme.of(context).colorTheme.whiteSnow,
|
||||||
title: 'Mute user',
|
title: 'Mute user',
|
||||||
@@ -150,16 +160,22 @@ class _ChatInfoScreenState extends State<ChatInfoScreen> {
|
|||||||
),
|
),
|
||||||
trailing: snapshot.data == null
|
trailing: snapshot.data == null
|
||||||
? CircularProgressIndicator()
|
? CircularProgressIndicator()
|
||||||
: CupertinoSwitch(
|
: ValueListenableBuilder<bool>(
|
||||||
value: snapshot.data,
|
valueListenable: mutedBool,
|
||||||
onChanged: (val) {
|
builder: (context, value, _) {
|
||||||
if (snapshot.data) {
|
return CupertinoSwitch(
|
||||||
channel.channel.unmute();
|
value: value,
|
||||||
} else {
|
onChanged: (val) {
|
||||||
channel.channel.mute();
|
mutedBool.value = val;
|
||||||
}
|
|
||||||
},
|
if (snapshot.data) {
|
||||||
),
|
channel.channel.unmute();
|
||||||
|
} else {
|
||||||
|
channel.channel.mute();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
|||||||
|
|
||||||
bool listExpanded = false;
|
bool listExpanded = false;
|
||||||
|
|
||||||
|
ValueNotifier<bool> mutedBool = ValueNotifier(false);
|
||||||
|
|
||||||
void _userNameListener() {
|
void _userNameListener() {
|
||||||
if (_searchController.text == _userNameQuery) {
|
if (_searchController.text == _userNameQuery) {
|
||||||
return;
|
return;
|
||||||
@@ -54,6 +56,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
|||||||
_nameController.addListener(() {
|
_nameController.addListener(() {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
});
|
});
|
||||||
|
mutedBool = ValueNotifier(StreamChannel.of(context).channel.isMuted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -434,6 +437,8 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
|||||||
StreamBuilder<bool>(
|
StreamBuilder<bool>(
|
||||||
stream: StreamChannel.of(context).channel.isMutedStream,
|
stream: StreamChannel.of(context).channel.isMutedStream,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
|
mutedBool.value = snapshot.data;
|
||||||
|
|
||||||
return OptionListTile(
|
return OptionListTile(
|
||||||
tileColor: StreamChatTheme.of(context).colorTheme.whiteSnow,
|
tileColor: StreamChatTheme.of(context).colorTheme.whiteSnow,
|
||||||
separatorColor:
|
separatorColor:
|
||||||
@@ -452,16 +457,22 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
|||||||
),
|
),
|
||||||
trailing: snapshot.data == null
|
trailing: snapshot.data == null
|
||||||
? CircularProgressIndicator()
|
? CircularProgressIndicator()
|
||||||
: CupertinoSwitch(
|
: ValueListenableBuilder<bool>(
|
||||||
value: snapshot.data,
|
valueListenable: mutedBool,
|
||||||
onChanged: (val) {
|
builder: (context, value, _) {
|
||||||
if (snapshot.data) {
|
return CupertinoSwitch(
|
||||||
channel.channel.unmute();
|
value: value,
|
||||||
} else {
|
onChanged: (val) {
|
||||||
channel.channel.mute();
|
mutedBool.value = val;
|
||||||
}
|
|
||||||
},
|
if (snapshot.data) {
|
||||||
),
|
channel.channel.unmute();
|
||||||
|
} else {
|
||||||
|
channel.channel.mute();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user