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 new database on mobile platform (AppFlowy-IO#3788)
* chore: downgrade clipboard package * fix: update i18n in the favorite page * fix: update the favorite icon * feat: support add new database * chore: disable cache in unit test * chore: bump version 0.3.7
- Loading branch information
Showing
19 changed files
with
324 additions
and
70 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
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
File renamed without changes.
105 changes: 105 additions & 0 deletions
105
...tend/appflowy_flutter/lib/mobile/presentation/bottom_sheet/bottom_sheet_add_new_page.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 |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import 'package:appflowy/generated/flowy_svgs.g.dart'; | ||
import 'package:appflowy/generated/locale_keys.g.dart'; | ||
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_action_widget.dart'; | ||
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_drag_handler.dart'; | ||
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_view_item_header.dart'; | ||
import 'package:appflowy_backend/protobuf/flowy-folder2/protobuf.dart'; | ||
import 'package:easy_localization/easy_localization.dart'; | ||
import 'package:flowy_infra_ui/flowy_infra_ui.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class AddNewPageWidgetBottomSheet extends StatelessWidget { | ||
const AddNewPageWidgetBottomSheet({ | ||
super.key, | ||
required this.view, | ||
required this.onAction, | ||
}); | ||
|
||
final ViewPB view; | ||
final void Function(ViewLayoutPB layout) onAction; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
// drag handler | ||
const MobileBottomSheetDragHandler(), | ||
|
||
// header | ||
MobileViewItemBottomSheetHeader( | ||
showBackButton: false, | ||
view: view, | ||
onBack: () {}, | ||
), | ||
const VSpace(8.0), | ||
const Divider(), | ||
|
||
// body | ||
_AddNewPageBody( | ||
onAction: onAction, | ||
), | ||
const VSpace(24.0), | ||
], | ||
); | ||
} | ||
} | ||
|
||
class _AddNewPageBody extends StatelessWidget { | ||
const _AddNewPageBody({ | ||
required this.onAction, | ||
}); | ||
|
||
final void Function(ViewLayoutPB layout) onAction; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
mainAxisSize: MainAxisSize.min, | ||
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | ||
children: [ | ||
// rename, duplicate | ||
Row( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
Expanded( | ||
child: BottomSheetActionWidget( | ||
svg: FlowySvgs.documents_s, | ||
text: LocaleKeys.newDocumentText.tr(), | ||
onTap: () => onAction(ViewLayoutPB.Document), | ||
), | ||
), | ||
Expanded( | ||
child: BottomSheetActionWidget( | ||
svg: FlowySvgs.grid_s, | ||
text: LocaleKeys.newGridText.tr(), | ||
onTap: () => onAction(ViewLayoutPB.Grid), | ||
), | ||
), | ||
], | ||
), | ||
|
||
// share, delete | ||
Row( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
Expanded( | ||
child: BottomSheetActionWidget( | ||
svg: FlowySvgs.board_s, | ||
text: LocaleKeys.newBoardText.tr(), | ||
onTap: () => onAction(ViewLayoutPB.Board), | ||
), | ||
), | ||
Expanded( | ||
child: BottomSheetActionWidget( | ||
svg: FlowySvgs.date_s, | ||
text: LocaleKeys.newCalendarText.tr(), | ||
onTap: () => onAction(ViewLayoutPB.Calendar), | ||
), | ||
), | ||
], | ||
), | ||
], | ||
); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...tend/appflowy_flutter/lib/mobile/presentation/bottom_sheet/bottom_sheet_drag_handler.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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class MobileBottomSheetDragHandler extends StatelessWidget { | ||
const MobileBottomSheetDragHandler({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Padding( | ||
padding: const EdgeInsets.only(top: 12, bottom: 12.0), | ||
child: Container( | ||
width: 64, | ||
height: 4, | ||
decoration: BoxDecoration( | ||
borderRadius: BorderRadius.circular(2.0), | ||
color: Colors.grey, | ||
), | ||
), | ||
); | ||
} | ||
} |
File renamed without changes.
126 changes: 126 additions & 0 deletions
126
frontend/appflowy_flutter/lib/mobile/presentation/bottom_sheet/bottom_sheet_view_item.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 |
---|---|---|
@@ -0,0 +1,126 @@ | ||
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'; | ||
|
||
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(24.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.read<ViewBloc>().add(const ViewEvent.duplicate()); | ||
context.pop(); | ||
break; | ||
case MobileViewItemBottomSheetBodyAction.share: | ||
// unimplemented | ||
context.pop(); | ||
break; | ||
case MobileViewItemBottomSheetBodyAction.delete: | ||
context.read<ViewBloc>().add(const ViewEvent.delete()); | ||
context.pop(); | ||
break; | ||
case MobileViewItemBottomSheetBodyAction.addToFavorites: | ||
case MobileViewItemBottomSheetBodyAction.removeFromFavorites: | ||
context | ||
.read<FavoriteBloc>() | ||
.add(FavoriteEvent.toggle(widget.view)); | ||
context.pop(); | ||
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(); | ||
}, | ||
); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ottom_sheet/mobile_bottom_sheet_body.dart → ...om_sheet/bottom_sheet_view_item_body.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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...end/appflowy_flutter/lib/mobile/presentation/bottom_sheet/default_mobile_action_pane.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
Oops, something went wrong.