feat:add toast in trash and confirm dialog + fix issues from launch review (#3787)

* chore: improve trash button

* feat: improve restore all&delete all

* refactor: add showFlowyMobileConfirmDialog

* feat: add toast in delete/restore single file

* refactor: refactor to TrashActionType enum

* fix: text invisible in signin page in dark mode

* feat: add FlowyMobileErrorStateContainer to display error state

* refactor: add FlowyMobileStateContainer to handle empty or error state

- Replace MobileErrorPage by FlowyMobileStateContainer.error
- Implement app version in reporting issue on github
- Implement FlowyMobileStateContainer in trash,setting,favorite and mobile view page

* refactor: unify bottom sheet style

- Unify bottom sheet style in add new page, page action, and trash action
- Add icon color in BottomSheetActionWidget for future use
- Add theme color in MobileBottomSheetDragHandle

* chore: unify Appbar style

* chore: remove the more button when trash list is empty

* fix: show bottom sheet error

* fix: fix merge and ui issue

* refactor: refactor ViewPageBottomSheet and origanize code

* chore: add icon color for favorite button

* fix: add missing icon color and delete comments

---------

Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io>
This commit is contained in:
Yijing Huang
2023-11-02 11:15:15 -07:00
committed by GitHub
parent a93d325e6a
commit 73ea1a0685
25 changed files with 594 additions and 574 deletions

View File

@ -0,0 +1,102 @@
import 'dart:io';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:package_info_plus/package_info_plus.dart';
enum _FlowyMobileStateContainerType {
info,
error,
}
/// Used to display info(like empty state) or error state
/// error state has two buttons to report issue with error message or reach out on discord
class FlowyMobileStateContainer extends StatelessWidget {
const FlowyMobileStateContainer.error({
this.emoji,
required this.title,
this.description,
required this.errorMsg,
super.key,
}) : _stateType = _FlowyMobileStateContainerType.error;
const FlowyMobileStateContainer.info({
this.emoji,
required this.title,
this.description,
super.key,
}) : errorMsg = null,
_stateType = _FlowyMobileStateContainerType.info;
final String? emoji;
final String title;
final String? description;
final String? errorMsg;
final _FlowyMobileStateContainerType _stateType;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return SizedBox.expand(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 32),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
emoji ?? '',
style: const TextStyle(fontSize: 40),
),
const SizedBox(height: 8),
Text(
title,
style: theme.textTheme.labelLarge,
),
const SizedBox(height: 4),
Text(
description ?? '',
style: theme.textTheme.bodyMedium?.copyWith(
color: theme.hintColor,
),
),
if (_stateType == _FlowyMobileStateContainerType.error) ...[
const SizedBox(height: 8),
FutureBuilder(
future: PackageInfo.fromPlatform(),
builder: (context, snapshot) {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
OutlinedButton(
onPressed: () {
final String? version = snapshot.data?.version;
final String os = Platform.operatingSystem;
safeLaunchUrl(
'https://github.com/AppFlowy-IO/AppFlowy/issues/new?assignees=&labels=&projects=&template=bug_report.yaml&title=[Bug]%20Mobile:%20&version=$version&os=$os&context=Error%20log:%20$errorMsg',
);
},
child: Text(
LocaleKeys.workspace_errorActions_reportIssue.tr(),
),
),
OutlinedButton(
onPressed: () =>
safeLaunchUrl('https://discord.gg/JucBXeU2FE'),
child: Text(
LocaleKeys.workspace_errorActions_reachOut.tr(),
),
),
],
);
},
)
]
],
),
),
);
}
}

View File

@ -0,0 +1,62 @@
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
///show the dialog to confirm one single action
///[onActionButtonPressed] and [onCancelButtonPressed] end with close the dialog
Future<T?> showFlowyMobileConfirmDialog<T>(
BuildContext context, {
String? title,
String? content,
required String actionButtonTitle,
Color? actionButtonColor,
String? cancelButtonTitle,
required void Function()? onActionButtonPressed,
void Function()? onCancelButtonPressed,
}) async {
return showDialog(
context: context,
builder: (dialogContext) {
final foregroundColor = Theme.of(context).colorScheme.onSurface;
return AlertDialog(
title: Text(
title ?? "",
),
content: Text(
content ?? "",
),
actions: [
TextButton(
child: Text(
actionButtonTitle,
style: TextStyle(
color: actionButtonColor ?? foregroundColor,
),
),
onPressed: () {
onActionButtonPressed?.call();
// we cannot use dialogContext.pop() here because this is no GoRouter in dialogContext. Use Navigator instead to close the dialog.
Navigator.of(
dialogContext,
).pop();
},
),
TextButton(
child: Text(
cancelButtonTitle ?? LocaleKeys.button_cancel.tr(),
style: TextStyle(
color: foregroundColor,
),
),
onPressed: () {
onCancelButtonPressed?.call();
Navigator.of(
dialogContext,
).pop();
},
),
],
);
},
);
}

View File

@ -0,0 +1,3 @@
export 'show_flowy_mobile_confirm_dialog.dart';
export 'show_flowy_mobile_bottom_sheet.dart';
export 'flowy_mobile_state_container.dart';