feat: Switch to VRouter
This commit is contained in:
parent
ab4ea74d00
commit
c2fce64494
57 changed files with 678 additions and 617 deletions
|
|
@ -22,7 +22,6 @@ import 'dart:convert';
|
|||
import 'dart:io';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fcm_shared_isolate/fcm_shared_isolate.dart';
|
||||
|
||||
|
|
@ -34,6 +33,7 @@ import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|||
import 'package:flutter_gen/gen_l10n/l10n_en.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:vrouter/vrouter.dart';
|
||||
import 'platform_infos.dart';
|
||||
import '../config/app_config.dart';
|
||||
import '../config/setting_keys.dart';
|
||||
|
|
@ -51,7 +51,7 @@ class BackgroundPush {
|
|||
FlutterLocalNotificationsPlugin();
|
||||
FluffyClient client;
|
||||
BuildContext context;
|
||||
GlobalKey<AdaptivePageLayoutState> apl;
|
||||
GlobalKey<VRouterState> router;
|
||||
String _fcmToken;
|
||||
LoginState _loginState;
|
||||
L10n l10n;
|
||||
|
|
@ -95,10 +95,10 @@ class BackgroundPush {
|
|||
}
|
||||
|
||||
factory BackgroundPush(FluffyClient _client, BuildContext _context,
|
||||
GlobalKey<AdaptivePageLayoutState> _apl) {
|
||||
GlobalKey<VRouterState> router) {
|
||||
final instance = BackgroundPush.clientOnly(_client);
|
||||
instance.context = _context;
|
||||
instance.apl = _apl;
|
||||
instance.router = router;
|
||||
instance.fullInit();
|
||||
return instance;
|
||||
}
|
||||
|
|
@ -235,7 +235,7 @@ class BackgroundPush {
|
|||
if (details == null ||
|
||||
!details.didNotificationLaunchApp ||
|
||||
_wentToRoomOnStartup ||
|
||||
apl == null) {
|
||||
router == null) {
|
||||
return;
|
||||
}
|
||||
_wentToRoomOnStartup = true;
|
||||
|
|
@ -249,7 +249,7 @@ class BackgroundPush {
|
|||
}
|
||||
if (await store.getItemBool(SettingKeys.showNoGoogle, true)) {
|
||||
await loadLocale();
|
||||
apl.currentState.showSnackBar(SnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(
|
||||
PlatformInfos.isAndroid
|
||||
? l10n.noGoogleServicesWarning
|
||||
|
|
@ -280,10 +280,10 @@ class BackgroundPush {
|
|||
Future<void> goToRoom(String roomId) async {
|
||||
try {
|
||||
Logs().v('[Push] Attempting to go to room $roomId...');
|
||||
if (apl == null) {
|
||||
if (router == null) {
|
||||
return;
|
||||
}
|
||||
await apl.currentState.pushNamedAndRemoveUntilIsFirst('/rooms/$roomId');
|
||||
router.currentState.push('/rooms/$roomId');
|
||||
} catch (e, s) {
|
||||
Logs().e('[Push] Failed to open room', e, s);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
|
@ -13,7 +12,7 @@ abstract class FluffyShare {
|
|||
await Clipboard.setData(
|
||||
ClipboardData(text: text),
|
||||
);
|
||||
AdaptivePageLayout.of(context).showSnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(L10n.of(context).copiedToClipboard)));
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ abstract class PlatformInfos {
|
|||
final version = await PlatformInfos.getVersion();
|
||||
showAboutDialog(
|
||||
context: context,
|
||||
useRootNavigator: false,
|
||||
children: [
|
||||
Text('Version: $version'),
|
||||
OutlinedButton(
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
|
||||
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:vrouter/vrouter.dart';
|
||||
|
||||
class UrlLauncher {
|
||||
final String url;
|
||||
|
|
@ -60,11 +61,10 @@ class UrlLauncher {
|
|||
if (room != null) {
|
||||
// we have the room, so....just open it
|
||||
if (event != null) {
|
||||
await AdaptivePageLayout.of(context)
|
||||
.pushNamedAndRemoveUntilIsFirst('/rooms/${room.id}/$event');
|
||||
VRouter.of(context)
|
||||
.push('/rooms/${room.id}', queryParameters: {'event': event});
|
||||
} else {
|
||||
await AdaptivePageLayout.of(context)
|
||||
.pushNamedAndRemoveUntilIsFirst('/rooms/${room.id}');
|
||||
VRouter.of(context).push('/rooms/${room.id}');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -72,7 +72,6 @@ class UrlLauncher {
|
|||
if (await showOkCancelAlertDialog(
|
||||
context: context,
|
||||
title: 'Join room $roomIdOrAlias',
|
||||
useRootNavigator: false,
|
||||
) ==
|
||||
OkCancelResult.ok) {
|
||||
roomId = roomIdOrAlias;
|
||||
|
|
@ -89,16 +88,15 @@ class UrlLauncher {
|
|||
context: context,
|
||||
future: () => Future.delayed(const Duration(seconds: 2)));
|
||||
if (event != null) {
|
||||
await AdaptivePageLayout.of(context).pushNamedAndRemoveUntilIsFirst(
|
||||
'/rooms/${response.result}/$event');
|
||||
VRouter.of(context).push('/rooms/${response.result}/$event');
|
||||
} else {
|
||||
await AdaptivePageLayout.of(context)
|
||||
.pushNamedAndRemoveUntilIsFirst('/rooms/${response.result}');
|
||||
VRouter.of(context).push('/rooms/${response.result}');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
await AdaptivePageLayout.of(context)
|
||||
.pushNamedAndRemoveUntilIsFirst('/search/$roomIdOrAlias');
|
||||
VRouter.of(context).push('/search', queryParameters: {
|
||||
if (roomIdOrAlias != null) 'query': roomIdOrAlias
|
||||
});
|
||||
}
|
||||
} else if (identityParts.primaryIdentifier.sigil == '@') {
|
||||
final user = User(
|
||||
|
|
@ -107,8 +105,7 @@ class UrlLauncher {
|
|||
);
|
||||
var roomId = matrix.client.getDirectChatFromUserId(user.id);
|
||||
if (roomId != null) {
|
||||
await AdaptivePageLayout.of(context)
|
||||
.pushNamedAndRemoveUntilIsFirst('/rooms/$roomId');
|
||||
VRouter.of(context).push('/rooms/$roomId');
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -116,7 +113,6 @@ class UrlLauncher {
|
|||
if (await showOkCancelAlertDialog(
|
||||
context: context,
|
||||
title: 'Message user ${user.id}',
|
||||
useRootNavigator: false,
|
||||
) ==
|
||||
OkCancelResult.ok) {
|
||||
roomId = (await showFutureLoadingDialog(
|
||||
|
|
@ -126,8 +122,7 @@ class UrlLauncher {
|
|||
.result;
|
||||
|
||||
if (roomId != null) {
|
||||
await AdaptivePageLayout.of(context)
|
||||
.pushNamedAndRemoveUntilIsFirst('/rooms/$roomId');
|
||||
VRouter.of(context).push('/rooms/$roomId');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue