remove store from being a property. also better animation
This commit is contained in:
parent
e3b561835b
commit
b2ef0883e3
|
@ -42,42 +42,53 @@ enum HeaderLevel {
|
||||||
class EditorToolbar extends HookWidget {
|
class EditorToolbar extends HookWidget {
|
||||||
final TextEditingController controller;
|
final TextEditingController controller;
|
||||||
final String instanceHost;
|
final String instanceHost;
|
||||||
final EditorToolbarStore store;
|
|
||||||
final FocusNode editorFocusNode;
|
final FocusNode editorFocusNode;
|
||||||
static const _height = 50.0;
|
static const _height = 50.0;
|
||||||
|
|
||||||
EditorToolbar({
|
const EditorToolbar({
|
||||||
required this.controller,
|
required this.controller,
|
||||||
required this.instanceHost,
|
required this.instanceHost,
|
||||||
required this.editorFocusNode,
|
required this.editorFocusNode,
|
||||||
}) : store = EditorToolbarStore(instanceHost);
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final visible = useListenable(editorFocusNode).hasFocus;
|
final visible = useListenable(editorFocusNode).hasFocus;
|
||||||
|
|
||||||
return MobxProvider(
|
return MobxProvider(
|
||||||
create: (context) => store,
|
create: (context) => EditorToolbarStore(instanceHost),
|
||||||
child: AsyncStoreListener(
|
child: ObserverBuilder<EditorToolbarStore>(builder: (context, store) {
|
||||||
asyncStore: store.imageUploadState,
|
return AsyncStoreListener(
|
||||||
child: AnimatedSwitcher(
|
asyncStore: store.imageUploadState,
|
||||||
duration: const Duration(milliseconds: 200),
|
child: AnimatedSwitcher(
|
||||||
child: visible
|
duration: kThemeAnimationDuration,
|
||||||
? Container(
|
transitionBuilder: (child, animation) {
|
||||||
height: _height,
|
final offsetAnimation =
|
||||||
width: double.infinity,
|
Tween<Offset>(begin: const Offset(0, 1.5), end: Offset.zero)
|
||||||
color: Theme.of(context).canvasColor,
|
.animate(animation);
|
||||||
child: SingleChildScrollView(
|
|
||||||
scrollDirection: Axis.horizontal,
|
return SlideTransition(
|
||||||
child: _ToolbarBody(
|
position: offsetAnimation,
|
||||||
controller: controller,
|
child: child,
|
||||||
instanceHost: instanceHost,
|
);
|
||||||
|
},
|
||||||
|
child: visible
|
||||||
|
? Container(
|
||||||
|
height: _height,
|
||||||
|
width: double.infinity,
|
||||||
|
color: Theme.of(context).canvasColor,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
child: _ToolbarBody(
|
||||||
|
controller: controller,
|
||||||
|
instanceHost: instanceHost,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
)
|
: const SizedBox.shrink(),
|
||||||
: const SizedBox.shrink(),
|
),
|
||||||
),
|
);
|
||||||
),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue