Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: config toast

appflowy57e5c36fe8af
diff --git a/frontend/app_flowy/lib/workspace/presentation/home/toast.dart b/frontend/app_flowy/lib/workspace/presentation/home/toast.dart
new file mode 100644
index 0000000000..28241c0ec4
--- /dev/null
+++ b/frontend/app_flowy/lib/workspace/presentation/home/toast.dart
@@ -0,0 +1,37 @@
+import 'package:app_flowy/startup/startup.dart';
+import 'package:flowy_infra_ui/style_widget/text.dart';
+import 'package:flutter/material.dart';
+import 'package:fluttertoast/fluttertoast.dart';
+
+class FlowyMessageToast extends StatelessWidget {
+ final String message;
+ const FlowyMessageToast({required this.message, Key? key}) : super(key: key);
+
+ @override
+ Widget build(BuildContext context) {
+ return Container(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
+ child: FlowyText.medium(message, color: Colors.white),
+ ),
+ decoration: const BoxDecoration(
+ borderRadius: BorderRadius.all(Radius.circular(4)),
+ color: Colors.black,
+ ),
+ );
+ }
+}
+
+void initToastWithContext(BuildContext context) {
+ getIt<FToast>().init(context);
+}
+
+void showMessageToast(String message) {
+ final child = FlowyMessageToast(message: message);
+
+ getIt<FToast>().showToast(
+ child: child,
+ gravity: ToastGravity.BOTTOM,
+ toastDuration: const Duration(seconds: 3),
+ );
+}
diff --git a/frontend/app_flowy/lib/workspace/presentation/widgets/float_bubble/question_bubble.dart b/frontend/app_flowy/lib/workspace/presentation/widgets/float_bubble/question_bubble.dart
index 8fecbc9489..6cc150489c 100644
--- a/frontend/app_flowy/lib/workspace/presentation/widgets/float_bubble/question_bubble.dart
+++ b/frontend/app_flowy/lib/workspace/presentation/widgets/float_bubble/question_bubble.dart
@@ -1,5 +1,5 @@
-import 'package:app_flowy/startup/startup.dart';
import 'package:app_flowy/startup/tasks/rust_sdk.dart';
+import 'package:app_flowy/workspace/presentation/home/toast.dart';
import 'package:app_flowy/workspace/presentation/widgets/pop_up_action.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/theme.dart';
@@ -16,7 +16,6 @@ import 'package:package_info_plus/package_info_plus.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:app_flowy/generated/locale_keys.g.dart';
import 'package:device_info_plus/device_info_plus.dart';
-import 'package:fluttertoast/fluttertoast.dart';
class QuestionBubble extends StatelessWidget {
const QuestionBubble({Key? key}) : super(key: key);
@@ -46,7 +45,7 @@ class QuestionBubble extends StatelessWidget {
_launchURL("https://discord.gg/9Q2xaN37tV");
break;
case BubbleAction.debug:
- const _DebugToast().show();
+ _DebugToast().show();
break;
}
});
@@ -71,55 +70,14 @@ class QuestionBubble extends StatelessWidget {
}
}
-class _DebugToast extends StatelessWidget {
- const _DebugToast({Key? key}) : super(key: key);
+class _DebugToast {
+ void show() async {
+ var debugInfo = "";
+ debugInfo += await _getDeviceInfo();
+ debugInfo += await _getDocumentPath();
+ Clipboard.setData(ClipboardData(text: debugInfo));
- @override
- Widget build(BuildContext context) {
- return FutureBuilder(
- future: Future(() async {
- var debugInfo = "";
- debugInfo += await _getDeviceInfo();
- debugInfo += await _getDocumentPath();
-
- Clipboard.setData(ClipboardData(text: debugInfo));
- }),
- builder: (BuildContext context, AsyncSnapshot<void> snapshot) {
- if (snapshot.connectionState == ConnectionState.done) {
- if (snapshot.hasError) {
- return _done(context, Text("Error: ${snapshot.error}"));
- } else {
- return _done(context, null);
- }
- } else {
- return const CircularProgressIndicator();
- }
- },
- );
- }
-
- Widget _done(BuildContext context, Widget? error) {
- final theme = context.watch<AppTheme>();
- return Container(
- padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
- decoration: BoxDecoration(borderRadius: BorderRadius.circular(25.0), color: theme.main1),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- const Icon(Icons.check),
- const SizedBox(width: 12.0),
- (error == null) ? Text(LocaleKeys.questionBubble_debug_success.tr()) : error
- ],
- ),
- );
- }
-
- void show() {
- getIt<FToast>().showToast(
- child: this,
- gravity: ToastGravity.BOTTOM,
- toastDuration: const Duration(seconds: 3),
- );
+ showMessageToast(LocaleKeys.questionBubble_debug_success.tr());
}
Future<String> _getDeviceInfo() async {