Skip to content

Commit

Permalink
Fix L10n missing from Calling's context
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSunCat authored and krille-chan committed Jul 19, 2023
1 parent a73b80a commit 8e7a2ec
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
21 changes: 11 additions & 10 deletions lib/pages/dialer/dialer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class MyCallingPage extends State<Calling> {
Room? get room => call.room;

String get displayName => call.room.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
MatrixLocals(L10n.of(widget.context)!),
);

String get callId => widget.callId;
Expand Down Expand Up @@ -248,18 +248,18 @@ class MyCallingPage extends State<Calling> {

void _resizeLocalVideo(Orientation orientation) {
final shortSide = min(
MediaQuery.of(context).size.width,
MediaQuery.of(context).size.height,
MediaQuery.of(widget.context).size.width,
MediaQuery.of(widget.context).size.height,
);
_localVideoMargin = remoteStream != null
? const EdgeInsets.only(top: 20.0, right: 20.0)
: EdgeInsets.zero;
_localVideoWidth = remoteStream != null
? shortSide / 3
: MediaQuery.of(context).size.width;
: MediaQuery.of(widget.context).size.width;
_localVideoHeight = remoteStream != null
? shortSide / 4
: MediaQuery.of(context).size.height;
: MediaQuery.of(widget.context).size.height;
}

void _handleCallState(CallState state) {
Expand Down Expand Up @@ -309,14 +309,15 @@ class MyCallingPage extends State<Calling> {
androidNotificationOptions: AndroidNotificationOptions(
channelId: 'notification_channel_id',
channelName: 'Foreground Notification',
channelDescription: L10n.of(context)!.foregroundServiceRunning,
channelDescription:
L10n.of(widget.context)!.foregroundServiceRunning,
),
iosNotificationOptions: const IOSNotificationOptions(),
foregroundTaskOptions: const ForegroundTaskOptions(),
);
FlutterForegroundTask.startService(
notificationTitle: L10n.of(context)!.screenSharingTitle,
notificationText: L10n.of(context)!.screenSharingDetail,
notificationTitle: L10n.of(widget.context)!.screenSharingTitle,
notificationText: L10n.of(widget.context)!.screenSharingDetail,
);
} else {
FlutterForegroundTask.stopService();
Expand Down Expand Up @@ -379,7 +380,7 @@ class MyCallingPage extends State<Calling> {
child: Icon(_speakerOn ? Icons.volume_up : Icons.volume_off),
onPressed: _switchSpeaker,
foregroundColor: Colors.black54,
backgroundColor: Theme.of(context).backgroundColor,
backgroundColor: Theme.of(widget.context).backgroundColor,
);
*/
final hangupButton = FloatingActionButton(
Expand Down Expand Up @@ -481,7 +482,7 @@ class MyCallingPage extends State<Calling> {
var title = '';
if (call.localHold) {
title = '${call.room.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
MatrixLocals(L10n.of(widget.context)!),
)} held the call.';
} else if (call.remoteOnHold) {
title = 'You held the call.';
Expand Down
5 changes: 3 additions & 2 deletions lib/utils/voip_plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class VoipPlugin with WidgetsBindingObserver implements WebRTCDelegate {
void addCallingOverlay(String callId, CallSession call) {
final context = kIsWeb
? ChatList.contextForVoip!
: FluffyChatApp.routerKey.currentContext!; // web is weird
: FluffyChatApp.matrixKey.currentContext!; // web is weird

if (overlayEntry != null) {
Logs().e('[VOIP] addCallingOverlay: The call session already exists?');
overlayEntry!.remove();
Expand Down Expand Up @@ -165,7 +166,7 @@ class VoipPlugin with WidgetsBindingObserver implements WebRTCDelegate {
addCallingOverlay(call.callId, call);
try {
if (!hasCallingAccount) {
ScaffoldMessenger.of(FluffyChatApp.routerKey.currentContext!)
ScaffoldMessenger.of(FluffyChatApp.matrixKey.currentContext!)
.showSnackBar(
const SnackBar(
content: Text(
Expand Down
2 changes: 2 additions & 0 deletions lib/widgets/fluffy_chat_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class FluffyChatApp extends StatefulWidget {
final List<Client> clients;
final Map<String, String>? queryParameters;
static GlobalKey<VRouterState> routerKey = GlobalKey<VRouterState>();
static GlobalKey<MatrixState> matrixKey = GlobalKey<MatrixState>();
const FluffyChatApp({
Key? key,
this.testWidget,
Expand Down Expand Up @@ -75,6 +76,7 @@ class FluffyChatAppState extends State<FluffyChatApp> {
initialUrl: _initialUrl ?? '/',
routes: AppRoutes(columnMode ?? false).routes,
builder: (context, child) => Matrix(
key: FluffyChatApp.matrixKey,
context: context,
router: FluffyChatApp.routerKey,
clients: widget.clients,
Expand Down

0 comments on commit 8e7a2ec

Please # to comment.