From d117cd6b5bb03ef39f26abee8c8fdfc5a2d898a2 Mon Sep 17 00:00:00 2001 From: Yijing Huang Date: Sat, 3 Feb 2024 10:56:50 -0600 Subject: [PATCH] chore: delete placeholder code and clean code (#4503) --- .../details_placeholder_page.dart | 99 ------------------- .../home/mobile_home_trash_page.dart | 19 ++-- .../lib/mobile/presentation/presentation.dart | 1 - .../setting/notifications_setting_group.dart | 2 +- .../mobile_workspace_start_screen.dart | 6 +- .../appearance/mobile_appearance.dart | 1 - 6 files changed, 14 insertions(+), 114 deletions(-) delete mode 100644 frontend/appflowy_flutter/lib/mobile/presentation/details_placeholder_page.dart diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/details_placeholder_page.dart b/frontend/appflowy_flutter/lib/mobile/presentation/details_placeholder_page.dart deleted file mode 100644 index cef64bc19c..0000000000 --- a/frontend/appflowy_flutter/lib/mobile/presentation/details_placeholder_page.dart +++ /dev/null @@ -1,99 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:go_router/go_router.dart'; - -// TODO(yijing): delete this after implementing the real screen inside bottom navigation bar. -/// For demonstration purposes -class DetailsPlaceholderScreen extends StatefulWidget { - /// Constructs a [DetailsScreen]. - const DetailsPlaceholderScreen({ - required this.label, - this.param, - this.extra, - this.withScaffold = true, - super.key, - }); - - /// The label to display in the center of the screen. - final String label; - - /// Optional param - final String? param; - - /// Optional extra object - final Object? extra; - - /// Wrap in scaffold - final bool withScaffold; - - @override - State createState() => DetailsPlaceholderScreenState(); -} - -/// The state for DetailsScreen -class DetailsPlaceholderScreenState extends State { - int _counter = 0; - - @override - Widget build(BuildContext context) { - if (widget.withScaffold) { - return Scaffold( - appBar: AppBar( - title: Text('Details Screen - ${widget.label}'), - ), - body: _build(context), - ); - } else { - return Container( - color: Theme.of(context).scaffoldBackgroundColor, - child: _build(context), - ); - } - } - - Widget _build(BuildContext context) { - return Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - 'Details for ${widget.label} - Counter: $_counter', - style: Theme.of(context).textTheme.titleLarge, - ), - const Padding(padding: EdgeInsets.all(4)), - TextButton( - onPressed: () { - setState(() { - _counter++; - }); - }, - child: const Text('Increment counter'), - ), - const Padding(padding: EdgeInsets.all(8)), - if (widget.param != null) - Text( - 'Parameter: ${widget.param!}', - style: Theme.of(context).textTheme.titleMedium, - ), - const Padding(padding: EdgeInsets.all(8)), - if (widget.extra != null) - Text( - 'Extra: ${widget.extra!}', - style: Theme.of(context).textTheme.titleMedium, - ), - if (!widget.withScaffold) ...[ - const Padding(padding: EdgeInsets.all(16)), - TextButton( - onPressed: () { - GoRouter.of(context).pop(); - }, - child: const Text( - '< Back', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18), - ), - ), - ], - ], - ), - ); - } -} diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/home/mobile_home_trash_page.dart b/frontend/appflowy_flutter/lib/mobile/presentation/home/mobile_home_trash_page.dart index 7df84cd04f..a9c2f1b933 100644 --- a/frontend/appflowy_flutter/lib/mobile/presentation/home/mobile_home_trash_page.dart +++ b/frontend/appflowy_flutter/lib/mobile/presentation/home/mobile_home_trash_page.dart @@ -164,23 +164,23 @@ class _DeletedFilesListView extends StatelessWidget { padding: const EdgeInsets.symmetric(vertical: 8), child: ListView.builder( itemBuilder: (context, index) { - final object = state.objects[index]; + final deletedFile = state.objects[index]; + return Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4), child: ListTile( - // TODO(Yijing): implement file type after TrashPB has file type + // TODO: show different file type icon, implement this feature after TrashPB has file type field leading: FlowySvg( FlowySvgs.document_s, size: const Size.square(24), color: theme.colorScheme.onSurface, ), title: Text( - object.name, + deletedFile.name, style: theme.textTheme.labelMedium ?.copyWith(color: theme.colorScheme.onBackground), ), horizontalTitleGap: 0, - // TODO(yiing): needs improve by container/surface theme color tileColor: theme.colorScheme.onSurface.withOpacity(0.1), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8), @@ -188,7 +188,6 @@ class _DeletedFilesListView extends StatelessWidget { trailing: Row( mainAxisSize: MainAxisSize.min, children: [ - // TODO(yijing): extract icon button IconButton( splashRadius: 20, icon: FlowySvg( @@ -199,10 +198,10 @@ class _DeletedFilesListView extends StatelessWidget { onPressed: () { context .read() - .add(TrashEvent.putback(object.id)); + .add(TrashEvent.putback(deletedFile.id)); Fluttertoast.showToast( msg: - '${object.name} ${LocaleKeys.trash_mobile_isRestored.tr()}', + '${deletedFile.name} ${LocaleKeys.trash_mobile_isRestored.tr()}', gravity: ToastGravity.BOTTOM, ); }, @@ -215,10 +214,12 @@ class _DeletedFilesListView extends StatelessWidget { color: theme.colorScheme.onSurface, ), onPressed: () { - context.read().add(TrashEvent.delete(object)); + context + .read() + .add(TrashEvent.delete(deletedFile)); Fluttertoast.showToast( msg: - '${object.name} ${LocaleKeys.trash_mobile_isDeleted.tr()}', + '${deletedFile.name} ${LocaleKeys.trash_mobile_isDeleted.tr()}', gravity: ToastGravity.BOTTOM, ); }, diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/presentation.dart b/frontend/appflowy_flutter/lib/mobile/presentation/presentation.dart index 909b4dbdd8..69a3ae503c 100644 --- a/frontend/appflowy_flutter/lib/mobile/presentation/presentation.dart +++ b/frontend/appflowy_flutter/lib/mobile/presentation/presentation.dart @@ -1,4 +1,3 @@ -export 'details_placeholder_page.dart'; export 'editor/mobile_editor_screen.dart'; export 'home/home.dart'; export 'mobile_bottom_navigation_bar.dart'; diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/setting/notifications_setting_group.dart b/frontend/appflowy_flutter/lib/mobile/presentation/setting/notifications_setting_group.dart index f0892a5f50..8813afc3b2 100644 --- a/frontend/appflowy_flutter/lib/mobile/presentation/setting/notifications_setting_group.dart +++ b/frontend/appflowy_flutter/lib/mobile/presentation/setting/notifications_setting_group.dart @@ -15,7 +15,7 @@ class NotificationsSettingGroup extends StatefulWidget { } class _NotificationsSettingGroupState extends State { - // TODO(yijing):remove this after notification page is implemented + // TODO:remove this after notification page is implemented bool isPushNotificationOn = false; @override diff --git a/frontend/appflowy_flutter/lib/user/presentation/screens/workspace_start_screen/mobile_workspace_start_screen.dart b/frontend/appflowy_flutter/lib/user/presentation/screens/workspace_start_screen/mobile_workspace_start_screen.dart index 9a3ec4f5ba..6c95d1076c 100644 --- a/frontend/appflowy_flutter/lib/user/presentation/screens/workspace_start_screen/mobile_workspace_start_screen.dart +++ b/frontend/appflowy_flutter/lib/user/presentation/screens/workspace_start_screen/mobile_workspace_start_screen.dart @@ -8,7 +8,7 @@ import 'package:flowy_infra_ui/widget/error_page.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -// TODO(yijing): needs refactor when multiple workspaces are supported +// TODO: needs refactor when multiple workspaces are supported class MobileWorkspaceStartScreen extends StatefulWidget { const MobileWorkspaceStartScreen({ super.key, @@ -64,7 +64,7 @@ class _MobileWorkspaceStartScreenState const VSpace(spacing * 4), DropdownMenu( width: size.width - 100, - // TODO(yijing): The following code cause the bad state error, need to fix it + // TODO: The following code cause the bad state error, need to fix it // initialSelection: widget.workspaceState.workspaces.first, label: const Text('Workspace'), controller: controller, @@ -76,7 +76,7 @@ class _MobileWorkspaceStartScreenState }, ), const Spacer(), - // TODO(yijing): needs to implement create workspace in the future + // TODO: needs to implement create workspace in the future // TextButton( // child: Text( // LocaleKeys.workspace_create.tr(), diff --git a/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/mobile_appearance.dart b/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/mobile_appearance.dart index c3863d5721..8900ae2256 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/mobile_appearance.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/mobile_appearance.dart @@ -64,7 +64,6 @@ class MobileAppearance extends BaseAppearance { brightness: brightness, primary: _primaryColor, onPrimary: Colors.black, - // TODO(yijing): add color later secondary: const Color(0xff2d2d2d), //temp onSecondary: Colors.white, tertiary: const Color(0xff858585), // temp