Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TW-1936: fix the share screen don't show up when sharing an image #1991

Merged
merged 7 commits into from
Sep 10, 2024
9 changes: 0 additions & 9 deletions lib/config/go_routes/go_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import 'package:fluffychat/pages/login/on_auth_redirect.dart';
import 'package:fluffychat/pages/new_group/new_group_chat_info.dart';
import 'package:fluffychat/pages/settings_dashboard/settings_app_language/settings_app_language.dart';
import 'package:fluffychat/pages/settings_dashboard/settings_profile/settings_profile.dart';
import 'package:fluffychat/pages/share/share.dart';
import 'package:fluffychat/pages/story/story_page.dart';
import 'package:fluffychat/pages/twake_welcome/twake_welcome.dart';
import 'package:fluffychat/presentation/model/chat/chat_router_input_argument.dart';
Expand Down Expand Up @@ -519,14 +518,6 @@ abstract class AppRoutes {
),
],
),
GoRoute(
path: '/share',
pageBuilder: (context, state) => defaultPageBuilder(
context,
const Share(),
),
redirect: loggedOutRedirect,
),
],
),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ class ParticipantListItem extends StatelessWidget {
Icons.person_search,
color: LinagoraSysColors.material().onSurface,
),
label: L10n.of(context)?.viewProfile != null
label: L10n.of(bottomSheetContext)?.viewProfile != null
? Row(
children: [
Text(
L10n.of(context)!.viewProfile,
L10n.of(bottomSheetContext)!.viewProfile,
style: TextStyle(
color: LinagoraSysColors.material()
.onSurface,
Expand Down
30 changes: 27 additions & 3 deletions lib/pages/chat_list/receive_sharing_intent_mixin.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:fluffychat/event/twake_event_types.dart';
import 'package:fluffychat/pages/share/share.dart';
import 'package:fluffychat/presentation/extensions/shared_media_file_extension.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/utils/url_launcher.dart';
Expand Down Expand Up @@ -35,9 +36,32 @@ mixin ReceiveSharingIntentMixin<T extends StatefulWidget> on State<T> {
},
)
.toList();
TwakeApp.router.go('/share');
openSharePage();
}

void openSharePage() {
if (isCurrentPageIsNotRooms()) {
return;
}
if (isCurrentPageIsInRooms()) {
TwakeApp.router.go('/rooms');
}

Navigator.of(TwakeApp.routerKey.currentContext!).push(
MaterialPageRoute(
builder: (context) => const Share(),
),
);
}

bool isCurrentPageIsInRooms() =>
TwakeApp.router.routeInformationProvider.value.uri.path
.startsWith('/rooms/');

bool isCurrentPageIsNotRooms() =>
!TwakeApp.router.routeInformationProvider.value.uri.path
.startsWith('/rooms');
sherlockvn marked this conversation as resolved.
Show resolved Hide resolved
nqhhdev marked this conversation as resolved.
Show resolved Hide resolved

void _processIncomingSharedText(String? text) {
if (text == null) return;
if (_intentOpenApp(text)) {
Expand All @@ -53,7 +77,7 @@ mixin ReceiveSharingIntentMixin<T extends StatefulWidget> on State<T> {
'msgtype': 'm.text',
'body': text,
};
TwakeApp.router.go('/share');
openSharePage();
}

void _processIncomingUris(String? text) async {
Expand All @@ -62,7 +86,7 @@ mixin ReceiveSharingIntentMixin<T extends StatefulWidget> on State<T> {
if (_intentOpenApp(text)) {
return;
}
TwakeApp.router.go('/share');
openSharePage();
WidgetsBinding.instance.addPostFrameCallback((_) {
UrlLauncher(context, url: text).openMatrixToUrl();
});
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/share/share.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class ShareController extends State<Share>
Map<String, dynamic>? textContent,
}) {
if (textContent == null) return;
Navigator.pop(context);
room.sendEvent(textContent);
context.go('/rooms/${room.id}');
}
Expand All @@ -107,6 +108,7 @@ class ShareController extends State<Share>
content?.tryGet<String>('msgtype') ==
TwakeEventTypes.shareFileEventType,
)) {
Navigator.pop(context);
context.go(
'/rooms/${room.id}',
extra: ChatRouterInputArgument(
Expand Down