|
@@ -1,16 +1,15 @@
|
|
import 'package:app_flowy/startup/tasks/rust_sdk.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/home/toast.dart';
|
|
import 'package:app_flowy/workspace/presentation/widgets/pop_up_action.dart';
|
|
import 'package:app_flowy/workspace/presentation/widgets/pop_up_action.dart';
|
|
|
|
+import 'package:appflowy_popover/appflowy_popover.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flowy_infra/theme.dart';
|
|
import 'package:flowy_infra/theme.dart';
|
|
-import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
|
|
|
import 'package:flowy_infra_ui/style_widget/button.dart';
|
|
import 'package:flowy_infra_ui/style_widget/button.dart';
|
|
import 'package:flowy_infra_ui/style_widget/text.dart';
|
|
import 'package:flowy_infra_ui/style_widget/text.dart';
|
|
import 'package:flowy_infra_ui/widget/spacing.dart';
|
|
import 'package:flowy_infra_ui/widget/spacing.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:provider/provider.dart';
|
|
-import 'package:dartz/dartz.dart' as dartz;
|
|
|
|
import 'package:styled_widget/styled_widget.dart';
|
|
import 'package:styled_widget/styled_widget.dart';
|
|
import 'package:package_info_plus/package_info_plus.dart';
|
|
import 'package:package_info_plus/package_info_plus.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
@@ -22,41 +21,59 @@ class QuestionBubble extends StatelessWidget {
|
|
|
|
|
|
@override
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget build(BuildContext context) {
|
|
- final theme = context.watch<AppTheme>();
|
|
|
|
- return SizedBox(
|
|
|
|
|
|
+ return const SizedBox(
|
|
width: 30,
|
|
width: 30,
|
|
height: 30,
|
|
height: 30,
|
|
- child: FlowyTextButton(
|
|
|
|
- '?',
|
|
|
|
- tooltip: LocaleKeys.questionBubble_help.tr(),
|
|
|
|
- fontSize: 12,
|
|
|
|
- fontWeight: FontWeight.w600,
|
|
|
|
- fillColor: theme.selector,
|
|
|
|
- mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
- radius: BorderRadius.circular(10),
|
|
|
|
- onPressed: () {
|
|
|
|
- final actionList = QuestionBubbleActionSheet(onSelected: (result) {
|
|
|
|
- result.fold(() {}, (action) {
|
|
|
|
- switch (action) {
|
|
|
|
- case BubbleAction.whatsNews:
|
|
|
|
- _launchURL("https://www.appflowy.io/whatsnew");
|
|
|
|
- break;
|
|
|
|
- case BubbleAction.help:
|
|
|
|
- _launchURL("https://discord.gg/9Q2xaN37tV");
|
|
|
|
- break;
|
|
|
|
- case BubbleAction.debug:
|
|
|
|
- _DebugToast().show();
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
- actionList.show(
|
|
|
|
- context,
|
|
|
|
- anchorDirection: AnchorDirection.topWithRightAligned,
|
|
|
|
- anchorOffset: const Offset(0, -10),
|
|
|
|
- );
|
|
|
|
- },
|
|
|
|
- ),
|
|
|
|
|
|
+ child: BubbleActionList(),
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+class BubbleActionList extends StatelessWidget {
|
|
|
|
+ const BubbleActionList({Key? key}) : super(key: key);
|
|
|
|
+
|
|
|
|
+ @override
|
|
|
|
+ Widget build(BuildContext context) {
|
|
|
|
+ final theme = context.watch<AppTheme>();
|
|
|
|
+
|
|
|
|
+ final List<PopoverAction> actions = [];
|
|
|
|
+ actions.addAll(
|
|
|
|
+ BubbleAction.values.map((action) => BubbleActionWrapper(action)),
|
|
|
|
+ );
|
|
|
|
+ actions.add(FlowyVersionDescription());
|
|
|
|
+
|
|
|
|
+ return PopoverActionList<PopoverAction>(
|
|
|
|
+ direction: PopoverDirection.topWithRightAligned,
|
|
|
|
+ actions: actions,
|
|
|
|
+ withChild: (controller) {
|
|
|
|
+ return FlowyTextButton(
|
|
|
|
+ '?',
|
|
|
|
+ tooltip: LocaleKeys.questionBubble_help.tr(),
|
|
|
|
+ fontSize: 12,
|
|
|
|
+ fontWeight: FontWeight.w600,
|
|
|
|
+ fillColor: theme.selector,
|
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
+ radius: BorderRadius.circular(10),
|
|
|
|
+ onPressed: () => controller.show(),
|
|
|
|
+ );
|
|
|
|
+ },
|
|
|
|
+ onSelected: (action, controller) {
|
|
|
|
+ if (action is BubbleActionWrapper) {
|
|
|
|
+ switch (action.inner) {
|
|
|
|
+ case BubbleAction.whatsNews:
|
|
|
|
+ _launchURL("https://www.appflowy.io/whatsnew");
|
|
|
|
+ break;
|
|
|
|
+ case BubbleAction.help:
|
|
|
|
+ _launchURL("https://discord.gg/9Q2xaN37tV");
|
|
|
|
+ break;
|
|
|
|
+ case BubbleAction.debug:
|
|
|
|
+ _DebugToast().show();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ controller.close();
|
|
|
|
+ },
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -101,54 +118,9 @@ class _DebugToast {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-class QuestionBubbleActionSheet
|
|
|
|
- with ActionList<BubbleActionWrapper>, FlowyOverlayDelegate {
|
|
|
|
- final Function(dartz.Option<BubbleAction>) onSelected;
|
|
|
|
- final _items =
|
|
|
|
- BubbleAction.values.map((action) => BubbleActionWrapper(action)).toList();
|
|
|
|
-
|
|
|
|
- QuestionBubbleActionSheet({
|
|
|
|
- required this.onSelected,
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- @override
|
|
|
|
- double get itemHeight => 22;
|
|
|
|
-
|
|
|
|
- @override
|
|
|
|
- List<BubbleActionWrapper> get items => _items;
|
|
|
|
-
|
|
|
|
- @override
|
|
|
|
- void Function(dartz.Option<BubbleActionWrapper> p1) get selectCallback =>
|
|
|
|
- (result) {
|
|
|
|
- result.fold(
|
|
|
|
- () => onSelected(dartz.none()),
|
|
|
|
- (wrapper) => onSelected(
|
|
|
|
- dartz.some(wrapper.inner),
|
|
|
|
- ),
|
|
|
|
- );
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- @override
|
|
|
|
- FlowyOverlayDelegate? get delegate => this;
|
|
|
|
-
|
|
|
|
|
|
+class FlowyVersionDescription extends CustomActionCell {
|
|
@override
|
|
@override
|
|
- void didRemove() {
|
|
|
|
- onSelected(dartz.none());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @override
|
|
|
|
- ListOverlayFooter? get footer => ListOverlayFooter(
|
|
|
|
- widget: const FlowyVersionDescription(),
|
|
|
|
- height: 40,
|
|
|
|
- padding: const EdgeInsets.only(top: 6),
|
|
|
|
- );
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-class FlowyVersionDescription extends StatelessWidget {
|
|
|
|
- const FlowyVersionDescription({Key? key}) : super(key: key);
|
|
|
|
-
|
|
|
|
- @override
|
|
|
|
- Widget build(BuildContext context) {
|
|
|
|
|
|
+ Widget buildWithContext(BuildContext context) {
|
|
final theme = context.watch<AppTheme>();
|
|
final theme = context.watch<AppTheme>();
|
|
|
|
|
|
return FutureBuilder(
|
|
return FutureBuilder(
|
|
@@ -165,23 +137,26 @@ class FlowyVersionDescription extends StatelessWidget {
|
|
String version = packageInfo.version;
|
|
String version = packageInfo.version;
|
|
String buildNumber = packageInfo.buildNumber;
|
|
String buildNumber = packageInfo.buildNumber;
|
|
|
|
|
|
- return Column(
|
|
|
|
- mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
- children: [
|
|
|
|
- Divider(height: 1, color: theme.shader6, thickness: 1.0),
|
|
|
|
- const VSpace(6),
|
|
|
|
- FlowyText(
|
|
|
|
- "$appName $version.$buildNumber",
|
|
|
|
- fontSize: 12,
|
|
|
|
- color: theme.shader4,
|
|
|
|
- ),
|
|
|
|
- ],
|
|
|
|
- ).padding(
|
|
|
|
- horizontal: ActionListSizes.itemHPadding + ActionListSizes.hPadding,
|
|
|
|
|
|
+ return SizedBox(
|
|
|
|
+ height: 30,
|
|
|
|
+ child: Column(
|
|
|
|
+ mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
+ children: [
|
|
|
|
+ Divider(height: 1, color: theme.shader6, thickness: 1.0),
|
|
|
|
+ const VSpace(6),
|
|
|
|
+ FlowyText(
|
|
|
|
+ "$appName $version.$buildNumber",
|
|
|
|
+ fontSize: 12,
|
|
|
|
+ color: theme.shader4,
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
|
|
+ ).padding(
|
|
|
|
+ horizontal: ActionListSizes.itemHPadding,
|
|
|
|
+ ),
|
|
);
|
|
);
|
|
} else {
|
|
} else {
|
|
- return const CircularProgressIndicator();
|
|
|
|
|
|
+ return const SizedBox(height: 30);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
);
|
|
);
|
|
@@ -190,7 +165,7 @@ class FlowyVersionDescription extends StatelessWidget {
|
|
|
|
|
|
enum BubbleAction { whatsNews, help, debug }
|
|
enum BubbleAction { whatsNews, help, debug }
|
|
|
|
|
|
-class BubbleActionWrapper extends ActionItem {
|
|
|
|
|
|
+class BubbleActionWrapper extends ActionCell {
|
|
final BubbleAction inner;
|
|
final BubbleAction inner;
|
|
|
|
|
|
BubbleActionWrapper(this.inner);
|
|
BubbleActionWrapper(this.inner);
|