mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-25 16:19:58 +08:00
BottomBar: Use widgets instead of functions
Improves performance
This commit is contained in:
@ -49,7 +49,7 @@ class EditorBottomBar extends StatelessWidget {
|
||||
onPressed: () {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (c) => _buildAddBottomSheet(c, editor, editorState),
|
||||
builder: (c) => AddBottomSheet(editor, editorState),
|
||||
elevation: 0,
|
||||
);
|
||||
},
|
||||
@ -60,13 +60,12 @@ class EditorBottomBar extends StatelessWidget {
|
||||
onPressed: () {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (c) => _buildBottomMenuSheet(
|
||||
c,
|
||||
editor,
|
||||
editorState,
|
||||
zenMode,
|
||||
onZenModeChanged,
|
||||
metaDataEditable,
|
||||
builder: (c) => BottomMenuSheet(
|
||||
editor: editor,
|
||||
editorState: editorState,
|
||||
zenModeEnabled: zenMode,
|
||||
zenModeChanged: onZenModeChanged,
|
||||
metaDataEditable: metaDataEditable,
|
||||
),
|
||||
elevation: 0,
|
||||
);
|
||||
@ -121,11 +120,15 @@ class EditorBottomBar extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildAddBottomSheet(
|
||||
BuildContext context,
|
||||
Editor editor,
|
||||
EditorState editorState,
|
||||
) {
|
||||
class AddBottomSheet extends StatelessWidget {
|
||||
final Editor editor;
|
||||
final EditorState editorState;
|
||||
|
||||
const AddBottomSheet(this.editor, this.editorState, {Key? key})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@ -173,16 +176,27 @@ Widget _buildAddBottomSheet(
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildBottomMenuSheet(
|
||||
BuildContext context,
|
||||
Editor editor,
|
||||
EditorState editorState,
|
||||
bool zenModeEnabled,
|
||||
Func0<void> zenModeChanged,
|
||||
bool metaDataEditable,
|
||||
) {
|
||||
class BottomMenuSheet extends StatelessWidget {
|
||||
final Editor editor;
|
||||
final EditorState editorState;
|
||||
final bool zenModeEnabled;
|
||||
final Func0<void> zenModeChanged;
|
||||
final bool metaDataEditable;
|
||||
|
||||
const BottomMenuSheet({
|
||||
Key? key,
|
||||
required this.editor,
|
||||
required this.editorState,
|
||||
required this.zenModeEnabled,
|
||||
required this.zenModeChanged,
|
||||
required this.metaDataEditable,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@ -248,4 +262,5 @@ Widget _buildBottomMenuSheet(
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user