Skip to content

Commit

Permalink
fix: improve group creation flow on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
brenodt committed Nov 21, 2023
1 parent ac31a01 commit d0db020
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
2 changes: 2 additions & 0 deletions qaul_ui/lib/screens/home/tabs/chat/chat_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class _ChatState extends _BaseTabState<_Chat> {
if (newChat is User) {
final newRoom = ChatRoom.blank(otherUser: newChat);
setOpenChat(newRoom, newChat);
} else if (newChat is ChatRoom) {
setOpenChat(newChat);
}
}, [setOpenChat]);

Expand Down
32 changes: 10 additions & 22 deletions qaul_ui/lib/screens/home/tabs/chat/dialogs/dialogs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ class _CreateNewRoomDialog extends StatelessWidget {
],
),
title: Text(l10n.createNewGroup),
onTap: () => Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (_) => _CreateNewGroupDialog(),
),
),
onTap: () async {
final result = await Navigator.push(
context,
MaterialPageRoute(
builder: (_) => _CreateNewGroupDialog(),
),
);
Navigator.pop(context, result);
},
);
}
final usr = users[i - 1];
Expand All @@ -53,21 +56,6 @@ class _CreateNewGroupDialog extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final worker = ref.read(qaulWorkerProvider);
final defaultUser = ref.watch(defaultUserProvider)!;

final mobile =
Responsiveness.isMobile(context); // MediaQuery on HookState.init throws
final setOpenChat = useCallback((ChatRoom room, [User? otherUser]) {
if (mobile) {
openChat(room,
ref: ref,
context: context,
user: defaultUser,
otherUser: otherUser);
} else {
ref.read(currentOpenChatRoom.notifier).state = room;
}
}, [mobile]);

final loading = useState(false);
final nameCtrl = useTextEditingController();
Expand Down Expand Up @@ -141,7 +129,7 @@ class _CreateNewGroupDialog extends HookConsumerWidget {
var chatRoom = ref
.read(chatRoomsProvider)
.firstWhereOrNull((g) => g.name == name);
if (chatRoom != null) setOpenChat(chatRoom);

Navigator.pop(context, chatRoom);
},
),
Expand Down

0 comments on commit d0db020

Please sign in to comment.