Skip to content

Commit

Permalink
fixup! TW-1456: optionnal duration param added to snackbar
Browse files Browse the repository at this point in the history
  • Loading branch information
Te-Z committed Mar 21, 2024
1 parent d36d131 commit d6b1297
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
17 changes: 11 additions & 6 deletions lib/pages/profile_info/profile_info_body/profile_info_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import 'package:fluffychat/di/global/get_it_initializer.dart';
import 'package:fluffychat/domain/app_state/contact/lookup_match_contact_state.dart';
import 'package:fluffychat/domain/usecase/contacts/lookup_match_contact_interactor.dart';
import 'package:fluffychat/pages/profile_info/profile_info_body/profile_info_body_view.dart';
import 'package:fluffychat/presentation/mixins/go_to_direct_chat_mixin.dart';
import 'package:fluffychat/presentation/model/search/presentation_search.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

import 'package:matrix/matrix.dart';

Expand All @@ -30,7 +31,8 @@ class ProfileInfoBody extends StatefulWidget {
State<ProfileInfoBody> createState() => ProfileInfoBodyController();
}

class ProfileInfoBodyController extends State<ProfileInfoBody> {
class ProfileInfoBodyController extends State<ProfileInfoBody>
with GoToDraftChatMixin {
final _lookupMatchContactInteractor =
getIt.get<LookupMatchContactInteractor>();

Expand Down Expand Up @@ -58,10 +60,13 @@ class ProfileInfoBodyController extends State<ProfileInfoBody> {
);
}

void openNewChat(String roomId) {
parentContext.go('/rooms/$roomId');
if (widget.onNewChatOpen != null) widget.onNewChatOpen!();
}
Future<void> openNewChat() => onContactTap(
context: context,
path: 'rooms',
contactPresentationSearch: user!.toContactPresentationSearch(),
).then((_) {
if (widget.onNewChatOpen != null) widget.onNewChatOpen!();
});

@override
void initState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:fluffychat/pages/profile_info/copiable_profile_row/svg_copiable_
import 'package:fluffychat/pages/profile_info/profile_info_body/profile_info_body.dart';
import 'package:fluffychat/pages/profile_info/profile_info_body/profile_info_body_view_style.dart';
import 'package:fluffychat/resource/image_paths.dart';
import 'package:fluffychat/utils/dialog/twake_dialog.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/presence_extension.dart';
import 'package:fluffychat/widgets/avatar/avatar.dart';
import 'package:fluffychat/widgets/matrix.dart';
Expand Down Expand Up @@ -54,15 +53,7 @@ class ProfileInfoBodyView extends StatelessWidget {
children: [
Expanded(
child: TextButton.icon(
onPressed: () async {
final roomIdResult =
await TwakeDialog.showFutureLoadingDialogFullScreen(
future: () => controller.user!.startDirectChat(),
);
if (roomIdResult.error != null) return;

controller.openNewChat(roomIdResult.result!);
},
onPressed: () => controller.openNewChat(),
icon: const Icon(Icons.chat_outlined),
label: L10n.of(context)?.newChat != null
? Row(
Expand Down
6 changes: 3 additions & 3 deletions lib/presentation/mixins/go_to_direct_chat_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ mixin GoToDraftChatMixin {
}
}

void onContactTap({
Future<void> onContactTap({
required BuildContext context,
required String path,
required ContactPresentationSearch contactPresentationSearch,
}) {
}) async {
final roomId = Matrix.of(context)
.client
.getDirectChatFromUserId(contactPresentationSearch.matrixId!);
Expand All @@ -43,7 +43,7 @@ mixin GoToDraftChatMixin {
contactPresentationSearch: contactPresentationSearch,
);
} else {
TwakeDialog.showFutureLoadingDialogFullScreen(
await TwakeDialog.showFutureLoadingDialogFullScreen(
future: () async {
if (contactPresentationSearch.matrixId != null &&
contactPresentationSearch.matrixId!.isNotEmpty) {
Expand Down

0 comments on commit d6b1297

Please sign in to comment.