forked from AppFlowy-IO/AppFlowy
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:add toast in trash and confirm dialog + fix issues from launch r…
…eview (AppFlowy-IO#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 <[email protected]>
- Loading branch information
Showing
25 changed files
with
592 additions
and
572 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
155 changes: 9 additions & 146 deletions
155
frontend/appflowy_flutter/lib/mobile/presentation/bottom_sheet/bottom_sheet.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,146 +1,9 @@ | ||
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_drag_handler.dart'; | ||
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_rename_widget.dart'; | ||
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_view_item_body.dart'; | ||
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_view_item_header.dart'; | ||
import 'package:appflowy/workspace/application/favorite/favorite_bloc.dart'; | ||
import 'package:appflowy/workspace/application/view/view_bloc.dart'; | ||
import 'package:appflowy_backend/protobuf/flowy-folder2/protobuf.dart'; | ||
import 'package:flowy_infra_ui/flowy_infra_ui.dart' hide WidgetBuilder; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
|
||
Future<void> showMobileBottomSheet({ | ||
required BuildContext context, | ||
required WidgetBuilder builder, | ||
}) async { | ||
showModalBottomSheet( | ||
context: context, | ||
isScrollControlled: true, | ||
enableDrag: true, | ||
useSafeArea: true, | ||
shape: const RoundedRectangleBorder( | ||
borderRadius: BorderRadius.only( | ||
topLeft: Radius.circular(8.0), | ||
topRight: Radius.circular(8.0), | ||
), | ||
), | ||
builder: builder, | ||
); | ||
} | ||
|
||
enum MobileBottomSheetType { | ||
view, | ||
rename, | ||
} | ||
|
||
class MobileViewItemBottomSheet extends StatefulWidget { | ||
const MobileViewItemBottomSheet({ | ||
super.key, | ||
required this.view, | ||
this.defaultType = MobileBottomSheetType.view, | ||
}); | ||
|
||
final ViewPB view; | ||
final MobileBottomSheetType defaultType; | ||
|
||
@override | ||
State<MobileViewItemBottomSheet> createState() => | ||
_MobileViewItemBottomSheetState(); | ||
} | ||
|
||
class _MobileViewItemBottomSheetState extends State<MobileViewItemBottomSheet> { | ||
MobileBottomSheetType type = MobileBottomSheetType.view; | ||
|
||
@override | ||
initState() { | ||
super.initState(); | ||
|
||
type = widget.defaultType; | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
// drag handler | ||
const MobileBottomSheetDragHandler(), | ||
|
||
// header | ||
_buildHeader(), | ||
const VSpace(8.0), | ||
const Divider(), | ||
|
||
// body | ||
_buildBody(), | ||
const VSpace(12.0), | ||
], | ||
); | ||
} | ||
|
||
Widget _buildHeader() { | ||
switch (type) { | ||
case MobileBottomSheetType.view: | ||
case MobileBottomSheetType.rename: | ||
// header | ||
return MobileViewItemBottomSheetHeader( | ||
showBackButton: type != MobileBottomSheetType.view, | ||
view: widget.view, | ||
onBack: () { | ||
setState(() { | ||
type = MobileBottomSheetType.view; | ||
}); | ||
}, | ||
); | ||
} | ||
} | ||
|
||
Widget _buildBody() { | ||
switch (type) { | ||
case MobileBottomSheetType.view: | ||
return MobileViewItemBottomSheetBody( | ||
isFavorite: widget.view.isFavorite, | ||
onAction: (action) { | ||
switch (action) { | ||
case MobileViewItemBottomSheetBodyAction.rename: | ||
setState(() { | ||
type = MobileBottomSheetType.rename; | ||
}); | ||
break; | ||
case MobileViewItemBottomSheetBodyAction.duplicate: | ||
context.pop(); | ||
context.read<ViewBloc>().add(const ViewEvent.duplicate()); | ||
break; | ||
case MobileViewItemBottomSheetBodyAction.share: | ||
// unimplemented | ||
context.pop(); | ||
break; | ||
case MobileViewItemBottomSheetBodyAction.delete: | ||
context.pop(); | ||
context.read<ViewBloc>().add(const ViewEvent.delete()); | ||
|
||
break; | ||
case MobileViewItemBottomSheetBodyAction.addToFavorites: | ||
case MobileViewItemBottomSheetBodyAction.removeFromFavorites: | ||
context.pop(); | ||
context | ||
.read<FavoriteBloc>() | ||
.add(FavoriteEvent.toggle(widget.view)); | ||
break; | ||
} | ||
}, | ||
); | ||
case MobileBottomSheetType.rename: | ||
return MobileBottomSheetRenameWidget( | ||
name: widget.view.name, | ||
onRename: (name) { | ||
if (name != widget.view.name) { | ||
context.read<ViewBloc>().add(ViewEvent.rename(name)); | ||
} | ||
context.pop(); | ||
}, | ||
); | ||
} | ||
} | ||
} | ||
export 'bottom_sheet_action_widget.dart'; | ||
export 'bottom_sheet_add_new_page.dart'; | ||
export 'bottom_sheet_drag_handler.dart'; | ||
export 'bottom_sheet_rename_widget.dart'; | ||
export 'bottom_sheet_view_item_body.dart'; | ||
export 'bottom_sheet_view_item_header.dart'; | ||
export 'bottom_sheet_view_page.dart'; | ||
export 'default_mobile_action_pane.dart'; | ||
export 'show_mobile_bottom_sheet.dart'; |
46 changes: 16 additions & 30 deletions
46
...end/appflowy_flutter/lib/mobile/presentation/bottom_sheet/bottom_sheet_action_widget.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,37 @@ | ||
import 'package:appflowy/generated/flowy_svgs.g.dart'; | ||
import 'package:appflowy/mobile/presentation/base/box_container.dart'; | ||
import 'package:flowy_infra_ui/flowy_infra_ui.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/services.dart'; | ||
|
||
class BottomSheetActionWidget extends StatelessWidget { | ||
const BottomSheetActionWidget({ | ||
super.key, | ||
required this.svg, | ||
required this.text, | ||
required this.onTap, | ||
this.iconColor, | ||
}); | ||
|
||
final FlowySvgData svg; | ||
final String text; | ||
final VoidCallback onTap; | ||
final Color? iconColor; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return FlowyBoxContainer( | ||
child: InkWell( | ||
onTap: () { | ||
HapticFeedback.mediumImpact(); | ||
onTap(); | ||
}, | ||
enableFeedback: true, | ||
child: Padding( | ||
padding: const EdgeInsets.symmetric( | ||
vertical: 10.0, | ||
horizontal: 12.0, | ||
), | ||
child: Row( | ||
mainAxisSize: MainAxisSize.min, | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
FlowySvg( | ||
svg, | ||
size: const Size.square(24.0), | ||
blendMode: BlendMode.dst, | ||
), | ||
const HSpace(6.0), | ||
FlowyText(text), | ||
const Spacer(), | ||
], | ||
), | ||
), | ||
final iconColor = | ||
this.iconColor ?? Theme.of(context).colorScheme.onBackground; | ||
|
||
return OutlinedButton.icon( | ||
icon: FlowySvg( | ||
svg, | ||
size: const Size.square(22.0), | ||
color: iconColor, | ||
), | ||
label: Text(text), | ||
style: Theme.of(context) | ||
.outlinedButtonTheme | ||
.style | ||
?.copyWith(alignment: Alignment.centerLeft), | ||
onPressed: onTap, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.