mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-04-20 23:22:07 +00:00
The initialization of discordRPC on iOS and Android was leading to a grey screen (UnimplementedError), preventing the app to paint the Flutter UI. The flutter_discord_rpc is only available on macOS, Linux and Windows.
48 lines
1.7 KiB
Dart
48 lines
1.7 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:mangayomi/main.dart';
|
|
import 'package:mangayomi/modules/more/providers/incognito_mode_state_provider.dart';
|
|
import 'package:mangayomi/modules/more/settings/general/providers/general_state_provider.dart';
|
|
import 'package:mangayomi/modules/more/widgets/list_tile_widget.dart';
|
|
import 'package:mangayomi/providers/l10n_providers.dart';
|
|
|
|
class IncognitoModeWidget extends ConsumerWidget {
|
|
const IncognitoModeWidget({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final l10n = l10nLocalizations(context);
|
|
final incognitoMode = ref.watch(incognitoModeStateProvider);
|
|
final hideDiscordRpcInIncognito = ref.watch(
|
|
hideDiscordRpcInIncognitoStateProvider,
|
|
);
|
|
return ListTileWidget(
|
|
onTap: () {
|
|
if (incognitoMode == true) {
|
|
ref.read(incognitoModeStateProvider.notifier).setIncognitoMode(false);
|
|
if (hideDiscordRpcInIncognito) discordRpc?.connect(ref);
|
|
} else {
|
|
ref.read(incognitoModeStateProvider.notifier).setIncognitoMode(true);
|
|
if (hideDiscordRpcInIncognito) discordRpc?.disconnect();
|
|
}
|
|
},
|
|
icon: CupertinoIcons.eyeglasses,
|
|
subtitle: l10n!.incognito_mode_description,
|
|
title: l10n.incognito_mode,
|
|
trailing: Switch(
|
|
value: incognitoMode,
|
|
onChanged: (value) {
|
|
ref.read(incognitoModeStateProvider.notifier).setIncognitoMode(value);
|
|
if (hideDiscordRpcInIncognito) {
|
|
if (value) {
|
|
discordRpc?.disconnect();
|
|
} else {
|
|
discordRpc?.connect(ref);
|
|
}
|
|
}
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|