statenotifier

This commit is contained in:
Christien Rioux 2023-09-30 21:00:22 -04:00
parent 8f0b4aaba0
commit 7a49497620
15 changed files with 28 additions and 56 deletions

View file

@ -207,7 +207,8 @@ class ChatComponentState extends ConsumerState<ChatComponent> {
IconButton(
icon: const Icon(Icons.close),
onPressed: () async {
activeChatState.add(null);
ref.read(activeChatStateProvider.notifier).state =
null;
}).paddingLTRB(16, 0, 16, 0)
]),
),

View file

@ -20,7 +20,7 @@ class ChatSingleContactItemWidget extends ConsumerWidget {
//final textTheme = theme.textTheme;
final scale = theme.extension<ScaleScheme>()!;
final activeChat = ref.watch(activeChatStateProvider).value;
final activeChat = ref.watch(activeChatStateProvider);
final remoteConversationRecordKey =
proto.TypedKeyProto.fromProto(contact.remoteConversationRecordKey);
final selected = activeChat == remoteConversationRecordKey;
@ -69,7 +69,8 @@ class ChatSingleContactItemWidget extends ConsumerWidget {
// component is not dragged.
child: ListTile(
onTap: () async {
activeChatState.add(remoteConversationRecordKey);
ref.read(activeChatStateProvider.notifier).state =
remoteConversationRecordKey;
ref.invalidate(fetchChatListProvider);
},
title: Text(contact.editedProfile.name),

View file

@ -15,10 +15,8 @@ class SignalStrengthMeterWidget extends ConsumerWidget {
final scale = theme.extension<ScaleScheme>()!;
const iconSize = 16.0;
final connState = ref.watch(globalConnectionStateProvider).value;
if (connState == null) {
return const Icon(Icons.signal_cellular_off, size: iconSize);
}
final connState = ref.watch(globalConnectionStateProvider);
late final double value;
late final Color color;
late final Color inactiveColor;