mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 16:05:18 +00:00
feat: custom error toast
This commit is contained in:
parent
622d938d9e
commit
96f04c1756
@ -78,4 +78,5 @@ abstract class SpotubeIcons {
|
|||||||
static const lightning = Icons.flash_on_rounded;
|
static const lightning = Icons.flash_on_rounded;
|
||||||
static const colorSync = FeatherIcons.activity;
|
static const colorSync = FeatherIcons.activity;
|
||||||
static const language = FeatherIcons.globe;
|
static const language = FeatherIcons.globe;
|
||||||
|
static const error = FeatherIcons.alertTriangle;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ import 'package:flutter_hooks/flutter_hooks.dart';
|
|||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:motion_toast/motion_toast.dart';
|
||||||
import 'package:sidebarx/sidebarx.dart';
|
import 'package:sidebarx/sidebarx.dart';
|
||||||
|
|
||||||
import 'package:spotube/collections/assets.gen.dart';
|
import 'package:spotube/collections/assets.gen.dart';
|
||||||
@ -280,7 +281,9 @@ class SidebarFooter extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(SpotubeIcons.settings),
|
icon: const Icon(SpotubeIcons.settings),
|
||||||
onPressed: () => Sidebar.goToSettings(context),
|
onPressed: () {
|
||||||
|
Sidebar.goToSettings(context);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -181,5 +181,6 @@
|
|||||||
"success_emoji": "আমরা সফল🥳",
|
"success_emoji": "আমরা সফল🥳",
|
||||||
"success_message": "এখন আপনি সফলভাবে আপনার Spotify অ্যাকাউন্ট দিয়ে লগ ইন করেছেন। সাধুভাত আপনাকে",
|
"success_message": "এখন আপনি সফলভাবে আপনার Spotify অ্যাকাউন্ট দিয়ে লগ ইন করেছেন। সাধুভাত আপনাকে",
|
||||||
"step_4": "ধাপ 4",
|
"step_4": "ধাপ 4",
|
||||||
"step_4_steps": "কপি করা \"sp_dc\" এবং \"sp_key\" এর মান সংশ্লিষ্ট ফিল্ডে পেস্ট করুন"
|
"step_4_steps": "কপি করা \"sp_dc\" এবং \"sp_key\" এর মান সংশ্লিষ্ট ফিল্ডে পেস্ট করুন",
|
||||||
|
"something_went_wrong": "কিছু ভুল হয়েছে"
|
||||||
}
|
}
|
@ -181,5 +181,6 @@
|
|||||||
"success_emoji": "Success🥳",
|
"success_emoji": "Success🥳",
|
||||||
"success_message": "Now you're successfully Logged In with your Spotify account. Good Job, mate!",
|
"success_message": "Now you're successfully Logged In with your Spotify account. Good Job, mate!",
|
||||||
"step_4": "Step 4",
|
"step_4": "Step 4",
|
||||||
"step_4_steps": "Paste the copied \"sp_dc\" and \"sp_key\" values in the respective fields"
|
"step_4_steps": "Paste the copied \"sp_dc\" and \"sp_key\" values in the respective fields",
|
||||||
|
"something_went_wrong": "Something went wrong"
|
||||||
}
|
}
|
@ -181,5 +181,6 @@
|
|||||||
"success_emoji": "Succès🥳",
|
"success_emoji": "Succès🥳",
|
||||||
"success_message": "Vous êtes maintenant connecté avec succès à votre compte Spotify. Bon travail, mon ami!",
|
"success_message": "Vous êtes maintenant connecté avec succès à votre compte Spotify. Bon travail, mon ami!",
|
||||||
"step_4": "Étape 4",
|
"step_4": "Étape 4",
|
||||||
"step_4_steps": "Collez les valeurs copiées de \"sp_dc\" et \"sp_key\" dans les champs respectifs"
|
"step_4_steps": "Collez les valeurs copiées de \"sp_dc\" et \"sp_key\" dans les champs respectifs",
|
||||||
|
"something_went_wrong": "Quelque chose s'est mal passé"
|
||||||
}
|
}
|
@ -181,5 +181,6 @@
|
|||||||
"success_emoji": "सफलता🥳",
|
"success_emoji": "सफलता🥳",
|
||||||
"success_message": "अब आप अपने स्पॉटिफाई अकाउंट से सफलतापूर्वक लॉगइन हो गए हैं। अच्छा काम किया!",
|
"success_message": "अब आप अपने स्पॉटिफाई अकाउंट से सफलतापूर्वक लॉगइन हो गए हैं। अच्छा काम किया!",
|
||||||
"step_4": "स्टेप 4",
|
"step_4": "स्टेप 4",
|
||||||
"step_4_steps": "कॉपी की गई \"sp_dc\" और \"sp_key\" मानों को संबंधित फील्ड में पेस्ट करें"
|
"step_4_steps": "कॉपी की गई \"sp_dc\" और \"sp_key\" मानों को संबंधित फील्ड में पेस्ट करें",
|
||||||
|
"something_went_wrong": "कुछ गलत हो गया"
|
||||||
}
|
}
|
@ -29,6 +29,7 @@ import 'package:spotube/provider/user_preferences_provider.dart';
|
|||||||
import 'package:spotube/services/audio_player/audio_player.dart';
|
import 'package:spotube/services/audio_player/audio_player.dart';
|
||||||
import 'package:spotube/services/youtube.dart';
|
import 'package:spotube/services/youtube.dart';
|
||||||
import 'package:spotube/themes/theme.dart';
|
import 'package:spotube/themes/theme.dart';
|
||||||
|
import 'package:spotube/utils/custom_toast_handler.dart';
|
||||||
import 'package:spotube/utils/persisted_state_notifier.dart';
|
import 'package:spotube/utils/persisted_state_notifier.dart';
|
||||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||||
import 'package:system_theme/system_theme.dart';
|
import 'package:system_theme/system_theme.dart';
|
||||||
@ -119,7 +120,7 @@ Future<void> main(List<String> rawArgs) async {
|
|||||||
enableApplicationParameters: false,
|
enableApplicationParameters: false,
|
||||||
),
|
),
|
||||||
FileHandler(await getLogsPath(), printLogs: false),
|
FileHandler(await getLogsPath(), printLogs: false),
|
||||||
SnackbarHandler(const Duration(seconds: 3)),
|
CustomToastHandler(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
releaseConfig: CatcherOptions(
|
releaseConfig: CatcherOptions(
|
||||||
@ -134,7 +135,7 @@ Future<void> main(List<String> rawArgs) async {
|
|||||||
await getLogsPath(),
|
await getLogsPath(),
|
||||||
printLogs: false,
|
printLogs: false,
|
||||||
),
|
),
|
||||||
SnackbarHandler(const Duration(seconds: 3)),
|
CustomToastHandler(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
runAppFunction: () {
|
runAppFunction: () {
|
||||||
|
58
lib/utils/custom_toast_handler.dart
Normal file
58
lib/utils/custom_toast_handler.dart
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
import 'package:catcher/model/platform_type.dart';
|
||||||
|
import 'package:catcher/model/report.dart';
|
||||||
|
import 'package:catcher/model/report_handler.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:motion_toast/motion_toast.dart';
|
||||||
|
import 'package:spotube/collections/spotube_icons.dart';
|
||||||
|
import 'package:spotube/extensions/context.dart';
|
||||||
|
|
||||||
|
class CustomToastHandler extends ReportHandler {
|
||||||
|
CustomToastHandler();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<bool> handle(Report error, BuildContext? context) async {
|
||||||
|
final theme = Theme.of(context!);
|
||||||
|
|
||||||
|
MotionToast(
|
||||||
|
primaryColor: theme.colorScheme.errorContainer,
|
||||||
|
icon: SpotubeIcons.error,
|
||||||
|
title: Text(
|
||||||
|
context.l10n.something_went_wrong,
|
||||||
|
style: theme.textTheme.bodyMedium?.copyWith(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: theme.colorScheme.onError,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
description: Text(
|
||||||
|
error.error.toString(),
|
||||||
|
style: theme.textTheme.bodyMedium?.copyWith(
|
||||||
|
color: theme.colorScheme.onError,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
dismissable: true,
|
||||||
|
toastDuration: const Duration(seconds: 10),
|
||||||
|
borderRadius: 10,
|
||||||
|
).show(context);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<PlatformType> getSupportedPlatforms() => [
|
||||||
|
PlatformType.android,
|
||||||
|
PlatformType.iOS,
|
||||||
|
PlatformType.web,
|
||||||
|
PlatformType.linux,
|
||||||
|
PlatformType.macOS,
|
||||||
|
PlatformType.windows,
|
||||||
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool isContextRequired() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool shouldHandleWhenRejected() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -1126,6 +1126,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.4"
|
version: "1.0.4"
|
||||||
|
motion_toast:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: motion_toast
|
||||||
|
sha256: f33fad8264d6d5359e41f2027d2d833614401c3983102e8f0aa13ccbbdcdeecd
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.6.8"
|
||||||
mutex:
|
mutex:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -102,6 +102,7 @@ dependencies:
|
|||||||
device_preview: ^1.1.0
|
device_preview: ^1.1.0
|
||||||
media_kit_native_event_loop: ^1.0.4
|
media_kit_native_event_loop: ^1.0.4
|
||||||
dbus: ^0.7.8
|
dbus: ^0.7.8
|
||||||
|
motion_toast: ^2.6.8
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
build_runner: ^2.3.2
|
build_runner: ^2.3.2
|
||||||
|
Loading…
Reference in New Issue
Block a user