diff --git a/lib/pages/chat_draft/draft_chat_adaptive_scaffold.dart b/lib/pages/chat_draft/draft_chat_adaptive_scaffold.dart index 52b4b2ebb6..e0e15ee243 100644 --- a/lib/pages/chat_draft/draft_chat_adaptive_scaffold.dart +++ b/lib/pages/chat_draft/draft_chat_adaptive_scaffold.dart @@ -34,6 +34,7 @@ class DraftChatAdaptiveScaffold extends StatelessWidget { onBack: controller.hideRightColumn, contact: _contact, isInStack: isInStack, + isDraftInfo: true, ); default: return const SizedBox(); diff --git a/lib/pages/chat_draft/draft_chat_view.dart b/lib/pages/chat_draft/draft_chat_view.dart index c7e6841ab4..1797130516 100644 --- a/lib/pages/chat_draft/draft_chat_view.dart +++ b/lib/pages/chat_draft/draft_chat_view.dart @@ -54,6 +54,9 @@ class DraftChatView extends StatelessWidget { title: Row( children: [ TwakeIconButton( + splashColor: Colors.transparent, + hoverColor: Colors.transparent, + highlightColor: Colors.transparent, tooltip: L10n.of(context)!.back, icon: Icons.arrow_back, onTap: () => context.pop(), diff --git a/lib/pages/chat_profile_info/chat_profile_info.dart b/lib/pages/chat_profile_info/chat_profile_info.dart index a62ca7fec0..c2babb4abc 100644 --- a/lib/pages/chat_profile_info/chat_profile_info.dart +++ b/lib/pages/chat_profile_info/chat_profile_info.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:dartz/dartz.dart' hide State; import 'package:fluffychat/app_state/failure.dart'; import 'package:fluffychat/app_state/success.dart'; @@ -16,6 +18,7 @@ class ProfileInfo extends StatefulWidget { final String? roomId; final PresentationContact? contact; final bool isInStack; + final bool isDraftInfo; const ProfileInfo({ super.key, @@ -23,6 +26,7 @@ class ProfileInfo extends StatefulWidget { required this.isInStack, this.roomId, this.contact, + required this.isDraftInfo, }); @override @@ -33,6 +37,8 @@ class ProfileInfoController extends State { final _lookupMatchContactInteractor = getIt.get(); + StreamSubscription? lookupContactNotifierSub; + final ValueNotifier> lookupContactNotifier = ValueNotifier>( const Right(LookupContactsInitial()), @@ -46,9 +52,9 @@ class ProfileInfoController extends State { room?.unsafeGetUserFromMemoryOrFallback(room?.directChatMatrixID ?? ''); void lookupMatchContactAction() { - _lookupMatchContactInteractor + lookupContactNotifierSub = _lookupMatchContactInteractor .execute( - val: user?.id ?? '', + val: widget.contact?.matrixId ?? user?.id ?? '', ) .listen( (event) => lookupContactNotifier.value = event, @@ -56,6 +62,7 @@ class ProfileInfoController extends State { } void goToProfileShared() { + if (widget.isDraftInfo) return; Navigator.of(context).pushNamed( ProfileInfoRoutes.profileInfoShared, arguments: widget.roomId, @@ -68,6 +75,13 @@ class ProfileInfoController extends State { super.initState(); } + @override + void dispose() { + lookupContactNotifier.dispose(); + lookupContactNotifierSub?.cancel(); + super.dispose(); + } + @override Widget build(BuildContext context) { return ProfileInfoView(this); diff --git a/lib/pages/chat_profile_info/chat_profile_info_navigator.dart b/lib/pages/chat_profile_info/chat_profile_info_navigator.dart index fcfcf2a415..f8f7d52fd9 100644 --- a/lib/pages/chat_profile_info/chat_profile_info_navigator.dart +++ b/lib/pages/chat_profile_info/chat_profile_info_navigator.dart @@ -7,10 +7,6 @@ import 'package:fluffychat/presentation/model/presentation_contact.dart'; class ProfileInfoRoutes { static const String profileInfo = '/profileInfo'; static const String profileInfoShared = 'profileInfo/shared'; - - static final GlobalKey innerNavigatorProfileKey = GlobalKey( - debugLabel: 'innerNavigatorProfileKey', - ); } class ProfileInfoNavigator extends StatelessWidget { @@ -18,6 +14,7 @@ class ProfileInfoNavigator extends StatelessWidget { final String? roomId; final PresentationContact? contact; final bool isInStack; + final bool isDraftInfo; const ProfileInfoNavigator({ Key? key, @@ -25,12 +22,12 @@ class ProfileInfoNavigator extends StatelessWidget { this.roomId, this.contact, required this.isInStack, + this.isDraftInfo = false, }) : super(key: key); @override Widget build(BuildContext context) { return Navigator( - key: ProfileInfoRoutes.innerNavigatorProfileKey, initialRoute: ProfileInfoRoutes.profileInfo, onGenerateRoute: (route) => MaterialPageRoute( builder: (context) { @@ -41,6 +38,7 @@ class ProfileInfoNavigator extends StatelessWidget { isInStack: isInStack, roomId: roomId, contact: contact, + isDraftInfo: isDraftInfo, ); case ProfileInfoRoutes.profileInfoShared: diff --git a/lib/pages/chat_profile_info/chat_profile_info_view.dart b/lib/pages/chat_profile_info/chat_profile_info_view.dart index b6dd99733b..d9239b5400 100644 --- a/lib/pages/chat_profile_info/chat_profile_info_view.dart +++ b/lib/pages/chat_profile_info/chat_profile_info_view.dart @@ -30,25 +30,27 @@ class ProfileInfoView extends StatelessWidget { final user = controller.user; final contact = controller.widget.contact; return Scaffold( + backgroundColor: LinagoraSysColors.material().onPrimary, appBar: AppBar( + backgroundColor: LinagoraSysColors.material().onPrimary, automaticallyImplyLeading: false, centerTitle: false, - leading: Padding( - padding: ChatProfileInfoStyle.backIconPadding, - child: IconButton( - splashColor: Colors.transparent, - hoverColor: Colors.transparent, - highlightColor: Colors.transparent, - onPressed: controller.widget.onBack, - icon: controller.widget.isInStack - ? const Icon(Icons.arrow_back) - : const Icon(Icons.close), - ), - ), - leadingWidth: 40, - title: Text( - L10n.of(context)!.contactInfo, - style: Theme.of(context).textTheme.titleLarge, + title: Row( + children: [ + Padding( + padding: ChatProfileInfoStyle.backIconPadding, + child: IconButton( + onPressed: controller.widget.onBack, + icon: controller.widget.isInStack + ? const Icon(Icons.arrow_back) + : const Icon(Icons.close), + ), + ), + Text( + L10n.of(context)!.contactInfo, + style: Theme.of(context).textTheme.titleLarge, + ), + ], ), ), body: SingleChildScrollView( @@ -71,6 +73,7 @@ class ProfileInfoView extends StatelessWidget { matrixId: contact.matrixId, lookupContactNotifier: controller.lookupContactNotifier, goToProfileShared: controller.goToProfileShared, + isDraftInfo: controller.widget.isDraftInfo, ), ); } @@ -80,6 +83,7 @@ class ProfileInfoView extends StatelessWidget { matrixId: contact.matrixId, lookupContactNotifier: controller.lookupContactNotifier, goToProfileShared: controller.goToProfileShared, + isDraftInfo: controller.widget.isDraftInfo, ); } return _Information( @@ -88,6 +92,7 @@ class ProfileInfoView extends StatelessWidget { matrixId: user?.id, lookupContactNotifier: controller.lookupContactNotifier, goToProfileShared: controller.goToProfileShared, + isDraftInfo: controller.widget.isDraftInfo, ); }, ), @@ -108,6 +113,7 @@ class _Information extends StatelessWidget { this.matrixId, required this.lookupContactNotifier, this.goToProfileShared, + required this.isDraftInfo, }) : super(key: key); final Uri? avatarUri; @@ -115,6 +121,7 @@ class _Information extends StatelessWidget { final String? matrixId; final ValueNotifier> lookupContactNotifier; final Function()? goToProfileShared; + final bool isDraftInfo; @override Widget build(BuildContext context) { @@ -244,29 +251,31 @@ class _Information extends StatelessWidget { }, child: const SizedBox.shrink(), ), - InkWell( - splashColor: Colors.transparent, - hoverColor: Colors.transparent, - highlightColor: Colors.transparent, - onTap: goToProfileShared, - child: Padding( - padding: ChatProfileInfoStyle.titleSharedMediaAndFilesPadding, - child: Row( - children: [ - Text( - L10n.of(context)!.sharedMediaAndFiles, - style: Theme.of(context).textTheme.titleMedium, - ), - const Spacer(), - Icon( - Icons.arrow_forward, - size: 18, - color: LinagoraSysColors.material().onSurface, - ), - ], + if (!isDraftInfo) + InkWell( + splashColor: Colors.transparent, + hoverColor: Colors.transparent, + highlightColor: Colors.transparent, + onTap: goToProfileShared, + child: Padding( + padding: + ChatProfileInfoStyle.titleSharedMediaAndFilesPadding, + child: Row( + children: [ + Text( + L10n.of(context)!.sharedMediaAndFiles, + style: Theme.of(context).textTheme.titleMedium, + ), + const Spacer(), + Icon( + Icons.arrow_forward, + size: 18, + color: LinagoraSysColors.material().onSurface, + ), + ], + ), ), ), - ), ], ), ), diff --git a/lib/presentation/mixins/go_to_direct_chat_mixin.dart b/lib/presentation/mixins/go_to_direct_chat_mixin.dart index 977a7f14a1..f6fa8fe268 100644 --- a/lib/presentation/mixins/go_to_direct_chat_mixin.dart +++ b/lib/presentation/mixins/go_to_direct_chat_mixin.dart @@ -74,7 +74,7 @@ mixin GoToDraftChatMixin { Matrix.of(context).client.userID) { Router.neglect( context, - () => context.push( + () => context.go( '/$path/draftChat', extra: { PresentationContactConstant.receiverId: